<?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>pstorage_update call MCU reset</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12910/pstorage_update-call-mcu-reset</link><description>My custom board, it connected with App, App sends a command to the board and the board keeps the command in the flash, but when i call the &amp;quot;pstorage_update&amp;quot;, it will cause reset. 
 My code is as follow: is there any wrong? Thanks! 
 nv_write(0,buf,16</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 12 Apr 2016 10:29:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12910/pstorage_update-call-mcu-reset" /><item><title>RE: pstorage_update call MCU reset</title><link>https://devzone.nordicsemi.com/thread/49164?ContentTypeID=1</link><pubDate>Tue, 12 Apr 2016 10:29:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74db5cb1-b9a0-4836-ad7c-e5e6db79ba19</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. Please upload the main.c file then.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage_update call MCU reset</title><link>https://devzone.nordicsemi.com/thread/49165?ContentTypeID=1</link><pubDate>Tue, 12 Apr 2016 06:52:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:587169ba-a76a-4b2a-b54e-cfdf9eb38a5c</guid><dc:creator>hark</dc:creator><description>&lt;p&gt;I am used the IAR, can you open the project in IAR.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage_update call MCU reset</title><link>https://devzone.nordicsemi.com/thread/49163?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2016 08:57:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c23122c-e704-4a0e-9120-c78b33a88be6</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Can you please edit your question and include your complete project? Zip the ble_app_uart folder and attach it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage_update call MCU reset</title><link>https://devzone.nordicsemi.com/thread/49162?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2016 01:34:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adc0c621-c552-430d-a427-49a5fccc775b</guid><dc:creator>hark</dc:creator><description>&lt;p&gt;Hi, SD version is 8.1, SDK is 10.0,&lt;/p&gt;
&lt;p&gt;my code is below, please help me check it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;nordic_common.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_soc.h&amp;quot;
#include &amp;quot;nrf_adc.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;ble.h&amp;quot;
#include &amp;quot;ble_hci.h&amp;quot;
#include &amp;quot;ble_nus.h&amp;quot;
#include &amp;quot;ble_srv_common.h&amp;quot;
#include &amp;quot;softdevice_handler.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;app_pwm.h&amp;quot;
#include &amp;quot;device_manager.h&amp;quot;
#include &amp;quot;app_util.h&amp;quot;
#include &amp;quot;pstorage.h&amp;quot;
#include &amp;quot;app_trace.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;bsp_btn_ble.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;user_util.h&amp;quot;
#include &amp;quot;user_nv.h&amp;quot;
#include &amp;quot;pstorage_platform.h&amp;quot;

pstorage_handle_t g_block_id;

nv_status_t nv_status = NV_IDEL;

static void flash_cb(pstorage_handle_t * handle,uint8_t op_code,uint32_t result,uint8_t * p_data, uint32_t data_len)
{    
    switch(op_code)
    {
        case PSTORAGE_STORE_OP_CODE:
        {
            if (result==NRF_SUCCESS)
            {
                nv_status = NV_IDEL;
            }
        
        }
      
        case PSTORAGE_UPDATE_OP_CODE:
        if (result == NRF_SUCCESS)
        {
            
        }
        break;
        
        case PSTORAGE_LOAD_OP_CODE:
        if (result == NRF_SUCCESS)
        {
 
        }
        break;
        
        case PSTORAGE_CLEAR_OP_CODE:
        if (result == NRF_SUCCESS)
        {
           
        }
        break;
    }
    
}


void nv_init(void)
{
  uint32_t ret;
  
  pstorage_module_param_t module_param;
  module_param.block_count =2; 
  module_param.block_size = 16;
  
  module_param.cb = flash_cb;
  
  ret = pstorage_init(); //Init
  
  if (ret!=NRF_SUCCESS)
  {
      while(1);
  }
  
  ret = pstorage_register(&amp;amp;module_param, &amp;amp;g_block_id);

  if (ret!=NRF_SUCCESS)
  {
      while(1);
  }

}

/*
Get Block NV Data
*/
uint32_t nv_read(uint8_t block_index, uint8_t* buf,uint16_t len)
{
  uint32_t ret;
  
  pstorage_handle_t dest_block_id;
  pstorage_block_identifier_get(&amp;amp;g_block_id,block_index, &amp;amp;dest_block_id); 
  
  ret = pstorage_load(buf,&amp;amp;dest_block_id,len,0);

  if (ret!=NRF_SUCCESS)
  {
      while(1);
  }
  
  return ret;
}

/*
Write Data To NV
*/
uint32_t nv_write(uint8_t block_index, uint8_t* buf,uint16_t len)
{
  uint32_t ret;
  
  nv_status = NV_BUSY;
  
  pstorage_handle_t dest_block_id;
  
  ret = pstorage_block_identifier_get(&amp;amp;g_block_id,block_index, &amp;amp;dest_block_id); 

  if (ret!=NRF_SUCCESS)
  {
      return ret;
  }
  
  ret = pstorage_clear(&amp;amp;g_block_id,16);
  
  if (ret!=NRF_SUCCESS)
  {
      return ret;
  }
   
  return ret;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage_update call MCU reset</title><link>https://devzone.nordicsemi.com/thread/49161?ContentTypeID=1</link><pubDate>Wed, 06 Apr 2016 08:35:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d58a3eff-1cba-4d8a-8e80-696a51a86ed1</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;What SoftDevice and SDK version are you using? Could you edit your question and upload your complete project so I can test it here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage_update call MCU reset</title><link>https://devzone.nordicsemi.com/thread/49160?ContentTypeID=1</link><pubDate>Wed, 06 Apr 2016 02:39:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a746bc6-3fdf-4f20-85e2-26ad8a15076c</guid><dc:creator>hark</dc:creator><description>&lt;p&gt;Hi, thanks for your help.  But I still failed in update the data into the flash. I check the return values/error codes of pstorage_block_identifier_get(), pstorage_clear(), and pstorage_update, the return value of these functions are &amp;quot;NRF_SUCCESS&amp;quot;. when call the &amp;quot;pstorage_update&amp;quot; it returns &amp;quot;NRF_SUCCESS&amp;quot;, when then it reset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage_update call MCU reset</title><link>https://devzone.nordicsemi.com/thread/49159?ContentTypeID=1</link><pubDate>Fri, 01 Apr 2016 09:02:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49072224-f6d5-4786-b4da-7d94b580c840</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Why are you clearing before updating? Wouldn&amp;#39;t this be equivalent of clearing and then storing? You should check the return values/error codes of pstorage_block_identifier_get(), pstorage_clear(), and pstorage_update. Not just pstorage_update(). pstorage_clear() is non-blocking, so when it returns it doesn&amp;#39;t mean that the block is cleared. You need to use the event notification handler to know if and when the operation is successful. Please examine the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/lib_pstorage.html?cp=4_0_0_3_19"&gt;documentation&lt;/a&gt;. There are also several questions on devzone explaining this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>