Hello,
I have a problem when I build my project using S32DS.I want to use the FlexCAN module to receive multiple data and process the messages in the interrupt,but I'm failed.The ProcessorExpert only provide the following function prototypes which seems to be useful.
void FLEXCAN_DRV_InstallEventCallback(uint8_t instance,
flexcan_callback_t callback,
void *callbackParam);
And I use it in my code,here like this:
static void ReceiveCANData(uint32_t mailbox, uint32_t messageId,
flexcan_msgbuff_t * data_buf_struct, uint32_t len)
{
flexcan_data_info_t dataInfo =
{ .data_length = len, .msg_id_type = FLEXCAN_MSG_ID_STD };
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, mailbox, &dataInfo, messageId);
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1, Callback,data_buf_struct);
while(FLEXCAN_DRV_Receive(INST_CANCOM1, mailbox, data_buf_struct) != STATUS_SUCCESS)
{
;
}
}
Then I called this function to receive three different messages.
int main(void)
{
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT();
#endif
CANService();
#ifdef PEX_RTOS_START
PEX_RTOS_START();
#endif
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
}
void CANService(void)
{
BoardInit();
Set_Pit_100ms();
InitCAN();
ReceiveCANData(1, 0x101, &test1,7);
ReceiveCANData(5, 0x105, &test2, 7);
ReceiveCANData(6, 0x106, &test3, 7);
}
But when I tested my code, there were some bugs.Here's my test code.
static void Callback(uint8_t instance,
flexcan_event_type_t eventType, uint32_t buffIdx,
flexcan_state_t *flexcanState)
{
flexcan_msgbuff_t * poninter_to_buf_struct = flexcanState ->callbackParam;
uint8_t data1[8] = {0};
int i = 0;
for (;i < poninter_to_buf_struct ->dataLen; i++)
{
data1 [i] = poninter_to_buf_struct ->data[i];
}
switch (eventType)
{
case FLEXCAN_EVENT_RX_COMPLETE:
switch (buffIdx)
{
case 1:
BSW_SendCANData(2, 0x102, data, 7);
BSW_ReceiveCANData(1, 0x101,
&test1, 7);
break;
case 5:
BSW_SendCANData(3, 0x103, data, 7);
BSW_ReceiveCANData(5, 0x105, &test2, 7);
break;
case 6:
BSW_SendCANData(4, 0x104, data, 7);
BSW_ReceiveCANData(6, 0x106, &test3, 7);
break;
default:
break;
}
break;
case FLEXCAN_EVENT_TX_COMPLETE:
break;
default:
break;
}
}
The result is an error as shown below.

The expected result is that when the chip receives the ID101 data, it should send the ID101 data back with ID102.The result was a mess.The ID102 returns the data of ID106 and ID103 returns the ID101's data.
I want to know how this problem occurs, how to deal with it, what should be the correct way to use interrupt processing to receive messages?
Thank you,
You.