Other Parts Discussed in Thread: TM4C123GH6PM
Hi everyone,
I'm using TM4C123GH6PM to capture the edge from the sinal of encoding disks(which i have checked and functioning well).
Here is my code:
void TimerInit() {
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
// configure the pins to capture.
GPIOPinConfigure(GPIO_PB0_T2CCP0);
GPIOPinConfigure(GPIO_PB1_T2CCP1);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_0);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_1);
/* // what does this mean ??????????
GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0,
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_1,
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);*/
// Configure the 32-bit periodic timers.
TimerConfigure(TIMER2_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT_UP |
TIMER_CFG_B_CAP_COUNT_UP));
// Configure the counters to count edges.
TimerControlEvent(TIMER2_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE);
TimerControlEvent(TIMER2_BASE, TIMER_B, TIMER_EVENT_NEG_EDGE);
TimerLoadSet(TIMER2_BASE, TIMER_A, 0);
TimerLoadSet(TIMER2_BASE, TIMER_B, 0);
TimerMatchSet(TIMER2_BASE, TIMER_A, encodingDiskCon);
TimerMatchSet(TIMER2_BASE, TIMER_B, 65535);
// INT
IntEnable(INT_TIMER2A);
IntEnable(INT_TIMER2B);
TimerIntEnable(TIMER2_BASE, TIMER_CAPA_MATCH);
TimerIntEnable(TIMER2_BASE, TIMER_CAPB_MATCH);
IntMasterEnable();
// Need this ???
// TimerIntRegister(TIMER2_BASE, TIMER_A, Timer2AIntHandler);
// enable timer
TimerEnable(TIMER2_BASE, TIMER_BOTH);
}
here's what i do in my main function
....
while (1) {
UARTprintf("%d ", TimerLoadGet(TIMER2_BASE, TIMER_A));
SysCtlDelay(SysCtlClockGet() / 3);
}
I always get 0 in the TimerLoadGet(TIMER2_BASE, TIMER_A) thus never get into interrupt.
Where is my problem? Did i miss something.