Clock Stretching Allowed in I2C?
Page 1 of 1

Author:  starwarslegokid [ Tue Jul 21, 2009 5:41 pm ]
Post subject:  Clock Stretching Allowed in I2C?

Hello Everyone,

I have a question, Im helping someone program a custom I2C devise and am having problems reading bytes back from the device using the Test I2C terminal. We can write to the device and it responds correctly, its only when we try to read back that we get a buss error. We know the device is holding the clock line low while it processes information, does anyone know if RobotC allows the slave to hold the clock line low?

Any info would be great, thanks again B-)

Author:  mightor [ Wed Jul 22, 2009 1:18 am ]
Post subject:  Re: Clock Stretching Allowed in I2C?


I have no experience with clock stretching sensors but I know that quite a lot of drivers/implementations that I've come across have issues with it. It would be useful to have as a feature. Perhaps one of the devs can answer this?


Author:  starwarslegokid [ Wed Jul 22, 2009 2:50 am ]
Post subject:  Re: Clock Stretching Allowed in I2C?

Ill have to pester Dick then ;-).

Scott B-)

Author:  starwarslegokid [ Wed Jul 29, 2009 3:09 am ]
Post subject:  Re: Clock Stretching Allowed in I2C?

Dick emailed this to me:

No. Not possible with the NXT. It is not a "true" I2C implementation.

In standards compliant I2c, the clock line is "open collector" (a hardware term) which allows the I2C master to send clock pulses but it also allows the I2C slave to pull the line low (i.e. "your clock stretching") to delay the I2C transaction. Unfortunately, this is not the implementation on the NXT.
· Clock line is a digital output line that is either high or low. It is not open collector.
· NXT firmware does not check for “clock stretching”.
· NXT has a series resistor and a pullup resistor on the I2C clock and data lines. This is for protecting the NXT against static electricity and other bad things if someone puts the wrong signals into the sensor port. Unfortunately, the end result is that the NXT sensor I2C is slower than the I2C specification standard.

It is possible to setup an output line on the NXT as Open Collector. I tried this a few years back and found that none of the NXT’s I2C sensors would work with it.

Standard NXT firmware uses a a clock signal around 10KHz. ROBOTC has some options to work faster but you can configure for the slow mode.

So, unfortunately no way to stall the transaction like you’ve described below.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group