aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/db_rfx.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-04-18 10:58:50 -0700
committerJosh Blum <josh@joshknows.com>2011-04-18 10:58:50 -0700
commit1304340f269b6474a49970ee302e08ca9ed8d0ed (patch)
treecab2e8adb49cf4db296fb913ca4efcf4672ab3e5 /host/lib/usrp/dboard/db_rfx.cpp
parent905a681afd3b8d089a3dbfe7aa31bbcb5a020c05 (diff)
downloaduhd-1304340f269b6474a49970ee302e08ca9ed8d0ed.tar.gz
uhd-1304340f269b6474a49970ee302e08ca9ed8d0ed.tar.bz2
uhd-1304340f269b6474a49970ee302e08ca9ed8d0ed.zip
rfx: changes to pick from the dboard clock rates and use R=1
Diffstat (limited to 'host/lib/usrp/dboard/db_rfx.cpp')
-rw-r--r--host/lib/usrp/dboard/db_rfx.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp
index 725b5cc03..f938c749a 100644
--- a/host/lib/usrp/dboard/db_rfx.cpp
+++ b/host/lib/usrp/dboard/db_rfx.cpp
@@ -312,7 +312,8 @@ double rfx_xcvr::set_lo_freq(
(8, adf4360_regs_t::BAND_SELECT_CLOCK_DIV_8)
;
- double actual_freq=0, ref_freq = this->get_iface()->get_clock_rate(unit);
+ std::vector<double> clock_rates = this->get_iface()->get_clock_rates(unit);
+ double actual_freq = 0, ref_freq = 0;
int R=0, BS=0, P=0, B=0, A=0;
/*
@@ -325,27 +326,31 @@ double rfx_xcvr::set_lo_freq(
* fvco = [P*B + A] * fref/R
* fvco*R/fref = P*B + A = N
*/
- for(R = 2; R <= 32; R+=2){
- BOOST_FOREACH(BS, bandsel_to_enum.keys()){
- if (ref_freq/R/BS > 1e6) continue; //constraint on band select clock
- BOOST_FOREACH(P, prescaler_to_enum.keys()){
- //calculate B and A from N
- double N = target_freq*R/ref_freq;
- B = int(std::floor(N/P));
- A = boost::math::iround(N - P*B);
- if (B < A or B > 8191 or B < 3 or A > 31) continue; //constraints on A, B
- //calculate the actual frequency
- actual_freq = double(P*B + A)*ref_freq/R;
- if (actual_freq/P > 300e6) continue; //constraint on prescaler output
- //constraints met: exit loop
- goto done_loop;
+ for(R = 1; R <= 32; R+=((R==1)?1:2)){
+ BOOST_FOREACH(ref_freq, uhd::reversed(uhd::sorted(clock_rates))){
+ BOOST_FOREACH(BS, bandsel_to_enum.keys()){
+ if (ref_freq/R/BS > 1e6) continue; //constraint on band select clock
+ BOOST_FOREACH(P, prescaler_to_enum.keys()){
+ //calculate B and A from N
+ double N = target_freq*R/ref_freq;
+ B = int(std::floor(N/P));
+ A = boost::math::iround(N - P*B);
+ if (B < A or B > 8191 or B < 3 or A > 31) continue; //constraints on A, B
+ //calculate the actual frequency
+ actual_freq = double(P*B + A)*ref_freq/R;
+ if (actual_freq/P > 300e6) continue; //constraint on prescaler output
+ //constraints met: exit loop
+ goto done_loop;
+ }
}
}
} done_loop:
if (rfx_debug) std::cerr << boost::format(
- "RFX tune: R=%d, BS=%d, P=%d, B=%d, A=%d, DIV2=%d"
- ) % R % BS % P % B % A % int(_div2[unit] && (!is_rx_rfx400)) << std::endl;
+ "RFX tune: R=%d, BS=%d, P=%d, B=%d, A=%d, DIV2=%d, ref=%fMHz"
+ ) % R % BS % P % B % A % int(_div2[unit] && (!is_rx_rfx400)) % (ref_freq/1e6) << std::endl;
+
+ this->get_iface()->set_clock_rate(unit, ref_freq);
//load the register values
adf4360_regs_t regs;