aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Meserve <mark.meserve@ni.com>2019-10-01 14:34:15 -0500
committerMartin Braun <martin.braun@ettus.com>2019-10-10 11:49:39 -0700
commitd79538d5a5f8b07bdcdc1684f3fffbf14c7aae6c (patch)
tree46da10a24590756e810b58f35ac74957ba2e572b
parent88b42db9cce3469369f99475ba802d69a821dd06 (diff)
downloaduhd-d79538d5a5f8b07bdcdc1684f3fffbf14c7aae6c.tar.gz
uhd-d79538d5a5f8b07bdcdc1684f3fffbf14c7aae6c.tar.bz2
uhd-d79538d5a5f8b07bdcdc1684f3fffbf14c7aae6c.zip
ad937x: increase default dc offset averaging window
- Fixes an issue where RX with close in signals (<5 kHz) had large discontinuities in IQ data - For <1 kHz, an LO offset should be used
-rw-r--r--mpm/lib/mykonos/ad937x_device.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/mpm/lib/mykonos/ad937x_device.cpp b/mpm/lib/mykonos/ad937x_device.cpp
index 6bf22059b..5d089601e 100644
--- a/mpm/lib/mykonos/ad937x_device.cpp
+++ b/mpm/lib/mykonos/ad937x_device.cpp
@@ -11,6 +11,7 @@
#include "config/ad937x_config_t.hpp"
#include "config/ad937x_default_config.hpp"
#include <boost/format.hpp>
+#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
@@ -40,6 +41,15 @@ static const size_t ARM_BINARY_SIZE = 98304;
static const uint32_t PLL_LOCK_TIMEOUT_MS = 200;
+// Amount of time to average samples for RX DC offset
+// A larger averaging window will result in:
+// Longer latency to correct DC offset changes
+// Fewer discontinuities at lower signal frequencies
+// Minimum value is 0.8 ms, enforced by ADI's API
+static constexpr double RX_DC_OFFSET_AVERAGING_WINDOW_MS = 1.0;
+static_assert(RX_DC_OFFSET_AVERAGING_WINDOW_MS >= 0.8,
+ "RX DC offset averaging window must be greater than 0.8 ms");
+
/******************************************************
Helper functions
******************************************************/
@@ -288,6 +298,15 @@ void ad937x_device::setup_cal(const uint32_t init_cals_mask,
throw mpm::runtime_error("Init cals failed!");
// TODO: add more debugging information here
}
+
+ // Set the DC offset averaging window
+ // ADI requires a minimum of 800us
+ // Parameter is (number of samples / 1024)
+ uint16_t window = std::ceil((RX_DC_OFFSET_AVERAGING_WINDOW_MS
+ * (mykonos_config.device->rx->rxProfile->iqRate_kHz))
+ / 1024);
+ CALL_API(MYKONOS_setRfDcOffsetCnt(mykonos_config.device, MYK_DC_OFFSET_RX_CHN, window));
+
CALL_API(MYKONOS_enableTrackingCals(mykonos_config.device, tracking_cals_mask));
// ready for radioOn
}