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?