M261的定时器,偏差很大,600秒差不多10秒的误差,咋办?
用了TIMER0作为定时器,采用内部高速时钟作为时钟源,系统时钟设置为4MHz.
void TMR0_IRQHandler(void)
{
TMR0_COUNT++;
TIMER_ClearIntFlag(TIMER0);
}
void TIMER0_INIT(void)
{
/* setting take effect */
TIMER_Open(TIMER0, TIMER_PERIODIC_MODE, 1);
CLK_SysTickDelay(50);
/* Enable timer wake up system */
TIMER_EnableWakeup(TIMER0);
CLK_SysTickDelay(50);
/* Enable Timer0 interrupt */
TIMER_EnableInt(TIMER0);
CLK_SysTickDelay(50);
NVIC_EnableIRQ(TMR0_IRQn);
/* Start Timer0 counting */
TIMER_Start(TIMER0);
CLK_SysTickDelay(50);
}
|