lpcware

LPC4350 I2C Error Recovery

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by gregd on Thu Apr 18 10:29:51 MST 2013
<p style="font-family: Roboto, sans-serif; font-size: 14px; background-color: #f0f0f0;">I have a design based on the LPC4350 that uses several I2C devices connected on I2C0 and I2C1.  During my develpment I have seen several instances where the board would fail to boot up my code properly becasue the SDA line is stuck low on one of the external devices causing the code to get stuck in the I2C_Start function.  I am assuming that this is due to the development process where I am starting/stopping the debugger etc...  causeing one of the external I2C devices to become out of sync.  This should not normally occur in the field but I am sure that it can and will on rare occasions due to noise, etc..  I would like to make sure that the I2C driver is robust enough to recover from these situations when possible.  
<p style="font-family: Roboto, sans-serif; font-size: 14px; background-color: #f0f0f0;">I am currently using the old LPC43xx CMSIS Driver Library but plan to upgrade to using LPCOpen in the near future.  I know that there are changes being made to the LPCOpen I2C driver for code size and effeciency.  Is support also being added to allow recovery from the situation above?  If the SCL line could be clocked when SDA is held low by an external device, it would probalby allow the external device to get back in sync and recover as described in the LPC4300 user manual under the section "i2c-bus obstucted by a LOW level on SCL or SDA".  I didn't see an easy way to simply pulse the SCL line since it is not mapped to a GPIO on I2C0.  If you set the STO flag while the STA flag is still set and force access to the bus (like described in the "Forced access to the I2C-bus", that seems like it may allow the I2C communication to continue and possibly resolve the SDA stuck low condition.  It may also be possible to connect another GPIO line to the SCL line and manually generate the clock pulses to get the external device in sync but it would be much cleaner if the I2C module can handle directly with a standard driver.
<p style="font-family: Roboto, sans-serif; font-size: 14px; background-color: #f0f0f0;">Is this support planned in the next release of LPCOpen?
<p style="font-family: Roboto, sans-serif; font-size: 14px; background-color: #f0f0f0;">Thanks,
<p style="font-family: Roboto, sans-serif; font-size: 14px; background-color: #f0f0f0;">Greg Dunn

Outcomes