CAN_InitStructure.CAN_TTCM=DISABLE;
CAN_InitStructure.CAN_ABOM=DISABLE;
CAN_InitStructure.CAN_AWUM=DISABLE;
CAN_InitStructure.CAN_NART=DISABLE;
CAN_InitStructure.CAN_RFLM=DISABLE;
CAN_InitStructure.CAN_TXFP=DISABLE;
CAN_InitStructure.CAN_Mode=CAN_Mode_Normal;//CAN_Mode_Normal CAN_Mode_LoopBack
CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;
CAN_InitStructure.CAN_BS1=CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2=CAN_BS2_3tq;
CAN_InitStructure.CAN_Prescaler=3;
CAN_Init(CAN1, &CAN_InitStructure);
/* CAN filter init */
CAN_FilterInitStructure.CAN_FilterNumber=0;
CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;//CAN_FilterMode_IdList 标识符列表模式 CAN_FilterMode_IdMask 标识符屏蔽位模式
CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
CAN_FilterInitStructure.CAN_FilterIdHigh=0x0A00;//<<8;//接收ID为0x0A的数据
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
//CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x001f<<8;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x1F00;//<<8;
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
// CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0;
CAN_FilterInitStructure.CAN_FilterAc
tivation=ENABLE;
CAN_FilterInit(&CAN_FilterInitStructure);
使用上面的设置后,CAN 就接收不到数据了,
CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;//<<8;//接收ID为0x0A的数据
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;//<<8;
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
使用上面的设置,然后用地址判断 能接收到数据。
一周热门 更多>