aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2/clock_control.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-04-13 14:23:36 -0700
committerJosh Blum <josh@joshknows.com>2010-04-13 14:23:36 -0700
commit5b5696cbb747c87775b8e90059c951ac51ddca5a (patch)
tree9f6d61da6ab2ba9097b6c81867de1cf392f8cdfe /host/lib/usrp/usrp2/clock_control.cpp
parentad0d641b38dd79cc29b4ca7a3a02c02e35eb8f71 (diff)
downloaduhd-5b5696cbb747c87775b8e90059c951ac51ddca5a.tar.gz
uhd-5b5696cbb747c87775b8e90059c951ac51ddca5a.tar.bz2
uhd-5b5696cbb747c87775b8e90059c951ac51ddca5a.zip
added more clock config, takes care of external reference
Diffstat (limited to 'host/lib/usrp/usrp2/clock_control.cpp')
-rw-r--r--host/lib/usrp/usrp2/clock_control.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/host/lib/usrp/usrp2/clock_control.cpp b/host/lib/usrp/usrp2/clock_control.cpp
index 74db5958a..4acc1bf29 100644
--- a/host/lib/usrp/usrp2/clock_control.cpp
+++ b/host/lib/usrp/usrp2/clock_control.cpp
@@ -30,6 +30,32 @@ class clock_control_ad9510 : public clock_control{
public:
clock_control_ad9510(usrp2_impl *impl){
_impl = impl;
+
+ _ad9510_regs.cp_current_setting = ad9510_regs_t::CP_CURRENT_SETTING_3_0MA;
+ this->write_reg(0x09);
+
+ //100mhz = 10mhz/R * (P*B + A)
+
+ _ad9510_regs.pll_power_down = ad9510_regs_t::PLL_POWER_DOWN_NORMAL;
+ _ad9510_regs.prescaler_value = ad9510_regs_t::PRESCALER_VALUE_DIV2;
+ this->write_reg(0x0A);
+
+ _ad9510_regs.acounter = 0;
+ this->write_reg(0x04);
+
+ _ad9510_regs.bcounter_msb = 0;
+ _ad9510_regs.bcounter_lsb = 5;
+ this->write_reg(0x05);
+ this->write_reg(0x06);
+
+ _ad9510_regs.ref_counter_msb = 0;
+ _ad9510_regs.ref_counter_lsb = 1; // r divider = 1
+ this->write_reg(0x0B);
+ this->write_reg(0x0C);
+
+ /* regs will be updated in commands below */
+
+ this->enable_external_ref(false);
this->enable_rx_dboard_clock(false);
this->enable_tx_dboard_clock(false);
}
@@ -54,6 +80,20 @@ public:
this->update_regs();
}
+ /*!
+ * If we are to use an external reference, enable the charge pump.
+ * \param enb true to enable the CP
+ */
+ void enable_external_ref(bool enb){
+ _ad9510_regs.charge_pump_mode = (enb)?
+ ad9510_regs_t::CHARGE_PUMP_MODE_NORMAL :
+ ad9510_regs_t::CHARGE_PUMP_MODE_3STATE ;
+ _ad9510_regs.pll_mux_control = ad9510_regs_t::PLL_MUX_CONTROL_DLD_HIGH;
+ _ad9510_regs.pfd_polarity = ad9510_regs_t::PFD_POLARITY_POS;
+ this->write_reg(0x08);
+ this->update_regs();
+ }
+
private:
/*!
* Write a single register to the spi regs.