Nokia 5110 display and U8G problem

Using the graphics test example all is well, unless I add a delay outside the do loop. During the delay I lose the top of the display. In the example below I draw a simple grid, the photos are with and without the delay after the do loop

  u8g.firstPage();  
  do {
    // simple grid
    for (int i=0; i<48; i+=5) {
      u8g.drawLine(0,i,84,i);
    }
    for (int i=0; i<84; i+=5) {
      u8g.drawLine(i,0,i,48);
    }
  } while( u8g.nextPage() );

  // rebuild the picture after some delay
  //delay(5000);

With delay:

Without delay:

Top left corner is flickering

Any ideas as to what I’m doing wrong?

Hi, welcome to the forum.

Please show the whole sketch, or make a test sketch. http://snippets-r-us.com/

How is the display connected ? It can not be connected directly to a 5V Arduino.

It does it on the U8G GraphicsTest example sketch as well. All I did was replace what was drawn in the do loop to a grid to better show the problem. The display was connected to an Uno with 5V Vcc and I also tried with 3V3 Vcc and 10K to the 5V data lines, with same results.

U8G constructor was

U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);       // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8

Perfect grid, with or without the delay :D

Good : U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8 ) ; // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8

Bad : U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8 ) ; // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8

And yes, I can confirm that with the wrong controller, I also have a weak upper-left corner.