打印
[STM32F1]

CAN ID过滤器问题

[复制链接]
1056|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
huhaomcu|  楼主 | 2015-2-11 19:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我想设置过滤器过滤两组ID号,如01H,02H,现设置如下

  CAN_FilterInitStructure.CAN_FilterNumber = 1;
  CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
  CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
  CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0200;
  CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0xFFFF;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0xFFFF;
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
  CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
  CAN_FilterInit(&CAN_FilterInitStructure);

  CAN_FilterInitStructure.CAN_FilterNumber = 2;
  CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
  CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
  CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0400;
  CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0xFFFF;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0xFFFF;
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
  CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
  CAN_FilterInit(&CAN_FilterInitStructure);

我设置了两个过滤器组,都分配至FIFO0,可为什么目前只能接收ID 01H的数据咧,问题出在那里咧?求指导!

沙发
airwill| | 2015-2-11 21:50 | 只看该作者
看看我的代码:
        CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdList;
        CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
        CAN_FilterInitStructure.CAN_FilterIdHigh = MOTOR_RETID/8192;
        CAN_FilterInitStructure.CAN_FilterIdLow  = MOTOR_RETID%8192*8+CAN_ID_EXT;

使用特权

评论回复
板凳
huhaomcu|  楼主 | 2015-2-12 10:50 | 只看该作者
airwill 发表于 2015-2-11 21:50
看看我的代码:
        CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdList;
        CAN_FilterInitStruct ...

像我上面这样写不行吗?我使用两组过滤器FILTER1,FILTER2;一组设置成只接收ID 01H的数据帧,一组设置成只接收02H的数据帧。

使用特权

评论回复
地板
搞IT的| | 2015-2-14 19:17 | 只看该作者
进来看看,可是咋感觉自己看的不是很懂哦。楼主上面写的代码是实现什么功能呀??

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

189

主题

508

帖子

3

粉丝