对于同一个ID能不能即接收标准帧又接收扩展帧?我使用了2个滤波器,但是好像不能还是只能接收扩展帧。。。。。
CAN_FilterInitStructure.CAN_FilterNumber=0; //过滤器0
CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; //32位
#if ID_EXT_En//扩展帧滤波器全部匹配
CAN_FilterInitStructure.CAN_FilterIdHigh = (((u32)0x0013<<3)&0xFFFF0000)>>16;
CAN_FilterInitStructure.CAN_FilterIdLow=(((u32)0x0013<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0xFFFF;//0x0000;//
CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0xFFFF;//0x0000;//
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO0;//过滤器0关联到FIFO0
CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; //激活过滤器0
CAN_FilterInit(&CAN_FilterInitStructure);//滤波器初始化
CAN_FilterInitStructure.CAN_FilterNumber=1; //过滤器1
CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; //32位
CAN_FilterInitStructure.CAN_FilterIdHigh=(((u32)0x0013<<21)&0xffff0000)>>16;//0x0012;////32位ID
CAN_FilterInitStructure.CAN_FilterIdLow=(((u32)0x0013<<21)|CAN_ID_STD|CAN_RTR_DATA)&0xffff;//0x0012;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh= 0xFFFF;//0x0000;//32位MASK
CAN_FilterInitStructure.CAN_FilterMaskIdLow= 0xFFFF;//0x0000;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO1;//过滤器0关联到FIFO1
CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; //激活过滤器0
CAN_FilterInit(&CAN_FilterInitStructure);//滤波器初始化
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
十几年前用过CAN,
忘差不多了。
帮顶。
一周热门 更多>