我用两台单片机进行CAN通信试验,收发都成功了,但发现了一个问题,设置的过滤器id为00和01,结果另一台单片机发送ID
StdId无论改为什么这台单片机都能收到消息,怎么回事?难道双节点通信不需要用ID标识符过滤消息?
这是我的can过滤器设置:
void CAN1_Config16BitFilter(uint16_t id1, uint16_t id2)
{
CAN_FilterInitTypeDef CAN_FilterInitStructure;
uint16_t mask = 0xFFFF;
CAN_FilterInitStructure.CAN_FilterNumber = 1;
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;//IDÄ£ê½
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_16bit;
CAN_FilterInitStructure.CAN_FilterIdHigh = (id1 << 5);
CAN_FilterInitStructure.CAN_FilterIdLow = (id2 << 5);
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = (mask << 5);
CAN_FilterInitStructure.CAN_FilterMaskIdLow = (mask << 5);
CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0; //FIFO0
CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
CAN_FilterInit(&CAN_FilterInitStructure);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
http://www.openedv.com/forum.php?mod=viewthread&tid=10328
一周热门 更多>