| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC2610A.ino
Go to the documentation of this file.
1 /*!
2 DC2610A
3 LTC6953: Ultra-Low Jitter, JESD204B Clock Distributor with Eleven Programmable Outputs
4
5 @verbatim
6
7 Setup:
8 Set the terminal baud rate to 115200 and select the newline terminator.
9 Refer to Demo Manual DC2610A.
10 One Power Supply is needed for this demo board: 3.3V supply.
11
12
13 Command Description:
14 1- Load Default Settings from a Look-up Table- Loads the SPI map from one of several options in a
15 look-up table. The look-up table allows the user to select different frequencies and synchronization
16 option.
17
18 2- READ/WRITE to Registers Addresses- Selecting this option will cause all the registers to
19 be read, stored to variables, and displayed. The user will then have the option
20 to write to one register address at a time.
21
22 3- READ/WRITE to Registers Fields- Selecting this option will allow the user
23 to read or write to one register field name at a time.
24
25 4- This function stores the current SPI settings in the demo boards EEPROM
26
27 5- This function loads SPI settings from the demo boards EEPROM to the device
28
29 6 - SPI Frequency: Allows user to control Linduino's SPI frequency. By default this is set to 8MHz
30 when connecting Linduino directly to the DC2610. If Linduino is connected to the DC2430 the default
31 SPI rate is 4MHz
32
33 7 - If using a DC2430 (Linduino Expander), this allows the user to select 1 of 8 sites to talk to.
34
35 USER INPUT DATA FORMAT:
36 decimal : 1024
37 hex : 0x400
38 octal : 02000 (leading 0 "zero")
39 binary : B10000000000
40 float : 1024.0
41
42 @endverbatim
43
44 http://www.linear.com/product/LTC6953
45
46 http://www.linear.com/product/LTC6953#demoboards
47
48
49 Copyright 2018(c) Analog Devices, Inc.
50
51 All rights reserved.
52
53 Redistribution and use in source and binary forms, with or without
54 modification, are permitted provided that the following conditions are met:
55 - Redistributions of source code must retain the above copyright
56 notice, this list of conditions and the following disclaimer.
57 - Redistributions in binary form must reproduce the above copyright
58 notice, this list of conditions and the following disclaimer in
59 the documentation and/or other materials provided with the
60 distribution.
61 - Neither the name of Analog Devices, Inc. nor the names of its
62 contributors may be used to endorse or promote products derived
63 from this software without specific prior written permission.
64 - The use of this software may or may not infringe the patent rights
65 of one or more patent holders. This license does not release you
66 from the requirement that you obtain separate licenses from these
67 patent holders to use this software.
68 - Use of the software either in source or binary form, must be run
69 on or directly connected to an Analog Devices Inc. component.
70
71 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
72 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
73 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
74 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
75 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
77 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
78 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
79 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81 */
82
83 /*! @file
84 @ingroup LTC6953
85 */
86
87 #include <Arduino.h>
88 #include <stdint.h>
89 #include "Linduino.h"
90 #include "LT_SPI.h"
91 #include "UserInterface.h"
92 #include "LT_I2C.h"
93 #include "QuikEval_EEPROM.h"
94 #include "LTC6953.h"
95 #include <SPI.h>
96 #include <Wire.h>
97
98 // Function Declaration
99 void print_title(); // Print the title block
100 void print_prompt(); // Print the main menu
101 void menu_1_load_default_settings(); // Sub-menus
102 void menu_2_RW_to_reg_addresss();
103 void menu_3_RW_to_reg_field();
104 void menu_4_store_settings();
105 void menu_5_restore_settings();
106 void menu_6_SPI_speed();
107 void menu_7_DC2430_site_select();
108 //void DUTsync();
109
110 // Global Variables
111 static int8_t demo_board_connected = 0; //!< Demo Board Name stored in QuikEval EEPROM
112 static int8_t DC2610_board_connected = 0; //!< Demo Board Name stored in QuikEval EEPROM
113 uint8_t First_Run=0; //!< if first time through loop = 0, otherwise=1
114 boolean Using_DC2430= false; //!< Indicator if DC2430 (Linduino Expander) is connected
115
116 // Analog Pins used on DC2430 (Linduino Expander)
117 int dc2430_site_A0_APin =0; //!< DC2430 resistor tree, if it reads 3.3V then DC2430 connected
118 int dc2430_site_A1_APin =1; //!< DC2430 resistor tree, if it reads 1.66V then DC2430 connected
119 int dc2430_site_A2_APin =2; //!< DC2430 INFO ONLY, measures DC2226 (Linduino) VCCIO voltage
120
121 // Digital Pins used on DC2430 (Linduino Expander)
122 int dc2430_site_DA0_Pin =2; //!< DC2430 digital pin allows Linduino to control which DC2430 site is selected
123 int dc2430_site_DA1_Pin =3; //!< DC2430 digital pin allows Linduino to control which DC2430 site is selected
124 int dc2430_site_DA2_Pin =4; //!< DC2430 digital pin allows Linduino to control which DC2430 site is selected
125 int dc2430_en_Pin =5; //!< DC2430 digital pin enables Linduino to control which DC2430 site is selected & turns on DC2430 LED
126
127 /* ------------------------------------------------------------------------- */
128 //! Initialize Linduino
129 //! @return void
130 void setup()
131 {
132 char demo_name[] = "DC2610"; // Demo Board Name stored in QuikEval EEPROM
133 uint8_t data;
134 int site_select=0;
135 int dc2430_A0_val=0;
136 int dc2430_A1_val=0;
137 int dc2430_A2_val=0;
138 float dc2430_A0_fval=0;
139 float dc2430_A1_fval=0;
140 float dc2430_A2_fval=0;
141
142 Serial.println(F("--- start ---"));
143
144 Using_DC2430= false;
145
146 quikeval_SPI_init(); //! Configure the spi port for 500kHz SCK
147 quikeval_SPI_connect(); //! Connect SPI to main data port
148 quikeval_I2C_init(); //! Configure the EEPROM I2C port for 100kHz
149 Serial.begin(115200); //! Initialize the serial port to the PC
150 LTC6953_init();
151 print_title();
152
153 //! **************** DETECT IF USING DC2430 SECTION ******************
154 //! this checks to see if a DC2026 (linduino) to DC2430 (linduino expander)
155 //! by measuring 3 analog voltages
156 //! if a DC2430 is connect then read A0, A1 , A2
157 dc2430_A0_val = analogRead(dc2430_site_A0_APin);
158 dc2430_A0_fval = (5.0*dc2430_A0_val)/1023;
159
160 dc2430_A1_val = analogRead(dc2430_site_A1_APin);
161 dc2430_A1_fval = (5.0*dc2430_A1_val)/1023;
162
163
164 //! If DC2430 located, auto search site 0 to 7 until a DC2610 is found
165 if ((dc2430_A0_fval>3.0) && (dc2430_A0_fval<3.6) && (dc2430_A1_fval>1.5) && (dc2430_A1_fval<1.8))
166 {
167 Serial.println(F("--- DC2430 Connected ---"));
168 Using_DC2430= true;
169 pinMode(dc2430_site_DA0_Pin, OUTPUT);
170 pinMode(dc2430_site_DA1_Pin, OUTPUT);
171 pinMode(dc2430_site_DA2_Pin, OUTPUT);
172 pinMode(dc2430_en_Pin, OUTPUT); // sets the digital pin as output
173 DC2610_board_connected =0;
174 demo_board_connected = 0;
175
176 digitalWrite(dc2430_en_Pin, HIGH); // sets the LED on
177 site_select=0;
178 do
179 {
180 dc2430_site_select(site_select);
181 delay(150); //! probably could be shorter, but this allows the eyes to track which site is being tested
182 demo_board_connected = discover_demo_board_local(demo_name); //! Checks if any demo board is connected.
183 if (demo_board_connected)
184 {
185 Serial.println(F("\n********************************************************"));
186 DC2610_board_connected = discover_demo_board(demo_name); //! Checks if correct demo board is connected.
187
188 if (DC2610_board_connected)
189 {
190 dc2430_A2_val = analogRead(dc2430_site_A2_APin);
191 dc2430_A2_fval = (5.0*dc2430_A2_val)/1023;
192 Serial.print(F("Linduino's JP3 VCCIO voltage = "));
193 Serial.println(dc2430_A2_fval); //! if DC2430 connect, VCCIO voltage set by JP3 on DC2026
194 spi_enable(SPI_CLOCK_DIV4); //! 1) Configure the spi port for 4MHz SCK
195 Serial.println(F("Linduino's SPI Frequency = 4MHz, max DC2430 SPI speed"));
196 Serial.print(F("\nDC2610 FOUND ON DC2430 SITE "));
197 Serial.println(site_select);
198 site_select=15;
199 }
200 }
201
202 if (!DC2610_board_connected)
203 {
204 Serial.print(F("\nDC2610 NOT FOUND ON DC2430 SITE "));
205 Serial.print(site_select);
206 site_select++;
207 }
208 }
209 while (site_select<8);
210
211 //! if no DC2610A was found. Return dc2430_en_Pin to default state (LOW)
212 if (!DC2610_board_connected)
213 {
214 digitalWrite(dc2430_en_Pin, LOW); // sets the LED on
215 Serial.println(F("\n\nConnect DC2610 demo board to DC2430, then press the reset button."));
216 }
217 }
218 else
219 {
220 //! If DC2430 is not located, check to see if Linduino is connected directly to the DC2610
221 //! most common use case
222 Serial.println(F("DC2610A CONNECTED TO LINDUINO"));
223 DC2610_board_connected = discover_demo_board(demo_name); //! Checks if correct demo board is connected.
224 if (DC2610_board_connected)
225 {
226 Serial.println(F("Linduino's SPI Frequency = 8MHz, max speed"));
227 spi_enable(SPI_CLOCK_DIV2); //! 1) Configure the spi port for 8MHz SCK
228 }
229 }
230
231 if (DC2610_board_connected)
232 {
233 print_prompt();
234 }
235 } // end of setup()
236
237
238 /* ------------------------------------------------------------------------- */
239 //! Repeats Linduino loop
240 //! @return void
241 void loop()
242 {
243 uint16_t user_command; // User input command
244
245 if (Serial.available()) // Check for user input
246 {
247 if (First_Run==0)
248 {
249 First_Run=1;
250 }
251
252 user_command = read_int(); //! Reads the user command
253 if (user_command != 'm')
254 Serial.println(user_command);
255
256 switch (user_command) //! Prints the appropriate submenu
257 {
258 case 1:
259 menu_1_load_default_settings();
260 break;
261
262 case 2:
263 menu_2_RW_to_reg_addresss();
264 break;
265
266 case 3:
267 menu_3_RW_to_reg_field();
268 break;
269
270 case 4:
271 menu_4_store_settings();
272 break;
273
274 case 5:
275 menu_5_restore_settings();
276 break;
277
278 case 6:
279 menu_6_SPI_speed();
280 break;
281
282 case 7:
283 menu_7_DC2430_site_select();
284 break;
285
286
287 default:
288 Serial.println(F("Incorrect Option"));
289 break;
290 } // end of switch statement
291 Serial.println(F("\n*****************************************************************"));
292 print_prompt();
293 } // end of if statement
294 } // end of loop()
295
296 // Function Definitions
297 /* ------------------------------------------------------------------------- */
298 //! Menu 1: Load Default SPI Register Settings
299 //! This function loads the register settings from a look up table.
300 //! The settings in the look up table were created using the LTC6952Wizard.
301 //! It is recommended to use the LTC6952Wizard to create the register settings for
302 //! all desired frequency plans and enter these frequency plans into a look-up table.
303 //! The LTC6952Wizard generates register values for optimal LTC6953 performance.
304 //! @return void
305 void menu_1_load_default_settings()
306 {
307
308 uint8_t field_num;
309 long field_val;
310
311 field_val=999L;
312 field_num=1;
313 // Read/Write loop, can exit loop by choosing 'm'
314 while (field_num != 0)
315 {
316 Serial.print(F("\n*****************************************************************"));
317 Serial.print(F("\n************* Select LTC6953 Configuration *****************"));
318 Serial.println(F("\n*****************************************************************"));
319
320 // Select Fields to read and write to
321 Serial.print(F("1- LTC6953 Front Page Datasheet Application\n"));
322 Serial.print(F("2- LTC6953 All output div 1\n"));
323 Serial.println(F("0 - Return to Main Menu\n"));
324
325 Serial.println(F("Load LTC6953 register settings from a look up table (Settings created from LTC6952Wizard)"));
326 Serial.println(F("Enter a command (1-2), or '0' to return to Main Menu): "));
327 field_num = read_int(); //! Reads the user command
328 Serial.println(field_num);
329
330 // User input: enter new setting for selected register
331 if (field_num != 0)
332 {
333 field_num=field_num-1;
334 set_LTC6953_REGS_lkup_tbl(field_num);
335 field_num=field_num+1;
336 } // end if user_command != 0 statement
337 } // end while loop
338 } // end menu_1_load_default_settings function
339
340
341 /* ------------------------------------------------------------------------- */
342 //! Menu 2: Reads and/or Writes the SPI register address
343 //! This function reads and displays all SPI register address settings in HEX format.
344 //! It then provides an option to modify(write to) individual registers one at time
345 //!
346 //! EXAMPLE:
347 //! - 0- ADDR00 = 0x29 (read only)
348 //! - 1- ADDR01 = 0xAA
349 //! - ....
350 //! - 54- ADDR36 = 0x00 55- ADDR37 = 0x00
351 //! - 56- ADDR38 = 0x13 (read only)
352 //! - 0 - Return to Main Menu
353 //! - Enter a command (1-55 to modify register, or '0' to return to Main Menu):
354 //! @return void
355 void menu_2_RW_to_reg_addresss()
356 {
357 uint8_t i, regval, user_regval, num_reg;
358 uint16_t user_address; // User input command
359
360 num_reg = get_LTC6953_REGSIZE();
361 user_address=1;
362 // Read/Write loop, can exit loop by choosing '0'
363 while (user_address != 0)
364 {
365 Serial.println(F("\n*****************************************************************"));
366 // Read All Registers and display results
367 for (i=0; i<num_reg; i++)
368 {
369 regval = LTC6953_read(LTC6953_CS,i);
370 Serial.print(i);
371 if (i<16)
372 Serial.print(F("- ADDR0"));
373 else
374 Serial.print(F("- ADDR"));
375 Serial.print(i, HEX);
376 Serial.print(F(" = 0x"));
377 if (regval<16) Serial.print(F("0"));
378 Serial.print(regval, HEX);
379 if (i==2) Serial.print(F(" (warning: if D0=1 it resets all registers. POR Bit)"));
380 if ((i==0)||(i==(num_reg-1))) Serial.print(F(" (read only) "));
381 if (i<4||(i==(num_reg-1))) Serial.println("");
382 else if ((i%2) == 1) Serial.println("");
383 else Serial.print(" ");
384 } // end for loop
385 Serial.print(F("0 - Return to Main Menu\n\n"));
386 // User input: Select which register to modify, or return to main menu
387 Serial.print(F("Enter a command (1-55 to modify register, or '0' to return to Main Menu): "));
388 user_address = read_int(); //! Reads the user command
389 Serial.println(user_address);
390
391 // User input: enter new setting for selected register
392 if (user_address >0 && user_address<(num_reg-1))
393 {
394 Serial.print(F("What value should ADDR"));
395 Serial.print(user_address);
396 Serial.print(F(" be set to (ex: HEX format 0xff): "));
397 user_regval = read_int(); //! Reads the user command
398 Serial.println(user_regval);
399
400 // writes new setting to part
401 LTC6953_write(LTC6953_CS, (uint8_t)user_address, user_regval);
402 } // end if statement
403 } // end while loop
404 } // end menu_2_RW_to_reg_addresss
405
406
407 /* ------------------------------------------------------------------------- */
408 //! Support function for function menu_3_RW_to_reg_field
409 //! displays current state of select field
410 //! provides user the option to write to that field or return to menu
411 //! @return field value (user input) that will be written to part
412 long field_menu_RW(long field_val, //!< current state of the selected field
413 char field_name[], //!< SPI Field name selected
414 uint8_t f //!< SPI field identifier identifies selected fields information in SPI MAP arrays
415 )
416 {
417 long usr_field_val;
418 uint8_t field_size, i;
419 long max_num=1, pow2=1;
420
421 Serial.print("CURRENT STATE (HEX): 0x");
422 Serial.println(field_val, HEX);
423
424 if (get_LTC6953_SPI_FIELD_RW(f)==0)
425 {
426 field_size=get_LTC6953_SPI_FIELD_NUMBITS(f);
427 for (i=1; i<field_size; i++)
428 {
429 pow2=pow2*2;
430 max_num=max_num + pow2;
431 }
432
433 Serial.print("Set Value or type '-1' to exit: (ex: HEX format 0x00 to 0x");
434 Serial.print(max_num, HEX);
435 Serial.print(")");
436 usr_field_val = read_int(); //! Reads the user command
437
438 if (usr_field_val>=0 && usr_field_val<=max_num)
439 {
440 Serial.println(usr_field_val);
441 return usr_field_val;
442 }
443 else
444 {
445 return field_val;
446 } // end of if statement
447 } // end of if statement
448 } // end of field_menu_RW
449
450
451 /* ------------------------------------------------------------------------- */
452 //! Menu 3: Reads and/or Writes individual SPI fields
453 //! This function provides the user with a list of all SPI fields.
454 //! The user can select a SPI field to read its current value.
455 //! Then the user will be provided with an option to write to that field
456 //! or return to the selection menu.
457 //!
458 //! EXAMPLE:
459 //! - 1-ADEL0 36-MD10 71-PDALL
460 //! - 2-ADEL1 37-MODE0 72-PDVCOPK
461 //! - ....
462 //! - 33-MD7 68-OINV9 103-x
463 //! - 34-MD8 69-OINV10
464 //! - 35-MD9 70-PART
465 //! - 0 - Return to Main Menu
466 //! - * = READ ONLY FIELD
467 //! - Enter a command (1-105 to modify register, or '0' to return to Main Menu)
468 //! @return void
469 void menu_3_RW_to_reg_field()
470 {
471 uint8_t field_num;
472 long field_val;
473
474 field_val=999L;
475 field_num=1;
476 // Read/Write loop, can exit loop by choosing 'm'
477 while (field_num != 0)
478 {
479 Serial.println(F("\n*****************************************************************"));
480 // Select Fields to read and write to
481 Serial.print(F(" 1-ADEL0 36-MD10 71-PDALL\n"));
482 Serial.print(F(" 2-ADEL1 37-MODE0 72-PDVCOPK\n"));
483 Serial.print(F(" 3-ADEL2 38-MODE1 73-PD10\n"));
484 Serial.print(F(" 4-ADEL3 39-MODE2 74-PD9\n"));
485 Serial.print(F(" 5-ADEL4 40-MODE3 75-PD8\n"));
486 Serial.print(F(" 6-ADEL5 41-MODE4 76-PD7\n"));
487 Serial.print(F(" 7-ADEL6 42-MODE5 77-PD6\n"));
488 Serial.print(F(" 8-ADEL7 43-MODE6 78-PD5\n"));
489 Serial.print(F(" 9-ADEL8 44-MODE7 79-PD4\n"));
490 Serial.print(F(" 10-ADEL9 45-MODE8 80-PD3\n"));
491 Serial.print(F(" 11-ADEL10 46-MODE9 81-PD2\n"));
492 Serial.print(F(" 12-DDEL0 47-MODE10 82-PD1\n"));
493 Serial.print(F(" 13-DDEL1 48-MP0 83-PD0\n"));
494 Serial.print(F(" 14-DDEL2 49-MP1 84-POR\n"));
495 Serial.print(F(" 15-DDEL3 50-MP2 85-REV\n"));
496 Serial.print(F(" 16-DDEL4 51-MP3 86-SYSCT\n"));
497 Serial.print(F(" 17-DDEL5 52-MP4 87-SRQMD\n"));
498 Serial.print(F(" 18-DDEL6 53-MP5 88-SSRQ\n"));
499 Serial.print(F(" 19-DDEL7 54-MP6 89-SRQEN0\n"));
500 Serial.print(F(" 20-DDEL8 55-MP7 90-SRQEN1\n"));
501 Serial.print(F(" 21-DDEL9 56-MP8 91-SRQEN2\n"));
502 Serial.print(F(" 22-DDEL10 57-MP9 92-SRQEN3\n"));
503 Serial.print(F(" 23-EZMD 58-MP10 93-SRQEN4\n"));
504 Serial.print(F(" 24-FILTV 59-OINV0 94-SRQEN5\n"));
505 Serial.print(F(" 25-INVSTAT 60-OINV1 95-SRQEN6\n"));
506 Serial.print(F(" 26-MD0 61-OINV2 96-SRQEN7\n"));
507 Serial.print(F(" 27-MD1 62-OINV3 97-SRQEN8\n"));
508 Serial.print(F(" 28-MD2 63-OINV4 98-SRQEN9\n"));
509 Serial.print(F(" 29-MD3 64-OINV5 99-SRQEN10\n"));
510 Serial.print(F(" 30-MD4 65-OINV6 100-TEMPO\n"));
511 Serial.print(F(" 31-MD5 66-OINV7 101-!VCOOK\n"));
512 Serial.print(F(" 32-MD6 67-OINV8 102-VCOOK\n"));
513 Serial.print(F(" 33-MD7 68-OINV9 103-x\n"));
514 Serial.print(F(" 34-MD8 69-OINV10 \n"));
515 Serial.print(F(" 35-MD9 70-PART \n"));
516
517
518 Serial.print(F("0 - Return to Main Menu\n"));
519 Serial.print(F("* = READ ONLY FIELD\n\n"));
520
521 Serial.print(F("Enter a command (1-105 to modify register, or '0' to return to Main Menu): "));
522 field_num = read_int(); //! Reads the user command
523 Serial.println(field_num);
524
525 // User input: enter new setting for selected register
526 if (field_num != 0)
527 {
528 switch (field_num) //! Prints the appropriate submenu
529 {
530 default:
531 field_val=get_LTC6953_SPI_FIELD(LTC6953_CS,field_num); // reads selected field
532 field_val=field_menu_RW(field_val," ",field_num); // user interface control and printout
533 if (field_val>-1)
534 {
535 set_LTC6953_SPI_FIELD(LTC6953_CS, field_num, field_val); // updates selected field
536 }
537 break;
538 } // end of switch statement
539 } // end if user_command != 0 statement
540 } // end while loop
541 } // end menu_3_RW_to_reg_field function
542
543
544 /* ------------------------------------------------------------------------- */
545 //! Store PLL settings to nonvolatile EEPROM on demo board
546 //! @return void
547 void menu_4_store_settings()
548 {
549 // Store the PLL Settings to the EEPROM
550 uint8_t regval;
551
552 uint8_t addr_offset;
553 uint8_t num_reg;
554
555 addr_offset=2;
556 num_reg = get_LTC6953_REGSIZE();
557
558 eeprom_write_int16(EEPROM_I2C_ADDRESS, EEPROM_CAL_KEY, EEPROM_CAL_STATUS_ADDRESS); // Cal key
559
560 for (uint8_t i = 0; i <= num_reg ; i++)
561 {
562 regval = LTC6953_read(LTC6953_CS,i);
563 eeprom_write_byte(EEPROM_I2C_ADDRESS,(char) regval, EEPROM_CAL_STATUS_ADDRESS+ i+addr_offset);
564 }
565 Serial.println(F("PLL Settings Stored to EEPROM"));
566
567 }
568
569 /* ------------------------------------------------------------------------- */
570 //! Read stored PLL settings from nonvolatile EEPROM on demo board
571 //! @return void
572 void menu_5_restore_settings()
573 {
574 // Read the PLL settings from EEPROM
575 int16_t cal_key;
576 uint8_t regval;
577 uint8_t user_address;
578
579 uint8_t addr_offset;
580 uint8_t num_reg;
581 long field_val;
582 uint8_t field_num;
583
584 addr_offset=2;
585 num_reg = get_LTC6953_REGSIZE();
586
587 // read the cal key from the EEPROM
588 eeprom_read_int16(EEPROM_I2C_ADDRESS, &cal_key, EEPROM_CAL_STATUS_ADDRESS);
589 if (cal_key == EEPROM_CAL_KEY)
590 {
591 // PLL Settings has been stored, read PLL Settings
592 user_address=2;
593 for (uint8_t i = 0; i <= num_reg ; i++)
594 {
595 eeprom_read_byte(EEPROM_I2C_ADDRESS,(char *) &regval, EEPROM_CAL_STATUS_ADDRESS + i+addr_offset);
596 LTC6953_write(LTC6953_CS, (uint8_t)i, regval);
597 user_address++;
598 }
599 Serial.println(F("LTC6953 Settings Restored"));
600
601 Serial.println(F("Syncs LTC6953 OUTPUTS"));
602 DUTsync(1);
603
604 }
605 else
606 {
607 Serial.println(F("PLL Settings not found"));
608 }
609
610 }
611
612 /* ------------------------------------------------------------------------- */
613 //! Syncs LTC6953 Outputs using SSYNC bit
614 //! @return void
615 void DUTsync(uint16_t delay_num)
616 {
617 set_LTC6953_SPI_FIELD(LTC6953_CS, LTC6953_SSRQ, 1L);
618 delay(1);
619 set_LTC6953_SPI_FIELD(LTC6953_CS, LTC6953_SSRQ, 0L);
620 delay(delay_num);
621 }
622
623
624
625 /* ------------------------------------------------------------------------- */
626 //! Read stored PLL settings from nonvolatile EEPROM on demo board
627 //! @return void
628 void menu_6_SPI_speed()
629 {
630 int temp_val;
631
632 Serial.println(F("\nCommand Summary:"));
633 if (Using_DC2430)
634 {
635 Serial.println(F(" 1-8MHz NOT Available with DC2430"));
636 }
637 else
638 {
639 Serial.println(F(" 1-SPI Clock = 8MHz"));
640 }
641 Serial.println(F(" 2-SPI Clock = 4MHz"));
642 Serial.println(F(" 3-SPI Clock = 2MHz"));
643 Serial.println(F(" 4-SPI Clock = 1MHz"));
644 Serial.println(F(" 5-SPI Clock = 500kHz"));
645 Serial.println("");
646 Serial.print(F("Enter a command: "));
647 temp_val = read_int(); //! Reads the user command
648
649 switch (temp_val) //! Prints the appropriate submenu
650 {
651 case 1:
652 if (Using_DC2430)
653 {
654 Serial.println(F("incorrect option"));
655 }
656 else
657 {
658 spi_enable(SPI_CLOCK_DIV2); //! 1) Configure the spi port for 8MHz SCK
659 }
660 break;
661
662 case 2:
663 spi_enable(SPI_CLOCK_DIV4); //! 1) Configure the spi port for 4MHz SCK
664 break;
665
666 case 3:
667 spi_enable(SPI_CLOCK_DIV8); //! 1) Configure the spi port for 2MHz SCK
668 break;
669
670 case 4:
671 spi_enable(SPI_CLOCK_DIV16); //! 1) Configure the spi port for 1MHz SCK
672 break;
673
674 case 5:
675 spi_enable(SPI_CLOCK_DIV32); //! 1) Configure the spi port for 500kHz SCK
676 break;
677
678 default:
679 Serial.println(F("Incorrect Option"));
680 break;
681 }
682 }
683
684
685 /* ------------------------------------------------------------------------- */
686 //! Read stored PLL settings from nonvolatile EEPROM on demo board
687 //! @return void
688 void menu_7_DC2430_site_select()
689 {
690 int temp_val;
691
692 Serial.println(F("\nCommand Summary:"));
693 Serial.println(F(" 0-Site 0"));
694 Serial.println(F(" 1-Site 1"));
695 Serial.println(F(" 2-Site 2"));
696 Serial.println(F(" 3-Site 3"));
697 Serial.println(F(" 4-Site 4"));
698 Serial.println(F(" 5-Site 5"));
699 Serial.println(F(" 6-Site 6"));
700 Serial.println(F(" 7-Site 7"));
701
702 Serial.println("");
703 Serial.print(F("Enter a command: "));
704 temp_val = read_int(); //! Reads the user command
705
706 dc2430_site_select(temp_val);
707 }
708
709 /* ------------------------------------------------------------------------- */
710 //! Called from function menu_8_DC2430_site_select(), programs DC2430 to site selected
711 //! @return void
712 void dc2430_site_select(int site_select)
713 {
714 switch (site_select) //! Prints the appropriate submenu
715 {
716 case 0:
717 digitalWrite(dc2430_site_DA0_Pin, LOW);
718 digitalWrite(dc2430_site_DA1_Pin, LOW);
719 digitalWrite(dc2430_site_DA2_Pin, LOW);
720 break;
721
722 case 1:
723 digitalWrite(dc2430_site_DA0_Pin, HIGH);
724 digitalWrite(dc2430_site_DA1_Pin, LOW);
725 digitalWrite(dc2430_site_DA2_Pin, LOW);
726 break;
727
728 case 2:
729 digitalWrite(dc2430_site_DA0_Pin, LOW);
730 digitalWrite(dc2430_site_DA1_Pin, HIGH);
731 digitalWrite(dc2430_site_DA2_Pin, LOW);
732 break;
733
734 case 3:
735 digitalWrite(dc2430_site_DA0_Pin, HIGH);
736 digitalWrite(dc2430_site_DA1_Pin, HIGH);
737 digitalWrite(dc2430_site_DA2_Pin, LOW);
738 break;
739
740 case 4:
741 digitalWrite(dc2430_site_DA0_Pin, LOW);
742 digitalWrite(dc2430_site_DA1_Pin, LOW);
743 digitalWrite(dc2430_site_DA2_Pin, HIGH);
744 break;
745
746 case 5:
747 digitalWrite(dc2430_site_DA0_Pin, HIGH);
748 digitalWrite(dc2430_site_DA1_Pin, LOW);
749 digitalWrite(dc2430_site_DA2_Pin, HIGH);
750 break;
751
752 case 6:
753 digitalWrite(dc2430_site_DA0_Pin, LOW);
754 digitalWrite(dc2430_site_DA1_Pin, HIGH);
755 digitalWrite(dc2430_site_DA2_Pin, HIGH);
756 break;
757
758 case 7:
759 digitalWrite(dc2430_site_DA0_Pin, HIGH);
760 digitalWrite(dc2430_site_DA1_Pin, HIGH);
761 digitalWrite(dc2430_site_DA2_Pin, HIGH);
762 break;
763
764 default:
765 Serial.println(F("Incorrect Option"));
766 break;
767 }
768 }
769
770 /* ------------------------------------------------------------------------- */
771 //! Prints the title block when program first starts.
772 void print_title()
773 {
774
775 Serial.println(F("\n*****************************************************************"));
776 Serial.println(F("* DC2610 Demonstration Program *"));
777 Serial.println(F("* - Input Voltage 3.3V (J30/J31) *"));
778 Serial.println(F("* *"));
779 Serial.println(F("* This program demonstrates how to send data to the LTC6953 *"));
780 Serial.println(F("* Ultra-Low Jitter, JESD204B Clock Distributor with Eleven *"));
781 Serial.println(F("* Programmable Outputs. *"));
782 Serial.println(F("* *"));
783 Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
784 Serial.println(F("* *"));
785 Serial.println(F("* Recommendations on how to best use LTC6952Wizard and DC2610 *"));
786 Serial.println(F("* Linduino code together *"));
787 Serial.println(F("* Use LTC6952Wizard to *"));
788 Serial.println(F("* - determine best SPI register values for specific *"));
789 Serial.println(F("* frequenices and Sync Methods for all settings *"));
790 Serial.println(F("* - Simulate LTC6953 Phase noise and Time Domain response *"));
791 Serial.println(F("* - initial engineering evaluation *"));
792 Serial.println(F("* use DC2610 Linduino code *"));
793 Serial.println(F("* - Create a look up table of the SPI register values created *"));
794 Serial.println(F("* from LTC6952Wizard (option 1) *"));
795 Serial.println(F("* - Software development for reading and writing to specific *"));
796 Serial.println(F("* register/address (option 2 & 3) *"));
797 Serial.println(F("* - Storing demo board settings on the demo board EEPROM *"));
798 Serial.println(F("* - starting place to use the DC2610 with the DC2430 *"));
799 Serial.println(F("*****************************************************************"));
800 Serial.println();
801 } // end of print_title
802
803
804 /* ------------------------------------------------------------------------- */
805 //! Prints main menu.
806 void print_prompt()
807 {
808
809 Serial.println(F("\nCommand Summary:"));
810 Serial.println(F(" 1-Load Default Settings from a Look-up Table"));
811 Serial.println(F(" 2-READ/WRITE to Registers Addresses"));
812 Serial.println(F(" 3-READ/WRITE to Registers Fields"));
813 Serial.println(F(" 4-Store LTC6953 SPI settings to the DC2610's EEPROM"));
814 Serial.println(F(" 5-Restore LTC6953 SPI settings from the DC2610's EEPROM"));
815 Serial.println(F(" 6-Adjust SPI frequency"));
816 if (Using_DC2430)
817 {
818 Serial.println(F(" 7-DC2430 Site Selector"));
819 }
820 Serial.println("");
821 Serial.print(F("Enter a command: "));
822 } // end of print_prompt
823
824
dc2430_site_DA2_Pin
static int dc2430_site_DA2_Pin
DC2430 digital pin allows Linduino to control which DC2430 site is selected.
Definition: DC2610A.ino:124
eeprom_read_int16
uint8_t eeprom_read_int16(uint8_t i2c_address, int16_t *read_data, uint16_t address)
Read the two byte integer data from the EEPROM starting at address.
Definition: QuikEval_EEPROM.cpp:395
LTC6953_SSRQ
#define LTC6953_SSRQ
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6953.h:166
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
Using_DC2430
boolean Using_DC2430
Indicator if DC2430 (Linduino Expander) is connected.
Definition: DC2610A.ino:114
menu_4_store_settings
static void menu_4_store_settings()
Store PLL settings to nonvolatile EEPROM on demo board.
Definition: DC2610A.ino:547
EEPROM_I2C_ADDRESS
#define EEPROM_I2C_ADDRESS
Definition: QuikEval_EEPROM.h:60
eeprom_write_byte
uint8_t eeprom_write_byte(uint8_t i2c_address, char data, uint16_t address)
Write the data byte to the EEPROM with i2c_address starting at EEPROM address.
Definition: QuikEval_EEPROM.cpp:214
LTC6953.h
LTC6953: Ultra-Low Jitter, JESD204B Clock Distributor with Eleven Programmable Outputs.
get_LTC6953_SPI_FIELD_RW
uint8_t get_LTC6953_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
Definition: LTC6953.cpp:265
dc2430_site_select
static void dc2430_site_select(int site_select)
Called from function menu_8_DC2430_site_select(), programs DC2430 to site selected.
Definition: DC2610A.ino:712
Linduino.h
Header File for Linduino Libraries and Demo Code.
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC2610A.ino:806
DC2610_board_connected
static int8_t DC2610_board_connected
Demo Board Name stored in QuikEval EEPROM.
Definition: DC2610A.ino:112
menu_3_RW_to_reg_field
static void menu_3_RW_to_reg_field()
Menu 3: Reads and/or Writes individual SPI fields This function provides the user with a list of all ...
Definition: DC2610A.ino:469
set_LTC6953_SPI_FIELD
void set_LTC6953_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6953 SPI field value calls function LTC6953_read_field, which reads specific address/fiel...
Definition: LTC6953.cpp:281
spi_enable
void spi_enable(uint8_t spi_clock_divider)
Setup the processor for hardware SPI communication.
Definition: LT_SPI.cpp:160
get_LTC6953_SPI_FIELD
long get_LTC6953_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6953 SPI field value calls function LTC6953_read_field, which reads specific address loca...
Definition: LTC6953.cpp:154
LTC6953_write
void LTC6953_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6953 Write Single Address writes 8 bit Data field to LTC6953.
Definition: LTC6953.cpp:175
data
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
First_Run
static uint8_t First_Run
if first time through loop = 0, otherwise=1
Definition: DC2610A.ino:113
menu_6_SPI_speed
static void menu_6_SPI_speed()
Read stored PLL settings from nonvolatile EEPROM on demo board.
Definition: DC2610A.ino:628
dc2430_site_DA0_Pin
static int dc2430_site_DA0_Pin
DC2430 digital pin allows Linduino to control which DC2430 site is selected.
Definition: DC2610A.ino:122
menu_1_load_default_settings
static void menu_1_load_default_settings()
Menu 1: Load Default SPI Register Settings This function loads the register settings from a look up t...
Definition: DC2610A.ino:305
loop
static void loop()
Repeats Linduino loop.
Definition: DC2610A.ino:241
eeprom_write_int16
uint8_t eeprom_write_int16(uint8_t i2c_address, int16_t write_data, uint16_t address)
Write the 2 byte integer data to the EEPROM starting at address.
Definition: QuikEval_EEPROM.cpp:377
dc2430_site_A1_APin
static int dc2430_site_A1_APin
DC2430 resistor tree, if it reads 1.66V then DC2430 connected.
Definition: DC2610A.ino:118
menu_2_RW_to_reg_addresss
static void menu_2_RW_to_reg_addresss()
Menu 2: Reads and/or Writes the SPI register address This function reads and displays all SPI registe...
Definition: DC2610A.ino:355
set_LTC6953_REGS_lkup_tbl
void set_LTC6953_REGS_lkup_tbl(uint8_t lkup_tbl_row)
Writes values to ALL LTC6953 RW addresses from a look-up table.
Definition: LTC6953.cpp:303
eeprom_read_byte
uint8_t eeprom_read_byte(uint8_t i2c_address, char *data, uint16_t address)
Read a data byte at address from the EEPROM with i2c_address.
Definition: QuikEval_EEPROM.cpp:282
QuikEval_EEPROM.h
QuikEval EEPROM Library.
dc2430_site_DA1_Pin
static int dc2430_site_DA1_Pin
DC2430 digital pin allows Linduino to control which DC2430 site is selected.
Definition: DC2610A.ino:123
menu_7_DC2430_site_select
static void menu_7_DC2430_site_select()
Read stored PLL settings from nonvolatile EEPROM on demo board.
Definition: DC2610A.ino:688
demo_board_connected
static int8_t demo_board_connected
Demo Board Name stored in QuikEval EEPROM.
Definition: DC2610A.ino:111
dc2430_en_Pin
static int dc2430_en_Pin
DC2430 digital pin enables Linduino to control which DC2430 site is selected & turns on DC2430 LED...
Definition: DC2610A.ino:125
menu_5_restore_settings
static void menu_5_restore_settings()
Read stored PLL settings from nonvolatile EEPROM on demo board.
Definition: DC2610A.ino:572
quikeval_SPI_init
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
EEPROM_CAL_STATUS_ADDRESS
#define EEPROM_CAL_STATUS_ADDRESS
Definition: QuikEval_EEPROM.h:58
discover_demo_board
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
Definition: QuikEval_EEPROM.cpp:141
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC2610A.ino:772
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
get_LTC6953_SPI_FIELD_NUMBITS
uint8_t get_LTC6953_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
Definition: LTC6953.cpp:252
LTC6953_init
void LTC6953_init()
Initializes the SPI MAP arrays The values set in initialization are used for all the LTC6953 SPI/WRIT...
Definition: LTC6953.cpp:353
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
setup
static void setup()
Initialize Linduino.
Definition: DC2610A.ino:130
demo_name
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
quikeval_SPI_connect
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
UserInterface.h
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
dc2430_site_A0_APin
static int dc2430_site_A0_APin
DC2430 resistor tree, if it reads 3.3V then DC2430 connected.
Definition: DC2610A.ino:117
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
i
static int i
Definition: DC2430A.ino:184
LTC6953_CS
#define LTC6953_CS
Define the SPI CS pin.
Definition: LTC6953.h:76
get_LTC6953_REGSIZE
uint8_t get_LTC6953_REGSIZE()
returns # of addresses in parts register map (array size)
Definition: LTC6953.cpp:242
discover_demo_board_local
int8_t discover_demo_board_local(char *demo_name)
Read the ID string from the EEPROM and determine if any demo board is connected.
Definition: LTC6951.cpp:831
field_menu_RW
long field_menu_RW(long field_val, char field_name[], uint8_t f)
Support function for function menu_3_RW_to_reg_field displays current state of select field provides ...
Definition: DC2610A.ino:412
EEPROM_CAL_KEY
#define EEPROM_CAL_KEY
Definition: QuikEval_EEPROM.h:59
DUTsync
static void DUTsync(uint16_t delay_num)
Syncs LTC6953 Outputs using SSYNC bit.
Definition: DC2610A.ino:615
LTC6953_read
uint8_t LTC6953_read(uint8_t cs, int8_t address)
LTC6953 Read Single Address reads 8 bit Data field to LTC6953.
Definition: LTC6953.cpp:98
dc2430_site_A2_APin
static int dc2430_site_A2_APin
DC2430 INFO ONLY, measures DC2226 (Linduino) VCCIO voltage.
Definition: DC2610A.ino:119