<?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>fstorage wait_for_flash_ready</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61629/fstorage-wait_for_flash_ready</link><description>Hi! 
 I know, that there are some similar issues in this forum, and I checked them, but I didn&amp;#39;t see the clue. 
 I try to use fstorage to write something to flash. I have a running softdevice, so i use the fstorage_sd backend. I looked at examples/peripheral</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 May 2020 16:26:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61629/fstorage-wait_for_flash_ready" /><item><title>RE: fstorage wait_for_flash_ready</title><link>https://devzone.nordicsemi.com/thread/251299?ContentTypeID=1</link><pubDate>Fri, 22 May 2020 16:26:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ead3837-1bfb-41a3-89e9-71cac8cd02ef</guid><dc:creator>Neum_d</dc:creator><description>&lt;p&gt;Changing the APP_TIMER_CONFIG_PRIORITY from 6 to 7 works. But I fear the side effects on other places in code, because I use many app_timers.&lt;/p&gt;
&lt;p&gt;So I decided to go the other way, also because it is nearly the same construction I have already to handle similar &amp;quot;low priority long running tasks&amp;quot;.&lt;/p&gt;
&lt;p&gt;Thank you very much.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage wait_for_flash_ready</title><link>https://devzone.nordicsemi.com/thread/251274?ContentTypeID=1</link><pubDate>Fri, 22 May 2020 13:17:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a66a6f62-9c29-440d-bd4b-707550806637</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Dirk,&lt;/p&gt;
&lt;p&gt;Exactly. So you are calling the fstorage functions from another interrupt, that probably has the same or higher priority. I don&amp;#39;t whether you are using the softdevice or not, but it is not that easy to modify the priority on the fstorage. You can try to set the priority of the app_timer to 7 and see if that helps. Change:&lt;/p&gt;
&lt;p&gt;#define APP_TIMER_CONFIG_IRQ_PRIORITY 6&lt;br /&gt;to&lt;br /&gt;#define APP_TIMER_CONFIG_IRQ_PRIORITY 7&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If that doesn&amp;#39;t work, one way to handle this is to actually write from your main() function, and use the timer to set a &lt;strong&gt;volatile&lt;/strong&gt;&amp;nbsp;flag which is used in main()&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;volatile bool flash_write_flag = false;

app_timer_handler()
{
    flash_write_flag = true;
}


main()
{
    ret_code_t err_code;
    //Init everything.
    ...
    
    for (;;)
    {
        if (flash_write_flag)
        {
            err_code = flash_write_function;
            if (err_code = NRF_SUCCESS)
            {
                flash_write_flag = false;
            }
        }
        if (!NRF_LOG_PROCESS())
        {
            power_manage();
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage wait_for_flash_ready</title><link>https://devzone.nordicsemi.com/thread/251108?ContentTypeID=1</link><pubDate>Thu, 21 May 2020 07:24:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee9408e9-69df-4c88-83fd-88dab0fc244d</guid><dc:creator>Neum_d</dc:creator><description>&lt;p&gt;Thank you for your suggestion. I call the nrf_fstorage_write() from a single shot application timer. When I call it from the main(), it works like a charm.&lt;/p&gt;
&lt;p&gt;So I guess, I have to refactor my code so that I call nrf_fstorage-functions not inside timer-handlers.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks a lot,&lt;/p&gt;
&lt;p&gt;Dirk.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage wait_for_flash_ready</title><link>https://devzone.nordicsemi.com/thread/250996?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 13:18:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f9940c6-7b55-433e-b8c4-bc8ade9260d2</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You are most likely correct. It is a priority issue. From where do you call&amp;nbsp;nrf_fstorage_write()? Is it inside an interrupt?&lt;/p&gt;
&lt;p&gt;Now, before you start changing all the interrupt priorities in your project, can you try the same function from your main() function? Does that work?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int main()
{
    ... //initialize everything
    ...
    
    is written = false;
    uint32_t retcode = nrf_fstorage_write(&amp;amp;fstorage, write_addr, data, 16, NULL);
    wait_for_flash_ready(&amp;amp;fstorage);
    for (;;)
    {
        //main loop;
        ...
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>