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_LTC6948_ALLREGS(
LTC6948_CS,0x04,0x04,0x3E,0x6E,0x11,0x10,0x48,0x23,0xD7,0x10,0x1C,0x0D,0x00);
223 set_LTC6948_ALLREGS(
LTC6948_CS, 0x04,0x04,0x3E,0x5E,0x11,0x10,0x5A,0x2C,0xCC,0xD0,0x1D,0x0D,0xC0);
225 set_LTC6948_ALLREGS(
LTC6948_CS,0x04,0x04,0x3E,0x4E,0x11,0x10,0x6C,0x35,0xC2,0x90,0x1E,0x0D,0xC0);
227 set_LTC6948_ALLREGS(
LTC6948_CS,0x04,0x04,0x3E,0x4E,0x11,0x10,0x6C,0x35,0xC2,0x90,0x1E,0x0D,0xC0);
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-13 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 18-CPMID 35-PART *\n"));
379 Serial.print(F(
"2-ALCEN 19-CPRST 36-PDALL\n"));
380 Serial.print(F(
"3-ALCHI * 20-CPUP 37-PDFN\n"));
381 Serial.print(F(
"4-ALCLO * 21-CPWIDE 38-PDOUT\n"));
382 Serial.print(F(
"5-ALCMON 22-DITHEN 39-PDPLL\n"));
383 Serial.print(F(
"6-ALCULOK 23-FILT 40-PDVCO\n"));
384 Serial.print(F(
"7-AUTOCAL 24-INTN 41-POR\n"));
385 Serial.print(F(
"8-AUTORST 25-LDOEN 42-RD\n"));
386 Serial.print(F(
"9-BD 26-LDOV 43-REV *\n"));
387 Serial.print(F(
"10-BST 27-LKCT 44-RFO\n"));
388 Serial.print(F(
"11-CAL 28-LKWIN 45-RSTFN\n"));
389 Serial.print(F(
"12-CP 29-LOCK * 46-SEED\n"));
390 Serial.print(F(
"13-CPCHI 30-MTCAL 47-THI *\n"));
391 Serial.print(F(
"14-CPCLO 31-ND 48-TLO *\n"));
392 Serial.print(F(
"15-CPDN 32-NUM 49-UNLOK *\n"));
393 Serial.print(F(
"16-CPINV 33-OD 50-x\n"));
394 Serial.print(F(
"17-CPLE 34-OMUTE\n"));
395 Serial.print(
"0 - Return to Main Menu\n");
396 Serial.print(
"* = READ ONLY FIELD\n\n");
398 Serial.print(
"Enter a command (1-50 to modify register, or '0' to return to Main Menu): ");
400 Serial.println(field_num);
865 unsigned long temp_val, temp_fref_MHz, temp_fref_Hz;
866 boolean valid_input=
false;
872 while (valid_input==
false)
876 Serial.print(F(
"\nThe Reference frequency will be entered with 2 integers\n"));
877 Serial.print(F(
"1st number is the MHZ portion, the 2nd number is Hz portion\n"));
878 Serial.print(F(
" - Example: A. 100\n"));
879 Serial.print(F(
" B. 25\n"));
880 Serial.print(F(
" equates to 100.000025MHZ\n\n"));
881 Serial.print(F(
"A. What is the MHz portion of the Reference Input Frequency(MHZ)? ["));
882 Serial.print(temp_fref_MHz);
883 Serial.print(F(
"]: "));
886 if (temp_val!=0) temp_fref_MHz = abs(temp_val);
887 Serial.println(temp_fref_MHz);
889 Serial.print(F(
"B. What is the sub-MHz portion of the Reference Input Frequency(HZ)? "));
891 temp_fref_Hz = abs(temp_val);
892 Serial.println(temp_fref_Hz);
898 temp_val= temp_fref_MHz*
OneMHz + temp_fref_Hz;
899 Serial.print(F(
"Reference Frequency set to "));
900 Serial.print(temp_val);
901 Serial.println(F(
"Hz"));
906 Serial.print(F(
"Reference Frequency must be between 10MHz and 425MHz\n"));
916 unsigned long odiv, temp_fout_MHz, temp_fout_Hz, temp_val;
917 unsigned long frf[2];
918 boolean valid_input=
false;
924 while (valid_input==
false)
926 Serial.print(F(
"\nThe Output Frequency (Frf) will be entered with 2 integers\n"));
927 Serial.print(F(
"1st number is the MHZ portion, the 2nd number is Hz portion\n"));
928 Serial.print(F(
"C. What is the MHz portion of the Output Frequency(MHZ)? ["));
929 Serial.print(temp_fout_MHz);
930 Serial.print(F(
"]: "));
933 if (temp_val!=0) temp_fout_MHz = abs(temp_val);
934 Serial.println(temp_fout_MHz);
936 Serial.print(F(
"D. What is the Hz portion of the Output Frequency(HZ)? "));
938 temp_fout_Hz = abs(temp_val);
939 Serial.println(temp_fout_Hz);
941 HZto64(frf,temp_fout_MHz,temp_fout_Hz);
946 if ((odiv>=1) && (odiv<=6)) valid_input=
true;
949 if (valid_input==
true)
952 if (temp_fout_MHz < 4294)
954 temp_val= temp_fout_MHz*
OneMHz + temp_fout_Hz;
955 Serial.print(F(
"Desired Output Frequency is "));
956 Serial.print(temp_val);
957 Serial.println(F(
"Hz"));
961 Serial.print(F(
"Desired Output Frequency is "));
962 Serial.print(temp_fout_MHz);
963 Serial.print(F(
"MHz + "));
964 Serial.print(temp_fout_Hz);
965 Serial.println(F(
"Hz"));
971 Serial.println(F(
"Invalid Fout frequency chosen"));
989 Serial.print(F(
"\nThis function calculates and programs OD, ND, NUM\n"));
990 Serial.print(F(
"based on the value input for Frf and Fref. It then calibrates the part.\n"));
991 Serial.print(F(
"It assumes all other register settings are correct\n"));
992 Serial.print(F(
"The FracNWizard tool can verify the correctness of the other register settings.\n"));
1007 uint8_t addr_offset;
1015 for (uint8_t
i = 0;
i <= num_reg ;
i++)
1020 Serial.println(F(
"PLL Settings Stored to EEPROM"));
1033 uint8_t user_address;
1035 uint8_t addr_offset;
1047 for (uint8_t
i = 0;
i <= num_reg ;
i++)
1053 Serial.println(F(
"PLL Settings Restored"));
1057 Serial.println(F(
"PLL Settings not found"));
1068 Serial.println(F(
"*****************************************************************"));
1069 Serial.println(F(
"* DC1959 Demonstration Program *"));
1070 Serial.println(F(
"* *"));
1071 Serial.println(F(
"* This program demonstrates how to send data to the LTC6948 *"));
1072 Serial.println(F(
"* Ultra Low Noise & Spurious FracN Synthesizer with *"));
1073 Serial.println(F(
"* Integrated VCO. *"));
1074 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
1075 Serial.println(F(
"* *"));
1076 Serial.println(F(
"* For loop filter design please use the FracN Wizard software. *"));
1077 Serial.println(F(
"* - It is recommended to use FracNWizard to determine the *"));
1078 Serial.println(F(
"* correct SPI register values for the initial setup. These *"));
1079 Serial.println(F(
"* values can be entered into this program via menu option 2 *"));
1080 Serial.println(F(
"* below. These values can then be stored and recalled from the *"));
1081 Serial.println(F(
"* DC1959 EEPROM using options 5 and 6 below. *"));
1082 Serial.println(F(
"*****************************************************************"));
1092 Serial.println(F(
"\nCommand Summary:"));
1093 Serial.println(F(
" 1-Load Default Settings (same as the FracN Wizard's LTC6948-x_100MHz.fracnset settings)"));
1094 Serial.println(F(
" 2-READ/WRITE to Registers Addresses"));
1095 Serial.println(F(
" 3-READ/WRITE to Registers Fields"));
1096 Serial.println(F(
" 4-Set Output Frequency (Frf)"));
1097 Serial.println(F(
" 5-Store LTC6948 SPI settings to the DC1959's EEPROM"));
1098 Serial.println(F(
" 6-Restore LTC6948 SPI settings from the DC1959's EEPROM"));
1100 Serial.print(F(
"Enter a command: "));
struct demo_board_type demo_board
Instantiate demo board structure.
uint8_t LTC6948_read(uint8_t cs, int8_t address)
LTC6948 Read Single Address reads 8 bit Data field to LTC6948.
#define LTC6948_UNLOK
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.
#define LTC6948_PDOUT
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned char user_command
#define EEPROM_I2C_ADDRESS
#define LTC6948_OMUTE
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.
#define LTC6948_ALCEN
for spi_map array, defines location for field specific information used to create the spi map ...
char name[15]
Demo Circuit number (DC1678)
#define LTC6948_CPCLO
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_PART
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_SEED
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_CPRST
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_LKWIN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_LKCT
for spi_map array, defines location for field specific information used to create the spi map ...
long get_LTC6948_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6948 SPI field value calls function LTC6948_read_field, which reads specific address loca...
#define LTC6948_ALCULOK
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 LTC6948_CPINV
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_CPCHI
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_CPUP
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6948_REGSIZE()
returns # of addresses in parts register map (array size)
#define LTC6948_RSTFN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_OD
for spi_map array, defines location for field specific information used to create the spi map ...
void LTC6948_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6948 Write Single Address writes 8 bit Data field to LTC6948.
#define LTC6948_NUM
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_FILT
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_ALCHI
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_MTCAL
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6948_global_frf_Hz()
returns global LTC6948_Frf_Hz
#define LTC6948_AUTORST
for spi_map array, defines location for field specific information used to create the spi map ...
#define OneMHz
1MHz in long format, used in 64 bit math
#define LTC6948_MIN_REF_FREQ
LTC6948 lower reference frequency limit.
static void setup()
Initialize Linduino.
static void menu_1_load_default_settings()
Menu 1: Load Default SPI Register Settings This function identifies which of the 4 LTC6948 frequency ...
void set_LTC6948_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6948 SPI field value calls function LTC6948_read_field, which reads specific address/fiel...
#define LTC6948_AUTOCAL
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6948_global_fref_Hz()
returns global LTC6948_Fref_Hz
#define LTC6948_CPMID
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...
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_2_RW_to_reg_addresss()
Menu 2: Reads and/or Writes the SPI register address This function reads and displays all SPI registe...
#define LTC6948_LDOV
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_ALCLO
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_CS
Define the SPI CS pin.
static void LTC6948_Fout_Freq_Verification(char part_version[])
verifies frf frequency is within datasheet specifications
union LT_union_int32_4bytes data
void LTC6948_init()
Initializes the SPI MAP arrays The values set in initialization are used all the LTC6948 SPI/WRITE an...
uint8_t get_LTC6948_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
void set_LTC6948_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)
Writes values to ALL LTC6948 RW address.
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 LTC6948_PDFN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_ND
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_DITHEN
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.
static uint8_t First_Run
if first time through loop = 0, otherwise=1
#define LTC6948_PDALL
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_CPWIDE
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_INTN
for spi_map array, defines location for field specific information used to create the spi map ...
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
static void loop()
Repeats Linduino loop.
#define LTC6948_MAX_REF_FREQ
LTC6948 upper reference frequency limit.
#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 menu_5_store_settings()
Store PLL settings to nonvolatile EEPROM on demo board.
static void menu_6_restore_settings()
Read stored PLL settings from nonvolatile EEPROM on demo board.
void set_LTC6948_global_fref(unsigned long fref_MHz, unsigned long fref_Hz)
sets globals LTC6948_Fref_MHz and LTC6948_Fref_Hz
static uint8_t ref_out
Used to keep track of reference out status.
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 ...
void LTC6948_set_frf(char part_version[])
FUNCTION: LTC6948_set_frf Calculates the integer (N), fractional (NUM) and output divider (OD) SPI va...
#define LTC6948_POR
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.
#define LTC6948_x
for spi_map array, defines location for field specific information used to create the spi map ...
void set_LTC6948_global_frf(unsigned long frf_MHz, unsigned long frf_Hz)
sets globals LTC6948_Frf_MHz and LTC6948_Frf_Hz
static void print_title()
Prints the title block when program first starts.
#define LTC6948_CP
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_THI
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.
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...
static void print_prompt()
Prints main menu.
#define LTC6948_CAL
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_ALCCAL
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.
#define LTC6948_LDOEN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_REV
for spi_map array, defines location for field specific information used to create the spi map ...
char product_name[15]
LTC Product (LTC2654-L16)
LTC6948: Ultralow Noise and Spurious 0.37GHz to 6.39GHz FracN Synthesizer with Integrated VCO...
#define LTC6948_ALCMON
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 ...
#define LTC6948_BD
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6948_global_fref_MHz()
returns global LTC6948_Fref_MHz
static void LTC6948_Ref_Freq_Verification()
verifies reference frequency is within datasheet specifications
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
#define LTC6948_RFO
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_RD
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_CPLE
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_PDVCO
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6948_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
unsigned long LTC6948_calc_odiv(char part_version[], unsigned long frf[2])
calculates the output divider setting based on the frf and version of LTC6948
#define LTC6948_CPDN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_PDPLL
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_LOCK
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6948_BST
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6948_global_frf_MHz()
returns global LTC6948_Frf_MHz
#define LTC6948_TLO
for spi_map array, defines location for field specific information used to create the spi map ...