extern void delayMs(unsigned int delayInMs);
void delayMs(unsigned int delayInMs)
{
T2TCR = 0x02; /* reset timer 计数器复位*/
T2PR = 0x00; /* set prescaler to zero 设置预分频的值为0 */
T2MR0 = delayInMs * (FPCLK-1);//匹配寄存器0 FPCLK等于24000000
T2IR = 1; /* reset all interrrupts 设置全部中断寄存器*/
T2MCR = 0x03; /* stop timer on match */
T2TCR = 0x01; /* start timer 开启定时/计数器 */
/* wait until delay time has elapsed */
while (T2TCR & 0x01);
}
void TIMER1_IRQHandler (void)里面加了一个延迟
{
delayMs(10); //定时时间10秒钟
}
程序只是示意表达我的意思,就是在定时器1中断的情况下,做个延迟
此帖出自
小平头技术问答
一周热门 更多>