From 7c794c4bd384bbcae051e024086f2293457ddd65 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 24 Aug 2021 11:45:31 +0200 Subject: rfnoc: duc: Fix frequency range for DUC block The tuning range of the DUC depends on the output sample rate (which is larger), but it was using the input sample rate. This was causing a bug where for Tx, the DSP tuning range was limited when using multi_usrp API, and thus would not allow to DSP-tune beyond the current sampling rate. In this patch, we also re-use the existing calculation of the sampling rate, and harmonize that code between duc_block_control and ddc_block_control. Consider the following Python REPL code: >>> import uhd >>> U = uhd.usrp.MultiUSRP('type=x300') >>> U.set_rx_rate(10e6) >>> U.set_tx_rate(10e6) >>> # Creating a streaming is required, or the input rate will not be >>> # set: >>> S = U.get_tx_stream(uhd.usrp.StreamArgs("fc32", "sc16")) >>> treq = uhd.types.TuneRequest(1e9) >>> treq.rf_freq = 1e9 >>> treq.dsp_freq = 50e6 >>> treq.dsp_freq_policy = uhd.types.TuneRequestPolicy.manual >>> treq.rf_freq_policy = uhd.types.TuneRequestPolicy.manual >>> tres = U.set_rx_freq(treq, 0) >>> print(str(tres)) Tune Result: Target RF Freq: 1000.000000 (MHz) Actual RF Freq: 1000.000000 (MHz) Target DSP Freq: 50.000000 (MHz) Actual DSP Freq: 5.000000 (MHz) >>> # Note the last two lines: The *target* DSP freq was already clipped >>> # to 5 MHz. These lines show 50.0 MHz when this patch is applied. This bugfix is accompanied some related changes: - The unit test is amended to verify the behaviour - The API documentation is amended with details on its behaviour --- host/include/uhd/rfnoc/duc_block_control.hpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'host/include') diff --git a/host/include/uhd/rfnoc/duc_block_control.hpp b/host/include/uhd/rfnoc/duc_block_control.hpp index cf9d3a5d7..7e398454d 100644 --- a/host/include/uhd/rfnoc/duc_block_control.hpp +++ b/host/include/uhd/rfnoc/duc_block_control.hpp @@ -77,6 +77,13 @@ public: virtual double get_freq(const size_t chan) const = 0; /*! Return the range of frequencies that \p chan can be set to. + * + * The frequency shifter is the last component in the DUC, and thus can + * shift frequencies (digitally) between -get_output_rate()/2 + * and +get_output_rate()/2. + * + * The returned values are in Hz (not normalized frequencies) and are valid + * inputs for set_freq(). * * \return The range of frequencies that the DUC can shift the input by */ -- cgit v1.2.3