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

Strategy for power off mode after power cycle with NFC

Hi,

In my aplication, I bring my nRF52840 into power system off mode with sd_power_system_off on several different events, most notably the BLE_GAP_EVT_DISCONNECTED event. The problem is that in my application it is not guaranteed that the nRF will always have its voltage on (it will be powered off occasionally). And when it is powered on (hence having a reset), it should go into power system off mode again.

So my first thought for that was to put my sleep_mode_enter function right after my initialization code, so that it it will do exactly that: entering power off mode right after a power cycle. The problem obviously is in this case that it will also happen when the nRF is woken up by an NFC event, since it will reset the nRF and the nRF will go immediately into power system off again, basically oscillating between system off mode and reset state.

Is there a smart strategy for achieving what I want? Are there any bits that indicate whether it was a reset from a power cycle or whether the nRF was in power system off mode that I could check? Or maybe even a ready-to-use function that indicates that the nRF was woken due to a FIELDDETECT event?

Thank you for your help.

Kind regards,

Alex

Parents Reply
  • Thank you! That helped. For everyone finding this thread in the future:

    if you use a Softdevice, a read or write on this register directly will lead to a Hardfault according to some forum threads, so you should use the functions 

    - sd_power_reset_reason_get(uint32_t * p_reset_reason) for reading the register and 

    - sd_power_reset_reason_get(uint32_t  reset_reason_clr_msk) for resetting the register

    (it needs to be cleared by software, otherwise you'll get always the same result).

    Thank you again, Kenneth!

Children
No Data
Related