SLUA475 November 2016 BQ2060A , BQ20Z80 , BQ40Z50-R1 , BQ40Z50-R2 , BQ40Z60 , BQ78350-R1 , BQ78350-R1A
The System Management Bus (SMBus) is the most common form of communication for Texas Instruments advanced fuel gauges. Many customers want to design SMBus engines to communicate with TI advanced fuel gauges. Though this is possible, these designs sometime lead to confusion and frustration. Investigating SMBus errors or transaction failures can seem to be a difficult or daunting task. The purpose of this application report is to reduce the complexity and make learning SMBus easier. This report assumes some knowledge of I²C.
All trademarks are the property of their respective owners.
Figure 1 shows some simple examples of generic SMBus transactions. These transactions are read/write words with and without packet error checking (PEC). Although a user's scope traces may not look exactly like these examples, it is easier to look at these theoretical examples and understand their content rather than considering actual scope traces. Examples of actual scope trace are given later in this document. Note that more detailed information can be gathered from these pictures than is discussed in this document. Simplified information is given in order to present only the basics of SMBus information. For most troubleshooting issues, the basics are all that users need to solve SMBus problems.
First, entire packets for read and write are examined. Only word communications are considered because they are common and relevant for most troubleshooting.
The following components make up the packet along with some of the relevant issues to consider.
To consider SMBus communication in more detail, Figure 2 shows an SMBus read word and zooms into one byte of a data packet and the NACK/Stop bit. This diagram gives examples of most of the important bits of a total packet.
Each byte is 8 bits long. Several things of interest can be derived by looking closely at this diagram:
The following are final considerations when examining all the points of a total packet.
Clock stretching is a simple way for the slave to indicate to the host that it is busy (see Figure 3). Any time the clock is low in the packet, the slave has the right to grab the clock and hold it low as long as required; however, the bit must not cause a packet timeout (25 ms).
The entire packet must not be longer than 25 ms, which includes the clock stretch. TI fuel gauges usually only clock stretch before or after the ACK or NACK bits.
Sometimes, a slave can become the master of the bus. The SMBus specification allows for this possibility. All of TI's advanced fuel gauges have this ability. Depending on the fuel gauge (FG), this feature can be enabled or disabled in different ways. If enabled, the FG as master causes the bus to send alarms and charging voltage and charging current every 10 to 20 seconds to the host (0x10) and charger (0x12) device addresses
An SMBus master can only start a packet if the SMBus has been idle for more than 50 µs. Once this requirement has been met, the master immediately takes control of the bus by sending a start bit. All TI FGs function exactly like this, and because they are hardware-controlled SMBus engines, the FGs easily detect idle.
This type of behavior is difficult to create for an SMBus engine implemented in firmware. It is easy to detect 50 µs of idle time, but the port pins used to create the bus must be switched to outputs, and the start bit must be sent. During this time frame, another master can actually take control of the bus. If another master controls the bus, the firmware-controlled bus does not detect that the bus is no longer busy, which causes arbitration to be lost.
Because of this difficulty, most host systems do not recognize this part of the SMBus specification and, instead, act as the only master on the bus. Therefore, TI recommends that broadcasting messages be disabled for every application unless absolutely necessary.
PEC is a simple form of a checksum used for error checking. It is important to use PEC in all communications to ensure what was sent or received was actually intended. PEC is really just an extra byte of data added to the end of the communication packet that is derived from a simple CRC-8 checksum. All TI fuel gauges that support PEC also have the option to add PEC to the broadcast data if desired. However, most customers never use the broadcasts. Broadcasts must be completely disabled if not used.
A common question is Who sends (is responsible for) the PEC byte? For this discussion, assume the master is the host system (notebook, PC, or another host), and the slave is the fuel gauge. In read operations, the slave (fuel gauge) is responsible for sending the PEC packet to the host. Then the host determines if the PEC is valid. In a write operation, the host is responsible for sending the PEC to the slave. Though some slave devices may not be fast enough, a TI fuel gauge always NACKs the PEC byte if an error is in the packet, which can sometimes be confusing. Therefore, a simple and easy way to remember this is that the SMBus device, which is responsible for sending the data of the last byte of the packet, is the one responsible for the PEC.
The SMBus specification has much more information about PEC relating to protection against devices that do not perform the PEC function reliably; however, they do not apply to TI fuel gauges. TI parts use a hardware PEC lookup; therefore, software does not interfere with the process. With TI fuel gauges, an ACK to a bad data packet's PEC byte will never be occur, instead, a NACK to a bad data packet occurs.