Other Parts Discussed in Thread: STRIKE
Tool/software: TI-RTOS
Hi
I am working just to capture the time difference between rising edge and falling edge of a input PWM signal(1KHz frequency).
I am using Timer 0 with CCP mode to capture external clock event. My Handler is getting called for both rising and falling edge of external clock but when I read the timer value on the handler using TimerValueGet(WTIMER0_BASE, TIMER_A) I am getting inappropriate value.
Timer a Value 4294967295
Timer a Value 4294978345
............................................
How to capture the time difference of two edges.Is there issue with timer configuration.
Please find my below config sequence.
SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);
GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_4);
GPIOPinConfigure(GPIO_PC4_WT0CCP0);
GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
TimerConfigure(WTIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME);
TimerControlEvent(WTIMER0_BASE, TIMER_A, TIMER_EVENT_BOTH_EDGES);
TimerIntEnable(WTIMER0_BASE, TIMER_CAPA_EVENT);
System_printf("clock %u\n",SysCtlClockGet());
TimerLoadSet(WTIMER0_BASE, TIMER_A, SysCtlClockGet());
TimerIntRegister(WTIMER0_BASE, TIMER_A, Wtimer0IntHandler);
TimerEnable(WTIMER0_BASE, TIMER_A);
My handler was
void
Wtimer0IntHandler(void)
{
// unsigned int data = GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_4);
// System_printf("data %d\n",data);
//
// Clear the timer interrupt.
//
unsigned long timera = TimerValueGet(WTIMER0_BASE, TIMER_A);
System_printf("Timer a Value %u\n",timera);
// System_flush();
TimerIntClear(WTIMER0_BASE, TIMER_CAPA_EVENT);
//
// Update the interrupt status on the display.
//
IntMasterDisable();
// GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_4, 0);
// data = !!GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_4);
// System_printf("data %d\n",data);
/* if(data != 0)
{
GPIO_write(Board_LED0, Board_LED_ON);
}
else
{
GPIO_write(Board_LED0, Board_LED_OFF);
}
*/
IntMasterEnable();
}