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.

Parents
  • Yes. I am checking for errors inside cli_init and cli_start. There are no errors and it returns from those two functions. I am using UART as backend.

    void CLI_Init(void)
    {
        nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
        uart_config.pseltxd = TX_PIN_NUMBER;
        uart_config.pselrxd = RX_PIN_NUMBER;
        uart_config.hwfc    = NRF_UART_HWFC_DISABLED;
    
        ret_code_t err_code = nrf_cli_init(&m_cli_uart, &uart_config, true, true, NRF_LOG_SEVERITY_INFO);
        APP_ERROR_CHECK(err_code);
        
    }
     
    void CLI_Start(void)
    {    
        ret_code_t err_code =  nrf_cli_start(&m_cli_uart);
        APP_ERROR_CHECK(err_code);    
    }
    
Reply
  • Yes. I am checking for errors inside cli_init and cli_start. There are no errors and it returns from those two functions. I am using UART as backend.

    void CLI_Init(void)
    {
        nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
        uart_config.pseltxd = TX_PIN_NUMBER;
        uart_config.pselrxd = RX_PIN_NUMBER;
        uart_config.hwfc    = NRF_UART_HWFC_DISABLED;
    
        ret_code_t err_code = nrf_cli_init(&m_cli_uart, &uart_config, true, true, NRF_LOG_SEVERITY_INFO);
        APP_ERROR_CHECK(err_code);
        
    }
     
    void CLI_Start(void)
    {    
        ret_code_t err_code =  nrf_cli_start(&m_cli_uart);
        APP_ERROR_CHECK(err_code);    
    }
    
Children
No Data
Related