<?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>Flash and BLE simultaneously creating hardfault</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44598/flash-and-ble-simultaneously-creating-hardfault</link><description>I am using nrf51822. Separately BLE and flash are working perfectly alright. But when I comment err_code = ble_advertising_start(BLE_ADV_MODE_FAST); this line flash is working alright. Vice versa when I comment flash_packet_transfer(arr,sizeof(arr));</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 20 Mar 2019 05:34:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44598/flash-and-ble-simultaneously-creating-hardfault" /><item><title>RE: Flash and BLE simultaneously creating hardfault</title><link>https://devzone.nordicsemi.com/thread/177200?ContentTypeID=1</link><pubDate>Wed, 20 Mar 2019 05:34:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37f65774-39b4-463c-9ce8-2de0c2acd742</guid><dc:creator>Meera Shah</dc:creator><description>&lt;p&gt;I have solved my problem here is my code. When BLE is turned on and as soon as you stop your code using&lt;br /&gt; breakpoint and start it again, it&amp;#39;s missed hundreds of ticks during which it had things it needed to do, &lt;br /&gt;&amp;nbsp;the internal checks inside the softdevice then fail and the device faults, errors or hardfaults.&lt;pre class="ui-code" data-mode="c_cpp"&gt;void flash_packet_transfer(uint8_t *data,uint8_t len)
{
    static uint32_t  addr;                  /*sd_flash_write function does not keep the data pointer alive, the variable needs to be static */
    static uint32_t   flash_write_word;
    uint32_t   pg_size;
    uint32_t *ptr;
    uint8_t days_count=0;
    
    data_buffer_t data_buf;
    uint32_t flash_add_storage_location = 0x33800;
  
    pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;
    addr = (FLASH_START_ADDR+ (packet_num * len));

    while(sd_flash_page_erase(flash_add_storage_location/pg_size)== NRF_ERROR_BUSY);
    nrf_delay_ms(1000);

    while(sd_flash_write((uint32_t *)flash_add_storage_location,&amp;amp;addr,1)== NRF_ERROR_BUSY);  /* This will store flash latest location which has been filled */
    nrf_delay_ms(1000);

    if(addr % pg_size ==0){
      while(sd_flash_page_erase(addr/pg_size)== NRF_ERROR_BUSY);
      nrf_delay_ms(1000);
    }
    ptr = (uint32_t *)addr;
    
    for(uint8_t i=0;i&amp;lt;len;i=i+4){ 
      flash_write_word = ((data[i+3] &amp;lt;&amp;lt; 24) | (data[i+2] &amp;lt;&amp;lt; 16) | (data[i+1] &amp;lt;&amp;lt; 8) | data[i]);
      while(sd_flash_write(ptr,&amp;amp;flash_write_word,1)== NRF_ERROR_BUSY);
      nrf_delay_ms(1000);
      ptr = ptr+1;
    }
    packet_num++;
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash and BLE simultaneously creating hardfault</title><link>https://devzone.nordicsemi.com/thread/176112?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2019 09:24:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2f498e9-bb25-4b28-a448-34152d78aca7</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;What SDK version are you using ?&lt;/p&gt;
&lt;p&gt;What is the value of&amp;nbsp;FLASH_START_ADDR in the code snippet you posted ?&lt;/p&gt;
&lt;p&gt;Could you upload a project that shows this issue ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash and BLE simultaneously creating hardfault</title><link>https://devzone.nordicsemi.com/thread/175227?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2019 05:08:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ee0b70e-58fe-48e0-b1e6-1baff019d060</guid><dc:creator>Meera Shah</dc:creator><description>&lt;p&gt;I changed my APIs with sd_flash_write but still having hardfault. Even normal&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void flash_packet_transfer(uint8_t *data,uint8_t len)
{
    uint32_t  addr;
    uint32_t   pg_size;
    uint32_t   flash_write_word;
    
    uint32_t   pg_num;
    uint32_t flash_addr;
    uint32_t *ptr = NULL;
    uint8_t buf_count;
    uint8_t previous_date = 0;
    uint8_t date_count =0;
    
    data_buffer_t data_buf;
    uint32_t flash_add_storage_location = 0x33800;
  
    pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;
    addr = (FLASH_START_ADDR+ (packet_num * (len+2)));
    
   
   
    sd_flash_page_erase(206);
    sd_flash_write((uint32_t *)flash_add_storage_location,(uint32_t *)addr,1);
   
   
    if(addr % pg_size ==0){
        sd_flash_page_erase(207);
    }
    ptr = (uint32_t *)addr;
    
    for(uint8_t i=0;i&amp;lt;len;i=i+4){ 
      flash_write_word = ((data[i+3] &amp;lt;&amp;lt; 24) | (data[i+2] &amp;lt;&amp;lt; 16) | (data[i+1] &amp;lt;&amp;lt; 8) | data[i]);
      sd_flash_write(ptr,(uint32_t *)flash_write_word,1);
      ptr = ptr+1;
    }
}&lt;/pre&gt;flash read and write not working with this. What should I include to work with this APIs&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash and BLE simultaneously creating hardfault</title><link>https://devzone.nordicsemi.com/thread/175033?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2019 13:47:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b9b2e57-57ee-4d2c-87f9-973111a95a7a</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When the SoftDevice is enabled, the functions sd_flash_erase/write have to be used for erase/write operations. If you try to access the NVMC directly when the SoftDevice is enabled, it will result in a hardfault. See &lt;a href="https://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;this&lt;/a&gt;, &lt;a href="https://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_9#ga8b49f2e72e97291aecc18ce396956eed"&gt;this &lt;/a&gt;and &lt;a href="https://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;this link.&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>