137 Serial.begin(115200);
147 Serial.println(F(
" was found"));
160 if (Serial.available())
168 if (user_command !=
'm')
169 Serial.println(user_command);
171 switch (user_command)
198 Serial.println(F(
"Incorrect Option"));
201 Serial.println(F(
"\n*****************************************************************"));
220 set_LTC6947_ALLREGS(
LTC6947_CS, 0x04,0x00,0x06,0x9E,0x11,0x10,0x30,0x13,0x33,0x30,0x19,0x2D,0x00);
221 Serial.println(F(
"Registers Have Been Written"));
241 uint8_t
i, regval, user_regval, num_reg;
242 uint16_t user_address;
247 while (user_address != 0)
249 Serial.println(F(
"\n*****************************************************************"));
251 for (i=0; i<num_reg; i++)
256 Serial.print(F(
"- ADDR0"));
258 Serial.print(F(
"- ADDR"));
259 Serial.print(i, HEX);
260 Serial.print(F(
" = 0x"));
261 if (regval<16) Serial.print(F(
"0"));
262 Serial.print(regval, HEX);
263 if ((i==0)||(i==(num_reg-1))) Serial.print(
" (read only) ");
264 if (i==2) Serial.print(
" (warning: if D0=1 it resets all registers. Power On Reset Bit)");
267 Serial.print(
"0 - Return to Main Menu\n\n");
269 Serial.print(
"Enter a command (1-13 to modify register, or '0' to return to Main Menu): ");
271 Serial.println(user_address);
274 if (user_address >0 && user_address<(num_reg-1))
276 Serial.print(
"What value should ADDR");
277 Serial.print(user_address);
278 Serial.print(
" be set to (ex: HEX format 0xff): ");
280 Serial.println(user_regval);
300 uint8_t field_size,
i;
301 long max_num=1, pow2=1;
303 Serial.print(
"CURRENT STATE (HEX): ");
304 Serial.print(field_name);
305 Serial.print(
"= 0x");
306 Serial.println(field_val, HEX);
311 for (i=1; i<field_size; i++)
314 max_num=max_num + pow2;
317 Serial.print(
"What value should ");
318 Serial.print(field_name);
319 Serial.print(
" be set to or type '-1' to exit: (ex: HEX format 0x00 to 0x");
320 Serial.print(max_num, HEX);
324 if (usr_field_val>=0 && usr_field_val<=max_num)
326 Serial.println(usr_field_val);
327 return usr_field_val;
361 while (field_num != 0)
363 Serial.println(F(
"\n*****************************************************************"));
365 Serial.print(F(
"1-AUTORST 14-FILT 27-PDFN\n"));
366 Serial.print(F(
"2-BST 15-INTN 28-PDOUT\n"));
367 Serial.print(F(
"3-CP 16-LDOEN 29-PDPLL\n"));
368 Serial.print(F(
"4-CPCHI 17-LDOV 30-POR\n"));
369 Serial.print(F(
"5-CPCLO 18-LKCT 31-RD\n"));
370 Serial.print(F(
"6-CPDN 19-LKWIN 32-REV *\n"));
371 Serial.print(F(
"7-CPINV 20-LOCK * 33-RFO\n"));
372 Serial.print(F(
"8-CPLE 21-ND 34-RSTFN\n"));
373 Serial.print(F(
"9-CPMID 22-NUM 35-SEED\n"));
374 Serial.print(F(
"10-CPRST 23-OD 36-THI *\n"));
375 Serial.print(F(
"11-CPUP 24-OMUTE 37-TLO *\n"));
376 Serial.print(F(
"12-CPWIDE 25-PART * 38-UNLOK *\n"));
377 Serial.print(F(
"13-DITHEN 26-PDALL 39-x\n"));
378 Serial.print(
"0 - Return to Main Menu\n");
379 Serial.print(
"* = READ ONLY FIELD\n\n");
381 Serial.print(
"Enter a command (1-39 to modify register, or '0' to return to Main Menu): ");
383 Serial.println(field_num);
750 unsigned long temp_val, temp_max_VCO_MHz, temp_min_VCO_MHz, temp_max_VCO_Hz, temp_min_VCO_Hz;
751 unsigned long fvco_max[2], fvco_min[2], fvco_max_lim[2], fvco_min_lim[2];
752 boolean valid_input=
false;
758 while (valid_input==
false)
765 Serial.print(F(
"What is the upper frequency limit of the VCO (MHZ portion)? ["));
766 Serial.print(temp_max_VCO_MHz);
767 Serial.print(F(
"]: "));
770 if (temp_val!=0) temp_max_VCO_MHz = abs(temp_val);
771 Serial.println(temp_max_VCO_MHz);
773 Serial.print(F(
"What is the upper VCO frequency limit (HZ portion)? "));
776 Serial.println(temp_max_VCO_Hz);
778 Serial.print(F(
"\nWhat is the lower frequency limit of the VCO (MHZ portion)? ["));
779 Serial.print(temp_min_VCO_MHz);
780 Serial.print(F(
"]: "));
783 if (temp_val!=0) temp_min_VCO_MHz = abs(temp_val);
784 Serial.println(temp_min_VCO_MHz);
786 Serial.print(F(
"What is the lower frequency limit of the VCO (HZ portion)? "));
788 Serial.println(temp_min_VCO_Hz);
790 HZto64(fvco_max,temp_max_VCO_MHz,temp_max_VCO_Hz);
791 HZto64(fvco_min,temp_min_VCO_MHz,temp_min_VCO_Hz);
797 if (
lt64(fvco_min_lim,fvco_min) &&
lt64(fvco_max,fvco_max_lim) &&
798 lt64(fvco_min_lim,fvco_max) &&
lt64(fvco_min,fvco_max_lim) &&
799 (
eq64(fvco_min, fvco_max) ||
lt64(fvco_min, fvco_max)) )
802 Serial.print(F(
"VCO Frequencies entered are valid\n"));
807 Serial.print(F(
"VCO Frequencies must be between 350MHz and 6000MHz\n"));
818 unsigned long temp_val, temp_fref_MHz, temp_fref_Hz;
819 boolean valid_input=
false;
825 while (valid_input==
false)
829 Serial.print(F(
"\nWhat is the MHz portion of the Reference Input Frequency(MHZ)? ["));
830 Serial.print(temp_fref_MHz);
831 Serial.print(F(
"]: "));
834 if (temp_val!=0) temp_fref_MHz = abs(temp_val);
835 Serial.println(temp_fref_MHz);
837 Serial.print(F(
"What is the sub-MHz portion of the Reference Input Frequency(HZ)? "));
839 temp_fref_Hz = abs(temp_val);
840 Serial.println(temp_fref_Hz);
846 temp_val= temp_fref_MHz*
OneMHz + temp_fref_Hz;
847 Serial.print(F(
"Reference Frequency set to "));
848 Serial.print(temp_val);
849 Serial.println(F(
"Hz"));
854 Serial.print(F(
"Reference Frequency must be between 10MHz and 425MHz\n"));
864 unsigned long odiv, temp_fout_MHz, temp_fout_Hz, temp_val;
865 unsigned long frf[2];
866 boolean valid_input=
false;
872 while (valid_input==
false)
874 Serial.print(F(
"\nWhat is the MHz portion of the Output Frequency(MHZ)? ["));
875 Serial.print(temp_fout_MHz);
876 Serial.print(F(
"]: "));
879 if (temp_val!=0) temp_fout_MHz = abs(temp_val);
880 Serial.println(temp_fout_MHz);
882 Serial.print(F(
"What is the Hz portion of the Output Frequency(HZ)? "));
884 temp_fout_Hz = abs(temp_val);
885 Serial.println(temp_fout_Hz);
887 HZto64(frf,temp_fout_MHz,temp_fout_Hz);
892 if ((odiv>=1) && (odiv<=6)) valid_input=
true;
895 if (valid_input==
true)
898 if (temp_fout_MHz < 4294)
900 temp_val= temp_fout_MHz*
OneMHz + temp_fout_Hz;
901 Serial.print(F(
"Desired Output Frequency is "));
902 Serial.print(temp_val);
903 Serial.println(F(
"Hz"));
907 Serial.print(F(
"Desired Output Frequency is "));
908 Serial.print(temp_fout_MHz);
909 Serial.print(F(
"MHz + "));
910 Serial.print(temp_fout_Hz);
911 Serial.println(F(
"Hz"));
917 Serial.println(F(
"Invalid Fout frequency chosen"));
934 Serial.print(F(
"\nThis function calculates and programs OD, ND, NUM\n"));
935 Serial.print(F(
"based on the value input for Fvco, Frf and Fref.\n"));
936 Serial.print(F(
"It assumes all other register settings are correct\n"));
937 Serial.print(F(
"The FracNWizard tool can verify the correctness of the other register settings.\n"));
940 Serial.print(F(
"\nThe following frequencies will be entered with 2 integers\n"));
941 Serial.print(F(
"1st number is the MHZ portion, the 2nd number is Hz portion\n"));
942 Serial.print(F(
" - Example: A. 100\n"));
943 Serial.print(F(
" B. 25\n"));
944 Serial.print(F(
" equates to 100.000025MHZ\n\n"));
967 for (uint8_t
i = 0;
i <= num_reg ;
i++)
972 Serial.println(F(
"PLL Settings Stored to EEPROM"));
985 uint8_t user_address;
999 for (uint8_t
i = 0;
i <= num_reg ;
i++)
1005 Serial.println(F(
"PLL Settings Restored"));
1009 Serial.println(F(
"PLL Settings not found"));
1019 Serial.println(F(
"*****************************************************************"));
1020 Serial.println(F(
"* DC1846 Demonstration Program *"));
1021 Serial.println(F(
"* *"));
1022 Serial.println(F(
"* This program demonstrates how to send data to the LTC6947 *"));
1023 Serial.println(F(
"* Ultra Low Noise & Spurious FracN Synthesizer. *"));
1024 Serial.println(F(
"* *"));
1025 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
1026 Serial.println(F(
"* *"));
1027 Serial.println(F(
"* For loop filter design please use the FracN Wizard software. *"));
1028 Serial.println(F(
"* - It is recommended to use FracNWizard to determine the *"));
1029 Serial.println(F(
"* correct SPI register values for the initial setup. These *"));
1030 Serial.println(F(
"* values can be entered into this program via menu option 2 *"));
1031 Serial.println(F(
"* below. These values can then be stored and recalled from the *"));
1032 Serial.println(F(
"* DC1846 EEPROM using options 5 and 6 below. *"));
1033 Serial.println(F(
"*****************************************************************"));
1043 Serial.println(F(
"\nCommand Summary:"));
1044 Serial.println(F(
" 1-Load Default Settings (same as the FracN Wizard's LTC6947_100MHz.fracnset settings)"));
1045 Serial.println(F(
" 2-READ/WRITE to Registers Addresses"));
1046 Serial.println(F(
" 3-READ/WRITE to Registers Fields"));
1047 Serial.println(F(
" 4-Set Output Frequency (Frf)"));
1048 Serial.println(F(
" 5-Store LTC6947 SPI settings to the DC1846's EEPROM"));
1049 Serial.println(F(
" 6-Restore LTC6947 SPI settings from the DC1846's EEPROM"));
1051 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 LTC6947_CPCHI
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_ND
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.
unsigned long get_LTC6947_global_VCO_MIN_Hz()
returns global LTC6947_VCO_Min_Freq_Hz
unsigned char user_command
#define LTC6947_INTN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_PDALL
for spi_map array, defines location for field specific information used to create the spi map ...
#define EEPROM_I2C_ADDRESS
#define LTC6947_PDPLL
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6947_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in 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 LTC6947_CPUP
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_MINFREQ
LTC6947 lower freq limit.
char name[15]
Demo Circuit number (DC1678)
#define LTC6947_POR
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_x
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_RSTFN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_BST
for spi_map array, defines location for field specific information used to create the spi map ...
void set_LTC6947_global_fref(unsigned long fref_MHz, unsigned long fref_Hz)
sets globals LTC6947_Fref_MHz and LTC6947_Fref_Hz
void set_LTC6947_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6947 SPI field value calls function LTC6947_read_field, which reads specific address/fiel...
Header File for Linduino Libraries and Demo Code.
uint8_t get_LTC6947_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
#define LTC6947_CPRST
for spi_map array, defines location for field specific information used to create the spi map ...
void LTC6947_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6947 Write Single Address writes 8 bit Data field to LTC6947.
uint8_t LTC6947_read(uint8_t cs, int8_t address)
LTC6947 Read Single Address reads 8 bit Data field to LTC6947.
static void print_title()
Prints the title block when program first starts.
#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
unsigned long get_LTC6947_global_VCO_MIN_MHz()
returns global LTC6947_VCO_Min_Freq_MHz
#define LTC6947_THI
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_RD
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_CPLE
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 LTC6947_REV
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 LTC6947_VCO_Freq_Verification()
verifies VCO frequency is within datasheet specifications
#define LTC6947_OD
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_FILT
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_CP
for spi_map array, defines location for field specific information used to create the spi map ...
union LT_union_int32_4bytes data
unsigned long get_LTC6947_global_VCO_MAX_MHz()
returns global LTC6947_VCO_Max_Freq_MHz
#define LTC6947_CPMID
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_OMUTE
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_PART
for spi_map array, defines location for field specific information used to create the spi map ...
void set_LTC6947_global_frf(unsigned long frf_MHz, unsigned long frf_Hz)
sets globals LTC6947_Frf_MHz and LTC6947_Frf_Hz
#define LTC6947_LDOEN
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.
#define LTC6947_CPDN
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...
void LTC6947_set_frf()
FUNCTION: LTC6947_set_frf Calculates the integer (N), fractional (NUM) and output divider (OD) SPI va...
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.
unsigned long get_LTC6947_global_frf_MHz()
returns global LTC6947_Frf_MHz
#define LTC6947_RFO
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6947_global_fref_Hz()
returns global LTC6947_Fref_Hz
static void print_prompt()
Prints main menu.
#define LTC6947_CPINV
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 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 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 LTC6947_PDFN
for spi_map array, defines location for field specific information used to create the spi map ...
unsigned long get_LTC6947_global_fref_MHz()
returns global LTC6947_Fref_MHz
#define LTC6947_LKWIN
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_MAXFREQ
LTC6947 upper freq limit.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
unsigned long get_LTC6947_global_VCO_MAX_Hz()
returns global LTC6947_VCO_Max_Freq_Hz
#define LTC6947_PDOUT
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_TLO
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_CPWIDE
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_CPCLO
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 LTC6947_LDOV
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 LTC6947_UNLOK
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...
LTC6947: Ultralow Noise and Spurious 0.35GHz to 6GHz FracN Synthesizer.
long get_LTC6947_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6947 SPI field value calls function LTC6947_read_field, which reads specific address loca...
static uint8_t First_Run
if first time through loop = 0, otherwise=1
#define LTC6947_LKCT
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.
#define LTC6947_NUM
for spi_map array, defines location for field specific information used to create the spi map ...
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 ...
static void menu_5_store_settings()
Store PLL settings to nonvolatile EEPROM on demo board.
#define LTC6947_MIN_REF_FREQ
LTC6947 lower reference frequency limit.
#define LTC6947_LOCK
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_SEED
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_DITHEN
for spi_map array, defines location for field specific information used to create the spi map ...
void LTC6947_init()
Initializes the SPI MAP arrays The values set in initialization are used for all the LTC6947 SPI/WRIT...
static void LTC6947_Ref_Freq_Verification()
verifies reference frequency is within datasheet specifications
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
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 ...
unsigned long LTC6947_calc_odiv(unsigned long frf[2])
calculates the output divider setting based on the frf and on board VCO frequencies of LTC6947 ...
static void setup()
Initialize Linduino.
#define LTC6947_AUTORST
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6947_CS
Define the SPI CS pin.
uint8_t get_LTC6947_REGSIZE()
returns # of addresses in parts register map (array size)
unsigned long get_LTC6947_global_frf_Hz()
returns global LTC6947_Frf_Hz
#define LTC6947_MAX_REF_FREQ
LTC6947 upper reference frequency limit.
static void LTC6947_Fout_Freq_Verification()
verifies frf frequency is within datasheet specifications
void set_LTC6947_global_vcolim(unsigned long fvco_max_MHz, unsigned long fvco_max_Hz, unsigned long fvco_min_MHz, unsigned long fvco_min_Hz)
sets globals LTC6947_VCO_Max_Freq_MHz, LTC6947_VCO_Max_Freq_Hz, LTC6947_VCO_Min_Freq_MHz and LTC6947_...
void set_LTC6947_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 LTC6947 RW addresses.
static uint8_t ref_out
Used to keep track of reference out status.
static void loop()
Repeats Linduino loop.