10 years, 5 months ago.

KL25Z I2C clock stretching

Hello,

I'm trying to talk over I2C to a peripheral that stretches the I2C clock. From the KL25Z documentation, I see that clock stretching is supported but I don't see the clock stretched when using I2C.read / I2C.write.

The eval platform for the peripheral which I'm trying to communicate with does clock stretch so I know the peripheral is using this.

Does the I2C mbed library for the kl25z support clock stretching? Is there anything particular I need to do to enable this?

Thank you!

2 Answers

10 years, 5 months ago.

I2C clock stretching is done completely in hardware. In I2C the master is in control of the clock (SCL). When the master is ready to continue it releases the SCL line, which should then go to high level because of the I2C pull up resistors. When a slave wants to slow down the master because it has to complete some internal task it pulls SCL low for as long as it needs to complete that internal operation. The master will monitor the SCL line and delay until the slave has released it again and SCL rises.

Ryan Z
poster
10 years, 5 months ago.

Thanks for the quick answer. Not sure what is going on....

Are you sure that the peripheral is stretching SCL. It will only do so when needed. Perhaps it can simply keep up with the master. What is your transmission speed? You would typically see SCL stretching at the end of a completed byte transfer and before the next byte is transmitted. Examples are EEPROMs that need some time to write the received byte to the internal flash memory. Note that some masters will actually time-out when you stretch the clock too long. This would result in an aborted I2C message.

posted by Wim Huiskamp 17 Dec 2013