tiny-i2c icon indicating copy to clipboard operation
tiny-i2c copied to clipboard

Timing issues with a SSD1306 OLED

Open Karl255 opened this issue 1 year ago • 3 comments

I've been having some issues with this library when using it with an SSD1306 OLED screen where the communication would completely break, usually only in the first second or two since power up. Although I managed to fix that by editing the delay times in TinyI2CMaster.cpp (lines 24 and 25):

#define DELAY_T2TWI (_delay_us(1.3))   // >1.3us
#define DELAY_T4TWI (_delay_us(0.6))   // >0.6us

This works because the _delay_us() function takes a double and converts it to a cycle-accurate delay. The floating point math gets optimized away by the compiler.

After changing those lines everything worked flawlessly. I guess the SSD1306 is sensitive to low communication speeds. I didn't try this for low speed mode.

Karl255 avatar Feb 21 '23 09:02 Karl255