今天晚上由于身体不适,所以没有继续学习,没有外部中断弄懂
#include"DSP28x_project.h"
interrupt void xint1_isr(void);
interrupt void xint2_isr(void);
Uint16 count1,count2;
void delay_loop(void)
{
short i,n;
for(i=0;i<100;i++)
for(n=0;n<100;n++){}
}
void main(void)
{
Uint16 temp1,temp2;
InitSysCtrl();
DINT;
InitPieCtrl();
IER=0x0000;
IFR=0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.XINT1=&xint1_isr;
PieVectTable.XINT2=&xint2_isr;
EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE=1;
PieCtrlRegs.PIEIER1.bit.INTx4=1;
PieCtrlRegs.PIEIER1.bit.INTx5=1;
IER|=M_INT1;
EINT;
EALLOW;
GpioCtrlRegs.GPAMUX1.all=0x0000;
GpioCtrlRegs.GPADIR.all=0x000c;
// GpioCtrlRegs.GPAMUX1.bit.GPIO2=0;
// GpioCtrlRegs.GPAMUX1.bit.GPIO3=0;
GpioDataRegs.GPADAT.all=0x0004;
GpioCtrlRegs.GPAQSEL1.bit.GPIO0=0;
GpioCtrlRegs.GPAQSEL1.bit.GPIO1=2;
GpioCtrlRegs.GPACTRL.bit.QUALPRD0=0xff;
EDIS;
EALLOW;
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL=0;
GpioIntRegs.GPIOXINT2SEL.bit.GPIOSEL=1;
EDIS;
XIntruptRegs.XINT1CR.bit.POLARITY=0;
XIntruptRegs.XINT2CR.bit.POLARITY=1;
XIntruptRegs.XINT1CR.bit.ENABLE=1;
XIntruptRegs.XINT2CR.bit.ENABLE=1;
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO4=0;
GpioCtrlRegs.GPADIR.bit.GPIO4=1;
GpioCtrlRegs.GPAMUX1.bit.GPIO5=0;
GpioCtrlRegs.GPADIR.bit.GPIO5=1;
EDIS;
for(;;)
{
temp1=count1;
temp2=count2;
GpioDataRegs.GPADAT.bit.GPIO2=1;
GpioDataRegs.GPADAT.bit.GPIO2=0;
while(temp1==count1){}
delay_loop();
GpioDataRegs.GPADAT.bit.GPIO3=1;
GpioDataRegs.GPADAT.bit.GPIO3=0;
while(temp2==count2){}
delay_loop();
GpioDataRegs.GPADAT.bit.GPIO4=0;
GpioDataRegs.GPADAT.bit.GPIO5=1;
}
}
interrupt void xint1_isr(void)
{
count1++;
GpioDataRegs.GPADAT.bit.GPIO4=1;
PieCtrlRegs.PIEACK.all=PIEACK_GROUP1;
}
interrupt void xint2_isr(void)
{
count2++;
GpioDataRegs.GPADAT.bit.GPIO5=0;
PieCtrlRegs.PIEACK.all=PIEACK_GROUP1;
} |