Skip to content

NRF52832 not going back to sleep completely after a wait_ms() call #7847

Closed
@RobMeades

Description

@RobMeades

Description

I have a board on which I am using an NRF52832 (inside a u-blox NINA-B1 module). The board is for use in an energy harvesting application and hence low power consumption is absolutely critical.

The software behaviour is to run a timed EventQueue callback in which the main operations are performed. I can normally achieve ~2 uA current consumption for the NRF52832 outside the EventQueue callback unless I call wait_ms() inside the EventQueue callback; as soon as I call wait_ms() in the EventQueue callback (or elsewhere, for that matter) the current consumption jumps to ~7 uA and never, ever, comes down again.

You can see the effect in trace A:

trace_a

...whereas in trace B I have commented out the wait_ms() call and the power consumption recovers:

trace_b

My question is: how do I make the current consumption return to what it was before the wait_ms() call?

Here is my complete code (built for UBLOX_EVK_NINA_B1 and ARM tools), where the meat is in the wakeup() EventQueue callback. FYI, init_used_pins() calls into the Nordic HAL to set specific pins on our board for very specific purposes, which can be ignored; gpio16 is just wired to an LED to make it obvious where the EventQueue call occurs in the trace.

#include "mbed.h"

static EventQueue gWakeUpEventQueue(/* event count */ 10 * EVENTS_EVENT_SIZE);
static int wakeupCount = 0;

static DigitalOut gpio1(NINA_B1_GPIO_1, 0);
static InterruptIn gpio2(NINA_B1_GPIO_2);
static DigitalOut gpio7(NINA_B1_GPIO_7, 1);
static DigitalOut gpio16(NINA_B1_GPIO_16, 0);
static DigitalOut gpio17(NINA_B1_GPIO_17, 0);
static DigitalOut gpio18(NINA_B1_GPIO_18, 0);
static DigitalOut gpio20(NINA_B1_GPIO_20, 0);
static InterruptIn gpio22(NINA_B1_GPIO_22);
static AnalogIn gpio24(NINA_B1_GPIO_24);
static AnalogIn gpio25(NINA_B1_GPIO_25);
static DigitalOut gpio28(NINA_B1_GPIO_28, 0);
static I2C i2c(NINA_B1_GPIO_23, NINA_B1_GPIO_21);

static void wakeup(EventQueue *pEventQueue)
{
    gpio16 = 1;
    wait_ms(100);
    gpio16 = 0;
    wakeupCount++;
}

static void init_unused_pins()
{
    nrf_gpio_cfg(NINA_B1_GPIO_3,
                 NRF_GPIO_PIN_DIR_OUTPUT,
                 NRF_GPIO_PIN_INPUT_DISCONNECT,
                 NRF_GPIO_PIN_NOPULL,
                 NRF_GPIO_PIN_S0D1,
                 NRF_GPIO_PIN_NOSENSE);

     nrf_gpio_cfg(NINA_B1_GPIO_4,
                 NRF_GPIO_PIN_DIR_OUTPUT,
                 NRF_GPIO_PIN_INPUT_DISCONNECT,
                 NRF_GPIO_PIN_NOPULL,
                 NRF_GPIO_PIN_S0D1,
                 NRF_GPIO_PIN_NOSENSE);

     nrf_gpio_cfg(NINA_B1_GPIO_5,
                 NRF_GPIO_PIN_DIR_OUTPUT,
                 NRF_GPIO_PIN_INPUT_DISCONNECT,
                 NRF_GPIO_PIN_NOPULL,
                 NRF_GPIO_PIN_S0D1,
                 NRF_GPIO_PIN_NOSENSE);

     nrf_gpio_cfg(NINA_B1_GPIO_27,
                 NRF_GPIO_PIN_DIR_OUTPUT,
                 NRF_GPIO_PIN_INPUT_DISCONNECT,
                 NRF_GPIO_PIN_NOPULL,
                 NRF_GPIO_PIN_S0D1,
                 NRF_GPIO_PIN_NOSENSE);

     nrf_gpio_cfg(NINA_B1_GPIO_29,
                 NRF_GPIO_PIN_DIR_OUTPUT,
                 NRF_GPIO_PIN_INPUT_DISCONNECT,
                 NRF_GPIO_PIN_NOPULL,
                 NRF_GPIO_PIN_S0D1,
                 NRF_GPIO_PIN_NOSENSE);
}

int main()
{
    init_unused_pins();

    // Start the timed callback
    gWakeUpEventQueue.call_every(10000, callback(wakeup, &gWakeUpEventQueue));
    gWakeUpEventQueue.dispatch_forever();
}

Issue request type

[x] Question
[ ] Enhancement
[ ] Bug

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions