From adac03ceb88dc9d11f9bc29afbbd49c4981c48ea Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 19 May 2015 13:44:21 -0700 Subject: ad9361: Minor clarifications on req_rate and baseband_bw --- host/lib/usrp/common/ad9361_driver/ad9361_device.cpp | 6 ++++-- host/lib/usrp/common/ad9361_driver/ad9361_device.h | 11 +++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'host/lib/usrp/common') diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp index e3139cd39..413ec75a2 100644 --- a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp +++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp @@ -1247,7 +1247,7 @@ double ad9361_device_t::_setup_rates(const double rate) /* If we make it into this function, then we are tuning to a new rate. * Store the new rate. */ _req_clock_rate = rate; - UHD_LOG << boost::format("[ad9361_device_t::_setup_rates] rate=%d\n") % rate; + UHD_LOG << boost::format("[ad9361_device_t::_setup_rates] rate=%.6d\n") % rate; /* Set the decimation and interpolation values in the RX and TX chains. * This also switches filters in / out. Note that all transmitters and @@ -1629,7 +1629,9 @@ double ad9361_device_t::set_clock_rate(const double req_rate) * starts up. This prevents that, and any bugs in user code that request * the same rate over and over. */ if (freq_is_nearly_equal(req_rate, _req_clock_rate)) { - return _baseband_bw; // IJB. Should this not return req_rate? + // We return _baseband_bw, because that's closest to the + // actual value we're currently running. + return _baseband_bw; } /* We must be in the SLEEP / WAIT state to do this. If we aren't already diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.h b/host/lib/usrp/common/ad9361_driver/ad9361_device.h index bd4ad368f..a42c5ac9a 100644 --- a/host/lib/usrp/common/ad9361_driver/ad9361_device.h +++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.h @@ -112,8 +112,15 @@ private: //Members ad9361_io::sptr _io_iface; //Intermediate state double _rx_freq, _tx_freq, _req_rx_freq, _req_tx_freq; - double _baseband_bw, _bbpll_freq, _adcclock_freq; - double _req_clock_rate, _req_coreclk; + //! Current baseband sampling rate (this is the actual rate the device is + // is running at) + double _baseband_bw; + double _bbpll_freq, _adcclock_freq; + //! This was the last clock rate value that was requested. + // It is cached so we don't need to re-set the clock rate + // if another call to set_clock_rate() actually has the same value. + double _req_clock_rate; + double _req_coreclk; boost::uint16_t _rx_bbf_tunediv; boost::uint8_t _curr_gain_table; double _rx1_gain, _rx2_gain, _tx1_gain, _tx2_gain; -- cgit v1.2.3 From da7302cacbcdad59df01a7d7789db3c6fa9c6b24 Mon Sep 17 00:00:00 2001 From: michael-west Date: Fri, 15 May 2015 17:06:51 -0700 Subject: B200/E300: Fix incorrect readback of frequency. When the LO is tuned it changes the frequency on both channels. The frequency value read back for the first channel was not updated when the LO frequency for the other channel was tuned to a different value. --- host/lib/usrp/b200/b200_impl.cpp | 1 + host/lib/usrp/common/ad9361_ctrl.cpp | 9 +++++++++ host/lib/usrp/common/ad9361_ctrl.hpp | 3 +++ host/lib/usrp/common/ad9361_driver/ad9361_device.cpp | 17 ++++++++++++++--- host/lib/usrp/common/ad9361_driver/ad9361_device.h | 3 +++ host/lib/usrp/e300/e300_impl.cpp | 1 + 6 files changed, 31 insertions(+), 3 deletions(-) (limited to 'host/lib/usrp/common') diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index bd07fcaee..bac904a31 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -684,6 +684,7 @@ void b200_impl::setup_radio(const size_t dspno) _tree->create(rf_fe_path / "bandwidth" / "range") .publish(boost::bind(&ad9361_ctrl::get_bw_filter_range, key)); _tree->create(rf_fe_path / "freq" / "value") + .publish(boost::bind(&ad9361_ctrl::get_freq, _codec_ctrl, key)) .coerce(boost::bind(&ad9361_ctrl::tune, _codec_ctrl, key, _1)) .subscribe(boost::bind(&b200_impl::update_bandsel, this, key, _1)) .set(B200_DEFAULT_FREQ); diff --git a/host/lib/usrp/common/ad9361_ctrl.cpp b/host/lib/usrp/common/ad9361_ctrl.cpp index bedd2eb32..65e8e2df9 100644 --- a/host/lib/usrp/common/ad9361_ctrl.cpp +++ b/host/lib/usrp/common/ad9361_ctrl.cpp @@ -149,6 +149,15 @@ public: return _device.tune(direction, value); } + //! get the current frequency for the given frontend + double get_freq(const std::string &which) + { + boost::lock_guard lock(_mutex); + + ad9361_device_t::direction_t direction = _get_direction_from_antenna(which); + return _device.get_freq(direction); + } + //! turn on/off data port loopback void data_port_loopback(const bool on) { diff --git a/host/lib/usrp/common/ad9361_ctrl.hpp b/host/lib/usrp/common/ad9361_ctrl.hpp index c5718302f..b7d7b8e26 100644 --- a/host/lib/usrp/common/ad9361_ctrl.hpp +++ b/host/lib/usrp/common/ad9361_ctrl.hpp @@ -95,6 +95,9 @@ public: //! tune the given frontend, return the exact value virtual double tune(const std::string &which, const double value) = 0; + //! get the current frequency for the given frontend + virtual double get_freq(const std::string &which) = 0; + //! turn on/off data port loopback virtual void data_port_loopback(const bool on) = 0; diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp index 413ec75a2..e63460730 100644 --- a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp +++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp @@ -1050,7 +1050,7 @@ double ad9361_device_t::_tune_bbvco(const double rate) const double vcomin = 672e6; double vcorate; int vcodiv; - + /* Iterate over VCO dividers until appropriate divider is found. */ int i = 1; for (; i <= 6; i++) { @@ -1855,10 +1855,21 @@ double ad9361_device_t::tune(direction_t direction, const double value) return tune_freq; } +/* Get the current RX or TX frequency. */ +double ad9361_device_t::get_freq(direction_t direction) +{ + boost::lock_guard lock(_mutex); + + if (direction == RX) + return _rx_freq; + else + return _tx_freq; +} + /* Set the gain of RX1, RX2, TX1, or TX2. * - * Note that the 'value' passed to this function is the gain index - * for RX. Also note that the RX chains are done in terms of gain, and + * Note that the 'value' passed to this function is the gain index + * for RX. Also note that the RX chains are done in terms of gain, and * the TX chains are done in terms of attenuation. */ double ad9361_device_t::set_gain(direction_t direction, chain_t chain, const double value) { diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.h b/host/lib/usrp/common/ad9361_driver/ad9361_device.h index a42c5ac9a..71ce78da7 100644 --- a/host/lib/usrp/common/ad9361_driver/ad9361_device.h +++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.h @@ -49,6 +49,9 @@ public: * After tuning, it runs any appropriate calibrations. */ double tune(direction_t direction, const double value); + /* Get the current RX or TX frequency. */ + double get_freq(direction_t direction); + /* Set the gain of RX1, RX2, TX1, or TX2. * * Note that the 'value' passed to this function is the actual gain value, diff --git a/host/lib/usrp/e300/e300_impl.cpp b/host/lib/usrp/e300/e300_impl.cpp index 693aa5734..41e8eacf3 100644 --- a/host/lib/usrp/e300/e300_impl.cpp +++ b/host/lib/usrp/e300/e300_impl.cpp @@ -1053,6 +1053,7 @@ void e300_impl::_setup_radio(const size_t dspno) _tree->create(rf_fe_path / "bandwidth" / "range") .publish(boost::bind(&ad9361_ctrl::get_bw_filter_range, key)); _tree->create(rf_fe_path / "freq" / "value") + .publish(boost::bind(&ad9361_ctrl::get_freq, _codec_ctrl, key)) .coerce(boost::bind(&ad9361_ctrl::tune, _codec_ctrl, key, _1)) .subscribe(boost::bind(&e300_impl::_update_fe_lo_freq, this, key, _1)) .set(e300::DEFAULT_FE_FREQ); -- cgit v1.2.3