Are there any problems with I2C slave devices?

Are there any problems with I2C slave devices?

There is no consistency in datasheets of I2C slave devices for specifying the device address, and even worse most vendors fail to specify which approach they use, leaving users to figure it out through trial and error.

Is there anything wrong with my I2C code?

In reality, there is nothing wrong with your code and simply removing and re-applying the power to the entire board will cause both the master and slave to be reset, leaving you able to communicate again.

What is the operation of the I2C bus?

The operation of the I2C bus is a read and write process between master and slave devices. There are mainly divided into 3 processes: Master device writes data to the slave device: The master device reads data from the slave device:

Are there any timeouts in the I2C protocol?

Since I2C is essentially transaction/packet based and it does not include timeouts in the specification (SMBUS does of course, but most slave sensors conform to I2C only) there is a real chance that you are going to reset your host processor (or bus master) in the middle of such a transaction.

How is the I2C bus designed to work?

Very often the peripheral will just blithely ack every byte that it reads from the slave regardless. The I2C bus is designed to be driven only through open-drain connections pulling the bus down, it is pulled up by a pair of pull-up resistors (one on the clock line and one on the data line).

What happens in the middle of an I2C transaction?

The result is that the slave thinks that it is in the middle of an I2C transaction and awaits the expected number of master clock pulses to complete the current transaction, but the master thinks that it should be creating a start condition on the bus.

When does a bus error occur in I2C?

Let’s understand different types of errors that may occur during I2C communication. 1.Bus error: This error happens when the interface detects an SDA’s rising or falling edge while SCL is high, occurring in a non-valid position during a byte transfer.

Are there any problems with the I2C standard?

I2C is such a widely used standard, yet it has caused me endless pain and suffering. In principle I2C is supposed to be simple and robust, a mechanism for “Inter-Integrated Circuit” communication.

How to get the bus unstuck in I2C?

Often getting the bus “unstuck” is as simple as providing the slave device enough clocks to convince it that the last transaction is complete. Some slaves behave well and after clocking them 8 times and providing a NAK they will abort their current transaction.

What should I do if my I2C transaction fails?

This means that typically you will need to disable the peripheral, change the pins to GPIO mode and bit-bang the clocks you need out of the port, after which you need to re-initialize the I2C peripheral and try the next transaction, and if this fails then rinse and repeat the process until you succeed.