-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Update core_esp8266_si2c.c #4070
Conversation
Add 'clockCount' decrement, while-loop, twi_status()
Add 'clockCount' decrement, while-loop, twi_status() |
I don't know the max. clock cycles required to reset an I2C bus, but I suspect that it's device dependent. I've seen 9 or 10 clock cycles given in some data-sheets, and the DS3231 RTC data-sheet (the device giving me problems) just tells you to clock until you clear the bus:
I believe the source of the '20' clock cycles can be found here: The author, @drmpf, however, doesn't given the reason why he picked 20 as a maximum (you might ask him). As for solving my own problem, I ultimately chose to power-cycle all the devices on the I2C bus, at which point I stopped researching the issue. Unless I could find the required number in a definitive I2C spec., I would leave things alone (maybe @miky2k has seen the spec and can provide a link) Sorry I can't give you a better answer. |
Indents in changed function, removed superflous else
Add 'clockCount' decrement, while-loop, twi_status()
While researching solutions for a stalled I2C bus, I found the following issue and pull-request:
I2C bus reset with status info to user, re issue 1025 #2058
method for recovering I2C bus #1025
The software provide by both @drmpf and @dave-prosee both worked fine, but the while-loop inside Dave's 'twi_status()' seems to be missing a 'clockCount' decrement, as noted in pull-request #2058 by both @Frida854 and @vlast3k. This pull-request adds the missing decrement.
The following code was used for testing: