My CAN initializes:
CAN_Init(&can3_pal_instance, &can3_pal_Config);
CanSetRate(canNum, rate);
/* Configure Rx message buffer with index 1 to receive frames with ID 2 */
CAN_ConfigRxBuff(&can3_pal_instance, eCAN2_RX_BOX, &RcvInfo, RX_MSG_ID);//eCAN2_RX_BOX =5,RX_MSG_ID =2
//FLEXCAN_DRV_SetRxMaskType(2, FLEXCAN_RX_MASK_INDIVIDUAL);
FLEXCAN_DRV_SetRxIndividualMask(2, FLEXCAN_MSG_ID_EXT, eCAN2_RX_BOX, 1);
//CAN_Receive(&can3_pal_instance, eCAN2_RX_BOX, &canRxInfo);
/*初始化CAN3接收回调函数*/
CAN_InstallEventCallback(&can3_pal_instance, (can_callback_t)Can2_RxCallBack, NULL);
CAN_Receive(&can3_pal_instance, eCAN2_RX_BOX, &canRxInfo);
void Can2_RxCallBack(uint8_t instance, can_event_t eventType, uint32_t buffIdx, void *driverState)
{
switch(eventType)
{
case CAN_EVENT_RX_COMPLETE://The program didn't go in here
break;
case CAN_EVENT_TX_COMPLETE:
break;
default:
break;
}
}
The function is called in one period(2ms)
CAN_Receive(&can3_pal_instance, eCAN2_RX_BOX, &canRxMsg);
I want to configure my CAN to be an ID that CAN receive any extended frame data, but my CAN receive function has not received any data. Is there any problem with the initialization of CAN?How to improve it?
Hi,AA
My question has been solved. Thank you for your answer!
Hi 张 舜毅,
The MB works the following way:
FLEXCAN_DRV_ConfigRxMb, this function configure the mailbox and the receiving ID, so only the messages send to this ID will be received.
FLEXCAN_DRV_SetRxIndividualMask, this function sets the RX mask, this mask corresponds to the following description:
So, only the bits sets are checked, for example, if you set this to 0 all the messages will be received, and depending of the bits set, the corresponding bits will be ignored of the ID.
An example, if you set the configuration like this:
can_buff_config_t buffCfg = {
.enableFD = true,
.enableBRS = true,
.fdPadding = 0U,
.idType = CAN_MSG_ID_EXT,
.isRemote = false
};
CAN_ConfigRxBuff(&can_pal1_instance, RX_MAILBOX, &buffCfg, 2);
CAN_SetRxFilter(&can_pal1_instance, CAN_MSG_ID_EXT, RX_MAILBOX, 0xFFFFFFFE);
The mailbox will receive the ID 0x2 and 0x3.
Also, the TX Mailbox and RX should be different.
If you want to check an example of how to do this check the .c attached. If you replace it in the can_pal example found in the SDK 3.0 should be enough to test it.
Let me know if this helps you
Best Regards,
Alexis Andalon
I'm sorry!I haven't replied to your message for such a long time, because we have a Spring Festival holiday, I have referred to your example, but the problem still hasn't been solved.When I send data to the CAN buffer in a cycle, I call the function "CAN_Receive(&can3_pal_instance, eCAN2_RX_BOX, &canRxMsg)".The program always goes into a default interrupt, I don't know why?
Exception information under debugging:
I sent the message:
I don't think I have a problem emulating the message I sent, but somehow the compiler says "received an exception message", causing the program to enter an emulating state
Hi 张 舜毅,
I saw in the previous message that the breakpoint was at the WDOG_EMW_IRQHandler(), if you check the RCM_SSRS.SWDOG at the start of your program you could check the latest reset source was the WDOG.
Usually in the ResetIRQ the WDOG is disabled due to is enable by default but maybe in your code this is not happening and that's the reason the IRQ is being called..
Let me know your findings.
Best Regards,
Alexis Andalon