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

Failing to understand app_timer

Hello.

I cannot get my head around app_timers. After reading the docs, examples and answers on the devzone I'm still unable to get it running. The timeout callback isn't called after starting the timer. Any assistance, please?

app_timer_id_t timerFoo;

void foobarHandler(void *context)
{
	log("foobar\r\n");
}

int main()
{	
	uartInit();
	log("begin\r\n");
	
	APP_TIMER_INIT(0, 1, 4, NULL);
	if(app_timer_create(&timerFoo, APP_TIMER_MODE_SINGLE_SHOT, foobarHandler) != NRF_SUCCESS) log("creation failed\r\n");
	if(app_timer_start(timerFoo, APP_TIMER_TICKS(2000, 0), NULL) != NRF_SUCCESS) log("starting failed\r\n");
	
	return 0;
}
Parents Reply
  • definitely not as it takes an unsigned integer. Not much uses floats (which is a good thing)

    There's really loads of example code on this plus lots of comments in the header files about how to set the divider, there are macros to get ticks for different milliseconds, microseconds etc etc. The documentation has a good intro to the whole library too.

    I really would look at the examples, although you aren't going to get much less than 1/10 millisecond with this library.

Children
No Data
Related