135 Serial.begin(115200);
145 Serial.println(F(
" was found"));
158 if (Serial.available())
166 if (user_command !=
'm')
167 Serial.println(user_command);
169 switch (user_command)
196 Serial.println(F(
"Incorrect Option"));
199 Serial.println(F(
"\n*****************************************************************"));
218 set_LTC6950_ALLREGS(
LTC6950_CS, 0x04,0x3b,0x08,0x00,0x3b,0x00,0x00,0x01,0x00,0x0a,0x44,0x80,0x84,0x80,0x84,0x80,0x84,0x80,0x84,0x80,0x04);
219 Serial.println(F(
"Registers Have Been Written"));
239 uint8_t
i, regval, user_regval, num_reg;
240 uint16_t user_address;
245 while (user_address != 0)
247 Serial.println(F(
"\n*****************************************************************"));
249 for (i=0; i<num_reg; i++)
254 Serial.print(F(
"- ADDR0"));
256 Serial.print(F(
"- ADDR"));
257 Serial.print(i, HEX);
258 Serial.print(F(
" = 0x"));
259 if (regval<16) Serial.print(F(
"0"));
260 Serial.print(regval, HEX);
261 if (i==3) Serial.print(F(
" (warning: if D2=1 it resets all registers. RES6950 Bit)"));
262 if ((i==0)||(i==(num_reg-1))) Serial.print(F(
" (read only) "));
265 Serial.print(
"0 - Return to Main Menu\n\n");
267 Serial.print(
"Enter a command (1-21 to modify register, or '0' to return to Main Menu): ");
269 Serial.println(user_address);
272 if (user_address >0 && user_address<(num_reg-1))
274 Serial.print(
"What value should ADDR");
275 Serial.print(user_address);
276 Serial.print(
" be set to (ex: HEX format 0xff): ");
278 Serial.println(user_regval);
298 uint8_t field_size,
i;
299 long max_num=1, pow2=1;
301 Serial.print(
"CURRENT STATE (HEX): ");
302 Serial.print(field_name);
303 Serial.print(
"= 0x");
304 Serial.println(field_val, HEX);
309 for (i=1; i<field_size; i++)
312 max_num=max_num + pow2;
315 Serial.print(
"What value should ");
316 Serial.print(field_name);
317 Serial.print(
" be set to or type '-1' to exit: (ex: HEX format 0x00 to 0x");
318 Serial.print(max_num, HEX);
322 if (usr_field_val>=0 && usr_field_val<=max_num)
324 Serial.println(usr_field_val);
325 return usr_field_val;
361 while (field_num != 0)
363 Serial.println(F(
"\n*****************************************************************"));
365 Serial.print(F(
"1-CMSINV 26-IBIAS3 51-PD_OUT2\n"));
366 Serial.print(F(
"2-CP 27-INV_ST1 52-PD_OUT3\n"));
367 Serial.print(F(
"3-CPCHI 28-INV_ST2 53-PD_OUT4\n"));
368 Serial.print(F(
"4-CPCLO 29-LKCT 54-PDPLL\n"));
369 Serial.print(F(
"5-CPDN 30-LKEN 55-PDREFAC\n"));
370 Serial.print(F(
"6-CPINV 31-LKWIN 56-PDVCOAC\n"));
371 Serial.print(F(
"7-CPMID 32-LOCK * 57-R\n"));
372 Serial.print(F(
"8-CPRST 33-LVCMS 58-RDIVOUT\n"));
373 Serial.print(F(
"9-CPUP 34-M0 59-RES6950\n"));
374 Serial.print(F(
"10-CPWIDE 35-M1 60-RESET_R\n"));
375 Serial.print(F(
"11-DEL0 36-M2 61-RESET_N\n"));
376 Serial.print(F(
"12-DEL1 37-M3 62-REV *\n"));
377 Serial.print(F(
"13-DEL2 38-M4 63-SM1\n"));
378 Serial.print(F(
"14-DEL3 39-N 64-SM2\n"));
379 Serial.print(F(
"15-DEL4 40-NO_REF * 65-SYNCMD\n"));
380 Serial.print(F(
"16-FILTR 41-NO_VCO * 66-SYNC_EN0\n"));
381 Serial.print(F(
"17-FILTV 42-PART * 67-SYNC_EN1\n"));
382 Serial.print(F(
"18-FLDRV0 43-PDALL 68-SYNC_EN2\n"));
383 Serial.print(F(
"19-FLDRV1 44-PD_DIV0 69-SYNC_EN3\n"));
384 Serial.print(F(
"20-FLDRV2 45-PD_DIV1 70-SYNC_EN4\n"));
385 Serial.print(F(
"21-FLDRV3 46-PD_DIV2 71-THI *\n"));
386 Serial.print(F(
"22-FLDRV4 47-PD_DIV3 72-TLO *\n"));
387 Serial.print(F(
"23-IBIAS0 48-PD_DIV4 73-UNLOCK *\n"));
388 Serial.print(F(
"24-IBIAS1 49-PD_OUT0 \n"));
389 Serial.print(F(
"25-IBIAS2 50-PD_OUT1 \n"));
390 Serial.print(
"0 - Return to Main Menu\n");
391 Serial.print(
"* = READ ONLY FIELD\n\n");
393 Serial.print(
"Enter a command (1-73 to modify register, or '0' to return to Main Menu): ");
395 Serial.println(field_num);
825 unsigned long temp_val, temp_max_VCO_MHz, temp_min_VCO_MHz, temp_max_VCO_Hz, temp_min_VCO_Hz;
826 unsigned long fvco_max[2], fvco_min[2], fvco_max_lim[2], fvco_min_lim[2];
827 boolean valid_input=
false;
833 while (valid_input==
false)
840 Serial.print(F(
"What is the upper frequency limit of the VCO (MHZ portion)? ["));
841 Serial.print(temp_max_VCO_MHz);
842 Serial.print(F(
"]: "));
845 if (temp_val!=0) temp_max_VCO_MHz = abs(temp_val);
846 Serial.println(temp_max_VCO_MHz);
848 Serial.print(F(
"What is the upper VCO frequency limit (HZ portion)? "));
851 Serial.println(temp_max_VCO_Hz);
853 Serial.print(F(
"\nWhat is the lower frequency limit of the VCO (MHZ portion)? ["));
854 Serial.print(temp_min_VCO_MHz);
855 Serial.print(F(
"]: "));
858 if (temp_val!=0) temp_min_VCO_MHz = abs(temp_val);
859 Serial.println(temp_min_VCO_MHz);
861 Serial.print(F(
"What is the lower frequency limit of the VCO (HZ portion)? "));
863 Serial.println(temp_min_VCO_Hz);
865 HZto64(fvco_max,temp_max_VCO_MHz,temp_max_VCO_Hz);
866 HZto64(fvco_min,temp_min_VCO_MHz,temp_min_VCO_Hz);
872 if (
lt64(fvco_min_lim,fvco_min) &&
lt64(fvco_max,fvco_max_lim) &&
873 lt64(fvco_min_lim,fvco_max) &&
lt64(fvco_min,fvco_max_lim) &&
874 (
eq64(fvco_min, fvco_max) ||
lt64(fvco_min, fvco_max)) )
877 Serial.print(F(
"VCO Frequencies entered are valid\n"));
882 Serial.print(F(
"VCO Frequencies must be less than 1400MHz\n"));
892 unsigned long temp_val, temp_fref_MHz, temp_fref_Hz;
893 boolean valid_input=
false;
899 while (valid_input==
false)
903 Serial.print(F(
"\nWhat is the MHz portion of the Reference Input Frequency(MHZ)? ["));
904 Serial.print(temp_fref_MHz);
905 Serial.print(F(
"]: "));
908 if (temp_val!=0) temp_fref_MHz = abs(temp_val);
909 Serial.println(temp_fref_MHz);
911 Serial.print(F(
"What is the sub-MHz portion of the Reference Input Frequency(HZ)? "));
913 temp_fref_Hz = abs(temp_val);
914 Serial.println(temp_fref_Hz);
920 temp_val= temp_fref_MHz*
OneMHz + temp_fref_Hz;
921 Serial.print(F(
"Reference Frequency set to "));
922 Serial.print(temp_val);
923 Serial.println(F(
"Hz"));
928 Serial.print(F(
"Reference Frequency must be between 2MHz and 250MHz\n"));
937 ---------------------------------------------------------------------------- */
940 unsigned long odiv, temp_fout_MHz, temp_fout_Hz, temp_val;
941 unsigned long frf[2];
942 boolean valid_input=
false;
948 while (valid_input==
false)
950 Serial.print(F(
"\nWhat is the MHz portion of the Output Frequency(MHZ)? ["));
951 Serial.print(temp_fout_MHz);
952 Serial.print(F(
"]: "));
955 if (temp_val!=0) temp_fout_MHz = abs(temp_val);
956 Serial.println(temp_fout_MHz);
958 Serial.print(F(
"What is the Hz portion of the Output Frequency(HZ)? "));
960 temp_fout_Hz = abs(temp_val);
961 Serial.println(temp_fout_Hz);
963 HZto64(frf,temp_fout_MHz,temp_fout_Hz);
968 if ((odiv>=1) && (odiv<=63)) valid_input=
true;
971 if (valid_input==
true)
974 if (temp_fout_MHz < 4294)
976 temp_val= temp_fout_MHz*
OneMHz + temp_fout_Hz;
977 Serial.print(F(
"Desired Output Frequency is "));
978 Serial.print(temp_val);
979 Serial.println(F(
"Hz"));
983 Serial.print(F(
"Desired Output Frequency is "));
984 Serial.print(temp_fout_MHz);
985 Serial.print(F(
"MHz + "));
986 Serial.print(temp_fout_Hz);
987 Serial.println(F(
"Hz"));
993 Serial.println(F(
"Invalid Fout frequency chosen"));
1010 Serial.print(F(
"\nThis function calculates and programs OD and ND\n"));
1011 Serial.print(F(
"based on the value input for Fvco, Frf and Fref.\n"));
1012 Serial.print(F(
"It assumes all other register settings are correct\n"));
1013 Serial.print(F(
"The ClockWizard tool can verify the correctness of the other register settings.\n"));
1016 Serial.print(F(
"\nThe following frequencies will be entered with 2 integers\n"));
1017 Serial.print(F(
"1st number is the MHZ portion, the 2nd number is Hz portion\n"));
1018 Serial.print(F(
" - Example: A. 100\n"));
1019 Serial.print(F(
" B. 25\n"));
1020 Serial.print(F(
" equates to 100.000025MHZ\n\n"));
1035 uint8_t addr_offset;
1043 for (uint8_t
i = 0;
i <= num_reg ;
i++)
1048 Serial.println(F(
"PLL Settings Stored to EEPROM"));
1061 uint8_t user_address;
1063 uint8_t addr_offset;
1075 for (uint8_t
i = 0;
i <= num_reg ;
i++)
1081 Serial.println(F(
"PLL Settings Restored"));
1085 Serial.println(F(
"PLL Settings not found"));
1096 Serial.println(F(
"*****************************************************************"));
1097 Serial.println(F(
"* DC1795 Demonstration Program *"));
1098 Serial.println(F(
"* *"));
1099 Serial.println(F(
"* This program demonstrates how to send data to the LTC6950 *"));
1100 Serial.println(F(
"* 1.4GHz Low Phase Noise, Low Jitter PLL with Clock *"));
1101 Serial.println(F(
"* Distribution. *"));
1102 Serial.println(F(
"* *"));
1103 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
1104 Serial.println(F(
"* *"));
1105 Serial.println(F(
"* For loop filter design please use the Clock Wizard software. *"));
1106 Serial.println(F(
"* - It is recommended to use ClockWizard to determine the *"));
1107 Serial.println(F(
"* correct SPI register values for the initial setup. These *"));
1108 Serial.println(F(
"* values can be entered into this program via menu option 2 *"));
1109 Serial.println(F(
"* below. These values can then be stored and recalled from the *"));
1110 Serial.println(F(
"* DC1795 EEPROM using options 5 and 6 below. *"));
1111 Serial.println(F(
"*****************************************************************"));
1121 Serial.println(F(
"\nCommand Summary:"));
1122 Serial.println(F(
" 1-Load Default Settings (same as the Clock Wizard's LTC6950_ALL_CHAN_250MHz.clkset settings)"));
1123 Serial.println(F(
" 2-READ/WRITE to Registers Addresses"));
1124 Serial.println(F(
" 3-READ/WRITE to Registers Fields"));
1125 Serial.println(F(
" 4-Set Output Frequency - OUT0"));
1126 Serial.println(F(
" 5-Store LTC6950 SPI settings to the DC1795's EEPROM"));
1127 Serial.println(F(
" 6-Restore LTC6950 SPI settings from the DC1795's EEPROM"));
1129 Serial.print(F(
"Enter a command: "));
#define LTC6950_RES6950
for spi_map array, defines location for field specific information used to create the spi map ...
struct demo_board_type demo_board
Instantiate demo board structure.
boolean lt64(unsigned long an[], unsigned long ann[])
64 bit, if an < ann, then true
#define LTC6950_CPWIDE
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6950_global_frf_MHz()
returns global LTC6950_Frf_MHz
uint8_t get_LTC6950_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
#define LTC6950_N
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_NO_REF
for spi_map array, defines location for field specific information used to create the spi map ...
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_6_restore_settings()
Read stored PLL settings from nonvolatile EEPROM on demo board.
unsigned char user_command
#define EEPROM_I2C_ADDRESS
#define LTC6950_RESET_N
for spi_map array, defines location for field specific information used to create the spi map ...
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.
char name[15]
Demo Circuit number (DC1678)
#define LTC6950_RESET_R
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_CS
Define the SPI CS pin.
#define LTC6950_LKCT
for spi_map array, defines location for field specific information used to create the spi map ...
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 ...
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 ...
static void menu_1_load_default_settings()
Menu 1: Load Default SPI Register Settings This function loads the register settings referenced in th...
#define LTC6950_CPCLO
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_SYNC_EN0
for spi_map array, defines location for field specific information used to create the spi map ...
Header File for Linduino Libraries and Demo Code.
#define LTC6950_PDALL
for spi_map array, defines location for field specific information used to create the spi map ...
void LTC6950_set_frf()
FUNCTION: LTC6950_set_frf Calculates the integer (N) and output divider (OD) SPI values using self cr...
#define LTC6950_SYNCMD
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_CPCHI
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_PDREFAC
for spi_map array, defines location for field specific information used to create the spi map ...
void set_LTC6950_global_frf(unsigned long frf_MHz, unsigned long frf_Hz)
sets globals LTC6950_Frf_MHz and LTC6950_Frf_Hz
#define OneMHz
1MHz in long format, used in 64 bit math
boolean eq64(unsigned long an[], unsigned long ann[])
64 bit, if an == ann, then true
#define LTC6950_TLO
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_FILTV
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_PDPLL
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_PDVCOAC
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_R
for spi_map array, defines location for field specific information used to create the spi map ...
static void menu_5_store_settings()
Store PLL settings to nonvolatile EEPROM on demo board.
static uint8_t ref_out
Used to keep track of reference out status.
unsigned long get_LTC6950_global_frf_Hz()
returns global LTC6950_Frf_Hz
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.
#define LTC6950_LKEN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_LKWIN
for spi_map array, defines location for field specific information used to create the spi map ...
static int8_t demo_board_connected
Demo Board Name stored in QuikEval EEPROM.
union LT_union_int32_4bytes data
#define LTC6950_UNLOCK
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_MAXFREQ
LTC6950 upper freq limit.
#define LTC6950_DEL0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_CPUP
for spi_map array, defines location for field specific information used to create the spi map ...
static void menu_4_set_frf()
Menu 4: Calculates and programs OD, ND, NUM based on desired Frf This function calculates and program...
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...
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.
LTC6950: 1.4GHz Low Phase Noise, Low Jitter PLL with Clock Distribution.
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.
void set_LTC6950_global_fref(unsigned long fref_MHz, unsigned long fref_Hz)
sets globals LTC6950_Fref_MHz and LTC6950_Fref_Hz
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.
#define LTC6950_M0
for spi_map array, defines location for field specific information used to create the spi map ...
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 ...
static void setup()
Initialize Linduino.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
unsigned long get_LTC6950_global_VCO_MAX_MHz()
returns global LTC6950_VCO_Max_Freq_MHz
#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.
static void loop()
Repeats Linduino loop.
unsigned long get_LTC6950_global_VCO_MIN_MHz()
returns global LTC6950_VCO_Min_Freq_MHz
#define LTC6950_FLDRV0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_REV
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_CPMID
for spi_map array, defines location for field specific information used to create the spi map ...
void LTC6950_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6950 Write Single Address writes 8 bit Data field to LTC6950.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
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
#define LTC6950_MAX_REF_FREQ
LTC6950 upper reference frequency limit.
static void print_title()
Prints the title block when program first starts.
static void LTC6950_Fout_Freq_Verification()
#define LTC6950_RDIVOUT
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t LTC6950_read(uint8_t cs, int8_t address)
LTC6950 Read Single Address reads 8 bit Data field to LTC6950.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC6950_IBIAS0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_MIN_REF_FREQ
LTC6950 lower reference frequency limit.
unsigned long get_LTC6950_global_fref_MHz()
returns global LTC6950_Fref_MHz
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
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_...
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...
void LTC6950_init()
Initializes the SPI MAP arrays The values set in initialization are used for all the LTC6950 SPI/WRIT...
#define LTC6950_CPRST
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_PART
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_MINFREQ
LTC6950 lower freq limit.
#define LTC6950_INV_ST1
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6950_global_VCO_MIN_Hz()
returns global LTC6950_VCO_Min_Freq_Hz
#define LTC6950_NO_VCO
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6950_global_fref_Hz()
returns global LTC6950_Fref_Hz
#define LTC6950_CPDN
for spi_map array, defines location for field specific information used to create the spi map ...
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...
uint8_t get_LTC6950_REGSIZE()
returns # of addresses in parts register map (array size)
unsigned long get_LTC6950_global_VCO_MAX_Hz()
returns global LTC6950_VCO_Max_Freq_Hz
static uint8_t First_Run
if first time through loop = 0, otherwise=1
#define LTC6950_LOCK
for spi_map array, defines location for field specific information used to create the spi map ...
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
#define LTC6950_SM1
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_PD_OUT0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_CP
for spi_map array, defines location for field specific information used to create the spi map ...
static void print_prompt()
Prints main menu.
static void LTC6950_Ref_Freq_Verification()
verifies reference frequency is within datasheet specifications
static void LTC6950_VCO_Freq_Verification()
verifies VCO frequency is within datasheet specifications
#define LTC6950_CMSINV
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_PD_DIV0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_LVCMS
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_THI
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_CPINV
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6950_FILTR
for spi_map array, defines location for field specific information used to create the spi map ...