STM32 CAN 通信 滤波设置问题
CAN_InitStructure.CAN_TTCM=DISABLE;CAN_InitStructure.CAN_ABOM=DISABLE;CAN_InitStructu...
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;
使用上面的设置,然后用地址判断 能接收到数据。
本文来自EEWORLD电子工程世界,转载请注明出处: http://bbs.eeworld.com.cn/thread-450431-1-1.html 展开
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;
使用上面的设置,然后用地址判断 能接收到数据。
本文来自EEWORLD电子工程世界,转载请注明出处: http://bbs.eeworld.com.cn/thread-450431-1-1.html 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
2个回答
展开全部
首先这个配置使用的是 32位的标识符屏蔽位模式
CAN_FilterIdHigh和CAN_FilterIdLow组合成一个32位寄存器,用来存储将要过滤的ID
CAN_FilterMaskIdHigh和CAN_FilterMaskIdLow组合成一个32位寄存器,用来表示这个ID的哪些位
必须符合(置1),哪些位不care(置0).
使用标示符屏蔽模式可以实现接收包含特定位的帧,即一系列的帧。
CAN的接收邮箱标示符寄存器中,31~3位存储29位的扩展标示符。
所以通过滤波器要接收ID为0x0A的帧,
CAN_FilterIdLow = 0x000A << 3; CAN_FilterIdHigh = 0;
CAN_FilterMaskIdLow = 0x00FF << 3; CAN_FilterMaskIdHigh = 0;
纯手打,若正确请给辛苦费
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我 可以帮你完成的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询