//官方代碼如下,為了方便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(模式,位寬,關聯(lián),激活均正常),導致前一組過濾器在屏蔽模式下,因為屏蔽位置0,任何ID都可通過。前一組過濾器在標識模式下,只能通過ID為0的數據幀。
????? ? 望解決。
熱門產品 :
CH641: PD及無線充電專用MCU