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

App_timer causes main loop restart when started

I'm trying to implement a simple RTC timer into my project, and it seems like the app_timer module is the best way to do that, especially when using the Softdevice. I added the following code to my project in order to implement:

static void Handle_Timer(void * p_context){
	UNUSED_VARIABLE(p_context);

}

void setTimerAndStart(void){
#define MILLISECOND 33
	uint32_t err_code;
	err_code = app_timer_start(Timer_A, 100*MILLISECOND, NULL);
	APP_ERROR_CHECK(err_code);
}

void initTimer(void){
		uint32_t err_code;

	    // Create battery timer.
	    err_code = app_timer_create(&Timer_A,
	                                APP_TIMER_MODE_REPEATED,
	                                Handle_Timer);
	    APP_ERROR_CHECK(err_code);
}

I also put an APP_TIMER_DEF(Timer_A) declaration at the top of the page and added appropriate calls into main.

If I try to call setTimerAndStart in my main loop after initializing it, the code stops working; it just loops through the main loop. I've tried stepping through it, but I haven't been able to get much usable information based on that (there's no error, at least as far as I can tell), and I've set a breakpoint at the handler in hardfault_implementation.c, but it doesn't trigger.

I'm using GCC and Eclipse, SDK 12.3, and softdevice s130 with an nRF51 devkit.

EDIT: here's some other relevant header stuff

#define APP_TIMER_PRESCALER             0                                           /**< Value of the RTC1 PRESCALER register. */
#define APP_TIMER_OP_QUEUE_SIZE         6                                           /**< Size of timer operation queues. */
Related