关于Timer16_0代码:
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7); //敞开定时器时钟
LPC_TMR16B0->PR=1000;//1000-1; //预分频计数器
LPC_TMR16B0->MR0=12000; //匹配寄存器
LPC_TMR16B0->TCR=0x1; //敞开定时器计数器
LPC_TMR16B0->MCR=3;//(1<<0)&(1<<1); //匹配操控--匹配则引发中止并复位定时器
NVIC_EnableIRQ(TIMER_16_0_IRQn); //中止使能
Timer16_0中止程序:
void TIMER16_0_IRQHandler(void)
{
if ( LPC_TMR16B0->IR & 0x1 )
{
LPC_TMR16B0->IR = 1; /* clear interrupt flag */
//timer16_0_counter++;
GPIOSetValue( 0, 3, 0 ); //给P0.3位写0
Delay_Ms(100);
GPIOSetValue( 0, 3, 1 ); //给P0.3位写0
Delay_Ms(100);
}
if ( LPC_TMR16B0->IR & (0x1<<4) )
{
LPC_TMR16B0->IR = 0x1<<4; /* clear interrupt flag */
timer16_0_capture++;
}
return;
}