外部中断——按键,使LED亮灭。使用矩阵键盘,并用按键延时提高抗干扰能力。
#include "DSP2833x_Project.h"
/**************函数声明**************/
void Gpio_setup(void);
interrupt void xint1_isr(void);
/**************函数声明**************/
volatile Uint32 Xint1Count;
/***************主函数**************/
int main(void)
{
InitSysCtrl();
Gpio_setup();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.XINT1 = &xint1_isr;
EDIS;
Xint1Count = 0;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
PieCtrlRegs.PIEIER1.bit.INTx4 = 1;
IER |= M_INT1;
EINT;
ERTM;
EALLOW;
GpioDataRegs.GPBSET.bit.GPIO60 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO60 = 0;
GpioCtrlRegs.GPBDIR.bit.GPIO60 = 1;
EDIS;
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO12 = 0;
GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 0;
EDIS;
EALLOW;
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 0x0C;
EDIS;
XIntruptRegs.XINT1CR.bit.POLARITY = 0;
XIntruptRegs.XINT1CR.bit.ENABLE = 1;
for(;;);
}
void Gpio_setup(void)
{
EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO50 = 0;
GpioDataRegs.GPBCLEAR.bit.GPIO50 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO50 = 0;
GpioCtrlRegs.GPBDIR.bit.GPIO50 = 1;
EDIS;
}
interrupt void xint1_isr(void)
{
DELAY_US(5000);
while(GpioDataRegs.GPADAT.bit.GPIO12==0);
GpioDataRegs.GPBTOGGLE.bit.GPIO60 = 1;
Xint1Count++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}