<?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 and NUS not working together</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13189/pstorage-and-nus-not-working-together</link><description>Hi, 
 I have a project that uses PStorage and the Nordic UART Service. PStorage is used to store a variable that is updated by the device, irrespective of the Bluetooth, and needs to be sent over the NUS when requested. Without using PStorage, the application</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 19 Apr 2016 08:22:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13189/pstorage-and-nus-not-working-together" /><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50301?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2016 08:22:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88a4e899-32ff-4240-bdd8-6fcd652b1f9a</guid><dc:creator>RPDben</dc:creator><description>&lt;p&gt;This worked perfectly. Thanks so much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50302?ContentTypeID=1</link><pubDate>Mon, 18 Apr 2016 17:22:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a62672a-0b5d-48ce-b201-67637bca87b9</guid><dc:creator>Pavan kumar</dc:creator><description>&lt;p&gt;Previously I&amp;#39;ve got the same issue with SDK11 so I&amp;#39;m using fstorage instead of pstorage that resolves my issue. So if possible once try fstorage. hope you all the best&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50300?ContentTypeID=1</link><pubDate>Mon, 18 Apr 2016 14:22:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:359be3cb-1a53-4900-8b33-f5d1b9fe114b</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;The events from the SoftDevice, both BLE and system events (for pstorage), are run in NRF_APP_PRIORITY_LOW(3) context. You are calling your pstorage functions in this context and you have a while where you are waiting for the flag to be cleared. The flag is cleared by a system event that is run in the same context, so it will not interrupt your while, and thus the flag will not be cleared. Try running your pstorage functions from main context instead. For example set a flag in nus_data_handler() and in your main loop:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Enter main loop.
for (;;)
{
    if(write_flag)
    {
        	pstorage_custom_read(BLOCK_1, &amp;amp;custom_data);
            custom_data += 1;
            pstorage_custom_update(BLOCK_1, &amp;amp;custom_data);
            write_flag = 0;
    }       
    power_manage();
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50299?ContentTypeID=1</link><pubDate>Mon, 18 Apr 2016 10:41:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf5cf49f-4975-4e2b-ada0-0d45485cb681</guid><dc:creator>RPDben</dc:creator><description>&lt;p&gt;Petter, I have attached a project that proves incorrect functionality. The while loop at the end of the pstorage_custom_init() function is never left. I assume this is because the callback handler is not called for whatever reason. thanks for all your help so far!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50298?ContentTypeID=1</link><pubDate>Mon, 18 Apr 2016 10:01:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8da98ca-b371-4b8a-b792-4e26b496720d</guid><dc:creator>RPDben</dc:creator><description>&lt;p&gt;Hi Petter, in the process of getting code that reproduces the error now. I have narrowed the error down to the callback not always being called. I assume this means that the pstorage operation has not finished and the code is waiting for the callback to be called to set the wait flag to 0. I am unsure why it is not completing though. I thought it might be my advertising interval being too low, so I upped that. Do you know of any other common practices that cause this error?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50297?ContentTypeID=1</link><pubDate>Mon, 18 Apr 2016 08:48:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6cfced7-f4a6-4bb9-9445-f28557fbe0dc</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure. It would be helpful if you could share you complete project, or some code that reproduces the issue. So I can debug it here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50293?ContentTypeID=1</link><pubDate>Fri, 15 Apr 2016 12:14:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69974358-87eb-422a-b664-1975c6edbaca</guid><dc:creator>RPDben</dc:creator><description>&lt;p&gt;I end up if nrf_drv_wdt_feed();. I cannot be sure if it is from these while loops or somewhere else. However, I know if is pstorage that is causing the issues as if I remove this the program works fine. I am using device manager if that changes things?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50296?ContentTypeID=1</link><pubDate>Fri, 15 Apr 2016 11:51:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79de7fa3-3329-4cde-bd9b-d57a67d6c232</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;So you are not calling pstorage_custom_read(), pstorage_custom_clear() or pstorage_custom_update() but you still end up in one of the while loops?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50295?ContentTypeID=1</link><pubDate>Fri, 15 Apr 2016 11:45:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e03e333-733b-4077-be33-2ceb9ec161ad</guid><dc:creator>RPDben</dc:creator><description>&lt;p&gt;Hi Petter, I have updated the question with my files&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50294?ContentTypeID=1</link><pubDate>Fri, 15 Apr 2016 11:26:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:157ce703-81c9-416b-98aa-4db4b736342c</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I think you should upload some more code, maybe even your complete project?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50292?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2016 15:49:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:880d2016-1b95-4b0f-a437-794e21d2ee9a</guid><dc:creator>RPDben</dc:creator><description>&lt;p&gt;Sorry, I guess &amp;quot;Appears to Freeze&amp;quot; would have been a better term. Whenever I pause the debugger during the issue it appears to be feeding the watchdog. While waiting for the pstorage functions to finish I feed the watchdog to avoid the device resetting as below. I believe I must be stuck in one of these while loops. However, the code should not be touching pstorage at this point so I am slightly confused as to why the code is here.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pstorage_wait_handle = base_handle.block_id;
	pstorage_wait_flag = 1;
	
	// Request clearing of all blocks in the module.
	retval = pstorage_clear(&amp;amp;base_handle, 4 * 16);

	if (retval == NRF_SUCCESS)
	{
			while(pstorage_wait_flag) { nrf_drv_wdt_feed(); }
	}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pstorage and NUS not working together</title><link>https://devzone.nordicsemi.com/thread/50291?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2016 15:42:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cf07b3a-2e27-480c-a63a-252b06cefcca</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Devices don&amp;#39;t freeze - they are somewhere doing something. If you hit break in the debugger, where is it and what is it doing? If it&amp;#39;s not the app_error_handler(), is it the hardfault handler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>