aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/lib/mykonos
diff options
context:
space:
mode:
authormattprost <matt.prost@ni.com>2022-04-06 14:00:06 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2022-04-07 13:28:02 -0700
commita8ad4917d331258e163e1786c0325a4b7e7d2e3e (patch)
treeb3cd5935981721f5ad98c11dad78122d013f7573 /mpm/lib/mykonos
parenteacbf15e30313793841ca6e4abd9cad02fffa5b4 (diff)
downloaduhd-a8ad4917d331258e163e1786c0325a4b7e7d2e3e.tar.gz
uhd-a8ad4917d331258e163e1786c0325a4b7e7d2e3e.tar.bz2
uhd-a8ad4917d331258e163e1786c0325a4b7e7d2e3e.zip
n310: Add frontend bandwidth control
Allow users to control the Mykonos frontend bandwidth settings for Rx and Tx. Note that this operation requires the daughterboard to re-initialize, so it may take some time. Values for frontend filter settings were derived using ADI's AD9371 Filter Wizard. This feature requires MPM version 4.1 or later on the device. Co-authored-by: bpadalino <bpadalino@gmail.com> Signed-off-by: mattprost <matt.prost@ni.com>
Diffstat (limited to 'mpm/lib/mykonos')
-rw-r--r--mpm/lib/mykonos/ad937x_device.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/mpm/lib/mykonos/ad937x_device.cpp b/mpm/lib/mykonos/ad937x_device.cpp
index b476922f2..fba065983 100644
--- a/mpm/lib/mykonos/ad937x_device.cpp
+++ b/mpm/lib/mykonos/ad937x_device.cpp
@@ -10,6 +10,7 @@
#include "adi/mykonos_gpio.h"
#include "config/ad937x_config_t.hpp"
#include "config/ad937x_default_config.hpp"
+#include <uhd/utils/algorithm.hpp>
#include <boost/format.hpp>
#include <cmath>
#include <fstream>
@@ -39,6 +40,23 @@ static const uint32_t AD9371_PRODUCT_ID = 0x3;
static const uint32_t AD9371_XBCZ_PRODUCT_ID = 0x1;
static const size_t ARM_BINARY_SIZE = 98304;
+/* Values derived from AD937x filter wizard tool
+ * https://github.com/analogdevicesinc/ad937x-filter-wizard/blob/
+ * 3e407b059be92fe65c4a32d5368fe4cdc491b1a1/profilegen/generate_RxORxPFIR.m#L130
+ * https://github.com/analogdevicesinc/ad937x-filter-wizard/blob/
+ * 3e407b059be92fe65c4a32d5368fe4cdc491b1a1/profilegen/generate_TxPFIR.m#L42
+ */
+static constexpr double AD9371_RX_MIN_BANDWIDTH = 8e6; // Hz
+static constexpr double AD9371_RX_MAX_BANDWIDTH = 100e6; // Hz
+static constexpr double AD9371_RX_BBF_MIN_CORNER = 20e6; // Hz
+static constexpr double AD9371_RX_BBF_MAX_CORNER = 100e6; // Hz
+static constexpr double AD9371_TX_MIN_BANDWIDTH = 20e6; // Hz
+static constexpr double AD9371_TX_MAX_BANDWIDTH = 125e6; // Hz
+static constexpr double AD9371_TX_BBF_MIN_CORNER = 20e6; // Hz
+static constexpr double AD9371_TX_BBF_MAX_CORNER = 125e6; // Hz
+static constexpr double AD9371_TX_DAC_FILT_MIN_CORNER = 92.0e6; // Hz
+static constexpr double AD9371_TX_DAC_FILT_MAX_CORNER = 187.0e6; // Hz
+
static const uint32_t PLL_LOCK_TIMEOUT_MS = 200;
// Amount of time to average samples for RX DC offset
@@ -548,26 +566,31 @@ double ad937x_device::tune(
double ad937x_device::set_bw_filter(const direction_t direction, const double value)
{
+ auto bw = value;
switch (direction) {
case TX_DIRECTION: {
- mykonos_config.device->tx->txProfile->rfBandwidth_Hz = value;
- mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = value / 1000;
- mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = value / 1000;
+ bw = uhd::clip(value, AD9371_TX_MIN_BANDWIDTH, AD9371_TX_MAX_BANDWIDTH);
+ const auto bbf =
+ uhd::clip(bw, AD9371_TX_BBF_MIN_CORNER, AD9371_TX_BBF_MAX_CORNER);
+ mykonos_config.device->tx->txProfile->rfBandwidth_Hz = bw;
+ mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = bbf / 1000;
+ const auto dacCorner = uhd::clip(
+ bw, AD9371_TX_DAC_FILT_MIN_CORNER, AD9371_TX_DAC_FILT_MAX_CORNER);
+ mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = dacCorner / 1000;
break;
}
case RX_DIRECTION: {
- mykonos_config.device->rx->rxProfile->rfBandwidth_Hz = value;
- mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = value / 1000;
+ bw = uhd::clip(value, AD9371_RX_MIN_BANDWIDTH, AD9371_RX_MAX_BANDWIDTH);
+ const auto bbf =
+ uhd::clip(bw, AD9371_RX_BBF_MIN_CORNER, AD9371_RX_BBF_MAX_CORNER);
+ mykonos_config.device->rx->rxProfile->rfBandwidth_Hz = bw;
+ mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = bbf / 1000;
break;
}
}
- const auto state = _move_to_config_state();
- CALL_API(MYKONOS_writeArmProfile(mykonos_config.device));
- _restore_from_config_state(state);
- return value; // TODO: what is coercer value?
+ return bw;
}
-
double ad937x_device::set_gain(
const direction_t direction, const chain_t chain, const double value)
{