刚开始接触DSP,2812的,学着使用三个计数器中断,timer1和timer2的使用都非常正常,但是使用timer0却时钟不能正常工作,要实现的功能很简单,就是写三个IO口,点亮三个LED,0.2s做一次变换,程序如下,可以编译,但run之后没有反应:
#include \"DSP28_Device.h\"
#include \"ext_inf.h\"
unsigned int Led_Flag;
interrupt void ISRTimer0(void);
void main(void)
{
/*初始化系统*/
InitSysCtrl();
/*关中断*/
DINT;
IER = 0x0000;
IFR = 0x0000;
Led_Flag = 0;
/*初始化PIE*/
InitPieCtrl();
/*初始化PIE中断矢量表*/
InitPieVectTable();
/*初始化外设*/
InitPeripherals();
EALLOW;
PieVectTable.TINT0= &ISRTimer1;
EDIS;
/*设置CPU*/
ConfigCpuTimer(&CpuTimer0, 150, 200000);
StartCpuTimer0();
/*开中断*/
IER |= M_INT1;
PieCtrl.PIEIER1.bit.INTx7 = 1;
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
for(; ;
}
interrupt void ISRTimer0(void)
{
CpuTimer1.InterruptCount++;
if(Led_Flag == 2)
{
GpioDataRegs.GPBDAT.bit.GPIOB5=0;
GpioDataRegs.GPBDAT.bit.GPIOB4=1;
GpioDataRegs.GPFDAT.bit.GPIOF14=0;
Led_Flag--;
}
else if(Led_Flag == 1)
{
GpioDataRegs.GPBDAT.bit.GPIOB5=1;
GpioDataRegs.GPBDAT.bit.GPIOB4=0;
GpioDataRegs.GPFDAT.bit.GPIOF14=0;
Led_Flag--;
}
else
{
GpioDataRegs.GPBDAT.bit.GPIOB5=0;
GpioDataRegs.GPBDAT.bit.GPIOB4=0;
GpioDataRegs.GPFDAT.bit.GPIOF14=1;
Led_Flag=2;
}
}
//===========================================================================
// No more.
//===========================================================================