aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1
diff options
context:
space:
mode:
authorNicholas Corgan <nick.corgan@ettus.com>2012-05-17 10:08:14 -0700
committerJosh Blum <josh@joshknows.com>2012-05-17 15:45:37 -0700
commitc033017a3f74d90cecd14b99f55402a01d7154ce (patch)
treeece51b24bfc6ea3235703201b804fc24a95ad90e /host/lib/usrp/usrp1
parente5c9dee58715e927dd919aa3bf361983d17a172f (diff)
downloaduhd-c033017a3f74d90cecd14b99f55402a01d7154ce.tar.gz
uhd-c033017a3f74d90cecd14b99f55402a01d7154ce.tar.bz2
uhd-c033017a3f74d90cecd14b99f55402a01d7154ce.zip
Fixing USRP1 aliasing logic
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index c82569ea3..b41e197ca 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
@@ -372,9 +372,43 @@ double usrp1_codec_ctrl_impl::fine_tune(double codec_rate, double target_freq)
return actual_freq;
}
-void usrp1_codec_ctrl_impl::set_duc_freq(double freq, double rate)
+double calc_dxc_freq(double target_freq, double rate)
{
+ double delta = target_freq; //- bandwidth;
+ double dxc_freq = 0.0;
+
+ if (delta >= 0) {
+ while(delta > rate) {
+ delta -= rate;
+ }
+ if (delta <= rate/2) {
+ // non-inverted region
+ dxc_freq = -delta;
+ } else {
+ // inverted region
+ dxc_freq = -(delta - rate) ;
+ }
+ } else {
+ while(delta < -rate) {
+ delta += rate;
+ }
+ std::cout << std::fixed << "delta: " << delta << std::endl;
+ if (delta >= -rate/2) {
+ // non-inverted region
+ dxc_freq = -delta;
+ } else {
+ // inverted region
+ dxc_freq = -(delta + rate);
+ }
+ }
+
+ return dxc_freq;
+}
+
+void usrp1_codec_ctrl_impl::set_duc_freq(double frequency, double rate){
+
double codec_rate = rate * 2;
+ double freq = calc_dxc_freq(frequency, codec_rate);
double coarse_freq = coarse_tune(codec_rate, freq);
double fine_freq = fine_tune(codec_rate / 4, freq - coarse_freq);