| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC6950.cpp
Go to the documentation of this file.
1 /*!
2 LTC6950: 1.4GHz Low Phase Noise, Low Jitter PLL with Clock Distribution
3
4 @verbatim
5
6 The LTC®6950 is a low phase noise integer-N frequency
7 synthesizer core with clock distribution. The LTC6950
8 delivers the low phase noise clock signals demanded in
9 high frequency, high resolution data acquisition systems.
10
11 The frequency synthesizer contains a full low noise PLL core
12 with a programmable reference divider (R), a programmable
13 feedback divider (N), a phase/frequency detector (PFD)
14 and a low noise charge pump (CP). The clock distribution
15 section of the LTC6950 delivers up to five outputs based on
16 the VCO input. Each output is individually programmed to
17 divide the VCO input frequency by any integer from 1 to 63
18 and to delay the output by 0 to 63 VCO clock cycles. Four
19 of the outputs feature very low noise, low skew LVPECL
20 logic signals capable of operation up to 1.4GHz. The fifth
21 output is selectable as either an LVDS (800MHz) or CMOS
22 (250MHz) logic type. This output is also programmed to
23 produce an output signal based on either the VCO input
24 or the reference divider output.
25
26 @endverbatim
27
28
29 http://www.linear.com/product/LTC6950
30
31 http://www.linear.com/product/LTC6950#demoboards
32
33
34 Copyright 2018(c) Analog Devices, Inc.
35
36 All rights reserved.
37
38 Redistribution and use in source and binary forms, with or without
39 modification, are permitted provided that the following conditions are met:
40 - Redistributions of source code must retain the above copyright
41 notice, this list of conditions and the following disclaimer.
42 - Redistributions in binary form must reproduce the above copyright
43 notice, this list of conditions and the following disclaimer in
44 the documentation and/or other materials provided with the
45 distribution.
46 - Neither the name of Analog Devices, Inc. nor the names of its
47 contributors may be used to endorse or promote products derived
48 from this software without specific prior written permission.
49 - The use of this software may or may not infringe the patent rights
50 of one or more patent holders. This license does not release you
51 from the requirement that you obtain separate licenses from these
52 patent holders to use this software.
53 - Use of the software either in source or binary form, must be run
54 on or directly connected to an Analog Devices Inc. component.
55
56 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
57 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
58 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
59 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
60 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
61 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
62 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
63 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
64 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
65 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 */
67
68 //! @ingroup RF_Timing
69 //! @{
70 //! @defgroup LTC6950 LTC6950: 1.4GHz Low Phase Noise, Low Jitter PLL with Clock Distribution
71 //! @}
72
73 /*! @file
74 @ingroup LTC6950
75 Library for LTC6950: 1.4GHz Low Phase Noise, Low Jitter PLL with Clock Distribution
76 */
77
78 #include <stdint.h>
79 #include <Arduino.h>
80 #include "Linduino.h"
81 #include "UserInterface.h"
82 #include "LT_SPI.h"
83 #include "LTC6950.h"
84 #include <SPI.h>
85
86 uint8_t LTC6950_reg[LTC6950_NUM_REGADDR]; //!< number of LTC6950 spi addresses
87 uint8_t LTC6950_spi_map[(LTC6950_NUM_REGFIELD+1)][4]; //!< LTC6950 spi map, stores MSB address location, MSB bit location, field length in bits, and R or RW capability
88
89 unsigned long LTC6950_Fref_MHz = 100; //!< Default Fref frequency - MHz portion (xxx); Fref = xxx, yyy,yyy
90 unsigned long LTC6950_Fref_Hz = 0; //!< Default Fref frequency - Hz portion (yyy,yyy); Fref = x,xxx, yyy,yyy
91 unsigned long LTC6950_Frf_MHz = 250; //!< Default Frf frequency - MHz portion (xxxx); Frf = x,xxx, yyy,yyy
92 unsigned long LTC6950_Frf_Hz = 0; //!< Default Frf frequency - Hz portion (yyy,yyy); Frf = x,xxx, yyy,yyy
93 unsigned long LTC6950_VCO_Max_Freq_MHz = 1002; //!< Max Vco frequency for default on board VCO - MHz portion (xxxx); Fvco max = xxx, yyy,yyy
94 unsigned long LTC6950_VCO_Min_Freq_MHz = 998; //!< Min Vco frequency for default on board VCO - MHz portion (xxxx); Fvco min = x,xxx, yyy,yyy
95 unsigned long LTC6950_VCO_Max_Freq_Hz = 0; //!< Max Vco frequency for default on board VCO - Hz portion (yyy,yyy); Fvco max = x,xxx, yyy,yyy
96 unsigned long LTC6950_VCO_Min_Freq_Hz = 0; //!< Min Vco frequency for default on board VCO - Hz portion (yyy,yyy); Fvco min= x,xxx, yyy,yyy
97
98 unsigned long zero64[]= {0,0}; //!< for 64bit math functions
99
100 /* -------------------------------------------------------------------------
101 FUNCTION: LTC6950_read
102 - reads 8 bit Data field to LTC6950.
103 - has to shift data by one bit to account for RW bit
104 -------------------------------------------------------------------------- */
105 uint8_t LTC6950_read(uint8_t cs, int8_t address)
106 {
107 int8_t address_shift;
108 LT_union_int16_2bytes rx;
109
110 address_shift =(address << 1) | 0x01; // shift to left to account for R/W bit, set bit high for read
111 spi_transfer_word(cs, address_shift<<8 , &rx.LT_uint16);
112
113 LTC6950_reg[address]=rx.LT_byte[0];
114 return(rx.LT_byte[0]);
115 }
116
117
118 /* -------------------------------------------------------------------------
119 FUNCTION: LTC6950_read_field
120 For SPI FIELDS located in 1 or multiple address location
121 - reads specific address locations
122 - identifies and returns specific field in question
123 - can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
124 --------------------------------------------------------------------------- */
125 long LTC6950_read_field(uint8_t cs, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
126 {
127 int bit_shift, i, num_reg;
128 long field_val, maskbits, pow2;
129
130 num_reg=0;
131 field_val=0;
132 // determines how many register are used
133 do
134 {
135 bit_shift = (MSB_loc+1)- (numbits-num_reg*8); // determines bit_shift for last register location
136 field_val=LTC6950_read(cs, (address+num_reg))+(field_val<<8); // reads current address locations, shifts previous address location 8 bits
137 num_reg++;
138 }
139 while ((bit_shift<0) && (num_reg<4));
140
141 // creates a bit mask for complete word,
142 maskbits = 1;
143 pow2=1;
144 for (i=1, maskbits=1; i<numbits; i++)
145 {
146 pow2=pow2*2;
147 maskbits = maskbits+pow2;
148 }
149
150 field_val=(field_val >>bit_shift) &maskbits;
151 return field_val;
152 }
153
154 /* -------------------------------------------------------------------------
155 FUNCTION: get_LTC6950_SPI_FIELD
156 For SPI FIELDS
157 - reads specific address locations
158 - identifies and returns specific field in question
159 - can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
160 --------------------------------------------------------------------------- */
161 long get_LTC6950_SPI_FIELD(uint8_t cs, uint8_t f)
162 {
163
164 return LTC6950_read_field(cs, LTC6950_spi_map[f][ADDRx], LTC6950_spi_map[f][DxMSB], LTC6950_spi_map[f][NUMBITS]);
165 }
166
167 /* -------------------------------------------------------------------------
168 FUNCTION: LTC6950_write
169 - writes 8 bit Data field to LTC6950.
170 - has to shift data by one bit to account for RW bit
171 --------------------------------------------------------------------------- */
172 void LTC6950_write(uint8_t cs, uint8_t address, uint8_t Data)
173 {
174 LT_union_int16_2bytes rx;
175
176 address=address << 1; // shift to left to account for R/W bit
177 spi_transfer_word(cs, (address<<8) | Data, &rx.LT_uint16);
178 }
179
180
181 /* -------------------------------------------------------------------------
182 FUNCTION: LTC6950_write_field
183 For SPI FIELDS
184 - reads specific address location
185 - identifies and returns specific field in question
186 - can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
187 ---------------------------------------------------------------------------- */
188 uint8_t LTC6950_write_field(uint8_t cs, long field_data, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
189 {
190 long current_content, desired_content, reg_val;
191 int LSB_loc, i, j, num_reg, bit_shift;
192 long temp_arr[32];
193
194 for (i=0; i<32 ; i++) temp_arr[i]=0; // init temp_arr
195
196 // read data in current address location and put in a bit array
197 num_reg=0;
198 current_content=0;
199 do
200 {
201 bit_shift=(MSB_loc+1)-(numbits-num_reg*8);
202 current_content=LTC6950_read(cs, (address+num_reg)) + (current_content<<8);
203
204 num_reg++;
205 }
206 while ((bit_shift<0) && (num_reg<4));
207 for (i=0; i<(8*num_reg); i++)
208 {
209 temp_arr[i]=(current_content>>i) & 1;
210 }
211
212 // exchange current bits with desired bits
213 LSB_loc = 8*(num_reg-1)+MSB_loc-numbits+1;
214 for (i=LSB_loc, j=0; i<=(MSB_loc+(num_reg-1)*8); i++, j++)
215 {
216 temp_arr[i] = (field_data>>j) &1;
217 } // end of for loop
218
219 // reconstruct bits into an integer
220 desired_content = 0;
221 for (i=0; i<(8*num_reg); i++)
222 {
223 desired_content = desired_content | (temp_arr[i]<<i);
224 } // end of for loop
225
226 // write new field value to part
227 for (i=0; i<num_reg; i++)
228 {
229 reg_val = (desired_content >> 8*(num_reg-1-i)) & 0xff;
230 LTC6950_write(cs, (address+i), reg_val);
231 } // end of for loop
232 } // end of LTC6950_write_field
233
234
235 /* -------------------------------------------------------------------------
236 FUNCTION: get_LTC6950_REGSIZE
237 - returns # of addresses in parts register map (array size)
238 ---------------------------------------------------------------------------- */
239 uint8_t get_LTC6950_REGSIZE()
240 {
241 return sizeof(LTC6950_reg);
242 }
243
244
245 /* -------------------------------------------------------------------------
246 FUNCTION: get_LTC6950_SPI_FIELD_NUMBITS
247 - returns the number of bits for a given field name in the SPI map
248 ---------------------------------------------------------------------------- */
249 uint8_t get_LTC6950_SPI_FIELD_NUMBITS(uint8_t f)
250 {
251 return LTC6950_spi_map[f][NUMBITS];
252 }
253
254
255 /* -------------------------------------------------------------------------
256 FUNCTION: get_LTC6950_SPI_FIELD_RW
257 - returns if the given field name is (0)read/write or (1)read_only field
258 ---------------------------------------------------------------------------- */
259 uint8_t get_LTC6950_SPI_FIELD_RW(uint8_t f)
260 {
261 return LTC6950_spi_map[f][R_ONLY];
262 }
263
264
265 /* -------------------------------------------------------------------------
266 FUNCTION: set_LTC6950_SPI_FIELD
267 For SPI FIELDS
268 - reads specific address location
269 - identifies and returns specific field in question
270 - can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
271 ---------------------------------------------------------------------------- */
272 void set_LTC6950_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
273 {
274 LTC6950_write_field(cs, field_data, LTC6950_spi_map[f][ADDRx], LTC6950_spi_map[f][DxMSB], LTC6950_spi_map[f][NUMBITS]);
275 }
276
277
278 /* -------------------------------------------------------------------------
279 FUNCTION: set_LTC6950_ALLREGS
280 - writes data to all registers at once
281 --------------------------------------------------------------------------- */
282 void set_LTC6950_ALLREGS(uint8_t cs, uint8_t reg01, uint8_t reg02, uint8_t reg03, uint8_t reg04, uint8_t reg05, uint8_t reg06, uint8_t reg07,
283 uint8_t reg08, uint8_t reg09, uint8_t reg0A, uint8_t reg0B, uint8_t reg0C, uint8_t reg0D, uint8_t reg0E, uint8_t reg0F,
284 uint8_t reg10, uint8_t reg11, uint8_t reg12, uint8_t reg13, uint8_t reg14, uint8_t reg15)
285 {
286 uint8_t i;
287
288 LTC6950_reg[1] = reg01;
289 LTC6950_reg[2] = reg02;
290 LTC6950_reg[3] = reg03;
291 LTC6950_reg[4] = reg04;
292 LTC6950_reg[5] = reg05;
293 LTC6950_reg[6] = reg06;
294 LTC6950_reg[7] = reg07;
295 LTC6950_reg[8] = reg08;
296 LTC6950_reg[9] = reg09;
297 LTC6950_reg[10] = reg0A;
298 LTC6950_reg[11] = reg0B;
299 LTC6950_reg[12] = reg0C;
300 LTC6950_reg[13] = reg0D;
301 LTC6950_reg[14] = reg0E;
302 LTC6950_reg[15] = reg0F;
303 LTC6950_reg[16] = reg10;
304 LTC6950_reg[17] = reg11;
305 LTC6950_reg[18] = reg12;
306 LTC6950_reg[19] = reg13;
307 LTC6950_reg[20] = reg14;
308 LTC6950_reg[21] = reg15;
309
310 for (i=1; i<22; i++) LTC6950_write(cs, i, LTC6950_reg[i]);
311 } // end of set_LTC6950_ALLREGS
312
313
314 /* -------------------------------------------------------------------------
315 FUNCTION: LTC6950_init
316 - initializes the SPI MAP
317 - for ease of programming there is spreadsheet that automates this some.
318 ----------------------------------------------------------------------------*/
319 void LTC6950_init()
320 {
321
322 // spi map
323 LTC6950_spi_map[LTC6950_CMSINV][ADDRx]=0X0b;
324 LTC6950_spi_map[LTC6950_CMSINV][DxMSB]= 3;
325 LTC6950_spi_map[LTC6950_CMSINV][NUMBITS]= 1;
326 LTC6950_spi_map[LTC6950_CP][ADDRx]=0x05;
327 LTC6950_spi_map[LTC6950_CP][DxMSB]= 3;
328 LTC6950_spi_map[LTC6950_CP][NUMBITS]= 4;
329 LTC6950_spi_map[LTC6950_CPCHI][ADDRx]=0x06;
330 LTC6950_spi_map[LTC6950_CPCHI][DxMSB]= 7;
331 LTC6950_spi_map[LTC6950_CPCHI][NUMBITS]= 1;
332 LTC6950_spi_map[LTC6950_CPCLO][ADDRx]=0x06;
333 LTC6950_spi_map[LTC6950_CPCLO][DxMSB]= 6;
334 LTC6950_spi_map[LTC6950_CPCLO][NUMBITS]= 1;
335 LTC6950_spi_map[LTC6950_CPDN][ADDRx]=0x06;
336 LTC6950_spi_map[LTC6950_CPDN][DxMSB]= 0;
337 LTC6950_spi_map[LTC6950_CPDN][NUMBITS]= 1;
338 LTC6950_spi_map[LTC6950_CPINV][ADDRx]=0x06;
339 LTC6950_spi_map[LTC6950_CPINV][DxMSB]= 4;
340 LTC6950_spi_map[LTC6950_CPINV][NUMBITS]= 1;
341 LTC6950_spi_map[LTC6950_CPMID][ADDRx]=0x06;
342 LTC6950_spi_map[LTC6950_CPMID][DxMSB]= 5;
343 LTC6950_spi_map[LTC6950_CPMID][NUMBITS]= 1;
344 LTC6950_spi_map[LTC6950_CPRST][ADDRx]=0x06;
345 LTC6950_spi_map[LTC6950_CPRST][DxMSB]= 2;
346 LTC6950_spi_map[LTC6950_CPRST][NUMBITS]= 1;
347 LTC6950_spi_map[LTC6950_CPUP][ADDRx]=0x06;
348 LTC6950_spi_map[LTC6950_CPUP][DxMSB]= 1;
349 LTC6950_spi_map[LTC6950_CPUP][NUMBITS]= 1;
350 LTC6950_spi_map[LTC6950_CPWIDE][ADDRx]=0x06;
351 LTC6950_spi_map[LTC6950_CPWIDE][DxMSB]= 3;
352 LTC6950_spi_map[LTC6950_CPWIDE][NUMBITS]= 1;
353 LTC6950_spi_map[LTC6950_DEL0][ADDRx]=0x0c;
354 LTC6950_spi_map[LTC6950_DEL0][DxMSB]= 5;
355 LTC6950_spi_map[LTC6950_DEL0][NUMBITS]= 6;
356 LTC6950_spi_map[LTC6950_DEL1][ADDRx]=0x0e;
357 LTC6950_spi_map[LTC6950_DEL1][DxMSB]= 5;
358 LTC6950_spi_map[LTC6950_DEL1][NUMBITS]= 6;
359 LTC6950_spi_map[LTC6950_DEL2][ADDRx]=0x10;
360 LTC6950_spi_map[LTC6950_DEL2][DxMSB]= 5;
361 LTC6950_spi_map[LTC6950_DEL2][NUMBITS]= 6;
362 LTC6950_spi_map[LTC6950_DEL3][ADDRx]=0x12;
363 LTC6950_spi_map[LTC6950_DEL3][DxMSB]= 5;
364 LTC6950_spi_map[LTC6950_DEL3][NUMBITS]= 6;
365 LTC6950_spi_map[LTC6950_DEL4][ADDRx]=0x14;
366 LTC6950_spi_map[LTC6950_DEL4][DxMSB]= 5;
367 LTC6950_spi_map[LTC6950_DEL4][NUMBITS]= 6;
368 LTC6950_spi_map[LTC6950_FILTR][ADDRx]=0x0b;
369 LTC6950_spi_map[LTC6950_FILTR][DxMSB]= 4;
370 LTC6950_spi_map[LTC6950_FILTR][NUMBITS]= 1;
371 LTC6950_spi_map[LTC6950_FILTV][ADDRx]=0x0b;
372 LTC6950_spi_map[LTC6950_FILTV][DxMSB]= 5;
373 LTC6950_spi_map[LTC6950_FILTV][NUMBITS]= 1;
374 LTC6950_spi_map[LTC6950_FLDRV0][ADDRx]=0x0c;
375 LTC6950_spi_map[LTC6950_FLDRV0][DxMSB]= 6;
376 LTC6950_spi_map[LTC6950_FLDRV0][NUMBITS]= 1;
377 LTC6950_spi_map[LTC6950_FLDRV1][ADDRx]=0x0e;
378 LTC6950_spi_map[LTC6950_FLDRV1][DxMSB]= 6;
379 LTC6950_spi_map[LTC6950_FLDRV1][NUMBITS]= 1;
380 LTC6950_spi_map[LTC6950_FLDRV2][ADDRx]=0x10;
381 LTC6950_spi_map[LTC6950_FLDRV2][DxMSB]= 6;
382 LTC6950_spi_map[LTC6950_FLDRV2][NUMBITS]= 1;
383 LTC6950_spi_map[LTC6950_FLDRV3][ADDRx]=0x12;
384 LTC6950_spi_map[LTC6950_FLDRV3][DxMSB]= 6;
385 LTC6950_spi_map[LTC6950_FLDRV3][NUMBITS]= 1;
386 LTC6950_spi_map[LTC6950_FLDRV4][ADDRx]=0x14;
387 LTC6950_spi_map[LTC6950_FLDRV4][DxMSB]= 6;
388 LTC6950_spi_map[LTC6950_FLDRV4][NUMBITS]= 1;
389 LTC6950_spi_map[LTC6950_IBIAS0][ADDRx]=0x0d;
390 LTC6950_spi_map[LTC6950_IBIAS0][DxMSB]= 7;
391 LTC6950_spi_map[LTC6950_IBIAS0][NUMBITS]= 1;
392 LTC6950_spi_map[LTC6950_IBIAS1][ADDRx]=0x0f;
393 LTC6950_spi_map[LTC6950_IBIAS1][DxMSB]= 7;
394 LTC6950_spi_map[LTC6950_IBIAS1][NUMBITS]= 1;
395 LTC6950_spi_map[LTC6950_IBIAS2][ADDRx]=0x11;
396 LTC6950_spi_map[LTC6950_IBIAS2][DxMSB]= 7;
397 LTC6950_spi_map[LTC6950_IBIAS2][NUMBITS]= 1;
398 LTC6950_spi_map[LTC6950_IBIAS3][ADDRx]=0x13;
399 LTC6950_spi_map[LTC6950_IBIAS3][DxMSB]= 7;
400 LTC6950_spi_map[LTC6950_IBIAS3][NUMBITS]= 1;
401 LTC6950_spi_map[LTC6950_INV_ST1][ADDRx]=0x01;
402 LTC6950_spi_map[LTC6950_INV_ST1][DxMSB]= 7;
403 LTC6950_spi_map[LTC6950_INV_ST1][NUMBITS]= 1;
404 LTC6950_spi_map[LTC6950_INV_ST2][ADDRx]=0x02;
405 LTC6950_spi_map[LTC6950_INV_ST2][DxMSB]= 7;
406 LTC6950_spi_map[LTC6950_INV_ST2][NUMBITS]= 1;
407 LTC6950_spi_map[LTC6950_LKCT][ADDRx]=0x05;
408 LTC6950_spi_map[LTC6950_LKCT][DxMSB]= 5;
409 LTC6950_spi_map[LTC6950_LKCT][NUMBITS]= 2;
410 LTC6950_spi_map[LTC6950_LKEN][ADDRx]=0x03;
411 LTC6950_spi_map[LTC6950_LKEN][DxMSB]= 3;
412 LTC6950_spi_map[LTC6950_LKEN][NUMBITS]= 1;
413 LTC6950_spi_map[LTC6950_LKWIN][ADDRx]=0x05;
414 LTC6950_spi_map[LTC6950_LKWIN][DxMSB]= 7;
415 LTC6950_spi_map[LTC6950_LKWIN][NUMBITS]= 2;
416 LTC6950_spi_map[LTC6950_LOCK][ADDRx]=0x00;
417 LTC6950_spi_map[LTC6950_LOCK][DxMSB]= 2;
418 LTC6950_spi_map[LTC6950_LOCK][NUMBITS]= 1;
419 LTC6950_spi_map[LTC6950_LVCMS][ADDRx]=0x0b;
420 LTC6950_spi_map[LTC6950_LVCMS][DxMSB]= 2;
421 LTC6950_spi_map[LTC6950_LVCMS][NUMBITS]= 1;
422 LTC6950_spi_map[LTC6950_M0][ADDRx]=0x0d;
423 LTC6950_spi_map[LTC6950_M0][DxMSB]= 5;
424 LTC6950_spi_map[LTC6950_M0][NUMBITS]= 6;
425 LTC6950_spi_map[LTC6950_M1][ADDRx]=0x0f;
426 LTC6950_spi_map[LTC6950_M1][DxMSB]= 5;
427 LTC6950_spi_map[LTC6950_M1][NUMBITS]= 6;
428 LTC6950_spi_map[LTC6950_M2][ADDRx]=0x11;
429 LTC6950_spi_map[LTC6950_M2][DxMSB]= 5;
430 LTC6950_spi_map[LTC6950_M2][NUMBITS]= 6;
431 LTC6950_spi_map[LTC6950_M3][ADDRx]=0x13;
432 LTC6950_spi_map[LTC6950_M3][DxMSB]= 5;
433 LTC6950_spi_map[LTC6950_M3][NUMBITS]= 6;
434 LTC6950_spi_map[LTC6950_M4][ADDRx]=0x15;
435 LTC6950_spi_map[LTC6950_M4][DxMSB]= 5;
436 LTC6950_spi_map[LTC6950_M4][NUMBITS]= 6;
437 LTC6950_spi_map[LTC6950_N][ADDRx]=0x09;
438 LTC6950_spi_map[LTC6950_N][DxMSB]= 2;
439 LTC6950_spi_map[LTC6950_N][NUMBITS]= 11;
440 LTC6950_spi_map[LTC6950_NO_REF][ADDRx]=0x00;
441 LTC6950_spi_map[LTC6950_NO_REF][DxMSB]= 4;
442 LTC6950_spi_map[LTC6950_NO_REF][NUMBITS]= 1;
443 LTC6950_spi_map[LTC6950_NO_VCO][ADDRx]=0x00;
444 LTC6950_spi_map[LTC6950_NO_VCO][DxMSB]= 5;
445 LTC6950_spi_map[LTC6950_NO_VCO][NUMBITS]= 1;
446 LTC6950_spi_map[LTC6950_PART][ADDRx]=0x16;
447 LTC6950_spi_map[LTC6950_PART][DxMSB]= 4;
448 LTC6950_spi_map[LTC6950_PART][NUMBITS]= 5;
449 LTC6950_spi_map[LTC6950_PDALL][ADDRx]=0x03;
450 LTC6950_spi_map[LTC6950_PDALL][DxMSB]= 7;
451 LTC6950_spi_map[LTC6950_PDALL][NUMBITS]= 1;
452 LTC6950_spi_map[LTC6950_PD_DIV0][ADDRx]=0x03;
453 LTC6950_spi_map[LTC6950_PD_DIV0][DxMSB]= 0;
454 LTC6950_spi_map[LTC6950_PD_DIV0][NUMBITS]= 1;
455 LTC6950_spi_map[LTC6950_PD_DIV1][ADDRx]=0x04;
456 LTC6950_spi_map[LTC6950_PD_DIV1][DxMSB]= 0;
457 LTC6950_spi_map[LTC6950_PD_DIV1][NUMBITS]= 1;
458 LTC6950_spi_map[LTC6950_PD_DIV2][ADDRx]=0x04;
459 LTC6950_spi_map[LTC6950_PD_DIV2][DxMSB]= 2;
460 LTC6950_spi_map[LTC6950_PD_DIV2][NUMBITS]= 1;
461 LTC6950_spi_map[LTC6950_PD_DIV3][ADDRx]=0x04;
462 LTC6950_spi_map[LTC6950_PD_DIV3][DxMSB]= 4;
463 LTC6950_spi_map[LTC6950_PD_DIV3][NUMBITS]= 1;
464 LTC6950_spi_map[LTC6950_PD_DIV4][ADDRx]=0x04;
465 LTC6950_spi_map[LTC6950_PD_DIV4][DxMSB]= 6;
466 LTC6950_spi_map[LTC6950_PD_DIV4][NUMBITS]= 1;
467 LTC6950_spi_map[LTC6950_PD_OUT0][ADDRx]=0x03;
468 LTC6950_spi_map[LTC6950_PD_OUT0][DxMSB]= 1;
469 LTC6950_spi_map[LTC6950_PD_OUT0][NUMBITS]= 1;
470 LTC6950_spi_map[LTC6950_PD_OUT1][ADDRx]=0x04;
471 LTC6950_spi_map[LTC6950_PD_OUT1][DxMSB]= 1;
472 LTC6950_spi_map[LTC6950_PD_OUT1][NUMBITS]= 1;
473 LTC6950_spi_map[LTC6950_PD_OUT2][ADDRx]=0x04;
474 LTC6950_spi_map[LTC6950_PD_OUT2][DxMSB]= 3;
475 LTC6950_spi_map[LTC6950_PD_OUT2][NUMBITS]= 1;
476 LTC6950_spi_map[LTC6950_PD_OUT3][ADDRx]=0x04;
477 LTC6950_spi_map[LTC6950_PD_OUT3][DxMSB]= 5;
478 LTC6950_spi_map[LTC6950_PD_OUT3][NUMBITS]= 1;
479 LTC6950_spi_map[LTC6950_PD_OUT4][ADDRx]=0x04;
480 LTC6950_spi_map[LTC6950_PD_OUT4][DxMSB]= 7;
481 LTC6950_spi_map[LTC6950_PD_OUT4][NUMBITS]= 1;
482 LTC6950_spi_map[LTC6950_PDPLL][ADDRx]=0x03;
483 LTC6950_spi_map[LTC6950_PDPLL][DxMSB]= 6;
484 LTC6950_spi_map[LTC6950_PDPLL][NUMBITS]= 1;
485 LTC6950_spi_map[LTC6950_PDREFAC][ADDRx]=0x03;
486 LTC6950_spi_map[LTC6950_PDREFAC][DxMSB]= 4;
487 LTC6950_spi_map[LTC6950_PDREFAC][NUMBITS]= 1;
488 LTC6950_spi_map[LTC6950_PDVCOAC][ADDRx]=0x03;
489 LTC6950_spi_map[LTC6950_PDVCOAC][DxMSB]= 5;
490 LTC6950_spi_map[LTC6950_PDVCOAC][NUMBITS]= 1;
491 LTC6950_spi_map[LTC6950_R][ADDRx]=0x07;
492 LTC6950_spi_map[LTC6950_R][DxMSB]= 1;
493 LTC6950_spi_map[LTC6950_R][NUMBITS]= 10;
494 LTC6950_spi_map[LTC6950_RDIVOUT][ADDRx]=0x15;
495 LTC6950_spi_map[LTC6950_RDIVOUT][DxMSB]= 7;
496 LTC6950_spi_map[LTC6950_RDIVOUT][NUMBITS]= 1;
497 LTC6950_spi_map[LTC6950_RES6950][ADDRx]=0x03;
498 LTC6950_spi_map[LTC6950_RES6950][DxMSB]= 2;
499 LTC6950_spi_map[LTC6950_RES6950][NUMBITS]= 1;
500 LTC6950_spi_map[LTC6950_RESET_R][ADDRx]=0x07;
501 LTC6950_spi_map[LTC6950_RESET_R][DxMSB]= 3;
502 LTC6950_spi_map[LTC6950_RESET_R][NUMBITS]= 1;
503 LTC6950_spi_map[LTC6950_RESET_N][ADDRx]=0x09;
504 LTC6950_spi_map[LTC6950_RESET_N][DxMSB]= 4;
505 LTC6950_spi_map[LTC6950_RESET_N][NUMBITS]= 1;
506 LTC6950_spi_map[LTC6950_REV][ADDRx]=0x16;
507 LTC6950_spi_map[LTC6950_REV][DxMSB]= 7;
508 LTC6950_spi_map[LTC6950_REV][NUMBITS]= 3;
509 LTC6950_spi_map[LTC6950_SM1][ADDRx]=0x01;
510 LTC6950_spi_map[LTC6950_SM1][DxMSB]= 5;
511 LTC6950_spi_map[LTC6950_SM1][NUMBITS]= 6;
512 LTC6950_spi_map[LTC6950_SM2][ADDRx]=0x02;
513 LTC6950_spi_map[LTC6950_SM2][DxMSB]= 5;
514 LTC6950_spi_map[LTC6950_SM2][NUMBITS]= 6;
515 LTC6950_spi_map[LTC6950_SYNCMD][ADDRx]=0x0b;
516 LTC6950_spi_map[LTC6950_SYNCMD][DxMSB]= 7;
517 LTC6950_spi_map[LTC6950_SYNCMD][NUMBITS]= 2;
518 LTC6950_spi_map[LTC6950_SYNC_EN0][ADDRx]=0x0c;
519 LTC6950_spi_map[LTC6950_SYNC_EN0][DxMSB]= 7;
520 LTC6950_spi_map[LTC6950_SYNC_EN0][NUMBITS]= 1;
521 LTC6950_spi_map[LTC6950_SYNC_EN1][ADDRx]=0x0e;
522 LTC6950_spi_map[LTC6950_SYNC_EN1][DxMSB]= 7;
523 LTC6950_spi_map[LTC6950_SYNC_EN1][NUMBITS]= 1;
524 LTC6950_spi_map[LTC6950_SYNC_EN2][ADDRx]=0x10;
525 LTC6950_spi_map[LTC6950_SYNC_EN2][DxMSB]= 7;
526 LTC6950_spi_map[LTC6950_SYNC_EN2][NUMBITS]= 1;
527 LTC6950_spi_map[LTC6950_SYNC_EN3][ADDRx]=0x12;
528 LTC6950_spi_map[LTC6950_SYNC_EN3][DxMSB]= 7;
529 LTC6950_spi_map[LTC6950_SYNC_EN3][NUMBITS]= 1;
530 LTC6950_spi_map[LTC6950_SYNC_EN4][ADDRx]=0x14;
531 LTC6950_spi_map[LTC6950_SYNC_EN4][DxMSB]= 7;
532 LTC6950_spi_map[LTC6950_SYNC_EN4][NUMBITS]= 1;
533 LTC6950_spi_map[LTC6950_THI][ADDRx]=0x00;
534 LTC6950_spi_map[LTC6950_THI][DxMSB]= 1;
535 LTC6950_spi_map[LTC6950_THI][NUMBITS]= 1;
536 LTC6950_spi_map[LTC6950_TLO][ADDRx]=0x00;
537 LTC6950_spi_map[LTC6950_TLO][DxMSB]= 0;
538 LTC6950_spi_map[LTC6950_TLO][NUMBITS]= 1;
539 LTC6950_spi_map[LTC6950_UNLOCK][ADDRx]=0x00;
540 LTC6950_spi_map[LTC6950_UNLOCK][DxMSB]= 3;
541 LTC6950_spi_map[LTC6950_UNLOCK][NUMBITS]= 1;
542
543
544 LTC6950_spi_map[LTC6950_CMSINV][R_ONLY]= 0;
545 LTC6950_spi_map[LTC6950_CP][R_ONLY]= 0;
546 LTC6950_spi_map[LTC6950_CPCHI][R_ONLY]= 0;
547 LTC6950_spi_map[LTC6950_CPCLO][R_ONLY]= 0;
548 LTC6950_spi_map[LTC6950_CPDN][R_ONLY]= 0;
549 LTC6950_spi_map[LTC6950_CPINV][R_ONLY]= 0;
550 LTC6950_spi_map[LTC6950_CPMID][R_ONLY]= 0;
551 LTC6950_spi_map[LTC6950_CPRST][R_ONLY]= 0;
552 LTC6950_spi_map[LTC6950_CPUP][R_ONLY]= 0;
553 LTC6950_spi_map[LTC6950_CPWIDE][R_ONLY]= 0;
554 LTC6950_spi_map[LTC6950_DEL0][R_ONLY]= 0;
555 LTC6950_spi_map[LTC6950_DEL1][R_ONLY]= 0;
556 LTC6950_spi_map[LTC6950_DEL2][R_ONLY]= 0;
557 LTC6950_spi_map[LTC6950_DEL3][R_ONLY]= 0;
558 LTC6950_spi_map[LTC6950_DEL4][R_ONLY]= 0;
559 LTC6950_spi_map[LTC6950_FILTR][R_ONLY]= 0;
560 LTC6950_spi_map[LTC6950_FILTV][R_ONLY]= 0;
561 LTC6950_spi_map[LTC6950_FLDRV0][R_ONLY]= 0;
562 LTC6950_spi_map[LTC6950_FLDRV1][R_ONLY]= 0;
563 LTC6950_spi_map[LTC6950_FLDRV2][R_ONLY]= 0;
564 LTC6950_spi_map[LTC6950_FLDRV3][R_ONLY]= 0;
565 LTC6950_spi_map[LTC6950_FLDRV4][R_ONLY]= 0;
566 LTC6950_spi_map[LTC6950_IBIAS0][R_ONLY]= 0;
567 LTC6950_spi_map[LTC6950_IBIAS1][R_ONLY]= 0;
568 LTC6950_spi_map[LTC6950_IBIAS2][R_ONLY]= 0;
569 LTC6950_spi_map[LTC6950_IBIAS3][R_ONLY]= 0;
570 LTC6950_spi_map[LTC6950_INV_ST1][R_ONLY]= 0;
571 LTC6950_spi_map[LTC6950_INV_ST2][R_ONLY]= 0;
572 LTC6950_spi_map[LTC6950_LKCT][R_ONLY]= 0;
573 LTC6950_spi_map[LTC6950_LKEN][R_ONLY]= 0;
574 LTC6950_spi_map[LTC6950_LKWIN][R_ONLY]= 0;
575 LTC6950_spi_map[LTC6950_LOCK][R_ONLY]= 1;
576 LTC6950_spi_map[LTC6950_LVCMS][R_ONLY]= 0;
577 LTC6950_spi_map[LTC6950_M0][R_ONLY]= 0;
578 LTC6950_spi_map[LTC6950_M1][R_ONLY]= 0;
579 LTC6950_spi_map[LTC6950_M2][R_ONLY]= 0;
580 LTC6950_spi_map[LTC6950_M3][R_ONLY]= 0;
581 LTC6950_spi_map[LTC6950_M4][R_ONLY]= 0;
582 LTC6950_spi_map[LTC6950_N][R_ONLY]= 0;
583 LTC6950_spi_map[LTC6950_NO_REF][R_ONLY]= 1;
584 LTC6950_spi_map[LTC6950_NO_VCO][R_ONLY]= 1;
585 LTC6950_spi_map[LTC6950_PART][R_ONLY]= 1;
586 LTC6950_spi_map[LTC6950_PDALL][R_ONLY]= 0;
587 LTC6950_spi_map[LTC6950_PD_DIV0][R_ONLY]= 0;
588 LTC6950_spi_map[LTC6950_PD_DIV1][R_ONLY]= 0;
589 LTC6950_spi_map[LTC6950_PD_DIV2][R_ONLY]= 0;
590 LTC6950_spi_map[LTC6950_PD_DIV3][R_ONLY]= 0;
591 LTC6950_spi_map[LTC6950_PD_DIV4][R_ONLY]= 0;
592 LTC6950_spi_map[LTC6950_PD_OUT0][R_ONLY]= 0;
593 LTC6950_spi_map[LTC6950_PD_OUT1][R_ONLY]= 0;
594 LTC6950_spi_map[LTC6950_PD_OUT2][R_ONLY]= 0;
595 LTC6950_spi_map[LTC6950_PD_OUT3][R_ONLY]= 0;
596 LTC6950_spi_map[LTC6950_PD_OUT4][R_ONLY]= 0;
597 LTC6950_spi_map[LTC6950_PDPLL][R_ONLY]= 0;
598 LTC6950_spi_map[LTC6950_PDREFAC][R_ONLY]= 0;
599 LTC6950_spi_map[LTC6950_PDVCOAC][R_ONLY]= 0;
600 LTC6950_spi_map[LTC6950_R][R_ONLY]= 0;
601 LTC6950_spi_map[LTC6950_RDIVOUT][R_ONLY]= 0;
602 LTC6950_spi_map[LTC6950_RES6950][R_ONLY]= 0;
603 LTC6950_spi_map[LTC6950_RESET_R][R_ONLY]= 0;
604 LTC6950_spi_map[LTC6950_RESET_N][R_ONLY]= 0;
605 LTC6950_spi_map[LTC6950_REV][R_ONLY]= 1;
606 LTC6950_spi_map[LTC6950_SM1][R_ONLY]= 0;
607 LTC6950_spi_map[LTC6950_SM2][R_ONLY]= 0;
608 LTC6950_spi_map[LTC6950_SYNCMD][R_ONLY]= 0;
609 LTC6950_spi_map[LTC6950_SYNC_EN0][R_ONLY]= 0;
610 LTC6950_spi_map[LTC6950_SYNC_EN1][R_ONLY]= 0;
611 LTC6950_spi_map[LTC6950_SYNC_EN2][R_ONLY]= 0;
612 LTC6950_spi_map[LTC6950_SYNC_EN3][R_ONLY]= 0;
613 LTC6950_spi_map[LTC6950_SYNC_EN4][R_ONLY]= 0;
614 LTC6950_spi_map[LTC6950_THI][R_ONLY]= 1;
615 LTC6950_spi_map[LTC6950_TLO][R_ONLY]= 1;
616 LTC6950_spi_map[LTC6950_UNLOCK][R_ONLY]= 1;
617 } // end of LTC6950_init
618
619 void set_LTC6950_global_fref(unsigned long fref_MHz, unsigned long fref_Hz)
620 {
621 LTC6950_Fref_MHz=fref_MHz;
622 LTC6950_Fref_Hz=fref_Hz;
623 }
624
625 void set_LTC6950_global_frf(unsigned long frf_MHz, unsigned long frf_Hz)
626 {
627 LTC6950_Frf_MHz=frf_MHz;
628 LTC6950_Frf_Hz=frf_Hz;
629 }
630
631 void set_LTC6950_global_vcolim(unsigned long fvco_max_MHz, unsigned long fvco_max_Hz, unsigned long fvco_min_MHz, unsigned long fvco_min_Hz)
632 {
633 LTC6950_VCO_Max_Freq_MHz=fvco_max_MHz;
634 LTC6950_VCO_Max_Freq_Hz=fvco_max_Hz;
635 LTC6950_VCO_Min_Freq_MHz=fvco_min_MHz;
636 LTC6950_VCO_Min_Freq_Hz=fvco_min_Hz;
637 }
638
639
640
641 unsigned long get_LTC6950_global_fref_MHz()
642 {
643 return LTC6950_Fref_MHz;
644 }
645
646 unsigned long get_LTC6950_global_fref_Hz()
647 {
648 return LTC6950_Fref_Hz;
649 }
650
651 unsigned long get_LTC6950_global_frf_MHz()
652 {
653 return LTC6950_Frf_MHz;
654 }
655
656 unsigned long get_LTC6950_global_frf_Hz()
657 {
658 return LTC6950_Frf_Hz;
659 }
660
661 unsigned long get_LTC6950_global_VCO_MAX_MHz()
662 {
663 return LTC6950_VCO_Max_Freq_MHz;
664 }
665
666 unsigned long get_LTC6950_global_VCO_MIN_MHz()
667 {
668 return LTC6950_VCO_Min_Freq_MHz;
669 }
670
671 unsigned long get_LTC6950_global_VCO_MAX_Hz()
672 {
673 return LTC6950_VCO_Max_Freq_Hz;
674 }
675
676 unsigned long get_LTC6950_global_VCO_MIN_Hz()
677 {
678 return LTC6950_VCO_Min_Freq_Hz;
679 }
680
681 /* -------------------------------------------------------------------------
682 FUNCTION: calc_odiv
683 - calculates the output divider setting based on the frf and on board
684 VCO frequencies of LTC6950
685 - @return odiv = 1-63 for valid setting, 999 as invalid odiv
686 ---------------------------------------------------------------------------- */
687 unsigned long LTC6950_calc_odiv(unsigned long frf[2])
688 {
689 unsigned long odiv, i;
690 unsigned long max_fout64[2];
691 unsigned long min_fout64[2];
692 unsigned long temp_fout[2];
693 unsigned long temp_i[2];
694 boolean valid_input=false;
695
696
697 HZto64(max_fout64,LTC6950_VCO_Max_Freq_MHz,LTC6950_VCO_Max_Freq_Hz);
698 HZto64(min_fout64,LTC6950_VCO_Min_Freq_MHz,LTC6950_VCO_Min_Freq_Hz);
699
700 // verify desired frequency falls within a divider range (1-6)
701 valid_input=false;
702 for (i=1; i<=63; i++)
703 {
704 init64(temp_i,0L,i);
705 temp_fout[0] = frf[0];
706 temp_fout[1] = frf[1];
707 mul64(temp_fout,temp_i);
708 if (lt64(temp_fout,max_fout64) || eq64(temp_fout, max_fout64)) // same as frf*i <= max_fout
709 {
710 if (lt64(min_fout64,temp_fout) || eq64(temp_fout, min_fout64)) // same as frf*i >= min_fout
711 {
712 valid_input=true;
713 odiv=i;
714 }
715 }
716 } // end of for loop
717
718 if (valid_input == false) odiv= 999L;
719 return odiv;
720
721 } // end of LTC6950_calc_odiv
722
723 /* -------------------------------------------------------------------------
724 FUNCTION: LTC6950_set_frf
725 Calculates the integer (N) and output divider (OD) SPI values
726 using self created 64bit math functions. For Out0 only. Use menu 3 to set dividers to
727 achieve desired frequencies on other outputs.
728
729 Datasheet equations
730 - fvco = fpfd*(N + F)
731 - frf = fvco/O
732 - fpfd = fref/R
733
734 can be modified to the following equations
735 - N = (int) (fvco/fpfd) = (int) frf*O*R/fref
736
737 where
738 - N = ndiv, O= M0div in the code below
739
740 Linduino One (Arduino Uno) is limited to 32 bit floats/double/long.
741 32 bit math functions will create rounding errors with the above equations,
742 tha can result in frequency errors.
743 Therefore, the following code uses self created 64bit functions for 64bit integer math.
744
745 - frf (33 bits) LTC6950 max frf/fvco = 1.4GHZ, which is 23 bit number (2^31 = 2.147G)
746 - fref (23 bits) LTC6950 min fref = 2MHz, which is a 20 bit number (2^20 = 1.05M)
747 - O (6 bits)
748 - R (10 bits)
749
750 step 1: create 64 bit frf and fref numbers
751
752 step 2: calculate O (output divider)
753
754 step 3: get current R-divider setting
755
756 step 4: calculate frf*O*R
757 - max bit count/resolution: 31b+6b+10b= 47b
758
759 step 5: calculate N(11b), using value from step 1
760 - N = (int) frf*O*R/fref
761 - max bit count/resolution: 47b-20b = 27b
762
763 step 6: find N for closest frequency - accounts for rounding with integer math
764 - 64b-47b=17b (using 16b instead of 17b)
765 ---------------------------------------------------------------------------- */
766 void LTC6950_set_frf()
767 {
768 unsigned long frf_MHz, frf_Hz, fref_MHz, fref_Hz, M0div, rdiv, ndiv, N_remainder;
769 unsigned long N64[2], R64[2], MO64[2], temp_long[2];
770 char buffer[100];
771 unsigned long frf[2], frf_act[2];
772 unsigned long fref[2];
773 unsigned long temp_math[2];
774 unsigned long frf_rdiv_M0div[2];
775 unsigned long frf_rdiv_M0div_int[2];
776 unsigned long roundup[2];
777
778 /* step 1: create 64 bit frf and fref numbers
779 32 bit xxxx MHz number and 32 bit yyy yyy Hz number. */
780 frf_MHz=LTC6950_Frf_MHz;
781 frf_Hz=LTC6950_Frf_Hz;
782 HZto64(frf, frf_MHz, frf_Hz);
783
784 fref_MHz=LTC6950_Fref_MHz;
785 fref_Hz=LTC6950_Fref_Hz;
786 HZto64(fref,fref_MHz,fref_Hz);
787
788 // step 2: calculate O (output divider)
789 M0div=LTC6950_calc_odiv(frf);
790
791 // step 3: get current R-divider setting
792 rdiv=get_LTC6950_SPI_FIELD(LTC6950_CS,LTC6950_R); // reads selected field
793
794 // step 3: calculate frf*O*R
795 frf_rdiv_M0div[0]=0;
796 frf_rdiv_M0div[1]=M0div*rdiv;
797 mul64(frf_rdiv_M0div, frf); // odiv*rdiv*frf
798 frf_rdiv_M0div_int[0]=frf_rdiv_M0div[0]; // copy odiv*rdiv*frf to another variable
799 frf_rdiv_M0div_int[1]=frf_rdiv_M0div[1];
800
801 // step 4: calculate N(10b), using value from step 3; N = (int) frf*O*R/fref
802 temp_math[0]=fref[0]; // copy fref to temp variable for math operation
803 temp_math[1]=fref[1];
804 div64(frf_rdiv_M0div_int, temp_math); // frf_rdiv_odiv_int= [(frf*odiv*rdiv)]/fref --> int(fvco/fpfd)
805 ndiv=frf_rdiv_M0div_int[1];
806
807 // step 6: find N for closest frequency - accounts for rounding with integer math
808 // 64b-47b=17b (use 16b)
809 temp_math[0]=fref[0]; // copy fref to temp variable for math operation
810 temp_math[1]=fref[1];
811 shl64by(frf_rdiv_M0div,16); // frf_rdiv_M0div --> [(frf*M0div*rdiv)<<16]/fref = N(double) <<16
812 div64(frf_rdiv_M0div,temp_math);
813 shl64by(frf_rdiv_M0div_int,16); // frf_rdiv_M0div_int --> [(int)((frf*M0div*rdiv)/fref)] <<13 = N(int) <<16
814 sub64(frf_rdiv_M0div,frf_rdiv_M0div_int); // N(double) <<16 - N(int)<<16
815
816 // at this point frf_rdiv_Modiv is the delta between N(double) and N(int) shifted by 16 bits.
817 // if this remainder is < 32768, N(int) will give the closest frequency
818 // if this remainder is >=32768, N(int)+1 will give the closest frequency
819 // 32768 is mid point of the 16 bit number range
820 N_remainder = (frf_rdiv_M0div[1] & 65535L); // 16 bits max code = 65535
821 if (N_remainder >= 32768)
822 {
823 ndiv=ndiv+1;
824 }
825
826 // program part and print out results to screen
827 set_LTC6950_SPI_FIELD(LTC6950_CS,LTC6950_M0,M0div); // programs output divider - OUT0
828 Serial.print("M0 = ");
829 Serial.println(M0div);
830
831 Serial.print("RD = ");
832 Serial.println(rdiv);
833
834 set_LTC6950_SPI_FIELD(LTC6950_CS,LTC6950_N,ndiv); // programs N-divider
835 Serial.print(F("ND = "));
836 Serial.println(ndiv);
837
838
839
840 ///// calculate actual fout here and print out
841 frf_act[0]=fref[0];
842 frf_act[1]=fref[1];
843 N64[0]=0;
844 R64[0]=0;
845 MO64[0]=0;
846 N64[1]=ndiv;
847 R64[1]=rdiv;
848 MO64[1]=M0div;
849
850 mul64(frf_act,N64); // N*fref
851 div64(frf_act,R64); // N*fref/rdiv (or N*fpfd)
852 div64(frf_act,MO64); // (N*fpdf)/odiv
853 if (frf_act[0]==0) // no 32 bit overflow case
854 {
855 Serial.print(F("Actual Output Frequency (closest available) is "));
856 Serial.print(frf_act[1]);
857 Serial.println("Hz");
858 }
859 else // overflow case
860 {
861 temp_math[0]=frf_act[0];
862 temp_math[1]=frf_act[1];
863 temp_long[0]=0;
864 temp_long[1]=OneMHz;
865 div64(temp_math,temp_long); // frf/1e6
866 Serial.print(F("Actual Output Frequency (closest available) is "));
867 Serial.print(temp_math[1]);
868 Serial.print("MHz + ");
869 temp_long[0]=0;
870 temp_long[1]=OneMHz;
871 mul64(temp_math,temp_long); // int(frf/1e6)*1e6
872 sub64(frf_act,temp_math); // frf-int(frf/1e6)*1e6
873 Serial.print(frf_act[1]);
874 Serial.println("Hz");
875 }
876 }
877
878
879 /* -------------------------------------------------------------------------
880 FUNCTION: prt
881 Prints HEX representation of 64 bit an
882 ---------------------------------------------------------------------------- */
883 void prt(unsigned long an[])
884 {
885 Serial.print(an[0],HEX);
886 Serial.print(" ");
887 Serial.println(an[1],HEX);
888 }
889
890
891 /* -------------------------------------------------------------------------
892 FUNCTION: init64
893 Creates a equivalent 64 bit number from 2 32 bit numbers
894 an[0]=bigPart //upper 32 bits
895 an[1]=littlePart //lower 32 bits
896 ---------------------------------------------------------------------------- */
897 void init64(unsigned long an[], unsigned long bigPart, unsigned long littlePart )
898 {
899 an[0]=bigPart;
900 an[1]=littlePart;
901 }
902
903 /* -------------------------------------------------------------------------
904 FUNCTION: HZto64
905 create a 64 bit Hz number from
906 32 bit xxxx MHz number and 32 bit yyy yyy Hz number.
907 A) if an < 2^32 bits
908 an(upper 32b) = 0
909 an(lower 32b) = MHzPart(32b)*1MHz + HzPart (32b)
910 B) if an > 2^32 bits (4,294,967,296)
911 an(upper 32b) = 1
912 an(lower 32b) = ((MHzPart-4294)*1MHz+HzPart)-967296
913 ---------------------------------------------------------------------------- */
914 void HZto64(unsigned long an[], unsigned long MHzPart, unsigned long HzPart )
915 {
916
917 if ((MHzPart>4295) || ((MHzPart==4294) && (HzPart>=967296)))
918 {
919 an[0]=1L; // upper 32 bits
920 an[1] =(MHzPart-4294L)*OneMHz + HzPart-967296L; // lower 32 bits
921 }
922 else
923 {
924 an[0] = 0; // upper 32 bits
925 an[1] = MHzPart*OneMHz+HzPart; // lower 32 bits
926 }
927 }
928
929 /* -------------------------------------------------------------------------
930 FUNCTION: shl64
931 Single Bit shift left of equivalent 64 bit number (an[] = an[]<<1)
932 ---------------------------------------------------------------------------- */
933 void shl64(unsigned long an[])
934 {
935 an[0] <<= 1;
936 if (an[1] & 0x80000000)
937 an[0]++;
938 an[1] <<= 1;
939 }
940
941
942 /* -------------------------------------------------------------------------
943 FUNCTION: shr64
944 Single Bit shift right of equivalent 64 bit number (an[] = an[]>>1)
945 ---------------------------------------------------------------------------- */
946 void shr64(unsigned long an[])
947 {
948 an[1] >>= 1;
949 if (an[0] & 0x1)
950 an[1]+=0x80000000;
951 an[0] >>= 1;
952 }
953
954
955 /* -------------------------------------------------------------------------
956 FUNCTION: shl64by
957 Multi Bit shift left of equivalent 64 bit number (an[] = an[]<<shiftnum)
958 ---------------------------------------------------------------------------- */
959 void shl64by(unsigned long an[], uint8_t shiftnum)
960 {
961 uint8_t i;
962
963 for (i=0; i<shiftnum; i++)
964 {
965 an[0] <<= 1;
966 if (an[1] & 0x80000000)
967 an[0]++;
968 an[1] <<= 1;
969 }
970 }
971
972
973 /* -------------------------------------------------------------------------
974 FUNCTION: shr64by
975 Multi Bit shift right of equivalent 64 bit number (an[] = an[]>>shiftnum)
976 ---------------------------------------------------------------------------- */
977 void shr64by(unsigned long an[], uint8_t shiftnum)
978 {
979 uint8_t i;
980
981 for (i=0; i<shiftnum; i++)
982 {
983 an[1] >>= 1;
984 if (an[0] & 0x1)
985 an[1]+=0x80000000;
986 an[0] >>= 1;
987 }
988 }
989
990
991 /* -------------------------------------------------------------------------
992 FUNCTION: add64
993 64 bit Add ann to an (an[] = an[] + ann[])
994 ---------------------------------------------------------------------------- */
995 void add64(unsigned long an[], unsigned long ann[])
996 {
997 an[0]+=ann[0];
998 if (an[1] + ann[1] < ann[1])
999 an[0]++;
1000 an[1]+=ann[1];
1001 }
1002
1003
1004 /* -------------------------------------------------------------------------
1005 FUNCTION: sub64
1006 64 bit Subtract ann from an (an[] = an[] - ann[])
1007 ---------------------------------------------------------------------------- */
1008 void sub64(unsigned long an[], unsigned long ann[])
1009 {
1010 an[0]-=ann[0];
1011 if (an[1] < ann[1])
1012 {
1013 an[0]--;
1014 }
1015 an[1]-= ann[1];
1016 }
1017
1018
1019 /* -------------------------------------------------------------------------
1020 FUNCTION: eq64
1021 64 bit, if an == ann, then true
1022 ---------------------------------------------------------------------------- */
1023 boolean eq64(unsigned long an[], unsigned long ann[])
1024 {
1025 return (an[0]==ann[0]) && (an[1]==ann[1]);
1026 }
1027
1028
1029 /* -------------------------------------------------------------------------
1030 FUNCTION: lt64
1031 64 bit, if an < ann, then true
1032 ---------------------------------------------------------------------------- */
1033 boolean lt64(unsigned long an[], unsigned long ann[])
1034 {
1035 if (an[0]>ann[0]) return false;
1036 return (an[0]<ann[0]) || (an[1]<ann[1]);
1037 }
1038
1039
1040 /* -------------------------------------------------------------------------
1041 FUNCTION: div64
1042 64 bit Divide, num=num/div
1043 ---------------------------------------------------------------------------- */
1044 void div64(unsigned long num[], unsigned long den[])
1045 {
1046 unsigned long quot[2];
1047 unsigned long qbit[2];
1048 unsigned long tmp[2];
1049 init64(quot,0,0);
1050 init64(qbit,0,1);
1051
1052 if (eq64(num, zero64)) //numerator 0, call it 0
1053 {
1054 init64(num,0,0);
1055 return;
1056 }
1057
1058 if (eq64(den, zero64)) //numerator not zero, denominator 0, infinity in my book.
1059 {
1060 init64(num,0xffffffff,0xffffffff);
1061 return;
1062 }
1063
1064 init64(tmp,0x80000000,0);
1065 while (lt64(den,tmp))
1066 {
1067 shl64(den);
1068 shl64(qbit);
1069 }
1070
1071 while (!eq64(qbit,zero64))
1072 {
1073 if (lt64(den,num) || eq64(den,num))
1074 {
1075 sub64(num,den);
1076 add64(quot,qbit);
1077 }
1078 shr64(den);
1079 shr64(qbit);
1080 }
1081
1082 //remainder now in num, but using it to return quotient for now
1083 init64(num,quot[0],quot[1]);
1084 }
1085
1086
1087 /* -------------------------------------------------------------------------
1088 FUNCTION: mul64
1089 64 bit multiply, an=an*ann
1090 ---------------------------------------------------------------------------- */
1091 void mul64(unsigned long an[], unsigned long ann[])
1092 {
1093 unsigned long p[2] = {0,0};
1094 unsigned long y[2] = {ann[0], ann[1]};
1095 while (!eq64(y,zero64))
1096 {
1097 if (y[1] & 1)
1098 add64(p,an);
1099 shl64(an);
1100 shr64(y);
1101 }
1102 init64(an,p[0],p[1]);
1103 }
LTC6950_RES6950
#define LTC6950_RES6950
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:139
LTC6950_CPWIDE
#define LTC6950_CPWIDE
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:90
get_LTC6950_global_frf_MHz
unsigned long get_LTC6950_global_frf_MHz()
returns global LTC6950_Frf_MHz
Definition: LTC6950.cpp:651
LTC6950_DEL4
#define LTC6950_DEL4
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:95
get_LTC6950_SPI_FIELD_NUMBITS
uint8_t get_LTC6950_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
Definition: LTC6950.cpp:249
LTC6950_N
#define LTC6950_N
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:119
LTC6950_NO_REF
#define LTC6950_NO_REF
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:120
LTC6950_M3
#define LTC6950_M3
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:117
LTC6950_PD_OUT2
#define LTC6950_PD_OUT2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:131
LTC6950_RESET_N
#define LTC6950_RESET_N
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:141
LTC6950_PD_OUT1
#define LTC6950_PD_OUT1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:130
LTC6950_FLDRV2
#define LTC6950_FLDRV2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:100
LTC6950_RESET_R
#define LTC6950_RESET_R
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:140
LTC6950_CS
#define LTC6950_CS
Define the SPI CS pin.
Definition: LTC6950.h:76
LTC6950_LKCT
#define LTC6950_LKCT
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:109
HZto64
void HZto64(unsigned long an[], unsigned long MHzPart, unsigned long HzPart)
create a 64 bit Hz number from 32 bit xxxx MHz number and 32 bit yyy yyy Hz number.
Definition: LTC6950.cpp:914
LTC6950_calc_odiv
unsigned long LTC6950_calc_odiv(unsigned long frf[2])
calculates the output divider setting based on the frf and on board VCO frequencies of LTC6950 ...
Definition: LTC6950.cpp:687
LTC6950_CPCLO
#define LTC6950_CPCLO
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:84
LTC6950_SYNC_EN4
#define LTC6950_SYNC_EN4
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:150
LTC6950_IBIAS2
#define LTC6950_IBIAS2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:105
lt64
boolean lt64(unsigned long an[], unsigned long ann[])
64 bit, if an < ann, then true
Definition: LTC6950.cpp:1033
LTC6950_SYNC_EN0
#define LTC6950_SYNC_EN0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:146
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC6950_PDALL
#define LTC6950_PDALL
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:123
LTC6950_set_frf
void LTC6950_set_frf()
FUNCTION: LTC6950_set_frf Calculates the integer (N) and output divider (OD) SPI values using self cr...
Definition: LTC6950.cpp:766
LTC6950_SYNCMD
#define LTC6950_SYNCMD
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:145
LTC6950_CPCHI
#define LTC6950_CPCHI
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:83
add64
void add64(unsigned long an[], unsigned long ann[])
64 bit Add ann to an (an[] = an[] + ann[])
Definition: LTC6950.cpp:995
LTC6950_PDREFAC
#define LTC6950_PDREFAC
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:135
sub64
void sub64(unsigned long an[], unsigned long ann[])
64 bit Subtract ann from an (an[] = an[] - ann[])
Definition: LTC6950.cpp:1008
set_LTC6950_global_frf
void set_LTC6950_global_frf(unsigned long frf_MHz, unsigned long frf_Hz)
sets globals LTC6950_Frf_MHz and LTC6950_Frf_Hz
Definition: LTC6950.cpp:625
OneMHz
#define OneMHz
1MHz in long format, used in 64 bit math
Definition: LTC6945.h:121
LTC6950_Fref_MHz
unsigned long LTC6950_Fref_MHz
Default Fref frequency - MHz portion (xxx); Fref = xxx, yyy,yyy.
Definition: LTC6950.cpp:89
LTC6950_TLO
#define LTC6950_TLO
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:152
LTC6950_INV_ST2
#define LTC6950_INV_ST2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:108
LTC6950_FILTV
#define LTC6950_FILTV
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:97
shr64by
void shr64by(unsigned long an[], uint8_t shiftnum)
Multi Bit shift right of equivalent 64 bit number (an[] = an[]>>shiftnum)
Definition: LTC6950.cpp:977
LTC6950_PDPLL
#define LTC6950_PDPLL
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:134
LTC6950_PDVCOAC
#define LTC6950_PDVCOAC
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:136
LTC6950_PD_DIV3
#define LTC6950_PD_DIV3
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:127
LTC6950_R
#define LTC6950_R
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:137
LTC6950_M1
#define LTC6950_M1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:115
get_LTC6950_global_frf_Hz
unsigned long get_LTC6950_global_frf_Hz()
returns global LTC6950_Frf_Hz
Definition: LTC6950.cpp:656
LTC6950_SYNC_EN3
#define LTC6950_SYNC_EN3
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:149
LTC6950_LKEN
#define LTC6950_LKEN
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:110
LTC6950_LKWIN
#define LTC6950_LKWIN
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:111
NUMBITS
#define NUMBITS
Definition: LTC6115.h:69
address
static uint8_t address
Definition: DC2091A.ino:83
LTC6950_Frf_MHz
unsigned long LTC6950_Frf_MHz
Default Frf frequency - MHz portion (xxxx); Frf = x,xxx, yyy,yyy.
Definition: LTC6950.cpp:91
mul64
void mul64(unsigned long an[], unsigned long ann[])
64 bit multiply, an=an*ann
Definition: LTC6950.cpp:1091
shl64
void shl64(unsigned long an[])
Single Bit shift left of equivalent 64 bit number (an[] = an[]<<1)
Definition: LTC6950.cpp:933
LTC6950_UNLOCK
#define LTC6950_UNLOCK
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:153
LTC6950_SYNC_EN1
#define LTC6950_SYNC_EN1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:147
LTC6950_DEL0
#define LTC6950_DEL0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:91
LTC6950_VCO_Min_Freq_Hz
unsigned long LTC6950_VCO_Min_Freq_Hz
Min Vco frequency for default on board VCO - Hz portion (yyy,yyy); Fvco min= x,xxx, yyy,yyy.
Definition: LTC6950.cpp:96
LTC6950_CPUP
#define LTC6950_CPUP
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:89
get_LTC6950_SPI_FIELD
long get_LTC6950_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6950 SPI field value calls function LTC6950_read_field, which reads specific address loca...
Definition: LTC6950.cpp:161
shl64by
void shl64by(unsigned long an[], uint8_t shiftnum)
Multi Bit shift left of equivalent 64 bit number (an[] = an[]<<shiftnum)
Definition: LTC6950.cpp:959
LTC6950.h
LTC6950: 1.4GHz Low Phase Noise, Low Jitter PLL with Clock Distribution.
set_LTC6950_ALLREGS
void set_LTC6950_ALLREGS(uint8_t cs, uint8_t reg01, uint8_t reg02, uint8_t reg03, uint8_t reg04, uint8_t reg05, uint8_t reg06, uint8_t reg07, uint8_t reg08, uint8_t reg09, uint8_t reg0A, uint8_t reg0B, uint8_t reg0C, uint8_t reg0D, uint8_t reg0E, uint8_t reg0F, uint8_t reg10, uint8_t reg11, uint8_t reg12, uint8_t reg13, uint8_t reg14, uint8_t reg15)
Writes values to ALL LTC6950 RW addresses.
Definition: LTC6950.cpp:282
div64
void div64(unsigned long num[], unsigned long den[])
64 bit Divide, num=num/div
Definition: LTC6950.cpp:1044
LT_union_int16_2bytes::LT_uint16
uint16_t LT_uint16
16-bit unsigned integer to be converted to two bytes
Definition: Linduino.h:102
set_LTC6950_global_fref
void set_LTC6950_global_fref(unsigned long fref_MHz, unsigned long fref_Hz)
sets globals LTC6950_Fref_MHz and LTC6950_Fref_Hz
Definition: LTC6950.cpp:619
eq64
boolean eq64(unsigned long an[], unsigned long ann[])
64 bit, if an == ann, then true
Definition: LTC6950.cpp:1023
R_ONLY
#define R_ONLY
used for 2nd dim of 2d spi_map array
Definition: LTC6945.h:119
spi_transfer_word
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
Reads and sends a word.
Definition: LT_SPI.cpp:98
LTC6950_M0
#define LTC6950_M0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:114
LTC6950_spi_map
uint8_t LTC6950_spi_map[(LTC6950_NUM_REGFIELD+1)][4]
LTC6950 spi map, stores MSB address location, MSB bit location, field length in bits, and R or RW capability.
Definition: LTC6950.cpp:87
get_LTC6950_global_VCO_MAX_MHz
unsigned long get_LTC6950_global_VCO_MAX_MHz()
returns global LTC6950_VCO_Max_Freq_MHz
Definition: LTC6950.cpp:661
LTC6950_DEL3
#define LTC6950_DEL3
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:94
LTC6950_reg
uint8_t LTC6950_reg[LTC6950_NUM_REGADDR]
number of LTC6950 spi addresses
Definition: LTC6950.cpp:86
LTC6950_DEL1
#define LTC6950_DEL1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:92
LTC6950_FLDRV4
#define LTC6950_FLDRV4
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:102
LTC6950_M4
#define LTC6950_M4
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:118
LTC6950_PD_DIV2
#define LTC6950_PD_DIV2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:126
get_LTC6950_global_VCO_MIN_MHz
unsigned long get_LTC6950_global_VCO_MIN_MHz()
returns global LTC6950_VCO_Min_Freq_MHz
Definition: LTC6950.cpp:666
LTC6950_FLDRV0
#define LTC6950_FLDRV0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:98
LTC6950_REV
#define LTC6950_REV
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:142
LTC6950_SM2
#define LTC6950_SM2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:144
LTC6950_CPMID
#define LTC6950_CPMID
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:87
LTC6950_write
void LTC6950_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6950 Write Single Address writes 8 bit Data field to LTC6950.
Definition: LTC6950.cpp:172
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
get_LTC6950_SPI_FIELD_RW
uint8_t get_LTC6950_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
Definition: LTC6950.cpp:259
LTC6950_PD_OUT3
#define LTC6950_PD_OUT3
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:132
LTC6950_write_field
uint8_t LTC6950_write_field(uint8_t cs, long field_data, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
LTC6950 Write Single Field For SPI FIELDS in 1 or multiple address locations reads specific address/f...
Definition: LTC6950.cpp:188
LTC6950_NUM_REGADDR
#define LTC6950_NUM_REGADDR
Defines number of LTC6950 SPI registers, used in spi_map array.
Definition: LTC6950.h:156
shr64
void shr64(unsigned long an[])
Single Bit shift right of equivalent 64 bit number (an[] = an[]<<1)
Definition: LTC6950.cpp:946
LTC6950_M2
#define LTC6950_M2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:116
LTC6950_RDIVOUT
#define LTC6950_RDIVOUT
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:138
ADDRx
#define ADDRx
used for 2nd dim of 2d spi_map array
Definition: LTC6945.h:116
LTC6950_read
uint8_t LTC6950_read(uint8_t cs, int8_t address)
LTC6950 Read Single Address reads 8 bit Data field to LTC6950.
Definition: LTC6950.cpp:105
LTC6950_NUM_REGFIELD
#define LTC6950_NUM_REGFIELD
Defines number of LTC6950 SPI fields, used in spi_map array.
Definition: LTC6950.h:157
LTC6950_IBIAS0
#define LTC6950_IBIAS0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:103
get_LTC6950_global_fref_MHz
unsigned long get_LTC6950_global_fref_MHz()
returns global LTC6950_Fref_MHz
Definition: LTC6950.cpp:641
UserInterface.h
set_LTC6950_global_vcolim
void set_LTC6950_global_vcolim(unsigned long fvco_max_MHz, unsigned long fvco_max_Hz, unsigned long fvco_min_MHz, unsigned long fvco_min_Hz)
sets globals LTC6950_VCO_Max_Freq_MHz, LTC6950_VCO_Max_Freq_Hz, LTC6950_VCO_Min_Freq_MHz and LTC6950_...
Definition: LTC6950.cpp:631
set_LTC6950_SPI_FIELD
void set_LTC6950_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6950 SPI field value calls function LTC6950_read_field, which reads specific address/fiel...
Definition: LTC6950.cpp:272
LTC6950_init
void LTC6950_init()
Initializes the SPI MAP arrays The values set in initialization are used for all the LTC6950 SPI/WRIT...
Definition: LTC6950.cpp:319
LTC6950_CPRST
#define LTC6950_CPRST
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:88
LTC6950_PART
#define LTC6950_PART
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:122
LTC6950_INV_ST1
#define LTC6950_INV_ST1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:107
LTC6950_SYNC_EN2
#define LTC6950_SYNC_EN2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:148
LTC6950_Fref_Hz
unsigned long LTC6950_Fref_Hz
Default Fref frequency - Hz portion (yyy,yyy); Fref = x,xxx, yyy,yyy.
Definition: LTC6950.cpp:90
get_LTC6950_global_VCO_MIN_Hz
unsigned long get_LTC6950_global_VCO_MIN_Hz()
returns global LTC6950_VCO_Min_Freq_Hz
Definition: LTC6950.cpp:676
LTC6950_NO_VCO
#define LTC6950_NO_VCO
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:121
LT_union_int16_2bytes
This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer) into two ...
Definition: Linduino.h:99
init64
void init64(unsigned long an[], unsigned long bigPart, unsigned long littlePart)
Creates a equivalent 64 bit number from 2 32 bit numbers.
Definition: LTC6950.cpp:897
LTC6950_Frf_Hz
unsigned long LTC6950_Frf_Hz
Default Frf frequency - Hz portion (yyy,yyy); Frf = x,xxx, yyy,yyy.
Definition: LTC6950.cpp:92
LTC6950_IBIAS1
#define LTC6950_IBIAS1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:104
LTC6950_FLDRV3
#define LTC6950_FLDRV3
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:101
get_LTC6950_global_fref_Hz
unsigned long get_LTC6950_global_fref_Hz()
returns global LTC6950_Fref_Hz
Definition: LTC6950.cpp:646
LTC6950_CPDN
#define LTC6950_CPDN
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:85
LTC6950_VCO_Max_Freq_Hz
unsigned long LTC6950_VCO_Max_Freq_Hz
Max Vco frequency for default on board VCO - Hz portion (yyy,yyy); Fvco max = x,xxx, yyy,yyy.
Definition: LTC6950.cpp:95
get_LTC6950_REGSIZE
uint8_t get_LTC6950_REGSIZE()
returns # of addresses in parts register map (array size)
Definition: LTC6950.cpp:239
get_LTC6950_global_VCO_MAX_Hz
unsigned long get_LTC6950_global_VCO_MAX_Hz()
returns global LTC6950_VCO_Max_Freq_Hz
Definition: LTC6950.cpp:671
LTC6950_LOCK
#define LTC6950_LOCK
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:112
LTC6950_SM1
#define LTC6950_SM1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:143
LTC6950_PD_OUT0
#define LTC6950_PD_OUT0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:129
LTC6950_read_field
long LTC6950_read_field(uint8_t cs, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
LTC6950 Read Single Field For SPI FIELDS located in 1 or multiple address location reads specific add...
Definition: LTC6950.cpp:125
i
static int i
Definition: DC2430A.ino:184
LTC6950_CP
#define LTC6950_CP
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:82
LTC6950_FLDRV1
#define LTC6950_FLDRV1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:99
LTC6950_PD_DIV1
#define LTC6950_PD_DIV1
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:125
LTC6950_CMSINV
#define LTC6950_CMSINV
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:81
LTC6950_PD_OUT4
#define LTC6950_PD_OUT4
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:133
LTC6950_PD_DIV0
#define LTC6950_PD_DIV0
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:124
LTC6950_LVCMS
#define LTC6950_LVCMS
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:113
LTC6950_VCO_Max_Freq_MHz
unsigned long LTC6950_VCO_Max_Freq_MHz
Max Vco frequency for default on board VCO - MHz portion (xxxx); Fvco max = xxx, yyy,yyy.
Definition: LTC6950.cpp:93
LT_union_int16_2bytes::LT_byte
uint8_t LT_byte[2]
2 bytes (unsigned 8-bit integers) to be converted to a 16-bit signed or unsigned integer ...
Definition: Linduino.h:103
LTC6950_DEL2
#define LTC6950_DEL2
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:93
LTC6950_PD_DIV4
#define LTC6950_PD_DIV4
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:128
prt
void prt(unsigned long an[])
Prints HEX representation of 64 bit an.
Definition: LTC6950.cpp:883
LTC6950_IBIAS3
#define LTC6950_IBIAS3
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:106
LTC6950_THI
#define LTC6950_THI
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:151
LTC6950_VCO_Min_Freq_MHz
unsigned long LTC6950_VCO_Min_Freq_MHz
Min Vco frequency for default on board VCO - MHz portion (xxxx); Fvco min = x,xxx, yyy,yyy.
Definition: LTC6950.cpp:94
LTC6950_CPINV
#define LTC6950_CPINV
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:86
LTC6950_FILTR
#define LTC6950_FILTR
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6950.h:96
zero64
unsigned long zero64[]
for 64bit math functions
Definition: LTC6950.cpp:98
DxMSB
#define DxMSB
used for 2nd dim of 2d spi_map array
Definition: LTC6945.h:117