K64F how to enter VLPS stop mode

Showing results for 
Search instead for 
Did you mean: 

K64F how to enter VLPS stop mode

Contributor II

I have been struggling to get my FRDM K64F board to enter VLPS mode. Here's my code to enter stop mode:

       disable_irq(); // Disable Interrupts

SMC ->PMPROT |= 0x20; //allow VLPS mode

SMC ->PMCTRL |= 0x02; //select VLPS mode

tmp = SMC ->PMCTRL; //dummy read

//clear watchdog STOPEN for giggles, maybe it's the culprit

WDOG ->UNLOCK = 0xC520;
WDOG ->UNLOCK = 0xD928;
WDOG ->STCTRLH &= ~0x0040;

//WDGEN is already 0



asm("WFI"); //sleep instruction

Nothing happens and my test blinky keeps running. 

Should I disable all peripherals first? Is it enough to disable the clock gates for the peripherals? Should the 48Mhz IRC clock be disabled? I think it is disabled at least in MCG_C7 and SIM_SOPT2. The USB RECOVER_IRC_EN register I could not check because my program would lock up when I try to read it(explanation for this would also be nice..:smileylaugh:). Should I change system clock source to the 4Mhz IRC first? I'm starting to go nuts with the reference manual. It does not clearly state any of these things. 

0 Kudos
2 Replies

Specialist V


Just get the free Open Source uTasker project from GIT hub as reference since it integrates proper low power mode without any effort.

However, a typical first mistake is that you may find that your initialisation code is writing PMPROT to 0. This is a "write-once" register and so any additional writes that you attempt will be ignored - and then no low leakage modes will be accepted.



Kinetis: http://www.utasker.com/kinetis.html
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html
Low power and LLWU: http://www.utasker.com/kinetis/LLWU.html
Low power videos:
- https://youtu.be/kWNlsAoMly4
- https://youtu.be/iZEMRiDmHzw
- https://youtu.be/v4UnfcDiaE4

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M

Professional Kinetis support, one-on-one training and complete fast-track project solutions: http://www.utasker.com/support.html

0 Kudos

Contributor II

Hi Mark

Yes, I have now found that the problem is again due to the, seemingly horrendous, mbed environment that I'm using. By reading PMCTRL after reset the STOPA bit was always high which probably means that there is still some interrupt doing its thing and preventing stop mode, although I have called disable_irq. 

I'm used to work with Eclipse and STM32 standard libraries, so as a pleasant surprise I found the NXP Kinetis SDK wizard plug-in for Eclipse and all the peripheral drivers, which seem to be very similar to the STM32 system. Installation was quick and I got VLPS working in under 10 minutes! Remarkably, code size for a basic blinky program is about 4kb done with the Kinetis SDK and about 25kb with the mbed SDK. Ridiculous.

Thanks for the links. I'll have to look at uTasker too, seems useful.

0 Kudos