121 #define EEPROM_CAL_KEY_INT 0x5678 124 #define EEPROM_CAL_KEY_EXT 0x9ABC 129 #define REF_INTERNAL LTC2655_CMD_INTERNAL_REFERENCE 130 #define REF_EXTERNAL LTC2655_CMD_EXTERNAL_REFERENCE
133 #define STORED_REF_STATE_BASE EEPROM_CAL_STATUS_ADDRESS 134 #define INT_CAL_VALID_BASE STORED_REF_STATE_BASE + 2
135 #define INT_CAL_PARAMS_BASE INT_CAL_VALID_BASE + 2
136 #define EXT_CAL_VALID_BASE INT_CAL_PARAMS_BASE + 32
137 #define EXT_CAL_PARAMS_BASE EXT_CAL_VALID_BASE + 2
138 #define EXT_REF_V_BASE EXT_CAL_PARAMS_BASE + 32
189 Serial.begin(115200);
204 static int16_t selected_dac = 0;
208 if (Serial.available())
211 Serial.println(user_command);
214 switch (user_command)
244 Serial.println(
"Incorrect Option");
247 if (ack) Serial.println(
"I2C NACK received, check address\n");
248 Serial.println(
"\n*****************************************************************");
261 Serial.print(
"Select DAC to operate on (0=A, 1=B, 2=C, 3=D, 4=All)");
263 if (*selected_dac == 4)
264 Serial.println(
"All");
266 Serial.println(*selected_dac);
327 Serial.println(
"Select reference mode - 0 for Internal, 1 for External");
332 Serial.println(
"External reference mode; enter external reference voltage");
341 Serial.println(
"Internal reference mode selected");
343 Serial.println(
"Writing reference mode to EEPROM\n\n");
354 for (i = 0; i < 4; i++)
368 Serial.println(F(
"\n\nSelect option - 0: Enable Internal, 1: Disable Internal, 2: Enable External, 3: Disable External"));
373 Serial.println(F(
"Enabling Internal Cal Params"));
377 Serial.println(F(
"Disabling Internal Cal Params"));
381 Serial.println(F(
"Enabling External Cal Params"));
385 Serial.println(F(
"Disabling External Cal Params"));
399 int16_t intvalid, extvalid;
403 Serial.println(F(
"\n\nReading Calibration parameters from EEPROM..."));
415 Serial.println(F(
"Restored external ref. Voltage:"));
421 Serial.println(
"Internal reference mode set");
459 for (i = 0; i <= 4; i++)
471 Serial.println(F(
"Found internal calibration, restoring...)"));
476 Serial.println(F(
"Found external calibration, restoring...)"));
478 else Serial.println(F(
"Calibration not found for this\nreference mode, using ideal calibration"));
492 Serial.println(
"Calibration Restored");
496 Serial.print(
"DAC ");
497 Serial.print((
char) (
'A' + i));
498 Serial.print(
" offset: ");
500 Serial.print(
" , lsb: ");
502 Serial.println(
" mv");
504 Serial.println(
"(DAC E applies to ALL DACs selections)");
505 if (eeaddr != 0)
return (1);
533 Serial.println(F(
"Calibration Stored to EEPROM"));
541 Serial.print(F(
"Type 1 to enter voltage, 2 to enter code:"));
544 Serial.println(user_input);
558 Serial.print(F(
"Enter Desired DAC output voltage: "));
560 Serial.print(dac_voltage);
561 Serial.println(
" V");
571 Serial.println(
"Enter Desired DAC Code");
572 Serial.print(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): ");
575 Serial.println(returncode, HEX);
584 Serial.println(F(
"*****************************************************************"));
585 Serial.println(F(
"* DC1703 Demonstration Program *"));
586 Serial.println(F(
"* *"));
587 Serial.println(F(
"* This program demonstrates how to send data to the LTC2655 *"));
588 Serial.println(F(
"* quad 16/12-bit DAC found on the DC1703 demo board. *"));
589 Serial.println(F(
"* *"));
590 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
591 Serial.println(F(
"* *"));
592 Serial.println(F(
"*****************************************************************"));
598 Serial.println(F(
"\nCommand Summary:"));
599 Serial.println(F(
" 1-Select DAC"));
600 Serial.println(F(
" 2-Write to input register (no update)"));
601 Serial.println(F(
" 3-Write and update DAC"));
602 Serial.println(F(
" 4-Update / power up DAC"));
603 Serial.println(F(
" 5-Power down DAC"));
604 Serial.println(F(
" 6-Set reference mode"));
605 Serial.println(F(
" 7-Calibrate DAC"));
606 Serial.println(F(
" 8-Enable / Disable calibration"));
608 Serial.println(
"\nPresent Values:");
609 Serial.print(
" Selected DAC: ");
610 if (selected_dac != 4)
611 Serial.println((
char) (selected_dac + 0x41));
613 Serial.println(
"All");
619 Serial.print(
" DAC Reference: ");
621 Serial.println(
"Internal");
624 Serial.print(F(
"External "));
626 Serial.println(F(
"V reference, please verify"));
627 Serial.print(F(
"Enter a command:"));
639 uint16_t code1 = 0x0200;
640 uint16_t code2 = 0xFFFF;
644 Serial.print(
"Calibrating DAC ");
645 Serial.println((
char) (0x41 + index));
648 Serial.print(
"DAC code set to 0x");
649 Serial.println(code1, HEX);
650 Serial.print(
"Enter measured DAC voltage:");
652 Serial.print(voltage1, 6);
653 Serial.println(
" V");
656 Serial.print(
"DAC code set to 0x");
657 Serial.println(code2, HEX);
658 Serial.print(
"Enter measured DAC voltage:");
660 Serial.print(voltage2, 6);
661 Serial.println(
" V");
struct demo_board_type demo_board
Instantiate demo board structure.
char option
Demo Circuit option (A)
LTC2655: Quad I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference.
static int8_t menu_7_calibrate_dacs()
Calibrate all DACs by measuring two known outputs.
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 char user_command
static uint8_t demo_board_connected
Set to 1 if the board is connected.
static uint8_t shift_count
The data align shift count.
#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.
static float LTC2655_lsb[5]
The LTC2655 lsb - index 4 for "all DACs." If part is calibrated, then index 0 is stored to "all DACs...
void LTC2655_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2655_lsb, int16_t *LTC2655_offset)
Calculate the LTC2655 offset and LSB voltages given two measured voltages and their corresponding cod...
static int8_t restore_calibration()
Read stored calibration parameters from nonvolatile EEPROM on demo board.
#define INT_CAL_VALID_BASE
Base address of the "internal ref calibration valid" flag.
Header File for Linduino Libraries and Demo Code.
static int8_t menu_4_update_power_up_dac(int16_t selected_dac)
Update DAC with data that is stored in input register, power up if sleeping.
#define STORED_REF_STATE_BASE
Base address of the stored reference state.
uint8_t eeprom_read_float(uint8_t i2c_address, float *read_data, uint16_t address)
Read the four byte float data from the EEPROM starting at address.
static int16_t LTC2655_offset[5]
DAC offset - index 4 for "all DACs." If part is calibrated, then index 0 is stored to "all DACs...
static void setup()
Initialize Linduino.
static float reference_voltage
Reference voltage, either internal or external.
#define EXT_CAL_PARAMS_BASE
Base address of the external ref calibration parameters.
static uint8_t reference_mode
Tells whether to set internal or external reference.
uint16_t LTC2655_voltage_to_code(float dac_voltage, float LTC2655_lsb, int16_t LTC2655_offset)
Calculate a LTC2655 DAC code given the desired output voltage.
#define INT_CAL_PARAMS_BASE
Base address of the internal ref calibration parameters.
#define REF_EXTERNAL
Stored reference state is External.
static int8_t menu_6_set_reference_mode()
Set reference mode and store to EEPROM.
#define LTC2655_CMD_POWER_DOWN
uint8_t eeprom_write_float(uint8_t i2c_address, float write_data, uint16_t address)
Write the 4 byte float data to the EEPROM starting at address.
static int8_t menu_8_enable_calibration()
Enable / Disable calibration.
static int8_t calibrate_dac(uint8_t index)
Calibrate the selected DAC using a voltmeter.
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.
static void print_title()
Prints the title block when program first starts.
const uint8_t address_map[5]
Lookup table for DAC address.
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 uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
int8_t LTC2655_write(uint8_t i2c_address, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write a 16-bit dac_code to the LTC2655.
static void print_prompt(int16_t selected_dac)
Prints main menu.
static int16_t prompt_voltage_or_code()
Prompt user to enter a voltage or digital code to send to DAC.
#define LTC2655_CMD_UPDATE
static int8_t menu_1_select_dac(int16_t *selected_dac)
Select which DAC to operate on.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define EXT_CAL_VALID_BASE
Base address of the "external ref calibration valid" flag.
#define LTC2655_CMD_WRITE
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static uint16_t get_voltage(float LTC2655_lsb, int16_t LTC2655_offset)
Get voltage from user input, calculate DAC code based on lsb, offset.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC2655_CMD_WRITE_UPDATE
static void store_calibration()
Store measured calibration parameters to nonvolatile EEPROM on demo board.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
static void loop()
Repeats Linduino loop.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
#define LTC2655_I2C_ADDRESS
static int8_t menu_3_write_and_update_dac(int16_t selected_dac)
Write data to DAC register (which updates output immediately)
#define REF_INTERNAL
Stored reference state is Internal.
static int8_t menu_2_write_to_input_register(int16_t selected_dac)
Write data to input register, but do not update DAC output.
#define EXT_REF_V_BASE
Base address of the stored external reference voltage.
static int8_t menu_5_power_down_dac(int16_t selected_dac)
Power down DAC.