在调试CAN通信,发现出现一个问题,详细描述如下
为了调试方便,我把CAN总线上的节点简化到只有2个节点,一个收一个发。
(1)当接收端滤波器设置为全接收,则可以接收到发送端数据,发送端显示发送成功。
(2)当接收端滤波器设置了过滤条件,则接收不到发送端的数据,但是发送端却显示发送成功。
请路过的帮忙指点一下,问题出来什么地方呢?
谢了先。
初始化代码部分:
// CAN cell init 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_InitStructure.CAN_SJW=CAN_SJW_1tq; CAN_InitStructure.CAN_BS1=CAN_BS1_8tq; CAN_InitStructure.CAN_BS2=CAN_BS2_3tq; CAN_InitStructure.CAN_Prescaler=60; CAN_Init(&CAN_InitStructure); // CAN filter init CAN_FilterInitStructure.CAN_FilterNumber=0; CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000; CAN_FilterInitStructure.CAN_FilterIdLow=0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0xFFFF; CAN_FilterInitStructure.CAN_FilterMaskIdLow=0xFFFF; CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FilterFIFO0; CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; CAN_FilterInit(&CAN_FilterInitStructure);
CAN_ITConfig(CAN_IT_FMP0 | CAN_IT_FMP1, ENABLE);
我的发送程序部分:
TransmitMailbox = CAN_Transmit(&TxMessage); i = 0; while((CAN_TransmitStatus(TransmitMailbox) != CANTXOK) && (i != 0xFFFF)) { i++; } if(i == 0xFFFF) { return ERROR; } else { return SUCCESS; }
接收是在中断中执行的。
|