How to implement Clock Stretching in I2c for Slave?
I have configured I2C0 as Slave. On reads from master - I need to support clock stretching after address ACK. Any help is appreciated?
Hi,
Pls refer to the section 15.6.16 in UM11065.pdf, after you have received the data as I2C slave via polling mode or interrupt mode with status register, you can read it from MONRXDAT register, if you want to extend the I2C lock LOW time, you can set the I2C->CFG[MONCLKSTR] bit, the slave will drive the SCL low until the bit is cleared.
Hope it can help you
BR
XiangJun Rong
Thanks XiangJun Rong for the reply.
Here I think we are trying to stretch before ACK pulse of I2C. I want to stretch after I send ACK to master, i.e. Master starts read operation, after sending slave address, slave acks, immediately post ACK, I need to stretch clock low until data is ready in the slave. Thanks
Hi,
As I said that you can set the I2C->CFG[MONCLKSTR] bit, the slave will drive the SCL low until the bit is cleared.
But it is a question when you set the I2C->CFG[MONCLKSTR] bit, you can poll the I2C status register STAT[SLVSTATE], when the STAT[SLVSTATE]=01 in binary, you know that the lpc804 i2C slave has received data, I think the ACK signal is driven by receiver automatically, then you can poll the STAT[SLVPENDING] bit, if it is 1, it means that ACK has driven out, you can set the I2C->CFG[MONCLKSTR] bit to stretch the SCL low.
Pls I never test above, pls have try.
BR
XiangJun Rong