diff options
author | Sugandha Gupta <sugandha.gupta@ettus.com> | 2018-08-01 10:47:01 -0700 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2018-08-02 16:07:15 -0700 |
commit | 61ac937294a8e91163e2635365ede10ed40ec3b8 (patch) | |
tree | dfc7642f4d75e4591e8e56980c607c9eb90d5854 /mpm/python | |
parent | 327ea7540b653bfc2994e01f7f3ea2a0ca37b870 (diff) | |
download | uhd-61ac937294a8e91163e2635365ede10ed40ec3b8.tar.gz uhd-61ac937294a8e91163e2635365ede10ed40ec3b8.tar.bz2 uhd-61ac937294a8e91163e2635365ede10ed40ec3b8.zip |
adf400x: Fix adf400x driver for ref counter and charge pump mode
- For different ref clock frequencies, the ref_counter should change
and not the n_counter.
- The charge pump should be set to normal mode and tristate as that
would prevent the PLL to lock.
Diffstat (limited to 'mpm/python')
-rw-r--r-- | mpm/python/usrp_mpm/chips/adf400x.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/mpm/python/usrp_mpm/chips/adf400x.py b/mpm/python/usrp_mpm/chips/adf400x.py index 4a33a33a9..5f200f30f 100644 --- a/mpm/python/usrp_mpm/chips/adf400x.py +++ b/mpm/python/usrp_mpm/chips/adf400x.py @@ -34,17 +34,20 @@ class ADF400x(object): # Instantiate our own copy of the register mapping and update some values self.adf400x_regs = ADF400xRegs() - self.adf400x_regs.ref_counter = 1 + # N counter = fVCO/PFD + self.adf400x_regs.n_counter = 4 self.adf400x_regs.charge_pump_current_1 = 7 self.adf400x_regs.charge_pump_current_2 = 7 + # Set MUXOUT to Digital Lock Detect self.adf400x_regs.muxout = ADF400xRegs.MUXOUT_DLD self.adf400x_regs.counter_reset = ADF400xRegs.COUNTER_RESET_NORMAL self.adf400x_regs.phase_detector_polarity = ADF400xRegs.PHASE_DETECTOR_POLARITY_POS - self.adf400x_regs.charge_pump_mode = ADF400xRegs.CHARGE_PUMP_TRISTATE + # Turn on Charge Pump + self.adf400x_regs.charge_pump_mode = ADF400xRegs.CHARGE_PUMP_NORMAL # Set the N counter if freq is None: freq = DEFAULT_REF_CLOCK_FREQ - self._set_n_counter(freq) + self._set_ref_counter(freq) # Now initialize the ADF400x self.program_regs() @@ -76,19 +79,24 @@ class ADF400x(object): self.adf400x_regs.charge_pump_mode = ADF400xRegs.CHARGE_PUMP_TRISTATE self.program_regs() - def _set_n_counter(self, freq): - n_counter = int(BASE_REF_CLOCK_FREQ / freq) - if self.adf400x_regs.n_counter == n_counter: - self.log.trace("No change to N counter value ({}); returning early".format(n_counter)) + def _set_ref_counter(self, freq): + """ + Set R Counter based on reference frequency + """ + # Calculate R counter fVCO = N * (fREF/R) + ref_counter = int(self.adf400x_regs.n_counter * freq / BASE_REF_CLOCK_FREQ) + if self.adf400x_regs.ref_counter == ref_counter: + self.log.trace("No change to ref counter value ({}); \ + returning early".format(ref_counter)) return - self.log.trace("Setting N counter to {}".format(n_counter)) + self.log.trace("Setting ref counter to {}".format(ref_counter)) # Limits from the datasheet - assert 1 <= n_counter <= 8191 - self.adf400x_regs.n_counter = n_counter + assert 1 <= ref_counter <= 16383 + self.adf400x_regs.ref_counter = ref_counter def set_ref_freq(self, freq): """Set the input reference frequency""" - self._set_n_counter(freq) + self._set_ref_counter(freq) self.program_regs() |