How to kown s32K146 come in to VLPS mode driver in MCAL

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

How to kown s32K146 come in to VLPS mode driver in MCAL

Jump to solution
3,050 Views
ananan
Contributor III

I am working in Mcal config the driver MCU go to VLPS,and Icu wake up the VLPS. when mcu come in to the VPLS,the jlink debugger is still work.The Icu is work well.but the Icu can not wake up the VLPS,So I think mcu does not come in the VLPS.In the figure below, the code in the red box is executed during emulation.

 

ananan_0-1631260915781.png

ananan_1-1631261110049.png

 

0 Kudos
1 Solution
2,894 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

It's up to you with the port, because port isn't required to be turned off during VLPS. To limit the power consumption, you can consider turn off the port as LED driver if any.

The power consumption dropped from 125mA to 15mA seems to be good, at least it proved that your CPU has entered VLPS. However, if your application requires an even lower power consumption in VLPS, then you might need to turn off/switch the clock source to SIRC for every peripherals.

Best Regards,

Nam

View solution in original post

0 Kudos
21 Replies
2,964 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

The EXECUTE_WAIT is implementing the "wfi" instruction, so it would wait until any interrupt becomes pending. As a result, please check whether any pending interrupt occurs before executing EXECUTE_WAIT, otherwise EXECUTE_WAIT will exit immediately. You also need to disable all peripherals that are not used in VLPS, and turn off/set clock sources as SIRC for clock peripherals, due to the fact that only SIRC is allowed in VLPS.

If your configuration is correct, then you will see the debug monitor is in "executing" state after the "wfi", then the debug will pause in next instruction (SuspendAllInterrupts()) after the MCU exits the VLPS. For sure you can check the power consumption (it should be in uA when entering VLPS).

Best Regards,

Nam

0 Kudos
2,956 Views
ananan
Contributor III

Hello, thank you for your answer to my question. In my program, I used freertos system. Before entering VLPS mode, Systiclk (tick timer) interrupt was executed, but before entering VLPS, I used critical function to close the interrupt.I wonder why Systick is not shut down?

ananan_2-1631771304851.jpeg

 

ananan_0-1631771029063.png

Systick has a priority of 15, and critical functions can turn off interrupts of 7 to 15

ananan_1-1631771133668.png

 

0 Kudos
2,947 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

Probably because the interrupts were resumed before EXECUTE_WAIT(), if you look into the code inside Mcu_SetMode(). As far as I know, SuspendAllInterurpts() and ResumeAllInterrupts() are removed in recently MCAL deliver. So you can try to remove them to verify. 

One more thing that Systick needs to be disabled, due to the fact that core clock is turned off in VLPS. You can refer to these threads: https://community.nxp.com/t5/S32K/Systick-and-stop-mode/m-p/943557 https://community.nxp.com/t5/S32K/SysTick-VLPS-Debug/m-p/953978 

Best Regards,

Nam

0 Kudos
2,943 Views
ananan
Contributor III

1,I did not find where to resum the interrupt before EXECUTE_WAIT()

2,Do you mean to delete the pair of critical functions in the figure

ananan_0-1631778698735.png

3,The MCAL has turned off the associated clock before EXECUTE_WAIT()

ananan_1-1631778866695.png

 

 

0 Kudos
2,935 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

Yes, the MCAL turns off the associated clock. However, MCAL is not able to turn off SYSTick. You shall need to turn it off manually (SYST_CSR[ENABLE] = 0)

Best Regards,

Nam

0 Kudos
2,989 Views
ananan
Contributor III

the program is not wait at the  EXECUTE_WAIT(),it can execute the next "break".the EXECUTE_WAIT() is defined the picture

ananan_0-1631262135689.png

 

0 Kudos
2,937 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

Sorry that I haven't clarified it. What I'm mentioning is above snapshot: in the definition of EXECUTE_WAIT(), you can try to remove SuspendAllInterrupts() and ResumeAllInterrupts(). Just keep only ("wfi").

Best Regards,

Nam

0 Kudos
2,931 Views
ananan
Contributor III

SYST_CSR[ENABLE] = 0 can not close it ,The critical function has turned it off. After entering the critical function, systick interrupts no longer enter

0 Kudos
2,932 Views
ananan
Contributor III

After removing ResumeAllInterrupts() and SuspendAllInterrupts(), the program stops at EXECUTE_WAIT(). Systick interrupts are not performed before WFI, but the register is still checked to indicate that VLPS mode is interrupted and stopped

ananan_0-1631784709534.png

ananan_1-1631784755829.png

 

0 Kudos
2,926 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

If the program has stopped at EXECUTE_WAIT(), possibly your MCU has entered the VLPS (For sure you can check the power consumption). Is it correct that the micro currently “stops” at the STANDBY (or WFI) instruction, and doesn't directly return from it and continues code execution?

However, the VLPSA bit seems not to reflect that. Could you check the NVIC registers and find is there any active/pending interrupt before executing WFI? 

Best Regards,

Nam

 

0 Kudos
2,922 Views
ananan
Contributor III

If the “cpsid” command is used to close interrupts instead of critical-function close interrupts, the register status is correct and the program stops at WFI, then there are other interrupts.

1,What is the difference between “cpsid” and critical-function close interrupts?

ananan_0-1631796441359.png

2,But how do you wake up mcuwith the Icu interrrupt?

0 Kudos
2,918 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

1. "cpsid i" is used to set the PRIMASK. When PRIMASK = 1, the processor prevents the activation of all exceptions with configurable priority. 

What do you mean by "critical-function close interrupts"? Is it a function in MCAL or from FreeRTOS? And "then there are other interrupts", are they interrupts that cause MCU wake up?

2. ICU interrupt can be used to wake up MCU.

Best Regards,

Nam

0 Kudos
2,910 Views
ananan
Contributor III

Sorry, my expression is not clear, what I mean is that the critical function prevents the execution of interruption.
After executing the WFI command, the program will stop here as shown in the picture. When I perform single-step simulation, the program will continue to execute, but when I run the program completely and press the stop button, it will stop at the break, I don't know whether it stops at WFI

ananan_0-1631838886524.png

 

0 Kudos
2,898 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

It's a limitation when using debugger to verify the VLPS mode, as far as I know by performing step-by-step, the debugger will always keep the core clock, so it will end up with exit VLPS immediately. You can verify with debugger by performing these steps:

1. Set a breakpoint in the instruction right after the wfi in EXECUTE_WAIT (you can find it in Disassembly window)

2. Press run. If your program keep running and is only suspended by either "pause" button or wake up source , then the core has entered and exited VLPS. Otherwise if it stop immediately at breakpoint, then the core hasn't entered VLPS yet, and you will need to check for the reason.

namnguyenviet_0-1631871786541.png

 

For sure you should check the VLPS entry without debugger, by either measure the power consumption via VDD or measure the CLKOUT - CLKOUT should be off during VLPS. Please note that the VLPSA bit is always set after exit VPLS during debug, so I suggest that you can check VLPSA by toggle a LED or by setting a variable during runtime.

Best Regards,

Nam

0 Kudos
2,875 Views
ananan
Contributor III

How to check the VLPSA bit in the MCAL?

0 Kudos
2,862 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

1. 15mA in VLPS seems a little bit high. What is the value of power consumption before entering VLPS? Are you turning on any peripherals/output (LEDs,...) during VLPS?

2. VLPSA can't be checked by MCAL. You can develop VLPSA checking in your interrupt handler, e.g. in the ICU wakeup interrupt handler:

void Wakeup_Detection_Cbk (void)
{
        if ((SMC->PMCTRL & (1 << 3)) != 0) //check VLPSA bit
        {
            /* Turn on the LED */
            PTB->PDOR &= (~(1 << 22));
        }
        else
        {
            /* Turn off the LED */
            PTB->PDOR |= (1 << 22);
        }
}
Best Regards,
Nam
0 Kudos
2,853 Views
ananan
Contributor III

Hi,nan
1.The current is 125mA Before entering VIPS.some peripherals such as SPI ,adc had be De_init. but the ports(such as led driver) does nothing.what to do about the ports before going to VIPS.
2.thank you very much about your help! I will do as your mentions!

0 Kudos
2,895 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

It's up to you with the port, because port isn't required to be turned off during VLPS. To limit the power consumption, you can consider turn off the port as LED driver if any.

The power consumption dropped from 125mA to 15mA seems to be good, at least it proved that your CPU has entered VLPS. However, if your application requires an even lower power consumption in VLPS, then you might need to turn off/switch the clock source to SIRC for every peripherals.

Best Regards,

Nam

0 Kudos
2,862 Views
namnguyenviet
NXP Employee
NXP Employee

Hello @ananan,

For your information, the MCAL 4.3 RTM 1.0.2 has supported VLPSA bit checking. So you can consider download the RTM 1.0.2 version to use.

Best Regards,

Nam

0 Kudos
2,877 Views
ananan
Contributor III

 I measure the power consumption via VDD is 15mA

0 Kudos