When the uc executes WFI, after waking up with an interrupt, both DeepSleep and SleepOnExit are false.
In what case might it stop at WFI next instruction(e.g. suspendInt) and does not execute the following code?
Hi @Bleach,
Yes, DIVCORE = 1 (/2), DIVBUS = 1 (/2).
PREDIV_SYS_CLK frequency / BUS_CLK frequency = 4
I have noticed that SOSCEN = 1.
The clock must be disabled before WFI.
Also, make sure all the peripherals that re not used in VLPS are disabled.
Thank you,
BR, Daniel
Hi Daniel,
Thanks for your review!
After I disabled the SOSCEN(set to 0), this issue is still here.
As the below. I found direct reason is that if interrupt is active after ResumeAllInterrupt and before wfi, mcu will be in deepsleep and can not run on with one interrupt.
If one interrupt occurs before wfi, will this situation cause the mcu to fail to run after deepsleeping?
Hi @Bleach,
Refer to Application Note 321 ARM Cortex-M Programming Guide to Memory Barrier Instructions
https://developer.arm.com/documentation/dai0321/latest/
Section 4.7 Enabling interrupts using CPS instructions and MSR instructions
Between "CPSIE I" and "WFI" , you could write S32_SCB->SCR and read the register back so that the memory access is serialized.
S32K1xx RM, Section 3.4.1 Read-after-write sequence and required serialization of
memory operations
Regards,
Daniel
Hi Daniel,
Thank u so much!
I'll look at these sections.
By the way, why was this bug not implemented in "wfi"?
Could you create a new ticket / thread about the MCAL bug,
Can you please elaborate on the description there.
Keep in mind that the MCAL version is already a legacy SW
Regards,
Daniel
Hi @Bleach,
I haven't encountered this is before.
But DeepSleep should be set in all the S32K1xx low-power modes.
BR, Daniel
Yes.
Before WFI, deepsleep will be set.
After WFI, I will disable deepsleep in the wakeup interrupt.
Do you mean this deelpsleep should be kept set after WFI?
Hi @Bleach,
No, DeepSleep does not have to be set all the time.
It could be related to ERR011063
https://www.nxp.com/webapp/Download?colCode=S32K144_0N57U
Please double check the clock configuration.
Regards,
Daniel
Hi Daniel
Thanks for response.
One more question: If we want to enter into VLPS, whether setting SleepOnExit bit before WFI and clearing SleepOnExit in interrupt could cause this issue?
P.S. I confirmed that clock configuration meets the errata ERR011063. I'll double check again.
Hi @Bleach,
Setting and clearing SleepOnExit should not cause any problems.
SleepOnExit can be enabled and disabled anytime.
As for errata ERR011063, the below is the clock before WFI execution.
Could you help me to find whether the clock is right? Thank u!