LPC11U24 I2C change frequency

04 Jan 2012

Hi,

I tried to set the I2C bus to a higher frequency using

I2C i2c(p28, p27);

i2c.frequency(400000);

my scope still shows around 96kHz on the clock line so it did not change the frequency at all. Did I miss something?

Regards Linus

05 Jan 2012

Hi Linus, thank you for the bug report.

The I2C API allows you to instantiate multiple I2C objects with different frequencies on the same pins. At each read/write the instance owns the bus and updates the frequency accordingly if the bus was owned by another instance.

The "frequency" method was relying on the acquiring of the bus for actually updating the frequency, this was not working when we were already the bus owners.

Cheers, Emilio

05 Jan 2012

Hi,

thanks for the reply. Will this tehen fixed in the next relese or is there any Workaround for the meantime? ....when is the next release scheduled?

Regards Linus

05 Jan 2012

Marcellinus Pfeiffer wrote:

when is the next release scheduled?

Tomorrow.

Emilio

05 Jan 2012

:)

Thanks!

06 Jan 2012

Released [rev 33] with the bug fix.

Cheers, Emilio

07 Jan 2012

Hi,

first, it changes the Frequency :)

But on the secondhand, it is off a little, is it supposed to?

If I set

i2c.frequency(475000);

i read at my Scope 403.2kHz

if I set

i2c.frequency(400000);

i read at my Scope 337.8kHz

if I set

i2c.frequency(100000);

i read at my Scope 96.15kHz

going higher it's even more off

if I set

i2c.frequency(800000);

i read at my Scope 609.8kHz

Of course, I can seek and set ... but maybe its fixeable ?

Regards Linus

09 Jan 2012

Marcellinus Pfeiffer wrote:

it is off a little, is it supposed to? i read at my Scope 403.2kHz

You should not look at a frequency, but at the duration of SCLH and SCLL.

The starting and ending conditions of I2C are going to introduce a big error in the reading of the signal interpreted as a clock.

At 400kHz you should see that both SCLH and SCLL are 1.25us.

At 100kHz you should see that both SCLH and SCLL are 5us.

Mind that at these frequencies some instruments can introduce a consistent percentage error.