Part Number: TMS320LF2407A
According to the following configuration program, it was found that the rising edge of CAP1(IOPA3) could not enter the interrupt for the first time, while the subsequent falling edge could enter the interrupt. After that, each rising edge could enter the interrupt normally. Tested multiple times with the same results each time, ruling out the aforementioned issues caused by random situations. May I ask how to solve this problem to ensure that the first rising edge can enter the interrupt normally.
void CAP1_init()
{ unsigned int dummy;
CAPCONA &= ~(0x6000); // 清零CAP1EN位,禁止CAP1
// 2. 配置GPIO功能
MCRA |= 0x0008; // IOPA3设为CAP1功能
PADATDIR &= ~(0x0808); // IOPA3设为输入
CAPCONA &= ~(0x0080); // 清除CAP1EDGE两位
CAPCONA |= 0x0040; // CAP1EDGE = 01,设置为上升沿触发
//
dummy = CAP1FIFO; // 空读,弹出可能存在的无效数据
dummy = CAP1FIFO; // 两级FIFO,读两次确保彻底清空
CAPFIFOA |= 0x0300; // 清除CAP1FIFO状态位
//
EVAIFRC |= 0x0001; // 清除CAP1中断标志
IFR |= 0x0008; // 清除INT4中断标志
EVAIMRC |= 0x0001; // 使能CAP1中断
IMR |= 0x0008; // 使能INT4中断
// 7. 最后,使能捕获单元,开始工作
CAPCONA |= 0x2000; // CAP1EN = 1,使能CAP1
}