This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

APP_EEROR_xx problem

Hi,

I'm using SDK17.2 to develop nRF52810's application.

When APP_ERROR_CHECK or APP_ERROR_HANDLER have a fault which is caused by hardware or software, the system will stop on the error, eventhough I have enabled watchdog.

So I need to restart my system when happened a error, what could I do?There are assembly language codes in app_error_handler.

Parents
  • Hi Taylor, 

    By default when there is an asser the chip will automatically reset (check the app_error_fault_handler() function) 

    If you define DEBUG in the project's preprocessor symbols, the app_error_handler() will be called and it will stay in an infinite loop. But I don't think WDT will be ignored. When the WDT timer is running it will continue to run and will trigger a reset if the WDT is not feed by the timer. So we need to see how you feed the WDT ? If you do that in a timer interrupt then it will continue to run and feed the WDT. 
    It's better to feed the WDT from main context or from an interrupt that at least equal or lower than other interrupts in your application. 

  • BTW, if I don't define DEBUG, when I use app_error_fault_handler to reset system,I need to  shield NRF_BREAKPOINT_COND. 

    __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    {
        __disable_irq();
        NRF_LOG_FINAL_FLUSH();
    
    #ifndef DEBUG
        NRF_LOG_ERROR("Fatal error");
    #else
        switch (id)
        {
    #if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT
            case NRF_FAULT_ID_SD_ASSERT:
                NRF_LOG_ERROR("SOFTDEVICE: ASSERTION FAILED");
                break;
            case NRF_FAULT_ID_APP_MEMACC:
                NRF_LOG_ERROR("SOFTDEVICE: INVALID MEMORY ACCESS");
                break;
    #endif
            case NRF_FAULT_ID_SDK_ASSERT:
            {
                assert_info_t * p_info = (assert_info_t *)info;
                NRF_LOG_ERROR("ASSERTION FAILED at %s:%u",
                              p_info->p_file_name,
                              p_info->line_num);
                break;
            }
            case NRF_FAULT_ID_SDK_ERROR:
            {
                error_info_t * p_info = (error_info_t *)info;
                NRF_LOG_ERROR("ERROR %u [%s] at %s:%u\r\nPC at: 0x%08x",
                              p_info->err_code,
                              nrf_strerror_get(p_info->err_code),
                              p_info->p_file_name,
                              p_info->line_num,
                              pc);
                 NRF_LOG_ERROR("End of error report");
                break;
            }
            default:
                NRF_LOG_ERROR("UNKNOWN FAULT at 0x%08X", pc);
                break;
        }
    #endif
    
    //    NRF_BREAKPOINT_COND;
        // On assert, the system can only recover with a reset.
    
    #ifndef DEBUG
        NRF_LOG_WARNING("System reset");
        NVIC_SystemReset();
    #else
        app_error_save_and_stop(id, pc, info);
    #endif // DEBUG
    }

  • Hi Taylor, 

    It's strange that it stopped at the break point. But when you test that did you use debug mode ? If you was debugging then it's expected that it stops at the NRF_BREAKPOINT_COND. 
    But it should not stop there if you are running the chip normally. 

    Which compiler&IDE are you using  ? 
    I did a quick test here with the ble_app_hrs and Segger Embedded Studio, trigger a fault and don't see that it stopped at the NRF_BREAKPOINT_COND. 

Reply
  • Hi Taylor, 

    It's strange that it stopped at the break point. But when you test that did you use debug mode ? If you was debugging then it's expected that it stops at the NRF_BREAKPOINT_COND. 
    But it should not stop there if you are running the chip normally. 

    Which compiler&IDE are you using  ? 
    I did a quick test here with the ble_app_hrs and Segger Embedded Studio, trigger a fault and don't see that it stopped at the NRF_BREAKPOINT_COND. 

Children
Related