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

APP_ERROR_CHECK outside main while(1) loop

I want to check if some errors happened during the initialization before entering while(1) loop in the main. I am using nrf_CLI in my application (SDK 14.2.0 and S140 on nRF52840).

So my main function looks like

void main( void )
{    
    sys_hw_init();

    log_init();

    cli_init();
            
    cli_start();
                
    err = System_Init();
    APP_ERROR_CHECK(err);
   

    NRF_LOG_INFO("Starting peripheral device...");
        
    while(1)
    {
        cli_process();
        
        if (NRF_LOG_PROCESS() == false)
        {
            wait_for_event();
        }
    }
}

When I use APP_ERROR_CHECK outside the main loop and there is an error, I don't see anything printed on the serial terminal (err is non-zero and not equal to NRF_SUCCESS). But if run time error occurs after application enters the main loop, then I see APP_ERROR_CHECK function normally without issues.

What could be wrong in the usage? It gets stuck inside the macro NRF_LOG_ERROR in the app_error_fault_handler routine , case NRF_FAULT_ID_SDK_ASSERT.

Related