最近在看定时器中断问题,遇到下面的程序:
void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period)
{
Uint32 temp;
Timer->CPUFreqInMHz = Freq;
Timer->PeriodInUSec = Period;
temp = (long) (Freq * Period);
Timer->RegsAddr->PRD.all = temp;
Timer->RegsAddr->TPR.all = 0;
Timer->RegsAddr->TPRH.all = 0;
Timer->RegsAddr->TCR.bit.TSS = 1; // 1 = Stop timer, 0 = Start/Restart Timer
Timer->RegsAddr->TCR.bit.TRB = 1; // 1 = reload timer
Timer->RegsAddr->TCR.bit.SOFT = 1;
Timer->RegsAddr->TCR.bit.FREE = 1; // Timer Free Run
Timer->RegsAddr->TCR.bit.TIE = 1; // 0 = Disable/ 1 = Enable Timer Interrupt
Timer->InterruptCount = 0;
}
然后在主程序中,有这样的设置:
ConfigCpuTimer(&CpuTimer0,100,1000000);//设定定时周期
我想问的是:这些参数是如何设置来确定定时的啊。打个比方,我想定时1ms,主程序的该如何设置啊。 |