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

Commit d66b77c

Browse files
author
Tim Harder
committed
Filter Wizard: fix auto-calculation of HB rates for mismatched BBPLLs
Signed-off-by: Tim Harder <timothy.harder@analog.com>
1 parent 2c6b28f commit d66b77c

File tree

3 files changed

+97
-19
lines changed

3 files changed

+97
-19
lines changed

AD9361_Filter_Wizard/AD9361_Filter_Wizard.m

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,63 @@ function AD9361_Filter_Wizard_OpeningFcn(hObject, eventdata, handles, varargin)
185185
% sanity check the DAC divider value and alter it if necessary, note that if
186186
% it's altered then the PLL and calibration dividers must be updated as well
187187
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;
188+
if (handles.input_rx.PLL_rate ~= handles.input_tx.PLL_rate)
189+
rhb1 = handles.input_tx.HB1;
190+
rhb2 = handles.input_tx.HB2;
191+
if handles.input_tx.HB3 == 3
192+
rhb3 = 3;
193+
elseif handles.input_tx.HB3 == 2
194+
rhb3 = 2;
195+
else
196+
rhb3 = 1;
197+
end
198+
handles.input_rx.HB1 = rhb1;
199+
handles.input_rx.HB2 = rhb2;
200+
handles.input_rx.HB3 = rhb3;
201+
202+
ADC_rate = handles.input_rx.Rdata * handles.input_rx.FIR * ...
203+
handles.input_rx.HB1 * handles.input_rx.HB2 * handles.input_rx.HB3;
204+
DAC_rate = handles.input_tx.Rdata * handles.input_tx.FIR * ...
205+
handles.input_tx.HB1 * handles.input_tx.HB2 * handles.input_tx.HB3;
206+
DAC_div = ADC_rate / DAC_rate;
207+
if ~(handles.input_tx.DAC_div == DAC_div)
208+
if (DAC_div == 1 || DAC_div == 2)
209+
handles.input_tx.DAC_div = DAC_div;
210+
handles.input_tx.PLL_mult = handles.input_rx.PLL_mult;
211+
filter_type = get(handles.filter_type, 'Value');
212+
set(handles.filter_type, 'Value', 0);
213+
handles.input_tx.caldiv = default_caldiv(handles);
214+
set(handles.filter_type, 'Value', filter_type);
215+
end
216+
end
217+
218+
handles.input_rx.PLL_mult = fastest_FIR([64 32 16 8 4 2 1], handles.MAX_BBPLL_FREQ, handles.MIN_BBPLL_FREQ, ...
219+
handles.input_rx.Rdata * handles.input_rx.FIR * handles.input_rx.HB1 * handles.input_rx.HB2 * handles.input_rx.HB3 * handles.input_rx.DAC_div);
195220
handles.input_tx.PLL_mult = handles.input_rx.PLL_mult;
196-
filter_type = get(handles.filter_type, 'Value');
197-
set(handles.filter_type, 'Value', 0);
198-
handles.input_tx.caldiv = default_caldiv(handles);
199-
set(handles.filter_type, 'Value', filter_type);
221+
222+
if handles.input_rx.PLL_mult > 64
223+
X = ['Date rate = ', num2str(tohwTx.TXSAMP), ' Hz. Tx BBPLL is too high for Rx to match.'];
224+
disp(X);
225+
end
226+
227+
handles.input_rx.PLL_rate = handles.input_rx.Rdata * handles.input_rx.FIR * handles.input_rx.HB1 * ...
228+
handles.input_rx.HB2 * handles.input_rx.HB3 * handles.input_rx.PLL_mult;
229+
else
230+
ADC_rate = handles.input_rx.Rdata * handles.input_rx.FIR * ...
231+
handles.input_rx.HB1 * handles.input_rx.HB2 * handles.input_rx.HB3;
232+
DAC_rate = handles.input_tx.Rdata * handles.input_tx.FIR * ...
233+
handles.input_tx.HB1 * handles.input_tx.HB2 * handles.input_tx.HB3;
234+
DAC_div = ADC_rate / DAC_rate;
235+
if ~(handles.input_tx.DAC_div == DAC_div)
236+
if (DAC_div == 1 || DAC_div == 2)
237+
handles.input_tx.DAC_div = DAC_div;
238+
handles.input_tx.PLL_mult = handles.input_rx.PLL_mult;
239+
filter_type = get(handles.filter_type, 'Value');
240+
set(handles.filter_type, 'Value', 0);
241+
handles.input_tx.caldiv = default_caldiv(handles);
242+
set(handles.filter_type, 'Value', filter_type);
243+
end
244+
end
200245
end
201246
end
202247

AD9361_Filter_Wizard/cook_input.m

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,6 @@
205205

206206
cooked = input;
207207

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

AD9361_Filter_Wizard/fastest_FIR.m

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

0 commit comments

Comments
 (0)