请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TM4C1231H6PZ 您好!
我正在使用捕获和比较计时器计算输入信号的周期和导通时间。 我有两个输入碰巧连接到 WT4CCP0和 WT4CCP1。 我的两个通道同时监控输入信号。 WT4CCP0无错误地计算信号参数。 WT4CCP1在大多数情况下运行良好、但会定期计算0导通时间。 我在计时器 ISR 中计算了导通时间。 我随附了此代码。 是否有人可以看到可能产生此错误的代码有任何问题?
void Wide Timer_4_subtimer_B_ISR (void){ ROM_TimerIntClear (WTIMER 4_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 (WTIMER 4_base、timer_B); } 否则{ IPC_Properties[6].IPC_TimerFling = ROM_TimerValueGet (WTIMER 4_base、Timer_B); IPC_Properties[6]。IPC_OnTime = IPC_Properties[6]。IPC_TimerFling - IPC_Properties[6]。IPC_Timer; } TMR_StartExpirationTimerMS (&IPC_Properties[6]。IPC_Shutoff、1000); ROM_TimerEnable (WTIMER 4_base、IPC_Properties[6].IPC_TimerConfig); } void Wide Timer_4_subtimer_A_ISR (void){ ROM_TimerIntClear (WTIMER 4_base、TIMER_CAP_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 (WTIMER 4_base、timer_A); } 否则{ IPC_Properties[8]。IPC_TimerFling = ROM_TimerValueGet (WTIMER 4_base、timer_A); IPC_Properties[8]。IPC_OnTime = IPC_Properties[8]。IPC_TimerFling - IPC_Properties[8]。IPC_Timer; } TMR_StartExpirationTimerMS (&IPC_Properties[8]。IPC_Shutoff、1000); ROM_TimerEnable (WTIMER 4_base、IPC_Properties[5]。IPC_TimerConfig); }