138 Serial.begin(115200);
148 Serial.println(F(
" was found"));
161 if (Serial.available())
169 if (user_command !=
'm')
170 Serial.println(user_command);
172 switch (user_command)
199 Serial.println(F(
"Incorrect Option"));
202 Serial.println(F(
"\n*****************************************************************"));
221 set_LTC6945_ALLREGS(
LTC6945_CS, 0x04,0x0C,0x01,0x90,0x0E,0x48,0x03,0x99,0xDB,0x00);
222 Serial.println(F(
"Registers Have Been Written"));
242 uint8_t
i, regval, user_regval, num_reg;
243 uint16_t user_address;
248 while (user_address != 0)
250 Serial.println(F(
"\n*****************************************************************"));
252 for (i=0; i<num_reg; i++)
257 Serial.print(F(
"- ADDR0"));
259 Serial.print(F(
"- ADDR"));
260 Serial.print(i, HEX);
261 Serial.print(F(
" = 0x"));
262 if (regval<16) Serial.print(F(
"0"));
263 Serial.print(regval, HEX);
264 if ((i==0)||(i==(num_reg-1))) Serial.print(
" (read only) ");
265 if (i==2) Serial.print(
" (warning: if D0=1 it resets all registers. Power On Reset Bit)");
268 Serial.print(
"0 - Return to Main Menu\n\n");
270 Serial.print(
"Enter a command (1-10 to modify register, or '0' to return to Main Menu): ");
272 Serial.println(user_address);
275 if (user_address >0 && user_address<(num_reg-1))
277 Serial.print(
"What value should ADDR");
278 Serial.print(user_address);
279 Serial.print(
" be set to (ex: HEX format 0xff): ");
281 Serial.println(user_regval);
301 uint8_t field_size,
i;
302 long max_num=1, pow2=1;
304 Serial.print(
"CURRENT STATE (HEX): ");
305 Serial.print(field_name);
306 Serial.print(
"= 0x");
307 Serial.println(field_val, HEX);
312 for (i=1; i<field_size; i++)
315 max_num=max_num + pow2;
318 Serial.print(
"What value should ");
319 Serial.print(field_name);
320 Serial.print(
" be set to or type '-1' to exit: (ex: HEX format 0x00 to 0x");
321 Serial.print(max_num, HEX);
325 if (usr_field_val>=0 && usr_field_val<=max_num)
327 Serial.println(usr_field_val);
328 return usr_field_val;
368 while (field_num != 0)
370 Serial.println(F(
"\n*****************************************************************"));
372 Serial.print(F(
"1-BST 12-LKCT 23-PDREFO\n"));
373 Serial.print(F(
"2-CP 13-LKEN 24-POR\n"));
374 Serial.print(F(
"3-CPCHI 14-LKWIN 25-RD\n"));
375 Serial.print(F(
"4-CPCLO 15-LOCK * 26-REV *\n"));
376 Serial.print(F(
"5-CPDN 16-ND 27-RFO\n"));
377 Serial.print(F(
"6-CPINV 17-OD 28-THI *\n"));
378 Serial.print(F(
"7-CPMID 18-OMUTE 29-TLO *\n"));
379 Serial.print(F(
"8-CPRST 19-PART * 30-UNLOCK *\n"));
380 Serial.print(F(
"9-CPUP 20-PDALL 31-x\n"));
381 Serial.print(F(
"10-CPWIDE 21-PDOUT \n"));
382 Serial.print(F(
"11-FILT 22-PDPLL \n"));
383 Serial.print(
"0 - Return to Main Menu\n");
384 Serial.print(
"* = READ ONLY FIELD\n\n");
385 Serial.print(
"Enter a command (1-31 to modify register, or '0' to return to Main Menu): ");
387 Serial.println(field_num);
682 unsigned long temp_val, temp_max_VCO_MHz, temp_min_VCO_MHz, temp_max_VCO_Hz, temp_min_VCO_Hz;
683 unsigned long fvco_max[2], fvco_min[2], fvco_max_lim[2], fvco_min_lim[2];
684 boolean valid_input=
false;
690 while (valid_input==
false)
697 Serial.print(F(
"What is the upper frequency limit of the VCO (MHZ portion)? ["));
698 Serial.print(temp_max_VCO_MHz);
699 Serial.print(F(
"]: "));
702 if (temp_val!=0) temp_max_VCO_MHz = abs(temp_val);
703 Serial.println(temp_max_VCO_MHz);
705 Serial.print(F(
"What is the upper VCO frequency limit (HZ portion)? "));
708 Serial.println(temp_max_VCO_Hz);
710 Serial.print(F(
"\nWhat is the lower frequency limit of the VCO (MHZ portion)? ["));
711 Serial.print(temp_min_VCO_MHz);
712 Serial.print(F(
"]: "));
715 if (temp_val!=0) temp_min_VCO_MHz = abs(temp_val);
716 Serial.println(temp_min_VCO_MHz);
718 Serial.print(F(
"What is the lower frequency limit of the VCO (HZ portion)? "));
720 Serial.println(temp_min_VCO_Hz);
722 HZto64(fvco_max,temp_max_VCO_MHz,temp_max_VCO_Hz);
723 HZto64(fvco_min,temp_min_VCO_MHz,temp_min_VCO_Hz);
729 if (
lt64(fvco_min_lim,fvco_min) &&
lt64(fvco_max,fvco_max_lim) &&
730 lt64(fvco_min_lim,fvco_max) &&
lt64(fvco_min,fvco_max_lim) &&
731 (
eq64(fvco_min, fvco_max) ||
lt64(fvco_min, fvco_max)) )
734 Serial.print(F(
"VCO Frequencies entered are valid\n"));
739 Serial.print(F(
"LTC6945 VCO Frequency datasheet limits are 350MHz to 6000MHz\n"));
750 unsigned long temp_val, temp_fref_MHz, temp_fref_Hz;
751 boolean valid_input=
false;
757 while (valid_input==
false)
761 Serial.print(F(
"\nWhat is the MHz portion of the Reference Input Frequency(MHZ)? ["));
762 Serial.print(temp_fref_MHz);
763 Serial.print(F(
"]: "));
766 if (temp_val!=0) temp_fref_MHz = abs(temp_val);
767 Serial.println(temp_fref_MHz);
769 Serial.print(F(
"What is the sub-MHz portion of the Reference Input Frequency(HZ)? "));
771 temp_fref_Hz = abs(temp_val);
772 Serial.println(temp_fref_Hz);
778 temp_val= temp_fref_MHz*
OneMHz + temp_fref_Hz;
779 Serial.print(F(
"Reference Frequency set to "));
780 Serial.print(temp_val);
781 Serial.println(F(
"Hz"));
786 Serial.print(F(
"Reference Frequency must be between 10MHz and 250MHz\n"));
796 unsigned long odiv, temp_fout_MHz, temp_fout_Hz, temp_val;
797 unsigned long frf[2];
798 boolean valid_input=
false;
804 while (valid_input==
false)
806 Serial.print(F(
"\nWhat is the MHz portion of the Output Frequency(MHZ)? ["));
807 Serial.print(temp_fout_MHz);
808 Serial.print(F(
"]: "));
811 if (temp_val!=0) temp_fout_MHz = abs(temp_val);
812 Serial.println(temp_fout_MHz);
814 Serial.print(F(
"What is the Hz portion of the Output Frequency(HZ)? "));
816 temp_fout_Hz = abs(temp_val);
817 Serial.println(temp_fout_Hz);
819 HZto64(frf,temp_fout_MHz,temp_fout_Hz);
824 if ((odiv>=1) && (odiv<=6)) valid_input=
true;
827 if (valid_input==
true)
830 if (temp_fout_MHz < 4294)
832 temp_val= temp_fout_MHz*
OneMHz + temp_fout_Hz;
833 Serial.print(F(
"Desired Output Frequency is "));
834 Serial.print(temp_val);
835 Serial.println(F(
"Hz"));
839 Serial.print(F(
"Desired Output Frequency is "));
840 Serial.print(temp_fout_MHz);
841 Serial.print(F(
"MHz + "));
842 Serial.print(temp_fout_Hz);
843 Serial.println(F(
"Hz"));
849 Serial.println(F(
"Invalid Fout frequency chosen"));
850 Serial.println(F(
"Fout must be between the VCO freq range entered above"));
867 Serial.print(F(
"\nThis function calculates and programs OD and ND\n"));
868 Serial.print(F(
"based on the value input for Fvco, Frf and Fref.\n"));
869 Serial.print(F(
"This function assumes all other register settings are correct.\n"));
870 Serial.print(F(
"The PLLWizard tool can verify the correctness of the other register settings.\n"));
872 Serial.print(F(
"\nThe following frequencies will be entered with 2 integers\n"));
873 Serial.print(F(
"1st number is the MHZ portion, the 2nd number is Hz portion\n"));
874 Serial.print(F(
" - Example: A. 100\n"));
875 Serial.print(F(
" B. 25\n"));
876 Serial.print(F(
" equates to 100.000025MHZ\n\n"));
900 for (uint8_t
i = 0;
i <= num_reg ;
i++)
905 Serial.println(F(
"PLL Settings Stored to EEPROM"));
918 uint8_t user_address;
932 for (uint8_t
i = 0;
i <= num_reg ;
i++)
938 Serial.println(F(
"PLL Settings Restored"));
942 Serial.println(F(
"PLL Settings not found"));
953 Serial.println(F(
"*****************************************************************"));
954 Serial.println(F(
"* DC1649 Demonstration Program *"));
955 Serial.println(F(
"* *"));
956 Serial.println(F(
"* This program demonstrates how to send data to the LTC6945 *"));
957 Serial.println(F(
"* Ultra Low Noise & Spurious Integer-N Synthesizer. *"));
958 Serial.println(F(
"* *"));
959 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
960 Serial.println(F(
"* *"));
961 Serial.println(F(
"* For loop filter design please use the PLL Wizard software. *"));
962 Serial.println(F(
"* - It is recommended to use Pll Wizard to determine the *"));
963 Serial.println(F(
"* correct SPI register values for the initial setup. These *"));
964 Serial.println(F(
"* values can be entered into this program via menu option 2 *"));
965 Serial.println(F(
"* below. These values can then be stored and recalled from the *"));
966 Serial.println(F(
"* DC1649 EEPROM using options 5 and 6 below. *"));
967 Serial.println(F(
"*****************************************************************"));
977 Serial.println(F(
"\nCommand Summary:"));
978 Serial.println(F(
" 1-Load Default Settings (same as the PLLWizard's DC1649_100MHz.pllset settings)"));
979 Serial.println(F(
" 2-READ/WRITE to Registers Addresses"));
980 Serial.println(F(
" 3-READ/WRITE to Registers Fields"));
981 Serial.println(F(
" 4-Set Output Frequency (Frf)"));
982 Serial.println(F(
" 5-Store LTC6945 SPI settings to the DC1649's EEPROM"));
983 Serial.println(F(
" 6-Restore LTC6945 SPI settings from the DC1649's EEPROM"));
985 Serial.print(F(
"Enter a command: "));
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 LTC6945_CP
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6945_global_VCO_MIN_Hz()
returns global LTC6945_VCO_Min_Freq_Hz
void set_LTC6945_global_frf(unsigned long frf_MHz, unsigned long frf_Hz)
sets globals LTC6945_Frf_MHz and LTC6945_Frf_Hz
#define LTC6945_LOCK
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 and ND based on desired Frf This function calculates and programs ...
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.
long get_LTC6945_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6945 SPI field value calls function LTC6945_read_field, which reads specific address loca...
unsigned char user_command
void set_LTC6945_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6945 SPI field value calls function LTC6945_read_field, which reads specific address/fiel...
#define EEPROM_I2C_ADDRESS
static void setup()
Initialize Linduino.
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.
#define LTC6945_FILT
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_CPRST
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 ...
char name[15]
Demo Circuit number (DC1678)
uint8_t LTC6945_read(uint8_t cs, int8_t address)
LTC6945 Read Single Address reads 8 bit Data field to LTC6945.
static int8_t demo_board_connected
Demo Board Name stored in QuikEval EEPROM.
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 ...
Header File for Linduino Libraries and Demo Code.
uint8_t get_LTC6945_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
#define LTC6945_LKEN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_BST
for spi_map array, defines location for field specific information used to create the spi map ...
static void LTC6945_Fout_Freq_Verification()
verifies frf frequency is within datasheet specifications
unsigned long LTC6945_calc_odiv(unsigned long frf[2])
calculates the output divider setting based on the frf and on board VCO frequencies of LTC6945 ...
#define LTC6945_TLO
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6945_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
unsigned long get_LTC6945_global_fref_MHz()
returns global LTC6945_Fref_MHz
#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
void LTC6945_init()
Initializes the SPI MAP arrays The values set in initialization are used for all the LTC6945 SPI/WRIT...
#define LTC6945_PDALL
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_ND
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_OD
for spi_map array, defines location for field specific information used to create the spi map ...
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 LTC6945_MAX_REF_FREQ
LTC6945 upper reference frequency limit.
static void print_prompt()
Prints main menu.
static void menu_5_store_settings()
Store PLL settings to nonvolatile EEPROM on demo board.
void set_LTC6945_global_fref(unsigned long fref_MHz, unsigned long fref_Hz)
sets globals LTC6945_Fref_MHz and LTC6945_Fref_Hz
static void LTC6945_Ref_Freq_Verification()
verifies reference frequency is within datasheet specifications
static uint8_t First_Run
if first time through loop = 0, otherwise=1
union LT_union_int32_4bytes data
unsigned long get_LTC6945_global_fref_Hz()
returns global LTC6945_Fref_Hz
#define LTC6945_POR
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6945_global_frf_MHz()
returns global LTC6945_Frf_MHz
#define LTC6945_PDOUT
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_THI
for spi_map array, defines location for field specific information used to create the spi map ...
static uint8_t ref_out
Used to keep track of reference out status.
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.
#define LTC6945_PDPLL
for spi_map array, defines location for field specific information used to create the spi map ...
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 LTC6945_MAXFREQ
LTC6945 upper freq limit.
void set_LTC6945_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)
Writes values to ALL LTC6945 RW addresses.
unsigned long get_LTC6945_global_frf_Hz()
returns global LTC6945_Frf_Hz
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
#define LTC6945_LKWIN
for spi_map array, defines location for field specific information used to create the spi map ...
void LTC6945_set_frf()
FUNCTION: LTC6945_set_frf Calculates the integer (N), fractional (NUM) and output divider (OD) SPI va...
#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.
unsigned long get_LTC6945_global_VCO_MAX_Hz()
returns global LTC6945_VCO_Max_Freq_Hz
#define LTC6945_CPINV
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6945_global_VCO_MAX_MHz()
returns global LTC6945_VCO_Max_Freq_MHz
#define LTC6945_CS
Define the SPI CS pin.
#define LTC6945_RFO
for spi_map array, defines location for field specific information used to create the spi map ...
static void print_title()
Prints the title block when program first starts.
static void loop()
Repeats Linduino loop.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define LTC6945_LKCT
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_CPMID
for spi_map array, defines location for field specific information used to create the spi map ...
static void menu_6_restore_settings()
Read stored PLL settings from nonvolatile EEPROM on demo board.
#define LTC6945_CPDN
for spi_map array, defines location for field specific information used to create the spi map ...
static void LTC6945_VCO_Freq_Verification()
verifies VCO frequency is within datasheet specifications
#define LTC6945_CPCHI
for spi_map array, defines location for field specific information used to create the spi map ...
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC6945_PART
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_CPWIDE
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_CPCLO
for spi_map array, defines location for field specific information used to create the spi map ...
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
void LTC6945_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6945 Write Single Address writes 8 bit Data field to LTC6945.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
LTC6945: Ultralow Noise and Spurious 0.35GHz to 6GHz Integer-N Synthesizer.
unsigned long get_LTC6945_global_VCO_MIN_MHz()
returns global LTC6945_VCO_Min_Freq_MHz
#define LTC6945_RD
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6945_REGSIZE()
returns # of addresses in parts register map (array size)
#define LTC6945_x
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 LTC6945_MIN_REF_FREQ
LTC6945 lower reference frequency limit.
#define LTC6945_PDREFO
for spi_map array, defines location for field specific information used to create the spi map ...
static void menu_1_load_default_settings()
Menu 1: Load Default SPI Register Settings This function loads the register settings referenced in th...
#define LTC6945_OMUTE
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...
#define LTC6945_MINFREQ
LTC6945 lower freq limit.
#define LTC6945_UNLOCK
for spi_map array, defines location for field specific information used to create the spi map ...
void set_LTC6945_global_vcolim(unsigned long fvco_max_MHz, unsigned long fvco_max_Hz, unsigned long fvco_min_MHz, unsigned long fvco_min_Hz)
sets globals LTC6945_VCO_Max_Freq_MHz, LTC6945_VCO_Max_Freq_Hz, LTC6945_VCO_Min_Freq_MHz and LTC6945_...
#define LTC6945_REV
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6945_CPUP
for spi_map array, defines location for field specific information used to create the spi map ...