This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Simple nRF51822 sleep example

Is there an example for sleeping? I just want to put this thing to sleep drawing minimum current and have it wake up on a RTC timeout, but do not seem to be able to achieve anything less than 3.4mA.

Parents Reply Children
  • Thanks Stefan. That's exactly what I was looking for. I took the main.c from your system-on-wakeup-on-rtc example, removed the GPIO LED and buttons stuff and compiled it in our build environment (Ubuntu build machine/GCC) in place of our main.c. When I run it on the PCA1004 board though, it doesn't appear to be waiting for the RTC interrupt. I am using GDB and the J-Link Lite and I've set breakpoints in the ISR as well as after the __WFE(). Occationally (randomly) it hits the ISR breakpoint, but mostly it doesn't go to sleep and just skips over the WFE hiting my breakpoint straight after. The weirdest thing though is that if I remove that breakpoint to see what the current draw is and then hit pause, it ends up in a hardfault condition.

    EDIT: On further testing, it looks like the hardfault is occurring on return from the ISR.

  • I've now tried the same code (system-on-wakeup-on-rtc example) on a fresh windows development machine (Eclipse/GCC/J-Link Lite/PCA1004 as per nAN-29) and it also HardFaults after a RTC interrupt call. I have, to date, never seen it sleep.

    Any advice would be appreciated.

Related