Help needed to power down a Nokia 3310 LCD.

I've got a Nokia 5110/3310 LCD in my project, and I'm controlling it using the adafruit library GitHub - adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library: Arduino driver for PC8544, most commonly found in small Nokia 5110's and all is well. Except I'm trying to achieve ultra-low power consumption when my project is sleeping.

The LED's are connected to a mosfet on a digital pin, so they can be shut off. But the logic supply is always on, and can't be rerouted to a digital pin due to the pcb already being made.

In the data sheet here it mentions a power_down mode, but the ram needs to be filled with 0's before entering it.

I can't find any mention of this power_down mode being able to be implemented anywhere though.

Can anyone tell me how to activate it?

The backlight consumes the most power. Switch off when unused.

The PCD8544 will consume a small amount when active. You can switch off power to the VCC pin.
The GPIO pins of your AVR might source / sink current when outputs or with internal input with pullup.

Most TFT controllers can sleep or be switched off in software.
The PCD8544 does not have these specific commands but it does have the PD bit.

8.3 Function set
8.3.1 BIT PD
· All LCD outputs at VSS (display off)
· Bias generator and VLCD generator off, VLCD can be
disconnected
· Oscillator off (external clock possible)
· Serial bus, command, etc. function
· Before entering Power-down mode, the RAM needs to
be filled with ‘0’s to ensure the specified current
consumption.

You generally know what is on the display. So clear the screen (write 0s to RAM) and then set the PD bit. When you "wake up" you redraw the screen.

If you are using an Arduino, the USB chip, regulators, Arduino system will be far more significant.

David.

Edit. Correct the PCD8544 part number. Clarify the PD strategy.

I’m wondering how to set the ram to 0’s and set the PD bit high (I’m still learning this coding stuff).

From the CPP file of my lcd library I’m wondering if

clearDisplay

fills the ram with 0’s? Or there’s also a commented out function below it that appears to “clear” the ram (not sure if that means fill with 0’s) without touching the display data buffer in the arduino.

// clear everything
void Adafruit_PCD8544::clearDisplay(void) {
  memset(pcd8544_buffer, 0, LCDWIDTH*LCDHEIGHT/8);
  updateBoundingBox(0, 0, LCDWIDTH-1, LCDHEIGHT-1);
  cursor_y = cursor_x = 0;
}

/*
// this doesnt touch the buffer, just clears the display RAM - might be handy
void Adafruit_PCD8544::clearDisplay(void) {
  
  uint8_t p, c;
  
  for(p = 0; p < 8; p++) {
    st7565_command(CMD_SET_PAGE | p);
    for(c = 0; c < 129; c++) {
      //uart_putw_dec(c);
      //uart_putchar(' ');
      st7565_command(CMD_SET_COLUMN_LOWER | (c & 0xf));
      st7565_command(CMD_SET_COLUMN_UPPER | ((c >> 4) & 0xf));
      st7565_data(0x0);
    }

Have I understood that correctly?

And how do you set the PD bit high? At the moment I’m only using the functions of the library, I’m not sure how to send custom SPI data.

Here’s my concept code (not what’s being used but it’s for demonstration purposes here).

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// Software SPI (slower updates, more flexible pin options):
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

byte lcdled = 12; 

void setup() {
  Serial.begin(9600);

  display.begin();
  display.setContrast(50);
  display.display();
  pinMode(lcdled, OUTPUT);      // sets the digital pin as output
  digitalWrite(lcdled, HIGH);   // sets the LED on
  

}

void loop() {


//*** do lots of things, when ready, progress to sleep mode below

//***put lcd sleep code here****

  digitalWrite(lcdled, LOW);   // turn off backlight.
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
  display.begin();          //this part re-initialises the screen.
  display.setContrast(50);
  display.display();

}

If you can throw in a little knowledgeable magic my way to help me on my way, it’d be much appreciated. Plus the odd annotation would help me learn and not just repeat what others do.

Cheers :slight_smile:

Can anyone help me with how to set the PD bit high and confirm that the clear.display command does fill the ram with 0's as required?

Untested.

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// Software SPI (slower updates, more flexible pin options):
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

    ...
    display.clearDisplay();   //write 0 to shadow buffer
    display.display();        // copy buffer to display memory
    display.command( PCD8544_FUNCTIONSET | PCD8544_POWERDOWN);
    ...

Try it for yourself.

David.

@david_prentice

Thanks for the hint. It is working Perfect.