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

How can I read RESETREAS register using a softdevice?

Hello,

I would like to know how I can identify the reason for a reset in my device, I have read about the register NRF_POWER->RESETREAS but I don't know how to check it since I am using a softdevice.

I have read as well this post but I couldn't capture the reset reason with it, thus I am turning to the NRF_POWER->RESETREAS register.

Any hints?

Thanks in advance

Parents
  • Simply read that register right after your FW boots way before you enable SD. No conflict at that time, you can freely read the value (I actually believe you can read it like that even when SD is active but it doesn't matter).

Reply
  • Simply read that register right after your FW boots way before you enable SD. No conflict at that time, you can freely read the value (I actually believe you can read it like that even when SD is active but it doesn't matter).

Children
  • Hi @endnode, I was just placing here but the my device seems to reset each time when placing it...

    int main(void)
    {
    
    
        uint32_t err_code;
        bool     erase_bonds;
        
       sd_power_reset_reason_get(NRF_POWER->RESETREAS);
    
        // Initialize the log if enabled
        err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
    ...}
    
  • You cannot call any sd_xxx function when Soft Device isn't enabled (I believe it applies to all functions but maybe there are few exceptions). Also parameter of the function looks bad, why would you supply register address as pointer to return value? See how nrf_power_resetreas_get function looks in components\drivers_nrf\hal\nrf_power.h, that's how you access (read) registers in C;)

  • Also look to log_resetreason function in examples\peripheral\usbd\main.c, that's a good example how you should handle the returned value.

  • Thanks for the examples @endnote, now I have modified my main to look like

    int main(void)
    {
    
    
        uint32_t err_code;
        bool     erase_bonds;
        
    
         // Initialize the log if enabled
        err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
        
        
        log_resetreason();
        nrf_power_resetreas_clear(0xFFFFFFFF);
    ...}
    

    I hope to capture the error

  • @endnode, I see that I get an NRF_POWER_RESETREAS_OFF, checking the datasheet of the nrf52832 I see that this is due to Reset due to wake up from System OFF mode when wakeup is triggered from DETECT signal from GPIO, does this mean that I get an interruption on a GPIO port?