<?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>Example code for using Non volatile memory</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/603/example-code-for-using-non-volatile-memory</link><description>I want to store a block of data in nRF51x22. I tried the following: 
 void HalStoreNVMBlock(uint32_t size, uint8_t* pBuf)
{
nrf_nvmc_page_erase(NRF_UICR_BASE);
nrf_nvmc_write_bytes(NRF_UICR_BASE, pBuf, size);
} 
 but after this code was executed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Oct 2013 06:04:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/603/example-code-for-using-non-volatile-memory" /><item><title>RE: Example code for using Non volatile memory</title><link>https://devzone.nordicsemi.com/thread/3136?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2013 06:04:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29d6b383-9e5c-40ba-b813-6dd13095bc52</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;Good! I&amp;#39;d be happy if you could accept one answer, by clicking the accept button below it, to mark this discussion as solved. :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Example code for using Non volatile memory</title><link>https://devzone.nordicsemi.com/thread/3135?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2013 06:03:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4243f9f-32e5-4aab-9634-3a17f99bb59f</guid><dc:creator>Klaus Karkov</dc:creator><description>&lt;p&gt;Thank you very much for your answer.
I will go for the full flash page solution, because it’s unknown how many times the user will change the NV setup parameters.
I consider this case successfully closed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Example code for using Non volatile memory</title><link>https://devzone.nordicsemi.com/thread/3134?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2013 11:59:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5151612-e5fb-41a3-8c3e-f1c8e010efe0</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;If you just need to store 8 bytes, you should be able to just write them to the correct part of UICR without erasing anything first. This can also be done with nrfjprog or similar, during production.&lt;/p&gt;
&lt;p&gt;When reading UICR, you should see that CLENR0 register at offset 0 (full address 0x10001000) is 0x14000 and that the FWID register at offset 0x10 also have a non-0xFF value, if you have programmed the S110 softdevice.&lt;/p&gt;
&lt;p&gt;I would strongly recommend you to not do an erase of UICR during run-time in your application, since this could potentially give you a bricked device if an external reset/power-loss happens just after erasing. If you need to change the value, I&amp;#39;d recommend you to either just cycle through UICR, and stop when it&amp;#39;s full, or just use a regular flash page, even though the size needed is small.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Example code for using Non volatile memory</title><link>https://devzone.nordicsemi.com/thread/3133?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2013 10:39:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0aebc0fa-c595-4eb4-9e24-ca874c1b15b8</guid><dc:creator>Klaus Karkov</dc:creator><description>&lt;p&gt;Hi Ole
Thanks’ very much for your quick answer.
Basically I only need to store 8 bytes, so using a full flash page for that seems like overkill.
I have tried reading out the first 1024 bytes of UICR (address 0x10001000 - 0x10001400) and they are all 0xff. I then tried writing 0x55 to offset 0x80 (Reserved for customer) and it worked fine.
I can’t see the application start address (BOOTLOADERADDR from nrf51.h) as it seems to be 0xffffffff.
If I could see the data I’m not allowed to erase, I could save it before erasing, and then write it back after the erase. Is that possible?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Klaus Karkov&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Example code for using Non volatile memory</title><link>https://devzone.nordicsemi.com/thread/3132?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2013 07:27:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63ec3c8c-1f84-46fb-a1dc-2d4780006c53</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;When using a softdevice, the base address of the application is stored in UICR, and if you delete the entire UICR register, the softdevice will therefore no longer know where or how it can start the application.&lt;/p&gt;
&lt;p&gt;If you just want to store a little configuration data, you can use the upper bytes of the UICR register, but there is no convenient way to erase this part without erasing the rest of UICR.&lt;/p&gt;
&lt;p&gt;If you need to store and remove more data, I&amp;#39;d therefore recommend you to just use a normal flash page for this. There have been quite some discussion on how to do such flash writes in &lt;a href="https://devzone.nordicsemi.com/index.php/how-to-handle-flashwrit-in-an-safe-way#reply-1745"&gt;this question&lt;/a&gt;, so it might be worth having a look at. I believe that should be more or less sufficient to get going, but please let me know if anything is still unclear.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>