Raspberry Pi I2C clock-stretching problem

The I2C slave that I’m developing has been failing intermittently.  I finally noticed this was a known bug in Raspberry Pi that mishandles clock stretching.

I2C slave may delay response by holding SCL low.  However, when the slave does it, the I2C master in Raspberry Pi gives very short clock for the first bit of the next byte.  The symptom can be seen as following picture.

10678616_689709434441211_7585444260259589843_n

More detail explanation can be read in this link:

http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html

In order to workaround this, I set data rate in I2C slave module higher.  The communication rate is 400 kbps, but I set the data rate 1000 kbps.  It worked for me.  Here is the setup of I2C slave module.

I2Cslave

 

Leave a Reply

Your email address will not be published. Required fields are marked *