我用两台单片机进行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);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我上面这样设置屏蔽滤波器uint16_t mask = 0xFFFF;就是设置为完全匹配才能接收,但不匹配的也能进接收中断;
我的问题是不满足过滤器设置也能收到消息,比如我16位ID标识符设置id1=00,id2=01;结果我另一台机发id=05的can帧他居然也能收到,有什么可能原因
一周热门 更多>