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
  • You don't have a softdevice - so you need to just start an LF clock

    nRF51_SDK_8.0.0/examples/peripheral/bsp/main.c

    there's an example, there are lots.

    The main function exiting isn't an issue. Just because you fall off the end of main() doesn't mean the CPU stops running, CPUs don't just .. stop. Normally it ends up in an exit loop just branching constantly to the same instruction, which is equivalent to adding a while().

Children
No Data
Related