From d79538d5a5f8b07bdcdc1684f3fffbf14c7aae6c Mon Sep 17 00:00:00 2001 From: Mark Meserve Date: Tue, 1 Oct 2019 14:34:15 -0500 Subject: 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 --- mpm/lib/mykonos/ad937x_device.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'mpm/lib') 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 +#include #include #include #include @@ -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 } -- cgit v1.2.3