Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC1558_DC1808.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1558 and DC1808 Demonstration Boards.
3 LTC3589: 8-Output Regulator with Sequencing and I2C
4 
5 @verbatim
6 
7 SETUP:
8  Set the terminal baud rate to 115200 and select the newline terminator.
9  Set all switches in SW1 to their default position.
10  Tie PWR_ON high by connecting it to VIN.
11  Power VIN from an external power supply.
12 
13 NOTE:
14  For proper IRQ LED behavior, move resistor R39 to the optional R38 position
15  on the DC2026B.
16 
17 @endverbatim
18 
19 http://www.linear.com/product/LTC3589
20 
21 http://www.linear.com/product/LTC3589#demoboards
22 
23 
24 Copyright 2018(c) Analog Devices, Inc.
25 
26 All rights reserved.
27 
28 Redistribution and use in source and binary forms, with or without
29 modification, are permitted provided that the following conditions are met:
30  - Redistributions of source code must retain the above copyright
31  notice, this list of conditions and the following disclaimer.
32  - Redistributions in binary form must reproduce the above copyright
33  notice, this list of conditions and the following disclaimer in
34  the documentation and/or other materials provided with the
35  distribution.
36  - Neither the name of Analog Devices, Inc. nor the names of its
37  contributors may be used to endorse or promote products derived
38  from this software without specific prior written permission.
39  - The use of this software may or may not infringe the patent rights
40  of one or more patent holders. This license does not release you
41  from the requirement that you obtain separate licenses from these
42  patent holders to use this software.
43  - Use of the software either in source or binary form, must be run
44  on or directly connected to an Analog Devices Inc. component.
45 
46 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
47 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
48 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
49 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
50 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
52 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
53 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 */
57 
58 /*! @file
59  @ingroup LTC3589
60 */
61 
62 #include <Arduino.h>
63 #include <stdint.h>
64 #include "Linduino.h"
65 #include "UserInterface.h"
66 #include "LT_I2C.h"
67 #include "QuikEval_EEPROM.h"
68 #include "LTC3589.h"
69 
70 // Global variables
71 static uint8_t demo_board_connected; //!< Set to 1 if the board is connected
72 static uint8_t i2c_address; //!< I2C address set for all LTC3589 options
73 static char board_option; //!< Demo board option of the attached demo board
74 char demo_name_1[] = "DC1558"; //!< Demo Board Name stored in QuikEval EEPROM
75 char demo_name_2[] = "DC1808"; //!< Demo Board Name stored in QuikEval EEPROM
76 uint8_t reg_phase[7] = {1,1,1,1,1,1,1}; //!< Power-up sequence phases for every regulator output
77 float delay_ms = 0; //!< Delay between power-up phases
78 uint8_t reg_read_list[15] = {0x07,0x010,0x12,0x20,0x23,0x24,0x25,0x26,0x27,0x29,0x2A,0x32,0x33,0x02,0x13};
79 uint8_t reg_write_list[14] = {0x07,0x010,0x12,0x20,0x21,0x23,0x24,0x25,0x26,0x27,0x29,0x2A,0x32,0x33};
80 
81 void setup()
82 // Setup the program
83 {
84  quikeval_I2C_init(); //! Initializes Linduino I2C port.
85  quikeval_I2C_connect(); //! Connects I2C port to the QuikEval connector
86  Serial.begin(115200); //! Initialize the serial port to the PC
87  print_title();
88  demo_board_connected = discover_demo_boards(demo_name_1, demo_name_2); //! Checks if correct demo board is connected.
90  {
92  print_prompt();
93  }
94  else
95  {
97  demo_board_connected = true;
99  }
100 }
101 
102 //! Repeats Linduino loop
103 void loop()
104 {
105  int8_t ack=0;
106  uint8_t user_command;
107  if (demo_board_connected) //! Does nothing if the demo board is not connected
108  {
109  if (Serial.available()) //! Checks for user input
110  {
111  user_command = read_int(); //! Reads the user command
112  if (user_command != 'm')
113  Serial.println(user_command);
114  ack = 0;
115  switch (user_command) //! Prints the appropriate submenu
116  {
117  case 1:
118  ack |= menu_1_read_write_registers(); // Print single-ended voltage menu
119  break;
120  case 2:
121  ack |= menu_2_regulator_settings(); // Differential voltage menu
122  break;
123  case 3:
124  ack |= menu_3_sequencing(reg_phase); // Sequencing menu
125  break;
126  default:
127  Serial.println("Incorrect Option");
128  break;
129  }
130  if (ack != 0)
131  {
132  Serial.print(F("Error: No Acknowledge. \n"));
133  }
134  print_prompt();
135  }
136  }
137 }
138 
139 // Function Definitions
140 
141 //! Prints the Read/Write Registers menu and handles the user response.
142 //! @return State of the acknowledge bit after menu selection. 0=valid selection, 1=invalid selection.
144 {
145  int8_t ack=0;
146  uint8_t user_command;
147  uint8_t data;
148  uint8_t user_register;
149  uint8_t user_bit;
150  do
151  {
152  //! Displays the Read/Write Registers menu
153  Serial.print(F("\nRead/Write Registers\n\n"));
154  Serial.print(F(" 1-Read All Registers\n"));
155  Serial.print(F(" 2-Read Single Register\n"));
156  Serial.print(F(" 3-Write Single Register\n"));
157  Serial.print(F(" 4-Set Bit\n"));
158  Serial.print(F(" 5-Clear Bit\n"));
159  Serial.print(F(" 6-Clear IRQ\n"));
160  Serial.print(F(" m-Main Menu\n"));
161  Serial.print(F("\nEnter a command: "));
162 
163  user_command = read_int(); //! Reads the user command
164  if (user_command == 'm') // Print m if it is entered
165  {
166  Serial.print(F("m\n"));
167  }
168  else
169  Serial.println(user_command); // Print user command
170 
171  //! Reads or writes to a LTC3589 and prints result.
172  switch (user_command)
173  {
174  case 1:
175  // Read every register and print it's data.
177  break;
178  case 2:
179  // Read a single register and print it's data.
180  Serial.print(F("\nAddress (in hex with '0x' prefix) of register to read: "));
181  user_register = read_int();
182  Serial.print("0x");
183  Serial.println(user_register, HEX);
184  if (!valid_register(user_register, reg_read_list, sizeof(reg_read_list)))
185  {
186  Serial.println(F(" Invalid input."));
187  break;
188  }
189  ack |= LTC3589_register_read(i2c_address, user_register, &data);
190  Serial.print("Register data: 0x");
191  Serial.println(data, HEX);
192  break;
193  case 3:
194  // Write a byte to a chosen register.
195  Serial.print(F("\nAddress (in hex with '0x' prefix) of register to write: "));
196  user_register = read_int();
197  Serial.print("0x");
198  Serial.println(user_register, HEX);
199  if (user_register == 0x21)
200  {
201  Serial.println(F(" Clear IRQ command sent."));
202  ack |= LTC3589_register_write(i2c_address, user_register, 0x01);
203  break;
204  }
205  else if (!valid_register(user_register, reg_write_list, sizeof(reg_write_list)))
206  {
207  Serial.println(F(" Invalid input."));
208  break;
209  }
210  Serial.print(F("Data (in hex with '0x' prefix) to write: "));
211  data = read_int();
212  Serial.println(data, HEX);
213  ack |= LTC3589_register_write(i2c_address, user_register, data);
214  Serial.print("0x");
215  Serial.print(data, HEX);
216  Serial.print(" written to register 0x");
217  Serial.println(user_register, HEX);
218  break;
219  case 4:
220  // Set a single bit within a chosen register.
221  Serial.print(F("\nAddress (in hex with '0x' prefix) of register: "));
222  user_register = read_int();
223  Serial.print("0x");
224  Serial.println(user_register, HEX);
225  if (!valid_register(user_register, reg_write_list, sizeof(reg_write_list)))
226  {
227  Serial.println(F(" Invalid input."));
228  break;
229  }
230  Serial.print(F("Bit position (0-7) to set: "));
231  data = read_int();
232  if (data < 0 || data > 7)
233  {
234  Serial.println(F(" Invalid input."));
235  break;
236  }
237  Serial.println(data, DEC);
238  ack |= LTC3589_bit_set(i2c_address, user_register, data);
239  Serial.print("Bit set. Register data is now 0x");
240  ack |= LTC3589_register_read(i2c_address, user_register, &data);
241  Serial.println(data, HEX);
242  break;
243  case 5:
244  // Clear a single bit within a chosen register.
245  Serial.print(F("\nAddress (in hex with '0x' prefix) of register: "));
246  user_register = read_int();
247  Serial.print("0x");
248  Serial.println(user_register, HEX);
249  if (!valid_register(user_register, reg_write_list, sizeof(reg_write_list)))
250  {
251  Serial.println(F(" Invalid input."));
252  break;
253  }
254  Serial.print(F("Bit position (0-7) to clear: "));
255  data = read_int();
256  if (data < 0 || data > 7)
257  {
258  Serial.println(F("Invalid input."));
259  break;
260  }
261  Serial.println(data, DEC);
262  ack |= LTC3589_bit_clear(i2c_address, user_register, data);
263  Serial.print("Bit cleared. Register data is now 0x");
264  ack |= LTC3589_register_read(i2c_address, user_register, &data);
265  Serial.println(data, HEX);
266  break;
267  case 6:
268  // Clear IRQ register
269  Serial.println(F("\n Clear IRQ command sent."));
271  break;
272  default:
273  if (user_command != 'm')
274  Serial.println("Invalid Selection");
275  break;
276  }
277  }
278  while ((user_command != 'm') && (ack != 1));
279  return(ack);
280 }
281 
282 //! Prints the Regulator Settings menu and handles the user response.
283 //! @return State of the acknowledge bit after menu selection. 0=valid selection, 1=invalid selection.
285 {
286  int8_t ack=0;
287  uint8_t user_command;
288  uint8_t data;
289  uint8_t user_register;
290  uint8_t user_int;
291  uint8_t user_buck;
292  uint8_t user_ldo;
293  int8_t user_char;
294  do
295  {
296  //! Displays the Regulator Settings menu
297  Serial.print(F("\nRegulator Settings\n\n"));
298  Serial.print(F(" 1-Enable/Disable Switchers\n"));
299  Serial.print(F(" 2-Enable/Disable LDOs\n"));
300  Serial.print(F(" 3-Set Buck Output Voltage\n"));
301  Serial.print(F(" 4-Set Buck Feedback Reference\n"));
302  Serial.print(F(" 5-Select Buck Reference\n"));
303  Serial.print(F(" 6-Set LDO2 Output Voltage\n"));
304  Serial.print(F(" 7-Set LDO2 Feedback Reference\n"));
305  Serial.print(F(" 8-Select LDO2 Reference\n"));
306  Serial.print(F(" 9-Set Buck Switching Mode\n"));
307  Serial.print(F(" 10-Set Buck-Boost Switching Mode\n"));
308  Serial.print(F(" 11-Set Start-Up Mode (300mV check)\n"));
309  Serial.print(F(" 12-Set PGOOD Slewing Mask Bits\n"));
310  Serial.print(F(" 13-Set LDO4 Voltage\n"));
311  Serial.print(F(" 14-Set Switch DV/DT Control\n"));
312  Serial.print(F(" 15-Set Regulator Slew Rate\n"));
313  Serial.print(F(" 16-Exit Software Control Mode\n"));
314  Serial.print(F(" m-Main Menu\n"));
315  Serial.print(F("\nEnter a command: "));
316 
317  user_command = read_int(); //! Reads the user command
318  if (user_command == 'm') // Print m if it is entered
319  Serial.print(F("m\n"));
320  else
321  Serial.println(user_command); // Print user command
322 
323  //! Reads or writes to a LTC3589 and prints result.
324  switch (user_command)
325  {
326  case 1:
327  //Enter software control mode
329  {
330  Serial.print(F("\n********** Note: LTC3589 is now in Sofware Control Mode **********\n"));
331  Serial.print(F("***************Select Option 16 to resume Pin Control ************\n"));
333  }
334  // Enable/Disable Bucks
335  Serial.print(F("\nSelect Regulator(1-3=Bucks, 4=Buck-boost, 5=All): "));
336  user_buck = read_int();
337  Serial.println(user_buck, DEC);
338  if (user_buck < 1 || user_buck > 5)
339  {
340  Serial.println(F(" Invalid input."));
341  break;
342  }
343  Serial.println(F("0=Disable, 1=Enable"));
344  Serial.print(F("Enter selection: "));
345  user_int = read_int();
346  Serial.println(user_int, DEC);
347  if (user_int > 1)
348  {
349  Serial.println(F(" Invalid input."));
350  break;
351  }
352  if (user_buck == 5)
353  {
358  }
359  else
360  ack |= LTC3589_bit_write(i2c_address, LTC3589_REG_OVEN, user_buck-1, user_int);
361  Serial.println(F("Done."));
362  break;
363  case 2:
364  //Enter software control mode
366  {
367  Serial.print(F("\n********** Note: LTC3589 is now in Sofware Control Mode **********\n"));
368  Serial.print(F("***************Select Option 16 to resume Pin Control ************\n"));
370  }
371  // Enable/Disable LDOs
372  Serial.print(F("\nSelect LDO(2-4, 5=all): "));
373  user_ldo = read_int();
374  Serial.println(user_ldo, DEC);
375  if (user_ldo < 2 || user_ldo > 5)
376  {
377  Serial.println(F(" Invalid input."));
378  break;
379  }
380  Serial.println(F("0=Disable, 1=Enable"));
381  Serial.print(F("Enter selection: "));
382  user_int = read_int();
383  Serial.println(user_int, DEC);
384  if (user_int > 1)
385  {
386  Serial.println(F(" Invalid input."));
387  break;
388  }
389  if (user_ldo == 5)
390  {
394  }
395  ack |= LTC3589_bit_write(i2c_address, LTC3589_REG_OVEN, user_ldo+2, user_int);
396  Serial.println(F("Done."));
397  break;
398  case 3:
399  // Set buck output voltage in mV
400  float user_output;
401  float new_output;
402  Serial.print(F("\nSelect Buck(1-3): "));
403  user_int = read_int();
404  Serial.println(user_int, DEC);
405  if (user_int < 1 || user_int > 3)
406  {
407  Serial.println(F("Invalid input."));
408  break;
409  }
410  if (user_int == 1)
411  user_register = LTC3589_REG_B1DTV1; //Converts selection to appropriate register address.
412  else if (user_int == 2)
413  user_register = LTC3589_REG_B2DTV1; //Converts selection to appropriate register address.
414  else if (user_int == 3)
415  user_register = LTC3589_REG_B3DTV1; //Converts selection to appropriate register address.
416  Serial.print(F("Select Reference (1=B"));
417  Serial.print(user_int, DEC);
418  Serial.print(F("DTV1, 2=B"));
419  Serial.print(user_int, DEC);
420  Serial.print(F("DTV2): "));
421  user_char = read_char();
422  Serial.write(user_char);
423  if (user_char < '1' || user_char > '2')
424  {
425  Serial.println(F("\nInvalid input."));
426  break;
427  }
428  else if (user_char == '2')
429  user_register += 1; //Converts selection of appropriate register address.
430  Serial.print(F("\nPotential output voltage range: "));
431  Serial.print(LTC3589_buck_vout_min(user_int), 0);
432  Serial.print(F("mV to "));
433  Serial.print(LTC3589_buck_vout_max(user_int), 0);
434  Serial.print(F("mV."));
435  Serial.print(F("\nNew output voltage in mV: "));
436  user_output = read_float();
437  Serial.println(user_output, 0);
438  if (user_output < LTC3589_buck_vout_min(user_int) | user_output > LTC3589_buck_vout_max(user_int))
439  {
440  Serial.println(F("\nInvalid input."));
441  break;
442  }
443  new_output = LTC3589_set_buck_output_voltage(i2c_address, user_register, user_output);
444  Serial.print(F("Output voltage set to "));
445  Serial.print(new_output, 0);
446  Serial.println(F("mV"));
447  Serial.print(F("New Feedback Reference Bits: 0x"));
448  ack |= LTC3589_register_read(i2c_address, user_register, &data);
449  Serial.println(data & 0x1F, HEX);
450  break;
451  case 4:
452  // Set buck feedback reference voltage in mV
453  float user_reference;
454  float new_reference;
455  Serial.print(F("\nSelect Buck(1-3): "));
456  user_int = read_int();
457  Serial.println(user_int, DEC);
458  if (user_int < 1 || user_int > 3)
459  {
460  Serial.println(F("Invalid input."));
461  break;
462  }
463  if (user_int == 1)
464  user_register = LTC3589_REG_B1DTV1; //Converts selection to appropriate register address.
465  else if (user_int == 2)
466  user_register = LTC3589_REG_B2DTV1; //Converts selection to appropriate register address.
467  else if (user_int == 3)
468  user_register = LTC3589_REG_B3DTV1; //Converts selection to appropriate register address.
469  Serial.print(F("Select Reference (1=B"));
470  Serial.print(user_int);
471  Serial.print(F("DTV1, 2=B"));
472  Serial.print(user_int);
473  Serial.print(F("DTV2): "));
474  user_char = read_char();
475  Serial.write(user_char);
476  if (user_char < '1' || user_char > '2')
477  {
478  Serial.println(F("\nInvalid input."));
479  break;
480  }
481  else if (user_char == '2')
482  user_register += 1; //Converts selection of appropriate register address.
483  Serial.print(F("\nNew feedback reference input in mV (362.5-750): "));
484  user_reference = read_float();
485  Serial.println(user_reference);
486  if (user_reference < 362.5 | user_reference > 750)
487  {
488  Serial.println(F("\nInvalid input."));
489  break;
490  }
491  new_reference = LTC3589_set_buck_fb_ref(i2c_address, user_register, user_reference);
492  Serial.print(F("Feedback reference input set to "));
493  Serial.print(new_reference, 0);
494  Serial.println(F("mV"));
495  Serial.print(F("New Feedback Reference Bits: 0x"));
496  ack |= LTC3589_register_read(i2c_address, user_register, &data);
497  Serial.println(data & 0x1F, HEX);
498  break;
499  case 5:
500  // Select buck reference (1 or 2)
501  Serial.print(F("\nSelect Buck(1-3, 4=all): "));
502  user_buck = read_int();
503  Serial.println(user_buck, DEC);
504  if (user_buck < 1 || user_buck > 4)
505  {
506  Serial.println(F(" Invalid input."));
507  break;
508  }
509  Serial.print(F("Select Reference 1 or 2): "));
510  user_char = read_char();
511  Serial.write(user_char);
512  if (user_char == '1' || user_char == '2')
513  {
514  if (user_buck == 4)
515  ack |= LTC3589_select_buck_reference(i2c_address, 0xFF, user_char);
516  else
517  ack |= LTC3589_select_buck_reference(i2c_address, user_buck, user_char);
518  Serial.println(F("\nDone."));
519  break;
520  }
521  Serial.println(F("\n Invalid input."));
522  break;
523  case 6:
524  // Set LDO2 output voltage in mV
525  user_register = LTC3589_REG_L2DTV1;
526  Serial.print(F("Select Reference (1=L2DTV1, 2=L2DTV2): "));
527  user_char = read_char();
528  Serial.write(user_char);
529  if (user_char < '1' || user_char > '2')
530  {
531  Serial.println(F("\nInvalid input."));
532  break;
533  }
534  else if (user_char == '2')
535  user_register += 1; //Converts selection of appropriate register address.
536  Serial.print(F("\nPotential output voltage range: "));
537  Serial.print(LTC3589_ldo2_vout_min(), 0);
538  Serial.print(F("mV to "));
539  Serial.print(LTC3589_ldo2_vout_max(), 0);
540  Serial.print(F("mV"));
541  Serial.print(F("\nNew output voltage in mV: "));
542  user_output = read_float();
543  Serial.println(user_output, 0);
544  if (user_output < LTC3589_ldo2_vout_min() | user_output > LTC3589_ldo2_vout_max())
545  {
546  Serial.println(F("\nInvalid input."));
547  break;
548  }
549  new_output = LTC3589_set_ldo2_output_voltage(i2c_address, user_register, user_output);
550  Serial.print(F("Output voltage set to "));
551  Serial.print(new_output, 0);
552  Serial.println(F("mV"));
553  Serial.print(F("New Feedback Reference Bits: 0x"));
554  ack |= LTC3589_register_read(i2c_address, user_register, &data);
555  Serial.println(data & 0x1F, HEX);
556  break;
557  case 7:
558  // Set LDO2 feedback reference voltage in mV
559  Serial.print(F("Select Reference (1=L2DTV1, 2=L2DTV2): "));
560  user_char = read_char();
561  Serial.write(user_char);
562  if (user_char < '1' || user_char > '2')
563  {
564  Serial.println(F("\nInvalid input."));
565  break;
566  }
567  else if (user_char == '2')
568  user_register += 1; //Converts selection of appropriate register address.
569  Serial.print(F("\nNew feedback reference input in mV (362.5-750): "));
570  user_reference = read_float();
571  Serial.println(user_reference);
572  if (user_reference < 362.5 | user_reference > 750)
573  {
574  Serial.println(F("\nInvalid input."));
575  break;
576  }
577  new_reference = LTC3589_set_ldo2_fb_ref(i2c_address, user_register, user_reference);
578  Serial.print(F("Feedback reference input set to "));
579  Serial.print(new_reference, 0);
580  Serial.println(F("mV"));
581  Serial.print(F("New Feedback Reference Bits: 0x"));
582  ack |= LTC3589_register_read(i2c_address, user_register, &data);
583  Serial.println(data & 0x1F, HEX);
584  break;
585  case 8:
586  // Select LDO2 reference (1 or 2)
587  Serial.print(F("Select Reference 1 or 2): "));
588  user_char = read_char();
589  Serial.write(user_char);
590  if (user_char == '1' || user_char == '2')
591  {
592  ack |= LTC3589_select_ldo2_reference(i2c_address, user_char);
593  Serial.println(F("\nDone."));
594  break;
595  }
596  Serial.println(F("\n Invalid input."));
597  break;
598  case 9:
599  // Set buck switching mode
600  Serial.print(F("\nSelect Buck(1-3, 4=all): "));
601  user_register = read_int();
602  Serial.println(user_register, DEC);
603  if (user_register < 1 || user_register > 4)
604  {
605  Serial.println(F(" Invalid input."));
606  break;
607  }
608  Serial.print(F("Select mode (0=Pulse Skipping, 1=Burst, 2=Forced Continuous): "));
609  user_int = read_int();
610  Serial.println(user_int, DEC);
611  if (user_int < 0 || user_int > 2)
612  {
613  Serial.println(F(" Invalid input."));
614  break;
615  }
616  if (user_register == 4)
617  ack |= LTC3589_set_buck_mode(i2c_address, 0xFF, user_int);
618  else
619  ack |= LTC3589_set_buck_mode(i2c_address, user_register, user_int);
620  Serial.println(F("Switching mode(s) set."));
621  break;
622  case 10:
623  // Set buck-boost switching mode
624  Serial.print(F("Select mode (0=Continuous, 1=Burst): "));
625  user_int = read_int();
626  Serial.println(user_int, DEC);
627  if (user_int < 0 || user_int > 1)
628  {
629  Serial.println(F(" Invalid input."));
630  break;
631  }
633  Serial.println(F("Switching mode(s) set."));
634  break;
635  case 11:
636  // Sets the startup mode for all bucks
637  Serial.println(F("0=Wait for output <300mV to enable, 1=Don't wait & disable discharge resistor")); //Standard and -1 Option
638  // Serial.println(F("0=Enable at any output voltage, 1=Wait for output <300mV to enable")); //-2 Option
639  Serial.print(F("\nSelect start-up mode: "));
640  Serial.print(F("Enter selection: "));
641  user_int = read_int();
642  Serial.println(user_int, DEC);
643  if (user_int < 0 || user_int > 1)
644  {
645  Serial.println(F(" Invalid input."));
646  break;
647  }
648  Serial.println(F("Start-up modes set."));
649  break;
650  case 12:
651  // Sets PGOOD mask bit.
652  Serial.println(F("0=PGOOD low when slewing, 1=PGOOD not forced low when slewing"));
653  Serial.print(F("Enter selection: "));
654  user_int = read_int();
655  Serial.println(user_int, DEC);
656  if (user_int < 0 || user_int > 1)
657  {
658  Serial.println(F(" Invalid input."));
659  break;
660  }
661  ack |= LTC3589_set_pgood_mask(i2c_address, user_int);
662  Serial.println(F("PGOOD Mask bits set."));
663  break;
664  case 13:
665  // Set LDO4 Output Voltage
666  //if (board_option == 'B')
667  //{
668  if (demo_board.option == 'A' || demo_board.option == 'B')
669  {
670  Serial.print(F("Select LDO4 Voltage (0=1.2V, 1=1.8V, 2=2.5V, 3=3.2V): "));
671  }
672  else
673  {
674  Serial.print(F("Select LDO4 Voltage (0=2.8V, 1=2.5V, 2=1.8V, 3=3.3V): "));
675  }
676  user_int = read_int();
677  Serial.println(user_int, DEC);
678  if (user_int > 3)
679  {
680  Serial.println(F(" Invalid input."));
681  break;
682  }
683  ack |= LTC3589_set_ldo4_voltage(i2c_address, user_int);
684  Serial.println(F("LDO4 Voltage Set."));
685  break;
686  //}
687  //Serial.println(" Invalid Selection");
688  //break;
689  case 14:
690  // Set switch DV/DT control
691  Serial.print(F("Select DV/DT Control (0=1ns, 1=2ns, 2=4ns, 3=8ns): "));
692  user_int = read_int();
693  Serial.println(user_int, DEC);
694  if (user_int > 3)
695  {
696  Serial.println(F(" Invalid input."));
697  break;
698  }
700  Serial.println(F("Switch DV/DT Set."));
701  break;
702  case 15:
703  // Set regulator slew rate
704  Serial.print(F("\nSelect Regulator(1-3=Bucks, 4=LDO2, 5=All): "));
705  user_buck = read_int();
706  Serial.println(user_buck, DEC);
707  if (user_buck < 1 || user_buck > 5)
708  {
709  Serial.println(F(" Invalid input."));
710  break;
711  }
712  Serial.print(F("Select Slew Rate (0=0.88mV/us, 1=1.75mV/us, 2=3.5mV/us, 3=7mV/us): "));
713  user_int = read_int();
714  Serial.println(user_int, DEC);
715  if (user_int > 3)
716  {
717  Serial.println(F(" Invalid input."));
718  break;
719  }
720  if (user_buck == 5)
721  {
722  ack |= LTC3589_set_regulator_slew(i2c_address, 0xFF, user_int);
723  }
724  else
725  ack |= LTC3589_set_regulator_slew(i2c_address, 3<<((user_buck-1)*2), user_int);
726  Serial.println(F("Done."));
727  break;
728  case 16:
729  // Exit software control mode
731  Serial.println(F("\nDone."));
732  break;
733  default:
734  if (user_command != 'm')
735  Serial.println(" Invalid Selection");
736  break;
737  }
738  }
739  while ((user_command != 'm') && (ack != 1));
740  return (ack);
741 }
742 
743 //! Prints the Powerup Sequencing menu and handles the user response.
744 //! @return State of the acknowledge bit after menu selection. 0=valid selection, 1=invalid selection.
745 int8_t menu_3_sequencing(uint8_t *reg_phase)
746 {
747  int8_t ack=0;
748  uint8_t user_command;
749  uint8_t data;
750  uint8_t user_sequence;
751  uint8_t user_int;
752  uint8_t reg_map[6];
753  uint8_t reg_oven;
754  uint8_t reg_bit_position[7] = {0,1,2,3,4,5,6};
755  int count;
756 
757  //Enter software control mode
759  {
760  Serial.print(F("\n********** Note: LTC3589 is now in Sofware Control Mode **********\n"));
761  Serial.print(F("************** Select Option 5 to resume Pin Control *************\n"));
763  }
764  do
765  {
766  //! Displays the Startup Sequencing menu
767 
768  Serial.print(F("\nPowerup Sequencing\n\n"));
769  Serial.print(F(" 1-Set Power-up Sequence\n"));
770  Serial.print(F(" 2-Print Power-up Sequence\n"));
771  Serial.print(F(" 3-Power-up Regulators\n"));
772  Serial.print(F(" 4-Power-down Regulators\n"));
773  Serial.print(F(" 5-Exit Software Control Mode\n"));
774  Serial.print(F(" m-Main Menu\n"));
775  Serial.print(F("\nEnter a command: "));
776 
777  user_command = read_int(); //! Reads the user command
778  if (user_command == 'm') // Print m if it is entered
779  Serial.print(F("m\n"));
780  else
781  Serial.println(user_command); // Print user command
782 
783  switch (user_command)
784  {
785  case 1:
786  Serial.println(F("\nRegulators will power-up in 4 phases"));
787  Serial.println(F("Select a phase for each"));
788  Serial.println(F("1=First phase, 2=Second phase, 3=Third phase, 4=Fourth phase, 0=Don't enable"));
789  Serial.print(F("Buck1: "));
790  user_int = read_int();
791  Serial.println(user_int, DEC);
792  if (user_int < 5)
793  reg_phase[0] = user_int;
794  Serial.print(F("Buck2: "));
795  user_int = read_int();
796  Serial.println(user_int, DEC);
797  if (user_int < 5)
798  reg_phase[1] = user_int;
799  Serial.print(F("Buck3: "));
800  user_int = read_int();
801  Serial.println(user_int, DEC);
802  if (user_int < 5)
803  reg_phase[2] = user_int;
804  Serial.print(F("BB: "));
805  user_int = read_int();
806  Serial.println(user_int, DEC);
807  if (user_int < 5)
808  reg_phase[3] = user_int;
809  Serial.print(F("LDO2: "));
810  user_int = read_int();
811  Serial.println(user_int, DEC);
812  if (user_int < 5)
813  reg_phase[4] = user_int;
814  Serial.print(F("LDO3: "));
815  user_int = read_int();
816  Serial.println(user_int, DEC);
817  if (user_int < 5)
818  reg_phase[5] = user_int;
819  Serial.print(F("LDO4: "));
820  user_int = read_int();
821  Serial.println(user_int, DEC);
822  if (user_int < 5)
823  reg_phase[6] = user_int;
824  Serial.print(F("Enter delay between phases in milliseconds: "));
825  delay_ms = read_float();
826  if (delay_ms >= 0 && delay_ms <= 10000)
827  Serial.println(delay_ms, 1);
828  else
829  Serial.println(F("Values less than 0 or greater than 10s not allowed."));
830  break;
831  case 2:
832  Serial.print(F("\nBuck1: "));
833  Serial.println(reg_phase[0]);
834  Serial.print(F("Buck2: "));
835  Serial.println(reg_phase[1]);
836  Serial.print(F("Buck3: "));
837  Serial.println(reg_phase[2]);
838  Serial.print(F("BB: "));
839  Serial.println(reg_phase[3]);
840  Serial.print(F("LDO2: "));
841  Serial.println(reg_phase[4]);
842  Serial.print(F("LDO3: "));
843  Serial.println(reg_phase[5]);
844  Serial.print(F("LDO4: "));
845  Serial.println(reg_phase[6]);
846  Serial.print(F("Delay: "));
847  Serial.print(delay_ms, 1);
848  Serial.println(F("ms"));
849  break;
850  case 3:
852  //Start Phase 1 Regulators
853  for (count=0; count<7; count++)
854  {
855  if (reg_phase[count] == 1)
856  {
857  reg_oven |= 0x01<<reg_bit_position[count];
859  }
860  }
861  delay(delay_ms);
862 
863  //Start Phase 2 Regulators
864  for (count=0; count<7; count++)
865  {
866  if (reg_phase[count] == 2)
867  {
868  reg_oven |= 0x01<<reg_bit_position[count];
870  }
871  }
872  delay(delay_ms);
873 
874  //Start Phase 3 Regulators
875  for (count=0; count<7; count++)
876  {
877  if (reg_phase[count] == 3)
878  {
879  reg_oven |= 0x01<<reg_bit_position[count];
881  }
882  }
883  delay(delay_ms);
884 
885  //Start Phase 4 Regulators
886  for (count=0; count<7; count++)
887  {
888  if (reg_phase[count] == 4)
889  {
890  reg_oven |= 0x01<<reg_bit_position[count];
892  }
893  }
894  break;
895  case 4:
896  // Power-down by clearing all enable bits
898  break;
899  case 5:
900  // Exit software control mode
902  user_command = 'm';
903  break;
904  default:
905  if (user_command != 'm')
906  Serial.println(" Invalid Selection");
907  break;
908  }
909  }
910  while ((user_command != 'm') && (ack != 1));
911  return (ack);
912 }
913 
914 //! Prints the title block when program first starts.
916 {
917  Serial.print(F("\n******************************************************************\n"));
918  Serial.print(F("* DC1558A Demonstration Program *\n"));
919  Serial.print(F("* *\n"));
920  Serial.print(F("* This program demonstrates how to send and receive data from *\n"));
921  Serial.print(F("* the LTC3589 8-Output Regulator with Sequencing and I2C. *\n"));
922  Serial.print(F("* *\n"));
923  Serial.print(F("* Setup: *\n"));
924  Serial.print(F("* Set the baud rate to 115200 and select the newline terminator. *\n"));
925  Serial.print(F("* Set all switches in SW1 to their default position. *\n"));
926  Serial.print(F("* Tie PWR_ON high by connecting it to VIN. *\n"));
927  Serial.print(F("* Power VIN from an external power supply. *\n"));
928  Serial.print(F("* *\n"));
929  Serial.print(F("* Note: *\n"));
930  Serial.print(F("* For proper IRQ LED behavior, move resistor R39 to the *\n"));
931  Serial.print(F("* optional R38 position on the DC2026B. *\n"));
932  Serial.print(F("******************************************************************\n"));
933 }
934 
935 //! Prints main menu.
937 {
938  Serial.print(F("\n 1-Read/Write Registers\n"));
939  Serial.print(F(" 2-Regulator Settings\n"));
940  Serial.print(F(" 3-Sequencing\n"));
941  Serial.print(F("\nEnter a command:"));
942 }
943 
944 //! Prints a warning that no demo board was not detected.
946 {
947  Serial.println(F("\nWarning: Demo board not detected. Linduino will attempt to proceed."));
948 }
949 
950 //! Reads and prints the data in every register
951 //! @return State of the acknowledge bit. 0=acknowledge, 1=no acknowledge.
953 {
954  int8_t ack = 0;
955  uint8_t data;
956  uint8_t i;
957  for (i=0; i<sizeof(reg_read_list); i++)
958  {
959  ack |= LTC3589_register_read(i2c_address, reg_read_list[i], &data); //! Read register
960  Serial.print("Register 0x");
961  Serial.print(reg_read_list[i], HEX);
962  Serial.print(":\t0x");
963  Serial.println(data, HEX);
964  }
965  return ack;
966 }
967 
968 //! Checks to see if a register address is a valid address in this device.
969 //! @return State of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
970 boolean valid_register(uint8_t user_register, uint8_t register_array[], uint8_t array_length)
971 {
972  uint8_t i=0;
973  for (i=0; i<array_length; i++)
974  {
975  if (register_array[i] == user_register)
976  {
977  return true;
978  }
979  }
980  return false;
981 }
982 
983 //! Read the ID string from the EEPROM to identify the connected demo board.
984 //! @return Returns 1 if successful, 0 if not successful
986 {
987  int8_t connected;
988  connected = 1;
989  // read the ID from the serial EEPROM on the board
990  // reuse the buffer declared in UserInterface
991  if (read_quikeval_id_string(&ui_buffer[0]) == 0) connected = 0;
992  // make sure it is the correct demo board
993  if (strcmp(demo_board.name, demo_name_1) == 0) connected = 1;
994  else if (strcmp(demo_board.name, demo_name_2) == 0) connected = 1;
995  else connected = 0;
996  if (connected != 0)
997  {
998  Serial.print("Demo Board Name: ");
999  Serial.println(demo_board.name);
1000  Serial.print("Product Name: ");
1001  Serial.println(demo_board.product_name);
1002  if (demo_board.option)
1003  {
1004  Serial.print("Demo Board Option: ");
1005  Serial.println(demo_board.option);
1006  }
1007  }
1008  else
1009  {
1010  Serial.print("Demo board not found, \nfound ");
1011  Serial.print(demo_board.name);
1012  Serial.println(" instead. \nConnect the correct demo board, then press the reset button.");
1013  }
1014  return(connected);
1015 }
1016 
struct demo_board_type demo_board
Instantiate demo board structure.
#define LTC3589_BUCKBOOST_MODE
Definition: LTC3589.h:119
float LTC3589_set_ldo2_fb_ref(uint8_t i2c_address, uint8_t register_address, float fb_ref_voltage)
Writes the Feedback Reference Voltage of LDO2.
Definition: LTC3589.cpp:187
static float delay_ms
Delay between power-up phases.
char option
Demo Circuit option (A)
static int8_t discover_demo_boards(char *demo_name_1, char *demo_name_2)
Read the ID string from the EEPROM to identify the connected demo board.
int8_t LTC3589_bit_write(uint8_t i2c_address, uint8_t register_address, uint8_t bit_number, uint8_t bit_data)
Writes any bit inside the LTC3589 using the standard I2C repeated start format.
Definition: LTC3589.cpp:126
int8_t LTC3589_set_switch_dvdt_control(uint8_t i2c_address, uint8_t dvdt_control_bits)
Sets the switch DV/DT control for the buck regulators.
Definition: LTC3589.cpp:380
unsigned char user_command
static uint8_t i2c_address
I2C address set for all LTC3589 options.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
#define LTC3589_EN2
Definition: LTC3589.h:131
char name[15]
Demo Circuit number (DC1678)
float LTC3589_ldo2_vout_min()
Calculates the minimum output voltage of LDO2 mV based on the feedback resistors. ...
Definition: LTC3589.cpp:223
int8_t LTC3589_select_ldo2_reference(uint8_t i2c_address, int8_t ref_char)
Selects the reference for LDO2.
Definition: LTC3589.cpp:263
#define LTC3589_EN4
Definition: LTC3589.h:129
#define LTC3589_REG_B2DTV1
Definition: LTC3589.h:106
Header File for Linduino Libraries and Demo Code.
LTC3589: 8-Output Regulator with Sequencing and I2C.
static void loop()
Repeats Linduino loop.
static int8_t menu_2_regulator_settings()
Prints the Regulator Settings menu and handles the user response.
static int32_t connected
Definition: CN-0413.ino:69
float LTC3589_ldo2_vout_max()
Calculates the maximum output voltage of LDO2 in mV based on the feedback resistors.
Definition: LTC3589.cpp:217
boolean valid_register(uint8_t user_register, uint8_t register_array[], uint8_t array_length)
Checks to see if a register address is a valid address in this device.
#define LTC3589_EN_LDO4
Definition: LTC3589.h:126
#define LTC3589_I2C_ADDRESS
Definition: LTC3589.h:79
float LTC3589_set_buck_fb_ref(uint8_t i2c_address, uint8_t register_address, float fb_ref_voltage)
Writes the Feedback Reference Voltage of any buck.
Definition: LTC3589.cpp:202
static int8_t LTC3589_print_all_registers(uint8_t i2c_address)
Reads and prints the data in every register.
static int8_t menu_3_sequencing(uint8_t *reg_phase)
Prints the Powerup Sequencing menu and handles the user response.
static void print_title()
Prints the title block when program first starts.
#define LTC3589_EN3
Definition: LTC3589.h:130
char demo_name_1[]
Demo Board Name stored in QuikEval EEPROM.
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
float LTC3589_buck_vout_max(uint8_t buck_number)
Calculates the maximum output voltage of any buck in mV based on the feedback resistors.
Definition: LTC3589.cpp:229
int8_t LTC3589_register_write(uint8_t i2c_address, uint8_t register_address, uint8_t register_data)
Writes to an 8-bit register inside the LTC3589 using the standard I2C repeated start format...
Definition: LTC3589.cpp:92
#define LTC3589_EN1
Definition: LTC3589.h:132
QuikEval EEPROM Library.
char demo_name_2[]
Demo Board Name stored in QuikEval EEPROM.
float LTC3589_buck_vout_min(uint8_t buck_number)
Calculates the minimum output voltage of any buck in mV based on the feedback resistors.
Definition: LTC3589.cpp:246
static void print_prompt()
Prints main menu.
int8_t LTC3589_select_buck_reference(uint8_t i2c_address, uint8_t buck_number, int8_t ref_char)
Selects the reference for the specified buck regulator(s).
Definition: LTC3589.cpp:275
int8_t LTC3589_set_regulator_slew(uint8_t i2c_address, uint8_t regulator_mask, uint8_t slew_rate)
Sets the dynamnic reference slew rate for the regulator(s).
Definition: LTC3589.cpp:359
uint8_t LTC3589_bit_is_set(uint8_t i2c_address, uint8_t register_address, uint8_t bit_number)
Reads the value of any bit in any register or the LTC3589.
Definition: LTC3589.cpp:140
#define LTC3589_SOFTWARE_CNTRL
Definition: LTC3589.h:125
static uint8_t reg_phase[7]
Power-up sequence phases for every regulator output.
#define LTC3589_EN_LDO3
Definition: LTC3589.h:127
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
#define LTC3589_EN_LDO2
Definition: LTC3589.h:128
#define LTC3589_REG_B1DTV1
Definition: LTC3589.h:103
static void setup()
float LTC3589_set_buck_output_voltage(uint8_t i2c_address, uint8_t register_address, float output_voltage)
Sets the output voltage of any buck.
Definition: LTC3589.cpp:164
int32_t read_int()
int8_t LTC3589_register_read(uint8_t i2c_address, uint8_t register_address, uint8_t *register_data)
Reads an 8-bit register from the LTC3589 using the standard repeated start format.
Definition: LTC3589.cpp:84
#define LTC3589_REG_L2DTV1
Definition: LTC3589.h:110
float read_float()
#define LTC3589_REG_CLIRQ
Definition: LTC3589.h:102
char product_name[15]
LTC Product (LTC2654-L16)
int8_t LTC3589_set_buck_mode(uint8_t i2c_address, uint8_t buck_number, uint8_t mode)
Sets the switching mode for the specified buck regulator(s).
Definition: LTC3589.cpp:294
int8_t LTC3589_bit_clear(uint8_t i2c_address, uint8_t register_address, uint8_t bit_number)
Clears any bit inside the LTC3589 using the standard I2C repeated start format.
Definition: LTC3589.cpp:113
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
static char board_option
Demo board option of the attached demo board.
#define LTC3589_REG_OVEN
Definition: LTC3589.h:99
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
float LTC3589_set_ldo2_output_voltage(uint8_t i2c_address, uint8_t register_address, float output_voltage)
Sets the output voltage of LDO2.
Definition: LTC3589.cpp:151
static int i
Definition: DC2430A.ino:184
int8_t LTC3589_set_pgood_mask(uint8_t i2c_address, uint8_t pgood_bit)
Sets the PGOOD mask bit for all bucks and LDO2.
Definition: LTC3589.cpp:336
static uint8_t reg_write_list[14]
static int8_t menu_1_read_write_registers()
Prints the Read/Write Registers menu and handles the user response.
int8_t LTC3589_set_ldo4_voltage(uint8_t i2c_address, uint8_t ldo4_output_voltage_code)
Sets LDO4 output voltage on the LTC3589.
Definition: LTC3589.cpp:347
int8_t read_char()
static void print_warning_prompt()
Prints a warning that no demo board was not detected.
#define LTC3589_REG_SCR1
Definition: LTC3589.h:98
uint8_t read_quikeval_id_string(char *buffer)
Read the id string from the EEPROM, then parse the product name, demo board name, and demo board opti...
char ui_buffer[UI_BUFFER_SIZE]
#define LTC3589_REG_B3DTV1
Definition: LTC3589.h:108
int8_t LTC3589_bit_set(uint8_t i2c_address, uint8_t register_address, uint8_t bit_number)
Sets any bit inside the LTC3589 using the standard I2C repeated start format.
Definition: LTC3589.cpp:100
static uint8_t reg_read_list[15]