<?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>RAM data is retained without power?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74516/ram-data-is-retained-without-power</link><description>SDK: 17.0.2 
 IDE: SES 
 nRF52832 module 
 Hi! 
 I have a nRF52832 based custom board operating on battery power. I assigned a variable to the non_init section in SES and loaded a value. I expected this would disappear if I disconnected power, so I unhooked</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Apr 2021 21:03:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74516/ram-data-is-retained-without-power" /><item><title>RE: RAM data is retained without power?</title><link>https://devzone.nordicsemi.com/thread/307566?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 21:03:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b0cb7ca-88b4-4f2f-9dd0-eec91eb8b623</guid><dc:creator>maxx44</dc:creator><description>&lt;p&gt;I was able to verify this method works.&amp;nbsp; Good work and thanks again!&lt;/p&gt;
&lt;p&gt;I was trying something very similar, but just placed a code in the .non_init variable versus reading the RTC device ID.&amp;nbsp; I wasn&amp;#39;t able to step through with the debugger, but as you pointed out it works OK if you disconnect the J-Link and just run on the board cycling power.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll mark your post as the verified answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM data is retained without power?</title><link>https://devzone.nordicsemi.com/thread/307338?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 22:51:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33000287-756d-4a5b-a9f1-57a6724f8346</guid><dc:creator>maxx44</dc:creator><description>&lt;p&gt;Thanks!!!&lt;/p&gt;
&lt;p&gt;I&amp;#39;m going to give this a try and see if I can work it in to my application.&amp;nbsp; May take a day or 2.&amp;nbsp; So far what you presented above compiles.&amp;nbsp; Some additions for the one time code and testing to follow.&amp;nbsp; I&amp;#39;ll report back.&lt;/p&gt;
&lt;p&gt;Yes, I am using the standard section placement file .... hopefully I&amp;#39;ll be OK with that.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Max&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM data is retained without power?</title><link>https://devzone.nordicsemi.com/thread/307335?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 21:14:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:958f0619-7c50-4cf6-a691-e7759231ae78</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;This works well, and is only invoked if RAM was lost on a power loss or other first-time power-up situation:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// One-time unique key, Use for example unique device ID as the valid signature
static volatile uint32_t mIamInitializedRTC __attribute__((section(&amp;quot;.non_init&amp;quot;)));

    // See if RTC data is valid - Use unique device ID as the valid signature
    if (mIamInitializedRTC != NRF_FICR-&amp;gt;DEVICEID[0])
    {
       // Key not valid, perform the 0ne-time initialisation
       ClearRTC_Timers();
       // Indicated data is now valid - Use unique device ID as the valid signature
       mIamInitializedRTC = NRF_FICR-&amp;gt;DEVICEID[0];
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I use this on nRF52832 and nRF52840 with no issues. The section placement file already handles the &lt;em&gt;non_init&lt;/em&gt; section unless you are using a modified file.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  &amp;lt;MemorySegment name=&amp;quot;RAM&amp;quot; start=&amp;quot;$(RAM_PH_START)&amp;quot; size=&amp;quot;$(RAM_PH_SIZE)&amp;quot;&amp;gt;
    ...
    &amp;lt;ProgramSection alignment=&amp;quot;4&amp;quot; load=&amp;quot;No&amp;quot; name=&amp;quot;.non_init&amp;quot; /&amp;gt;
    ...
  &amp;lt;/MemorySegment&amp;gt;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM data is retained without power?</title><link>https://devzone.nordicsemi.com/thread/307318?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 17:54:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22dd911a-2187-4483-a64a-74836094b8ad</guid><dc:creator>maxx44</dc:creator><description>&lt;p&gt;Yes, worth a try.&amp;nbsp; I&amp;#39;ll give it a shot.&amp;nbsp; :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM data is retained without power?</title><link>https://devzone.nordicsemi.com/thread/307317?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 17:53:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ec8f7a5-514d-4edd-9bb2-3a30e3ac0c86</guid><dc:creator>maxx44</dc:creator><description>&lt;p&gt;What I&amp;#39;d like to do is have a variable be set to zero (or some value) on initial power up.&amp;nbsp; Then on initialization I could look to see if it&amp;#39;s telling me this is an initial power on startup.&amp;nbsp; I&amp;#39;d then execute some code that I want to ONLY be run once on power on.&amp;nbsp; I thought to do this I would declare the variable to be in the .non_init segment and have my initial power on code write some known value in it which would not change with any subsequent resets and initialization and would be kept as long as power was on (i.e. my battery has not expired).&amp;nbsp; I was surprised to find that once I wrote a value into my .non_init variable, unplugging the battery did not cause that value to disappear.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I thought the GPREGRET registers might work for this, but I plan to have DFU and that uses them.&lt;/p&gt;
&lt;p&gt;I suspect this might be done with a modification of the Segger section placement file plus perhaps some code to define the initial state of the .non_init RAM section and load it.&amp;nbsp; I can&amp;#39;t claim I know what I&amp;#39;m doing there though and would take a while to figure it out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM data is retained without power?</title><link>https://devzone.nordicsemi.com/thread/307314?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 17:04:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c10b968-568d-400f-af01-08a11920103f</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Closing SES won&amp;#39;t help; try physically removing the J-Link or other hardware SWD connection including any serial port sniffers or other test connections; worth a try.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM data is retained without power?</title><link>https://devzone.nordicsemi.com/thread/307233?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 11:51:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cb79c34-49fb-4c92-a6bd-427702ca9d53</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Max,&lt;/p&gt;
&lt;p&gt;I am not sure entirely what you want to do. Generally though you can never trust the RAM content after a power-cycle or reset, no matter how short time has passed. Some or all data may have been preserved, or it may not have been.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>