Slaa 476 B
Slaa 476 B
Slaa 476 B
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 MCU interrogates the fuel gauge for voltage, current, and other parameters through SMBus. The
MCU then adjusts the pulse width modulation (PWM) duty-cycle output signals that are 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 to other MSP430 MCUs with minor modifications. The
charger scheme demonstrated in this application report is specific to a Li-ion and Li-polymer
battery chemistry. However, the overall battery charging concept is applicable to any type of
battery chemistry.
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 1
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com
Contents
1 Introduction ................................................................................................................... 3
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 ............................................................................................. 12
3.4 Sample Application Description ................................................................................. 24
4 SBS Supported Commands Using SMBus Protocol ................................................................... 26
5 Detailed Sample Application Flow Chart ................................................................................ 27
6 Battery Status Register Description ...................................................................................... 29
6.1 BatteryStatus (0x16) .............................................................................................. 29
7 MSP430F5510 Daughterboard Schematics ............................................................................ 30
8 Setting Up the MSP430F5510 Daughterboard Hardware ............................................................ 32
8.1 JTAG FET Debugger Interface (Power Up, Program and Debug Options) ............................... 32
8.2 eZ430 Emulator Interface (Power Up, Program and Debug Options) ...................................... 32
8.3 Power Stage Board (Power Up Option Only) .................................................................. 33
9 Battery Calibration Circuit Setup ......................................................................................... 33
10 Battery Voltage and PWM Conversions ................................................................................. 33
11 Battery Current and PWM Conversions ................................................................................. 34
12 Power Stage Board Schematics (Generation 1: 40-V Input) ......................................................... 35
13 Bode Plot Measurement for Feedback Loop Stability Analysis ...................................................... 37
14 Power Stage Board Schematics (Generation 2: 60-V Input) ......................................................... 38
15 Setting Up the Power Stage Board Hardware .......................................................................... 40
16 References .................................................................................................................. 41
List of Figures
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 ................................................................................. 7
5 Overvoltage and Reverse Polarity Protection Circuitry ................................................................. 8
6 Typical Charging Profile .................................................................................................... 9
7 Constant Current and Voltage Feedback to Charge the Battery ...................................................... 9
8 Sample Application Flow Chart (Brief) .................................................................................. 25
9 Sample Application Flow Chart (Detailed) .............................................................................. 27
10 Safety Checks .............................................................................................................. 28
11 MSP430F5510 Daughterboard Schematic (Page 1) .................................................................. 30
12 MSP430F5510 Daughterboard Schematic (Page 2) .................................................................. 31
13 Battery Calibration Circuit Setup ......................................................................................... 33
14 40-V Input Power Stage Board Schematic (Page 1) .................................................................. 35
15 40-V Input Power Stage Board Schematic (Page 2) .................................................................. 36
16 Bode Plot Measurement Graph - Gain (left) and Phase (right) ...................................................... 37
17 60-V Input Power Stage Board Schematic (Page 1) .................................................................. 38
18 60-V Input Power Stage Board Schematic (Page 2) .................................................................. 39
List of Tables
1 MSP430F5510 Port-to-Functionality Mapping ........................................................................... 6
2 SBS Commands ............................................................................................................ 26
2 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Introduction
3 Battery Voltage and PWM Conversions ................................................................................. 33
4 Battery Current and PWM Conversions ................................................................................. 34
Trademarks
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.
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 allow the application to set the desired charging
parameters. These fuel gauges 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 microcontrollers are 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, or
SAR), DAC, op-amps, comparators, LCD drivers, USART, and other integrated analog and 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 or 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 uses 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 and restrictions to
the original I2C protocol [4]. SMBus is the primary method of communication with the smart-battery fuel
gauges. On the MSP430F550x MCUs, the SMBus protocol can be implemented using the I2C USCI
module.
Figure 1 shows a high-level system block diagram of this reference design smart-battery charger.
Smart
PWM
DC/DC Converter Power Battery
Power Stage System
Board
VCC
MSP430 MCU
Controller Board
SDA bq
SMBus SCL Fuel Gage
Chipset
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.
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 3
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Hardware www.ti.com
Based on the parametric values received through SMBus, the MSP430F5510 either adjusts the PWM duty
cycle or shuts off the PWM outputs, if the battery is fully charged or reports 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 with parameters only when the MSP430F5510
addresses commands to it.
2 Hardware
OCP
18-40 Vin Current Shunt
(100 V surge) Monitor (INA193)
Surge Circuitry
Clamp to 37 V Battery 1
Wide Vin
DC/DC
Voltage
Controller
TPS40057 5.5-35.0 V Charging
Current ±
Discrete LDO 0.20-10 A Terminals
Vbias (10 V) PWM
180 Out-of-Phase
synchronization
SMBus bq Fuel
Gauge Chipset
Current Shunt + Protection
OCP Monitor (INA193)
Wide Vin
DC/DC 5.5-35.0 V
Controller
TPS40057 0.20-10 A
3.3 V LDO
TPS71533 VCC Battery 2
Current
Voltage
PWM
Battery 1
Battery 2
10 W
...
10 W
Status Indicator LEDs (8)
(3.3 V, 3 mA)
Calibrate 1
Microcontroller
Calibrate 2 Daughterboard
This particular system can monitor and charge two smart batteries at the same time. 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 through a 10-pin header. The following sections describe each of the subsystems.
Batt 1 Voltage
Vbias (10 V) TPS71533
LDO (3.3 V) VCC
[Power Stage Board] Batt 1 Current DC/DC Power
Converters (x2)
PWM Batt 2 Voltage
JTAG FET [Power Stage Board]
Debugger or Batt 2 Current
Programmer eZ430 Emulator EEM
VCC
SDA Fuel Gauge
Batt 1 Analog Voltage 10kW SCL
MSP430F5510 [Inside Batt 1]
Batt 1 Analog Current USCI 1-to-2
Level Shifted (I2C) SDA demux
Analog Signals Batt 2 Analog Voltage ADC SCL SDA
TS3A24157 Fuel Gauge
Batt 2 Analog Current SCL [Inside Batt 2]
Status Batt 1
Indicator GPIO Power Resistor Terminals (±)
LEDs (8) GPIO Discharge Circuit
Batt 2
Terminals (±)
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 5
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Hardware www.ti.com
For more details on signal net names and connections, see Section 7 for the MSP430F5510
daughterboard schematic.
6 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Hardware
VPWM1
IPWM1
VPWM2
INA193 Batt 2
IPWM2 Current Monitor Terminals (±)
TPS40xxx
Voltage Control
DC/DC
ISNS1 VPWM2 Input
Power Stage VBATT2
Circuitry
ISNS2
ISNS2 Current Control
VPWM2 Input
VBATT1
VBATT2
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 7
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Hardware www.ti.com
R36 0
VIN
Q9 Q10
SUM90P10-19L SUM90P10-19L J8
J9 TP15 TP16 1
1 10 V to 37 V
10 V to 100 V 2
2 GND
GND
R37
D2 10.0K D3 C22
6.2 V 6.2 V 4.7 µF
Q11 D4
MMBT3906 36 V
+ C23
R39 R40 10.0K C24 0.1 µF R38
47 uF 100K
100K
C25 22 pF
Q12
PBSS8110T
TP17
R41 R42 SD1
10.0K 3.01K J10
SD2 1
R43 Q100 2
3.01K R44 MMBT3904LT1
10.0K
• 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.
8 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Hardware
Regulation Current
Charge
Current
Charge
Voltage
Precharge Fastcharge
BP5
10.0K
VBIAS
C17 R28 1.00K
0.047uF VBIAS
R29 1.00K C19
C20
U3:A 1uF 0.01uF
TLV274PW 2 R30 15.0K
4 VBATT1
1 +
3 R31 10.0K R32 10.0K
11 - V_PWM1
R33 R34
C21
1M 1.00K
0.1uF
• 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.
• The current into the battery is measured using shunt resistors (R5, R7, and R8) along with an INA193
(U2) (see schematic in Section 12). This circuit provides a voltage that is proportional to the output
current (see Equation 1).
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 9
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Software www.ti.com
3 Software
10 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Software
For additional details on timing diagrams and specifications, see the System Management Bus (SMBus)
Specification [3].
• 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.
• 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.
• smbus.c – Source code that uses the I2C USCI module for SMBus communication.
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 11
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Software www.ti.com
• misc.h – Header file with constants and 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.
3.3.1 UCS_Init ( )
This function initializes the universal clock system (UCS) within the MSP430F5510 to:
• Select internally generated REFO (approximately 32 kHz) as the FLL reference clock
• Select internally generated REFO (approximately 32 kHz) as ACLK
• Program the DCO to approximately 20 MHz (for SMCLK and MCLK)
Function Definition
void UCS_Init(void) {...}
Inputs
None
Return
None
Example Function Call
UCS_Init();
12 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Software
3.3.2 Timer_Init ( )
This function initializes the Timer module to establish a TIMER_TICK time-base and time-out duration.
TIMER_TICK constant is defined in init.h header file. The time-out duration for the SMBus clock low
extension and the blinking period of the LEDs are based on this Timer.
Function Definition
void Timer_Init(void) {...}
Inputs
None
Return
None
Example Function Call
Timer_Init();
3.3.3 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
None
Return
None
Example Function Call
PWM_Init();
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 13
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Software www.ti.com
3.3.4 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
None
Return
None
Example Function Call
ADC_Init();
The function uses 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.
Structure Definition Name
ADCDescription_t
14 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Software
3.3.5 Fan_Init ( )
This function configures the port connected to the fan to be in the output direction.
Function Definition
void Fan_Init(void) {...}
Inputs
None
Return
None
Example Function Call
Fan_Init();
The function uses a structure to map the MSP430F5510 port pins to the fan control channel.
Structure Definition Name
FanDescription_t
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 15
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Software www.ti.com
3.3.6 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
None
Return
None
Example Function Call
LED_Init();
The function uses 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 time-out duration. This
structure declaration keeps track of the virtual count for each LED as well as the time-out duration.
Structure Definition Name
LEDDescription_t
16 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Software
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 and slave addresses for the MSP430F5510 are defined in the header file smbus.h
Function Definition
void SMBus_Initialize (unsigned char SMBus_Mode) {...}
Inputs
Return
None
Example Function Call
To configure the MSP430F5510 in master mode:
SMBus_Initialize SMBUS_MASTER_MODE);
The function uses 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.
Structure Definition Name
SMBusDescription_t
Parameters
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 17
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Software www.ti.com
3.3.8 LED_Control ( )
This function provides control of the LEDs on the board. Call the LED_Init() function to initialize the LED
ports to output direction before making calls to this function.
Function Definition
void LED_Control (unsigned char led_num, unsigned char led_mode, unsigned char
led_blink_rate) {...}
Inputs
Return
None
Example Function Call
To make LED0 blink at a medium rate:
LED_Control(LED_NUM_0, LED_MODE_BLINK, LED_BLINK_RATE_MEDIUM);
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.
Function Definition
void char Fan_Control (unsigned char on_off) {...}
Inputs
Return
None
Example Function Call
To turn the fan on:
Fan_Control(FAN_ON);
18 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Software
3.3.10 VI_ADC_Read ( )
This function provides access to battery voltage and current using 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.
Function Definition
unsigned int VI_ADC_Read (unsigned char batt_num, unsigned char channel_vi) {...}
Inputs
Return
3.3.11 SMBus_Select ( )
This function selects the active SMBus battery channel.
Function Definition
void SMBus_Select(unsigned char batt_num) {...}
Inputs
Return
None
Example Function Call
Select battery 2 for SMBus communication:
SMBus_Select(BATT_2);
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 19
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Software www.ti.com
3.3.12 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 Section 9.
Function Definition
void Calibrate_Battery (unsigned char batt_num, unsigned char on_off) {...}
Inputs
Return
None
Example Function Call
To turn on the discharge circuit for battery 1 voltage calibration:
Calibrate_Battery(BATT_1, CAL_ON);
3.3.13 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 time-out and LED
refresh blink period. When the function reaches the desired delay, it wakes up the CPU and program
execution resumes.
Function Definition
void Delay_Timer(int number_of_ticks) {...}
Inputs
Return
None
Example Function Call
To have a 100 ms delay where TIMER_TICK has been defined for 25-ms delay:
Delay_Timer(4);
20 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Software
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.
Function Definition
void PWM_Control (unsigned char batt_num, unsigned char pwm_channel, unsigned char
on_off, unsigned int pwm_duty_period) {...}
Inputs
Return
None
Example Function Call
To turn off PWM on battery 1 voltage channel:
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.
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 21
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Software www.ti.com
3.3.15 Smbus_Access ( )
This function is implemented as a generic SMBus access function when the MSP430F5510 is initialized to
master transmitter and 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.
Function Definition
unsigned char Smbus_Access (unsigned char smbus_command, unsigned char read_write,
unsigned char size_in_bytes {...}
Inputs
Return
// 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];
22 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Software
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.
Function Definition
unsigned char Smbus_Access_PEC (unsigned char smbus_command, unsigned char
read_write, unsigned char size_in_bytes {...}
Inputs
Return
// 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];
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 23
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Software www.ti.com
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 and CRC32 functions presented in CRC Implementation With MSP430
MCUs 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, and SBS commands. However, it does not include
the START, repeated START, ACK, NACK, or STOP bits.
Function Definition
unsigned short crc8MakeBitwise(unsigned char CRC, unsigned char Poly, unsigned char
*Pmsg, unsigned int Msg_Size) {...}
Inputs
Return
24 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Software
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 Section 5.
Interrogate Battery:
(SMBus Slave Mode)
Wait a Charging Voltage
Few seconds Charging Current
State of Charge (0-100%)
Battery Status
Yes
Battery Status
Error Condition?
Adjust PWM
to Deliver
Power Requested
No
Halt PWM
Yes Outputs to Stop
No Charging
Is Battery
Fully Charged?
Stop
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, and battery status register value. 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 through SMBus, see
Section 4.
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. Section 10 gives a duty cycle computation
example along with mapping table for voltage, and Section 11 gives an example for current.
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.
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 25
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
SBS Supported Commands Using SMBus Protocol www.ti.com
26 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Detailed Sample Application Flow Chart
Initialize MSP430
Start
I2C USCI in Master Mode
TRUE
Safety Check
See Page 2
SUCCESS
FAIL
SET PWM Outputs Based on
Shut Off PWM Signals
(1) Charging Voltage (0x15)
(2) Charging Current (0x14)
Blink LED2 (Orange) Steady On
Blink LED0 (Green) Steady On Enable PWM Outputs
FALSE
for SMB-CH-SELECT = 0
FC Bit = 1? or
SOC = 100%? Blink LED3 (Orange) Steady On
Indicating Battery Blink LED1 (Green) Steady On
Fully Charged for SMB-CH-SELECT = 1
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
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 27
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Detailed Sample Application Flow Chart 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
NOTE: These factors are adjustable in the code by changing the percentage factor.
Figure 10. Safety Checks
28 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Battery Status Register Description
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 29
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
MSP430F5510 Daughterboard Schematics www.ti.com
30 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com MSP430F5510 Daughterboard Schematics
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 31
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Setting Up the MSP430F5510 Daughterboard Hardware www.ti.com
8.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.
8.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.
32 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Setting Up the MSP430F5510 Daughterboard Hardware
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.
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 33
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Battery Current and PWM Conversions www.ti.com
34 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Power Stage Board Schematics (Generation 1: 40-V Input)
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 35
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Power Stage Board Schematics (Generation 1: 40-V Input) www.ti.com
36 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Bode Plot Measurement for Feedback Loop Stability Analysis
180
60
5-Phase 3-Phase
50 dB 13-Phase 150 deg
3-Gain 5-Gain
40 dB 9-Gain 13-Gain 120 deg
18-Gain 4-Gain
30 dB 90 deg
4-Phase
20 dB 60 deg
10 dB 30 deg
Feedback Bode Plot
With Battery Load
Phase
Gain
0 dB 0 deg
100 kHz
100 Hz
10 kHz
10 Hz
1 kHz
-180
1 Hz
18-Phase
-60
1 Frequency 1M
Figure 16. Bode Plot Measurement Graph - Gain (left) and Phase (right)
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 37
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Power Stage Board Schematics (Generation 2: 60-V Input) www.ti.com
38 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com Power Stage Board Schematics (Generation 2: 60-V Input)
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 39
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Setting Up the Power Stage Board Hardware www.ti.com
40 Wide-Vin Battery Charger Using SMBus Communication Interface Between SLAA476B – February 2011 – Revised July 2019
MSP430™ MCUs and bq Fuel Gauges Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
www.ti.com References
16 References
1. Quick Start Guide for bq20zxx Family Gas Gauges
2. MSP430F5xx and MSP430F6xx Family User’s Guide
3. System Management Bus (SMBus) Specification v2.0, Aug 2000 (http://www.smbus.org)
4. I2C-Bus Specification and User Manual, Rev. 03, Jun 2007 (http://www.i2c-bus.org/)
5. MSP430F550x Mixed-Signal Microcontrollers data sheet
6. bq20z90 SBS 1.1-Compliant Gas Gauge Enabled With Impedance Track™ Technology for Use With
the bq29330 data sheet
7. PMM, UCS, Port Mapping, and Flash Libraries for the MSP430x5xx and MSP430x6xx Devices
8. CRC Implementation With MSP430 MCUs
9. bq20z90EVM-001 SBS 1.1 Impedance Track™ Technology Enabled Battery Management Solution
Evaluation Module
10. bq20z90-V1.50 + bq29330, bq20z95 Technical Reference
11. EV2300 Evaluation Module Interface Board User’s Guide
12. bq20z90EVM-001 – bqEV-Easy-SW Setup Evaluation Software for Windows
13. bqEASY Evaluation Software User’s Guide
14. MSP430™ Hardware Tools User’s Guide
15. TS3A24157 0.65-Ω Dual SPDT Analog Switch Dual-Channel 2:1 Multiplexer/Demultiplexer data sheet
16. TPS715xx 50 mA, 24 V, 3.2-µA Supply Current Low-Dropout Linear Regulator in SC70 Package data
sheet
17. TPS79801-Q1, TPS79850-Q1 50 mA, 3V to 50 V, Micropower, Low-Dropout Linear Regulator data
sheet
18. TPS40054, TPS40055, TPS40057 Wide-Input Synchronous Buck Controller data sheet
19. TPS40170 4.5-V to 60-V Wide-Input Synchronous PWM Buck Controller data sheet
20. INA193, INA194, INA195, INA196, INA197, INA198 Current Shunt Monitor -16 V to + 80 V Common-
Mode Range data sheet
SLAA476B – February 2011 – Revised July 2019 Wide-Vin Battery Charger Using SMBus Communication Interface Between 41
Submit Documentation Feedback MSP430™ MCUs and bq Fuel Gauges
Copyright © 2011–2019, Texas Instruments Incorporated
Revision History www.ti.com
Revision History
NOTE: Page numbers for previous revisions may differ from page numbers in the current version.
Changes from July 26, 2011 to July 12, 2019 .................................................................................................................. Page
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2022, Texas Instruments Incorporated