Low power issue when stopping the SPI

I am developing a very low power application (100µA) that use ePaper. I use the GxEPD2 library to access the display. It works perfectely.

But I have an extra consumption issue (+1mA) when I have used the ePaper write function. Even after having issued display.hibernate(), I guess the SPI clock does not stop, that could explain these extra consumption.

So is there a way to stop properly the SPI, because, once I have displayed something on the ePaper I dont need it any more and I am expecting the same consumption than before I call the display routine.

Hi there,

Man these e-papers are shredding the Tech world :grin:

SO it’s a PIN state… Was my first guess but I’ll give you the AI version.
"
You are spot on! A lingering pin state drawing power is a classic issue with the nRF52840, and it explains that exact +1mA jump perfectly.

On the nRF52840, when you initialize a hardware peripheral like the SPI master (SPIM), the underlying Nordic SDK/core configures the associated GPIO pins (SCK, MOSI, CS) into active output states. Even if you call display.hibernate() in the GxEPD2 library, that function only puts the e-Paper panel’s hardware controller to sleep—it does not cleanly de-initialize or release the microcontroller’s SPI peripheral pins.

Because the SPI pins remain driven high or low by the nRF52, they form a closed circuit with the e-Paper display’s onboard level shifters or internal resistors, constantly leaking current.

Here is exactly what needs to be suggested to fbd38 on the forum to drop that power draw back down to microamps:

The Fix: Explicitly Disabling the SPI Peripheral

To completely kill the power leak, they need to un-map and disable the SPI peripheral before going into deep sleep.

In the Adafruit nRF52 core (which the XIAO nRF52840 uses), SPI.end() is available, but sometimes it doesn’t cleanly clear the Nordic hardware register configurations. The most bulletproof way to fix this is to call SPI.end() and then explicitly force the data pins into a high-impedance, disconnected state.

Tell them to add a shutdown sequence right after calling display.hibernate():

display.hibernate();

// 1. Shut down the SPI hardware peripheral 
SPI.end(); 

// 2. Force the SPI pins into INPUT mode with NO pull-up/pull-down (High-Impedance)
// Replace these with whatever physical pins they mapped to the ePaper
pinMode(SCK, INPUT);
pinMode(MOSI, INPUT);
pinMode(EPD_CS, INPUT); 

// 3. Make sure the DC and RESET pins aren't leaking into the display either
pinMode(EPD_DC, INPUT);
pinMode(EPD_RST, INPUT);

The “Under the Hood” Nordic Issue

If they find that standard Arduino pinMode(pin, INPUT) doesn’t completely drop the current, it means the underlying Nordic SPIM driver instance is still hooked to the GPIO matrix. :backhand_index_pointing_left: :smiling_face_with_sunglasses: ***(it’s always the MATRIX )***They can force the hardware registers completely clear using the direct Nordic SDK commands:

to wake up and write to the screen again, they just call SPI.begin() and initialize the display class normally. This completely eliminates the 1mA ghost draw!

// Forcefully disable the SPIM3 or SPIM2 instance at the register level
NRF_SPIM3->ENABLE = 0; 

// Disconnect the pins physically from the peripheral
NRF_SPIM3->PSEL.SCK  = 0xFFFFFFFF;
NRF_SPIM3->PSEL.MOSI = 0xFFFFFFFF;
NRF_SPIM3->PSEL.MISO = 0xFFFFFFFF;

(You need to check if GxEPD2 is using NRF_SPIM2 or NRF_SPIM3 depending on the core version).

As it say’s and much testing with it, the Nrf Pin States for even interrupts, edge vs, level will sip more power

HTH
GL :slight_smile: PJ :v:

It’s the little things sometimes.