Hello
I'm finding some trouble when I switch my application from RUN to VLPS and then again to RUN.
Normally everything works correctly but sometimes it seems to fail and my application resets for watchdog event.
I'm using the SDK 4.01, so please let me know if invoking "POWER_SYS_SetMode(VLPS, POWER_MANAGER_POLICY_AGREEMENT);" is enough or if I have to make something else.
Is the switch from VLPS to RUN automatic when an interrupt happens? (LIN or LPTMR for instance). At the moment I'm invoking POWER_SYS_SetMode also for RUN mode.
Please note that:
if I use the STOP1 or STOP2 mdoe instead of VLPS, I don't have trouble (no resets);
if I use VLPR instead of VLPS, I always have trouble (continously resets).
If I use VLPS (that is my aim) I sometimes have troubles (often resets)
Please let me know as soon as you can.
Thank you and kind regards,
Francesco
You need to disable all the peripherals that are not used in VLPS.
Then, call POWER_SYS_SetMode(VLPS), which disables all the clocks (except SIRC if used in VLPS).
After the wakeup, call POWER_SYS_SetMode(RUN) to reenable all the clocks, and enable all the peripherals the application needs.
Regarding the WDOG, I would recommend that you measure the execution time of each API.
Since the SOSC clock must be disabled in VLPx, the SOSC startup in RUN takes some time.
Regards,
Daniel
Hi Francesco,
In general, the ISRs should be as short as possible, the system clock switching takes some time.
You can use the CLOCK_SYS_GetFreq() of the clock driver to verify the clock.
Hi Francesco,
As I said, in general, ISRs should not be that long, POWER_SYS_SetMode() should be called from main().
Calling CLOCK_SYS_GetFreq() is up to you, if you want to confirm a clock configuration. The POWER_SYS_SetMode() sets the clocks.
Not sure about the OSIF. Can you disable the WDOG and see where it is stuck?
Is the core waiting in a loop for a flag to be set, like a clock valid flag etc.
Thank you,
Daniel
Hello Francesco,
If the debugger loses the connection, the MCU is in the VLPS mode. But I would recommed that you measure the power consumption of the MCU. After the wakeup event, you should see an increase in the power consumption again.
You could use CLKOUT to output any system clock, e.g. the BUS_CLK. This example uses CLKOUT:
https://community.nxp.com/t5/S32K-Knowledge-Base/Example-S32K144-RTC-VLPS/ta-p/1119655
So, you should see when the MCU enters VLPS, when it leaves VLPS, and when the power driver changes the clock configuration.
The GPIO should be cleared as the first thing in the wakeup interrupt not after POWER_SYS_SetMode(VLPS).
Also, make sure you don't call POWER_SYS_SetMode(VLPS) from an interrupt routine.
Regards,
Daniel