summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-06-28 13:10:01 -0700
committerJosh Blum <josh@joshknows.com>2012-06-28 13:10:01 -0700
commit0d5cef73c18340b8466c06edd9722fad4cac1de1 (patch)
tree68340e1ab03b39cb5d85fec00d1eebddbc30a5f3
parentca8281f5c35bd7d3dde3640a2117fa1e08022e52 (diff)
downloaduhd-0d5cef73c18340b8466c06edd9722fad4cac1de1.tar.gz
uhd-0d5cef73c18340b8466c06edd9722fad4cac1de1.tar.bz2
uhd-0d5cef73c18340b8466c06edd9722fad4cac1de1.zip
usrp1: wrap around for DAC tuning outside 1st nyquist
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index c82569ea3..7383c9833 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2011 Ettus Research LLC
+// Copyright 2010-2012 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
#include <boost/format.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/math/special_functions/round.hpp>
+#include <boost/math/special_functions/sign.hpp>
#include <boost/assign/list_of.hpp>
#include <iomanip>
@@ -375,6 +376,12 @@ double usrp1_codec_ctrl_impl::fine_tune(double codec_rate, double target_freq)
void usrp1_codec_ctrl_impl::set_duc_freq(double freq, double rate)
{
double codec_rate = rate * 2;
+
+ //correct for outside of rate (wrap around)
+ freq = std::fmod(freq, rate);
+ if (std::abs(freq) > rate/2.0)
+ freq -= boost::math::sign(freq)*rate;
+
double coarse_freq = coarse_tune(codec_rate, freq);
double fine_freq = fine_tune(codec_rate / 4, freq - coarse_freq);