<object id="k0taz"><form id="k0taz"></form></object>
<pre id="k0taz"></pre>
      1. <table id="k0taz"></table>
        <bdo id="k0taz"><center id="k0taz"></center></bdo>
        <table id="k0taz"><option id="k0taz"></option></table><track id="k0taz"><ruby id="k0taz"></ruby></track>
        專注電子技術學習與研究
        當前位置:單片機教程網 >> STM32 >> 瀏覽文章

        STM8 外部中斷配置方法

        作者:huqin   來源:本站原創   點擊數:  更新時間:2014年05月01日   【字體:

        1:引用STM8 的中斷庫

          #include "stm8s_exti.h"

        2:配置外部中斷的觸發管腳

        GPIO_Init(LEDS_PORT,MB,GPIO_MODE_IN_FL_IT );

        或者

        GPIO_Init(LEDS_PORT,MB,GPIO_MODE_IN_PU_IT );

        3:初始化中斷

        EXTI_DeInit();

        EXTI_SetTLISensitivity(EXTI_TLISENSITIVITY_RISE_ONLY);//下降沿觸發中斷
        EXTI_SetExtIntSensitivity((EXTI_PORT_GPIOD),EXTI_SENSITIVITY_RISE_ONLY);

         

        4:中斷服務子程序的配置

        (1)外部定義中斷服務子程序

        @far @interrupt void EXTI3 (void)

        {
          disableInterrupts();
          counter ();
          enableInterrupts();
        }

        (2)聲明外部中斷子程序

        extern void EXTI3 ();

        (3)配置外部中斷子程序向量表

        struct interrupt_vector const _vectab[] = {
         {0x82, (interrupt_handler_t)_stext},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, EXTI3              },
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, TIM2_UPD_OVF_TRG_IRQHandler },
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, UART_RI            },
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
         {0x82, NonHandledInterrupt},
        };

        注:在配置中斷實以上三部缺一不可

        關閉窗口

        相關文章

        欧美国产伦久久久久_亚洲爽爽一区二区三区_一色屋精品视频在线观看免费_久久伊人成色777综合网
        <object id="k0taz"><form id="k0taz"></form></object>
        <pre id="k0taz"></pre>
          1. <table id="k0taz"></table>
            <bdo id="k0taz"><center id="k0taz"></center></bdo>
            <table id="k0taz"><option id="k0taz"></option></table><track id="k0taz"><ruby id="k0taz"></ruby></track>