色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > IAR FOR AVR 定時(shí)器中斷的使用

          IAR FOR AVR 定時(shí)器中斷的使用

          作者: 時(shí)間:2016-12-03 來(lái)源:網(wǎng)絡(luò) 收藏
          首先看下在iar 里面 iom16.h里面的中斷向量表

          /* NB! vectors are specified as byte addresses */

          本文引用地址:http://cafeforensic.com/article/201612/325106.htm

          #define RESET_vect (0x00)
          #define INT0_vect (0x04)
          #define INT1_vect (0x08)
          #define TIMER2_COMP_vect (0x0C)
          #define TIMER2_OVF_vect (0x10)
          #define TIMER1_CAPT_vect (0x14)
          #define TIMER1_COMPA_vect (0x18)
          #define TIMER1_COMPB_vect (0x1C)
          #define TIMER1_OVF_vect (0x20)
          #define TIMER0_OVF_vect (0x24)
          #define SPI_STC_vect (0x28)
          #define USART_RXC_vect (0x2C)
          #define USART_UDRE_vect (0x30)
          #define USART_TXC_vect (0x34)
          #define ADC_vect (0x38)
          #define EE_RDY_vect (0x3C)
          #define ANA_COMP_vect (0x40)
          #define TWI_vect (0x44)
          #define INT2_vect (0x48)
          #define TIMER0_COMP_vect (0x4C)
          #define SPM_RDY_vect (0x50)

          然后我是用的atmega16 4mhz晶振

          源程序:

          #include

          char flag=0;

          void timer_init() // 中斷初始化
          {
          TCCR1B = 0x04;

          TCNT1H = 0xc2;
          TCNT1L = 0xf6;

          TIMSK_Bit2 = 1; // 定時(shí)器中斷屏蔽寄存器
          SREG_Bit7 = 1; // 總中斷
          }

          # pragma vector = TIMER1_OVF_vect
          __interrupt void timer1(void)
          {
          TCNT1H = 0xc2;
          TCNT1L = 0xf6;
          flag=1;
          }

          void main(void)
          {
          timer_init();
          DDRB_Bit1 = 1;
          while(1)
          {
          if(flag==1)
          {
          PORTB_Bit1 = ~PORTB_Bit1;
          flag = 0;
          }
          }
          }



          關(guān)鍵詞: IARAVR定時(shí)器中

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉