Wide-Vin Battery-Charger Using SMBus

Wide-Vin Battery-Charger Using SMBus
Application Report
SLAA476A – February 2011 – Revised July 2011
Wide-Vin Battery Charger Using SMBus Communication
Interface Between MSP430™ MCUs and bq Fuel Gauges
Abhishek A. Joshi ........................................................................................ MSP430 Systems Solutions
Keith J. Keller ................................................................................................ Analog Field Applications
ABSTRACT
This application report describes a smart-battery charger reference design with a wide-input-voltage
range. The reference design implements the System Management Bus (SMBus) protocol for
communication between the MSP430 microcontroller and a SMBus-compatible battery fuel gauge. The
MSP430 device interrogates the fuel gauge for voltage, current, and other parameters via SMBus. It then
adjusts the pulse width modulation (PWM) duty-cycle output signals being fed to the dc/dc converter to
deliver the power requested by the battery.
Hardware schematic diagrams, software source code, and other information can be downloaded from
http://www.ti.com/lit/zip/slaa476.
NOTE: While the software has been designed for use with the MSP430F550x family of
microcontrollers, it can be ported over to other families of MSP430 with minor modifications.
The charger scheme demonstrated in this application note is specific to a Li-ion/Li-polymer
battery chemistry. However, the overall battery charging concept described here should be
applicable to any type of battery chemistry.
Contents
Introduction .................................................................................................................. 2
Hardware ..................................................................................................................... 4
2.1
Overall System Description ....................................................................................... 4
2.2
MSP430F5510 Daughterboard Subsystem ..................................................................... 5
2.3
Power Stage Board Subsystem .................................................................................. 7
3
Software .................................................................................................................... 10
3.1
SMBus Protocol Description .................................................................................... 10
3.2
Software File Structure .......................................................................................... 11
3.3
API Calls Description ............................................................................................. 13
3.4
Sample Application Description ................................................................................. 24
4
References ................................................................................................................. 26
Appendix A
SBS Supported Commands Using SMBus Protocol ......................................................... 27
Appendix B
Detailed Sample Application Flow Chart ...................................................................... 28
Appendix C Battery Status Register Description ............................................................................ 30
Appendix D MSP430F5510 Daughterboard Schematic .................................................................... 31
Appendix E
Setting Up the MSP430F5510 Daughterboard Hardware ................................................... 33
Appendix F
Battery Calibration Circuit Setup ............................................................................... 35
Appendix G Battery Voltage and PWM Conversions ....................................................................... 35
Appendix H Battery Current and PWM Conversions ....................................................................... 36
Appendix I
Power Stage Board Schematic (Generation 1: 40-V Input) ................................................. 37
Appendix J
Bode Plot Measurement for Feedback Loop Stability Analysis ............................................ 39
Appendix K
Power Stage Board Schematic (Generation 2: 60-V Input) ................................................. 40
Appendix L
Setting Up the Power Stage Board Hardware ................................................................ 42
1
2
List of Figures
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
1
Introduction
www.ti.com
1
High-Level System Block Diagram of Smart-Battery Charger ........................................................ 3
2
System Block Diagram ..................................................................................................... 4
3
MSP430F5510 Daughterboard Subsystem Block Diagram ........................................................... 5
4
Power Stage Subsystem Block Diagram
18
................................................................................
Overvoltage and Reverse Polarity Protection Circuitry ................................................................
Typical Charging Profile ....................................................................................................
Constant Current/Voltage Feedback to Charge the Battery ...........................................................
Sample Application Flow Chart (Brief) ..................................................................................
Sample Application Flow Chart (Detailed) .............................................................................
Safety Checks..............................................................................................................
MSP430F5510 Daughterboard Schematic (Page 1)..................................................................
MSP430F5510 Daughterboard Schematic (Page 2)..................................................................
Battery Calibration Circuit Setup ........................................................................................
40-V Input Power Stage Board Schematic (Page 1)..................................................................
40-V Input Power Stage Board Schematic (Page 2)..................................................................
Bode Plot Measurement Graph - Gain (left) and Phase (right)......................................................
60-V Input Power Stage Board Schematic (Page 1)..................................................................
60-V Input Power Stage Board Schematic (Page 2)..................................................................
1
MSP430F5510 Port/Pin to Functionality Mapping ...................................................................... 6
2
SBS Commands ........................................................................................................... 27
3
Battery Voltage and PWM Conversions ................................................................................ 35
4
Battery Current and PWM Conversions ................................................................................ 36
5
6
7
8
9
10
11
12
13
14
15
16
17
7
8
9
9
25
28
29
31
32
35
37
38
39
40
41
List of Tables
1
Introduction
Smart-battery fuel gauges made by Texas Instruments (TI), such as the bq20Zxx, bq78PLxxx, bq2060A,
and bq3060 (or any other SMBus-compatible fuel gauge) provide safety and protection functions, as well
as detailed information on a battery’s present state and desired charging parameters. They can be
programmed for different battery chemistries such as Li-ion or NiMH and have built-in algorithms for
charging and discharging cycles to optimize battery performance. Additionally, battery fuel gauges monitor
many different parameters throughout the life of the battery to provide accurate state-of-charge information
[1]. All of this information can be easily read by a microcontroller such as the MSP430 devices.
The MSP430 family of microcontrollers is a series of 16-bit RISC instruction-set processors with an
ultra-low-power architecture and a variety of peripheral options. The peripheral options include ADC
(slope, sigma-delta, SAR), DAC, op-amps, comparators, LCD drivers, USART, and other integrated
analog/digital components, all on one silicon die. The MSP430F550x family of microcontrollers features a
rich peripheral set such as 10-bit SAR ADC10_A module, multiple timers (capture/compare registers with
PWM output capability), USB interface for firmware upgrades, USCI module, watchdog timers, and more
[2].
Communication between the microcontroller and the fuel gauge is done via the System Management Bus
(SMBus) communication protocol. The SMBus standard was developed by a group of companies
collaborating together under the umbrella of Smart Battery System (SBS) Implementers Forum to
implement one standard communication protocol for smart batteries and other digital devices [3]. SMBus
is based on the popular Inter-IC Communication (I2C) standard and adds enhancements along with
restrictions to the original I2C protocol [4]. SMBus is the primary method of communication with the
smart-battery fuel gauges. On the MSP430F550x family, the SMBus protocol can be implemented by
utilizing the I2C USCI module.
MSP430, Code Composer Studio, eZ430-Chronos are trademarks of Texas Instruments.
IAR Embedded Workbench is a trademark of IAR Systems.
All other trademarks are the property of their respective owners.
2
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Introduction
www.ti.com
A high-level system block diagram of this reference design smart-battery charger is shown in Figure 1.
PWM
MSP430
Controller
Board
SMBus
DC/DC
Converter
Power
Stage
Board
POWER
VCC
SDA
SCL
Smart
Battery
System
bq
Fuel Gage
Chipset
Figure 1. High-Level System Block Diagram of Smart-Battery Charger
This battery charger reference design employs the MSP430F5510 as the microcontroller configured in the
SMBus/I2C Master mode to interrogate the fuel gauge for desired charging voltage, current, and other
parameters [5]. The MSP430F5510 then outputs two PWM signals per battery to control both charging
voltage and current provided by the dc/dc converter power stage.
Based on the parametric values received via SMBus, the MSP430F5510 either adjusts the PWM duty
cycle or shuts off the PWM outputs, if the battery is fully charged or reads back a terminate charging
condition. A smart-battery containing the bq20z90 fuel gauge with open access to the SMBus terminals
was used to test this reference design. If an open smart battery is not available, the bq20z90 fuel gauge
evaluation module kit can be used to emulate a smart battery [6]. The reference design assumes that the
bq20z90 is configured with charging broadcasts disabled (BCAST = 0 in Operation Cfg B register).
However, if the battery fuel gauge does place charging broadcast requests on the SMBus lines, the
MSP430F5510 ignores them. Therefore, the fuel gauge responds back with parameters only when the
MSP430F5510 addresses commands to it.
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
3
Hardware
www.ti.com
2
Hardware
2.1
Overall System Description
The wide-Vin battery charger system block diagram is shown in Figure 2.
Power Stage Board
OCP
18-40 Vin
(100 V surge)
Current Shunt
Monitor (INA193)
Surge Circuitry
Clamp to 37 V
Voltage
Current
Discrete LDO
Vbias (10 V)
Battery 1
Wide Vin
DC/DC
Controller
TPS40057
5.5 - 35.0 V
0.20 - 10 A
PWM
180 Out-of-Phase
synchronization
SMBus bq Fuel
Gauge Chipset
+ Protection
Current Shunt
Monitor (INA193)
OCP
5.5 - 35.0 V
0.20 - 10 A
Battery 2
PWM
Voltage
VCC
Current
Wide Vin
DC/DC
Controller
TPS40057
3.3 V LDO
TPS71533
Charging
Terminals
±
VCC
Batt 2 Current
Batt 2 Voltage
MSP430F5510
Microcontroller
Batt 1 Current
SDA
1-to-2
demux
TS3A24157
SCL
Batt 1 Voltage
SDA
SCL
SMBus
Communication
ADC Inputs
Charging
Terminals
SCL
10kW
SDA
±
SMBus bq Fuel
Gauge Chipset
+ Protection
Battery 1
Battery 2
10W
10W
...
Status Indicator LEDs (8)
(3.3 V/3 mA)
Calibrate 1
Calibrate 2
Microcontroller
Daughterboard
Figure 2. System Block Diagram
This particular system can monitor and charge two smart batteries at once. The system primarily
comprises two subsystems (boards):
• MSP430F5510 daughterboard subsystem
• Power-stage board with the dc/dc converter subsystem
The MSP430F5510 board contains all of the digital logic and components of the system, while the
power-stage board has all of the analog and power components. The MSP430F5510 board docks to the
power-stage board via a 10-pin header. The following sections describe each of the subsystems.
4
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Hardware
www.ti.com
2.2
MSP430F5510 Daughterboard Subsystem
2.2.1
Subsystem Description
Figure 3 shows the block diagram of the MSP430F5510 daughterboard subsystem.
Vbias (10 V)
[Power Stage Board]
TPS71533
LDO (3.3 V)
Batt 1 Voltage
VCC
Batt 1 Current
PWM
Debugger or
Programmer
Level Shifted
Analog Signals
JTAG FET
eZ430 Emulator
Batt 1 Analog Voltage
Batt 1 Analog Current
Batt 2 Analog Voltage
Batt 2 Analog Current
Status
Indicator
LEDs (8)
Batt 2 Current
EEM
GPIO
DC/DC Power
Converters (x2)
[Power Stage Board]
VCC
MSP430F5510
ADC
Batt 2 Voltage
10KW
USCI
(I2C)
GPIO
SDA
SCL
1-to-2
demux
TS3A24157
SDA
SCL
Fuel Gauge
[Inside Batt 1]
SDA
SCL
Fuel Gauge
[Inside Batt 2]
Power Resistor
Discharge Circuit
Batt 1
Terminals (±)
Batt 2
Terminals (±)
Figure 3. MSP430F5510 Daughterboard Subsystem Block Diagram
The daughtercard subsystem has the following features:
• The I2C USCI module within the MSP430F5510 is utilized to implement the SMBus protocol for
communication with the battery fuel gauges.
• A 1-to-2 demultiplexer (demux), TS3A24157, is used to separate the SMBus clock (SCL) and data
(SDA) lines for the two batteries [15]. During the manufacturing process, all of the fuel gauges for a
particular battery series are programmed to the same SMBus slave address. The advantage of using a
demux is that one microcontroller with one I2C/SMBus USCI module can be used to communicate with
multiple fuel gauges within multiple smart-batteries.
• The MSP430F5510 outputs voltage and current PWM signals at a frequency of 20 kHz to control the
power delivered by the dc/dc converters on the power stage subsystem.
• The on-chip 10-bit ADC is used to convert voltage and current signals from the batteries. The voltage
from the battery is divided down from the wide-input range to the ADC range by means of a
resistor-divider circuit on the MSP430F5510 daughterboard. The current is fed into a shunt resistor on
the power-stage board, and the resulting voltage is fed into the ADC channels directly.
• Eight status LED indicators; seven are software programmable, and one indicates power-on status.
• Two sets of power resistors for discharging two batteries independently. The discharge circuitry can be
turned on or off by the microcontroller to calibrate battery pack voltages. Appendix F has details on
setting up these circuits.
• Fan control output to power a heat venting circulation fan on or off.
• Two options to program the software on the MSP430F5510 daughterboard:
– 14-pin JTAG interface (four-wire) for connecting the Flash Emulation Tool (FET)
– 6-pin Spy-Bi-Wire interface (two-wire) for connecting the eZ430 Emulator
• Three options to power the MSP430F5510 daughterboard:
– JTAG interface (voltage level programmable in the integrated development environment (IDE)
options)
– eZ430 emulator interface (supply voltage fixed at 3.6 V)
– The charger board supply power (~10 V), which is routed via the TPS71533 LDO to supply 3.3 V to
the MSP430F5510 [16]. For a wider input supply range up to 50 V, the TPS79801 LDO can also be
used to supply 3.3 V [17].
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
5
Hardware
2.2.2
www.ti.com
MSP430F5510 Port Pins Functionality Description
Table 1 shows the port/pin name to functionality mapping for the MSP430F5510 microcontroller. The
signal name column represents the net names referred to in the daughterboard schematic. The right-most
column describes the purpose and functionality of the signal net.
Table 1. MSP430F5510 Port/Pin to Functionality Mapping
Port/Pin Name
Signal Name
Description
P1.0
LED0
Status Indicator LED – D1 (Green)
P1.1
LED1
Status Indicator LED – D3 (Green)
P1.2
V_PWM1
Voltage PWM output for Battery 1
P1.3
I_PWM1
Current PWM output for Battery 1
P1.4
V_PWM2
Voltage PWM output for Battery 2
P1.5
I_PWM2
Current PWM output for Battery 2
P1.6
LED2
Status Indicator LED – D4 (Orange)
P1.7
LED3
Status Indicator LED – D5 (Orange)
P2.0
FAN-CTL
Fan Control
P2.1
LED4
Status Indicator LED – D6 (Red)
P2.2
LED5
Status Indicator LED – D7 (Red)
P2.3
LED6
Status Indicator LED – D8 (Green)
P4.0
SMB-CH-SELECT
SMBus Battery Channel Selector
P4.1
430-SMBUS-DATA
SMBus Data Line (SDA)
P4.2
430-SMBUS-CLK
SMBus Clock Line (SCL)
P4.3
LED-ON
Power On Indicator LED – D2 (Green)
P4.6
CAL-CH1
Turns on calibration circuit for Battery 1
P4.7
CAL-CH2
Turns on calibration circuit for Battery 2
P6.0
ISNS1
Current Sampling ADC Channel for Battery 1
P6.1
ISNS2
Current Sampling ADC Channel for Battery 2
P6.2
VBATT1
Voltage Sampling ADC Channel for Battery 1
P6.3
VBATT2
Voltage Sampling ADC Channel for Battery 2
For more details on signal net names and connections, see Appendix D for the MSP430F5510
daughterboard schematic.
6
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Hardware
www.ti.com
2.3
2.3.1
Power Stage Board Subsystem
Subsystem Description
Figure 4 shows a block diagram of the power-stage board.
Reverse Polarity Protection
and 100 V Over-Voltage
Protection
8-40 V DC Input
Discrete LDO
Providing 10 Vbias
Voltage Control
VPWM1 Input
TPS40xxx
DC/DC
Power Stage
Circuitry
INA193
Current Monitor
Batt 1
Terminals (±)
VBATT1
ISNS1
Current Control
IPWM1 Input
Vbias
VPWM1
IPWM1
VPWM2
IPWM2
Voltage Control
VPWM2 Input
ISNS1
ISNS2
TPS40xxx
DC/DC
Power Stage
Circuitry
INA193
Current Monitor
Batt 2
Terminals (±)
VBATT2
ISNS2
Current Control
VPWM2 Input
VBATT1
VBATT2
Figure 4. Power Stage Subsystem Block Diagram
The power-stage board has the following features:
• Dual wide-input-voltage buck dc/dc converters for charging two batteries independently. Two
power-stage boards with different input voltage ranges were built for this reference design.
– 40-V input range employing the TPS40057 dc/dc converter (see Appendix I) [18]
– 60-V input range employing the TPS40170 dc/dc converter (see Appendix K) [19]
• Output voltage and current controlled by 20-kHz PWM signals provided by MSP430F5510
daughterboard.
• Precision current measurements provided by INA193 current shunt monitor [20]
• Battery charging feedback network to first provide constant current regulation followed by constant
voltage regulation.
• 100-V overvoltage and reverse-polarity protection
• 180° out-of-phase operation
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
7
Hardware
2.3.2
www.ti.com
Input Protection Features
This reference design includes protection circuitry for both overvoltage (up to 100 V) as well as reverse
voltage (positive and negative leads swapped). This portion of the circuitry is shown in Figure 5.
Q7
SUM90P10-19L
J9
10 V to 100 V
GND
1
2
TP15
Q9
SUM90P10-19L
Q8
SUM90P10-19L
+
R39
100K
Q10
SUM90P10-19L
TP16
D2
6.2 V
TP14
R37
10.0K
D3
6.2 V
R40 10.0K
C25
0
R36
0
1
2
VIN_2
VIN
J8
10 V to 37 V
GND
C22
4.7uF
Q11
MMBT3906
C23
47 uF
R35
D4
36 V
C24 0.1 uF
R38
100K
22 pF
Q12
PBSS8110T
TP17
R41
10.0K
SD1
R42
3.01K
SD2
R43
3.01K
TP18
TP19
R44
10.0K
Q13
MMBT3904LT1
Q100
MMBT3904LT1
J10
1
2
TP20
Figure 5. Overvoltage and Reverse Polarity Protection Circuitry
•
•
8
Reverse voltage protection – FETs Q7 and Q9 along with D2 provide reverse voltage protection in
case the input voltage is connected backwards. This does not allow a negative voltage to be applied to
the system.
Input overvoltage protection – FETs Q8 and Q10 provide an overvoltage protection circuit. The zener
diode D4 sets the voltage that the circuit starts to clamp. Once the zener voltage is exceeded, the
gate-to-source voltage of the FETs starts to drop. This causes the FETs to operate in the linear region.
At the same time, the battery charging circuits are turned off with signals SD1 and SD2.
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Hardware
www.ti.com
2.3.3
Constant-Voltage and Constant-Current Feedback
Properly charging a battery requires constant current control followed by constant voltage control as the
current tapers. Two separate feedback loops are required to address this requirement (see Figure 6 and
Figure 7).
Precharge
Current
Regulation
Phase
SBS Charging Current
(0x14) from Battery
Fastcharge Voltage
Regulation Phase
Fastcharge Current
Regulation Phase
Termination
Regulation Voltage
Regulation Current
SBS Charging Voltage
(0x15) from Battery
Charge
Current
Charge
Voltage
IPRECH and ITERM
The battery determines if
precharge current is
required and provides that
information as SBS
Charging Current (0x14)
Fastcharge
Precharge
Figure 6. Typical Charging Profile
BP5
R21
R26
R100
10.0K
10.0K
10.0K
TP10
R18
R22
51.1
0
D1
TP11
R23
10.0K
VBIAS
BAT54A
TP12
TP9
R16
C15 1uF
R15
10.0K
U3:D
4OUT +
12
14 13
TLV274PW
R25
0
C17
10K
TLV274PW 6
7
+ 5
2OUT
TP8
U3:B
R28
R17 10.0K
R19 10.0K R20 100.0k
R24
1M
ISNS1
I_PWM1
C16
1uF
C113
10uF
1.00K
0.047uF VBIAS
U3:A
TLV274PW
2
4
1 +
3
11
C20
1uF
R29 1.00K
C19
0.01uF
R30 15.0K
R31 10.0K
R33
1M
R34
1.00K
R32 10.0K
VBATT1
V_PWM1
C21
0.1uF
Figure 7. Constant Current/Voltage Feedback to Charge the Battery
•
•
The feedback to the TPS40057 is controlled by two loops, one voltage loop and one current loop. Only
one of the loops is in control of the power supply at a given time.
The current and voltage levels are set by the PWM outputs of the MSP430F5510. Duty cycles between
0% and 100% are filtered to produce an analog voltage reference.
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
9
Software
www.ti.com
•
The current into the battery is measured using shunt resistors (R5, R7, and R8) along with an INA193
(U2) (see schematic in Appendix I). This circuit provides a voltage that is proportional to the output
current. The equation is shown below:
Gain = 20V/V × R105 / R13 = 13.32
For IOUT = 10 A; ISNS = 10 A × 0.025 Ω × 12.1 = 3.33 V
For IOUT = 10 A; ISNS = 10 A × 0.025 Ω × 12.1 = 3.33 V
The current sense voltage is then compared to the current reference voltage using U3:B. If the
reference voltage is higher, the output of the amplifier is high. If the reference voltage is lower, the
output of the amplifier is low.
The output voltage is measured using a resistor divider (R30 and R34). This voltage is then compared
to the output voltage reference. If the reference voltage is higher, the output of the amplifier is high. If
the reference voltage is lower, the output of the amplifier is low.
VOUT_MAX = VSNS / R34 × (R34 + R30)
Diode D1 combines the outputs of the two amplifiers with a logical OR. The voltage that is lowest is fed
into an inverting amplifier that makes the error signal polarity correct for the TPS40057 controller.
The basic operation is that the controller tries to put out a set current, and if the load can accept this
current, the controller regulates to that current level. If the load cannot accept the full amount of
current, the voltage begins to rise and eventually reaches VOUT_MAX. When this happens, the voltage
loop takes over and regulates the output voltage.
•
•
•
•
3
Software
3.1
SMBus Protocol Description
As was mentioned in the introduction section, the MSP430 microcontroller communicates with the fuel
gauge within the smart battery by means of the SMBus communication protocol. SMBus is based on the
I2C protocol and is a two-wire serial interface: serial clock (SCL) and serial data (SDA). The two lines are
connected via pullup resistors to VCC, and the idle state of the bus is VCC or logic HIGH. Multiple devices
are connected to the SMBus lines in a wired-AND configuration with the premise that the active devices
can drive the lines LOW while other devices relinquish bus control by staying in high-impedance state.
Devices that use the SMBus protocol to communicate can be classified as a master or slave device. A
master or slave device can transmit or receive data. The device that initiates the communication packet by
placing a START condition on the bus and providing clock pulses on the SCL line is considered as the
master. Once the master places the START condition on the bus, it is followed by a 7-bit slave address
and a Read/Write bit to indicate if it is receiving or transmitting data, respectively. As each slave device
can have a unique 7-bit address, a maximum of 128 devices can be connected to the bus. If there is a
slave device with the address requested by the master, it acknowledges (ACK) by pulling the SDA line
LOW. If not, the SDA line remains HIGH (during the ninth clock pulse on SCL) and is interpreted as a
no-acknowledge (NACK). A successful ACK is followed by a stream of 8-bit packets that can be data, SBS
commands, or PEC byte. The receiving device must ACK every time it receives an 8-bit packet.
Communication ends when the master device places a STOP condition on the bus.
Unlike the I2C protocol, the SMBus protocol has a minimum clock frequency restriction of 10 kHz and a
maximum clock frequency restriction of 100 kHz. The SMBus protocol also places a timeout restriction
that prevents slave devices from extending the clock (SCL) line LOW for a certain interval before the
master issues a STOP condition. A slave can hold the SCL line LOW for 25 ms before timeout occurs,
after which the slave should be able to receive a new START condition within 35 ms. Another SMBus
feature to improve communication robustness is Packet Error Checking (PEC). The PEC byte is generated
by using the Cyclic Redundancy Check (CRC-8) polynomial and is calculated on all bytes including device
addresses, Read/Write bits, SBS commands, etc. The PEC calculation, however, does not include the
START, repeated START, ACK, NACK, or STOP bits.
10
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Software
www.ti.com
The reference design implements the timeout feature on the MSP430F5510 and also has the API calls to
access the fuel gauge with or without PEC. The bq fuel gauges can also transmit or receive data with or
without PEC. When the MSP430F5510 is receiving data from the fuel gauge and if it clocks out eight extra
cycles, then the fuel gauge correspondingly outputs the PEC byte. When the MSP430F5510 is writing
data to the fuel gauge and if it passes the PEC byte, then the fuel gauge compares the value against its
own hardware-generated PEC value. If the values match, the fuel gauge issues an acknowledge (ACK); if
the values do not match, a no-acknowledge (NACK) is issued before the STOP condition.
For additional details on timing diagrams and specifications, see the System Management Bus (SMBus)
Specification [3].
3.2
Software File Structure
This section describes the organization of the software code file structure.
• main.c – Contains the main() function. The file also contains other functions such as:
Name
Brief Description
Battery_Charger_Controller()
Implements the demo reference design software flow chart.
Initialize_Battery_Definitions()
Initializes the hardware to charge two smart batteries simultaneously.
Get_Battery_Charger_SMBus_Parameters()
Interrogates the battery fuel gauge for the desired charging voltage, desired
charging current, and other parameters.
Safety_Checks_Primary_SMBus()
Compares the parameters received via SMBus against a set of limits to check
whether the nominal operating values have been exceeded or not.
Safety_Checks_Secondary_ADC()
Compares the parameters received via ADC conversions against a set of limits
to check whether the nominal operating values have been exceeded or not.
Set_LED_Indicator_Status()
Set the hardware LEDs to indicate status such as charging, fully charged or
error condition.
Interrupt Service Routines (ISRs)
ISRs for Timer, I2C/SMBus USCI, ADC10, and other peripherals
•
init.c – Functions for initializing modules/peripherals on the controller board:
Name
Brief Description
UCS_Init()
Initializes the clock system within the MSP430F5510.
Timer_Init()
Initializes the timer.
PWM_Init()
Initializes the PWM outputs.
ADC_Init()
Initializes the ADC for voltage/current conversions.
•
•
init.h – Header file that contains device and controller board specific constants. The constants defined
in this file should be used during structure declaration.
led.c – These functions control the operation of the status LEDs on the controller board.
Name
Brief Description
LED_Init()
Initializes the LEDs on the board.
LED_Control()
Set the LEDs to a steady on/off state or set the LEDs to blink with an adjustable period.
•
•
•
led.h – Header file that defines the constants used in functions within the LED.c source file.
pwm.c – Functions that control the PWM duty cycle output to the charger board.
pwm.h – Constants associated with the functions defined in pwm.c source file.
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
11
Software
•
www.ti.com
smbus.c – Source code that uses the I2C USCI module for SMBus communication.
Name
Brief Description
SMBus_Initialize()
Initializes the SMBus communication lines with the option to configure the MSP430F5510 in
master or slave mode.
SMBus_Access()
Configures the MSP430F5510 in master mode and interrogates the battery fuel gauge with the
user-specified command.
SMBus_Access_PEC()
Configures the MSP430F5510 in master mode and interrogates the battery fuel gauge with the
user-specified command with packet-error-checking (PEC).
SMBus_Select()
Selects which battery channel to send the SMBus commands to.
crc8MakeBitwise()
Implements the CRC-8 algorithm to compute the PEC byte.
•
•
smbus.h – Header file with SMBus related constants and definitions.
misc.c – Source file with miscellaneous functions.
Name
Brief Description
Fan_Init()
Initializes the fan structure.
Fan_Control()
Turns the fan on or off.
VI_ADC_Read()
Reads the voltage or current via ADC.
Calibrate_Battery()
Turns on or off the calibration resistor circuitry.
Delay_Timer()
Generic delay function.
•
•
•
•
•
misc.h – Header file with constants/definitions used in misc.c source file.
device.h – Header file for target device declaration.
F5XX_6XX_Core_Lib – This folder contains code files for configuring the power management module
(PMM) within the MSP430F5510. These source code files are derived from an external set of
Hardware Abstraction Libraries (HAL) for the 5xx and 6xx series of devices [7].
– hal_pmm.c – Function library for setting the PMM VCore voltage level. To operate the DCO that
drives the SMCLK at a higher or lower frequency, the VCore level must be raised up or lowered
down by calling these functions.
– hal_pmm.h – Header file with function declarations and constants.
demo.c – Demo functions that exemplify API function call usage.
demo.h – Header file with function call prototypes declared in demo.c source file.
NOTE: The files demo.c and demo.h should be excluded from the project settings when
compiling/building the sample application software. These files are provided for example
purposes only.
12
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Software
www.ti.com
3.3
API Calls Description
This section describes the individual API function calls with details such as function call syntax,
parameters passed and returned, and example use-case declarations. The example values denoted in the
parameters section are aliases defined in the respective header files. It is recommended to use these
aliases when writing system software to maintain ease of use and documentation.
3.3.1
UCS_Init ( )
This function initializes the universal clock system (UCS) within the MSP430F5510 to:
• Select internally generated REFO (~32 kHz) as the FLL reference clock
• Select internally generated REFO (~32 kHz) as ACLK
• Program the DCO to approximately 20 MHz (for SMCLK and MCLK)
3.3.2
Function Definition
void UCS_Init(void) {…}
Inputs
Return
None
None
Example Function Call
UCS_Init();
Timer_Init ( )
This function initializes the Timer module to establish a TIMER_TICK timebase/timeout duration.
TIMER_TICK constant is defined in init.h header file. The timeout duration for the SMBus clock low
extension and the blinking period of the LEDs are based on this Timer.
3.3.3
Function Definition
void Timer_Init(void) {…}
Inputs
Return
None
None
Example Function Call
Timer_Init();
PWM_Init ( )
This function initializes the MSP430F5510 port pins to output a 20-kHz PWM with 10-bit resolution. The
PWM outputs are initialized to low.
Function Definition
void PWM_Init(void) {…}
Inputs
Return
None
None
Example Function Call
PWM_Init();
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
13
Software
3.3.4
www.ti.com
ADC_Init ( )
This function initializes the on-chip integrated 10-bit ADC to do single-channel single-conversions.
Function Definition
void ADC_Init(void) {…}
Inputs
Return
None
None
Example Function Call
ADC_Init();
The function utilizes a structure to map the MSP430F5510 port pins to the ADC channels
and to also keep the assignments separated when multiple batteries are connected to the
system.
ADCDescription_t
Structure Definition Name
Parameters
Name
Type
Description
Example Value
BatteryNum
unsigned char
Value that represents battery channel number
BATT_1, BATT_2
ChannelType
unsigned char
Channel type (voltage or current)
CHANNEL_VOLTAGE,
CHANNEL_CURRENT
PortSelAddr
unsigned int
Address of the Port Select Register listed in the
register description table of the data sheet.
P6SEL_ADDR
PortBit
unsigned int
Bit of the port (value can range from 0 to 15)
BIT0, BIT1,…, BITF
Value that represents ADC input channel number
ADC10INCH_1,
ADC10INCH_2
InputChanNum
unsigned char
Example Structure Declaration
For battery 1 voltage on P6.2 (A2) channel:
#define ADC_DEFAULT_STATE {BATT_1, CHANNEL_VOLTAGE, P6SEL_ADDR, BIT2, ADC10INCH_2}
// Constant defined in header file
ADCDescription_t ADC = ADC_DEFAULT_STATE;
14
// Declared in source code
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Software
www.ti.com
3.3.5
Fan_Init ( )
This function configures the port connected to the fan to be in the output direction.
Function Definition
void PWM_Init(void) {…}void Fan_Init(void) {…}
Inputs
Return
None
None
Example Function Call
Fan_Init();
The function utilizes a structure to map the MSP430F5510 port pins to the fan control
channel.
FanDescription_t
Structure Definition Name
Parameters
Name
Type
Description
Example Value
P2OUT_ADDR
PortOutAddr
unsigned int
Address of the Port Out Register of the fan
control output. This register controls the on/off
state of the output.
PortDirAddr
unsigned int
Address of the Port Direction Register. This
register controls the input/output capability of the
port.
P2DIR_ADDR
PortBit
unsigned int
Bit of the port (value can range from 0 to 15)
BIT0, BIT1,…, BITF
Example Structure Declaration
For the fan control pin on Port P2.0:
// Constant defined in header file
#define FAN_DEFAULT_STATE { P2OUT_ADDR, P2DIR_ADDR, BIT0 }
// Declaration in source code file
FanDescription_t Fan = FAN_DEFAULT_STATE;
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
15
Software
3.3.6
www.ti.com
LED_Init ( )
This function configures all of the port bits connected to the LEDs to output direction and initializes all
LEDs to off state.
Function Definition
void LED_Init(void) {…}
Inputs
Return
None
None
Example Function Call
LED_Init();
The function utilizes a structure to map the MSP430F5510 port pins to the LEDs. To allow
multiple LEDs to blink at different intervals, virtual timer counters are used to keep track of
the timeout duration. This structure declaration keeps track of the virtual count for each
LED as well as the timeout duration.
LEDDescription_t
Structure Definition Name
Parameters
Name
Type
Description
Example Value
PortOutAddr
unsigned int
Address of the Port Out Register of the LED
control output. This register controls the on/off
state of the output.
P2OUT_ADDR
PortDirAddr
unsigned int
Address of the Port Direction Register. This
register controls the input/output capability of the
port.
P2DIR_ADDR
PortBit
unsigned int
Bit of the Port (value can range from 0 to 15)
BIT0, BIT1,…, BITF
unsigned char
Virtual Timer keeps tracks of timer ticks before
timeout expires and LED is toggled.
0
unsigned char
This parameter contains the timeout period that
the virtual timer starts counting down from. This
parameter is used to adjust the LED blink rate.
0
LEDVirtualTimer
LEDBlinkPeriod
(1)
(1)
(1)
The parameters LEDVirtualTimer and LEDBlinkPeriod are initialized to zero and are used by the LED_Control function to set the
blink period/timer value based on the user’s input for that particular LED. Initializing these parameters to non-zero values can
cause the LEDs to function improperly.
Example Structure Declaration
For a case with two LEDs on P2.0 and P2.1:
// Constant defined in header file
#define LED_DEFAULT_STATE { { P2OUT_ADDR, P2DIR_ADDR, BIT0, 0, 0 }, \
{ P2OUT_ADDR, P2DIR_ADDR, BIT1, 0, 0 } }
// Declaration in source code file
LEDDescription_t LEDs[2] = LED_DEFAULT_STATE;
16
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Software
www.ti.com
3.3.7
SMBus_Initialize ( )
This function initializes the I2C USCI module within the MSP430F5510 for SMBus communication.
• Uses SMCLK as synchronous clock source to operate SMBus clock (SCL) at approximately 100 kHz.
• Can configure the MSP430F5510 to act in master or slave mode. The master mode is useful when
only the MSP430F5510 interrogates the fuel gauge; the slave mode is useful when the battery is setup
in Broadcast Mode.
• Master/slave addresses for the MSP430F5510 are defined in the header file smbus.h
void SMBus_Initialize (unsigned char SMBus_Mode) {…}
Function Definition
Inputs
Name
SMBus_Mode
Type
Description
unsigned char
Return
Example Value
Option to configure the MSP430F5510 in SMBus SMBUS_MASTER_MODE,
master or SMBus slave mode.
SMBUS_SLAVE_MODE
None
• To configure the MSP430F5510 in master mode:
Example Function Call
SMBus_Initialize(SMBUS_MASTER_MODE);
The function utilizes a structure to map the MSP430F5510 port pins to the 1-to-2 demux (to
prevent SMBus signal collision) and the SMBus clock and data Lines.
SMBusDescription_t
Structure Definition Name
Parameters
Name
Type
Description
Example Value
PortChanDir
unsigned int
Address of the Port Direction Register connected
to the 1-to-2 demux. This register controls the
P4DIR_ADDR
input/output capability of the port.
PortChanOut
unsigned int
Address of the Port Output Register connected
to the 1-to-2 demux. This register controls the
on/off state of the output.
P4OUT_ADDR
PortChanBit
unsigned int
Bit of the port connected to the 1-to-2 demux
(value can range from 0 to 15)
BIT0, BIT1,…, BITF
PortComAddr
unsigned int
Address of the Port Select Register connected to
P6SEL_ADDR
the I2C USCI lines for SMBus.
PortComBitData
unsigned int
Bit of the port connected to the data line of the
I2C USCI module (value can range from 0 to 15)
BIT0,…,BITF
PortComBitClock
unsigned int
Bit of the port connected to the clock line of the
I2C USCI module (value can range from 0 to 15)
BIT0,…,BITF
Example Structure Declaration
For the SMBus channel select pin on P4.0 and SMBus communication lines SDA on P4.1
and SCL on P4.2:
// Constant defined in header file
#define SMBUS_DEFAULT_STATE {P4DIR_ADDR, P4OUT_ADDR, BIT8, P4SEL_ADDR, BIT9, BITA}
// Declaration in source code file
SMBusDescription_t SMBus = SMBUS_DEFAULT_STATE;
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
17
Software
3.3.8
www.ti.com
LED_Control ( )
This function provides control of the board’s LEDs. Call the LED_Init() function to initialize the LED ports to
output direction before making calls to this function.
void LED_Control (unsigned char led_num, unsigned
char led_mode, unsigned char led_blink_rate) {…}
Function Definition
Inputs
Name
Type
Description
Example Value
led_num
unsigned char
Number designated to the LED on the hardware
LED_NUM_0, LED_NUM_1,…,
LED_NUM_7
led_mode
unsigned char
Configures the LED to stay in either a steady
on/off state or blink periodically.
LED_MODE_ON,
LED_MODE_OFF,
LED_MODE_BLINK
led_blink_rate
unsigned char
Configures the blink rate of the LED, if it has
been programmed to blink. Value has no effect
when LED is set to a steady on or off state.
LED_BLINK_RATE_SLOW,
LED_BLINK_RATE_MEDIUM,
LED_BLINK_RATE_FAST
Return
None
• To make LED0 blink at a medium rate:
LED_Control(LED_NUM_0, LED_MODE_BLINK,
LED_BLINK_RATE_MEDIUM);
Example Function Call
• To turn LED1 off:
LED_Control(LED_NUM_1, LED_MODE_OFF,
LED_BLINK_RATE_SLOW);
3.3.9
Fan_Control ( )
This function provides control of the fan. Call the Fan_Init() function to initialize the fan port before
configuring the fan to an on or off state.
void char Fan_Control (unsigned char on_off) {…}
Function Definition
Inputs
Name
Type
on_off
unsigned char
Return
Example Function Call
18
Description
Example Value
Sets the state of the venting fan output to either
ON or OFF.
FAN_ON, FAN_OFF
None
• To turn the fan on: Fan_Control(FAN_ON);
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Software
www.ti.com
3.3.10
VI_ADC_Read ( )
This function provides access to battery voltage/current via ADC conversion. Call the ADC_Init() function
to initialize the ADC for single-channel single-conversions before using this function to receive digital
conversion values.
unsigned int VI_ADC_Read (unsigned char batt_num,
unsigned char channel_vi) {…}
Function Definition
Inputs
Name
Type
Description
Example Value
batt_num
unsigned char
Value that represents battery channel number
BATT_1, BATT_2
channel_vi
unsigned char
Channel type (voltage or current)
CHANNEL_VOLTAGE,
CHANNEL_CURRENT
Return
Name
Type
conversion_value
unsigned int
Description
Digital conversion value from the ADC (can be voltage or current
based on the specified input parameters)
• To read the ADC conversion voltage value on Battery 1:
conversion_value = VI_ADC_Read(BATT_1,
CHANNEL_VOLTAGE);
Example Function Call
3.3.11
SMBus_Select ( )
This function selects the active SMBus battery channel.
void SMBus_Select(unsigned char batt_num) {…}
Function Definition
Inputs
Name
batt_num
Type
unsigned char
Return
Example Function Call
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Description
Example Value
Value that represents battery channel number
BATT_1, BATT_2
None
• Select battery 2 for SMBus communication: SMBus_Select(BATT_2);
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
19
Software
3.3.12
www.ti.com
Calibrate_Battery ( )
This function provides control over the power resistor circuitry to discharge the selected battery. This
discharging circuit can be used for calibrating battery pack voltages and can be turned on or off by calling
this function. For details on hardware setup for this circuit, see Appendix F.
void Calibrate_Battery (unsigned char batt_num,
unsigned char on_off) {…}
Function Definition
Inputs
Name
Type
Example Value
batt_num
unsigned char
Value that represents battery number
BATT_1, BATT_2
on_off
unsigned char
Turns the calibration circuit to on or off state.
CAL_ON, CAL_OFF
Return
None
• To turn on the discharge circuit for battery 1 voltage calibration:
Example Function Call
3.3.13
Description
Calibrate_Battery(BATT_1, CAL_ON);
Delay_Timer ( )
This function implements a fixed delay in the program. It halts program execution and places the CPU in
low-power mode. Rather than consume CPU cycles, it uses a Timer running in the background to count
delay. This delay function acts like a software virtual counter where one count for the virtual counter is
equivalent to TIMER_TICK counts of the hardware timer. TIMER_TICK is a definition in the misc.h that
can be easily modified. It is set to default of 25 ms as it is used to implement SMBus timeout and LED
refresh blink period. When the function reaches the desired delay, it wakes up the CPU and program
execution resumes.
void Delay_Timer(int number_of_ticks) {…}
Function Definition
Inputs
Name
number_of_ticks
Return
Example Function Call
20
Type
unsigned char
Description
Example Value
Amount of delay required. Delay is a multiple of
the TIMER_TICK duration.
1, 2, 3, etc.
None
• To have a 100 ms delay where TIMER_TICK has been defined for 25-ms delay:
Delay_Timer(4);
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Software
www.ti.com
3.3.14
PWM_Control ( )
This function provides access to PWM output control. The timer within the MSP430F5510 is configured to
output the PWM at a rate of 20 kHz and can independently adjust two outputs for controlling voltage and
current to the dc/dc converter.
void PWM_Control (unsigned char batt_num, unsigned
char pwm_channel, unsigned char on_off, unsigned int
pwm_duty_period) {…}
Function Definition
Inputs
Name
Type
Description
Example Value
batt_num
unsigned char
Value that represents battery channel number
BATT_1, BATT_2
pwm_channel
unsigned char
Channel type to output PWM: voltage or current
CHANNEL_VOLTAGE,
CHANNEL_CURRENT
on_off
unsigned char
Set the PWM output to HIGH or LOW
PWM_ON, PWM_OFF
Configure the duty cycle of the PWM output
PWM_DUTY_0 (~0%)...
PWM_DUTY_100 (~100%)
pwm_duty_period
unsigned int
Return
None
• To turn off PWM on Battery1, Voltage Channel:
Example Function Call
PWM_Control(BATT_1, CHANNEL_VOLTAGE, PWM_OFF,
PWM_DUTY_0);
• To specify 10% duty cycle on Battery 1, Voltage Channel:
PWM_Control(BATT_1, CHANNEL_VOLTAGE, PWM_ON, 0.1 *
PWM_DUTY_100); where pwm_duty_period = 0.1 *
PWM_DUTY_100
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
21
Software
3.3.15
www.ti.com
Smbus_Access ( )
This function is implemented as a generic SMBus access function when the MSP430F5510 is initialized to
master transmitter/receiver mode. This function handles the communication between the MSP430F5510
master and the slave bq fuel gauge device. It also assumes that the slave fuel gauge has the broadcast
mode disabled.
NOTE: When using this function to write to the fuel gauge, use the Delay_Timer() function to wait
for 50 to 100 ms before issuing a read or write command to the fuel gauge. This delay is
necessary to give time for the data Flash memory within the fuel gauge to be written without
any corruption.
unsigned char Smbus_Access (unsigned char
smbus_command, unsigned char read_write, unsigned
char size_in_bytes {…}
Function Definition
Inputs
Name
Type
Description
Example Value
SBS_CMD_VOLTAGE,
SBS_CMD_CHARGING_CUR
RENT
smbus_command
unsigned char
One byte of SMBus command (0x00 to 0x7F).
See Appendix A for a list of supported SMBus
commands.
read_write
unsigned char
Set the mode to either read data from or write
data to the slave device.
SMBUS_MASTER_MODE_RE
AD,
SMBUS_MASTER_MODE_WR
ITE
size_in_bytes
unsigned char
Based on the command syntax, size of the data
set to be sent or received.
0x01 to 0x20
SMBus_Data_To_Slave
unsigned char[]
Array of data to be sent to the slave. The calling
function should parse the data into byte-size
elements and stuff them into this array.
Return
Name
Type
Description
Example Value
FLAG_SUCCESS=0,
FLAG_FAIL=1, FLAG_NACK=2
smbus_access_status
unsigned char
Returns the status of whether the command was
successful or not
SMBus_Data_From_
Slave
unsigned char[]
Array of data to be received from the slave. The
calling function should concatenate the byte-size
elements to construct the data received.
• To interrogate the battery voltage via SMBus:
Example Function Call
smbus_access_status =
SMBus_Access(SBS_CMD_VOLTAGE,
SMBUS_MASTER_MODE_READ, 2);
// Tables for data to/from Slave Device declared with size of 32 bytes
#define SMBUS_DATA_TO_SLAVE 32
//Table length
unsigned char SMBus_Data_To_Slave[SMBUS_DATA_TO_SLAVE];
#define SMBUS_DATA_FROM_SLAVE 32
//Table length
unsigned char SMBus_Data_From_Slave[SMBUS_DATA_FROM_SLAVE];
22
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Software
www.ti.com
3.3.16
Smbus_Access_PEC ( )
This function is implemented as a generic SMBus access function with packet error checking (PEC)
implementation on the MSP430F5510 initialized to master mode. While similar to the SMBus_Access
function, this function can either generate the PEC byte (if the master is transmitter) or can compare the
PEC byte received against the internally computed one (if the master is receiver).
This function calls another function crc8MakeBitwise(), which computes the PEC byte within the
MSP430F5510. In the master transmitter case, the PEC byte is appended last to the transmit buffer. If the
slave fuel gauge returns an ACK immediately following the PEC byte, then data integrity was preserved
during the transaction. On the other hand, if the return is a NACK, then some bits are being altered
unintentionally during the transaction. In the case of the master receiver, the last byte in the receive buffer
is the PEC byte. The PEC byte is internally generated, compared with the received one and if the bytes
are equal, then a valid transaction occurred.
unsigned char Smbus_Access_PEC (unsigned char
smbus_command, unsigned char read_write, unsigned
char size_in_bytes {…}
Function Definition
Inputs
Name
Type
Description
Example Value
SBS_CMD_VOLTAGE,
SBS_CMD_CHARGING_CUR
RENT
smbus_command
unsigned char
One byte of SMBus command (0x00 to 0x7F).
See Appendix A for a list of supported SMBus
commands.
read_write
unsigned char
Set the mode to either read data from or write
data to the slave device.
SMBUS_MASTER_MODE_RE
AD,
SMBUS_MASTER_MODE_WR
ITE
size_in_bytes
unsigned char
Based on the command syntax, size of the data
set to be sent or received.
0x01 to 0x20
SMBus_Data_To_Slave
unsigned char[]
Array of data to be sent to the slave. The calling
function should parse the data into byte-size
elements and stuff them into this array.
Return
Name
Type
Description
Example Value
smbus_access_status
unsigned char
Returns the status flag if the PEC byte sent by
the slave fuel gauge matches the ones computed
FLAG_SUCCESS=0,
in the MSP430F5510 or if the PEC byte written
FLAG_FAIL=1, FLAG_NACK=2
by the MSP430F5510 is acknowledged by the
slave device.
SMBus_Data_From_
Slave
unsigned char[]
Array of data to be received from the slave. The
calling function should concatenate the byte-size
elements to construct the data received.
• To access the battery voltage via SMBus with PEC:
smbus_access_status =
SMBus_Access_PEC(SBS_CMD_VOLTAGE,
SMBUS_MASTER_MODE_READ, 2);
Example Function Call
// Tables for data to/from Slave Device declared with size of 32 bytes
#define SMBUS_DATA_TO_SLAVE 32
//Table length
unsigned char SMBus_Data_To_Slave[SMBUS_DATA_TO_SLAVE];
#define SMBUS_DATA_FROM_SLAVE 32
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
//Table length
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
23
Software
www.ti.com
unsigned char SMBus_Data_From_Slave[SMBUS_DATA_FROM_SLAVE];
3.3.17
crc8MakeBitwise ( )
This function implements the cyclic redundancy check (CRC) algorithm to generate the PEC byte. It has
been derived from the CRC16/CRC32 functions presented in CRC Implementation With MSP430
(SLAA221) and has been modified to output a CRC-8 error check byte [8]. It performs XOR operations in
the order the bits are received using the CRC-8 polynomial: C(x) = x8 + x2 + x1 + 1. The calculation is done
on all bytes including device addresses, Read/Write bits, SBS commands, etc. However, it does not
include the START, repeated START, ACK, NACK, or STOP bits.
unsigned short crc8MakeBitwise(unsigned char CRC,
unsigned char Poly, unsigned char *Pmsg, unsigned int
Msg_Size) {…}
Function Definition
Inputs
Name
Type
Description
Example Value
CRC
unsigned char
Initial value of the CRC byte
CRC8_INIT_REM
Poly
unsigned char
CRC-8 polynomial 0x07 (the ‘1’ in the polynomial
CRC8_POLY
0x107 is implied)
*Pmsg
unsigned char
Input stream for which the CRC-8/PEC byte is
computed.
Data stream parsed into an
array of byte-size elements
Msg_Size
unsigned char[]
Number of bytes in the input bit stream
5 (for five bytes)
Return
Name
unsigned short
Example Function Call
Type
unsigned short
Description
The computed CRC-8/PEC byte.
• To calculate the CRC-8/PEC byte with a five-element array:
unsigned char crc_msg_size = 5;
unsigned char crc_msg[5];
crc_generated = crc8MakeBitwise(CRC8_INIT_REM, CRC8_POLY, crc_msg, crc_msg_size);
3.4
Sample Application Description
The sample application included with this reference design showcases a demo smart battery charger. The
application runs on the MSP430F5510 daughterboard connected to the Power Stage Board by the means
of a 10-pin connector. Instructions for setting up the MSP430F5510 daughterboard are listed in
Appendix E and instructions for setting up the Power Stage Board are listed in Appendix L.
The hardware setup requires connecting the charger setup to a smart battery with access to the battery
terminals and the SMBus communication bus. The MSP430F5510 daughterboard has two headers to
connect the SMBus lines from two batteries and are illustrated in the schematic as J2 and J3
(Appendix D). The Power Stage Board can independently charge two batteries and the output terminals
are denoted as J2 and J12 in the illustrated schematic (Appendix I for 40 V and Appendix K for 60 V
versions).
24
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Software
www.ti.com
If a smart battery is not available, the system can be tested out by using a SMBus battery fuel gauge
evaluation module. This reference design was tested with the bq20z90EVM module, which has a four-pin
header for SMBus communication and an input connector for resistors. The idea is to apply an external
voltage across the resistors connected in series to simulate the cell voltages of a multi-cell Li-ion battery.
For additional details on setting up the EVM, see the Quick Start Guide [1] and the bq20z90EVM User’s
Guide [9].
Another advantage of this EVM is that the bq device can easily be programmed and configured unlike a
sealed battery in which the bq register settings are locked. An example programmer that can accomplish
such task is the EV2300. It supports multiple protocols to communicate with fuel gauges such as SMBus,
I2C and HDQ [11]. The EV2300 communicates to the PC via USB and the control panel display GUI on
the PC allows easy modifications to register settings [12]. For detailed instructions on setting up the
evaluation software to communicate with the EVM, see the bqEASY Evaluation Software User’s Guide
(SLUU278) [13].
Figure 8 shows an abbreviated flow chart of the sample application provided with this reference design.
The detailed flow chart with safety checks is presented in Appendix B.
Start
Initialize MSP430
(SMBus Master Mode)
Wait a
Few seconds
Interrogate Battery:
(SMBus Slave Mode)
Charging Voltage
Charging Current
State of Charge (0-100%)
Battery Status
Yes
Battery Status
Error Condition?
Adjust PWM
to Deliver
Power Requested
No
Yes
No
Is Battery
Fully Charged?
Halt PWM
Outputs to Stop
Charging
Stop
Figure 8. Sample Application Flow Chart (Brief)
The application initializes the MSP430F5510 in SMBus master mode and assumes that the bq fuel gauge
is configured in SMBus Slave Mode (with broadcasts turned off). With charge broadcasts disabled, the
fuel gauge does not seize control of the SMBus by becoming the SMBus Master when it detects an idle
condition. It is recommended to keep the fuel gauge charge broadcasts disabled for robust operation of
this reference design application.
The MSP430F5510 interrogates the fuel gauge for parameters such as Charging Voltage, Charging
Current, State of Charge, Battery Status register value, etc. The choice of parameters is governed by two
factors: the desired charging power requested by the battery and any indication of error or warning
condition with the battery. For a full list of parameters that can be interrogated from the fuel gauge via
SMBus, see Appendix A.
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
25
References
www.ti.com
The MSP430F5510 outputs voltage and current PWM signals at 20 kHz to the dc/dc converters on the
Power Stage Board. Based on the values of the desired charging voltage and charging current required,
the duty cycle of the PWM signals is adjusted accordingly. A duty cycle computation example along with
mapping table for voltage is presented in Appendix G and for current in Appendix H.
The MSP430F5510 outputs voltage and current PWM signals at 20 kHz to the dc/dc converters on the
Power Stage Board. Based on the values of the desired charging voltage and charging current required,
the duty cycle of the PWM signals is adjusted accordingly. A duty cycle computation example along with
mapping table for voltage is presented in Appendix G and for current in Appendix H.
Another level of protection involves taking the voltage from the battery terminals and the current from the
power-stage board and level-shifting down to be sampled by the ADC10 on the MSP430F5510. If the
voltage or current sampled by the ADC exceed a certain range reported over the SMBus, then the PWM
outputs are switched off to prevent any hazard.
4
References
1.
2.
3.
4.
5.
6.
Quick Start Guide for bq20zxx Family Gas Gauges (SLUA421)
MSP430x5xx/MSP430x6xx Family User’s Guide (SLAU208)
System Management Bus (SMBus) Specification v2.0, Aug 2000 (http://www.smbus.org)
I2C-Bus Specification and User Manual, Rev. 03, Jun 2007 (http://www.i2c-bus.org/)
MSP430F550x Mixed Signal Microcontroller Data Sheet (SLAS645)
bq20z90 SBS 1.1-Compliant Gas Gauge Enabled With Impedance Track™ Technology for Use With
the bq29330 Data Sheet (SLUS778)
7. PMM, UCS, Port Mapping, and Flash Libraries for the MSP430x5xx and MSP430x6xx Devices
(SLAA448)
8. CRC Implementation With MSP430 (SLAA221)
9. bq20z90EVM-001 SBS 1.1 Impedance Track™ Technology Enabled Battery Management Solution
Evaluation Module (SLUU234)
10. bq20z90-V1.50 + bq29330, bq20z95 Technical Reference (SLUU264)
11. EV2300 Evaluation Module Interface Board User’s Guide (SLUU159)
12. bq20z90EVM-001 – bqEV-Easy-SW Setup Evaluation Software for Windows (SLUC091)
13. bqEASY Evaluation Software User’s Guide (SLUU278)
14. MSP430™ Hardware Tools User’s Guide (SLAU278)
15. TS3A24157 0.65-Ω Dual SPDT Analog Switch Dual-Channel 2:1 Multiplexer/Demultiplexer Data Sheet
(SCDS208)
16. TPS715xx 50 mA, 24 V, 3.2-µA Supply Current Low-Dropout Linear Regulator in SC70 Package Data
Sheet (SLVS338)
17. TPS79801-Q1, TPS79850-Q1 50 mA, 3V to 50 V, Micropower, Low-Dropout Linear Regulator Data
Sheet (SLVS822)
18. TPS40054, TPS40055, TPS40057 Wide-Input Synchronous Buck Controller Data Sheet(SLUS593)
19. TPS40170 4.5-V to 60-V Wide-Input Synchronous PWM Buck Controller Data Sheet (SLUS970)
20. INA193, INA194, INA195, INA196, INA197, INA198 Current Shunt Monitor -16 V to + 80 V
Common-Mode Range Data Sheet (SBOS307)
26
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
www.ti.com
Appendix A SBS Supported Commands Using SMBus Protocol
Table 2 shows SBS commands that are supported by the bq fuel gauges using the Smbus_Access or
Smbus_Access_PEC function. For details on each individual SBS command, see the bq20z90-V1.50 +
bq29330, bq20z95 Technical Reference (SLUU264) [10].
Table 2. SBS Commands
Size In
Bytes
Min Value
Max Value
Default
Value
hex
2
0x0000
0xffff
-
RemainingCapacityAlarm
unsigned int
2
0
65535
-
mAh or
10 mWh
R/W
RemainingTimeAlarm
unsigned int
2
0
65535
-
min
0x03
R/W
BatteryMode
hex
2
0x0000
0xffff
-
0x04
R/W
AtRate
signed int
2
-32768
32767
-
mA or
10 mW
0x05
R
AtRateTimeToFull
unsigned int
2
0
65535
-
Min
0x06
R
AtRateTimeToEmpty
unsigned int
2
0
65535
-
Min
0x07
R
AtRateOK
unsigned int
2
0
65535
-
0x08
R
Temperature
SBS CMD
Mode
0x00
(1)
Name
Format
R/W
ManufacturerAccess
0x01
R/W
0x02
(1)
Unit
unsigned int
2
0
65535
-
0.1K
unsigned int
2
0
20000
-
mV
signed int
2
-32768
32767
-
mA
0x09
R
Voltage
(1)
0x0a
R
Current
(1)
0x0b
R
AverageCurrent
signed int
2
-32768
32767
-
mA
0x0c
R
MaxError
unsigned int
1
0
100
-
%
0x0d
R
RelativeStateOfCharge
unsigned int
1
0
100
-
%
0x0e
R
AbsoluteStateOfCharge
unsigned int
1
0
100
-
%
(1)
0x0f
R
RemainingCapacity
unsigned int
2
0
65535
-
mAh or
10 mWh
0x10
R
FullChargeCapacity
unsigned int
2
0
65535
-
mAh or
10 mWh
0x11
R
RunTimeToEmpty
unsigned int
2
0
65535
-
min
0x12
R
AverageTimeToEmpty
unsigned int
2
0
65535
-
min
0x13
R
AverageTimeToFull
unsigned int
2
0
65535
-
min
0x14
R
ChargingCurrent
(1)
unsigned int
2
0
65535
-
mA
0x15
R
ChargingVoltage
(1)
unsigned int
2
0
65535
-
mV
0x16
R
BatteryStatus
unsigned int
2
0x0000
0xffff
-
0x17
R
CycleCount
unsigned int
2
0
65535
-
0x18
R/W
DesignCapacity
unsigned int
2
0
65535
0x19
R/W
DesignVoltage
unsigned int
2
700
16000
14400
0x1a
R/W
SpecifcationInfo
unsigned int
2
0x0000
0xffff
0x0031
0x1b
R/W
ManufactureDate
unsigned int
2
0
65535
0
0x1c
R/W
SerialNumber
hex
2
0x0000
0xffff
0x0001
0x20
R/W
ManufacturerName
string
11+1
-
-
TI
ASCII
0x21
R/W
DeviceName
string
7+1
-
-
bq20z80
ASCII
0x22
R/W
DeviceChemistry
string
4+1
-
-
LION
ASCII
0x23
R
ManufacturerData
string
14+1
-
-
-
ASCII
0x2f
R/W
Authenticate
string
20+1
-
-
-
(1)
mAh or
10 mWh
0x3c
R
CellVoltage4
unsigned int
2
0
65535
mV
0x3d
R
CellVoltage3
unsigned int
2
0
65535
mV
0x3e
R
CellVoltage2
unsigned int
2
0
65535
mV
0x3f
R
CellVoltage1
unsigned int
2
0
65535
mV
This parameter is used in the sample application.
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
27
Appendix B
www.ti.com
Appendix B Detailed Sample Application Flow Chart
Figure 9 shows a detailed flow chart for the sample software application implemented in this reference
design. Figure 10 gives a detailed view of the primary and secondary safety checks being performed on
the parameters received via SMBus and ADC, respectively.
Initialize MSP430
I2C USCI in Master Mode
Start
Initialize Peripherals for the
Controller Board (Assumes BCAST = 0,
No Broadcast From Battery)
Set SMB-CH-SELECT = 0 Default
(PP4M_OU - Pin29)
Interrogate Battery Via SMBus
Toggle
SMB-CH-SELECT
Toggle
SMB-CH-SELECT
(1) Voltage (0x09
(2) Current (0x0A)
(3) Temperature (0x08)
(4) Battery Status (0x16)
(5) Charging Voltage (0x15)
(6) Charging Current (0x14)
Blink LED4 (Red) Steady On [BATT1]
or
Blink LED5 (Red) Steady On [BATT2]
FALSE
X2
MSP430 Enter Low-Power Mode
Wait Two Seconds
Confirm Both
Values Match
for Charging Voltage and
Charging Current
TRUE
Safety Check
See Page 2
SUCCESS
FAIL
SET PWM Outputs Based on
Shut Off PWM Signals
FALSE
FC Bit = 1?
SOC = 100%?
Indicating Battery
Fully Charged
(1) Charging Voltage (0x15)
(2) Charging Current (0x14)
Blink LED2 (Orange) Steady On
Blink LED0 (Green) Steady On
for SMB-CH-SELECT = 0
or
Blink LED3 (Orange) Steady On
Blink LED1 (Green) Steady On
for SMB-CH-SELECT = 1
Enable PWM Outputs
TRUE
MSP430 Enter Low-Power Mode
Wait Two seconds
Set LED0 (Green) Steady On
for SMB-CH-SELECT = 0
or
Set LED1 (Green) Steady On
for SMB-CH-SELECT = 1
MSP430 Enter Low-Power Mode
Wait Two seconds
Figure 9. Sample Application Flow Chart (Detailed)
28
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Appendix B
www.ti.com
Safety Checks
SMBus Verification
A
IF Voltage [first read] (0x09) > Charging Voltage (0x15) x 1.1
A
IF Voltage [second read] (0x09) > Charging Voltage (0x15) x1.1
OR
A
IF Current [first read] (0x0A) > Charging Voltage (0x14) x 1.05
A
IF Current [second read] (0x0A) > Charging Voltage (0x14) x1.05
OR
IF Battery Status [first read] or [second read] any of the following bits are set
(OCA, TCA, OTA, FC)
OR
IF temperature [first read] or [second read] (0x08) > 45°C
External ADC Verification
A
VBATT1 (ADC) > Charging Voltage (0x15) x 1.1
A
ISNS1 (ADC) > Charging Current (0x14) x 1.1
For (SMB-CH-SELECT = 0)
A
VBATT2 (ADC) > Charging Current (0x15) x 1.05
A
ISNS2 (ADC) > Charging Current (0x14) x 1.05
For (SMB-CH-SELECT = 1)
A
These factors are adjustable in the code by changing the percentage factor.
Figure 10. Safety Checks
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
29
Appendix C
www.ti.com
Appendix C Battery Status Register Description
The following section describes the individual bits within the Battery Status Register. The corresponding
SMBus Command is 0x16 and the sample application software monitors the following bits for safety
checks: OCA, TCA, OTA, and FC. Additional details are available in the bq20z90-V1.50 + bq29330,
bq20z95 Technical Reference (SLUU264) [10].
C.1
BatteryStatus (0x16)
This read-word function returns the status of the bq20z90/bq20z95-based battery.
High Byte
Low Byte
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
OCA
INIT
TCA
DSG
RSVD
FC
OTA
FD
TDA
EC3
RSVD
EC2
RCA
EC1
RTA
EC0
LEGEND: All Values Read Only; RSVD = Reserved
1 = Over Charged Alarm (1)
1 = Terminate Charge Alarm (1)
1 = Over Temperature Alarm (1)
1 = Terminate Discharge Alarm
Remaining Capacity Alarm
1 = Remaining Capacity Alarm is set [see: SBS:RemainingCapacityAlarm(0x01)]
RTA:
Remaining Time Alarm
1 = Remaining Time Alarm is set [see: SBS:RemainingTimeAlarm(0x02)]
INIT:
1 = Initialization. This flag is cleared approximately 1 second after device reset, after all SBS parameters have been measured
and updated.
DSG:
Discharging
0 = bq20z90/bq20z95 is in charging mode
1 = bq20z90/bq20z95 is in discharging mode, relaxation mode, or valid charge termination has occurred (see the Gas Gauging
section in bq20z90-V1.50 + bq29330, bq20z95 Technical Reference (SLUU264) [10]
FC:
1 = Fully Charged (1)
FD:
1 = Fully Discharged
EC3, EC2, EC1, EC0: Error Code, returns status of processed SBS function
0,0,0,0 = OK
bq20z90/bq20z95 processed the function code with no errors detected.
0,0,0,1 = BUSY
bq20z90/bq20z95 is unable to process the function code at this time.
0,0,1,0 = Reserved bq20z90/bq20z95 detected an attempt to read or write to a function code reserved by this version of the
specification or bq20z90/bq20z95 detected an attempt to access an unsupported optional manufacturer
function code.
OCA:
TCA:
OTA:
TDA:
RCA:
(1)
30
This parameter is used in the sample application.
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
www.ti.com
Appendix D MSP430F5510 Daughterboard Schematic
The schematics of the MSP430F5510 microcontroller daughterboard (PMP5385) are presented in
Figure 11 and Figure 12:
Figure 11. MSP430F5510 Daughterboard Schematic (Page 1)
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
31
Appendix D
www.ti.com
Figure 12. MSP430F5510 Daughterboard Schematic (Page 2)
32
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
www.ti.com
Appendix E Setting Up the MSP430F5510 Daughterboard Hardware
There are multiple ways of powering and programming the MSP430F5510 Daughterboard. Detailed
explanations and recommendations for MSP430F5510 hardware design can be found in the MSP430™
Hardware Tools User’s Guide (SLAU278) [14].
E.1
JTAG FET Debugger Interface (Power Up, Program and Debug Options)
The MSP-FET430UIF (MSP430 Flash Emulation Tool with USB Debug Interface, referred to as JTAG FET
Debugger, uses the four-wire JTAG connection (along with VDD and GND) to power and program the
target MSP430 device. When used with an IDE, such as the Code Composer Studio™ IDE or IAR
Embedded Workbench™ IDE, the JTAG FET debugger allows the target voltage to be programmed,
multiple hardware and software breakpoints to be set, and extensive debugging to be performed.
The following steps should be performed with the JTAG FET debugger to power and program the board:
1. Populate jumpers J19 and J20. This connects the VCC power rail from the FET debugger to the 3V3
power rail of the board.
2. Connect the 14-pin female dual-row ribbon cable from the target end of the FET debugger to jumper
J17 of the board.
The power indicator LED D2 should light up. Pressing the Debug button in the IDE environment
downloads the program on the hardware for debug and testing.
E.2
eZ430 Emulator Interface (Power Up, Program and Debug Options)
NOTE: This procedure works only with the eZ430 emulator (Black) supplied with the
eZ430-Chronos™ software development tool. eZ430 emulators supplied with eZ430-F2013
(Blue) and eZ430-RF2500 (Red) are NOT able to program this daughterboard, as they do
not contain the firmware for programming 5xx devices. Only the black eZ430-Chronos
emulator can program this daughterboard out-of-the-box.
The eZ430 emulator Interface uses the Spy-Bi-Wire JTAG protocol to power and program the hardware. It
uses only two wires, along with VDD and GND, for programming the target MSP430 device. The target
voltage, however, is fixed at 3.6 V and there is limited debug capability when compared to the FET JTAG
debugger. Nonetheless, the small USB stick form-factor of a six-pin header with low cost has made this
emulator very popular.
The following steps should be performed with the eZ430 emulator interface to power and program the
board:
1. Populate jumpers J10 and J11. This connects the 3.6-V power rail from the FET Debugger to the 3.3-V
power rail of the board. In other words, the daughterboard operates at 3.6 V, instead of 3.3 V.
2. Connect the 6-pin male header of the eZ430 USB stick Emulator to Jumper J9 of the board.
Power indicator LED D2 should light up. Pressing the Debug button in the IDE environment downloads the
program on the hardware for debug and testing.
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
33
Power Stage Board (Power Up Option Only)
E.3
www.ti.com
Power Stage Board (Power Up Option Only)
When debugging is not necessary and the whole system needs to run independently, the MSP430F5510
daughterboard can be powered directly from the power-stage board with the following steps:
1. Connect the right-angle male header (J4) to the corresponding female header on the Power Stage
Board.
2. Apply VIN to power-stage board to create the VBIAS voltage (approximately 10 V).
3. Confirm approximately 10 V on Jumper J7, pin1.
4. Populate jumper 7 to supply the VBIAS-IN to the TPS71533 3.3-V LDO. Confirm 3.3-V output on
jumper 6, pin 1 and on jumper 12, pin 1.
5. Populate jumper J6 to supply 3.3 V to daughterboard peripherals.
6. Populate jumper J12 to supply 3.3 V to the MSP430F5510 microcontroller.
Power indicator LED D2 should light up, and the software should start up and begin execution.
34
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
www.ti.com
Appendix F Battery Calibration Circuit Setup
The MSP430F5510 daughterboard hardware has power resistors that can be connected to battery
terminals for discharging. The discharge circuitry can be turned on or off by the microcontroller to calibrate
battery pack voltages. There are two independent circuits for calibrating two batteries simultaneously.
• To enable the calibration circuit for Battery 1, populate J5, pins 1 and 2.
• To enable the calibration circuit for Battery 2, populate J8, pins 1 and 2.
Figure 13. Battery Calibration Circuit Setup
Note that to enable the power FETs, the respective calibration signal from the microcontroller must be set
to a logic high (CAL-CH1 or CAL-CH2). This task can be easily accomplished by calling the
Calibrate_Battery() function.
Appendix G Battery Voltage and PWM Conversions
Table 3 represents the mapping between the MSP430F5510 PWM duty cycle and the voltage output from
the dc/dc converter. The PWM frequency is 20 kHz and modifying the PWM duty cycle for the voltage
input changes the voltage output of the dc/dc converter. Pulling the PWM signals LOW causes the dc/dc
converter to switch off and stop delivering power to the battery.
Table 3. Battery Voltage and PWM Conversions
Duty Cycle
(%)
PWM Average Voltage
(V)
Average Output Voltage
(V)
0
0
0
10.78
0.335
5.5
24.71
0.791
12.6
32.94
1.054
16.8
68.6
2.196
35 (maximum allowed with TPS40054 Power Stage Board)
100.0
3.200
51 (maximum allowed with TPS40170 Power Stage Board)
Sample Calculation Example:
• Desired charger output voltage (Vout) = 16.8 V
• Duty cycle (based on 51 V maximum output voltage) = 16.8 V/51 V = 0.3294 (32.94%)
• Desired average voltage of PWM = Duty cycle × 3.2 V = 1.054 V, where 3.2 V is the MSP430F5510
supply range (and also the conversion range for the ADC10)
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
35
Appendix H
www.ti.com
Appendix H Battery Current and PWM Conversions
Table 4 represents the mapping between the MSP430F5510 PWM duty cycle and the current output from
the dc/dc converter. The PWM frequency is 20 kHz and modifying the PWM duty cycle for the current
input changes the current output of the dc/dc converter. Pulling the PWM signals LOW causes the dc/dc
converter to switch off and stop delivering power to the battery.
Table 4. Battery Current and PWM Conversions
Duty Cycle
(%)
PWM Average
Voltage
(V)
Average Output
Current
(A)
0
0
0
1.0
0.033
0.1
10.0
0.33
1.0
20.0
0.67
2.0
50.0
1.67
5.0
100.0
3.3
10.0
Sample Calculation Example:
• Desired charger output current (Iout) = 1 A
• Duty cycle (based on 10-A maximum output current) = 1 A / 10 A = 0.1 (10%)
• Desired average voltage of PWM = Duty cycle × 3.3 V = 0.330 V, where 3.3 V is the MSP430F5510
supply range (and also the conversion range for the ADC10)
36
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
www.ti.com
Appendix I Power Stage Board Schematic (Generation 1: 40-V Input)
+
+
+
The schematics of the 40-V tolerant input power-stage board (PMP5306) with the TPS40057 dc/dc
controller [18] are presented in Figure 14 and Figure 15:
Figure 14. 40-V Input Power Stage Board Schematic (Page 1)
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
37
Appendix I
+
+
www.ti.com
Figure 15. 40-V Input Power Stage Board Schematic (Page 2)
38
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
www.ti.com
Appendix J Bode Plot Measurement for Feedback Loop Stability Analysis
Figure 16 shows the bode plot measurement for feedback loop stability analysis. The gain is represented
on the left side of the phase on the right side of the y-axis.
5-Phase
50 dB
40 dB
3-Gain
9-Gain
18-Gain
180
60
Feedback Bode Plot for
PMP5306 With Electronic Load
3-Phase
13-Phase
5-Gain
13-Gain
4-Gain
150 deg
120 deg
30 dB
90 deg
4-Phase
20 dB
60 deg
30 deg
Feedback Bode Plot
With Battery Load
0 dB
0 deg
-10 dB
-30 deg
-20 dB
-60 deg
-30 dB
-90 deg
-40 dB
Phase
Gain
10 dB
-120 deg
1
Frequency
-180
100 kHz
10 kHz
1 kHz
18-Phase
100 Hz
10 Hz
1 Hz
-60
9-Phase
1M
Figure 16. Bode Plot Measurement Graph - Gain (left) and Phase (right)
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
39
Appendix K
www.ti.com
Appendix K Power Stage Board Schematic (Generation 2: 60-V Input)
+
+
+
The schematic of the 60-V tolerant input power-stage board (PMP5313) with the TPS40170 dc/dc
controller [19] are presented in Figure 17 and Figure 18. Note that these schematics are for preliminary
prototypes and are subject to change in the future.
Figure 17. 60-V Input Power Stage Board Schematic (Page 1)
40
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Appendix K
+
+
www.ti.com
Figure 18. 60-V Input Power Stage Board Schematic (Page 2)
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
41
Appendix L
www.ti.com
Appendix L Setting Up the Power Stage Board Hardware
The power-stage board can be setup in the following steps:
• Each dc/dc converter stage can be tested independently. If both stages are being used, each stage
switches 180° out-of-phase to lower the input capacitor current ripple.
• J1 is the input connector to the first power stage buck converter. Apply a voltage to J1 that is higher
than the battery voltage to charge including 15% overhead for the duty cycle limitation of the converter.
• The 20-kHz PWM inputs from the MSP430F5510 microprocessor board feed into I_PWM1 and
V_PWM1. Analog voltages could also be fed onto these pins to control the output voltage and current
of the DC/DC controller.
• A protection diode is used on the output of each power stage to protect the converter and prevent
discharge of the battery. For output currents less than 5 A, the surface mount output diode can be
used. For current levels from 5 to 10 A, heatsinking is required to remove heat from the TO-220 diode.
• To test the reverse polarity and overvoltage protection, apply the input voltage to J9. The voltage on J8
feeding VIN and VIN_2 is limited by the breakdown voltage of zener diode D4. In an overvoltage
condition, both dc/dc converters are shut off by signals SD1 and SD2 but continue to power the
microprocessor though the Vbias voltage created by Q6 discrete linear regulator.
42
Wide-Vin Battery Charger Using SMBus Communication Interface Between
MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011, Texas Instruments Incorporated
SLAA476A – February 2011 – Revised July 2011
Submit Documentation Feedback
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements,
and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should
obtain the latest relevant information before placing orders and should verify that such information is current and complete. All products are
sold subject to TI’s terms and conditions of sale supplied at the time of order acknowledgment.
TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI’s standard
warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where
mandated by government requirements, testing of all parameters of each product is not necessarily performed.
TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and
applications using TI components. To minimize the risks associated with customer products and applications, customers should provide
adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right,
or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information
published by TI regarding third-party products or services does not constitute a license from TI to use such products or services or a
warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual
property of the third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied
by all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptive
business practice. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additional
restrictions.
Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all
express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not
responsible or liable for any such statements.
TI products are not authorized for use in safety-critical applications (such as life support) where a failure of the TI product would reasonably
be expected to cause severe personal injury or death, unless officers of the parties have executed an agreement specifically governing
such use. Buyers represent that they have all necessary expertise in the safety and regulatory ramifications of their applications, and
acknowledge and agree that they are solely responsible for all legal, regulatory and safety-related requirements concerning their products
and any use of TI products in such safety-critical applications, notwithstanding any applications-related information or support that may be
provided by TI. Further, Buyers must fully indemnify TI and its representatives against any damages arising out of the use of TI products in
such safety-critical applications.
TI products are neither designed nor intended for use in military/aerospace applications or environments unless the TI products are
specifically designated by TI as military-grade or "enhanced plastic." Only products designated by TI as military-grade meet military
specifications. Buyers acknowledge and agree that any such use of TI products which TI has not designated as military-grade is solely at
the Buyer's risk, and that they are solely responsible for compliance with all legal and regulatory requirements in connection with such use.
TI products are neither designed nor intended for use in automotive applications or environments unless the specific TI products are
designated by TI as compliant with ISO/TS 16949 requirements. Buyers acknowledge and agree that, if they use any non-designated
products in automotive applications, TI will not be responsible for any failure to meet such requirements.
Following are URLs where you can obtain information on other Texas Instruments products and application solutions:
Products
Applications
Audio
www.ti.com/audio
Communications and Telecom www.ti.com/communications
Amplifiers
amplifier.ti.com
Computers and Peripherals
www.ti.com/computers
Data Converters
dataconverter.ti.com
Consumer Electronics
www.ti.com/consumer-apps
DLP® Products
www.dlp.com
Energy and Lighting
www.ti.com/energy
DSP
dsp.ti.com
Industrial
www.ti.com/industrial
Clocks and Timers
www.ti.com/clocks
Medical
www.ti.com/medical
Interface
interface.ti.com
Security
www.ti.com/security
Logic
logic.ti.com
Space, Avionics and Defense
www.ti.com/space-avionics-defense
Power Mgmt
power.ti.com
Transportation and
Automotive
www.ti.com/automotive
Microcontrollers
microcontroller.ti.com
Video and Imaging
www.ti.com/video
RFID
www.ti-rfid.com
Wireless
www.ti.com/wireless-apps
RF/IF and ZigBee® Solutions
www.ti.com/lprf
TI E2E Community Home Page
e2e.ti.com
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2011, Texas Instruments Incorporated
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising