Skip to content

Can't reach low power mode on NRF52840 / nicenano / xiao ble, with TinyGo #4886

Description

@FlorianSoler

Hi,

I've been trying to get the nRF52840 into a proper low-power or deep sleep mode using TinyGo, but I'm running into problems. The [official low power docs](https://tinygo.org/docs/concepts/low-power/) mention using:

for {
    arm.Asm("wfi")
}

But when I measure current, it's still around 1.2 mA, which is way too high for a chip like the nRF52 that should be in the µA range when idle.

I also tried directly writing to the low power register:

func deepSleep() {
    const TASKS_LOWPWR_ADDR = 0x4000007C
    taskLowPower := (*volatile.Register32)(unsafe.Pointer(uintptr(TASKS_LOWPWR_ADDR)))
    taskLowPower.Set(1)
    device.Asm("wfi")
}

Still no improvement.

To verify, I ran similar logic on the same hardware using Arduino + Bluefruit and got proper low power results:

#include <Arduino.h>
#include <bluefruit.h>

void setup() {
    sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
    sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
    __WFE();
    __WFI();
    sd_app_evt_wait();
    NRF_POWER->SYSTEMOFF = 1;
}

void loop() {}

So the issue seems specific to TinyGo. Any working examples or advice on how to properly enter deep sleep on nRF52840 using TinyGo would be great.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions