diff options
author | Josh Blum <josh@joshknows.com> | 2010-05-04 04:30:19 +0000 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-05-04 04:30:19 +0000 |
commit | d8c04c4b70f41b27acb33cd69ed88469d7c94482 (patch) | |
tree | 9da4f56489f11fb9c6451ff831e8f7b651e0874e /host/lib/usrp/usrp2/dsp_impl.cpp | |
parent | 2e222f4a77df389551d08b42a1bf947487d1442f (diff) | |
parent | 3198ff91dcd3a06433654f9e50818f4566cbbe13 (diff) | |
download | uhd-d8c04c4b70f41b27acb33cd69ed88469d7c94482.tar.gz uhd-d8c04c4b70f41b27acb33cd69ed88469d7c94482.tar.bz2 uhd-d8c04c4b70f41b27acb33cd69ed88469d7c94482.zip |
Merge branch 'master' of git@ettus.sourcerepo.com:ettus/uhdpriv into usrp_e
Diffstat (limited to 'host/lib/usrp/usrp2/dsp_impl.cpp')
-rw-r--r-- | host/lib/usrp/usrp2/dsp_impl.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp index 84314a656..fc4c5479e 100644 --- a/host/lib/usrp/usrp2/dsp_impl.cpp +++ b/host/lib/usrp/usrp2/dsp_impl.cpp @@ -52,6 +52,23 @@ static boost::uint32_t calculate_freq_word_and_update_actual_freq(double &freq, return freq_word; } +// Check if requested decim/interp rate is: +// multiple of 4, enable two halfband filters +// multiple of 2, enable one halfband filter +// handle remainder in CIC +static boost::uint32_t calculate_cic_word(size_t rate){ + int hb0 = 0, hb1 = 0; + if (not (rate & 0x1)){ + hb0 = 1; + rate /= 2; + } + if (not (rate & 0x1)){ + hb1 = 1; + rate /= 2; + } + return (hb1 << 9) | (hb0 << 8) | (rate & 0xff); +} + static boost::uint32_t calculate_iq_scale_word(boost::int16_t i, boost::int16_t q){ return (boost::uint16_t(i) << 16) | (boost::uint16_t(q) << 0); } @@ -84,7 +101,7 @@ void usrp2_impl::init_ddc_config(void){ void usrp2_impl::update_ddc_config(void){ //set the decimation - _iface->poke32(FR_DSP_RX_DECIM_RATE, _ddc_decim); + _iface->poke32(FR_DSP_RX_DECIM_RATE, calculate_cic_word(_ddc_decim)); //set the scaling static const boost::int16_t default_rx_scale_iq = 1024; @@ -163,15 +180,14 @@ void usrp2_impl::init_duc_config(void){ void usrp2_impl::update_duc_config(void){ // Calculate CIC interpolation (i.e., without halfband interpolators) - size_t tmp_interp = _duc_interp; - while(tmp_interp > 128) tmp_interp /= 2; + size_t tmp_interp = calculate_cic_word(_duc_interp) & 0xff; // Calculate closest multiplier constant to reverse gain absent scale multipliers double interp_cubed = std::pow(double(tmp_interp), 3); boost::int16_t scale = rint((4096*std::pow(2, ceil(log2(interp_cubed))))/(1.65*interp_cubed)); //set the interpolation - _iface->poke32(FR_DSP_TX_INTERP_RATE, _ddc_decim); + _iface->poke32(FR_DSP_TX_INTERP_RATE, calculate_cic_word(_duc_interp)); //set the scaling _iface->poke32(FR_DSP_TX_SCALE_IQ, calculate_iq_scale_word(scale, scale)); |