征服stm32 can 标准帧 扩展帧 过滤器配置
2019-09-30
如果过滤器配置不好,就会导致发送的数据接收不到,下面是过滤器配置的代码
//配置过滤器
CAN_FilterInitStructure.CAN_FilterNumber=0; //过滤器0
CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; //32位
/*******************************标准帧配置***********************************
#define ID_REQUEST 0xc750 //11000 11101010 000
#define Mask_Ack_Request_Tbdt 0xffc0
********************************************************************/
CAN_FilterInitStructure.CAN_FilterIdHigh=ID_REQUEST;////32位ID
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=Mask_Ack_Request_Tbdt;//32位MASK
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
/*******************************标准帧配置***********************************
CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;////32位ID
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;//32位MASK
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
*******************************************************************/
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO0;//过滤器0关联到FIFO0
CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; //激活过滤器
CAN_FilterInit(&CAN_FilterInitStructure);//滤波器初始化