I am trying to get the M4 of the i.MX7 communicating over CAN. I have included the flexcan.c and flexcan.h file in my project from the FreeRTOS_BSP_1.0.1_iMX7D_Linux.tar.gz BSP.
When initializing the FlexCAN peripheral the system gets stuck in the call to FLEXCAN_Disable in the FLEXCAN_Init call on :
/* Wait until disabled */ while (!(CAN_MCR_REG(base) & CAN_MCR_LPM_ACK_MASK));
I can verify that the MDIS bit is set in the MCR register with the debugger. I have configured the clocking and RDC of the FlexCAN as follows:
/* In this example, we need to grasp board flexcan exclusively */ RDC_SetPdapAccess(RDC, rdcPdapFlexCan1, 3 << (BOARD_DOMAIN_ID * 2), false, false); /* Select board flexcan derived from OSC clock(24M) */ CCM_UpdateRoot(CCM, ccmRootCan1, ccmRootmuxCanOsc24m, 0, 0); /* Enable flexcan clock */ CCM_EnableRoot(CCM, ccmRootCan1); CCM_ControlGate(CCM, ccmCcgrGateCan1, ccmClockNeededAll);
What may be causing the system to hang on the LPM_ACK bit when trying to disable the module?
Solved! Go to Solution.
The issue was with the IOMUX Daisy configuration. I am using the CL_SOM_iMX7 from compulab. Adding the following lines to the pin configurations fixed the issue:
// CAN1 RX
IOMUXC_FLEXCAN1_RX_SELECT_INPUT = IOMUXC_FLEXCAN1_RX_SELECT_INPUT_DAISY(1);
// CAN2 RX
IOMUXC_FLEXCAN2_RX_SELECT_INPUT = IOMUXC_FLEXCAN2_RX_SELECT_INPUT_DAISY(1);
The issue was with the IOMUX Daisy configuration. I am using the CL_SOM_iMX7 from compulab. Adding the following lines to the pin configurations fixed the issue:
// CAN1 RX
IOMUXC_FLEXCAN1_RX_SELECT_INPUT = IOMUXC_FLEXCAN1_RX_SELECT_INPUT_DAISY(1);
// CAN2 RX
IOMUXC_FLEXCAN2_RX_SELECT_INPUT = IOMUXC_FLEXCAN2_RX_SELECT_INPUT_DAISY(1);
Thank you for sharing your solution Allen. We appreciate it.
Regards,
Carlos
NXP Technical Support
I found this (MQX FlexCAN ) thread for an iMX6SX getting stuck on the same line. Unfortunately the Clock Control Module (CCM) is not the same between the iMX6SX and the iMX7D. The problem seems like it is related to the clock. Digging around I found that the CCM registers for the IGP_CLK_ROOT show the clock as disabled. I cannot enable it and this thread (https://community.nxp.com/message/864525 ) indicates that it is always enabled and cannot be disabled.
Are the registers wrong?