I am using the CC3200 Timer A2 in edge time mode to determine the duration of high and low pulses from an external signal.
In the edge time mode, it is a 16-bit timer with 8 bit prescaler.The timer edge interrupt is triggered for both rising and falling edges.The CC3200 is running at 80MHz and I have set the prescaler to 0xFF . Here is the code I have written in the interrupt handler.
To avoid timer overflow, i am setting the timer value to 0xFFFF everytime the interrupt occurs using the TimerValueSet(TIMERA2_BASE,TIMER_A,0xFFFF);
I have a couple of doubts:
1) when i use MAP_TimerValueGet, does it return the 16 bit timer value or does it include the 8-bit prescaler
2) when i use TimerValueSet, does it set only the 16-bit timer count or also the prescaler
Is there any better way/logic to implement this? Thanks
static void TimerIntHandler()
{
MAP_TimerIntClear(TIMERA2_BASE,TIMER_CAPA_EVENT); // Clear the interrupt
g_ulSamples[0] = 0xffff;
g_ulSamples[1] = MAP_TimerValueGet(TIMERA2_BASE,TIMER_A); //Get the current timer value
capturedValues[index] = g_ulSamples[0] - g_ulSamples[1]; //Storing Duration of the pulse
index++;
TimerValueSet(TIMERA2_BASE,TIMER_A,0xFFFF); //Setting the timer value to 0xFFFF every time the interrupt occurs
if(index >=63)
{
MAP_TimerDisable(TIMERA2_BASE,TIMER_A);
index = 0;
}
}