使用下面两句代码,来修改时间间隔:
TIMER_SET_CMP_VALUE(TIMER0, 0xFFFFFF);
TIMER_SET_PRESCALE_VALUE(TIMER0, 2); //大概为2秒钟。
示例Demo源码如下:
void Timer0_Init()
{
//CLK_EnableModuleClock(TMR0_MODULE);
TIMER_Open(TIMER0, TIMER_PERIODIC_MODE, 1);
TIMER_SET_CMP_VALUE(TIMER0, 0xFFFFFF);
TIMER_SET_PRESCALE_VALUE(TIMER0, 2); //2 seconds
//TIMER_SET_PRESCALE_VALUE(TIMER0, 5); // 5 seconds
//TIMER_SET_PRESCALE_VALUE(TIMER0, 10); // 7 seconds
TIMER_EnableInt(TIMER0);
NVIC_EnableIRQ(TMR0_IRQn);
TIMER_Start(TIMER0);
}
有关Timer0中断使用详情,请阅读这篇博客:https://blog.csdn.net/qq_41811438/article/details/100671500,希望可以帮到你。
---- The End.