ssd1306 l2c + mega2560 with extremely long time communication

Hello guys.

This is a picture of the communication between L2C ssd1306 and mega2560 and external 4k7 pullup resistors .

The code is very simple.

Is this correct ? Almost 40ms to update a simple number on screen?

Thak you very much !

  while (true)
  {
    display.fillRect(0, 29, SCREEN_WIDTH, 9, BLACK);
    display.setCursor(0, 29);
    display.print(random(12));
    display.display();
    delay(200);
  }

display.display() copies the whole 128x64 buffer from SRAM in one burst.

The buffer is 1024 bytes @ 400kHz I2C it will take 1024 * 9 * 2500ns = 23.04ms
The buffer is 1024 bytes @ 100kHz I2C it will take 1024 * 9 * 10us = 92.16ms

Since you have a scope, you can see the I2C bus speed. Normally the SSD1306 is driven @ 400kHz.

Quite honestly an I2C SSD1306 works plenty fast enough.
If speed is important, buy the SPI version.

David.

Hi David.

Very nice to talk to you again!

As ALWAYS, crystal clear explanation.

Yes , Ill take the SPI version and replace it on my project!

Thank you very much!

Gibran

Please inspect your I2C bus traffic.
I would expect 400kHz clock without any gaps.
Hence my theoretical calculation possibly with some small housekeeping at the start.

From memory, SSD1306 will not work faster than 400kHz I2C.
But 8MHz SPI should be ok.
The Adafruit libraries should set a suitable speed.

David.

Yes I´ll do it !

Thank you !!