120 #define EEPROM_CAL_KEY_INT 0x5678 121 #define EEPROM_CAL_KEY_EXT 0x9ABC
126 #define REF_INTERNAL LTC2657_CMD_INTERNAL_REFERENCE 127 #define REF_EXTERNAL LTC2657_CMD_EXTERNAL_REFERENCE
130 #define STORED_REF_STATE_BASE EEPROM_CAL_STATUS_ADDRESS 131 #define INT_CAL_VALID_BASE STORED_REF_STATE_BASE + 2
132 #define INT_CAL_PARAMS_BASE INT_CAL_VALID_BASE + 2
133 #define EXT_CAL_VALID_BASE INT_CAL_PARAMS_BASE + 32
134 #define EXT_CAL_PARAMS_BASE EXT_CAL_VALID_BASE + 2
135 #define EXT_REF_V_BASE EXT_CAL_PARAMS_BASE + 32
187 Serial.begin(115200);
202 static int16_t selected_dac = 0;
206 if (Serial.available())
209 Serial.println(user_command);
212 switch (user_command)
242 Serial.println(
"Incorrect Option");
245 if (ack) Serial.println(
"I2C NACK received, check address\n");
246 Serial.println(
"\n*****************************************************************");
259 Serial.print(
"Select DAC to operate on (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H, 8=All)");
261 if (*selected_dac == 8)
262 Serial.println(
"All");
264 Serial.println(*selected_dac);
325 Serial.println(
"Select reference mode - 0 for Internal, 1 for External");
330 Serial.println(
"External reference mode; enter external reference voltage");
339 Serial.println(
"Internal reference mode selected");
341 Serial.println(
"Writing reference mode to EEPROM\n\n");
352 for (i = 0; i < 8; i++)
366 Serial.println(F(
"\n\nSelect option - 0: Enable Internal, 1: Disable Internal, 2: Enable External, 3: Disable External"));
371 Serial.println(F(
"Enabling Internal Cal Params"));
375 Serial.println(F(
"Disabling Internal Cal Params"));
379 Serial.println(F(
"Enabling External Cal Params"));
383 Serial.println(F(
"Disabling External Cal Params"));
397 int16_t intvalid, extvalid;
401 Serial.println(F(
"\n\nReading Calibration parameters from EEPROM..."));
413 Serial.println(F(
"Restored external ref. Voltage:"));
419 Serial.println(
"Internal reference mode set");
480 for (i = 0; i <= 8; i++)
492 Serial.println(F(
"Found internal calibration, restoring...)"));
497 Serial.println(F(
"Found external calibration, restoring...)"));
499 else Serial.println(F(
"Calibration not found for this\nreference mode, using ideal calibration"));
521 Serial.println(
"Calibration Restored");
525 Serial.print(
"DAC ");
526 Serial.print((
char) (
'A' + i));
527 Serial.print(
" offset: ");
529 Serial.print(
" , lsb: ");
531 Serial.println(
" mv");
533 Serial.println(
"(DAC I applies to ALL DACs selections)");
534 if (eeaddr != 0)
return (1);
570 Serial.println(F(
"Calibration Stored to EEPROM"));
578 Serial.print(F(
"Type 1 to enter voltage, 2 to enter code:"));
581 Serial.println(user_input);
595 Serial.print(F(
"Enter Desired DAC output voltage: "));
597 Serial.print(dac_voltage);
598 Serial.println(
" V");
608 Serial.println(
"Enter Desired DAC Code");
609 Serial.print(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): ");
612 Serial.println(returncode, HEX);
621 Serial.println(F(
"*****************************************************************"));
622 Serial.println(F(
"* DC1529 Demonstration Program *"));
623 Serial.println(F(
"* *"));
624 Serial.println(F(
"* This program demonstrates how to send data to the LTC2657 *"));
625 Serial.println(F(
"* Octal 16/12-bit DAC found on the DC1529 demo board. *"));
626 Serial.println(F(
"* *"));
627 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
628 Serial.println(F(
"* *"));
629 Serial.println(F(
"*****************************************************************"));
635 Serial.println(F(
"\nCommand Summary:"));
636 Serial.println(F(
" 1-Select DAC"));
637 Serial.println(F(
" 2-Write to input register (no update)"));
638 Serial.println(F(
" 3-Write and update DAC"));
639 Serial.println(F(
" 4-Update / power up DAC"));
640 Serial.println(F(
" 5-Power down DAC"));
641 Serial.println(F(
" 6-Set reference mode"));
642 Serial.println(F(
" 7-Calibrate DAC"));
643 Serial.println(F(
" 8-Enable / Disable calibration"));
645 Serial.println(
"\nPresent Values:");
646 Serial.print(
" Selected DAC: ");
647 if (selected_dac != 8)
648 Serial.println((
char) (selected_dac + 0x41));
650 Serial.println(
"All");
651 Serial.print(
" DAC Reference: ");
653 Serial.println(
"Internal");
656 Serial.print(F(
"External "));
658 Serial.println(F(
"V reference, please verify"));
660 Serial.print(F(
"Enter a command:"));
670 uint16_t code1 = 0x0200;
671 uint16_t code2 = 0xFFFF;
675 Serial.print(
"Calibrating DAC ");
676 Serial.println((
char) (0x41 + index));
679 Serial.print(
"DAC code set to 0x");
680 Serial.println(code1, HEX);
681 Serial.print(
"Enter measured DAC voltage:");
683 Serial.print(voltage1, 6);
684 Serial.println(
" V");
687 Serial.print(
"DAC code set to 0x");
688 Serial.println(code2, HEX);
689 Serial.print(
"Enter measured DAC voltage:");
691 Serial.print(voltage2, 6);
692 Serial.println(
" V");
struct demo_board_type demo_board
Instantiate demo board structure.
static uint8_t reference_mode
Tells whether to set internal or external reference.
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.
char option
Demo Circuit option (A)
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 LTC2657_CMD_WRITE_UPDATE
unsigned char user_command
#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.
#define LTC2657_CMD_WRITE
uint16_t LTC2657_voltage_to_code(float dac_voltage, float LTC2657_lsb, int16_t LTC2657_offset)
Calculate a LTC2657 DAC code given the desired output voltage and DAC address (0-3) ...
Header File for Linduino Libraries and Demo Code.
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.
#define STORED_REF_STATE_BASE
Base address of the stored reference state.
static int8_t menu_1_select_dac(int16_t *selected_dac)
Select which DAC to operate on.
static int8_t menu_3_write_and_update_dac(int16_t selected_dac)
Write data to DAC register (which updates output immediately)
static int8_t menu_8_enable_calibration()
Enable / Disable calibration.
#define EXT_CAL_VALID_BASE
Base address of the "external ref calibration valid" flag.
static void print_title()
Prints the title block when program first starts.
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.
void LTC2657_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2657_lsb, int16_t *LTC2657_offset)
Calculate the LTC2657 offset and LSB voltages given two measured voltages and their corresponding cod...
#define INT_CAL_VALID_BASE
Base address of the "internal ref calibration valid" flag.
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 setup()
Initialize Linduino.
static int8_t calibrate_dac(uint8_t index)
Calibrate the selected DAC using a voltmeter.
static int16_t LTC2657_offset[9]
DAC offset - index 8 for "all DACs".
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 print_prompt(int16_t selected_dac)
Prints main menu.
int8_t LTC2657_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 LTC2657.
#define EXT_REF_V_BASE
Base address of the stored external reference voltage.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
static uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
#define LTC2657_CMD_POWER_DOWN
static uint8_t shift_count
The data align shift count.
static int8_t menu_2_write_to_input_register(int16_t selected_dac)
Write data to input register, but do not update DAC output.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
const uint8_t address_map[9]
Lookup table for DAC address.
static void loop()
Repeats Linduino loop.
static void store_calibration()
Store measured calibration parameters to nonvolatile EEPROM on demo board.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC2657_I2C_ADDRESS
char product_name[15]
LTC Product (LTC2654-L16)
static int16_t prompt_voltage_or_code()
Prompt user to enter a voltage or digital code to send to DAC.
static int8_t restore_calibration()
Read stored calibration parameters from nonvolatile EEPROM on demo board.
#define LTC2657_CMD_UPDATE
static int8_t menu_7_calibrate_dacs()
Calibrate all DACs by measuring two known outputs.
static float reference_voltage
Reference voltage, either internal or external.
static float LTC2657_lsb[9]
The LTC2657 lsb - index 8 for "all DACs".
static int8_t menu_5_power_down_dac(int16_t selected_dac)
Power down DAC.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
static int8_t menu_6_set_reference_mode()
Set reference mode and store to EEPROM.
static uint16_t get_voltage(float LTC2657_lsb, int16_t LTC2657_offset)
Get voltage from user input, calculate DAC code based on lsb, offset.
#define INT_CAL_PARAMS_BASE
Base address of the internal ref calibration parameters.
#define REF_EXTERNAL
Stored reference state is External.
#define EXT_CAL_PARAMS_BASE
Base address of the external ref calibration parameters.
LTC2657: Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference.
#define REF_INTERNAL
Stored reference state is Internal.