-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I2C hangs when power removed from bus on nrf52840 #8093
Comments
This adds a check to make sure that SDA and SCL are in a sane condition before starting any I2C operation. If they are not it tries to rectify it, and then returns an error code if unable to do so.
Could this be related to the warning about not using one of the SPI periphs while on battery power detailed here? I know that's SPI and your issue is I2C but seems similar enough to bring up. |
@DJDevon3 I don't think so. This issue only occurs when the I2C bus pull-ups are unpowered - this leaves both SDA and SCL low (which is an invalid state for I2C). It also affects both TWIM peripherals, whereas the one you reference only affects SPIM3. Also this bug occurs both when battery and USB powered. |
@furbrain Sorry for the on-again off-again approval/revert of your #8094 PR. I realized this is another manifestation of an old issue, #2253. Rather than look for good initial conditions (which might change out from under us), I think adding a timeout, as suggested in #2253, would be a better solution, since a bad I2C device can hang the bus while a transaction is in progress. |
Yes, I think that could work, but would need to change to a callback related method. I disagree with the comment about the timeout not getting called in #2253 - could have the callback set a flag and then poll for this flag while checking the time and abort if the time increases by a certain amount before the flag is set. I'd be happy to look at this, though I have found a different route around this problem in my use case in any event. |
My main issue in doing this would be working out a good way to test that I haven't broken any I2C functionality. |
CircuitPython version
Code/REPL
Behavior
The code above gets as far as the second
print(imu.acceleration)
and then the device hangs and can only be recovered by a manual reset.Description
No response
Additional information
Debugging with STLINK-V2 identifies that the call to
nrfx_twim_xfer
incommon_hal_busio_i2c_write
is where the device hangsThe text was updated successfully, but these errors were encountered: