Hello,
I am calculating period and on time for an input signal using capture and compare timers. I have two inputs that happen to be connected to WT4CCP0 and WT4CCP1. I have both channels monitoring input signals at the same time. WT4CCP0 calculates the signal parameters without error. WT4CCP1 does well for the most part, but periodically will calculate a 0 on time. I have the on time calculated in the timer ISR. I have attached this code. Can anyone see any issues with the code that may produce this error?
void Wide_Timer_4_subtimer_B_ISR(void) { ROM_TimerIntClear(WTIMER4_BASE, TIMER_CAPB_EVENT); IPC_Properties[6].IPC_Edge = ROM_GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_5) >> 5; if(IPC_Properties[6].IPC_Edge == 1) { IPC_Properties[6].IPC_TimerPrev = IPC_Properties[6].IPC_Timer; IPC_Properties[6].IPC_Timer = ROM_TimerValueGet(WTIMER4_BASE, TIMER_B); } else { IPC_Properties[6].IPC_TimerFalling = ROM_TimerValueGet(WTIMER4_BASE, TIMER_B); IPC_Properties[6].IPC_OnTime = IPC_Properties[6].IPC_TimerFalling - IPC_Properties[6].IPC_Timer; } TMR_StartExpirationTimerMS(&IPC_Properties[6].IPC_Shutoff, 1000); ROM_TimerEnable(WTIMER4_BASE, IPC_Properties[6].IPC_TimerConfig); } void Wide_Timer_4_subtimer_A_ISR(void) { ROM_TimerIntClear(WTIMER4_BASE, TIMER_CAPA_EVENT); IPC_Properties[8].IPC_Edge = ROM_GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_4) >> 4; if(IPC_Properties[8].IPC_Edge == 1) { IPC_Properties[8].IPC_TimerPrev = IPC_Properties[8].IPC_Timer; IPC_Properties[8].IPC_Timer = ROM_TimerValueGet(WTIMER4_BASE, TIMER_A); } else { IPC_Properties[8].IPC_TimerFalling = ROM_TimerValueGet(WTIMER4_BASE, TIMER_A); IPC_Properties[8].IPC_OnTime = IPC_Properties[8].IPC_TimerFalling - IPC_Properties[8].IPC_Timer; } TMR_StartExpirationTimerMS(&IPC_Properties[8].IPC_Shutoff, 1000); ROM_TimerEnable(WTIMER4_BASE, IPC_Properties[5].IPC_TimerConfig); }