136 Serial.begin(115200);
146 Serial.println(F(
" was found"));
159 if (Serial.available())
167 if (user_command !=
'm')
168 Serial.println(user_command);
170 switch (user_command)
197 Serial.println(F(
"Incorrect Option"));
200 Serial.println(F(
"\n*****************************************************************"));
221 set_LTC6946_ALLREGS(
LTC6946_CS, 0x04,0x0C,0x00,0x64,0x0A,0x8C,0x33,0x9B,0x8B,0x00);
223 set_LTC6946_ALLREGS(
LTC6946_CS, 0x04,0x0C,0x00,0x64,0x0E,0x10,0x33,0x9C,0x8B,0x00);
225 set_LTC6946_ALLREGS(
LTC6946_CS, 0x04,0x0C,0x00,0x64,0x11,0x94,0x33,0x9D,0x8B,0x00);
227 set_LTC6946_ALLREGS(
LTC6946_CS, 0x04,0x0C,0x00,0x64,0x11,0x94,0x33,0x9D,0x8B,0x00);
230 Serial.print(
"No default file for this board: ");
234 Serial.println(F(
"Registers Have Been Written"));
254 uint8_t
i, regval, user_regval, num_reg;
255 uint16_t user_address;
260 while (user_address != 0)
262 Serial.println(F(
"\n*****************************************************************"));
264 for (i=0; i<num_reg; i++)
269 Serial.print(F(
"- ADDR0"));
271 Serial.print(F(
"- ADDR"));
272 Serial.print(i, HEX);
273 Serial.print(F(
" = 0x"));
274 if (regval<16) Serial.print(F(
"0"));
275 Serial.print(regval, HEX);
276 if ((i==0)||(i==(num_reg-1))) Serial.print(
" (read only) ");
277 if (i==2) Serial.print(
" (warning: if D0=1 it resets all registers. Power On Reset Bit)");
280 Serial.print(
"0 - Return to Main Menu\n\n");
282 Serial.print(
"Enter a command (1-10 to modify register, or '0' to return to Main Menu): ");
284 Serial.println(user_address);
287 if (user_address >0 && user_address<(num_reg-1))
289 Serial.print(
"What value should ADDR");
290 Serial.print(user_address);
291 Serial.print(
" be set to (ex: HEX format 0xff): ");
293 Serial.println(user_regval);
313 uint8_t field_size,
i;
314 long max_num=1, pow2=1;
316 Serial.print(
"CURRENT STATE (HEX): ");
317 Serial.print(field_name);
318 Serial.print(
"= 0x");
319 Serial.println(field_val, HEX);
324 for (i=1; i<field_size; i++)
327 max_num=max_num + pow2;
330 Serial.print(
"What value should ");
331 Serial.print(field_name);
332 Serial.print(
" be set to or type '-1' to exit: (ex: HEX format 0x00 to 0x");
333 Serial.print(max_num, HEX);
337 if (usr_field_val>=0 && usr_field_val<=max_num)
339 Serial.println(usr_field_val);
340 return usr_field_val;
374 while (field_num != 0)
376 Serial.println(F(
"\n*****************************************************************"));
378 Serial.print(F(
"1-ALCCAL 15-CPMID 29-PDALL\n"));
379 Serial.print(F(
"2-ALCEN 16-CPRST 30-PDOUT\n"));
380 Serial.print(F(
"3-ALCHI * 17-CPUP 31-PDPLL\n"));
381 Serial.print(F(
"4-ALCLO * 18-CPWIDE 32-PDREFO\n"));
382 Serial.print(F(
"5-ALCMON 19-FILT 33-PDVCO\n"));
383 Serial.print(F(
"6-ALCULOK 20-LKCT 34-POR\n"));
384 Serial.print(F(
"7-BD 21-LKEN 35-RD\n"));
385 Serial.print(F(
"8-BST 22-LKWIN 36-REV *\n"));
386 Serial.print(F(
"9-CAL 23-LOCK * 37-RFO\n"));
387 Serial.print(F(
"10-CP 24-MTCAL 38-THI *\n"));
388 Serial.print(F(
"11-CPCHI 25-ND 39-TLO *\n"));
389 Serial.print(F(
"12-CPCLO 26-OD 40-UNLOK *\n"));
390 Serial.print(F(
"13-CPDN 27-OMUTE 41-x\n"));
391 Serial.print(F(
"14-CPINV 28-PART *\n"));
392 Serial.print(
"0 - Return to Main Menu\n");
393 Serial.print(
"* = READ ONLY FIELD\n\n");
395 Serial.print(
"Enter a command (1-41 to modify register, or '0' to return to Main Menu): ");
397 Serial.println(field_num);
781 unsigned long temp_val, temp_fref_MHz, temp_fref_Hz;
782 boolean valid_input=
false;
788 while (valid_input==
false)
792 Serial.print(F(
"\nThe Reference frequency will be entered with 2 integers\n"));
793 Serial.print(F(
"1st number is the MHZ portion, the 2nd number is Hz portion\n"));
794 Serial.print(F(
" - Example: A. 100\n"));
795 Serial.print(F(
" B. 25\n"));
796 Serial.print(F(
" equates to 100.000025MHZ\n\n"));
797 Serial.print(F(
"A. What is the MHz portion of the Reference Input Frequency(MHZ)? ["));
798 Serial.print(temp_fref_MHz);
799 Serial.print(F(
"]: "));
802 if (temp_val!=0) temp_fref_MHz = abs(temp_val);
803 Serial.println(temp_fref_MHz);
805 Serial.print(F(
"B. What is the sub-MHz portion of the Reference Input Frequency(HZ)? "));
807 temp_fref_Hz = abs(temp_val);
808 Serial.println(temp_fref_Hz);
814 temp_val= temp_fref_MHz*
OneMHz + temp_fref_Hz;
815 Serial.print(F(
"Reference Frequency set to "));
816 Serial.print(temp_val);
817 Serial.println(F(
"Hz"));
822 Serial.print(F(
"Reference Frequency must be between 10MHz and 250MHz\n"));
832 unsigned long odiv, temp_fout_MHz, temp_fout_Hz, temp_val;
833 unsigned long frf[2];
834 boolean valid_input=
false;
840 while (valid_input==
false)
842 Serial.print(F(
"\nThe Output Frequency (Frf) will be entered with 2 integers\n"));
843 Serial.print(F(
"1st number is the MHZ portion, the 2nd number is Hz portion\n"));
844 Serial.print(F(
"C. What is the MHz portion of the Output Frequency(MHZ)? ["));
845 Serial.print(temp_fout_MHz);
846 Serial.print(F(
"]: "));
849 if (temp_val!=0) temp_fout_MHz = abs(temp_val);
850 Serial.println(temp_fout_MHz);
852 Serial.print(F(
"D. What is the Hz portion of the Output Frequency(HZ)? "));
854 temp_fout_Hz = abs(temp_val);
855 Serial.println(temp_fout_Hz);
857 HZto64(frf,temp_fout_MHz,temp_fout_Hz);
862 if ((odiv>=1) && (odiv<=6)) valid_input=
true;
865 if (valid_input==
true)
868 if (temp_fout_MHz < 4294)
870 temp_val= temp_fout_MHz*
OneMHz + temp_fout_Hz;
871 Serial.print(F(
"Desired Output Frequency is "));
872 Serial.print(temp_val);
873 Serial.println(F(
"Hz"));
877 Serial.print(F(
"Desired Output Frequency is "));
878 Serial.print(temp_fout_MHz);
879 Serial.print(F(
"MHz + "));
880 Serial.print(temp_fout_Hz);
881 Serial.println(F(
"Hz"));
887 Serial.println(F(
"Invalid Fout frequency chosen"));
905 Serial.print(F(
"\nThis function calculates and programs OD and ND\n"));
906 Serial.print(F(
"based on the value input for Frf and Fref. It then calibrates the part.\n"));
907 Serial.print(F(
"It assumes all other register settings are correct\n"));
908 Serial.print(F(
"The PLLWizard tool can verify the correctness of the other register settings.\n"));
931 for (uint8_t
i = 0;
i <= num_reg ;
i++)
936 Serial.println(F(
"PLL Settings Stored to EEPROM"));
949 uint8_t user_address;
963 for (uint8_t
i = 0;
i <= num_reg ;
i++)
969 Serial.println(F(
"PLL Settings Restored"));
973 Serial.println(F(
"PLL Settings not found"));
983 Serial.println(F(
"*****************************************************************"));
984 Serial.println(F(
"* DC1705 Demonstration Program *"));
985 Serial.println(F(
"* *"));
986 Serial.println(F(
"* This program demonstrates how to send data to the LTC6946 *"));
987 Serial.println(F(
"* Ultra Low Noise & Spurious IntegerN Synthesizer with *"));
988 Serial.println(F(
"* Integrated VCO. *"));
989 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
990 Serial.println(F(
"* *"));
991 Serial.println(F(
"* For loop filter design please use the PLL Wizard software. *"));
992 Serial.println(F(
"* - It is recommended to use Pll Wizard to determine the *"));
993 Serial.println(F(
"* correct SPI register values for the initial setup. These *"));
994 Serial.println(F(
"* values can be entered into this program via menu option 2 *"));
995 Serial.println(F(
"* below. These values can then be stored and recalled from the *"));
996 Serial.println(F(
"* DC1705 EEPROM using options 5 and 6 below. *"));
997 Serial.println(F(
"*****************************************************************"));
1007 Serial.println(F(
"\nCommand Summary:"));
1008 Serial.println(F(
" 1-Load Default Settings (same as the PLL Wizard's DC1705-x(LTC6946-x)100MHz.pllset settings)"));
1009 Serial.println(F(
" 2-READ/WRITE to Registers Addresses"));
1010 Serial.println(F(
" 3-READ/WRITE to Registers Fields"));
1011 Serial.println(F(
" 4-Set Output Frequency (Frf)"));
1012 Serial.println(F(
" 5-Store LTC6946 SPI settings to the DC1705's EEPROM"));
1013 Serial.println(F(
" 6-Restore LTC6946 SPI settings from the DC1705's EEPROM"));
1015 Serial.print(F(
"Enter a command: "));
struct demo_board_type demo_board
Instantiate demo board structure.
#define LTC6946_THI
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_MIN_REF_FREQ
LTC6946 lower reference frequency limit.
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 ...
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.
#define LTC6946_MAX_REF_FREQ
LTC6946 upper reference frequency limit.
unsigned char user_command
unsigned long get_LTC6946_global_fref_MHz()
returns global LTC6946_Fref_MHz
static void loop()
Repeats Linduino loop.
#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.
char name[15]
Demo Circuit number (DC1678)
void LTC6946_init()
Initializes the SPI MAP arrays The values set in initialization are used all the LTC6946 SPI/WRITE an...
static uint8_t First_Run
if first time through loop = 0, otherwise=1
#define LTC6946_TLO
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_CPINV
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 LTC6946_CP
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_RD
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_REV
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_ALCULOK
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 based on desired Frf This function calculates and programs OD...
#define OneMHz
1MHz in long format, used in 64 bit math
#define LTC6946_CS
Define the SPI CS pin.
#define LTC6946_PDOUT
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.
static void menu_6_restore_settings()
Read stored PLL settings from nonvolatile EEPROM on demo board.
static int8_t demo_board_connected
Demo Board Name stored in QuikEval EEPROM.
static void setup()
Initialize Linduino.
static void print_prompt()
Prints main menu.
#define LTC6946_BD
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_OD
for spi_map array, defines location for field specific information used to create the spi map ...
static void LTC6946_Fout_Freq_Verification(char part_version[])
verifies frf frequency is within datasheet specifications
#define LTC6946_ALCMON
for spi_map array, defines location for field specific information used to create the spi map ...
union LT_union_int32_4bytes data
#define LTC6946_CPWIDE
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6946_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
void set_LTC6946_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 LTC6946 RW address.
#define LTC6946_MTCAL
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 LTC6946_ALCLO
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6946_global_fref_Hz()
returns global LTC6946_Fref_Hz
#define LTC6946_PDVCO
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_LKEN
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 identifies which of the 4 LTC6946 frequency ...
#define LTC6946_FILT
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_ALCHI
for spi_map array, defines location for field specific information used to create the spi map ...
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.
unsigned long LTC6946_calc_odiv(char part_version[], unsigned long frf[2])
calculates the output divider setting based on the frf and version of LTC6946
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.
static void menu_5_store_settings()
Store PLL settings to nonvolatile EEPROM on demo board.
void set_LTC6946_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6946 SPI field value calls function LTC6946_read_field, which reads specific address/fiel...
#define LTC6946_CPRST
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6946_REGSIZE()
returns # of addresses in parts register map (array size)
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
#define LTC6946_PDREFO
for spi_map array, defines location for field specific information used to create the spi map ...
#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.
#define LTC6946_BST
for spi_map array, defines location for field specific information used to create the spi map ...
void LTC6946_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6946 Write Single Address writes 8 bit Data field to LTC6946.
#define LTC6946_CAL
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_LOCK
for spi_map array, defines location for field specific information used to create the spi map ...
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
LTC6946: Ultralow Noise and Spurious 0.37GHz to 6.39GHz Integer-N Synthesizer with Integrated VCO...
#define LTC6946_PDALL
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 LTC6946_ALCCAL
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6946_global_frf_MHz()
returns global LTC6946_Frf_MHz
#define LTC6946_RFO
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.
static uint8_t ref_out
Used to keep track of reference out status.
void LTC6946_set_frf(char part_version[])
FUNCTION: LTC6946_set_frf Calculates the integer (N), fractional (NUM) and output divider (OD) SPI va...
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
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 ...
#define LTC6946_ALCEN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_UNLOK
for spi_map array, defines location for field specific information used to create the spi map ...
char product_name[15]
LTC Product (LTC2654-L16)
void set_LTC6946_global_frf(unsigned long frf_MHz, unsigned long frf_Hz)
sets globals LTC6946_Frf_MHz and LTC6946_Frf_Hz
#define LTC6946_LKWIN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_PDPLL
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6946_global_frf_Hz()
returns global LTC6946_Frf_Hz
#define LTC6946_LKCT
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 LTC6946_CPUP
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_OMUTE
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_CPCHI
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t LTC6946_read(uint8_t cs, int8_t address)
LTC6946 Read Single Address reads 8 bit Data field to LTC6946.
#define LTC6946_x
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6946_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
#define LTC6946_PART
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_POR
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6946_CPDN
for spi_map array, defines location for field specific information used to create the spi map ...
long get_LTC6946_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6946 SPI field value calls function LTC6946_read_field, which reads specific address loca...
#define LTC6946_CPCLO
for spi_map array, defines location for field specific information used to create the spi map ...
static void LTC6946_Ref_Freq_Verification()
verifies reference frequency is within datasheet specifications
static void print_title()
Prints the title block when program first starts.
#define LTC6946_ND
for spi_map array, defines location for field specific information used to create the spi map ...
void set_LTC6946_global_fref(unsigned long fref_MHz, unsigned long fref_Hz)
sets globals LTC6946_Fref_MHz and LTC6946_Fref_Hz
#define LTC6946_CPMID
for spi_map array, defines location for field specific information used to create the spi map ...