Hi,
I have encountered a problem when using platform: used:S32SDK_S32K1xx_RTM_3.0.0 for can init.
1、Testing procedure:
Use the CAN tool to send a single frame, and then power on the machine to perform CAN initialization. Under normal circumstances, the machine should first send an ACK message and then enter the receive processing interrupt function. But when the problem occurred, it was found that only ACK was returned, but the IFLAG1 register corresponding to MB was not triggered, so the receiving interrupt was not triggered.
2、Current code initialization timing:
1) FLEXCAN_DRV_Init();
2) FLEXCAN_DRV_ConfigRxMb();
3) FLEXCAN_DRV_SetRxIndividualMask();
4) FLEXCAN_DRV_Receive();
5) FLEXCAN_DRV_SetRxMaskType();
I found that when FlexCAN_DRV_init is called, it has the ability to respond with an ACK(while exit freeze mode), but at this time, RXMB may not have been initialized properly, so the data was missed ,cannot trigger interrupt.
Found CAN initialization sequence in the chip manual, it should exit freeze mode only after all the required configurations have been fully configured, but In the current code,while executing FlexCAN_DRV_init, it enter and then exit freeze mode even though MB and Rx Individual Mask Registers has not been initialized at this time.
I don't know why the initialization sequence code is not completely consistent with what is described in the chip manual,but I modified the exit time from freeze mode for verification and found that the issue has been improved(not exiting freeze mode in FLEXCAN_DRV_init until executing several functions as described above 1~5).
I'm not sure if this is the root cause of the problem,Perhaps you have encountered similar problems before, or do you have any suggestions or solutions.
Please guide me with this.
Thank you.
Regards,
FLEXCAN_DRV_Init()
{
.
.
.
/* Select mode */
FLEXCAN_SetOperationMode(base, data->flexcanMode);
if (data->flexcanMode != FLEXCAN_FREEZE_MODE)
{
FLEXCAN_ExitFreezeMode(base);
}
/* Enable FlexCAN interrupts.*/
FLEXCAN_EnableIRQs(instance);
...
}
