I am feeding a 16.384Mhz clock to both 16-bit timer A and B of GPTM block 2, hoping to create two independent timers from the same source
B is a simple up counter, no interrupt will be fired from Timer B, it simply wraps around when overflows, and it works fine
A is intended to be configurable with reload and prescale, when it counts to zero, it will reload with preload value and fire an interrupt, and the ISR will generate a pulse
Somehow, the pulse interval generated from Timer A ISR seems too short.
With reload number of 60000, no prescaler, and clock source of 16384000hz, I am expecting the pulse interval from TimerA ISR to be 60000 /16384000, or ~3.66ms, but the interval between pulses is around 500us, what did I miss here?
Thanks for your time!
///Configuration codes below
main()
{
....
IntDisable(INT_TIMER2A);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
MAP_GPIOPinConfigure(GPIO_PM0_T2CCP0);
MAP_GPIOPinConfigure(GPIO_PM1_T2CCP1);
MAP_GPIOPinTypeTimer(GPIO_PORTM_BASE, GPIO_PIN_0);
MAP_GPIOPinTypeTimer(GPIO_PORTM_BASE, GPIO_PIN_1);
TimerConfigure(TimerBase, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PERIODIC|TIMER_CFG_B_CAP_COUNT_UP);
TimerControlEvent(TimerBase, TIMER_A, TIMER_EVENT_POS_EDGE);
TimerDisable(TimerBase, TIMER_A);
TimerLoadSet(TimerBase, TIMER_A, 60000);
TimerMatchSet(TimerBase, TIMER_A, 0);
TimerPrescaleSet(TimerBase, TIMER_A, 0);
TimerPrescaleMatchSet(TimerBase, TIMER_A, 0);
TimerEnable(TimerBase, TIMER_A);
// Configuration for Timer B is here, removed so that we don't get distracted.
HWREG(TimerBase+0x50)=0; //Reset counter, only the lower 16 bits!
IntEnable(INT_TIMER2A);
TimerIntEnable (TimerBase, TIMER_CAPA_MATCH|TIMER_CAPA_EVENT|TIMER_TIMA_TIMEOUT);
...
}
Timer2AIntHandler(void)
{
GPIOPinWrite(GPIO_PORTP_BASE,GPIO_PIN_3, 0); //LED ON
TimerIntClear(TIMER2_BASE, TIMER_CAPA_MATCH|TIMER_TIMA_MATCH|TIMER_TIMA_TIMEOUT);
GPIOPinWrite(GPIO_PORTP_BASE,GPIO_PIN_3, GPIO_PIN_3); //LED OFF
}