程序如下:
void delayMs(uint8_t
timer_num, uint32_t delayInMs)
{
if ( timer_num == 0 )
{
LPC_TIM0->TCR = 0x02; /* reset timer */
LPC_TIM0->PR = 0x00; /* set prescaler to zero */
LPC_TIM0->MR0 = delayInMs * (9000000 / 1000-1);
LPC_TIM0->IR = 0xff; /* reset all interrrupts */
LPC_TIM0->MCR = 0x04; /* stop timer on match */
LPC_TIM0->TCR = 0x01; /* start timer */
/* wait until delay time has elapsed */
while (LPC_TIM0->TCR & 0x01);
}
else if ( timer_num == 1 )
{
LPC_TIM1->TCR = 0x02; /* reset timer */
LPC_TIM1->PR = 0x00; /* set prescaler to zero */
LPC_TIM1->MR0 = delayInMs * (9000000 / 1000-1);
LPC_TIM1->IR = 0xff; /* reset all interrrupts */
LPC_TIM1->MCR = 0x04; /* stop timer on match */
LPC_TIM1->TCR = 0x01; /* start timer */
/* wait until delay time has elapsed */
while (LPC_TIM1->TCR & 0x01);
}
return;
}
程序中的9000000是怎么算出来的,求大神解答!!!
谢谢!!
一周热门 更多>