Other Parts Discussed in Thread: SYSCONFIG
Hello,
So I've been trying to stop and start a non-blocking oneshot callback timer. I've noticed that whenever I've tried to start the timer back up it will start where it left off instead of starting from the last time it was started. In the code I've provided below shows me trying to start the timer put it to sleep for 500ms stop it, close it, open it and start it back up. However after 5ish seconds after the code is run I get the printf statement in the callback rather than 5 seconds after the last start of the timer. I am I doing something wrong and if not what is the most effective work around?
void timerCallback(Timer_Handle handle, int_fast16_t status)
{
printf("Timer CB\r\n");
}
void test()
{
Timer_Params _timer_params;
Timer_Params_init(&_timer_params);
_timer_params.periodUnits = Timer_PERIOD_US;
Timer_Handle _timer = NULL;
_timer_params.period = 5000000;
_timer_params.timerCallback = timerCallback;
_timer_params.timerMode = Timer_ONESHOT_CALLBACK;
_timer = Timer_open(CONFIG_TIMER_3, &_timer_params);
Timer_start(_timer);
usleep(500000);
printf("usleep1\r\n");
Timer_stop(_timer);
Timer_close(_timer);
_timer = Timer_open(CONFIG_TIMER_3, &_timer_params);
Timer_start(_timer);
usleep(500000);
printf("usleep2\r\n");
Timer_stop(_timer);
Timer_close(_timer);
_timer = Timer_open(CONFIG_TIMER_3, &_timer_params);
Timer_start(_timer);
usleep(500000);
printf("usleep3\r\n");
Timer_stop(_timer);
Timer_close(_timer);
_timer = Timer_open(CONFIG_TIMER_3, &_timer_params);
Timer_start(_timer);
usleep(500000);
printf("usleep4\r\n");
Timer_stop(_timer);
Timer_close(_timer);
_timer = Timer_open(CONFIG_TIMER_3, &_timer_params);
Timer_start(_timer);
usleep(500000);
printf("usleep5\r\n");
Timer_stop(_timer);
Timer_close(_timer);
_timer = Timer_open(CONFIG_TIMER_3, &_timer_params);
Timer_start(_timer);
printf("timer go\r\n");
sleep(60);
Timer_close(_timer);
}