关于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; }