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

Timer handler not called

I know this was asked before, but none of the posts address my problem. There is a similar thread , but the issue on that one was that the softdevice was not being used. I'm using S210 softdevice and trying to make a current efficient delay using a timer, but my handler is never called:

// do nothing

static void delay(void * p_context)

{

// do nothing

}


 app_timer_id_t module_init(void)

{

	
    // Initialize and start a single shot timer, which is used as a delay

    APP_TIMER_INIT(RTC_PRESCALER, 1u, 1u, false);
    app_timer_id_t timer_id;
    uint32_t err_code = app_timer_create(&timer_id, APP_TIMER_MODE_SINGLE_SHOT, delay);
    APP_ERROR_CHECK(err_code);

	
	return (timer_id);
}

	

app_timer_id_t timer_id;
	
{
.
.
.

   timer_id = module_init(); 

   uint32_t err_code = app_timer_start(timer_id, 50u, NULL);  

   app_timer_stop(timer_id);
	
.
.
.
.
}
Parents
  • When you stop an app_timer it does not cause the handler function to execute. You need to let the timer expire. How long do you want your delay to be? What is the value of your APP_TIMER_PRESCALER?

    Your handler does nothing so I'm not sure how you are testing whether execution reaches the handler or now. Most compiler would either not allow breakpoints within a blank function, or simply compiler of the function all together.

Reply
  • When you stop an app_timer it does not cause the handler function to execute. You need to let the timer expire. How long do you want your delay to be? What is the value of your APP_TIMER_PRESCALER?

    Your handler does nothing so I'm not sure how you are testing whether execution reaches the handler or now. Most compiler would either not allow breakpoints within a blank function, or simply compiler of the function all together.

Children
No Data
Related