AnsweredAssumed Answered

S32K144 flexcan init stuck when wakeup from VLPS mode

Question asked by David Shu on Sep 27, 2018


I try to initialization flexcan1 module when S32K144 power mode switch from VLPS to RUN, but it stuck while poll the LPMACK register, see below code (from flexcan_hw_access.c'), 

void FLEXCAN_Enable(CAN_Type * base)
   /* Check for low power mode */
      /* Enable clock */
      base->MCR = (base->MCR & ~CAN_MCR_MDIS_MASK) | CAN_MCR_MDIS(0U);
      base->MCR = (base->MCR & ~CAN_MCR_FRZ_MASK) | CAN_MCR_FRZ(0U);
      base->MCR = (base->MCR & ~CAN_MCR_HALT_MASK) | CAN_MCR_HALT(0U);
      /* Wait until enabled */
      while (((base->MCR & CAN_MCR_LPMACK_MASK) >> CAN_MCR_LPMACK_SHIFT) != 0U) {}

The code excute sequence is like below when quit from VLPS power mode:

Check_wakeupEvent_valid();  //check wakeup interrupt valid

PINS_DRV_Init();                   // PIN initialization

POWER_SYS_Init();              // Power manager initialization

POWER_SYS_SetMode(POWER_MANAGER_RUN, ..);  // change power mode to Run mode

CAN_Transceiver_SetMode(Normal); // set CAN transceiver to normal mode

CanInit(1);                             //flexcan1 Init  ---> stuck here !!


If MCU just switch from STOP mode or any other low power mode to run mode, the flexcan1 is OK!

I am very puzzled, please let me know where is the problem ? 

Many thanks!