115 Serial.begin(115200);
128 static int16_t selected_dac =0;
132 if (Serial.available())
135 Serial.println(user_command);
137 switch (user_command)
155 Serial.println(
"\n*****************************************************************");
167 Serial.print(
"Select DAC to operate on (0=A, 1=B, 2=C, 3=D, 4=All)");
169 if (*selected_dac == 4)
170 Serial.println(
"All");
172 Serial.println(*selected_dac);
221 Serial.print(F(
"Type 1 to enter voltage, 2 to enter code:"));
224 Serial.println(user_input);
239 Serial.print(F(
"Enter Desired DAC output voltage: "));
241 Serial.print(dac_voltage);
242 Serial.println(
" V");
252 Serial.println(
"Enter Desired DAC Code");
253 Serial.print(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): ");
256 Serial.println(returncode, HEX);
265 Serial.println(F(
"*****************************************************************"));
266 Serial.println(F(
"* DC809A Demonstration Program *"));
267 Serial.println(F(
"* *"));
268 Serial.println(F(
"* This program demonstrates how to send data to the LTC2604 *"));
269 Serial.println(F(
"* quad 16/14/12-bit DAC found on the DC809A demo board. *"));
270 Serial.println(F(
"* *"));
271 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
272 Serial.println(F(
"* *"));
273 Serial.println(F(
"*****************************************************************"));
279 Serial.println(F(
"\nCommand Summary:"));
280 Serial.println(F(
" 1-Select DAC"));
281 Serial.println(F(
" 2-Write to input register (no update)"));
282 Serial.println(F(
" 3-Write and update DAC"));
283 Serial.println(F(
" 4-Update / power up DAC"));
284 Serial.println(F(
" 5-Power down DAC"));
286 Serial.println(
"\nPresent Values:");
287 Serial.print(
" Selected DAC: ");
288 if (selected_dac != 4)
289 Serial.println((
char) (selected_dac + 0x41));
291 Serial.println(
"All");
292 Serial.print(
" DAC Reference: ");
293 Serial.println(
"Internal");
294 Serial.print(F(
"Enter a command:"));
static uint8_t demo_board_connected
set to 1 if the board is connected
unsigned char user_command
static void setup()
Initialize Linduino.
static int16_t prompt_voltage_or_code()
Prompt user to enter a voltage or digital code to send to DAC.
#define LTC2604_CMD_WRITE_UPDATE
Write to input register n, update (power up) all.
Header File for Linduino Libraries and Demo Code.
uint16_t LTC2604_voltage_to_code(float dac_voltage, float LTC2604_lsb, int16_t LTC2604_offset)
Calculate a LTC2604 DAC code given the desired output voltage and DAC address (0-3) ...
static void print_prompt(int16_t selected_dac)
Prints main menu.
static void menu_3_write_and_update_dac(int16_t selected_dac)
Write data to DAC register (which updates output immediately)
static void menu_4_update_power_up_dac(int16_t selected_dac)
Update DAC with data that is stored in input register, power up if sleeping.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
static float LTC2604_lsb[4]
static float reference_voltage[4]
set based on jumper positions
#define LTC2604_CMD_UPDATE
Update (power up) DAC register n.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
void LTC2604_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2604.
const uint8_t address_map[5]
Lookup table for DAC address.
static void print_title()
Prints the title block when program first starts.
static int16_t LTC2604_offset
static uint16_t get_voltage(float LTC2604_lsb, int16_t LTC2604_offset)
Get voltage from user input, calculate DAC code based on lsb, offset.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC2604_CS
Define the SPI CS pin.
static void menu_5_power_down_dac(int16_t selected_dac)
Power down DAC.
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 uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
static void loop()
Repeats Linduino loops.
LTC2604: Quad 16-Bit Rail-to-Rail DACs in 16-Lead SSOP.
static void menu_1_select_dac(int16_t *selected_dac)
Select which DAC to operate on.
static void menu_2_write_to_input_register(int16_t selected_dac)
Write data to input register, but do not update DAC output.
#define LTC2604_CMD_POWER_DOWN
Power down n.
static uint8_t shift_count
The data align shift count for 16-bit =0 14-bit =2 12-bit =4.
#define LTC2604_CMD_WRITE
Write to input register n.