← index #2419Issue #1765
Related · high · value 0.934
QUERY · ISSUE

I2C bus recovery

openby deshipuopened 2016-09-14updated 2024-09-29
enhancementports

I wonder how useful would it be to add a bus recovery mechanism to the software I2C implementation. It would be something similar to what is discussed here: https://github.com/esp8266/Arduino/issues/1025

The particular use case is when either the slave or the master get reset in the middle of a transmission, and leave the bus in inconsistent state, usually with the other party pulling one of the lines down and preventing communication. This can easily happen when we are doing aggressive power management, entering deep sleep or cutting power to the sensors.

The proposed solution is to strobe the clock line several times and send a NACK, to make sure all the devices on the bus get to finish the last byte they were sending.

CANDIDATE · ISSUE

unable to recover from I2C bus error

closedby PeterKenyonopened 2016-01-04updated 2016-11-11
bugports

OK this version (1.5.2) has introduced a breaking change for I2C.
It is impossible to recover from an I2C bus error

1.5.1
from pyb import I2C
i2c=I2C(2,I2C.MASTER)
i2c.mem_write(8,76,112) # force a reset causes i2c error (but not until we next do a read)
i2c.init(I2C.MASTER) # reset the i2c bus to recover
i2c.mem_read(1,76,112) # works

1.5.2
from pyb import I2C
i2c=I2C(2,I2C.MASTER)
i2c.mem_write(8,76,112) # force a reset causes i2c error
i2c.init(I2C.MASTER) # reset the i2c bus to recover
i2c.mem_read(1,76,112) # nope doesnt work OSError 116
i2c=I2C(2,I2C.MASTER) # see if this works
i2c.mem_read(1,76,112) # nope doesnt work

see:
http://forum.micropython.org/viewtopic.php?f=2&t=1027

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied