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

How to detect cause of Reset

Hello,

 

I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flashing the image. I am using ‘ble_app_blinky’.

 

1) As per below link, do I need to skip GPIO initialization when chip wakeup from System OFF or even peripheral, ble and other initializations (Ex: rtc, timers etc…) can be skipped.

https://devzone.nordicsemi.com/f/nordic-q-a/38550/gpio-value-after-wake-up-from-gpio

 

2) Is there any API to know the status of reset (System OFF, Watchdog etc…) or directly read NRF_POWER->RESETREAS register.

 

3) As per below link, I am trying to print RESETREAS register. But code gets hanged. Do I need to call NRF_POWER->RESETREAS before enabling of SoftDevice.

https://devzone.nordicsemi.com/f/nordic-q-a/38405/detect-wake-up-reason-from-deep-sleep/148200#148200

 

 

    #if 1
    uint32_t u32Reset_reason = NRF_POWER->RESETREAS;
    NRF_LOG_INFO("Reset Status %x", u32Reset_reason);
    NRF_POWER->RESETREAS = NRF_POWER->RESETREAS; // Clear reset reason by writting 1.
    #endif

I called above code after all Peripheral and SoftDevice initilization. But I am getting below debug prints.

<info> app: Reset Status 0

<error> app: SOFTDEVICE: INVALID MEMORY ACCESS

Thanks & Regards

Vishnu Beema

  • Hi,

    You can store the err_code on the flash (particular region) inside the app_error_handler.

    https://github.com/jimmywong2003/nrf5-debug-save-error-code-flash-app

    void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info)
    {
    ...
            case NRF_FAULT_ID_SDK_ERROR:
                    m_error_data.p_error_info = (error_info_t *)info;
                    m_error_data.err_code     = m_error_data.p_error_info->err_code;
                    m_error_data.line_num     = m_error_data.p_error_info->line_num;
                    m_error_data.p_file_name  = m_error_data.p_error_info->p_file_name;
                    path_addr=(uint32_t *)m_error_data.p_error_info->p_file_name;
    
    
                    // Erase page:
                    flash_page_erase(flash_addr);
                    flash_word_write(flash_addr, m_error_data.err_code);
                    flash_addr++;
                    flash_word_write(flash_addr, m_error_data.line_num);
                    flash_addr++;
                    for(store_length=0; store_length<1000;)
                    {

    When you print out the reset reason (NRF_POWER->RESETREAS) after just system power up,

    if the reset reason is 0, most likely it is caused by the POR (Power on reset ) or BOR (Burst on reset).

    If it is non-zero value, you can refer to the table as below (inside the Product specification).

Related