IMX8QXP flexCAN1问题

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IMX8QXP flexCAN1问题

2,200 Views
zhengjianfei1
Contributor III

Hi ,

   近期我们在调试i.MX 8QXP MEK的M4内核,正在调试FLEXCAN的功能。使用的是SDK_2.7.0_MEK-MIMX8QX\boards\mekmimx8qx\driver_examples\flexcan\interrupt_transfer程序。pastedImage_2.png

例程使用的是CAN0,我们将CAN0相关配置改成CAN1后,发现CAN1无法使用,初始化的时候会卡死在初始化函数里,如下图:

pastedImage_3.png

经过各种尝试发现一定要将CAN0先初始化,CAN1才能正常初始化和使用,不知道为何需要这样? 您这边是否能提供一个CAN1的使用例程呢,非常感谢!

0 Kudos
6 Replies

1,933 Views
Zodiac
NXP Employee
NXP Employee

The flexcan on 8QX is implemented as below :

  • Power domain of CAN1/CAN2 is the child domain of CAN0's
  • FlexCAN0,CAN1/CAN2 share the clock root, SCFW provides CAN0 clock control list(interface) only to enable or disable the clock.

 

So

  • when use CAN1/CAN2 you need to power on CAN0 as well, take CAN1 for exampe :

 

 

    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");
    }​

 

 

  • Flexcan clock table should all set to CAN0 in fsl_clock.h as below , as scfw only provides control interface for CAN0, the new package for 8QX will be available soon with the patch.

 

 

#define FLEXCAN_CLOCKS                                     \
    {                                                      \
        kCLOCK_DMA_Can0, kCLOCK_DMA_Can0, kCLOCK_DMA_Can0, \
    }

 

 

 

 

 

   Please have a try.

Life is not easy!
0 Kudos

1,959 Views
jimmychan
NXP TechSupport
NXP TechSupport

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.

1,959 Views
zhengjianfei1
Contributor III

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!

0 Kudos

1,959 Views
jimmychan
NXP TechSupport
NXP TechSupport

Please find attached the patches. They have only modifications in documentation/comments, no code changes.

0 Kudos

1,959 Views
mosaddek_hossai
Contributor III

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 

0 Kudos

1,959 Views
jimmychan
NXP TechSupport
NXP TechSupport

I am asking the internal expert for helping this. I will let you know when I get the reply.

0 Kudos