diff options
author | Josh Blum <josh@joshknows.com> | 2011-01-29 21:03:29 +0000 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-01-29 21:03:29 +0000 |
commit | 572a64f0acb459583abfccbc8288158822fa2f77 (patch) | |
tree | 4f75150a25958a646514b4a6e60ec7f57dd174bd /host/lib/usrp | |
parent | ef6331f622aacadf233369637e08bfb7f2e6995a (diff) | |
download | uhd-572a64f0acb459583abfccbc8288158822fa2f77.tar.gz uhd-572a64f0acb459583abfccbc8288158822fa2f77.tar.bz2 uhd-572a64f0acb459583abfccbc8288158822fa2f77.zip |
usrp-e100: clock control use boost math gcd for divider calculation
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/usrp_e100/clock_ctrl.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index e2c4889bc..dd7f8507b 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -24,6 +24,7 @@ #include <boost/foreach.hpp> #include <boost/format.hpp> #include <boost/operators.hpp> +#include <boost/math/common_factor_rt.hpp> //gcd #include <algorithm> #include <utility> #include <iostream> @@ -216,12 +217,14 @@ public: _chan_rate = rate; _out_rate = rate; - _ad9522_regs.enable_clock_doubler = 1; + _ad9522_regs.enable_clock_doubler = 1; //doubler always on + const double ref_rate = REFERENCE_INPUT_RATE*2; - //bypass prescalers and counters == 1 - _ad9522_regs.set_r_counter(125); + //bypass prescaler such that N = B + long gcd = boost::math::gcd(long(ref_rate), long(rate)); + _ad9522_regs.set_r_counter(int(ref_rate/gcd)); _ad9522_regs.a_counter = 0; - _ad9522_regs.set_b_counter(384); + _ad9522_regs.set_b_counter(int(rate/gcd)); _ad9522_regs.prescaler_p = ad9522_regs_t::PRESCALER_P_DIV1; //setup external vcxo |