久久人妻精品人妻视频五月天一区二区三区,,自慰午夜喷水久久久av国产成人a视频高在线,,欧美日韩免费专区在线97精品国产手机

  • <cite id="cwywg"></cite>
    <button id="cwywg"></button>
  • <button id="cwywg"><source id="cwywg"></source></button>
    <button id="cwywg"><tbody id="cwywg"></tbody></button>
  • <button id="cwywg"></button>
  • 
    
  • logo logo
    • BANNER
    • BANNER
    • BANNER
    您的位置 : 首頁 > 新聞資訊 > 技術(shù)支持
    STM32F103C8T6 can端口映射
    發(fā)布者:江蘇瑞易通電子科技有限公司 人氣:742 發(fā)布日期:2021-04-23 10:10:40

    之前在網(wǎng)上找了一個(gè)STM32F103C8T6關(guān)于can通信的例子,直接燒錄,can不能使用,

    使用示波器在VP230前后端查看沒有波形,

    先介紹板子硬件資源:

    HSE時(shí)鐘:8MHz;

    MCU : STM32F103C8T6

    CAN:一路;

     

    在軟件的配置中找不到任何原因,使用USB-CAN分析儀不能識(shí)別波特率,懷疑是不是因?yàn)椴ㄌ芈试O(shè)置不對(duì),

     

    是不是硬件設(shè)計(jì)出現(xiàn)錯(cuò)誤,

    查找手冊(cè) 《stm32f103c8t6》

    can的發(fā)送接收引腳是在PA11 PA12,(注意:can和其他的復(fù)用)

    我找的那個(gè)程序,我把原理找到看了一下,can的發(fā)送接收是在 PB8 PB9,懷疑是我的板子硬件出錯(cuò)了,

    我的板子硬件原理圖上是PA11 PA12,是按照手冊(cè)來設(shè)計(jì)的,

    既然硬件沒有問題,應(yīng)該是軟件問題,看看GPIO的配置:

    /*CAN GPIO  */

     void CAN_GPIO_Config(void)

    {

      GPIO_InitTypeDef GPIO_InitStructure; 

      /* GPIOB */     

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO " RCC_APB2Periph_GPIOB, ENABLE);                                                                         


      /* CAN1  */

      RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE); 


      /* Configure CAN pin: RX */     // PB8

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;     // 

      GPIO_Init(GPIOB, &GPIO_InitStructure);

      

      /* Configure CAN pin: TX */   // PB9

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 

      GPIO_Init(GPIOB, &GPIO_InitStructure);

      

        //#define GPIO_Remap_CAN    GPIO_Remap1_CAN1 

      GPIO_PinRemapConfig(GPIO_Remap1_CAN1, ENABLE);    

      

    }

    明白了,原來是把can的發(fā)送接收端口映射到了PB8、9上面了,

    修改后的代碼:

    void CAN_GPIO_Config(void)

    {

      GPIO_InitTypeDef GPIO_InitStructure; 

      /* GPIOA */     

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA, ENABLE);                                                                         


      /* CAN1  */

      RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE); 


      /* Configure CAN pin: RX */     // PA11

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;     // 

      GPIO_Init(GPIOA, &GPIO_InitStructure);

      

      /* Configure CAN pin: TX */   // PA12

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 

      GPIO_Init(GPIOA, &GPIO_InitStructure);

      

      //#define GPIO_Remap_CAN    GPIO_Remap1_CAN1 

      //GPIO_PinRemapConfig(GPIO_Remap1_CAN1, ENABLE);     //取消端口映射   craigtao 2014-4-4

      

    }


    返回新聞列表