新手刚开始学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;
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
// Disable CPU interrupts
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
InitPieVectTable();
一周热门 更多>