140 Serial.begin(115200);
151 if (Serial.available())
177 Serial.println(
"Invalid Option");
192 uint8_t single_ended = 0;
205 Serial.println(F(
" Single-Ended, Unipolar mode, 0 to Vref:"));
206 Serial.println(F(
" 0-CH0"));
207 Serial.println(F(
" 1-CH1"));
208 Serial.println(F(
" 2-CH2"));
209 Serial.println(F(
" 3-CH3"));
210 Serial.println(F(
" 4-CH4"));
211 Serial.println(F(
" 5-CH5"));
212 Serial.println(F(
" 6-CH6"));
213 Serial.println(F(
" 7-CH7"));
214 Serial.println(F(
" 8-ALL"));
215 Serial.println(F(
" m-Main Menu"));
222 Serial.println(F(
" Single-Ended, Bipolar mode, -Vref/2 to +Vref/2:"));
223 Serial.println(F(
" 0-CH0"));
224 Serial.println(F(
" 1-CH1"));
225 Serial.println(F(
" 2-CH2"));
226 Serial.println(F(
" 3-CH3"));
227 Serial.println(F(
" 4-CH4"));
228 Serial.println(F(
" 5-CH5"));
229 Serial.println(F(
" 6-CH6"));
230 Serial.println(F(
" 7-CH7"));
231 Serial.println(F(
" 8-ALL"));
232 Serial.println(F(
" m-Main Menu"));
238 Serial.println(F(
" Differential, Unipolar mode, 0 to Vref:"));
239 Serial.println(F(
" 0-0P-1N"));
240 Serial.println(F(
" 1-2P-3N"));
241 Serial.println(F(
" 2-4P-5N"));
242 Serial.println(F(
" 3-6P-7N"));
243 Serial.println(F(
" 4-1P-0N"));
244 Serial.println(F(
" 5-3P-2N"));
245 Serial.println(F(
" 6-5P_4N"));
246 Serial.println(F(
" 7-7P-6N"));
247 Serial.println(F(
" 8-ALL Even_P-Odd_N"));
248 Serial.println(F(
" m-Main Menu"));
254 Serial.println(F(
" Differential Bipolar mode, -Vref to +Vref:"));
255 Serial.println(F(
" 0-0P-1N"));
256 Serial.println(F(
" 1-2P-3N"));
257 Serial.println(F(
" 2-4P-5N"));
258 Serial.println(F(
" 3-6P-7N"));
259 Serial.println(F(
" 4-1P-0N"));
260 Serial.println(F(
" 5-3P-2N"));
261 Serial.println(F(
" 6-5P_4N"));
262 Serial.println(F(
" 7-7P-6N"));
263 Serial.println(F(
" 8-ALL"));
264 Serial.println(F(
" m-Main Menu"));
268 Serial.println(
" Invalid Option");
273 Serial.print(F(
" Enter a Command: "));
309 Serial.println(
" Invalid Option");
317 switch (single_ended)
322 for (i = 0; i <= 7; i++)
336 Serial.print(F(
" Received ADC Code: 0x"));
341 Serial.print(F(
" Equivalent voltage: "));
343 Serial.println(F(
"V"));
362 Serial.print(F(
" Received ADC Code: 0x"));
367 Serial.print(F(
" Equivalent voltage: "));
369 Serial.println(F(
"V"));
377 for (i = 0; i <= 7; i++)
390 Serial.print(F(
" CH"));
392 Serial.print(F(
" Received ADC Code: 0x"));
397 Serial.print(F(
" Equivalent voltage: "));
399 Serial.println(F(
"V"));
418 Serial.print(F(
" CH"));
420 Serial.print(F(
" Received ADC Code: 0x"));
425 Serial.print(F(
" Equivalent voltage: "));
427 Serial.println(F(
"V"));
440 uint8_t temp_bits = 0;
443 Serial.println(F(
"*****************************************************************************************"));
444 Serial.println(F(
"* This routine demonstrates how to program the sequencer. *"));
445 Serial.println(F(
"* *"));
446 Serial.println(F(
"* A specific set of four configurations will be programmed: *"));
447 Serial.println(F(
"* A single-ended unipolar voltage on AIN1+ *"));
448 Serial.println(F(
"* A differential unipolar voltage on AIN1+/AIN1-, which feeds the ADC differentially *"));
449 Serial.println(F(
"* A single-ended bipolar voltage on AIN3, which feeds the ADC differentially *"));
450 Serial.println(F(
"* A differential bipolar voltage on AIN4+/AIN4- *"));
451 Serial.println(F(
"* *"));
452 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator. *"));
453 Serial.println(F(
"* *"));
454 Serial.println(F(
"*****************************************************************************************"));
466 Serial.println(F(
" Write Codes: "));
467 Serial.print(F(
" Register C3 adc config code: "));
468 Serial.println(adc_configuration.
LT_byte[0] & 0x7F, BIN);
469 Serial.print(F(
" Register C2 adc config code: "));
470 Serial.println(adc_configuration.
LT_byte[1] & 0x7F, BIN);
471 Serial.print(F(
" Register C1 adc config code: "));
472 Serial.println(adc_configuration.
LT_byte[2] & 0x7F, BIN);
473 Serial.print(F(
" Register C0 adc config code: "));
474 Serial.println(adc_configuration.
LT_byte[3] & 0x7F, BIN);
485 for (i = 0; i < 4; i++)
497 Serial.print(F(
" Register C"));
504 Serial.println(F(
" Unipolar, 0 to Vref"));
507 Serial.println(F(
" Bipolar, -Vref/2 to +Vref/2"));
510 Serial.println(F(
" Differential unipolar, 0 to Vref"));
513 Serial.println(F(
" Differential bipolar, -Vref to +Vref"));
517 Serial.print(F(
" Readback adc config: "));
520 Serial.print(F(
" Received Code: 0x"));
526 Serial.print(F(
" Equivalent voltage: "));
528 Serial.println(F(
"V"));
543 Serial.println(F(
" 16 bits selected"));
545 Serial.println(F(
" 18 bits selected"));
547 Serial.println(F(
" 16 = 2373-16"));
548 Serial.println(F(
" 18 = 2373-18"));
549 Serial.println(F(
""));
550 Serial.print(F(
" Enter a Command, based upon the resolution of the part under test: "));
553 Serial.println(user_command);
554 switch (user_command)
564 Serial.println(
" Invalid Option");
578 Serial.println(F(
" 0 = Unipolar, 0 to Vref"));
579 Serial.println(F(
" 1 = Bipolar, -Vref/2 to +Vref/2"));
580 Serial.println(F(
" 2 = Differential unipolar, 0 to Vref"));
581 Serial.println(F(
" 3 = Differential bipolar, -Vref to +Vref"));
582 Serial.println(F(
""));
583 Serial.print(F(
" Enter a Command: "));
585 Serial.println(user_command);
587 switch (user_command)
590 Serial.println(F(
" Unipolar input range selected; set JP9 to 'GND' position"));
594 Serial.println(F(
" Bipolar input range selected; set JP9 to 'CM' position"));
598 Serial.println(F(
" Differential Unipolar input range selected"));
599 Serial.println(F(
" Note that this range operates only for the following configurations:"));
600 Serial.println(F(
" CH 0P-1N, with AIN1+ connected to GND"));
601 Serial.println(F(
" CH 1P-0N, with AIN1- connected to GND"));
605 Serial.println(F(
" Differential Bipolar input range selected"));
610 Serial.println(
" Invalid Option");
625 Serial.println(F(
" No gain compression enabled"));
627 Serial.println(F(
" Gain compression enabled"));
629 Serial.println(F(
" 0 = No Gain Compression"));
630 Serial.println(F(
" 1 = Gain Compression"));
631 Serial.println(F(
""));
632 Serial.print(F(
" Enter a Command: "));
635 Serial.println(user_command);
636 switch (user_command)
646 Serial.println(
" Invalid Option");
658 Serial.println(F(
"*****************************************************************"));
659 Serial.println(F(
"* DC2071A Demonstration Program *"));
660 Serial.println(F(
"* *"));
661 Serial.println(F(
"* This program demonstrates how to receive data *"));
662 Serial.println(F(
"* from the LTC2373-16/18 ADC. *"));
663 Serial.println(F(
"* *"));
664 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
665 Serial.println(F(
"* *"));
666 Serial.println(F(
"*****************************************************************"));
674 Serial.println(F(
" 1-Read ADC Input"));
675 Serial.println(F(
" 2-Program the Sequencer"));
676 Serial.println(F(
" 3-Read the Sequencer"));
677 Serial.println(F(
" 4-Select Number of Bits (Default is 18 bits)"));
678 Serial.println(F(
" 5-Select Range (Default is Single-Ended Unipolar Range)"));
679 Serial.println(F(
" 6-Select Gain Compression (Default is No Gain Compression)\n"));
680 Serial.println(F(
""));
681 Serial.print(F(
" Enter a command: "));
692 Serial.print(F(
" CH 0P-1N"));
695 Serial.print(F(
" CH 2P-3N"));
698 Serial.print(F(
" CH 4P-5N"));
701 Serial.print(F(
" CH 6P-7N"));
704 Serial.print(F(
" CH 1P-0N"));
707 Serial.print(F(
" CH 3P-2N"));
710 Serial.print(F(
" CH 5P-4N"));
713 Serial.print(F(
" CH 7P-6N"));
uint8_t LTC2373_build_command(uint8_t sequencer_bit, uint8_t ch_designate, uint8_t range_select, uint8_t gain_compression)
const uint8_t COMMAND_SINGLE_ENDED[8]
Lookup table to build the command for single-ended mode, input with respect to GND.
static uint8_t adc_command
int8_t i2c_write_byte(uint8_t address, uint8_t value)
Write "value" byte to device at "address".
uint8_t LT_byte[4]
4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer ...
static void print_prompt()
Prints main menu.
void LTC2373_configure(uint8_t cs, uint32_t adc_configure)
Configures the LTC2373.
#define LTC2373_RANGE_DIFF_BIPOLAR
static void print_user_command(uint8_t menu)
Display selected differential channels.
LTC2373: 16/18-bit 1Msps 8 channel SAR ADC LTC2372: 16/18-bit 500ksps 8 channel SAR ADC LTC2374: 16 b...
const uint8_t COMMAND_DIFF[8]
Lookup table to build the command for differential mode.
static void menu_4_select_bits()
Select number of bits.
Header File for Linduino Libraries and Demo Code.
#define LTC2373_SEQUENCER_BIT
static void loop()
Repeats Linduino loop.
uint32_t LT_uint32
32-bit unsigned integer to be converted to four bytes
#define LTC2373_RANGE_BIPOLAR
static void menu_3_read_sequencer()
Program the sequencer.
static void setup()
Initialize Linduino.
#define LTC2373_RANGE_UNIPOLAR
static float LTC2373_vref
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
void LTC2373_read(uint8_t cs, uint8_t adc_command, uint32_t *ptr_adc_code)
Reads the LTC2373 and returns 32-bit data.
#define LTC2373_CS
Define the SPI CS pin.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static void print_title()
Prints the title block when program first starts.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
static uint8_t LTC2373_bits
Default set for 18 bits.
static void menu_6_select_gain_compression()
Select gain compression.
#define LTC2373_RANGE_DIFF_UNIPOLAR
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
static uint8_t LTC2373_range_select
Default set for single-ended unipolar mode.
static int32_t display_code
#define LTC2373_NO_COMPRESSION
static uint8_t LTC2373_gain_compression
Default set for no compression mode.
This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer) four uint...
static uint8_t user_command
static void menu_2_program_sequencer()
Program the sequencer.
static void menu_5_select_range()
Select range.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
float LTC2373_code_to_voltage(uint8_t adc_command, uint32_t adc_code, float vref)
Calculates the LTC2373 input voltage given the binary data and lsb weight.
static uint8_t LTC2373_sequencer_bit
static void menu_1_read_adc()
Read channels in single-ended mode.