Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 8 months ago.
How can I temporarily disable I2C and re-enable after?
I'm communicating with some devices via I2C that occasionally lock up and hold one the SDA line low. I've looked at the I2C lines and the pullups are sufficient (2.2k on 3.3V signals) to generate a nice clean waveform. Speed is 100kHz.
The general consensus on how to get them functioning again is to switch the I2C pins to GPIO pins temporarily, toggle the SCL back and forth to advance the device state machine, and then switch back to I2C mode again.
How do I do this?
1 Answer
5 years, 8 months ago.
If you're using ST then this may help if it is still current or similar in the later libraries, line 135 _HAL_I2C_DISABLE(hi2c); and _HAL_I2C_ENABLE(hi2c); on line 194.
May be easier to power down the device and restart.