Closed Deoptim closed 3 years ago
Hi,
can you please explain what the bug is and what kind of fix you propose?
Best, Bernhard
In any case, if you want to control the speed of TWI/I2C communication when using the hardware module (#define I2C_HARDWARE 1), then the best way to do that is to set the bit rate of the TWI module using the TWIBR register and the prescale value in the TWISR register (see function "fequency" in example/I2CShell.ino). When using the standard Wire library, also the setClock method will help.
Hello. When I use OLED display with FPS(GyverOLED) benchmark and Arduino Pro Mini (16MHz/5V):
My parameters to replace standard Wire.h lib:
Empirically, it was found that even the actual frequency of the MCU (8Mhz or 16Mhz) does not depend on the value 6400000UL - i.e. it is universal value for any MCU frequency and gives the maximum speed on the I2C bus.
Also tested with atmega8a (8MHz internal clock) and Arduino Pro Mini (8MHz/3.3V)
Wire.h
![Wire h](https://user-images.githubusercontent.com/5656726/130215211-b5801fb0-d9a3-4407-b584-c792a9a955b3.jpg)Commented out "//#define I2C_CPUFREQ 6400000UL"
![hardware](https://user-images.githubusercontent.com/5656726/130215488-536c6703-d01f-4e15-8a3f-335861382c2e.jpg)With "#define I2C_CPUFREQ 6400000UL"
![hardware_plus_6400000](https://user-images.githubusercontent.com/5656726/130215611-5a01c293-9d59-49f0-b76b-3db293312d12.jpg)