<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>create a variable that maintains the value after module sleep</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35819/create-a-variable-that-maintains-the-value-after-module-sleep</link><description>Hello, 
 I am develop a project with nRF52832 and I use nRF5_SDK_14.2.0 and softdevice s132. 
 My problem is I need create a variable that maintains the value after of the module have been in sleep state. 
 how can I create this variable? 
 
 Regards</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Jun 2018 10:03:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35819/create-a-variable-that-maintains-the-value-after-module-sleep" /><item><title>RE: create a variable that maintains the value after module sleep</title><link>https://devzone.nordicsemi.com/thread/138067?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 10:03:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa2b1204-d6bd-42dc-8ce4-90b2f02e8df4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Yes, perfect example for you in the SDK you are using&lt;/p&gt;
&lt;p&gt;SDK14.2\examples\peripheral\ram_retention\main.c.&lt;/p&gt;
&lt;p&gt;But in this example the whole of RAM is retained. In your case, just keep only that 4K RAM block retained in which the address you selected for your variable resides.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: create a variable that maintains the value after module sleep</title><link>https://devzone.nordicsemi.com/thread/138008?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 07:06:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e74d539b-f478-4fcb-87ab-f5e32ed64d33</guid><dc:creator>Toyman</dc:creator><description>&lt;p&gt;Is there an example or simply a piece of code for (2)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: create a variable that maintains the value after module sleep</title><link>https://devzone.nordicsemi.com/thread/138000?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 06:08:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c2adc90-04a0-4e6b-827f-3cc45f54c28d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;In IDLE sleep (WFE) you do not need to worry about this as the RAM is kept alive, so I am assuming you are talking about SYSTEM_OFF sleep.&lt;/p&gt;
&lt;p&gt;There are few ways to do it.&lt;/p&gt;
&lt;p&gt;1) You can use persistent storage (flash) and use the flash libraries to create a smaller block which you can easily address in any state of your system startup. Since you are already using the SDK, I assume you know &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Flib_fds.html&amp;amp;cp=4_0_1_3_50"&gt;fds &lt;/a&gt;and &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Flib_fstorage.html&amp;amp;cp=4_0_1_3_51"&gt;fstorage &lt;/a&gt;libraries.&lt;/p&gt;
&lt;p&gt;2) You can force a variable initialization to reside at a &lt;a href="https://mcuoneclipse.com/2012/11/01/defining-variables-at-absolute-addresses-with-gcc/"&gt;particular address&lt;/a&gt;&amp;nbsp;and then you can configure the RAM section individually to be &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fpower.html&amp;amp;cp=2_1_0_17_4&amp;amp;anchor=ram_sections"&gt;kept ON&lt;/a&gt; during system OFF state. This will not consume too much current as a RAM block of 4KB size will only consume &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fpower.html&amp;amp;cp=2_1_0_17_9&amp;amp;anchor=unique_369110630"&gt;20nA extra average current&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;3) If you are writing only once and reading multiple times, you can use one of the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fuicr.html&amp;amp;cp=2_1_0_13_0_27&amp;amp;anchor=register.CUSTOMER-0"&gt;UICR-&amp;gt;CUSTOMER[X]&lt;/a&gt; register. Note that unlike option 1) you will be able to write to this register only once (without full chiperase)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>