This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

nrf_delay_ms code hangs when using app_timer

Hey,

I am trying to use app_timers and nrf_delay_ms together but the system gets stuck almost everytime. I have the following code:

void timer_handler(void *p_context) 
{ 
    uint32_t err_code = app_timer_stop(timer_id); 
    APP_ERROR_CHECK(err_code); 
    func_2(); 
}

void func_1() 
{ 
    //create timer
    uint32_t err_code = app_timer_create(&timer_id, APP_TIMER_MODE_SINGLE_SHOT, timer_handler);

    APP_ERROR_CHECK(err_code); 

    err_code = app_timer_start(timer_id, TIMER_INTERVAL(TIMER_INTERVAL_S), NULL);

    APP_ERROR_CHECK(err_code); 
    return;
}


void func_2() 
{ 
    /* code/ 
    nrf_delay_ms(125); //system gets stuck here!! 

    /code*/ 
    return; 
}

for the assert call back I have this:

void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name)
{
     SEGGER_RTT_printf(0, "app_error_handler\r\n: 0x%#04x\nline_num=%u\r\nfile_name=%s",error_code, line_num,p_file_name); 
}

void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) { 
    app_error_handler(1, line_num, p_file_name); 
}

I'm getting the following response on RTTviewer:

0> app_error_handler 0> : 0x0001 0> line_num=1371 0> file_name=src\rem.c

I'm using a custom board with nrf51822. The system gets stuck after this error and doesn't reset. If I enable wdt then I do see a reset. Why is this error occurring even after stopping the timer?

Thanks, Vandita