microcontrollercommunicationi2cmicroprocessors

Is it possible to verify the received slave data in i2C protocol


I recently came across one question related to the I2C protocol,

usually we read the data from the I2C slave devices and use it for the further calculations on the master side,

but can I be sure if the data I got is the data I wanted or is that corrupted while transmitting to the bus?

is there any possibilities to do so in I2C protocol?


Solution

  • In many cases, no, you can't be certain from software. You have to verify the design by hardware (with an oscilloscope) and then make sure nothing changes.

    However, some slave devices provide checksums or check bits on certain transactions that can be used to detect some faults.

    Reading a known value from the ID register at startup is usually good enough for most applications.

    Remember that if your data is getting corrupted then maybe your addresses are too, and that will cause ACKs to not be returned when you expect them.

    Many things you can do from software will not detect an error instantly though, so you need to think about how important or harmful it could be if an incorrect value is used. There are various standards that help you plan for this, such as ISO 14971 "Application of risk management to medical devices".