我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?
求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?
1、初始化
EALLOW; // Enable EALLOW
// Set up the ECAP1 pin to primary func
tion
GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1; // GPIO24 is ECAP1
EDIS; // Disable EALLOW
ECap1Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap1Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap1Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1; // one shot mode
ECap1Regs.ECCTL2.bit.STOP_WRAP = 1; // Stop at 2 events
//ECap1Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap1Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Disable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2; //Disable sync out
ECap1Regs.ECCTL2.bit.REARM = 1; // arm one-shot
//ECap1Regs.ECEINT.bit.CEVT1 = 1; // 1st events = interrupt
ECap1Regs.ECEINT.bit.CEVT2 = 1; // 2st events = interrupt
2、开中断
EALLOW;
PieVectTable.ECAP1_INT = &ecap1_isr;
EDIS;
IER |= M_INT4;
PieCtrlRegs.PIEIER4.bit.INTx1 = 1;
3、中断函数
interrupt void ecap1_isr(void)
[
GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
//ECap1Regs.ECCLR.bit.CEVT1 = 1;
ECap1Regs.ECCLR.bit.CEVT2 = 1;
ECap1Regs.ECCLR.bit.INT = 1;
ECap1Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
]
1