Hello,
I am attempting to build a input capture routine. I configure my timers to trigger on a certain edge and in the ISR I am attempting to save the time value at that moment.
I am getting into the ISR as expected, but when I read the time, I only see 0 or 1 as the value. I am inputting a 1000Hz square wave.
Any suggestions on where I may be going wrong?
Thanks.
IPC_ResetProperties(DIN_ID);
if (Prescaler == 0)
IPC_Properties[DIN_ID].IPC_Prescaler = 1;
else
IPC_Properties[DIN_ID].IPC_Prescaler = Prescaler;
IPC_Properties[DIN_ID].IPC_Status = TRUE;
IPC_Properties[DIN_ID].IPC_TimerInterrupt = INT_TIMER5A;
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER5);
ROM_GPIOPinTypeTimer(GPIO_PORTM_BASE, GPIO_PIN_2);
ROM_GPIOPinConfigure(GPIO_PM2_T5CCP0);
ROM_IntMasterEnable();
ROM_TimerLoadSet(TIMER5_BASE, TIMER_A, IPC_Properties[DIN_ID].IPC_Prescaler);
ROM_TimerMatchSet(TIMER5_BASE, TIMER_A, 0);
if (edgeConfig == IPC_CONFIG_EDGE_NEGATIVE)
ROM_TimerControlEvent(TIMER5_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE);
else
ROM_TimerControlEvent(TIMER5_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
if (IPC_Properties[HAL_DIN02].IPC_Status == FALSE) {
ROM_TimerConfigure(TIMER5_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT));
IPC_Properties[DIN_ID].IPC_TimerConfig = TIMER_A;
}
else {
ROM_TimerConfigure(TIMER5_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_CAP_COUNT | TIMER_CFG_A_CAP_COUNT));
IPC_Properties[DIN_ID].IPC_TimerConfig = TIMER_BOTH;
IPC_Properties[HAL_DIN02].IPC_TimerConfig = TIMER_BOTH;
}
ROM_IntEnable(INT_TIMER5A);
ROM_TimerIntEnable(TIMER5_BASE, TIMER_CAPA_MATCH);
ROM_TimerEnable(TIMER5_BASE, IPC_Properties[DIN_ID].IPC_TimerConfig);
void Timer_5_subtimer_A_ISR(void) {
ROM_TimerIntClear(TIMER5_BASE, TIMER_CAPA_MATCH);
IPC_Properties[HAL_DIN01].IPC_TimerPrev = IPC_Properties[HAL_DIN01].IPC_Timer;
IPC_Properties[HAL_DIN01].IPC_Timer = TimerValueGet(TIMER5_BASE, TIMER_A);
IPC_Properties[HAL_DIN01].IPC_EdgeCount += 1;
ROM_TimerEnable(TIMER5_BASE, IPC_Properties[HAL_DIN01].IPC_TimerConfig);
}