How does one configure a Timer to have 32 bit capture resolution on TM4C129ENCPDT? Tivaware manual is confusing me about how to make TIMER0A and TIMER0B become a single 32 bit capture. I am not sure I am using the "TIMER_BOTH" correctly. I tried without "TIMER_CFG_SPLIT_PAIR" in the "TimerConfigure" but then the interrupt is never called.
I am trying to measure time between pulses which are 10mS apart. So, having 32 bits or 4294967296 cycles (4.3 billion) and running off the main clock at 120MHz should give me enough to measure 10mS.
Here is code configuring TIMER0:
***************************
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable( SYSCTL_PERIPH_TIMER0 );
ROM_GPIOPinConfigure( GPIO_PA0_T0CCP0 );
ROM_GPIOPinTypeTimer( GPIO_PORTA_BASE , GPIO_PIN_0) ;
ROM_IntMasterEnable();
ROM_TimerConfigure( TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME | TIMER_CFG_B_CAP_TIME );
ROM_TimerControlEvent( TIMER0_BASE, TIMER_BOTH, TIMER_EVENT_POS_EDGE );
ROM_TimerLoadSet( TIMER0_BASE, TIMER_A, 0xFFFF);
ROM_TimerLoadSet( TIMER0_BASE, TIMER_BOTH, 0xFFFF);
ROM_TimerIntClear( TIMER0_BASE, TIMER_CAPA_EVENT );
ROM_TimerIntClear( TIMER0_BASE, TIMER_CAPB_EVENT );
ROM_TimerIntEnable( TIMER0_BASE, TIMER_A );
ROM_TimerIntEnable( TIMER0_BASE, TIMER_B );
ROM_IntEnable( INT_TIMER0A_TM4C129 );
ROM_IntEnable( INT_TIMER0A );
ROM_TimerEnable( TIMER0_BASE, TIMER_A);
ROM_TimerEnable( TIMER0_BASE, TIMER_B);
************************************
and the handler:
*************************************
void TIMER0A_Handler(void){
ROM_TimerIntClear(TIMER0_BASE, TIMER_CAPA_EVENT );
capture_duration = ROM_TimerValueGet(TIMER0_BASE, TIMER_A );
ROM_TimerLoadSet( TIMER0_BASE, TIMER_BOTH, 0xFFFF);
}
***************************************
The value in "capture_duration" is not transferring from one of the timer registers. But that doesn't surprise me because I don't think things are set-up correctly.
***I have confirmed (unless I am very confused)***
1- The capture interrupt routine is correctly getting called.
2- The timer registers are changing.
3- I do have a 10mS period toggling input on PA0 (pin 33).
If it's relevant I am using Keil Microvision 5.24.1. and a J-Link.
I read several excellent prior posts including:
"https://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/358696"
and
Thanks,
Jeff