Software Development Guide
Software Development Guide
Application Report
BQ769x2 Software Development Guide
Matt Sunna
ABSTRACT
This application report provides examples of communication packets and sequences for the BQ769x2 device
family of battery monitors (which includes the BQ76952, BQ76942, and BQ769142). Examples include bit-
transaction details of direct commands, subcommands, and reads and writes to RAM registers. Examples
include instructions for using the BQStudio Command Sequence panel to perform these read and write
transactions. Simple code examples are also provided. Use this document along with the device-specific
Technical Reference Manual and data sheet. These documents are listed in Section 7. BQSTUDIO software
is also used for many examples and offers a convenient way to view all of the device registers. For the BQ769x2
device family, version 1.3.102 or above of BQStudio is required.
The BQ769x2 device family integrates three different communication interfaces - I2C, SPI, and single-wire HDQ.
The I2C and SPI interfaces include an optional CRC check. For the full list of options, see the device-specific
data sheet. This document covers many examples using the I2C interface and then covers some of the same
examples using SPI with CRC.
Table of Contents
1 Direct Commands................................................................................................................................................................... 3
1.1 Alarm Enable - 0x66...........................................................................................................................................................3
1.2 Cell 1 Voltage - 0x14.......................................................................................................................................................... 3
1.3 Internal Temperature - 0x68............................................................................................................................................... 4
1.4 CC2 Current - 0x3A............................................................................................................................................................4
2 Subcommands........................................................................................................................................................................ 6
2.1 DEVICE_NUMBER - 0x0001............................................................................................................................................. 6
2.2 MANUFACTURING STATUS - 0x0057.............................................................................................................................. 7
2.3 FET_ENABLE - 0x0022..................................................................................................................................................... 7
2.4 RESET - 0x0012................................................................................................................................................................ 7
3 Reading and Writing RAM Registers.................................................................................................................................... 9
3.1 Read 'Enabled Protections A'.............................................................................................................................................9
3.2 Enter CONFIG_UPDATE Mode....................................................................................................................................... 10
3.3 Write 'Enabled Protections A'........................................................................................................................................... 10
3.4 Write 'VCell Mode'............................................................................................................................................................ 11
3.5 Exit CONFIG_UPDATE Mode.......................................................................................................................................... 11
4 I2C With CRC.........................................................................................................................................................................12
5 SPI With CRC Examples.......................................................................................................................................................13
5.1 Direct Command Example: Alarm Enable - 0x66.............................................................................................................14
5.2 Direct Command Example: Cell 1 Voltage - 0x14............................................................................................................ 15
5.3 Subcommand Example: Device Number - 0x0001.......................................................................................................... 16
5.4 Subcommand Example: FET_ENABLE - 0x0022............................................................................................................ 16
5.5 Subcommand Example: RESET - 0x0012....................................................................................................................... 17
5.6 RAM Register Read Example: Enabled Protections A.....................................................................................................17
5.7 RAM Register Write Example: Enabled Protections A..................................................................................................... 18
6 Simple Code Examples........................................................................................................................................................ 19
7 References............................................................................................................................................................................ 21
8 Revision History................................................................................................................................................................... 21
List of Figures
Figure 1-1. Captured I2C Waveform for Setting Alarm Enable to 0xF082...................................................................................3
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 1
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
Trademarks [Link]
List of Tables
Table 1-1. Alarm Enable Command Description..........................................................................................................................3
Table 1-2. Cell 1 Voltage Command Description......................................................................................................................... 3
Table 1-3. Internal Temperature Command Description.............................................................................................................. 4
Table 1-4. CC2 Current Command Description........................................................................................................................... 4
Table 2-1. DEVICE_NUMBER Subcommand Description...........................................................................................................6
Table 2-2. MANUFACTURING STATUS Subcommand Description............................................................................................7
Table 2-3. FET_ENABLE Subcommand Description...................................................................................................................7
Table 2-4. RESET Subcommand Description..............................................................................................................................7
Table 3-1. Enabled Protections A Description............................................................................................................................. 9
Table 3-2. SET_CFGUPDATE and EXIT_CFGUPDATE Descriptions...................................................................................... 10
Table 3-3. VCell Mode Description.............................................................................................................................................11
Trademarks
All trademarks are the property of their respective owners.
2 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] Direct Commands
1 Direct Commands
A complete list of direct commands can be found in the device-specific Technical Reference Manual. The format
for a direct command is shown in the following examples.
1.1 Alarm Enable - 0x66
Table 1-1 shows the Alarm Enable command that uses command 0x66. By default, the register setting for
Alarm Enable is set to 0xF800. In the example, the setting is changed to 0xF082. The data is in little endian
format. The device address for the BQ769x2 is 0x10 (8-bits) where the LSB is the R/W bit. A direct command
follows the format I2C_Write(I2C_ADDR, Command, DataBlock), so for this example the command would be
I2C_Write(0x10, 0x66, [0x82, 0xF0]).
Table 1-1. Alarm Enable Command Description
Command Name Units Type Description
Mask for Alarm Status(). Can be written to change during operation to
0x66 Alarm Enable Hex H2
change which alarm sources are enabled.
Figure 1-1. Captured I2C Waveform for Setting Alarm Enable to 0xF082
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 3
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
Direct Commands [Link]
The Command Sequence module in the BQStudio software enables you to try commands. This tool can also be
used to create and save command sequences. The Transaction Log in this example shows all of the commands
that have been covered so far.
4 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] Direct Commands
BQStudio has an Auto Refresh on the Dashboard which periodically reads the registers of the device to refresh
the measurements displayed. When using the Command Sequence module, it is recommended to disable Auto
Refresh by clicking on the green banner. The banner will turn red to indicate Auto Refresh is disabled (see
Figure 1-6).
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 5
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
Subcommands [Link]
2 Subcommands
Subcommands use a different format from direct commands and are accessed indirectly using the 7-bit
command address space. They also provide the capability for block transfers. To issue a subcommand, the
command address is written to 0x3E/0x3F. If data is to be read back, it will be populated in the 32-byte transfer
buffer which uses addresses 0x40 - 0x5F. Multiple examples follow.
The timing required for the device to fetch data depends on the specific subcommand and any other processing
underway within the device, so it will vary during operation. The approximate times for each subcommand are
shown in the Technical Reference Manual. There are two approaches for addressing this timing when reading
data from a subcommand:
The simplest approach is to use a 2 ms wait time after writing to 0x3E/0x3F before reading the result from the
transfer buffer.
A second approach is described in Chapter 3 of the Technical Reference Manual. This approach is to
read from 0x3E/0x3F until the subcommand has completed operation. If the value returned is 0xFF, this
indicates the subcommand has not completed operation yet. When the subcommand has completed, the
value returned will match the command that was written. This response only applies to subcommands that
return data to be read back.
Certain subcommands write data to a register and must be followed by a write to 0x60/0x61 with the checksum
and length. This only applies to the FET_Control(), REG12_Control(), CB_Active_Cells(), and CB_SET_LVL()
subcommands. Examples for calculating checksum and length are provided in the next section since this is also
required when writing to RAM registers.
2.1 DEVICE_NUMBER - 0x0001
The device number can be read by first writing the subcommand number 0x0001 (little endian) to the command
address 0x3E. This is followed by reading from the data buffer at address 0x40. In this example, the device
number returned is 0x7694 (which represents BQ76942).
Table 2-1. DEVICE_NUMBER Subcommand Description
Command Name Data Units Type Description
Reports the device number that identifies
0x0001 DEVICE_NUMBER Device Number Hex U2 the product. The data is returned in little-
endian format
6 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] Subcommands
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 7
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
Subcommands [Link]
The Transaction Log in this example shows all of the commands that have been covered for executing
Subcommands.
8 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] Reading and Writing RAM Registers
Note
When writing to RAM registers, it is highly recommended to first enter CONFIG_UPDATE mode and
then perform the command to exit CONFIG_UPDATE mode once complete. This ensures stable
operation while settings are being modified.
Figure 3-1. Captured I2C Waveform for Reading 'Enabled Protections A' Register
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 9
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
Reading and Writing RAM Registers [Link]
10 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] Reading and Writing RAM Registers
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 11
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
I2C With CRC [Link]
The Transaction Log in this example shows all of the commands that have been covered for reading and writing
to RAM registers.
Figure 3-6. BQStudio Example Showing Execution of RAM Register Reads and Writes
Figure 4-1. Captured I2C Waveform for FET_ENABLE Subcommand With CRC
12 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] SPI With CRC Examples
Figure 4-2, using the VCell 1 command, the CRC for the first byte is computed for [0x10 0x14 0x11 0x68] - the
resulting CRC is 0x33. The CRC for the second byte [0x0B] is 0x31.
Figure 4-2. Captured I2C Waveform for VCell 1 Command With CRC
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 13
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
SPI With CRC Examples [Link]
14 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] SPI With CRC Examples
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 15
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
SPI With CRC Examples [Link]
16 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] SPI With CRC Examples
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 17
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
SPI With CRC Examples [Link]
18 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] Simple Code Examples
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 19
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
Simple Code Examples [Link]
def crc8(b,key):
crc = 0
ptr = 0
for j in range(len(b),0,-1):
for k in range(8):
i = 128 / (2**k)
if ((crc & 0x80) != 0):
crc = crc * 2
crc = crc ^ key
else:
crc = crc * 2
if ((b[ptr] & i) != 0):
crc = crc ^ key
ptr = ptr + 1
return crc
##########################################
# Start of Main Script
##########################################
################ Direct Command Examples ################
#Write Alarm Enable to 0xF082
I2C_Write(I2C_ADDR, 0x66, [0x82, 0xF0])
#Read Voltage on Cell #1
result = I2C_Read(I2C_ADDR, 0x14, 2)
print "Cell 1 = ", (result[1]*256 + result[0]), " mV"
#Read Internal Temperature
result = I2C_Read(I2C_ADDR, 0x68, 2)
print "Internal Temp = ", ((result[1]*256 + result[0])/10 - 273.15), "degrees C"
#Read CC2 Current Measurement
result = I2C_Read(I2C_ADDR, 0x3A, 2)
print "CC2 = ", (result[1]*256 + result[0]), " mA"
################ Subcommand Examples ################
#Read Device Number
b = DataRAM_Read(0x0001,6)
print "Device_Number = " '{0:04X}'.format(b[1]*256+b[0])
#Read Manufacturing Status
b = DataRAM_Read(0x0057,2)
print "Manufacturing Status = " '{0:04X}'.format(b[0]+256*b[1])
## Command-only Subcomands ##
#FET_ENABLE
I2C_Write(I2C_ADDR, 0x3E, [0x22, 0x00])
#RESET - returns device to default settings
I2C_Write(I2C_ADDR, 0x3E, [0x12, 0x00])
sleep(1)
############ Reading and Writing to RAM Registers ##########
# Read 'Enabled Protections A' RAM register 0x9261
b = DataRAM_Read(0x9261,1)
print "Enabled Protections A = 0x" '{0:02X}'.format(b[0])
#Set CONFIG_UPDATE Mode (RAM registers should be written while in
#CONFIG_UPDATE mode and will take effect after exiting CONFIG_UPDATE mode
I2C_Write(I2C_ADDR, 0x3E, [0x90, 0x00])
#Write to 'Enabled Protections A' RAM register to enable CUV protection
DataRAM_Write(0x9261, [0x8C])
#Write to 'VCell Mode' RAM register to configure for a 9-cell battery
DataRAM_Write(0x9304, [0x03, 0x7f])
#Exit CONFIG_UPDATE Mode
I2C_Write(I2C_ADDR, 0x3E, [0x92, 0x00])
# CRC8 Example Calculation
TestValue = [0x10, 0x14, 0x11, 0x68]
crcKey = 0x107
check = 0xff & crc8(TestValue,crcKey)
print "crc8 check = 0x" '{0:02X}'.format(check)
The output from running the example Python script on a BQ76942 Evaluation Module follows.
Cell 1 = 3700 mV
Internal Temp = 25.05 degrees C
CC2 = 7 mA
Device_Number = 7694
Manufacturing Status = 0040
Enabled Protections A = 0x88
crc8 check = 0x33
20 BQ769x2 Software Development Guide SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
[Link] References
7 References
• Texas Instruments: BQ76952 3S-16S Battery Monitor and Protector Data Sheet
• Texas Instruments: BQ76942 3S-160S Battery Monitor and Protector Data Sheet
• Texas Instruments: BQ76952 Technical Reference Manual
• Texas Instruments: BQ76942 Technical Reference Manual
8 Revision History
NOTE: Page numbers for previous revisions may differ from page numbers in the current version.
SLUAA11B – FEBRUARY 2020 – REVISED AUGUST 2021 BQ769x2 Software Development Guide 21
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
IMPORTANT NOTICE AND DISCLAIMER
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATA SHEETS), DESIGN RESOURCES (INCLUDING REFERENCE
DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS”
AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD
PARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate
TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable
standards, and any other safety, security, regulatory or other requirements.
These resources are subject to change without notice. TI grants you permission to use these resources only for development of an
application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license
is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you
will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of these
resources.
TI’s products are provided subject to TI’s Terms of Sale or other applicable terms available either on [Link] or provided in conjunction with
such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicable warranties or warranty disclaimers for
TI products.
TI objects to and rejects any additional or different terms you may have proposed. IMPORTANT NOTICE
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2022, Texas Instruments Incorporated