S32K144 flexcan init stuck when wakeup from VLPS mode

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

S32K144 flexcan init stuck when wakeup from VLPS mode

2,755 Views
DavidShu
Contributor II

Hi,

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 */
   if(((base->MCR & CAN_MCR_LPMACK_MASK) >> CAN_MCR_LPMACK_SHIFT) == 1U)
   {
      /* 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! 

4 Replies

1,951 Views
hiren_virapara
Contributor I

Facing same issue, but not very time.
I'm facing this issue on intermediate but within few try only I'm facing this issue.


Can someone please help me to get out from this issue?

0 Kudos
Reply

1,944 Views
DavidShu
Contributor II

Sorry for not update the result at that time,here is the answer for my case, for your reference:

1.Normal Clock & System Power Init

CLOCK_SYS_Init ->CLOCK_SYS_UpdateConfiguration->POWER_SYS_Init---->(Goto work)
        ↑                                           ↓
        --------------------[Re-init after wakeup]-----------(Enter VLPS)

If follow the above clock & System power init, it is OK when wakeuped from VLPS


2. Abnormal Init sequence

CLOCK_SYS_Init ->CLOCK_SYS_UpdateConfiguration->POWER_SYS_Init---->(Goto work)
                                                      ↑ |
                                                       | |
                                             ————————————————| |
                                               ↑ ↓
                                             [Re-init after wakeup]----------(Enter VLPS)

above init sequence when wakeup from VLPS is OK in SDK0.86, but not OK for SDK RTM 2.0.0(when enter VLPS sdk close Pll clock).
So take care the code from old SDK!

0 Kudos
Reply

2,224 Views
137574543
Contributor I

HI, David Shu

Forgive me for not being able to solve your problem, and I want to ask a question. I want to use FlexCAN interrupt to wake up LVPS mode, but fail. Can you show me your code?

微信图片_20181025162706.jpg微信图片_20181025162717.jpg

0 Kudos
Reply

2,224 Views
DavidShu
Contributor II

Thanks for your reply!

MCU will not wakeup from VLPS by CAN wakeup ISR in my case, but wakeup by GPIO connected with CAN transceiver ERR Pin which will become logic high when CAN bus state become normal from idle.

Below is my example code:

Step 1: enable GPIO extern interrupt before MCU go to VLPS mode

20181026_001.jpg

Step 2: MCU will wakeup by GPIO external interrupt from VLPS mode when wakeup event happened

Picpick_20181026_002.jpg

I use CAN1 in my project, not have CAN wakeup IRQ. Could you explain what's the usecase for CAN wakeup IRQ? 

0 Kudos
Reply