<?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 Banks (RAM retention)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/272/ram-banks-ram-retention</link><description>How are the four RAM banks divided up in the nRF51822? Is it an even split of the 16K total RAM (i.e. 4K per block)? 
 Furthermore, can I expect strange results if I turn on RAM-retention for the 8K of RAM the SoftDevice uses? 
 Thanks :)</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 14 Aug 2013 06:26:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/272/ram-banks-ram-retention" /><item><title>RE: RAM Banks (RAM retention)</title><link>https://devzone.nordicsemi.com/thread/1476?ContentTypeID=1</link><pubDate>Wed, 14 Aug 2013 06:26:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a1b172a-a5d1-4586-b298-64d7a768b35b</guid><dc:creator>Nick</dc:creator><description>&lt;p&gt;Thanks for the hints. Unfortunately I am not using Keil but instead gcc-arm.&lt;/p&gt;
&lt;p&gt;This is how you do it for GCC for those who are interested:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Add the following to the linker script (in SECTIONS, before bss):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;   .noinit (NOLOAD) :
	{
		*(.noinit*)
    } &amp;gt; RAM
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; In your source code for each variable you want retained:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;static uint8_t varName __attribute__ ((section(&amp;quot;.noinit&amp;quot;)));&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s it! Working perfectly :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM Banks (RAM retention)</title><link>https://devzone.nordicsemi.com/thread/1475?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2013 12:08:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5f28ac9-3c3a-4c45-93d1-c0a47a6a4c4f</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;Exactly how to do this will depend on toolchain used. I&amp;#39;ve edited my answer to provide a little more info.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM Banks (RAM retention)</title><link>https://devzone.nordicsemi.com/thread/1474?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2013 11:51:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf4998bc-b6ea-4716-a09c-9d6b40bb5e56</guid><dc:creator>Nick</dc:creator><description>&lt;p&gt;Thanks. Looks like the RAM might be getting cleared at startup though as you mentioned. Any idea what would be the typical cause? (something in the startup file I assume?)&lt;/p&gt;
&lt;p&gt;Thanks again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM Banks (RAM retention)</title><link>https://devzone.nordicsemi.com/thread/1473?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2013 11:21:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0046339-8ac2-4866-956b-c55a69a2f1f0</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;The size of the RAM blocks are given in section 3.2.2 in the PS.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t believe anything strange should happen if you enable RAM retention with the S110, but I&amp;#39;m not sure whether it has been tested or not.&lt;/p&gt;
&lt;p&gt;It should be noted that you may need to take some care to avoid the RAM being zeroed on startup.&lt;/p&gt;
&lt;p&gt;Such care will be toolchain specific, but &lt;a href="http://www.keil.com/forum/13461/"&gt;this thread on Keil&amp;#39;s forums&lt;/a&gt; contains some tips on how to do it with Keil:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Exclude the memory area from the project settings, and just use a raw pointer.&lt;/li&gt;
&lt;li&gt;Use a scatter-file and declare an area as UNINIT, like this:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;
RW_RTCRAM 0xE0084000 UNINIT 0x000007FF
{
    main.o (rtc_ram)
}

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Edit 1: Added info on how to avoid initialization.
Edit 2: It seems that marking a section of the memory as NoInit in Keil&amp;#39;s target options should also do the trick, according to &lt;a href="https://devzone.nordicsemi.com/index.php/discussions/static-data-not-cleared-by-arm_startup_nrf51-s"&gt;this question&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>