DC2343A  FW 1.0.2 / GUI 1.0.10
LTC3335 Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter
 All Data Structures Namespaces Files Functions Variables Enumerations Macros Pages
LTC3335.h
Go to the documentation of this file.
1 /*
2  Linear Technology DC2343A Demonstration Board.
3  Driver File for LTC3335 Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter.
4  All datasheet references in this file refer to Linear Technology document 3335p.pdf
5 
6  @verbatim
7  Demonstration Circuit DC2343A is a complete system level solution for a Nanopower Buck-Boost
8  DC/DC with Integrated Coulomb Counter. The DC2343A contains a PIC16F1459 embedded processor
9  for communication to the PC over USB and the LTC3335 via its I2C port. The GUI is capable of
10  reading and writing all the control registers on the LTC3335 as well as displaying and
11  resetting all its alarm registers. The firmware and software for the embedded system and the GUI
12  are available at the LTC3335 solutions page located at http://www.linear.com/product/LTC3335#demoboards.
13  The DC2343A uses two Analog-to-Digital Convert-er channels to sample the Battery and Output voltages.
14  The voltage samples improve the functionality of the GUI, and allow optimal software correction to the
15  measured coulombs. By adding the software correction the first order known errors are compensated
16  for over the operating range and the resultant coulomb count is accurate to within 3%.
17 
18  The DC2343A contains an LTC3335 which is a high efficiency, low quiescent current (680nA) buck-boost
19  DC/DC converter with an integrated precision cou-lomb counter which monitors accumulated battery discharge
20  in long life battery powered applications. The buck-boost can operate down to 1.8V on its input and
21  provides eight pin selectable output voltages with up to 50mA of output current. The coulomb counter
22  stores the accumulated battery discharge in an internal register accessible via an I2C interface. The
23  LTC3335 features a programmable discharge alarm threshold. When the threshold is reached, an interrupt
24  is generated at the IRQ pin. To accommodate a wide range of battery types and sizes, the peak input
25  current can be selected from as low as 5mA to as high as 250mA and the full-scale coulomb counter has a
26  range from 1.1mAh (with 5mA IPEAK) to 1793Ah (with 250mA IPEAK).
27  @endverbatim
28 
29  http://www.linear.com/product/LTC3335
30 
31  REVISION HISTORY
32  $Revision: 687 $
33  $Date: 2014-09-05 14:51:22 -0400 (Fri, 05 Sep 2014) $
34 
35  Copyright (c) 2014, Linear Technology Corp.(LTC)
36  All rights reserved.
37 
38  Redistribution and use in source and binary forms, with or without
39  modification, are permitted provided that the following conditions are met:
40 
41  1. Redistributions of source code must retain the above copyright notice, this
42  list of conditions and the following disclaimer.
43  2. Redistributions in binary form must reproduce the above copyright notice,
44  this list of conditions and the following disclaimer in the documentation
45  and/or other materials provided with the distribution.
46 
47  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
48  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
49  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
51  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
56  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 
58  The views and conclusions contained in the software and documentation are those
59  of the authors and should not be interpreted as representing official policies,
60  either expressed or implied, of Linear Technology Corp.
61 
62 */
63 
64 /*! @file
65  Firmware Driver Header File for LTC3335 Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter.
66 
67  This driver was designed to provide the following services to application code:
68  1. Perform the basic register commands necessary to access the features of the LTC3335.
69  2. Minimize I2C communication in an effort to minimize power consumption.
70  3. Use the Counter Test feature of the LTC3335 to provide a real time battery current measurement.
71 
72  Software correction was not included in this driver due to Program Memory limitations in the PIC16F1459.
73  See the LTC3335.vb file in with the DC2343A GUI source code for an example of software correction of the
74  LTC3335 coulomb count.
75 */
76 
77 #ifndef __LTC3335_H__
78 #define __LTC3335_H__
79 
80 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
81 // Includes
82 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
83 #include "Typedefs.h"
84 #include "DC2343A.h"
85 
86 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
87 // Definitions
88 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
89 
90 //! @name LTC3335 Driver Properties
91 //! @{
92 #define LTC3335_BAUD_RATE 400 //!< in kHz, Max Clock Operating Frequency (fSCL from datasheet page 5)
93 #define LTC3335_PRESCALER_MAX 15 //!< the maximum prescaler that be selected for the LTC3335.
94 //! @}
95 
96 //! @name LTC3335 I/O
97 //! @{
98 #define LTC3335_DVCC DVCC_OUT_PIN //!< DVCC pin must be high for LTC3335 to communicate.
99 #define LTC3335_PGOOD PGOOD_IN_PIN //!< PGOOD is high when LTC3335 is in regulation.
100 #define LTC3335_IRQ IRQ_IN_PIN //!< IRQ is low when alarm condition is present or has not been cleared. IRQ also toggle during Counter Test.
101 //! @}
102 
103 //! @name Voltage Settings
104 //! @{
105 //! Options available for setting output voltage via I2C.
106 typedef enum {
107  LTC3335_OUTPUT_VOLTAGE_1_8V,
108  LTC3335_OUTPUT_VOLTAGE_2_5V,
109  LTC3335_OUTPUT_VOLTAGE_2_8V,
110  LTC3335_OUTPUT_VOLTAGE_3_0V,
111  LTC3335_OUTPUT_VOLTAGE_3_3V,
112  LTC3335_OUTPUT_VOLTAGE_3_6V,
113  LTC3335_OUTPUT_VOLTAGE_4_5V,
114  LTC3335_OUTPUT_VOLTAGE_5_0V,
115  LTC3335_NUM_OUTPUT_VOLTAGES
116 } LTC3335_OUTPUT_VOLTAGE_TYPE;
117 //! @}
118 
119 //! @name IPeak Settings
120 //! @{
121 //! Options available for IPeak setting.
122 //! NOTE! This can not be set via I2C. It can only be set with resistors on pins 13-15
123 //! of the LTC3335, along with the an appropriately sized inductor. In order to
124 //! translate accumulator values to coulombs, and Counter Test results to amps,
125 //! this setting must be known.
126 typedef enum {
127  LTC3335_IPEAK_CONFIGURATION_IPEAK_5MA,
128  LTC3335_IPEAK_CONFIGURATION_IPEAK_10MA,
129  LTC3335_IPEAK_CONFIGURATION_IPEAK_15MA,
130  LTC3335_IPEAK_CONFIGURATION_IPEAK_25MA,
131  LTC3335_IPEAK_CONFIGURATION_IPEAK_50MA,
132  LTC3335_IPEAK_CONFIGURATION_IPEAK_100MA,
133  LTC3335_IPEAK_CONFIGURATION_IPEAK_150MA,
134  LTC3335_IPEAK_CONFIGURATION_IPEAK_250MA,
135  LTC3335_NUM_IPEAK_CONFIGURATIONS
136 } LTC3335_IPEAK_CONFIGURATION_TYPE;
137 //! @}
138 
139 //! The alarm conditions which cause the LTC3335 to activate the /INT pin.
140 typedef struct {
141  unsigned ac_on_time_overflow :1; //!< AC(ON) time operating fault (tAC > tFS) due to improperly chosen inductor value timing out the AC(ON) measurement.
142  unsigned coulomb_counter_overflow :1; //!< Coulomb counter operating fault due to an improperly chosen prescalar causing the ripple counter to overflow.
143  unsigned alarm_trip :1; //!< Accumulator value has met or exceeded the alarm threshold value.
144  unsigned unused :5;
146 
147 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
148 // Global Data
149 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
150 
151 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
152 // Global Prototypes
153 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
154 
155 //! Initializes the LTC3335 driver.
156 //! @return void
157 void LTC3335_Init(void);
158 
159 //! Enables/Disables software control of the LTC3335 output voltage.
160 //! If software control is enabled, the voltage is set to the specified setting.
161 //! @return TRUE if the LTC3335 communication was successful.
162 bool_t LTC3335_Set_Voltage(bool_t enabled, //!< TRUE to enable software control of output voltage, FALSE to disable software control (output voltage set by pins 3-5).
163  LTC3335_OUTPUT_VOLTAGE_TYPE voltage //!< The output voltage setting if software control is enabled.
164  );
165 
166 //! Get whether the software control of the LTC3335 output voltage is enabled/disabled.
167 //! Gets the voltage setting, if software control is enabled.
168 //! @return TRUE if the LTC3335 communication was successful.
169 bool_t LTC3335_Get_Voltage(bool_t* enabled, //!< TRUE if software control of output voltage is enabled, FALSE is software control is disabled (output voltage set by pins 3-5).
170  LTC3335_OUTPUT_VOLTAGE_TYPE* voltage //!< The output voltage setting if software control is enabled.
171  );
172 
173 //! Sets the specified prescaler setting for the LTC3335.
174 //! @return TRUE if the LTC3335 communication was successful.
175 bool_t LTC3335_Set_Prescaler(uint8_t prescaler //!< The prescaler setting to set for the LTC3335.
176  );
177 
178 //! Gets the prescaler setting from the LTC3335.
179 //! @return TRUE if the LTC3335 communication was successful.
180 bool_t LTC3335_Get_Prescaler(uint8_t* prescaler //!< The prescaler setting being used by the LTC3335.
181  );
182 
183 //! Sets the specified alarm threshold for the LTC3335.
184 //! @return TRUE if the LTC3335 communication was successful.
185 bool_t LTC3335_Set_Alarm_Threshold(uint8_t threshold //!< The alarm threshold to set for the LTC3335.
186  );
187 
188 //! Gets the alarm threshold from the LTC3335.
189 //! @return TRUE if the LTC3335 communication was successful.
190 bool_t LTC3335_Get_Alarm_Threshold(uint8_t* threshold //!< The alarm threshold setting being used by the LTC3335.
191  );
192 
193 //! Sets the specified accumulator value for the LTC3335.
194 //! @return TRUE if the LTC3335 communication was successful.
195 bool_t LTC3335_Set_Accumulator(uint8_t accumulator //!< The accumulator value to set for the LTC3335.
196  );
197 
198 //! Gets the specified accumulator value from the LTC3335.
199 //! @return TRUE if the LTC3335 communication was successful.
200 bool_t LTC3335_Get_Accumulator(uint8_t* accumulator //!< The current LTC3335 accumulator value.
201  );
202 
203 //! Gets the alarms active from the LTC3335.
204 //! @return TRUE if the LTC3335 communication was successful.
205 bool_t LTC3335_Get_Alarms(LTC3335_ALARM_TYPE* alarms //!< Bitmap containing the LTC3335 active alarms.
206  );
207 
208 //! Sends the command to clear the INT condition.
209 //! NOTE! Additional registers will also need to be rewritten in order for the INT condition
210 //! to not be immediately reset.
211 //! @return TRUE if the LTC3335 communication was successful.
212 bool_t LTC3335_Clear_Int(void);
213 
214 //! Enables/Disables the LTC3335 Counter Test feature.
215 //! @return TRUE if the LTC3335 communication was successful.
216 bool_t LTC3335_Set_Counter_Test(bool_t enabled //!< TRUE to enable Counter Test feature, FALSE to disable Counter Test feature.
217  );
218 
219 //! Gets whether the LTC3335 Counter Test feature is Enabled/Disabled.
220 bool_t LTC3335_Get_Counter_Test(bool_t* enabled //!< TRUE if Counter Test is enabled, FALSE is Counter Test is disabled.
221  );
222 
223 
224 //! Gets whether the LTC3335 Counter Test feature is Enabled/Disabled.
225 //! Gets the number of edges and the amount of time since the Counter Test
226 //! was last reset, which allows edges/sec to be calculated. The edges/sec is proportional to
227 //! battery current.
228 //! @return TRUE if the LTC3335 communication was successful.
229 bool_t LTC3335_Get_Counter_Test_Results(bool_t* enabled, //!< TRUE if Counter Test is enabled, FALSE is Counter Test is disabled.
230  uint32_t* edge_count, //!< The number of edges counted since the Counter Test was last reset.
231  uint32_t* time //!< The number of timer ticks since the Counter Test was last reset.
232  );
233 
234 //! Resets the number of edges and the amount of time stored for the Counter Test feature.
235 //! @return TRUE if the LTC3335 communication was successful.
236 bool_t LTC3335_Reset_Counter_Test(void);
237 
238 //! Task that must be run periodically, for the edges and time to be stored for the
239 //! LTC3335 Counter Test feature.
240 //! @return TRUE if the LTC3335 communication was successful.
241 void LTC3335_Counter_Test_Task(void);
242 
243 #endif
bool_t LTC3335_Set_Alarm_Threshold(uint8_t threshold)
Sets the specified alarm threshold for the LTC3335.
Definition: LTC3335.c:261
bool_t LTC3335_Set_Prescaler(uint8_t prescaler)
Sets the specified prescaler setting for the LTC3335.
Definition: LTC3335.c:219
void LTC3335_Counter_Test_Task(void)
Task that must be run periodically, for the edges and time to be stored for the LTC3335 Counter Test ...
Definition: LTC3335.c:454
bool_t LTC3335_Set_Accumulator(uint8_t accumulator)
Sets the specified accumulator value for the LTC3335.
Definition: LTC3335.c:287
bool_t LTC3335_Set_Counter_Test(bool_t enabled)
Enables/Disables the LTC3335 Counter Test feature.
Definition: LTC3335.c:375
bool_t LTC3335_Get_Accumulator(uint8_t *accumulator)
Gets the specified accumulator value from the LTC3335.
Definition: LTC3335.c:297
bool_t LTC3335_Reset_Counter_Test(void)
Resets the number of edges and the amount of time stored for the Counter Test feature.
Definition: LTC3335.c:442
bool_t LTC3335_Get_Prescaler(uint8_t *prescaler)
Gets the prescaler setting from the LTC3335.
Definition: LTC3335.c:244
bool_t LTC3335_Get_Alarms(LTC3335_ALARM_TYPE *alarms)
Gets the alarms active from the LTC3335.
Definition: LTC3335.c:313
bool_t LTC3335_Get_Voltage(bool_t *enabled, LTC3335_OUTPUT_VOLTAGE_TYPE *voltage)
Get whether the software control of the LTC3335 output voltage is enabled/disabled.
Definition: LTC3335.c:195
bool_t LTC3335_Get_Counter_Test_Results(bool_t *enabled, uint32_t *edge_count, uint32_t *time)
Gets whether the LTC3335 Counter Test feature is Enabled/Disabled.
Definition: LTC3335.c:429
bool_t LTC3335_Clear_Int(void)
Sends the command to clear the INT condition.
Definition: LTC3335.c:356
bool_t LTC3335_Set_Voltage(bool_t enabled, LTC3335_OUTPUT_VOLTAGE_TYPE voltage)
Enables/Disables software control of the LTC3335 output voltage.
Definition: LTC3335.c:175
bool_t LTC3335_Get_Alarm_Threshold(uint8_t *threshold)
Gets the alarm threshold from the LTC3335.
Definition: LTC3335.c:271
bool_t LTC3335_Get_Counter_Test(bool_t *enabled)
Gets whether the LTC3335 Counter Test feature is Enabled/Disabled.
Definition: LTC3335.c:408
void LTC3335_Init(void)
Initializes the LTC3335 driver.
Definition: LTC3335.c:154
The alarm conditions which cause the LTC3335 to activate the /INT pin.
Definition: LTC3335.h:140