How to perform an I2C reset?

Hi,

I have a rebel I2C device that stops responding from time to time.
If I wanted to reset the bus somehow, what would be the proper steps to follow?

I'm thinking of this:

Wire.end();
Wire.reset();
Wire.begin();

I'm not sure if Wire.reset() should be called when the bus is being used; eg: before calling Wire.end().

References:
ref 1
ref 2

Thanks

You can just call Wire.reset(). You can only do it after previously initializing it using begin(), and reset() will initialize it again, so you should not call begin() again.

The only other thing is that reset() obtains the Wire lock, so make sure you've unlocked it first if you are using locking.

Wire.reset does a lot to release the I2C bus; the code looks similar for RTL872x:

2 Likes

This is cool, I had read about the trick of the 9 pulses in other places.
Thanks

There isn't really an I2C reset, the NXP I2C spec unlike other protocols doesn't explicitly define a reset sequence, so the reset sequence above only resets the interface on the slave/client device. Creating 9 clocks can get the device back into a known state, but you still may need a Power-on-Reset event to really reset the device.

For example, if the client device is holding SDA LOW, you can create the clocks until it gives up the bus, then you should be able to do a start-stop condition and presto, device is ready for the next transaction. If the device is still holding SDA LOW after the 9 clocks, then a POR must occur. Having a scope or logic capture will give you the details on what's occurring.

Hi Erik, yes I am aware that this reset does not exist at I2C level, and is only a list of things one can try to recover from a situation, and the result is not guaranteed.
I'll take this reset as a first measure, before executing a POR.
Thank you

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.