//官方代码如下,为了方便ID改成1 CAN_FilterInitSturcture.CAN_FilterNumber = 0; CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit; CAN_FilterInitSturcture.CAN_FilterIdHigh = 0x0020; CAN_FilterInitSturcture.CAN_FilterIdLow = 0; CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = 0xFFE0; CAN_FilterInitSturcture.CAN_FilterMaskIdLow = 0x0006; CAN_FilterInitSturcture.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0; CAN_FilterInitSturcture.CAN_FilterActivation = ENABLE; CAN_FilterInit(&CAN_FilterInitSturcture); //在官方代码中加另一组过滤器 CAN_FilterInitSturcture.CAN_FilterNumber = 1; CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit; CAN_FilterInitSturcture.CAN_FilterIdHigh = 0x0040; CAN_FilterInitSturcture.CAN_FilterIdLow = 0x0000; CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = 0xFFE0; CAN_FilterInitSturcture.CAN_FilterMaskIdLow = 0x0; CAN_FilterInitSturcture.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0; CAN_FilterInitSturcture.CAN_FilterActivation = ENABLE; CAN_FilterInit(&CAN_FilterInitSturcture);
在调试中,只开一组过滤器的时候,功能正常,当开一组以上过滤器时,最后打开的过滤器功能正常,前面打开的过滤器组的标识符寄存器和屏蔽位寄存器会置0(模式,位宽,关联,激活均正常),导致前一组过滤器在屏蔽模式下,因为屏蔽位置0,任何ID都可通过。前一组过滤器在标识模式下,只能通过ID为0的数据帧。
望解决。
热门产品 :
CH182: 以太网PHY收发器芯片