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. 

  • Hi Hung,

    Thanks for your reply!

    I have defined DEBUG in the project's preprocessor symbols, but WDT seems doesn't work when occured an error.

    Here is my WDT code, I have defined a 2s timer to feed.

    #include "usr_wdt.h"
    #include "nrf_drv_wdt.h"
    #include "app_timer.h"
    
    nrf_drv_wdt_channel_id m_channel_id;
    
    APP_TIMER_DEF(m_wdt_timer_id);
    #define WDT_TIME_INTERVAL     APP_TIMER_TICKS(2000)
    /**
     * @brief WDT events handler.
     */
    void wdt_event_handler(void)
    {
    
    }
    /**
     * @brief WDT timer events handler.
     */
    static void m_wat_timeout_handler(void * p_context)
    {
        UNUSED_PARAMETER(p_context);
    		nrf_drv_wdt_channel_feed(m_channel_id);
        //NOTE: The max amount of time we can spend in WDT interrupt is two cycles of 32768[Hz] clock - after that, reset occurs
    }
    /**
     * @brief WDT feed.
     */
    void m_wat_feed(void)
    {
    		nrf_drv_wdt_channel_feed(m_channel_id);
        //NOTE: The max amount of time we can spend in WDT interrupt is two cycles of 32768[Hz] clock - after that, reset occurs
    }
    /**
     * @brief WDT init.
     */
    void m_wdt_init(void)
    {
    		uint32_t err_code = NRF_SUCCESS;
        //Configure WDT.
        nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
        err_code = nrf_drv_wdt_init(&config, wdt_event_handler);
        APP_ERROR_CHECK(err_code);
        err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
        APP_ERROR_CHECK(err_code);
        nrf_drv_wdt_enable();
    	
    		//Create timers.
        err_code = app_timer_create(&m_wdt_timer_id,
                                    APP_TIMER_MODE_REPEATED,
                                    m_wat_timeout_handler);
        APP_ERROR_CHECK(err_code);
    		
    		// Start application timers.
        err_code = app_timer_start(m_wdt_timer_id, WDT_TIME_INTERVAL, NULL);
        APP_ERROR_CHECK(err_code);
    }

Reply
  • Hi Hung,

    Thanks for your reply!

    I have defined DEBUG in the project's preprocessor symbols, but WDT seems doesn't work when occured an error.

    Here is my WDT code, I have defined a 2s timer to feed.

    #include "usr_wdt.h"
    #include "nrf_drv_wdt.h"
    #include "app_timer.h"
    
    nrf_drv_wdt_channel_id m_channel_id;
    
    APP_TIMER_DEF(m_wdt_timer_id);
    #define WDT_TIME_INTERVAL     APP_TIMER_TICKS(2000)
    /**
     * @brief WDT events handler.
     */
    void wdt_event_handler(void)
    {
    
    }
    /**
     * @brief WDT timer events handler.
     */
    static void m_wat_timeout_handler(void * p_context)
    {
        UNUSED_PARAMETER(p_context);
    		nrf_drv_wdt_channel_feed(m_channel_id);
        //NOTE: The max amount of time we can spend in WDT interrupt is two cycles of 32768[Hz] clock - after that, reset occurs
    }
    /**
     * @brief WDT feed.
     */
    void m_wat_feed(void)
    {
    		nrf_drv_wdt_channel_feed(m_channel_id);
        //NOTE: The max amount of time we can spend in WDT interrupt is two cycles of 32768[Hz] clock - after that, reset occurs
    }
    /**
     * @brief WDT init.
     */
    void m_wdt_init(void)
    {
    		uint32_t err_code = NRF_SUCCESS;
        //Configure WDT.
        nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
        err_code = nrf_drv_wdt_init(&config, wdt_event_handler);
        APP_ERROR_CHECK(err_code);
        err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
        APP_ERROR_CHECK(err_code);
        nrf_drv_wdt_enable();
    	
    		//Create timers.
        err_code = app_timer_create(&m_wdt_timer_id,
                                    APP_TIMER_MODE_REPEATED,
                                    m_wat_timeout_handler);
        APP_ERROR_CHECK(err_code);
    		
    		// Start application timers.
        err_code = app_timer_start(m_wdt_timer_id, WDT_TIME_INTERVAL, NULL);
        APP_ERROR_CHECK(err_code);
    }

Children
No Data
Related