From 067491b58676cbdaa754334949a8ffc2daf32979 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 16 Apr 2010 11:05:54 -0700 Subject: RFX seems to be tuning. Added some code to dsp to check for valid range. --- host/lib/usrp/usrp2/dsp_impl.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'host/lib/usrp/usrp2/dsp_impl.cpp') diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp index 664d69948..204277ba7 100644 --- a/host/lib/usrp/usrp2/dsp_impl.cpp +++ b/host/lib/usrp/usrp2/dsp_impl.cpp @@ -40,7 +40,8 @@ template T log2(T num){ * DDC Helper Methods **********************************************************************/ static boost::uint32_t calculate_freq_word_and_update_actual_freq(double &freq, double clock_freq){ - double scale_factor = std::pow(2.0, 32); + ASSERT_THROW(std::abs(freq) < clock_freq/2.0); + static const double scale_factor = std::pow(2.0, 32); //calculate the freq register word boost::uint32_t freq_word = rint((freq / clock_freq) * scale_factor); @@ -124,12 +125,10 @@ void usrp2_impl::ddc_set(const wax::obj &key, const wax::obj &val){ case DSP_PROP_FREQ_SHIFT:{ double new_freq = val.as(); - ASSERT_THROW(new_freq <= get_master_clock_freq()/2.0); - ASSERT_THROW(new_freq >= -get_master_clock_freq()/2.0); - _ddc_freq = new_freq; //shadow _iface->poke32(FR_DSP_RX_FREQ, - calculate_freq_word_and_update_actual_freq(_ddc_freq, get_master_clock_freq()) + calculate_freq_word_and_update_actual_freq(new_freq, get_master_clock_freq()) ); + _ddc_freq = new_freq; //shadow } return; @@ -209,12 +208,10 @@ void usrp2_impl::duc_set(const wax::obj &key, const wax::obj &val){ case DSP_PROP_FREQ_SHIFT:{ double new_freq = val.as(); - ASSERT_THROW(new_freq <= get_master_clock_freq()/2.0); - ASSERT_THROW(new_freq >= -get_master_clock_freq()/2.0); - _duc_freq = new_freq; //shadow _iface->poke32(FR_DSP_TX_FREQ, - calculate_freq_word_and_update_actual_freq(_duc_freq, get_master_clock_freq()) + calculate_freq_word_and_update_actual_freq(new_freq, get_master_clock_freq()) ); + _duc_freq = new_freq; //shadow } return; -- cgit v1.2.3