<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 關(guān)于STM32中CAN中斷的使用

          關(guān)于STM32中CAN中斷的使用

          作者: 時(shí)間:2016-11-28 來源:網(wǎng)絡(luò) 收藏
          “如果你用的CAN引腳是PA11和PA12,接收中斷用CAN1_RX0_IRQn。如果CAN引腳用的是PB8和PB9,也就是用重定義的引腳,接收中斷用CAN1_RX1_IRQn。由于PA11和PA12也是USB的引腳,所以非互聯(lián)型且?guī)AN控制器的微控制器的庫文件在起名字時(shí)用了USB_LP_CAN1_RX0_IRQn。”具體的定義可以參考stm32F10x.h文件,其中對(duì)不同型號(hào)的中斷有具體的定義。

          本文引用地址:http://www.ex-cimer.com/article/201611/322717.htm

          示例如下:

          1. 配置過濾器

          CAN_FilterInitStructure.CAN_FilterNumber = 0;

          CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;

          CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;

          CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;

          CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;

          CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
          CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;

          CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0;//關(guān)聯(lián)FIFO0

          CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;

          CAN_FilterInit(&CAN_FilterInitStructure);


          CAN_FilterInitStructure.CAN_FilterNumber = 14;

          CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO1;//關(guān)聯(lián)FIFO1

          CAN_FilterInit(&CAN_FilterInitStructure);

          2. 開啟CAN中斷

          CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);

          CAN_ITConfig(CAN1, CAN_IT_FMP1, ENABLE);

          CAN_ITConfig(CAN2, CAN_IT_FMP0, ENABLE);

          CAN_ITConfig(CAN2, CAN_IT_FMP1, ENABLE);

          3. 中斷處理函數(shù)


          void CAN1_RX0_IRQHandler(void)

          {
          CAN_Receive(CAN1, CAN_FIFO0, &CAN1_RxMsg);

          //
          }


          void CAN1_RX1_IRQHandler(void)

          {
          CAN_Receive(CAN1, CAN_FIFO1, &CAN1_RxMsg);

          //
          }

          void CAN2_RX0_IRQHandler(void)

          {

          CAN_Receive(CAN2, CAN_FIFO0, &CAN2_RxMsg);
          //
          }


          void CAN2_RX1_IRQHandler(void)

          {
          CAN_Receive(CAN2, CAN_FIFO1, &CAN2_RxMsg);
          //
          }



          關(guān)鍵詞: STM32CAN中

          評(píng)論


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

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();