Hello,
I am working on a K60 custom board with MQX 4.2 and I am having issues putting the processor to STOP mode (LLS). It seems the WFI instruction has no effect. _lpm_set_operation_mode(LPM_OPERATION_MODE_STOP) is called from PEE at 96 Mhz. Clock config was done using Processor Expert, the custom board has a 8 MHZ resonator. Before WFI is executed, here are the registers:
SIM_SCGC4 = 0xF0100070 -> LLWU is set
LLWU_ME = 0x01 -> WUME0 is selected for wakeup source
MCG_C6 = 0x40 -> clock monitor disabled
MC_PMPROT = 0x2A -> LLS is allowed
MC_PMCTRL = 0x8B -> STOPM to Low-Leakage Stop (LLS), RUNM=00
SCB_SCR = 0x04 -> SLEEPDEEP bit is set
After WFI instruction:
LLWU_F3 = 0x00 - > Module 0 input was not a wakeup source
SMC_PMCTRL = 0x8B -> STOPA is set
I also tried the Lowpower mqx example without success.
Any help would be appreciated, Thank You.
解決済! 解決策の投稿を見る。
Thank you David but I found the problem. In lpm_smc.c, there is a SPI workaround(ENGR00178898) where SPI clocks are disabled before calling WFI. This fix is incomplete as it only takes care of SPI0 and SPI1. On my custom board, SPI2 is used so the following lines must be added.
/*before _ASM_SLEEP(NULL)*/
#ifdef SIM_SCGC3_SPI2_MASK
SIM_SCGC3 &= ~SIM_SCGC3_SPI2_MASK;
#endif
/*after _ASM_SLEEP(NULL)*/
#ifdef SIM_SCGC3_SPI2_MASK
SIM_SCGC3 |= SIM_SCGC3_SPI2_MASK;
#endif
Thank you David but I found the problem. In lpm_smc.c, there is a SPI workaround(ENGR00178898) where SPI clocks are disabled before calling WFI. This fix is incomplete as it only takes care of SPI0 and SPI1. On my custom board, SPI2 is used so the following lines must be added.
/*before _ASM_SLEEP(NULL)*/
#ifdef SIM_SCGC3_SPI2_MASK
SIM_SCGC3 &= ~SIM_SCGC3_SPI2_MASK;
#endif
/*after _ASM_SLEEP(NULL)*/
#ifdef SIM_SCGC3_SPI2_MASK
SIM_SCGC3 |= SIM_SCGC3_SPI2_MASK;
#endif
Be careful with this peripheral clock clearing/setting as it does not work for SLEEP mode since the core will execute the event that takes the core out of SLEEP which can attempt to use the SPI[0-2] causing Hardfaults.
Hi Louise-Philippe,
If you have problem with Lowpower example in MQX my guess is you have the debugger/IDE being used during test. If debugger interface active the device will not go into low power mode. You need to disconnect the debugger and let application run independently.
If your debugger interface is not being used maybe there is outstanding ISR request for some reason???
Regards,
David