OLED_I2C and TIMER0 interrupt

Hi.

I have a TIMER0 interrupt that only increment a volatile int cnt++; and change the status of a volatile boolean Flag1ms=true;

This two variables are used to refresh in the loop{} some outputs states to produce a specific pattern of pulses and to pool a rotary encoder pin status.

If i do a Serial.print of the encoder status on the serial monitor, the output signals are perfectly stable in the oscilloscope and the changes on the rotary encoder and the push button are precise in the serial monitor.

If i try to do the same in the OLED_1306 with libraries OLED_I2C.h and OLED_I2C.cpp my signals go crazy and some pulses are missing.

My question is why the TWI influence the interrupts while serial doesn't?

Thank you for your time, and yes i have read:

OLED_I2C manual,
Gammon Forum : Electronics : Microprocessors : Interrupts, and
Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet, point 21.6

perhaps there is a way to use pool instead of interrupt for the I2C.

MENUTEST08.ino (16.1 KB)

Just for the people who arrive to this question, yes! If you stream to the oled you cant use timer interrupt.

Timer 0 is already used for the millis() and micros() functions.

There is no need to interfere with it in any way - millis() works just fine for timing things.