I'm trying to implement a set of routines that allow me to time between two points in execution. A function, start(), is called at the first point and another function, stop(), is called at the second point in execution. The double returned by stop() is supposed to compute the time measured (i.e. counted) since start() was called.
I always get 0 from stop(), and upon debugging it further I see that the timer value is zero. I've been experimenting with several uses of the timers and everytime I try to use Up Counting it doesn't work, so I'm missing something. For example I experimented with a timeout style timer and used up counting and set match register. It wasn't until I did load Set and down counted that it worked. But here I feel I really need to be able to count up. Any advise/suggestions?
Thanks.
void init() {
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER3); //
ROM_TimerConfigure(TIMER3_BASE, TIMER_CFG_ONE_SHOT_UP);
ROM_TimerControlStall(TIMER3_BASE, TIMER_A, true) ;
}
void start() {
ROM_TimerDisable(TIMER3_BASE, TIMER_A) ;
ROM_TimerLoadSet(TIMER3_BASE, TIMER_A,0) ;
ROM_TimerEnable(TIMER3_BASE, TIMER_A) ;
}
double stop() {
ROM_IntDisable(INT_TIMER3A);
ROM_TimerIntDisable(TIMER3_BASE, TIMER_TIMA_TIMEOUT) ;
ROM_TimerDisable(TIMER3_BASE, TIMER_A) ;
uint32_t count = ROM_TimerValueGet(TIMER3_BASE, TIMER_A) ;
return (double(double(count)/double(ROM_SysCtlClockGet()))) ; // forcing double just in case there's an issue w compiler
}
My environment: Linux, LM4f120, CCS 5.2, etc.