<?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>Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28482/erasing-uicr-register-in-application-code</link><description>Hello Everyone, 
 I am using nrf51822 with S130.
After completely erasing the chip, with the below mentioned code snippet in application code: 
 NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos; 
 while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Jan 2018 15:30:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28482/erasing-uicr-register-in-application-code" /><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112650?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 15:30:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ae990ec-b9da-4e00-a519-a4c7571fcf11</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Is the softdevice enabled when you call these functions? Note that if the softdevice is enabled, &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.0/group___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html#ga9c93dd94a138ad8b5ed3693ea38ffb3e"&gt;the call will return and generate an event on completion&lt;/a&gt;. If you write right after erasing, the erase operation might not be completed yet. You are not checking the return values from the function calls.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112649?ContentTypeID=1</link><pubDate>Sat, 23 Dec 2017 03:24:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc45c30e-7a44-4195-8285-b48ec1ae4d00</guid><dc:creator>Dhiraj</dc:creator><description>&lt;p&gt;Hello Jorgen,&lt;/p&gt;
&lt;p&gt;It doesn&amp;#39;t work.
I used above mentioned code snippet. It shows data to be &amp;#39;-1&amp;#39;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112652?ContentTypeID=1</link><pubDate>Thu, 21 Dec 2017 11:23:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7fa501d-ec39-44c7-8450-53d29d37a695</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I don&amp;#39;t understand what you mean by your last commend. Does it work when you use the softdevice API?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112651?ContentTypeID=1</link><pubDate>Thu, 21 Dec 2017 08:50:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dffd676-5cfc-4a71-b25c-3f2baccfb899</guid><dc:creator>Dhiraj</dc:creator><description>&lt;p&gt;uint32_t  addr;
uint32_t patwr=0x1F00;
uint32_t *addrloc;
const uint32_t *dataloc;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;addr = (uint32_t) 0x3B000; //(uint32_t *)(pg_size * pg_num);
 addrloc = &amp;amp;addr;
 dataloc = &amp;amp;patwr;

 sd_flash_page_erase(addr);
 sd_flash_write(addrloc,dataloc, 32);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112648?ContentTypeID=1</link><pubDate>Wed, 20 Dec 2017 12:22:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e41fc469-6e4c-47b1-a80d-6d6e0815604d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Are you erasing/writing while the softdevice is enabled? Note that &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.sds/dita/softdevices/s130/sd_resource_reqs/hw_block_interrupt_vector.html?cp=3_7_2_0_6_0"&gt;access to the NVMC peripheral is restricted when the softdevice is enabled&lt;/a&gt;, and should only be accessed throught the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html?cp=3_7_2_1_0_2_7_2_7#ga9c93dd94a138ad8b5ed3693ea38ffb3e"&gt;softdevice flash API&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112647?ContentTypeID=1</link><pubDate>Wed, 20 Dec 2017 09:09:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b60679d6-344e-44ad-81f8-1d0458a2d684</guid><dc:creator>Dhiraj</dc:creator><description>&lt;p&gt;static void flash_page_erase(uint32_t * page_address)
{
// Turn on flash erase enable and wait until the NVMC is ready:
NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Een &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)
    {
        // Do nothing.
    }

    // Erase page:
    NRF_NVMC-&amp;gt;ERASEPAGE = (uint32_t)page_address;

    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)
    {
        // Do nothing.
    }

    // Turn off flash erase enable and wait until the NVMC is ready:
    NRF_NVMC-&amp;gt;CONFIG &amp;amp;= ~(NVMC_CONFIG_WEN_Een &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);

    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)
    {
        // Do nothing.
    }
}

static void flash_word_write(uint32_t * address, uint32_t value)
{
    // Turn on flash write enable and wait until the NVMC is ready:
    NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Wen &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);

    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)
    {
        // Do nothing.
    }

    *address = value;

    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)
    {
        // Do nothing.
    }

    // Turn off flash write enable and wait until the NVMC is ready:
    NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Ren &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);

    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)
    {
        // Do nothing.
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am using above function to erase and write data to location 0x0003B000 (1 page below bootloader).
But device isn&amp;#39;t advertising. When I disable erasing, the device is advertising.
Does that means I am erasing wrong location?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112646?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2017 15:37:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22b258c4-5cb7-4f03-aeb7-d6dced3d71ae</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Please have a look at the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/bledfu_memory.html?cp=4_0_8_4_3_1_3"&gt;Memory layout&lt;/a&gt; and &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/bledfu_memory_appdata.html?cp=4_0_8_4_2_3_3_3"&gt;Preserving application data&lt;/a&gt; sections in the SDK 11 BLE DFU Bootloader documentation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112645?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2017 03:57:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb163c57-b321-4cd2-9cb1-e772c0d04ed9</guid><dc:creator>Dhiraj</dc:creator><description>&lt;p&gt;Thank you for reply, Jorgen.
I am using nrf51822 with 256KB flash and 32KB ram with SDK11, S130 (108kb I guess), with a dfu bootloader (16kb).
I have to store only two data (each 4kb).
Which addresses will be the best suitable addresses to write the two data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112644?ContentTypeID=1</link><pubDate>Tue, 28 Nov 2017 14:34:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5150abe0-4251-4806-87ee-00bd6f4319a0</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You should make sure your application does not overwrite the flash area where the data is stored. In order to overwrite written data, you will have to perform an erase. If your application, or you do not erase the flash, the data will not be overwritten. The best approach is to place the data in the upper region of flash, and reduce the flash size settings in your project to avoid that the application grows into this area.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112643?ContentTypeID=1</link><pubDate>Tue, 28 Nov 2017 04:57:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb0c0977-3b9a-43a4-b987-fa1fc1ce53a0</guid><dc:creator>Dhiraj</dc:creator><description>&lt;p&gt;Can I use particular area of flash memory to write data?
So that even if application code is updated, the particular reserved area will not be erased.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112639?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 12:48:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0efccf1-d4ed-4dc5-9362-441adc1064b1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;No, you need to erase whole chip or &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/nvmc.html?cp=2_1_0_10_3#concept_p4n_mbz_vr"&gt;switch to nRF52 series&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112641?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2017 14:51:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7659c80c-3642-4bb2-a8bb-c63e9b28cc17</guid><dc:creator>Dhiraj</dc:creator><description>&lt;p&gt;Is there any other way to achieve the same?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112642?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:52:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f319cb92-5a27-40b5-9274-18a4326fd837</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If it does not work, you probably does not have a chip with pre-programmed factory code, as mentioned in the post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112640?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 06:18:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9071051c-2834-4b99-8cea-64d75491248b</guid><dc:creator>Dhiraj</dc:creator><description>&lt;p&gt;Hello John,&lt;/p&gt;
&lt;p&gt;Thank you for your reply.
I tried erasing the UICR using following code:&lt;/p&gt;
&lt;p&gt;NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Een &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos;&lt;/p&gt;
&lt;p&gt;while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}&lt;/p&gt;
&lt;p&gt;NRF_NVMC-&amp;gt;ERASEUICR = 1;&lt;/p&gt;
&lt;p&gt;while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}&lt;/p&gt;
&lt;p&gt;But it doesn`t work.
I followed this forum :&lt;a href="https://devzone.nordicsemi.com/question/35099/erasing-uicr-doesnt-work-on-s130/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;
which mentions that ERASEUICR is not available functionality on all chip configurations. It is only available when there is a pre-programmed factory code is present in the chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing UICR register in application code</title><link>https://devzone.nordicsemi.com/thread/112638?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2017 21:44:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b963cd39-3edd-4755-a976-dc5a8c96e45f</guid><dc:creator>John</dc:creator><description>&lt;p&gt;On the nRF51822 you cannot programatically erase the UICR. If you go to a newer variant such as the nRF52840, there is a ERASEUICR register in the NVM controller. I haven&amp;#39;t checked the nRF52832 to see if it supports that register as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>