在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

    
    
    <address id="vxupu"><td id="vxupu"></td></address>

      <pre id="vxupu"><small id="vxupu"></small></pre>
      <dfn id="vxupu"></dfn>
      <div id="vxupu"><small id="vxupu"></small></div>
    1. 新聞中心

      EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 【STM32 Cotex-M3處理器系列編程】外部按鍵中斷

      【STM32 Cotex-M3處理器系列編程】外部按鍵中斷

      作者: 時(shí)間:2016-11-27 來源:網(wǎng)絡(luò) 收藏
      #include "stm32f10x.h"
      unsigned int TimingDelay;
      void Delay(unsigned int x)
      {
      TimingDelay=x;
      while(TimingDelay--);
      }
      void EXTI9_5_IRQHandler(void) //中斷處理函數(shù)
      {
      unsigned int tt;
      tt=6553500;
      if(EXTI_GetITStatus(EXTI_Line5)!=RESET)
      {
      GPIO_SetBits(GPIOC, GPIO_Pin_7);
      while(tt--);
      GPIO_ResetBits(GPIOC, GPIO_Pin_7);
      while(tt--);
      EXTI_ClearFlag(EXTI_Line5);//清除中斷標(biāo)志
      EXTI_ClearITPendingBit(EXTI_Line5);//清除EXTI線路掛起位
      }
      }
      int main(void)
      {
      //配置IO口
      RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE,ENABLE);//IO口使能設(shè)置
      GPIO_InitTypeDef GPIO_InitStructure; //定義結(jié)構(gòu)體
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
      GPIO_Init(GPIOC, &GPIO_InitStructure);
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //設(shè)置為上拉輸入
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
      GPIO_Init(GPIOE, &GPIO_InitStructure);
      //配置外部中斷控制器
      EXTI_InitTypeDef EXTI_InitStructure;
      RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);//使能時(shí)鐘
      EXTI_InitStructure.EXTI_Line = EXTI_Line5; //使用IO口5作為中斷口
      EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //設(shè)置EXTI線路為中斷請(qǐng)求
      EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //下降沿觸發(fā)
      EXTI_InitStructure.EXTI_LineCmd = ENABLE;
      EXTI_Init(&EXTI_InitStructure);
      GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource5);//將PE5掛接到EXTI9_5_IRQn中斷源上
      //配置中斷控制器
      NVIC_InitTypeDef NVIC_InitStructure;
      NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); //選擇中斷組0
      NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn; //指定中斷源,0-4管腳屬于EXTI0_IRQn~EXTI4_IRQn,5-9管腳屬于EXTI9_5_IRQn,10-15管腳屬于EXTI15_10_IRQn
      //NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;//無先占優(yōu)先級(jí),從優(yōu)先級(jí)為1
      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
      NVIC_Init(&NVIC_InitStructure);
      while(1);
      }
      //以下是報(bào)錯(cuò)函數(shù)
      #ifdef USE_FULL_ASSERT
      void assert_failed(uint8_t* file, uint32_t line)
      {
      while (1)
      {
      }
      }
      #endif


      關(guān)鍵詞: STM32Cotex-M3按鍵中

      評(píng)論


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

      關(guān)閉