aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2017-05-08 11:48:45 -0700
committerMartin Braun <martin.braun@ettus.com>2017-06-26 13:25:38 -0700
commite1b686318fab1cb2b11542c28d82d810d1fc63a2 (patch)
tree66673f1bb3f7ddae30465063fc6b30bee2d2d2a2 /host
parent0b403340c3e924b642ba72679a8a1bfa23bbfd4c (diff)
downloaduhd-e1b686318fab1cb2b11542c28d82d810d1fc63a2.tar.gz
uhd-e1b686318fab1cb2b11542c28d82d810d1fc63a2.tar.bz2
uhd-e1b686318fab1cb2b11542c28d82d810d1fc63a2.zip
X300: Fix DAC sync
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/x300/x300_adc_dac_utils.cpp47
-rw-r--r--host/lib/usrp/x300/x300_radio_ctrl_impl.cpp20
2 files changed, 14 insertions, 53 deletions
diff --git a/host/lib/usrp/x300/x300_adc_dac_utils.cpp b/host/lib/usrp/x300/x300_adc_dac_utils.cpp
index 6fd0ca50b..a6815286e 100644
--- a/host/lib/usrp/x300/x300_adc_dac_utils.cpp
+++ b/host/lib/usrp/x300/x300_adc_dac_utils.cpp
@@ -21,53 +21,6 @@
using namespace uhd::usrp::x300;
/***********************************************************************
- * DAC: Reset and synchronization operations
- **********************************************************************/
-
-void x300_impl::synchronize_dacs(const std::vector<radio_perifs_t*>& radios)
-{
- if (radios.size() < 2) return; //Nothing to synchronize
-
- //**PRECONDITION**
- //This function assumes that all the VITA times in "radios" are synchronized
- //to a common reference. Currently, this function is called in get_tx_stream
- //which also has the same precondition.
-
- //Reinitialize and resync all DACs
- for (size_t i = 0; i < radios.size(); i++) {
- radios[i]->dac->reset();
- }
-
- //Get a rough estimate of the cumulative command latency
- boost::posix_time::ptime t_start = boost::posix_time::microsec_clock::local_time();
- for (size_t i = 0; i < radios.size(); i++) {
- radios[i]->ctrl->peek64(uhd::usrp::radio::RB64_TIME_NOW); //Discard value. We are just timing the call
- }
- boost::posix_time::time_duration t_elapsed =
- boost::posix_time::microsec_clock::local_time() - t_start;
-
- //Add 100% of headroom + uncertaintly to the command time
- uint64_t t_sync_us = (t_elapsed.total_microseconds() * 2) + 13000 /*Scheduler latency*/;
-
- //Pick radios[0] as the time reference.
- uhd::time_spec_t sync_time =
- radios[0]->time64->get_time_now() + uhd::time_spec_t(((double)t_sync_us)/1e6);
-
- //Send the sync command
- for (size_t i = 0; i < radios.size(); i++) {
- radios[i]->ctrl->set_time(sync_time);
- radios[i]->ctrl->poke32(uhd::usrp::radio::sr_addr(uhd::usrp::radio::DACSYNC), 0x1); //Arm FRAMEP/N sync pulse
- radios[i]->ctrl->set_time(uhd::time_spec_t(0.0)); //Clear command time
- }
-
- //Wait and check status
- boost::this_thread::sleep(boost::posix_time::microseconds(t_sync_us));
- for (size_t i = 0; i < radios.size(); i++) {
- radios[i]->dac->verify_sync();
- }
-}
-
-/***********************************************************************
* ADC: Self-test operations
**********************************************************************/
diff --git a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp
index 69eb51f55..a3bc2e691 100644
--- a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp
+++ b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp
@@ -608,8 +608,14 @@ void x300_radio_ctrl_impl::synchronize_dacs(const std::vector<x300_radio_ctrl_im
boost::posix_time::time_duration t_elapsed =
boost::posix_time::microsec_clock::local_time() - t_start;
- //Add 100% of headroom + uncertaintly to the command time
- uint64_t t_sync_us = (t_elapsed.total_microseconds() * 2) + 13000 /*Scheduler latency*/;
+ //Set tick rate and make sure FRAMEP/N is 0
+ for (size_t i = 0; i < radios.size(); i++) {
+ radios[i]->set_command_tick_rate(radios[i]->_radio_clk_rate, IO_MASTER_RADIO);
+ radios[i]->_regs->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::DAC_SYNC, 0);
+ }
+
+ //Add 100% of headroom + uncertainty to the command time
+ uint64_t t_sync_us = (t_elapsed.total_microseconds() * 2) + 16000 /*Scheduler latency*/;
//Pick radios[0] as the time reference.
uhd::time_spec_t sync_time =
@@ -617,15 +623,17 @@ void x300_radio_ctrl_impl::synchronize_dacs(const std::vector<x300_radio_ctrl_im
//Send the sync command
for (size_t i = 0; i < radios.size(); i++) {
- radios[i]->set_command_tick_rate(radios[i]->_radio_clk_rate, IO_MASTER_RADIO);
- radios[i]->_regs->misc_outs_reg.set(radio_regmap_t::misc_outs_reg_t::DAC_SYNC, 0);
radios[i]->set_command_time(sync_time, IO_MASTER_RADIO);
//Arm FRAMEP/N sync pulse by asserting a rising edge
- radios[i]->_regs->misc_outs_reg.set(radio_regmap_t::misc_outs_reg_t::DAC_SYNC, 1);
- radios[i]->_regs->misc_outs_reg.set(radio_regmap_t::misc_outs_reg_t::DAC_SYNC, 0);
+ radios[i]->_regs->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::DAC_SYNC, 1);
radios[i]->set_command_time(uhd::time_spec_t(0.0), IO_MASTER_RADIO);
}
+ //Reset FRAMEP/N to 0
+ for (size_t i = 0; i < radios.size(); i++) {
+ radios[i]->_regs->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::DAC_SYNC, 0);
+ }
+
//Wait and check status
boost::this_thread::sleep(boost::posix_time::microseconds(t_sync_us));
for (size_t i = 0; i < radios.size(); i++) {