Other Parts Discussed in Thread: SYSCONFIG
Hi,
I am using two timers as shown in the snapshot.
The Timer_close() API doesnt seem to reset the timer count properly. Hence, calling Timer_start() with a new period value doesn't seem to take effect(callback function isn't called).
For example, here is the code to initialize timer 1:
void timer_1_init(uint32_t period_us)
{
int32_t status = 0;
timer_1_flag = 0;
Timer_Params_init(&timer_1_params);
timer_1_params.periodUnits = Timer_PERIOD_US;
timer_1_params.period = period_us;
timer_1_params.timerMode = Timer_ONESHOT_CALLBACK;
timer_1_params.timerCallback = timer_1_callbackfunction;
Timer_init();
timer_1_handle = Timer_open(CONFIG_TIMER_1, &timer_1_params);
if (timer_1_handle == NULL) {
// Timer_open() failed
while (1);
}
}
Here is the code snippet to close and re-start the timer(within a state machine) with a new period value:
timer_1_flag = 0;
Timer_close(timer_1_handle);
timer_1_init(TIMESTAMP_START_TX);
Timer_start(timer_1_handle);
(1) Kindly review the code snippet and let me know if there is any issue with it.
(2) How do I access timer 1 through hardware register address to reset the counter?
Thanks
Karthik




