forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
CircuitPython version
error present in:
Adafruit CircuitPython 8.0.0-beta.3, RP2040 Stamp with rp2040
Adafruit CircuitPython 8.0.0-beta.4 on 2022-10-30; RP2040 Stamp with rp2040
problem absent in:
Adafruit CircuitPython 8.0.0-beta.1 on 2022-10-01; RP2040 Stamp with rp2040
Code/REPL
import board
from i2ctarget import I2CTarget
i2c_pins = {'scl': board.GP21, 'sda': board.GP20}
i2c = I2CTarget(**i2c_pins, addresses=(0x33,))
while True:
print("start")
req = i2c.request() # also happens with timeout=-1, timeout=0.000001
if not req:
continue
Behavior
It blocks in the first iteration:
start
then nothing happens until interrupted with CTRL+C:
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
KeyboardInterrupt:
OTOH in beta.1
, it will keep on looping:
start
start
start
start
start
start
start
start
start
Description
I noticed that on two identical boards I assembled a few weeks apart, i2c works on one but not the other. One board was on 8.0.0b3 and I tried updating it to 8.0.0b4 but it still didn't work. The other board is on 8.0.0b1 and works as expected (and as the documentation states).
Additional information
This can be worked around (poorly) by specifying a relatively low but nonzero timeout value, e.g. i2c.request(timeout=0.005)
, and wrapping the call in try/exept
.
However going too low with the timeout (0.00001 for example) again causes it to just block, which is odd.