SLUA475 November   2016 BQ2060A , BQ20Z80 , BQ40Z50-R1 , BQ40Z50-R2 , BQ40Z60 , BQ78350-R1 , BQ78350-R1A

 

  1.   SMBus Made Simple
    1.     Trademarks
    2. 1 Getting to Know SMBus
      1. 1.1 Closer Inspection
      2. 1.2 Final Considerations
        1. 1.2.1 Clock Stretching
        2. 1.2.2 Broadcasting (Master Mode Messages)
        3. 1.2.3 PEC
          1. 1.2.3.1 How to Calculate PEC
        4. 1.2.4 Examples
          1. 1.2.4.1 Example 1
          2. 1.2.4.2 Example 2
          3. 1.2.4.3 Example 3
          4. 1.2.4.4 Example 4
    3. 2 Most Common Problems
    4. 3 Glossary
    5. 4 References
  2.   A SMBus Reference Sheet
    1.     19

How to Calculate PEC

PEC calculations take some resources by the host system unless it has a hardware PEC engine. Although this document does not detail about how to do these calculations, many resources are available on the Internet, which include explanations and even code examples. Do an Internet search for PEC or CRC-8 computation. For an example of an online calculator that can check your code, refer to http://smbus.org/faq/crc8Applet.htm.

The following are two primary methods to calculate a PEC for a given data packet. Depending on your host CPU and memory, one of these methods should work for your application.

  1. A lookup table method is time efficient. However, it requires a large data memory to implement.
  2. Direct calculation of the PEC is simple to understand and takes little program memory; however, it is an iterative process that takes CPU time.

Consider the use of a logic analyzer or bus snooper for PEC calculations. Though a logic analyzer or a bus snooper may appear to be the simplest tools to monitor the SMBus traces, the following are a few of many reasons why an oscilloscope is preferable.

  1. A logic analyzer only shows a vague or high level piece of what is actually on the bus (see Figure 4). A logic analyzer shows only transitions, not rise times, noise, or any other electrical aspects of the bus. It is necessary to see all the information when troubleshooting. A logic analyzer is a fine tool to see what is happening on a bus that has no issues. However, when working with critical communication failures, more detail is required than is available from a logic analyzer.
  2. analizer_lua475.gifFigure 4. Oscilloscope Versus Logic Analyzer Comparison
  3. A bus snooper is a tool that logs communications, and in that log, reports ASCII text representing what is happening on the bus. It gives information at an even higher level than the logic analyzer. The following are several lines out of a log file:
  4. Msg 11 [S]#16 [A] #0E [A][S] #17 [A] #8C [A] #86 [A] #D8 [N][P] Msg 12 [S]#16 [A] #0E [A][S] #17 [N]

It is apparent that this communication has a problem: the device NACKed its device address after the repeated start.