專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

LPC1114_Timer16_0中斷程序_MDK編譯環(huán)境

作者:佚名   來源:本站原創(chuàng)   點(diǎn)擊數(shù):  更新時(shí)間:2012年11月12日   【字體:
關(guān)于Timer16_0代碼:

  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;
}
關(guān)閉窗口

相關(guān)文章