-
Notifications
You must be signed in to change notification settings - Fork 5
Adding a checksum (is almost useless)
A common way to increase the reliability for serial data is to add a checksum and start and stop markers. However, the I2C bus is not just a stream of serial data. It is a package of data with a certain protocol with the SDA and SCL signals.
In a noisy environment, a glitch on the SDA or SCL signal could result in a wrong data byte. That can be detected by adding a checksum. However, that is almost useless. A glitch could also result in a START or STOP condition, a wrong ACK or NAK, or a I2C device could enter a wrong or error state with too many or too little clock pulses. If a I2C bus is so bad that glitches can occur, then the I2C bus is not reliable and the I2C bus should be fixed. See the page: How to make a reliable I2C bus.
Extra data bytes means that it takes longer to transfer data, that also means that there is more chance for a glitch to appear. For the same reason, lowering the clock speed is not always better, because it takes longer to transfer data.
The worst case scenario is when the I2C gets stuck, because the SDA or SCL is held low by a I2C device. See the page about How to unlock a stuck I2C bus how to try to unlock a stuck I2C bus.
The goal should always be to have a I2C bus that is 100% reliable. The I2C bus is not a fault tolerant bus.