微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > STM32 can通信 滤波设置不成功

STM32 can通信 滤波设置不成功

时间:10-02 整理:3721RD 点击:
CAN_InitStructure.CAN_TTCM=DISABLE;
     CAN_InitStructure.CAN_ABOM=DISABLE;
     CAN_InitStructure.CAN_AWUM=DISABLE;
     CAN_InitStructure.CAN_NART=DISABLE;
     CAN_InitStructure.CAN_RFLM=DISABLE;
     CAN_InitStructure.CAN_TXFP=DISABLE;
     CAN_InitStructure.CAN_Mode=CAN_Mode_Normal;//CAN_Mode_Normal CAN_Mode_LoopBack
     CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;
     CAN_InitStructure.CAN_BS1=CAN_BS1_8tq;
     CAN_InitStructure.CAN_BS2=CAN_BS2_3tq;
     CAN_InitStructure.CAN_Prescaler=3;
     CAN_Init(CAN1, &CAN_InitStructure);   
/* CAN filter init */
     CAN_FilterInitStructure.CAN_FilterNumber=0;
     CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;//CAN_FilterMode_IdList 标识符列表模式 CAN_FilterMode_IdMask 标识符屏蔽位模式
     CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;

     CAN_FilterInitStructure.CAN_FilterIdHigh=0x0A00;//<<8;//接收ID为0x0A的数据
     CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;

    //CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x001f<<8;
    CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x1F00;//<<8;
     CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
   //  CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;
     CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0;
     CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
     CAN_FilterInit(&CAN_FilterInitStructure);

使用上面的设置后,CAN 就接收不到数据了,
CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;//<<8;//接收ID为0x0A的数据
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;//<<8;
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
使用上面的设置,然后用地址判断 能接收到数据。

用什么收的数据啊 大哥 串口小助手么?

支持支持支持支持

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top