LPC1114_Timer16_0中斷程序_MDK編譯環(huán)境
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7); //開啟定時(shí)器時(shí)鐘
LPC_TMR16B0->PR=1000;//1000-1; //預(yù)分頻計(jì)數(shù)器
LPC_TMR16B0->MR0=12000; //匹配寄存器
LPC_TMR16B0->TCR=0x1; //開啟定時(shí)器計(jì)數(shù)器
LPC_TMR16B0->MCR=3;//(1<<0)&(1<<1); //匹配控制--匹配則引發(fā)中斷并復(fù)位定時(shí)器
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;
}
評(píng)論