Hi,
I have been fighting with a repeatable problem in the I2C subsystem that happens on startup and reboot. In a number of cases, the system will start with the I2C hardware state machine in an indeterminate state manifesting itself with the bus_busy flag of the i2c_dev_t structure already set prior to any I2C messages having been sent. This prevents all subsequent use of the I2C until a manual reset is performed. Even a soft reboot of the chip is insufficient to set the I2C state machine to a known starting state.
I have tried different methods to restart/reset the state machine such as:
- reconfiguring the I2C to operate in slave mode and then back into master mode
- running through the I2C startup steps again
- trying to change bus_busy flag to 0 manually
- trying to clear interrupt flag bits
- clearing the command buffer
- setting the done flag of the failed command in command buffer.
- adding clock toggle on the SCL line
Is there any known sequence of steps to get the subsystem into a known state or to restart via code?
Without a software solution, we will be forced to abandon the use of the module in production. It is working well in other respects and that would be unfortunate.
Thanks,
Jason
I2C bus_busy set on startup/reboot and no recovery option
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: I2C bus_busy set on startup/reboot and no recovery option
Strange... can you see if a combination of periph_module_disable(PERIPH_I2C0_MODULE); periph_module_enable(PERIPH_I2C0_MODULE); gets the FSM working again?
Re: I2C bus_busy set on startup/reboot and no recovery option
Thank you, that worked once I did these steps and reinitialized the I2C configuration. I did not see that specific information in the documentation or the forum search. It would be helpful to have it explicitly defined in the documentation here:
http://espressif.com/sites/default/file ... ual_en.pdf
Thanks,
Jason
http://espressif.com/sites/default/file ... ual_en.pdf
Thanks,
Jason
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: I2C bus_busy set on startup/reboot and no recovery option
Agreed. I'll see if I can get the dev who's looking at it to talk to the doc team to add this to the TRM and/or ECO.
Re: I2C bus_busy set on startup/reboot and no recovery option
When should these bugfix be applied, can you run it at every boot? Could it be integrated in idf or arduino-esp32 by default? How would a code snippet look like?
This problem was also hitting me a few times!
This problem was also hitting me a few times!
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: I2C bus_busy set on startup/reboot and no recovery option
There should be no issue running it on every boot; as far as I can see, you may loose the state of the i2c peripheral but on boot there's nothing useful inthere anyway. We're still looking into the source of the issue, so we'll probably have some workaround in the future in esp-idf, but I can't tell you what one and when it'll be finished.
Re: I2C bus_busy set on startup/reboot and no recovery option
Good to hear! You can for post an update in this thread when a fix appears in idf/docs. I will add it now to my main.
Do I delay/NOP between the calls?
Do I delay/NOP between the calls?
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: I2C bus_busy set on startup/reboot and no recovery option
No need to, the reset should happen in a single clock cycle.
Re: I2C bus_busy set on startup/reboot and no recovery option
A reset method is now available in the Arduino master for the Wire library. You can use it as a part of recovery of the I2C under your own control.
Who is online
Users browsing this forum: No registered users and 59 guests