Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC1333A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1333A Demonstration Board.
3 LTC2640: Single 12-/10-/8-Bit Rail-to-Rail DACs with 10ppm/C Reference
4 Demonstration Circuit DC1333 features the 12-bit versions of the LTC2640.
5 
6 Linear Technology DC1074A Demonstration Board.
7 LTC2630: Single 12-/10-/8-Bit Rail-to-Rail DACs with Integrated Reference in SC70
8 
9 @verbatim
10 NOTES
11  Setup:
12  Set the terminal baud rate to 115200 and select the newline terminator. The
13  program displays calculated voltages which are based on the voltage of the
14  reference used, be it internal or external. A precision voltmeter is needed to
15  verify the actual measured voltages against the calculated voltage displayed. If
16  an external reference is used, a precision voltage source is required to apply
17  the external reference voltage. A precision voltmeter is also required to measure
18  the external reference voltage. No external power supply is required. All four
19  demo board options may be used: DC1333A-A, DC1333A-B, DC1333A-C, or DC1333A-D.
20 
21 
22  Explanation of Commands:
23 
24 
25  1- Write to DAC input register: Value is stored in the DAC for updating later,
26  through a software "Update" command. User will be prompted to enter either a
27  code in hex or decimal, or a voltage. If a voltage is entered, a code will be
28  calculated based on the active scaling and reference parameters - ideal values
29  if no calibration was ever stored. (This is more often used with the
30  multichannel DACs in the family, where all DACs can be updated at once in
31  software or by asserting the LDAC# pin.)
32 
33  2- Write and Update: Similar to item 1, but DAC is updated immediately.
34 
35  3- Write to DAC: Sends the DAC code to the Input Register.
36 
37  4- Update DAC: Copies the value from the input register into the DAC Register.
38  Note that a "write and update" command writes the code to BOTH the input
39  register and DAC register, so subsequent "update" commands will simply re-copy
40  the same data (no change in output.)
41 
42  5- Power Down DAC: Disable DAC output. Power supply current is reduced. DAC code
43  present in DAC registers at time of shutdown are preserved.
44 
45  6- Set reference mode: Either internal or external. Selecting external mode
46  prompts for the external refernce voltage, which is used directly if no
47  individual DAC calibration is stored. The selection and entered volgage are
48  stored to EEPROM so it is persisent across reset / power cycles.
49 
50  7- Calibrate DAC: Use a precision voltmeter to obtain and enter VOUT readings
51  taken with different DAC codes. Set reference mode FIRST, as values are stored
52  separately for internal and external reference mode. Entries are used to
53  calculate the closest code to send to the DAC to achieve an entered voltage.
54 
55  8- Enable / Disable Calibration: Switch between stored calibration values and
56  defaults. Calibration parameters are stored separately for internal and
57  external reference modes. Ideal calibration will be used if the calibration
58  parameter valid key is not set.
59 
60 
61 USER INPUT DATA FORMAT:
62  decimal : 1024
63  hex : 0x400
64  octal : 02000 (leading 0 "zero")
65  binary : B10000000000
66  float : 1024.0
67 
68 @endverbatim
69 
70 http://www.linear.com/product/LTC2640
71 http://www.linear.com/product/LTC2630
72 
73 http://www.linear.com/product/LTC2640#demoboards
74 http://www.linear.com/product/LTC2630#demoboards
75 
76 
77 Copyright 2018(c) Analog Devices, Inc.
78 
79 All rights reserved.
80 
81 Redistribution and use in source and binary forms, with or without
82 modification, are permitted provided that the following conditions are met:
83  - Redistributions of source code must retain the above copyright
84  notice, this list of conditions and the following disclaimer.
85  - Redistributions in binary form must reproduce the above copyright
86  notice, this list of conditions and the following disclaimer in
87  the documentation and/or other materials provided with the
88  distribution.
89  - Neither the name of Analog Devices, Inc. nor the names of its
90  contributors may be used to endorse or promote products derived
91  from this software without specific prior written permission.
92  - The use of this software may or may not infringe the patent rights
93  of one or more patent holders. This license does not release you
94  from the requirement that you obtain separate licenses from these
95  patent holders to use this software.
96  - Use of the software either in source or binary form, must be run
97  on or directly connected to an Analog Devices Inc. component.
98 
99 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
100 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
101 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
102 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
103 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
104 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
105 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
106 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
107 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
108 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109  */
110 
111 /*! @file
112  @ingroup LTC2640
113 */
114 
115 #include <Arduino.h>
116 #include <stdint.h>
117 #include "Linduino.h"
118 #include "LT_SPI.h"
119 #include "LT_I2C.h"
120 #include "UserInterface.h"
121 #include "QuikEval_EEPROM.h"
122 #include "LTC2640.h"
123 #include <SPI.h>
124 #include <Wire.h>
125 
126 #define EEPROM_CAL_KEY_INT 0x5678 //!< Calibration associated with internal reference
127 #define EEPROM_CAL_KEY_EXT 0x9ABC //!< Calibration associated with external reference
128 
129 // DAC Reference State
130 // Could have been zero or 1, this allows you to use the
131 // variable "reference_mode" as the command argument to a write
132 #define REF_INTERNAL LTC2640_CMD_INTERNAL_REFERENCE //!< Stored reference state is Internal
133 #define REF_EXTERNAL LTC2640_CMD_EXTERNAL_REFERENCE //!< Stored reference state is External
134 
135 // EEPROM memory locations
136 #define STORED_REF_STATE_BASE EEPROM_CAL_STATUS_ADDRESS //!< Base address of the stored reference state
137 #define INT_CAL_VALID_BASE STORED_REF_STATE_BASE + 2 //!< Base address of the "internal ref calibration valid" flag
138 #define INT_CAL_PARAMS_BASE INT_CAL_VALID_BASE + 2 //!< Base address of the internal ref calibration parameters
139 #define EXT_CAL_VALID_BASE INT_CAL_PARAMS_BASE + 8 //!< Base address of the "external ref calibration valid" flag
140 #define EXT_CAL_PARAMS_BASE EXT_CAL_VALID_BASE + 2 //!< Base address of the external ref calibration parameters
141 #define EXT_REF_V_BASE EXT_CAL_PARAMS_BASE + 8 //!< Base address of the stored external reference voltage
142 #define LSB_PARAM_ADDR_OFFSET 4 //!< Offset into XXX_CAL_PARAMS_BASE to locate stored LSB parameter
143 
144 // Function Declaration
145 int8_t restore_calibration(); // Read the DAC calibration from EEPROM, Return 1 if successful, 0 if not
146 void store_calibration(); // Store the DAC calibration to the EEPROM
147 void print_title(); // Print the title block
148 void print_prompt(); // Prompt the user for an input command
149 int16_t prompt_voltage_or_code();
150 uint16_t get_voltage(float LTC2640_lsb, int32_t LTC2640_offset);
151 uint16_t get_code();
152 void calibrate_dac(); // Calibrate the selected DAC using a voltmeter. The routine does a linear curve fit given two data points.
153 
157 void menu_4_power_down_dac();
158 void menu_5_set_reference_mode(); // Int, ext, if ext, prompt for voltage
159 void menu_6_calibrate_dacs();
161 
162 // Global variables
163 static uint8_t demo_board_connected; //!< Set to 1 if the board is connected
164 static uint8_t shift_count = 4; //!< The data align shift count. For 12-bits, shift_count = 4
165 static uint8_t reference_mode; //!< Tells whether to set internal or external reference
166 
167 // Global calibration variables
168 static float reference_voltage; //!< Reference voltage, either internal or external
169 static float LTC2640_lsb = 1e-3; //!< DAC lsb. Default to 12-bits
170 static int16_t LTC2640_offset = 0; //!< DAC offset
171 
172 //! Used to keep track to print voltage or print code
173 enum
174 {
175  PROMPT_VOLTAGE = 0, /**< 0 */
176  PROMPT_CODE = 1 /**< 1 */
177 };
178 
179 //! Initialize Linduino
180 void setup()
181 // Setup the program
182 {
183  char demo_name[] = "DC1333"; // Demo Board Name stored in QuikEval EEPROM
184 
185  quikeval_SPI_init(); // Configure the spi port for 4Mhz SCK
186  quikeval_SPI_connect(); // Connect SPI to main data port
187  quikeval_I2C_init(); // Configure the EEPROM I2C port for 100khz
188  Serial.begin(115200); // Initialize the serial port to the PC
189  print_title();
192  {
193  // The DC1333A does not have the option indicated in the demo board name
194  // Uses product name for the option
195  if (strlen(strstr(demo_board.product_name, "-LM")) > 1)
196  demo_board.option = 'A';
197  if (strlen(strstr(demo_board.product_name, "-LZ")) > 1)
198  demo_board.option = 'B';
199  if (strlen(strstr(demo_board.product_name, "-HM")) > 1)
200  demo_board.option = 'C';
201  if (strlen(strstr(demo_board.product_name, "-HZ")) > 1)
202  demo_board.option = 'D';
203  Serial.print("Demo Board Option: ");
204  Serial.println(demo_board.option);
206  print_prompt();
207  }
208 }
209 
210 //! Repeats Linduino loop
211 void loop()
212 {
213  int16_t user_command;
214  // The main control loop
215  if (demo_board_connected) // Do nothing if the demo board is not connected
216  {
217  if (Serial.available()) // Check for user input
218  {
219  user_command = read_int(); // Read the user command
220  Serial.println(user_command);
221  Serial.flush();
222  switch (user_command)
223  {
224  case 1:
226  break;
227  case 2:
229  break;
230  case 3:
232  break;
233  case 4:
235  break;
236  case 5:
237  menu_5_set_reference_mode(); // Int, ext, if ext, prompt for voltage
239  break;
240  case 6:
243  break;
244  case 7:
247  break;
248  default:
249  Serial.println("Incorrect Option");
250  break;
251  }
252  Serial.println("\n*****************************************************************");
253  print_prompt();
254  }
255  }
256 }
257 
258 // Function Definitions
259 
260 //! Write data to input register, but do not update DAC output
262 {
263  uint16_t dac_code;
264 
267  else
268  dac_code = get_code();
269 
271 }
272 
273 //!Write data to DAC register (which updates output immediately)
275 {
276  uint16_t dac_code;
277 
280  else
281  dac_code = get_code();
283 }
284 
285 //! Update DAC with data that is stored in input register, power up if sleeping
287 {
288  // Update DAC
290 }
291 
292 //! Power down DAC
294 {
295  // Power down DAC
297 }
298 
299 //! Set reference mode and store to EEPROM
300 void menu_5_set_reference_mode() // Int, ext, if ext, prompt for voltage
301 {
302  int16_t user_input;
303  Serial.println("Select reference mode - 0 for Internal, 1 for External");
304  user_input = read_int();
305  if (user_input == 1)
306  {
308  Serial.println("External reference mode; enter external reference voltage");
310  Serial.print(reference_voltage, 5);
311  Serial.println("V");
313  }
314  else
315  {
317  Serial.println("Internal reference mode selected");
318  }
319  Serial.println("Writing reference mode to EEPROM\n\n");
321 }
322 
323 //! Calibrate all DACs by measuring two known outputs
325 {
326  // Calibrate the DACs using a multimeter
327  calibrate_dac(); // Run calibration routine
329 }
330 
331 //! Enable / Disable calibration. Use with caution - behavior is undefined if you enable calibration and an actual
332 //! calibration cycle has not been performed.
334 {
335  int16_t user_input;
336  Serial.println(F("\n\nSelect option - 0: Enable Internal, 1: Disable Internal, 2: Enable External, 3: Disable External"));
337  user_input = read_int();
338  switch (user_input)
339  {
340  case 0:
341  Serial.println(F("Enabling Internal Cal Params"));
343  break;
344  case 1:
345  Serial.println(F("Disabling Internal Cal Params"));
347  break;
348  case 2:
349  Serial.println(F("Enabling External Cal Params"));
351  break;
352  case 3:
353  Serial.println(F("Disabling External Cal Params"));
355  break;
356  }
357 }
358 
359 //! Read stored calibration parameters from nonvolatile EEPROM on demo board
360 //! @return Return 1 if successful, 0 if not
362 // Read the DAC calibration from EEPROM
363 // Return 1 if successful, 0 if not
364 {
365  int16_t intvalid, extvalid;
366  uint8_t i, eeaddr;
367  float dac_count; // The number of codes, 4096 for 12 bits, 65536 for 16 bits
368 
369  Serial.println(F("\n\nReading Calibration parameters from EEPROM..."));
370  float full_scale; // To avoid confusion - in internal ref mode, FS=Vref, in ext mode, FS=2*Vref
371  // Read the cal keys from the EEPROM.
374  // Read the stored reference state
376  // Read external ref V unconditionally, overwrite with defaults if no cal found
378 
379  if (reference_mode == REF_EXTERNAL)
380  {
381  Serial.print(F("Restored external ref. Voltage:"));
382  Serial.println(reference_voltage, 5);
383  }
384  else // EITHER reference is set to internal, OR not programmed in which case default to internal
385  {
386  reference_mode = REF_INTERNAL; // Redundant if already set
387  Serial.println("Internal reference mode set");
388  }
389 
390  // Write the reference mode to the DAC right away
391  LTC2640_write(LTC2640_CS, reference_mode, 0x0000);
392 
393  // Set up default values, shift count, DAC count
394  // Calibration parameters MAY be changed next, if match
395  // between reference mode and stored calibration
396  full_scale = reference_voltage; // If external ref mode, this applies.
397  switch (demo_board.option)
398  {
399  case 'A':
400  // LTC2640-LM, 12-bits, 2.5V full scale
401  shift_count = 4;
402  if (reference_mode == REF_INTERNAL) full_scale = 2.5;
403  dac_count = 4096;
404  break;
405  case 'B':
406  // LTC2640-LZ, 12-bits, 4.096V full scale
407  shift_count = 4;
408  if (reference_mode == REF_INTERNAL) full_scale = 2.5;
409  dac_count = 4096;
410  break;
411  case 'C':
412  // LTC2640-HM, 12-bits, 2.5V full scale
413  shift_count = 4;
414  if (reference_mode == REF_INTERNAL) full_scale = 4.096;
415  dac_count = 4096;
416  break;
417  case 'D':
418  // LTC2640-HZ, 12-bits, 4.096V full scale
419  shift_count = 4;
420  if (reference_mode == REF_INTERNAL) full_scale = 4.096;
421  dac_count = 4096;
422  break;
423  }
424 
425  LTC2640_offset = 0;
426  LTC2640_lsb = full_scale / dac_count;
427 
428  // Restore calibration IF reference mode matches stored calibraiton
429  eeaddr = 0; // Assume no calibration present or mismatch between cal and reference mode
430 
431  if ((intvalid == EEPROM_CAL_KEY) && (reference_mode == REF_INTERNAL))
432  {
433  eeaddr = INT_CAL_PARAMS_BASE;
434  Serial.println(F("Found internal calibration, restoring...)"));
435  }
436  else if ((extvalid == EEPROM_CAL_KEY) && (reference_mode == REF_EXTERNAL))
437  {
438  eeaddr = EXT_CAL_PARAMS_BASE;
439  Serial.println(F("Found external calibration, restoring...)"));
440  }
441  else Serial.println(F("Calibration not found for this\nreference mode, using ideal calibration"));
442 
443  if (eeaddr != 0) // If cal key was enabled and reference mode is correct, read offset and lsb
444  {
447  Serial.println("Calibration Restored");
448  }
449 
450  Serial.print("offset: ");
451  Serial.print(LTC2640_offset);
452  Serial.print(" , lsb: ");
453  Serial.print(LTC2640_lsb * 1000, 4);
454  Serial.println(" mv");
455 
456  if (eeaddr != 0) return (1);
457  return (0);
458 }
459 
460 //! Store measured calibration parameters to nonvolatile EEPROM on demo board
462 // Store the DAC calibration to the EEPROM
463 {
464  uint8_t eeaddr;
466  {
468  eeaddr = INT_CAL_PARAMS_BASE;
469  }
470  else
471  {
473  eeaddr = EXT_CAL_PARAMS_BASE;
474  }
477  Serial.println(F("Calibration Stored to EEPROM"));
478 }
479 
480 //! Prompt user to enter a voltage or digital code to send to DAC
481 //! @return Returns the prompt indicator
483 {
484  int16_t user_input;
485  Serial.print(F("Type 1 to enter voltage, 2 to enter code:"));
486  Serial.flush();
487  user_input = read_int();
488  Serial.println(user_input);
489 
490  if (user_input != 2)
491  return(PROMPT_VOLTAGE);
492  else
493  return(PROMPT_CODE);
494 }
495 
496 //! Get voltage from user input, calculate DAC code based on lsb, offset
497 //! @return Returns the DAC code
498 uint16_t get_voltage(float LTC2640_lsb, int16_t LTC2640_offset)
499 {
500  float dac_voltage;
501 
502  Serial.print(F("Enter Desired DAC output voltage: "));
503  dac_voltage = read_float();
504  Serial.print(dac_voltage);
505  Serial.println(" V");
506  Serial.flush();
507  return(LTC2640_voltage_to_code(dac_voltage, LTC2640_lsb, LTC2640_offset));
508 }
509 
510 //! Get code to send to DAC directly, in decimal, hex, or binary
511 //! @return Returns users input dac code
512 uint16_t get_code()
513 {
514  uint16_t returncode;
515  Serial.println("Enter Desired DAC Code");
516  Serial.print("(Format 32768, 0x8000, 0100000, or B1000000000000000): ");
517  returncode = (uint16_t) read_int();
518  Serial.print("0x");
519  Serial.println(returncode, HEX);
520  Serial.flush();
521  return(returncode);
522 }
523 
524 //! Prints the title block when program first starts.
526 {
527  Serial.println("");
528  Serial.println(F("*****************************************************************"));
529  Serial.println(F("* DC1333 Demonstration Program *"));
530  Serial.println(F("* *"));
531  Serial.println(F("* This program demonstrates how to send data to the LTC2640 *"));
532  Serial.println(F("* Single 12-bit DAC found on the DC1333 demo board. *"));
533  Serial.println(F("* *"));
534  Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
535  Serial.println(F("* *"));
536  Serial.println(F("*****************************************************************"));
537 }
538 
539 //! Prints main menu.
541 {
542  Serial.println(F("\nCommand Summary:"));
543  Serial.println(F(" 1-Write to input register (no update)"));
544  Serial.println(F(" 2-Write and update DAC"));
545  Serial.println(F(" 3-Update / power up DAC"));
546  Serial.println(F(" 4-Power down DAC"));
547  Serial.println(F(" 5-Set reference mode"));
548  Serial.println(F(" 6-Calibrate DAC"));
549  Serial.println(F(" 7-Enable / Disable calibration"));
550 
551  Serial.println("\nPresent Values:");
552  Serial.print(" DAC Reference: ");
554  Serial.println("Internal");
555  else
556  {
557  Serial.print(F("External "));
558  Serial.print(reference_voltage, 5);
559  Serial.println(F("V reference, please verify"));
560  Serial.print(F("Enter a command:"));
561  }
562  Serial.flush();
563 }
564 
565 //! Calibrate the selected DAC using a voltmeter. The routine
566 //! does a linear curve fit given two data points.
568 {
569  uint16_t code1 = 0x0020; //! Calibration code 1
570  uint16_t code2 = 0x0FFF; //! Calibration code 2
571  float voltage1; //! Calibration voltage 1
572  float voltage2; //! Calibration voltage 2
573  Serial.println();
574  Serial.print("Calibrating DAC ");
575 
576  // Left align 12-bit code1 to 16 bits & write to DAC
578  Serial.print("DAC code set to 0x");
579  Serial.println(code1, HEX);
580  Serial.print("Enter measured DAC voltage:");
581  voltage1 = read_float();
582  Serial.print(voltage1, 6);
583  Serial.println(" V");
584  // Left align 12-bit code2 to 16 bits & write to DAC
586  Serial.print("DAC code set to 0x");
587  Serial.println(code2, HEX);
588  Serial.print("Enter measured DAC voltage:");
589  voltage2 = read_float();
590  Serial.print(voltage2, 6);
591  Serial.println(" V");
592  LTC2640_calibrate(code1, code2, voltage1, voltage2, &LTC2640_lsb, &LTC2640_offset);
593 }
struct demo_board_type demo_board
Instantiate demo board structure.
static void menu_7_enable_calibration()
Enable / Disable calibration.
Definition: DC1333A.ino:333
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 REF_EXTERNAL
Stored reference state is External.
Definition: DC1333A.ino:133
unsigned char user_command
#define EXT_CAL_VALID_BASE
Base address of the "external ref calibration valid" flag.
Definition: DC1333A.ino:139
#define EEPROM_I2C_ADDRESS
static void menu_4_power_down_dac()
Power down DAC.
Definition: DC1333A.ino:293
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 void menu_2_write_and_update_dac()
Write data to DAC register (which updates output immediately)
Definition: DC1333A.ino:274
static void print_title()
Prints the title block when program first starts.
Definition: DC1333A.ino:525
Header File for Linduino Libraries and Demo Code.
#define STORED_REF_STATE_BASE
Base address of the stored reference state.
Definition: DC1333A.ino:136
static void store_calibration()
Store measured calibration parameters to nonvolatile EEPROM on demo board.
Definition: DC1333A.ino:461
#define LSB_PARAM_ADDR_OFFSET
Offset into XXX_CAL_PARAMS_BASE to locate stored LSB parameter.
Definition: DC1333A.ino:142
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 prompt_voltage_or_code()
Prompt user to enter a voltage or digital code to send to DAC.
Definition: DC1333A.ino:482
static void print_prompt()
Prints main menu.
Definition: DC1333A.ino:540
static void menu_1_write_to_input_register()
Write data to input register, but do not update DAC output.
Definition: DC1333A.ino:261
static void loop()
Repeats Linduino loop.
Definition: DC1333A.ino:211
static uint8_t reference_mode
Tells whether to set internal or external reference.
Definition: DC1333A.ino:165
static uint8_t shift_count
The data align shift count.
Definition: DC1333A.ino:164
#define REF_INTERNAL
Stored reference state is Internal.
Definition: DC1333A.ino:132
static uint8_t demo_board_connected
Set to 1 if the board is connected.
Definition: DC1333A.ino:163
#define LTC2640_CMD_UPDATE
Definition: LTC2640.h:111
uint16_t LTC2640_voltage_to_code(float dac_voltage, float LTC2640_lsb, int16_t LTC2640_offset)
Calculate the LTC2640 DAC code given the desired output voltage.
Definition: LTC2640.cpp:101
void LTC2640_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2640_lsb, int16_t *LTC2640_offset)
Calculate the LTC2640 offset and LSB voltages given two measured voltages and their corresponding cod...
Definition: LTC2640.cpp:123
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.
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 menu_6_calibrate_dacs()
Calibrate all DACs by measuring two known outputs.
Definition: DC1333A.ino:324
static uint16_t get_voltage(float LTC2640_lsb, int32_t LTC2640_offset)
static void calibrate_dac()
Calibrate the selected DAC using a voltmeter.
Definition: DC1333A.ino:567
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.
QuikEval EEPROM Library.
void LTC2640_write(uint8_t cs, uint8_t dac_command, uint16_t dac_code)
Write the dac_command and 16-bit dac_code to the LTC2640.
Definition: LTC2640.cpp:87
static int8_t restore_calibration()
Read stored calibration parameters from nonvolatile EEPROM on demo board.
Definition: DC1333A.ino:361
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
#define LTC2640_CS
Define the SPI CS pin.
Definition: LTC2640.h:105
static void setup()
Initialize Linduino.
Definition: DC1333A.ino:180
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_REF_V_BASE
Base address of the stored external reference voltage.
Definition: DC1333A.ino:141
#define INT_CAL_VALID_BASE
Base address of the "internal ref calibration valid" flag.
Definition: DC1333A.ino:137
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
static float reference_voltage
Reference voltage, either internal or external.
Definition: DC1333A.ino:168
#define LTC2640_CMD_WRITE
Definition: LTC2640.h:110
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
static uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
Definition: DC1333A.ino:512
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
int32_t read_int()
float read_float()
LTC2640: Single 12-/10-/8-Bit Rail-to-Rail DACs with 10ppm/C Reference.
char product_name[15]
LTC Product (LTC2654-L16)
static float LTC2640_lsb
DAC lsb.
Definition: DC1333A.ino:169
#define LTC2640_CMD_POWER_DOWN
Definition: LTC2640.h:113
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
static int i
Definition: DC2430A.ino:184
static int16_t LTC2640_offset
DAC offset.
Definition: DC1333A.ino:170
static void menu_3_update_power_up_dac()
Update DAC with data that is stored in input register, power up if sleeping.
Definition: DC1333A.ino:286
#define INT_CAL_PARAMS_BASE
Base address of the internal ref calibration parameters.
Definition: DC1333A.ino:138
static void menu_5_set_reference_mode()
Set reference mode and store to EEPROM.
Definition: DC1333A.ino:300
#define EEPROM_CAL_KEY
#define LTC2640_CMD_WRITE_UPDATE
Definition: LTC2640.h:112
#define EXT_CAL_PARAMS_BASE
Base address of the external ref calibration parameters.
Definition: DC1333A.ino:140