1、系统初始化,及定时器timer0设定中断时间60MHz,500 000 uSecond
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 60, 500000);
CpuTimer0Regs.TCR.all = 0x4001; // Use write-only instruction to set TSS bit = 0 开启定时器
2、设置中断
设置中断向量组和中断号
IER |= M_INT1; //中断使能寄存器 中断向量组INT1=0x01 timer0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; //中断号:INTx7
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
3、中断函数中用户代码
interrupt void TINT0_ISR(void) // CPU-Timer 0
{
CpuTimer0.InterruptCount++;
GpioDataRegs.GPATOGGLE.bit.GPIO1 = 1; // Toggle GPIO1 once per 500 milliseconds
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;//清除相应的中断位,以便响应下次中断
}