void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period) { Uint32 temp; // Initialize timer period: Timer->CPUFreqInMHz = Freq; Timer->PeriodInUSec = Period; temp = (long) (Freq * Period); Timer->RegsAddr->PRD.all = temp; // Se
时间: 2024-01-30 13:02:36 浏览: 184
linux-timer.zip_Linux timer_linux timer driver
ems counter to zero:
Timer->RegsAddr->TIM.all = 0x0000;
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
Timer->RegsAddr->TPR.all = 0;
// Make sure timer is stopped:
Timer->RegsAddr->TCR.bit.TSS = 1;
// Reload all counter register with period value:
Timer->RegsAddr->TCR.bit.TRB = 1;
// Reset interrupt counter:
Timer->InterruptCount = 0;
// Register interrupt handler:
Timer->IntRegsAddr->IER.all = M_INT1;
Timer->IntRegsAddr->IFR.all = M_INT1;
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
}
这是一个配置CPU定时器的函数,它主要是用来初始化一个结构体,然后根据传入的频率和周期计算出定时器的周期值,并初始化一些寄存器和计数器。最后注册中断处理程序,使得在定时器到达周期时能够触发中断。
阅读全文