Faster I2C on Atmega328?

Greetings my fellow makers!

I am into an arduino promini based project, that will utilize 3 different I2C devices, and normally this takes a bunch of runtime, about 40 frames/loop, worst case. Of course I would like to keep the project at the lowest possible runtime, with fixed looptime.

For this reason, I began to look for a way to increase I2C clock of the board, but I was not satisfied with 400kHz, so I searched further. After a while I did find a way, that seems too simple to be true.

There is a register called TWI Bit Rate Register, that is used by the atmega to set I2C clock frequency, in the following context:

FSCL = Fclock/(16+2TWBRPrescaler)

I have hooked up a quick test circuit with a cheapo 24MHz logic analizer and a PFC8574 based LCD driver board, because I did not have anything else laying around. However PFC8574 is sold as a 100 kHz IIC device, it did not seem to have any problem with handling higher clock frequencies. The test code is very simple, I was sending a constant LCD.print("0").

My experiences are summarized in the following chart:

TWBR SCL Frame time ACK
72 100kHz 209us Yes
12 400kHz 63,5us Yes
8 500kHz 53us Yes
6 571kHz 48,75us Yes
4 667kHz 43,75us Yes
3 727kHz 41,375us Yes
2 800kHz NAK NO
1 889kHz NAK NO

I have also created a dump of the signals, and compared the 100kHz, most reliable signal, to the 727kHz, least reliable acknowledged one. They show 100% match.

However 41,3us frame time is almost 80% progress compared to the original 100kHz one, and about 35% compared to the required time for a single package at 400 kHz, I am realy interrested if this speed is only limited by the PFC8574 to 727kHz, and if it can be increased with a better slave.

I have a few more advanced I2C devices on the way, with 1MHz I2C support, and I will do the same test with those, to see if the Arduino meets the 1MHz absolute limit for the atmega328.

In the mean time let me know, what do you think about this whole "fight for I2C overclocking"? Are there any possible sideeffects?

robinson01:
However PFC8574 is sold as a 100 kHz IIC device

.................

In the mean time let me know, what do you think about this whole "fight for I2C overclocking"? Are there any possible sideeffects?

Of course; there are very obvious 'possible sideeffects'. If you exceed the data sheet specifications then the I2C device could stop responding or the Arduino could lock up.

Whether its worth the risk depends on whether the project needs to be reliable.

I have also created a dump of the signals, and compared the 100kHz, most reliable signal, to the 727kHz, least reliable acknowledged one. They show 100% match.

Take a look at the signals with a scope. I'm quite sure you'll see differences. I2C is a bus that is passively pulled high. Sure you can lower the resistor values of the pull-ups but most chips can sink about 3mA at most so you are quite limited in increasing the speed anymore. If you can keep the bus capacitance low (you used just one device on the bus additionally to the master) this might work for some time but if you have 3 or 4 devices on the bus the capacitance will be significantly higher and the edges smoother. I'll bet at some value you will loose the signal completely.

+1 for Pylon.

If you use a higher speed you should consider using smaller pull up resistors so the signal has sharper edges.
(e.g. 4K7 iso 10K) Many devices can work above spec, but it can happen that different batches behave differently.

You can do quick testing with my multiSpeedI2CScanner found here