Hi ,
近期我们在调试i.MX 8QXP MEK的M4内核,正在调试FLEXCAN的功能。使用的是SDK_2.7.0_MEK-MIMX8QX\boards\mekmimx8qx\driver_examples\flexcan\interrupt_transfer程序。
例程使用的是CAN0,我们将CAN0相关配置改成CAN1后,发现CAN1无法使用,初始化的时候会卡死在初始化函数里,如下图:
经过各种尝试发现一定要将CAN0先初始化,CAN1才能正常初始化和使用,不知道为何需要这样? 您这边是否能提供一个CAN1的使用例程呢,非常感谢!
The flexcan on 8QX is implemented as below :
So
if (sc_pm_set_resource_power_mode(ipc, SC_R_CAN_0, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
{
PRINTF("Error: Failed to power on FLEXCAN0\r\n");
}
if (sc_pm_set_resource_power_mode(ipc, SC_R_CAN_1, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
{
PRINTF("Error: Failed to power on FLEXCAN1\r\n");
}
#define FLEXCAN_CLOCKS \
{ \
kCLOCK_DMA_Can0, kCLOCK_DMA_Can0, kCLOCK_DMA_Can0, \
}
Please have a try.
I believe the issue here is there is only a single clock that feeds all three CAN modules (SC_R_CAN_0), in the SDK when you call -
/* Power on Peripherals. */
if (sc_pm_set_resource_power_mode(ipc, SC_R_CAN_0, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
{
PRINTF("Error: Failed to power on FLEXCAN\r\n");
}
This will enable the clock as well, but if you use SC_R_CAN_1, I don't believe the clock will get enabled, which also explains why when you initialize CAN_0, CAN_1 then works.
The fix is calling the above for both SC_R_CAN_0 and SC_R_CAN_1 should work, in order to use any of the CAN modules a call to CAN_0 will be needed.
Hi jimmy,
Thanks for your reply. We have tried to add SC_R_CAN_0 Power on code,but it still didn't work. we found we have to initialize CAN0 and send data to CAN0,and then initialize CAN1, the CAN1 could work. But when CAN1 could work,CAN0 couldn't work,it is a very strange problem,seems that CAN0 & CAN1 can not work at the same time.We have no sense about this strange problem,do you have any suggestion?Thanks a lot!
Hello jimmychan,
I am also facing the problem in cm4 in IMX8qxp. The flexCAN1 is not working in M4. I have tried suggestion mentioned in your patch file. In Linux in A35 core both FLEXcan0 , Flexcan1 works perfectly. As our project is safety critical thus we need to implement Flexcan 0, 1 in cM4.
I have explained in details my problem in this thread : https://community.nxp.com/message/1347914
I am asking the internal expert for helping this. I will let you know when I get the reply.