求教高手关于计数器的用法
#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.
//===========================================================================
没有初始化定时器
中断程序中需加一句话:
PieCtrlRegs.PIEACK.all = 1;
PieVectTable.TINT0= &ISRTimer1;
interrupt void ISRTimer0(void)
中断向量表和中断服务程序的名称对不上号,应该是:
PieVectTable.TINT0= &ISRTimer0;
遇到同样的问题. 不过大家提到的我都注意到了. 我是用的TI的范例稍做修改, 大家说说可能是什么问题?