Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit e54a3c2

Browse files
author
Tim Harder
committed
Filter Wizard: determine the correct DAC divider value for generated filters
Previously it was assigning only static values for Tx instead of basing the Tx DAC divider value off the ADC rate. Now we still assign static values in cook_input (since it's currently a standalone design so the Tx design doesn't know about the Rx values) but the values are sanity checked and altered along with the PLL multiplier if they need to be changed. Signed-off-by: Tim Harder <timothy.harder@analog.com>
1 parent ed404f4 commit e54a3c2

File tree

3 files changed

+67
-10
lines changed

3 files changed

+67
-10
lines changed

AD9361_Filter_Wizard/AD9361_Filter_Wizard.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,27 @@ function AD9361_Filter_Wizard_OpeningFcn(hObject, eventdata, handles, varargin)
182182
end
183183
end
184184

185+
% sanity check the DAC divider value and alter it if necessary, note that if
186+
% it's altered then the PLL and calibration dividers must be updated as well
187+
if isfield(handles, 'input_tx') && isfield(handles, 'input_rx')
188+
ADC_rate = handles.input_rx.Rdata * handles.input_rx.FIR * ...
189+
handles.input_rx.HB1 * handles.input_rx.HB2 * handles.input_rx.HB3;
190+
DAC_rate = handles.input_tx.Rdata * handles.input_tx.FIR * ...
191+
handles.input_tx.HB1 * handles.input_tx.HB2 * handles.input_tx.HB3;
192+
DAC_div = ADC_rate / DAC_rate;
193+
if ~(handles.input_tx.DAC_div == DAC_div)
194+
handles.input_tx.DAC_div = DAC_div;
195+
handles.input_tx.PLL_mult = fastest_FIR([64 32 16 8 4 2 1], ...
196+
handles.MAX_BBPLL_FREQ, handles.MIN_BBPLL_FREQ, ...
197+
handles.input_tx.Rdata * handles.input_tx.FIR * handles.input_tx.HB1 * ...
198+
handles.input_tx.HB2 * handles.input_tx.HB3 * handles.input_tx.DAC_div);
199+
filter_type = get(handles.filter_type, 'Value');
200+
set(handles.filter_type, 'Value', 0);
201+
handles.input_tx.caldiv = default_caldiv(handles);
202+
set(handles.filter_type, 'Value', filter_type);
203+
end
204+
end
205+
185206
if isfield(handles, 'input_tx') || isfield(handles, 'input_rx')
186207
set(handles.store_filter, 'Visible', 'off');
187208
guidata(hObject, handles);

AD9361_Filter_Wizard/cook_input.m

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108

109109
if strcmp(input.RxTx, 'Rx')
110110
max_HB = max.MAX_RX;
111-
input.DAC_div = 1;
112111
else
113112
max_HB = max.MAX_TX;
114113
end
@@ -149,7 +148,9 @@
149148
input.HB1 = fastest_FIR([2 1], max_HB.HB1, 0, input.Rdata * input.FIR);
150149
input.HB2 = fastest_FIR([2 1], max_HB.HB2, 0, input.Rdata * input.FIR * input.HB1);
151150
input.HB3 = fastest_FIR([3 2 1], max_HB.HB3, 0, input.Rdata * input.FIR * input.HB1 * input.HB2);
152-
if strcmp(input.RxTx, 'Tx')
151+
if strcmp(input.RxTx, 'Rx')
152+
input.DAC_div = 1;
153+
else
153154
input.DAC_div = 2;
154155
end
155156
input.PLL_mult = fastest_FIR([64 32 16 8 4 2 1], max.MAX_BBPLL_FREQ, max.MIN_BBPLL_FREQ, input.Rdata * input.FIR * input.HB1 * input.HB2 * input.HB3 * input.DAC_div);
@@ -206,14 +207,6 @@
206207

207208
cooked = input;
208209

209-
function rate = fastest_FIR(rates, max, min, mult)
210-
for i = 1:length(rates)
211-
if max >= mult * rates(i) && min <= mult * rates(i)
212-
break;
213-
end
214-
end
215-
rate = rates(i);
216-
217210
function caldiv = default_caldiv(input)
218211
if strcmp(input.RxTx, 'Rx')
219212
wnom = 1.4 * input.Fstop; % Rx

AD9361_Filter_Wizard/fastest_FIR.m

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
%%
2+
% Copyright 2015(c) Analog Devices, Inc.
3+
%
4+
% All rights reserved.
5+
%
6+
% Redistribution and use in source and binary forms, with or without modification,
7+
% are permitted provided that the following conditions are met:
8+
% - Redistributions of source code must retain the above copyright
9+
% notice, this list of conditions and the following disclaimer.
10+
% - Redistributions in binary form must reproduce the above copyright
11+
% notice, this list of conditions and the following disclaimer in
12+
% the documentation and/or other materials provided with the
13+
% distribution.
14+
% - Neither the name of Analog Devices, Inc. nor the names of its
15+
% contributors may be used to endorse or promote products derived
16+
% from this software without specific prior written permission.
17+
% - The use of this software may or may not infringe the patent rights
18+
% of one or more patent holders. This license does not release you
19+
% from the requirement that you obtain separate licenses from these
20+
% patent holders to use this software.
21+
% - Use of the software either in source or binary form or filter designs
22+
% resulting from the use of this software, must be connected to, run
23+
% on or loaded to an Analog Devices Inc. component.
24+
%
25+
% THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
26+
% INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
27+
% PARTICULAR PURPOSE ARE DISCLAIMED.
28+
%
29+
% IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30+
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
31+
% RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32+
% BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33+
% STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
34+
% THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35+
%%
36+
37+
function rate = fastest_FIR(rates, max, min, mult)
38+
for i = 1:length(rates)
39+
if max >= mult * rates(i) && min <= mult * rates(i)
40+
break;
41+
end
42+
end
43+
rate = rates(i);

0 commit comments

Comments
 (0)