sleep VLLS mode retain sram not working?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sleep VLLS mode retain sram not working?

1,505 Views
mjg8t
Contributor IV

Hi there,

I need to go into low power and retain RAM.  The VLLS3 mode should do this no problem.  I have taken the demo application "power mode switch" to base my application on.  The demo seems to work fine going in and out of power modes.  But, when I check the SRAM contents of data should not be lost on wake it always reads zero.   I added a "count" variable which is output to the UART and the count should be incremented each time the device is put to sleep.  But the count always reads 0.  

 

Should I be doing anything special to retain the SRAM during VLLS3?

 

I have created a standalone project and attached.  

Original Attachment has been moved to: k22f_low_power_standalone.zip

Labels (1)
0 Kudos
Reply
4 Replies

1,230 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi mjg8t,

Would you please specify which KSDK version and which platform you are using? I am trying to reproduce this issue on my side. Thanks for your patience!

B.R

Kan

0 Kudos
Reply

1,230 Views
mjg8t
Contributor IV

Hi Kan. Sorry I forgot to specify. I am using ksdk 2 and the frdm k22f.
Thanks!

0 Kudos
Reply

1,230 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi mjg8t,

I am sorry, but I found maybe this issue is a code issue, you should not define the "count" variable in a normal way like "volatile uint8_t count;" because waking up from VLLSx mode always follows the system reset processor, so the "count" always gets initialized if you put it in that way, you have to define a pointer to some address in SRAM, where other vars never touch it (this can be achieved by modifying the link file, for example, you may exclude this position out of the memory map), and read the content from where the pointer is referring to, modify the content, and restore it. so that you may find the value incremented each time the device wakes up from VLLS3 mode.

Here I attached my test code, which is based on the demo of power_mode_switch_frdmk22f, locating in SDK_2.1_FRDM-K22F\boards\frdmk22f\demo_apps\power_mode_switch\kds. For quicker response, I didn't modify the link file, just make the pointer refer to 0x20000300, where the SRAM is retained even under VLLS2 mode. You may search 0x20000300 to find out the code I added for test.

To avoid 0x20000300 be initialized by the main application every system reset, I got it initialized to zero when the device enter STOP mode, it is just for a cleaner view for reset counter, you may ignore this if you don't care about the value out of reset.

Please kindly refer to the attachment for details.


Hope that helps,
Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,230 Views
mjg8t
Contributor IV

Thanks for clearing that up Kan.  

For reference here is a forum that talks about how to define variables in the non-volatile ram in the linker, which I needed:

How to preserve variables from initialization after VLLS3 

Also, I spent a lot of time jumping around in the low power switch demo to understand all the steps to get into the appropriate power modes.  The demo also consumes more current than it needs to >35-40uA in LLS, or VLLS.  In LLS mode the current should be <5uA.  So the demo code is not properly initializing or de-initializing pins/peripherals to get this power level.  I have modified the design with a single function call to put the device into the LLS and get the correct power with wake using button, or LPTMR, both consume <5uA.  There is a #define DEMO switch which will run the stock demo or my "simple" modified version, in case anyone else wants a quicker way of seeing the steps.  

0 Kudos
Reply