新手刚开始学c2000 launchpad,设置了S3-GPIO12的按键中断程序,不过开始运行时发现没有按键也会进入中断。而运行几秒钟后就会变好。请问这是什么问题,程序如下:
中断函数:
interrupt void S3_GetPressed_isr(void)
{
S3_GetPressed_Flag=1-S3_GetPressed_Flag;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
注意:以下程序 EALLOW/EDIS未写出,实际程序中没问题的。
gpio初始化:
GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO12 = 0;
GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 2;
GpioCtrlRegs.GPACTRL.bit.QUALPRD1 = 0xff;
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 12;
连接中断函数:
PieVectTable.XINT1 = &S3_GetPressed_isr;
中断使能:
XIntruptRegs.XINT1CR.bit.POLARITY = 1;
XIntruptRegs.XINT1CR.bit.ENABLE = 1;
IER |= M_INT1;
PieCtrlRegs.PIEIER1.bit.INTx4 = 1; |