本人在初学DSP,在学习周期中断的时候,发现在
仿真模式下程序一直不能进入周期中断,找了很久都找不到原因,请各位大侠帮帮忙
#include "DSP2803x_Device.h"
#include "DSP2803x_Examples.h"
unsigned int num=0;
interrupt void Count (void)
{
num++;
EPwm1Regs.ETCLR.bit.INT = 1; //中断向量清零处理
PieCtrlRegs.PIEACK.all = 0x0004;
EINT; //使能全局中断INTM
}
void main(void)
{
int i,j;
InitSysCtrl();
DINT;
IER=0x0000;
IFR=0x0000;
InitPieVectTable();
InitPieCtrl();
PieCtrlRegs.PIECTRL.bit.ENPIE=1;
PieCtrlRegs.PIEIER3.bit.INTx1=1; //EPWM1_INT 中断允许pie级
PieCtrlRegs.PIEACK.all=0xFFFF;
EPwm1Regs.ETSEL.bit.INTEN=1; // Enable EPWMx_INT generation
EPwm1Regs.ETSEL.bit.INTSEL=2; // cnt = 2 int(设置中断方式为周期中断)
EPwm1Regs.ETPS.bit.INTPRD=1; // int at every cnt =1event每次(周期中断)匹配产生中断(每隔一次/每隔两次)
EPwm1Regs.ETCLR.bit.INT=1; // ePWM Interrupt (EPWMx_INT) Flag Clear Bit
EALLOW;
EPwm1Regs.TBPRD=0x05DC; // Set period for ePWM1,1500=5DC
EPwm1Regs.TBCTL.all=0x8000+0x0008+0x0002+0x0000+0x0000+0x0000+0x0000; // count up and down ,start
EPwm1Regs.TBPHS.half.TBPHS=0;
EPwm1Regs.CMPCTL.all=0x0000;
EPwm1Regs.AQCTLA.all=0x0090; //EPWM1A=0 when CTR=cmpa and counter increase
//EPWM1A=1 when CTR=cmpa and counter decrease
EPwm1Regs.CMPA.half.CMPA=0x02EE; // Set compare A value初始值设置750
EDIS;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1;
EALLOW;
PieVectTable.EPWM1_INT=&Count;
EDIS;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1; //EPWM1_INT 中断允许
IER|=M_INT3;
EINT;
ERTM;
while(1)
{
}
}