I could not get the chip KL27Z64VFM4 wake up from sleeping mode with interrupt. I followed AN4503 power management for Kinetis. When I remove line asm("WFI"); the MCU could not goes into sleep. I don't know what I did wrong?
here is the code:
Initial(); //main clock =2MHz LIRC Bus/flash =500KHz.
Main
{
Process();
Sleep();
}
Void sleep(void)
{
SMC->PMPROT = SMC_PMPROT_AVLP_MASK;
SMC->PMCTRL &= ~SMC_PMCTRL_STOPM_MASK;
SMC->PMCTRL |= SMC_PMCTRL_STOPM(0x2);
SMC->PMCTRL=SMC->PMCTRL;
SCB->SCR |=(1UL << 2U); //SCB_SCR_SLEEPDEEP_MASK;
asm("WFI");
__enable_irq();
}
Hi Albert,
That Application Note use APIs of Kinetis software development kit (SDK). The KSDK is no more recommend for new design.
Please download the latest MCUXpresso SDK.
Then refer the power example in SDK_2.6.0_MKL27Z64xxx4.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Robin,
Thanks for your respond to my question. I know the MCUxpressor is newer but my kinetis is holding the old project
I have to use. I just try to add a couple lines of code to get the chip to sleep and wakeup by LPUART1.
Could please help me to solve the problem?
Oh, I did add the line in the initial();
SMC->PMPROT =BIT5+BIT3+BIT1; //42
Albert
Hi Albert
Beware that SMC_PROT is a 'write-once' register and so if you set it in initialisation code it can never be changed again (until after a power cycle).
If I interpret your code correctly you are setting VLPS mode. This only allows asynchronous interrupts on the UART so you need to make sure that you enable RxD edge detection for it to be able to wake you.
See also VLPS with continuous UART operation: https://community.nxp.com/message/421247#421247
Regards
Mark
Complete Kinetis solutions for faster/more efficient professional needs, training and support: http://www.utasker.com/kinetis.html
i.MX RT project compatibility: http://www.utasker.com/iMX.html
Including FreeRTOS integration for all Kinetis parts
Kinetis KL25, KL26, KL27, KL28, KL43, KL46, KL82
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL43Z.html
- http://www.utasker.com/kinetis/TWR-KL43Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL46Z.html
- http://www.utasker.com/kinetis/TWR-KL46Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html
Open Source version at https://github.com/uTasker/uTasker-Kinetis
https://community.nxp.com/thread/512558
https://community.nxp.com/thread/352862
https://community.nxp.com/thread/498809
Hi Mark,
Thanks for your response.
Do you mean I need also enable the RX pin with failing edge in order to wake up the VLPS mode? I will try that.
The original code has LPUART1 interrupt working.
Best regards,
Albert Zhou
Sr. Electronics Engineer
Sensorex
p:
+1 714 230 2768
a:
11751 Markon Drive, Garden Grove, CA 92841
w:
e:
albert.zhou@sensorex.com<mailto:albert.zhou@sensorex.com>
<https://www.facebook.com/Sensorex> <http://t.sidekickopen05.com/s1t/c/5/f18dQhb0S7lM8dDMPbW2n0x6l2B9nMJN7t5X-Ff4Yc8W4WJpMP7dWWcgW6ND00211fj5b0?t=https%3A%2F%2Ftwitter.com%2FSensorexInc&si=7000000000014733&pi=ca5a45ef-58ca-4f28-9010-24a9c3d147a2> <http://t.sidekickopen05.com/s1t/c/5/f18dQhb0S7lM8dDMPbW2n0x6l2B9nMJN7t5X-Ff4Yc8W4WJpMP7dWWcgW6ND00211fj5b0?t=https%3A%2F%2Fwww.linkedin.com%2Fcompany-beta%2F1768298%2F&si=7000000000014733&pi=ca5a45ef-58ca-4f28-9010-24a9c3d147a2>
Yes, in VLPS the UART is not actually working - its clocks are stopped - but it can detect an edge on its RxD line (asynchronous) and wake from that. Whether you miss the data depends on the UART speed, the clock used in RUN mode and the time it takes for the processor to get these ready after waking.
Regards
Mark
Hi Mark,
I see in VLPS mode, the LPUART1 is not actually working. How to make the RxD line as a pin interrupt and LPUART interrupt both at one pin?
The problem is I could not even get any sleep mode to work. It seems the asm(“WFI”) line disables LPUART1 interrupt.
I tried VLPR mode flowing AN4503 page 41 that does not have any effect in power saving.
What is difference between WAIT and STOP function in 9. Power mode entry?
Best regards,
Albert Zhou
Sr. Electronics Engineer
Sensorex
p:
+1 714 230 2768
a:
11751 Markon Drive, Garden Grove, CA 92841
w:
e:
albert.zhou@sensorex.com<mailto:albert.zhou@sensorex.com>
<https://www.facebook.com/Sensorex> <http://t.sidekickopen05.com/s1t/c/5/f18dQhb0S7lM8dDMPbW2n0x6l2B9nMJN7t5X-Ff4Yc8W4WJpMP7dWWcgW6ND00211fj5b0?t=https%3A%2F%2Ftwitter.com%2FSensorexInc&si=7000000000014733&pi=ca5a45ef-58ca-4f28-9010-24a9c3d147a2> <http://t.sidekickopen05.com/s1t/c/5/f18dQhb0S7lM8dDMPbW2n0x6l2B9nMJN7t5X-Ff4Yc8W4WJpMP7dWWcgW6ND00211fj5b0?t=https%3A%2F%2Fwww.linkedin.com%2Fcompany-beta%2F1768298%2F&si=7000000000014733&pi=ca5a45ef-58ca-4f28-9010-24a9c3d147a2>