老师好,原来延时去抖动按键不太合适,我想在改为定时器按键功能,现在先启用定时器,可是定时器0为什么没有反应,观察CpuTimer0.InterruptCount的数值没有变化,麻烦帮忙看下哈。main(void)
{
InitSysCtrl();
InitPieCtrl();
InitPieVectTable();//中断向量表的初始化函数
DINT;
IER = 0x0000;
IFR = 0x0000;
InitXintf();
InitECanGpio();
canchushihua();
configtestled();
delay(1);
LcdInit();
delay(1);
InitI2CGpio();
InitI2C();
epromRead();
InitCpuTimers(); // For this example, only initialize the Cpu Timers
// fasong();
// fasong();
delay(100);
ConfigCpuTimer(&CpuTimer0, 150, 100000);
StartCpuTimer0();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &ISRTimer0;
//PieVectTable.XINT13 = &cpu_timer1_isr;
//PieVectTable.TINT2 = &cpu_timer2_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
IER |= M_INT1;
//IER |= M_INT13;
//IER |= M_INT14;
// Enable TINT0 in the PIE: Group 1 interrupt 7
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EALLOW;
SysCtrlRegs.HISPCP.all = ADC_MODCLK; // HSPCLK = SYSCLKOUT/ADC_MODCLK
EDIS;
EALLOW;
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO pin
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // Output pin
EDIS;
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.ECAN0INTB = &ECAN0INT_ISR;
EDIS;
IER |= M_INT9;
//PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
PieCtrlRegs.PIEIER9.bit.INTx7 = 1; //使能Ecan0INT
EINT; // Enable Global interrupt INTM
ERTM;
RW=0; //245方向 输出
delay(1);
INTFORFFT();
delay(1);
START=1;
// CLEAR=0;
L=1;
delay(10);
Lcdrest();
delay(1);
LcdInit();
delay(5);
Lcdrest();
LcdInit();
xianshi0();
DELAY_US(5);
DELAY_US(5);
// can_xmit(300) ;
// GpioDataRegs.GPCDAT.bit.GPIO79 =0;
//shuzuchushihua();
while(1)
{
handldata(); //参数计算
RUN_DETECT();
keyscan(); //按键扫描
delay(1);
handlekey(); // 按键处理
}
}
interrupt void ISRTimer0(void)
{
CpuTimer0.InterruptCount++;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
CpuTimer0Regs.TCR.bit.TIF=1;//
CpuTimer0Regs.TCR.bit.TRB=1;
} |