Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC2609A.ino
Go to the documentation of this file.
1 /*!
2 DC2609A
3 LTC6952: Ultralow Jitter, 4.5GHz PLL with 11 Outputs and JESD204B Support
4 
5 @verbatim
6 
7  Setup:
8  Set the terminal baud rate to 115200 and select the newline terminator.
9  Refer to Demo Manual DC2609A.
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 DC2609. 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/LTC6952
45 
46 http://www.linear.com/product/LTC6952#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 LTC6952
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 "LTC6952.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
104 void menu_4_store_settings();
106 void menu_6_SPI_speed();
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 DC2609_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[] = "DC2609"; // 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  LTC6952_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 DC2609 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
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.
184  {
185  Serial.println(F("\n********************************************************"));
186  DC2609_board_connected = discover_demo_board(demo_name); //! Checks if correct demo board is connected.
187 
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("\nDC2609 FOUND ON DC2430 SITE "));
197  Serial.println(site_select);
198  site_select=15;
199  }
200  }
201 
203  {
204  Serial.print(F("\nDC2609 NOT FOUND ON DC2430 SITE "));
205  Serial.print(site_select);
206  site_select++;
207  }
208  }
209  while (site_select<8);
210 
211  //! if no DC2609A was found. Return dc2430_en_Pin to default state (LOW)
213  {
214  digitalWrite(dc2430_en_Pin, LOW); // sets the LED on
215  Serial.println(F("\n\nConnect DC2609 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 DC2609
221  //! most common use case
222  Serial.println(F("DC2609A CONNECTED TO LINDUINO"));
223  DC2609_board_connected = discover_demo_board(demo_name); //! Checks if correct demo board is 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 
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:
260  break;
261 
262  case 2:
264  break;
265 
266  case 3:
268  break;
269 
270  case 4:
272  break;
273 
274  case 5:
276  break;
277 
278  case 6:
280  break;
281 
282  case 7:
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 LTC6952 performance.
304 //! @return void
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 LTC6952 Configuration *****************"));
318  Serial.println(F("\n*****************************************************************"));
319 
320  // Select Fields to read and write to
321  Serial.print(F("1- LTC6952 Front Page Datasheet Application\n"));
322  Serial.print(F("2- LTC6952 All output div 1\n"));
323  Serial.println(F("0 - Return to Main Menu\n"));
324 
325  Serial.println(F("Load LTC6952 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_LTC6952_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
356 {
357  uint8_t i, regval, user_regval, num_reg;
358  uint16_t user_address; // User input command
359 
360  num_reg = get_LTC6952_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 = LTC6952_read(LTC6952_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  LTC6952_write(LTC6952_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_LTC6952_SPI_FIELD_RW(f)==0)
425  {
426  field_size=get_LTC6952_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 43-MD4 85-PART
460 //! - 2-ADEL1 44-MD5 86-PDALL
461 //! - ....
462 //! - 40-MD1 82-OINV9 124-VCOOK
463 //! - 41-MD2 83-OINV10 125-x
464 //! - 42-MD3 84-PARSYNC
465 //! - 0 - Return to Main Menu
466 //! - * = READ ONLY FIELD
467 //! - Enter a command (1-125 to modify register, or '0' to return to Main Menu)
468 //! @return void
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 43-MD4 85-PART\n"));
482  Serial.print(F(" 2-ADEL1 44-MD5 86-PDALL\n"));
483  Serial.print(F(" 3-ADEL2 45-MD6 87-PDPLL\n"));
484  Serial.print(F(" 4-ADEL3 46-MD7 88-PDREFPK\n"));
485  Serial.print(F(" 5-ADEL4 47-MD8 89-PDVCOPK\n"));
486  Serial.print(F(" 6-ADEL5 48-MD9 90-PD10\n"));
487  Serial.print(F(" 7-ADEL6 49-MD10 91-PD9\n"));
488  Serial.print(F(" 8-ADEL7 50-MODE0 92-PD8\n"));
489  Serial.print(F(" 9-ADEL8 51-MODE1 93-PD7\n"));
490  Serial.print(F(" 10-ADEL9 52-MODE2 94-PD6\n"));
491  Serial.print(F(" 11-ADEL10 53-MODE3 95-PD5\n"));
492  Serial.print(F(" 12-BST 54-MODE4 96-PD4\n"));
493  Serial.print(F(" 13-CP 55-MODE5 97-PD3\n"));
494  Serial.print(F(" 14-CPDN 56-MODE6 98-PD2\n"));
495  Serial.print(F(" 15-CPINV 57-MODE7 99-PD1\n"));
496  Serial.print(F(" 16-CPMID 58-MODE8 100-PD0\n"));
497  Serial.print(F(" 17-CPRST 59-MODE9 101-POR\n"));
498  Serial.print(F(" 18-CPUP 60-MODE10 102-RAO\n"));
499  Serial.print(F(" 19-CPWIDE 61-MP0 103-RD\n"));
500  Serial.print(F(" 20-DDEL0 62-MP1 104-nREFOK\n"));
501  Serial.print(F(" 21-DDEL1 63-MP2 105-REFOK\n"));
502  Serial.print(F(" 22-DDEL2 64-MP3 106-REV\n"));
503  Serial.print(F(" 23-DDEL3 65-MP4 107-SYSCT\n"));
504  Serial.print(F(" 24-DDEL4 66-MP5 108-SRQMD\n"));
505  Serial.print(F(" 25-DDEL5 67-MP6 109-SSRQ\n"));
506  Serial.print(F(" 26-DDEL6 68-MP7 110-SRQEN0\n"));
507  Serial.print(F(" 27-DDEL7 69-MP8 111-SRQEN1\n"));
508  Serial.print(F(" 28-DDEL8 70-MP9 112-SRQEN2\n"));
509  Serial.print(F(" 29-DDEL9 71-MP10 113-SRQEN3\n"));
510  Serial.print(F(" 30-DDEL10 72-ND 114-SRQEN4\n"));
511  Serial.print(F(" 31-EZMD 73-OINV0 115-SRQEN5\n"));
512  Serial.print(F(" 32-FILTR 74-OINV1 116-SRQEN6\n"));
513  Serial.print(F(" 33-FILTV 75-OINV2 117-SRQEN7\n"));
514  Serial.print(F(" 34-INVSTAT 76-OINV3 118-SRQEN8\n"));
515  Serial.print(F(" 35-LKCT 77-OINV4 119-SRQEN9\n"));
516  Serial.print(F(" 36-LKWIN 78-OINV5 120-SRQEN10\n"));
517  Serial.print(F(" 37-nLOCK 79-OINV6 121-TEMPO\n"));
518  Serial.print(F(" 38-LOCK 80-OINV7 122-UNLOCK\n"));
519  Serial.print(F(" 39-MD0 81-OINV8 123-nVCOOK\n"));
520  Serial.print(F(" 40-MD1 82-OINV9 124-VCOOK\n"));
521  Serial.print(F(" 41-MD2 83-OINV10 125-x\n"));
522  Serial.print(F(" 42-MD3 84-PARSYNC\n"));
523 
524  Serial.print(F("0 - Return to Main Menu\n"));
525  Serial.print(F("* = READ ONLY FIELD\n\n"));
526 
527  Serial.print(F("Enter a command (1-125 to modify register, or '0' to return to Main Menu): "));
528  field_num = read_int(); //! Reads the user command
529  Serial.println(field_num);
530 
531  // User input: enter new setting for selected register
532  if (field_num != 0)
533  {
534  switch (field_num) //! Prints the appropriate submenu
535  {
536  default:
537  field_val=get_LTC6952_SPI_FIELD(LTC6952_CS,field_num); // reads selected field
538  field_val=field_menu_RW(field_val," ",field_num); // user interface control and printout
539  if (field_val>-1)
540  {
541  set_LTC6952_SPI_FIELD(LTC6952_CS, field_num, field_val); // updates selected field
542  }
543  break;
544  } // end of switch statement
545  } // end if user_command != 0 statement
546  } // end while loop
547 } // end menu_3_RW_to_reg_field function
548 
549 
550 /* ------------------------------------------------------------------------- */
551 //! Store PLL settings to nonvolatile EEPROM on demo board
552 //! @return void
554 {
555 // Store the PLL Settings to the EEPROM
556  uint8_t regval;
557 
558  uint8_t addr_offset;
559  uint8_t num_reg;
560 
561  addr_offset=2;
562  num_reg = get_LTC6952_REGSIZE();
563 
565 
566  for (uint8_t i = 0; i <= num_reg ; i++)
567  {
568  regval = LTC6952_read(LTC6952_CS,i);
570  }
571  Serial.println(F("PLL Settings Stored to EEPROM"));
572 
573 }
574 
575 /* ------------------------------------------------------------------------- */
576 //! Read stored PLL settings from nonvolatile EEPROM on demo board
577 //! @return void
579 {
580 // Read the PLL settings from EEPROM
581  int16_t cal_key;
582  uint8_t regval;
583  uint8_t user_address;
584 
585  uint8_t addr_offset;
586  uint8_t num_reg;
587  long field_val;
588  uint8_t field_num;
589 
590  addr_offset=2;
591  num_reg = get_LTC6952_REGSIZE();
592 
593 // read the cal key from the EEPROM
595  if (cal_key == EEPROM_CAL_KEY)
596  {
597  // PLL Settings has been stored, read PLL Settings
598  user_address=2;
599  for (uint8_t i = 0; i <= num_reg ; i++)
600  {
601  eeprom_read_byte(EEPROM_I2C_ADDRESS,(char *) &regval, EEPROM_CAL_STATUS_ADDRESS + i+addr_offset);
602  LTC6952_write(LTC6952_CS, (uint8_t)i, regval);
603  user_address++;
604  }
605  Serial.println(F("LTC6952 Settings Restored"));
606 
607  Serial.println(F("Syncs LTC6952 OUTPUTS"));
608  DUTsync(1);
609 
610  }
611  else
612  {
613  Serial.println(F("PLL Settings not found"));
614  }
615 
616 }
617 
618 /* ------------------------------------------------------------------------- */
619 //! Syncs LTC6952 Outputs using SSYNC bit
620 //! @return void
621 void DUTsync(uint16_t delay_num)
622 {
624  delay(1);
626  delay(delay_num);
627 }
628 
629 
630 
631 /* ------------------------------------------------------------------------- */
632 //! Read stored PLL settings from nonvolatile EEPROM on demo board
633 //! @return void
635 {
636  int temp_val;
637 
638  Serial.println(F("\nCommand Summary:"));
639  if (Using_DC2430)
640  {
641  Serial.println(F(" 1-8MHz NOT Available with DC2430"));
642  }
643  else
644  {
645  Serial.println(F(" 1-SPI Clock = 8MHz"));
646  }
647  Serial.println(F(" 2-SPI Clock = 4MHz"));
648  Serial.println(F(" 3-SPI Clock = 2MHz"));
649  Serial.println(F(" 4-SPI Clock = 1MHz"));
650  Serial.println(F(" 5-SPI Clock = 500kHz"));
651  Serial.println("");
652  Serial.print(F("Enter a command: "));
653  temp_val = read_int(); //! Reads the user command
654 
655  switch (temp_val) //! Prints the appropriate submenu
656  {
657  case 1:
658  if (Using_DC2430)
659  {
660  Serial.println(F("incorrect option"));
661  }
662  else
663  {
664  spi_enable(SPI_CLOCK_DIV2); //! 1) Configure the spi port for 8MHz SCK
665  }
666  break;
667 
668  case 2:
669  spi_enable(SPI_CLOCK_DIV4); //! 1) Configure the spi port for 4MHz SCK
670  break;
671 
672  case 3:
673  spi_enable(SPI_CLOCK_DIV8); //! 1) Configure the spi port for 2MHz SCK
674  break;
675 
676  case 4:
677  spi_enable(SPI_CLOCK_DIV16); //! 1) Configure the spi port for 1MHz SCK
678  break;
679 
680  case 5:
681  spi_enable(SPI_CLOCK_DIV32); //! 1) Configure the spi port for 500kHz SCK
682  break;
683 
684  default:
685  Serial.println(F("Incorrect Option"));
686  break;
687  }
688 }
689 
690 
691 /* ------------------------------------------------------------------------- */
692 //! Read stored PLL settings from nonvolatile EEPROM on demo board
693 //! @return void
695 {
696  int temp_val;
697 
698  Serial.println(F("\nCommand Summary:"));
699  Serial.println(F(" 0-Site 0"));
700  Serial.println(F(" 1-Site 1"));
701  Serial.println(F(" 2-Site 2"));
702  Serial.println(F(" 3-Site 3"));
703  Serial.println(F(" 4-Site 4"));
704  Serial.println(F(" 5-Site 5"));
705  Serial.println(F(" 6-Site 6"));
706  Serial.println(F(" 7-Site 7"));
707 
708  Serial.println("");
709  Serial.print(F("Enter a command: "));
710  temp_val = read_int(); //! Reads the user command
711 
712  dc2430_site_select(temp_val);
713 }
714 
715 /* ------------------------------------------------------------------------- */
716 //! Called from function menu_8_DC2430_site_select(), programs DC2430 to site selected
717 //! @return void
718 void dc2430_site_select(int site_select)
719 {
720  switch (site_select) //! Prints the appropriate submenu
721  {
722  case 0:
723  digitalWrite(dc2430_site_DA0_Pin, LOW);
724  digitalWrite(dc2430_site_DA1_Pin, LOW);
725  digitalWrite(dc2430_site_DA2_Pin, LOW);
726  break;
727 
728  case 1:
729  digitalWrite(dc2430_site_DA0_Pin, HIGH);
730  digitalWrite(dc2430_site_DA1_Pin, LOW);
731  digitalWrite(dc2430_site_DA2_Pin, LOW);
732  break;
733 
734  case 2:
735  digitalWrite(dc2430_site_DA0_Pin, LOW);
736  digitalWrite(dc2430_site_DA1_Pin, HIGH);
737  digitalWrite(dc2430_site_DA2_Pin, LOW);
738  break;
739 
740  case 3:
741  digitalWrite(dc2430_site_DA0_Pin, HIGH);
742  digitalWrite(dc2430_site_DA1_Pin, HIGH);
743  digitalWrite(dc2430_site_DA2_Pin, LOW);
744  break;
745 
746  case 4:
747  digitalWrite(dc2430_site_DA0_Pin, LOW);
748  digitalWrite(dc2430_site_DA1_Pin, LOW);
749  digitalWrite(dc2430_site_DA2_Pin, HIGH);
750  break;
751 
752  case 5:
753  digitalWrite(dc2430_site_DA0_Pin, HIGH);
754  digitalWrite(dc2430_site_DA1_Pin, LOW);
755  digitalWrite(dc2430_site_DA2_Pin, HIGH);
756  break;
757 
758  case 6:
759  digitalWrite(dc2430_site_DA0_Pin, LOW);
760  digitalWrite(dc2430_site_DA1_Pin, HIGH);
761  digitalWrite(dc2430_site_DA2_Pin, HIGH);
762  break;
763 
764  case 7:
765  digitalWrite(dc2430_site_DA0_Pin, HIGH);
766  digitalWrite(dc2430_site_DA1_Pin, HIGH);
767  digitalWrite(dc2430_site_DA2_Pin, HIGH);
768  break;
769 
770  default:
771  Serial.println(F("Incorrect Option"));
772  break;
773  }
774 }
775 
776 /* ------------------------------------------------------------------------- */
777 //! Prints the title block when program first starts.
779 {
780 
781  Serial.println(F("\n*****************************************************************"));
782  Serial.println(F("* DC2609 Demonstration Program *"));
783  Serial.println(F("* - Input Voltage 4-6V (J32) *"));
784  Serial.println(F("* - Input Voltage 9-12V (J30) *"));
785  Serial.println(F("* *"));
786  Serial.println(F("* This program demonstrates how to send data to the LTC6952 *"));
787  Serial.println(F("* Ultralow Jitter, 4.5GHz PLL with 11 Outputs and JESD204B *"));
788  Serial.println(F("* Support. *"));
789  Serial.println(F("* *"));
790  Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
791  Serial.println(F("* *"));
792  Serial.println(F("* Recommendations on how to best use LTC6952Wizard and DC2609 *"));
793  Serial.println(F("* Linduino code together *"));
794  Serial.println(F("* Use LTC6952Wizard to *"));
795  Serial.println(F("* - determine best SPI register values for specific *"));
796  Serial.println(F("* frequenices and Sync Methods for all settings *"));
797  Serial.println(F("* - Simulate LTC6952 Phase noise and Time Domain response *"));
798  Serial.println(F("* - initial engineering evaluation *"));
799  Serial.println(F("* use DC2609 Linduino code *"));
800  Serial.println(F("* - Create a look up table of the SPI register values created *"));
801  Serial.println(F("* from LTC6952Wizard (option 1) *"));
802  Serial.println(F("* - Software development for reading and writing to specific *"));
803  Serial.println(F("* register/address (option 2 & 3) *"));
804  Serial.println(F("* - Storing demo board settings on the demo board EEPROM *"));
805  Serial.println(F("* - starting place to use the DC2609 with the DC2430 *"));
806  Serial.println(F("*****************************************************************"));
807  Serial.println();
808 } // end of print_title
809 
810 
811 /* ------------------------------------------------------------------------- */
812 //! Prints main menu.
814 {
815 
816  Serial.println(F("\nCommand Summary:"));
817  Serial.println(F(" 1-Load Default Settings from a Look-up Table"));
818  Serial.println(F(" 2-READ/WRITE to Registers Addresses"));
819  Serial.println(F(" 3-READ/WRITE to Registers Fields"));
820  Serial.println(F(" 4-Store LTC6952 SPI settings to the DC2609's EEPROM"));
821  Serial.println(F(" 5-Restore LTC6952 SPI settings from the DC2609's EEPROM"));
822  Serial.println(F(" 6-Adjust SPI frequency"));
823  if (Using_DC2430)
824  {
825  Serial.println(F(" 7-DC2430 Site Selector"));
826  }
827  Serial.println("");
828  Serial.print(F("Enter a command: "));
829 } // end of print_prompt
830 
831 
static int8_t demo_board_connected
Demo Board Name stored in QuikEval EEPROM.
Definition: DC2609A.ino:111
#define LTC6952_SSRQ
for spi_map array, defines location for field specific information used to create the spi map ...
Definition: LTC6952.h:188
static int dc2430_site_DA2_Pin
DC2430 digital pin allows Linduino to control which DC2430 site is selected.
Definition: DC2609A.ino:124
static int dc2430_site_A1_APin
DC2430 resistor tree, if it reads 1.66V then DC2430 connected.
Definition: DC2609A.ino:118
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.
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: DC2609A.ino:469
unsigned char user_command
#define EEPROM_I2C_ADDRESS
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.
static void setup()
Initialize Linduino.
Definition: DC2609A.ino:130
uint8_t get_LTC6952_REGSIZE()
returns # of addresses in parts register map (array size)
Definition: LTC6952.cpp:244
static int dc2430_site_DA1_Pin
DC2430 digital pin allows Linduino to control which DC2430 site is selected.
Definition: DC2609A.ino:123
void set_LTC6952_REGS_lkup_tbl(uint8_t lkup_tbl_row)
Writes values to ALL LTC6952 RW addresses from a look-up table.
Definition: LTC6952.cpp:305
void LTC6952_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6952 Write Single Address writes 8 bit Data field to LTC6952.
Definition: LTC6952.cpp:177
Header File for Linduino Libraries and Demo Code.
static int dc2430_en_Pin
DC2430 digital pin enables Linduino to control which DC2430 site is selected & turns on DC2430 LED...
Definition: DC2609A.ino:125
uint8_t get_LTC6952_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
Definition: LTC6952.cpp:254
void spi_enable(uint8_t spi_clock_divider)
Setup the processor for hardware SPI communication.
Definition: LT_SPI.cpp:160
static void print_prompt()
Prints main menu.
Definition: DC2609A.ino:813
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: DC2609A.ino:412
static void print_title()
Prints the title block when program first starts.
Definition: DC2609A.ino:778
static void loop()
Repeats Linduino loop.
Definition: DC2609A.ino:241
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
uint8_t LTC6952_read(uint8_t cs, int8_t address)
LTC6952 Read Single Address reads 8 bit Data field to LTC6952.
Definition: LTC6952.cpp:100
void LTC6952_init()
Initializes the SPI MAP arrays The values set in initialization are used for all the LTC6952 SPI/WRIT...
Definition: LTC6952.cpp:355
LTC6952: Ultralow Jitter, 4.5GHz PLL with 11 Outputs and JESD204B Support.
static void dc2430_site_select(int site_select)
Called from function menu_8_DC2430_site_select(), programs DC2430 to site selected.
Definition: DC2609A.ino:718
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.
static int dc2430_site_A0_APin
DC2430 resistor tree, if it reads 3.3V then DC2430 connected.
Definition: DC2609A.ino:117
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.
QuikEval EEPROM Library.
boolean Using_DC2430
Indicator if DC2430 (Linduino Expander) is connected.
Definition: DC2609A.ino:114
static int8_t DC2609_board_connected
Demo Board Name stored in QuikEval EEPROM.
Definition: DC2609A.ino:112
static int dc2430_site_DA0_Pin
DC2430 digital pin allows Linduino to control which DC2430 site is selected.
Definition: DC2609A.ino:122
uint8_t get_LTC6952_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
Definition: LTC6952.cpp:267
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
#define EEPROM_CAL_STATUS_ADDRESS
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
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: DC2609A.ino:305
long get_LTC6952_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6952 SPI field value calls function LTC6952_read_field, which reads specific address loca...
Definition: LTC6952.cpp:156
#define LTC6952_CS
Define the SPI CS pin.
Definition: LTC6952.h:76
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
static void DUTsync(uint16_t delay_num)
Syncs LTC6952 Outputs using SSYNC bit.
Definition: DC2609A.ino:621
static void menu_6_SPI_speed()
Read stored PLL settings from nonvolatile EEPROM on demo board.
Definition: DC2609A.ino:634
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
int32_t read_int()
void set_LTC6952_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6952 SPI field value calls function LTC6952_read_field, which reads specific address/fiel...
Definition: LTC6952.cpp:283
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
static int i
Definition: DC2430A.ino:184
static void menu_5_restore_settings()
Read stored PLL settings from nonvolatile EEPROM on demo board.
Definition: DC2609A.ino:578
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
#define EEPROM_CAL_KEY
static uint8_t First_Run
if first time through loop = 0, otherwise=1
Definition: DC2609A.ino:113
static int dc2430_site_A2_APin
DC2430 INFO ONLY, measures DC2226 (Linduino) VCCIO voltage.
Definition: DC2609A.ino:119
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: DC2609A.ino:355
static void menu_4_store_settings()
Store PLL settings to nonvolatile EEPROM on demo board.
Definition: DC2609A.ino:553
static void menu_7_DC2430_site_select()
Read stored PLL settings from nonvolatile EEPROM on demo board.
Definition: DC2609A.ino:694