Texas Instruments | Using I2C Communication With the bq275xx Series of Fuel Gauges (Rev. B) | Application notes | Texas Instruments Using I2C Communication With the bq275xx Series of Fuel Gauges (Rev. B) Application notes

Texas Instruments Using I2C Communication With the bq275xx Series of Fuel Gauges (Rev. B) Application notes
Application Report
SLUA467B – May 2008 – Revised May 2014
Using I2C Communication with the bq275xx Series of Fuel
Gauges
Jeff Mueller and Ming Yu ................................................................ HVAL - Battery Management Solutions
ABSTRACT
This application report provides two examples that illustrate the bit-transaction details of I2C commands
used with the Texas Instruments bq275xx series of battery fuel gauges. The first example shows how to
implement a simple fuel gauge command that interrogates the gauge for reading cell voltage. The second
example shows the added bit transitions required to access a gauge subcommand, specifically requesting
firmware version information. Other I2C commands can be executed in the same manner, using the
methodology of these two examples.
Example 1: Reading Cell Voltage
I2C commands are always initiated by the host with a START (S) bit sequence, immediately followed by a
7-bit I2C address with the most-significant bit (MSB) sent first. An eighth bit of 0 is sent by the host,
indicating that the next byte to be sent will be a write to the gauge. For the bq275xx series of parts, these
8 bits form the byte 0xAA. Once the start bit and address byte have been successfully received by the
gauge, the gauge responds with an ACKNOWLEDGE (A) bit sequence. The gauge is now ready for the
subsequent command directive from the host. Further descriptions of the control bit sequences are
presented in the Glossary: Control-Bit-Sequence Definitions.
lsb
msb
HOST
S
lsb
I2C ADDR[6:0]
msb
0
Sr
0xAA
A
I2C ADDR[6:0] 1
msb
A
SLAVE
msb
lsb
GAUGE CMD [7:0]
A
0x08
A
lsb
DATA [7:0] (LSB)
N
msb
P
lsb
DATA [7:0] (MSB)
0xAB
2
Figure 1. Simple I C Command Transaction Sequence
After the successful transmission of the I2C address and read/write bit, the gauge command code can be
sent by the host, in this case 0x08 for the Voltage( ) command. The command code is actually a base
address location within the gauge and must not be confused with the I2C address for the gauge. Once this
location is sent by the host, the gauge responds by sending an ACKNOWLEDGE bit sequence and then
executing the corresponding command subroutine.
Even though two-byte locations are used for many gauge commands, writing to only the single byte is
required to start gauge command processing. In this case, only 0x08 was written to the gauge, even
though the command consists of the two consecutive command bytes 0x08 and 0x09. Most commands
consist of two bytes, because the data is returned to these command locations and are also two bytes –
the least-significant byte (LSB) is stored in the lower address (0x08), whereas the most-significant byte
(MSB) is stored in the higher address (0x09). Like the I2C address data, the gauge command is sent MSBfirst.
SLUA467B – May 2008 – Revised May 2014
Submit Documentation Feedback
Using I 2C Communication with the bq275xx Series of Fuel Gauges
Copyright © 2008–2014, Texas Instruments Incorporated
1
www.ti.com
The host initiates the reading of the command data by sending a REPEAT START (Sr) bit sequence. This
is immediately followed by the 7-bit I2C address of the gauge plus the read-bit directive (1), which together
create the byte 0xAB. The gauge responds with an ACKNOWLEDGE bit sequence, then takes control of
the data bus. The first data byte (LSB) is stored at the 0x08 location in the gauge and is strobed out by the
gauge MSB-first. If the host responds with an ACKNOWLEDGE bit sequence, the gauge automatically
increments the command location to 0x09, then strobes out the MSB stored there. If the host responds
with a NO ACKNOWLEDGE (P or NACK) bit transmission, no further data is spooled to the host. The host
terminates the present command packet by sending a STOP bit.
Example 2: Reading the Firmware Version
Reading the firmware version is an example of using the bq275xx subcommands. Subcommands are
unique, as they represent another level of depth into the gauge command structure. All subcommands are
accessed through the paired command locations at 0x00 and 0x01 in the gauge. The subcommands are
written LSB-first. Hence, to send the FW_VERSION subcommand (0x0002), the host writes 0x02 to
command location 0x00 and 0x00 to 0x01. Again, I2C always writes the MSB first.
The format for address/command/data exchange between host and gauge is similar to the previous
example and is shown in Figure 2. As in Example 1, the host initiates transmission with a START bit,
followed by the gauge I2C address and a WRITE bit of 0 (0xAA). The gauge responds with an
ACKNOWLEDGE, then the host specifies the command address of 0x00. Again, the gauge responds with
an ACKNOWLEDGE.
At this stage, the host must make additional writes to the gauge to set the subcommand code of 0x0002.
Hence, the host sends the low byte of the subcommand (0x02). The gauge acknowledges. Then the host
sends the high byte of the subcommand (0x00). The gauge issues an ACKNOWLEDGE. The host
completes the writing process by issuing the STOP bit sequence. Now the gauge is prepared to return
firmware information to the host.
msb
S
HOST
lsb
I2C ADDR[6:0]
msb
0
msb
lsb
GAUGE CMD [7:0]
A
SLAVE
A
0xAA
msb
lsb
SUB CMD[7:0] (LSB)
lsb
SUB CMD[7:0] (MSB)
A
0x00
P
N
0x02
0x00
Figure 2. I2C Subcommand Initiation Sequence
To start the reading process, the host proceeds in a manner similar to Example 1, by issuing a START (S)
bit sequence, immediately followed by the 7-bit I2C address of the gauge and the eighth bit of 0
(altogether, 0xAA for the bq275xx series of parts). The gauge responds with an ACKNOWLEDGE bit
sequence. The host sends the Control( ) command of 0x00, and the gauge acknowledges. The gauge
address location has now been set.
To retrieve the data at 0x00 and 0x01, the host proceeds as before. It initiates the reading of the
command data by sending a REPEATED START bit sequence. This is immediately followed by the 7-bit
I2C address of the gauge plus the read-bit directive (1), which together create the byte 0xAB. The gauge
responds with an ACKNOWLEDGE bit sequence, then takes control of the data bus. The first data byte
(LSB) is stored at the 0x00 location in the gauge and is strobed out by the gauge MSB-first. If the host
responds with an ACKNOWLEDGE bit sequence, the gauge automatically increments the command
location to 0x01, then strobes out the MSB stored there. The host terminates the entire command process
by sending a STOP bit.
msb
HOST
S
lsb
I2C ADDR[6:0]
msb
0
msb
lsb
GAUGE CMD [7:0]
Sr
lsb
I2C ADDR[6:0] 1
A
msb
A
SLAVE
0xAA
A
0x00
A
lsb
DATA [7:0] (LSB)
N
msb
P
lsb
DATA [7:0] (MSB)
0xAB
Figure 3. I2C Read Subcommand Sequence
2
Using I 2C Communication with the bq275xx Series of Fuel Gauges
Copyright © 2008–2014, Texas Instruments Incorporated
SLUA467B – May 2008 – Revised May 2014
Submit Documentation Feedback
Revision History
www.ti.com
Summary
In summary, remember the following critical aspects when implementing I2C communication between host
and bq275xx gauges:
1. Handshaking between the host and gauge is performed by five bit sequences: START, REPEAT
START, ACKNOWLEDGE, NO ACKNOWLEDGE, and STOP.
2. The I2C address and read/write bit is the first data item sent at the beginning of an I2C packet
transmission. The I2C address must not be mistaken for the command address in the gauge, the latter
being the second data field to be transmitted by the host.
3. The host initiates all communication to the gauge and uses the WRITE directive at the end of the I2C
address (total byte is 0xAA). When followed by the gauge command, this sets the command address
from which the host writes or reads gauge data.
4. When reading or writing multiple bytes, the host should use the base-address auto-increment feature
of the gauge, rather than specifying the gauge address location each time a byte is transferred.
5. Whether command address or gauge data, all I2C data is transferred between host and gauge with the
least-significant byte first.
6. All bytes transferred between host and gauge is transferred most-significant bit first.
Glossary: Control-Bit-Sequence Definitions
START: The START-bit sequence is a host-generated bit that begins the transmission of every packet. It
is defined by a high-to-low transition on the SDA line, while the SCL line is high.
REPEAT START: The REPEAT-START-bit sequence is also a host-generated bit. It has the same
characteristics as the START bit, but appears in the middle of a packet transmission. It tells the slave that
the gauge command (address) has been specified and data is ready for transfer to/from that command
address.
STOP: The STOP-bit sequence indicates the end of a transmission packet. It is consists of a low-to-high
transition of the SDA line, while the SCL line is high.
ACKNOWLEDGE: The ACKNOWLEDGE-bit sequence follows every (successful) data field sent between
the host and gauge. The device receiving the data field is responsible for sending the bit sequence. The
sequence consists of the SDA line being maintained in a low-status, while the SCL line is pulsed high.
NO ACKNOWLEDGE: The NO-ACKNOWLEDGE-bit sequence is frequently used by the host or gauge to
indicate the last data byte has been transmitted/received, and that the host should terminate the packet
with a STOP-bit sequence. It can also be used to indicate that an I2C device is not listening or capable of
responding to the host at a given time. The sequence consists of the SDA line floating in a high state,
while the SCL line is pulsed high.
Revision History
Changes from A Revision (May 2009) to B Revision ...................................................................................................... Page
•
Changed NO ACKNOWLEDGE to ACKNOWLEDGE ................................................................................ 2
SLUA467B – May 2008 – Revised May 2014
Submit Documentation Feedback
Revision History
Copyright © 2008–2014, Texas Instruments Incorporated
3
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and other
changes to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latest
issue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current and
complete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of sale
supplied at the time of order acknowledgment.
TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s terms
and conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessary
to support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarily
performed.
TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products and
applications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provide
adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or
other intellectual property right relating to any combination, machine, or process in which TI components or services are used. Information
published by TI regarding third-party products or services does not constitute a license 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 significant portions 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. TI is not responsible or liable for such altered
documentation. Information of third parties may be subject to additional restrictions.
Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or service
voids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice.
TI is not responsible or liable for any such statements.
Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirements
concerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or support
that may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards which
anticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might cause
harm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the use
of any TI components in safety-critical applications.
In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is to
help enable customers to design and create their own end-product solutions that meet applicable functional safety standards and
requirements. Nonetheless, such components are subject to these terms.
No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the parties
have executed a special agreement specifically governing such use.
Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use in
military/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI components
which have not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal and
regulatory requirements in connection with such use.
TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use of
non-designated products, TI will not be responsible for any failure to meet ISO/TS16949.
Products
Applications
Audio
www.ti.com/audio
Automotive and Transportation
www.ti.com/automotive
Amplifiers
amplifier.ti.com
Communications and Telecom
www.ti.com/communications
Data Converters
dataconverter.ti.com
Computers and Peripherals
www.ti.com/computers
DLP® Products
www.dlp.com
Consumer Electronics
www.ti.com/consumer-apps
DSP
dsp.ti.com
Energy and Lighting
www.ti.com/energy
Clocks and Timers
www.ti.com/clocks
Industrial
www.ti.com/industrial
Interface
interface.ti.com
Medical
www.ti.com/medical
Logic
logic.ti.com
Security
www.ti.com/security
Power Mgmt
power.ti.com
Space, Avionics and Defense
www.ti.com/space-avionics-defense
Microcontrollers
microcontroller.ti.com
Video and Imaging
www.ti.com/video
RFID
www.ti-rfid.com
OMAP Applications Processors
www.ti.com/omap
TI E2E Community
e2e.ti.com
Wireless Connectivity
www.ti.com/wirelessconnectivity
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2014, 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

Related manuals

Download PDF

advertising