void timer0Init (unsigned int fz0)
{
LPC_TIM0->TCR = 0x02;
LPC_TIM0->IR = 1;
LPC_TIM0->CTCR = 0;
LPC_TIM0->TC = 0;
LPC_TIM0->PR = 0;
LPC_TIM0->MR0 = SystemFrequency /(4*fz0);
LPC_TIM0->MCR = 0x03;
LPC_TIM0->TCR = 0x01;
}
void timer1Init (unsigned int fz1)
{
LPC_TIM1->TCR = 0x02;
LPC_TIM1->IR = 1;
LPC_TIM1->CTCR = 0;
LPC_TIM1->TC = 0;
LPC_TIM1->PR = 0;
LPC_TIM1->MR0 = SystemFrequency /(4*fz1);
LPC_TIM1->MCR = 0x03;
LPC_TIM1->TCR = 0x01;
}
void timer2Init (unsigned int fz1)
{
LPC_TIM2->TCR = 0x02;
LPC_TIM2->IR = 1;
LPC_TIM2->CTCR = 0;
LPC_TIM2->TC = 0;
LPC_TIM2->PR = 0;
LPC_TIM2->MR0 = SystemFrequency /(4*fz1);
LPC_TIM2->MCR = 0x03;
LPC_TIM2->TCR = 0x01;
timer2_counter = 0;
}
前个定时器初始化没问题,为什么TIM2定时器初始化有问题,程序直接跳转到了HardFault_Handler
此帖出自
小平头技术问答
一周热门 更多>