DSP

【DSP】TMS320F28035 GPIO外部中断例程

2019-07-13 10:41发布

#include "DSP28x_Project.h" //extern Uint16 RamfuncsLoadStart; //extern Uint16 RamfuncsLoadEnd; //extern Uint16 RamfuncsRunStart; interrupt void xint1_isr(void); int main(void) { InitSysCtrl(); EALLOW; GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; GpioDataRegs.GPBDAT.bit.GPIO34 = 0; EDIS; DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); // MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart); // InitFlash(); EALLOW; PieVectTable.XINT1 = &xint1_isr; EDIS; EALLOW; GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0; GpioCtrlRegs.GPADIR.bit.GPIO12 = 0; GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 0;//GPAQSEL1寄存器用来配置采样数,也可以认为是滤波数,当干扰信号持续采样周期小于该寄存器设置的采样周期数时,干扰信号被滤除。 GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 12;//GPIO12被配置为XINT外部中断1 XIntruptRegs.XINT1CR.bit.POLARITY = 0;//外部中断1设置为下降沿触发 XIntruptRegs.XINT1CR.bit.ENABLE = 1;//使能外部中断1 EDIS; PieCtrlRegs.PIEIER1.bit.INTx4 = 1;//Enable PIE GROUP1 INT4 PieCtrlRegs.PIECTRL.bit.ENPIE = 1;//Enable PIE IER |= M_INT1; //Enable CPU INT1 EINT;//Enable CPU Interrupt while(1) { } } interrupt void xint1_isr(void) { if(GpioDataRegs.GPADAT.bit.GPIO12 == 0) { GpioDataRegs.GPBDAT.bit.GPIO34 =~ GpioDataRegs.GPBDAT.bit.GPIO34; } PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; }