For our iMXRT1064-based project, we are using the fsl_flexcan.c driver distributed with MCUXpresso SDK, and we notice that the FLEXCAN_Init() function hangs if we don’t previously initialize one of the LPUART instances. The location of the hang is in FLEXCAN_Init(), when it comes time to disable the module, set CTRL1.CLKSRC bit and then re-enable the module. When the module is disabled (MCR.MDIS = 1), the MCR.LPMACK bit never gets set to acknowledge low power mode so software hangs in the while loop:
static inline void FLEXCAN_Enable(CAN_Type *base, bool enable)
base->MCR &= ~CAN_MCR_MDIS_MASK;
/* Wait FlexCAN exit from low-power mode. */
while (base->MCR & CAN_MCR_LPMACK_MASK)
We find that FlexCAN initializes successfully only if at least one of the LPUART clocks is enabled (e.g., CCM_CCGR0.CG14=3 for lpuart2 clock). If none of the lpuart clocks is enabled, then the software hangs. This behavior we confirmed with the canfd interrupt_transfer example code using the iMXRT1064EVB.
Is this expected behavior? Is it required to have the lpuart clock enabled for FlexCAN peripheral (at least the FlexCAN3 CAN-FD peripheral) to function correctly?