<?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>How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10789/how-to-check-pstorage-operation-is-complete</link><description>Hi, When I write data synchronously to memory (nRF51822), I do : 
 APP_ERROR_CHECK(pstorage_block_identifier_get(flash_handler, 2, &amp;amp;block_handler));
APP_ERROR_CHECK(pstorage_clear(&amp;amp;block_handler, 16));
// check here ?
APP_ERROR_CHECK(pstorage_store</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Mar 2016 17:56:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10789/how-to-check-pstorage-operation-is-complete" /><item><title>RE: How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/thread/40318?ContentTypeID=1</link><pubDate>Wed, 23 Mar 2016 17:56:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:385d9a51-3ee4-4d54-a53d-2deaa2bd70b7</guid><dc:creator>Thomas</dc:creator><description>&lt;p&gt;Sorry for coming back on this @Nick that late but a part of the question is not answered : is it safer to check in the callback (wait flag) or check that the pstorage_count is 0 ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/thread/40315?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2015 19:45:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73787d80-cf41-4739-8d17-843951dd7210</guid><dc:creator>Nick Pelis</dc:creator><description>&lt;p&gt;To be paranoid and safe under all possible scenarios, I would also initialize count to zero (since pstorage_access_status_get() can exit without setting count).  But what you have looks OK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/thread/40314?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2015 19:38:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0f508c0-e039-4bfd-a352-4c10dc59fa40</guid><dc:creator>Thomas</dc:creator><description>&lt;p&gt;hi @Nick, thank you for your quick answer. I don&amp;#39;t know what could go on, maybe some code is slower or something. In keil, I didn&amp;#39;t call app_sched_execute in the loop but everything was working. On gcc, I saw that the firmware was hanging somewhere and I tracked this to my wait function and discovered that app_sched_execute did the trick. I have edited the question, it is clearer. If my edit is good, I would think that nordic should give this snippet to other people&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/thread/40317?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2015 18:33:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3495ee8-fd2e-4949-ac7d-7b0b4b301280</guid><dc:creator>Nick Pelis</dc:creator><description>&lt;p&gt;app_sched_execute() is the proper way to go, as this gives the SoftDevice opportunities to complete its asynchronous flash operation, which is asynchronous due to the length of time it takes to program and erase flash.  I can&amp;#39;t possibly think of any reason why your Keil code would work, and I suspect it&amp;#39;s not.  Is count &amp;lt;= 0 just before executing the while(), or did you invoke pstorage_load() immediately beforehand, or you did you do anything else that gave the SoftDevice a chance to run?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/thread/40316?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2015 18:18:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f91b8f28-68d7-4c8e-b0b2-43e78f2c4694</guid><dc:creator>Thomas</dc:creator><description>&lt;p&gt;Hi @Nick, could you update on this ? I realized that when I compile my code with keil/windows doing &lt;code&gt;while (count &amp;gt; 0) pstorage_access_status_get(&amp;amp;count);&lt;/code&gt; works, but when I compile with gcc, I need to add &lt;code&gt;app_sched_execute()&lt;/code&gt; in the loop. Is that correct ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/thread/40313?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2015 07:26:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4e379e7-c794-43c0-a6c2-94876661586b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Nick,&lt;/p&gt;
&lt;p&gt;What do you mean by &amp;quot;blocking wait in the check here wont work&amp;quot;? This is communicated to SD through an SVC call, app can still block and wait for a flag that is set in the sys_event handler. May be i misunderstood your text?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/thread/40312?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2015 05:55:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0370f0e9-67c2-4a38-8f1a-90da1fb4d159</guid><dc:creator>Thomas</dc:creator><description>&lt;p&gt;Thanks but what about the first kind of blocking code in the &amp;quot;check here&amp;quot; ?   uint16_t count; do pstorage_access_status_get(&amp;amp;count); while(count &amp;gt; 0)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check pstorage operation is complete ?</title><link>https://devzone.nordicsemi.com/thread/40311?ContentTypeID=1</link><pubDate>Thu, 10 Dec 2015 23:45:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bda016d2-d3b7-413c-bf14-9e2b2a527f41</guid><dc:creator>Nick Pelis</dc:creator><description>&lt;p&gt;You need to exit out to the main scheduler and give the SoftDevice control of the system until the flash callback is executed, at which point you can continue to the next step of your original code.  A blocking wait in the &amp;quot;check here&amp;quot; lines won&amp;#39;t work as the SoftDevice is what invokes the flash callback in the first place.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>