<?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>NRF51 Flash write during brown-out</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8022/nrf51-flash-write-during-brown-out</link><description>The v3 reference manual of the nrf51 mentions: 
 
 &amp;quot;[The powerfail comparator] also provides hardware protection of data stored in program memory by preventing write instructions from being executed.&amp;quot; (page 45) 
 
 The meaning of this is not entirely</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 03 Jun 2017 21:45:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8022/nrf51-flash-write-during-brown-out" /><item><title>RE: NRF51 Flash write during brown-out</title><link>https://devzone.nordicsemi.com/thread/28744?ContentTypeID=1</link><pubDate>Sat, 03 Jun 2017 21:45:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:791f8ca4-9a96-4774-b1ff-b3f06459ee07</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;Another thread says 2.3V is adequate for flash write to work.  Can I assume that EVENTS_POFWARN is wired to the internal circuitry that disables the NVMC?  If so, then if, in the ISR you clear EVENTS_POFWARN (set at 2.7V) after determining it is set but before attempting write to flash, the write might succeed?  My goal is, in a browning out system, to write the PC to UICR (not to program flash.)  I don&amp;#39;t need the memory protection, I need to know where in the code it is browning out, while debugging a system that intends to manage power from a weak solar powered supply.  (sans SD.) I might post this as a separate question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 Flash write during brown-out</title><link>https://devzone.nordicsemi.com/thread/28743?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2015 13:00:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dcab334c-3207-4528-bade-ff9dd274dda7</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I have Agilent variable DC output power supply
&lt;a href="http://www.tequipment.net/agilente3631a/"&gt;www.tequipment.net/.../&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 Flash write during brown-out</title><link>https://devzone.nordicsemi.com/thread/28742?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2015 12:56:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9494cc86-527f-41f9-b12a-247d37365c87</guid><dc:creator>Bouke</dc:creator><description>&lt;p&gt;Thanks for the thorough answer! How did you change the input power?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 Flash write during brown-out</title><link>https://devzone.nordicsemi.com/thread/28741?ContentTypeID=1</link><pubDate>Wed, 08 Jul 2015 13:24:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f22f819b-7af4-477d-a793-02f792b9876b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;pin 22 is connected to LED and it does not change its state.
if I move the write operation into main just before the check, then it sucesfully writes and the LED changes its state. So the conclusion is that after the POFWARN event occured, write failed. write block is removed if your voltage is again above the POF threshold.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 Flash write during brown-out</title><link>https://devzone.nordicsemi.com/thread/28740?ContentTypeID=1</link><pubDate>Wed, 08 Jul 2015 13:21:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d18254e-4fe6-4dbc-b8f6-ce9947ab7332</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;This threshold is user set and you have to enable Power Fail comparator function explicitly .
Please look into Power_Register -&amp;gt;POFCON&lt;/p&gt;
&lt;p&gt;Regarding you write operation, all writes are blocked immediately after EVENTS_POFWARN is triggered.
I verified this on 100028 board&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;

#define POF_PIN      (21)

void soc_hal_flash_word_unprotected_write(uint32_t * p_address, uint32_t value)
{
  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.
  }
  *p_address = value;

  // Wait flash write to finish
  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.
  }
}

uint32_t *ptr = (uint32_t *)0X3C000;
void POWER_CLOCK_IRQHandler()
{
    if(NRF_POWER-&amp;gt;EVENTS_POFWARN == 1)
    {
        soc_hal_flash_word_unprotected_write(ptr, 0XDEADBEEF);
        NRF_POWER-&amp;gt;EVENTS_POFWARN = 0;
        nrf_gpio_pin_toggle(POF_PIN);
        
    }
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    // Configure LED-pins as outputs.
    LEDS_CONFIGURE(1&amp;lt;&amp;lt;POF_PIN);
    LEDS_CONFIGURE(1&amp;lt;&amp;lt;22);
    nrf_gpio_pin_clear(POF_PIN);
    nrf_gpio_pin_clear(22);
    NRF_POWER-&amp;gt;INTENSET = POWER_INTENSET_POFWARN_Msk;
    NRF_POWER-&amp;gt;POFCON = ((POWER_POFCON_THRESHOLD_V23 &amp;lt;&amp;lt; POWER_POFCON_THRESHOLD_Pos) | (POWER_POFCON_POF_Enabled &amp;lt;&amp;lt; POWER_POFCON_POF_Pos));
    NVIC_EnableIRQ(POWER_CLOCK_IRQn);
    while(1)
    {
    if(*ptr == 0XDEADBEEF)
    {
        nrf_gpio_pin_set(22);
    }
    };
    
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>