Part Number: TM4C129ENCZAD
Tool/software:
Hello,
I am using the General Purpose Timers to count edges and record the total flow from a flow meter.
I need to clear the timer value and get it to start from 0 again whenever the flow starts and I need to record the number of edges. However, the zeroing part is not working. Below is the function code for the timer reset that I created.:
void
TimerReset(uint32_t ui32Base, uint32_t ui32Timer)
{
if((ui32Timer & TIMER_A) == TIMER_A)
{
HWREG(ui32Base + TIMER_O_TAV) &= 0x00000000;
}
if((ui32Timer & TIMER_B) == TIMER_B)
{
HWREG(ui32Base + TIMER_O_TBV) &= 0x00000000;
}
}
Below is the timer set up code for reference:
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
TimerConfigure(TIMER2_BASE,
(TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP | TIMER_CFG_B_CAP_TIME_UP));
TimerControlEvent(TIMER2_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
TimerControlEvent(TIMER2_BASE, TIMER_B, TIMER_EVENT_NEG_EDGE);
TimerPrescaleSet(TIMER2_BASE, TIMER_BOTH, 0xFF);
TimerLoadSet(TIMER2_BASE, TIMER_BOTH, 0xFFFF);
TimerEnable(TIMER2_BASE, TIMER_BOTH);
I also tried disabling and enabling the timer when zeroing and that didn't work either.
Any help regarding this would be appreciated.






