Skip to content

Wire library lockups recoverable with timeout but without hardware reset #326

@matthijskooijman

Description

@matthijskooijman

#42 is about adding timeouts to the Wire library to prevent lockups. One well-diagnosed case is when noise causes the TWI hardware to think there is a second master and lock up indefinitely until the other master is done. This can only be resolved by resetting the TWI hardware.

However, there is a "jm_Wire" library that implements timeouts but not the hardware reset, which does seem to solve lockup problems for some people, making me suspect there is another failure mode that would be useful to understand better. To prevent clutter in #42, I've opened this issue to further investigate.

I think that in some cases, a timeout without reset could indeed prevent lockups, even if not actually allowing further I2C communication afterwards.

However, the following post triggered my interest, since it mentions disconnecting an I2c slave triggering a lockup, which I can't quite understand. A missing slave should result in a NAK on the address byte, which should be handled as an error by an unmodified Wire already:

Originally posted by @Hyperdimensionals in #42 (comment)

In case this is useful testing data, jm_Wire.h fixed my problem mentioned above with my DS3231SN real time clock module, and I can now fully disconnect it from my Uno R3 without it blocking.

@Hyperdimensionals, could you expand a bit on this case? Does the lockup only occur when disconnecting the module at runtime, or also when it is disconnected already at powerup? Can you still reproduce it? If so, could you share the sketch that shows the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions