<?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>unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48161/unexpected-sd_app_evt_wait-returning</link><description>Hello, 
 
 I have a BLE application, running a GATT server on a nrf52832. The main loop, is basically an endless loop, starting with a call to `sd_app_evt_wait()`, then handling events provided by `sd_ble_evt_get()`. I toggle a debug pin at the beginning</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 04 Jun 2019 14:42:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48161/unexpected-sd_app_evt_wait-returning" /><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190851?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 14:42:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e960df51-ebdc-4b74-9f05-7ce311bc38d5</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;If your application does not need any events from softdevice, then clearing the pend register should work just fine&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190850?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 13:30:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8e1e976-b41e-4568-83c9-59d3c4326d08</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;might be, that I never noticed the increased power consumption.&lt;/p&gt;
&lt;p&gt;I simply cleared the pending SWI2 interrupt directly behind the call to `NVIC_ClearPendingIRQ()`. This seems to work. From the source in nrf_sdh.c, it seems that the IRQ handler does nothing but to call a list of dynamically registered handlers that are interested&amp;nbsp;in SD state changes.&amp;nbsp;And as this list is empty in my application, I think this should be ok.&lt;/p&gt;
&lt;p&gt;best regards,&lt;/p&gt;
&lt;p&gt;Torsten&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190849?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 13:18:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:832abd42-9121-4b4d-afdf-e5d90ce2282a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Torsten,&lt;/p&gt;
&lt;p&gt;This is not a bug in SDK or SD.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The SD has always clearly mentioned that any BLE activity events generated in the softdevice are communicated to the application through SWI2 interrupt. In the earlier projects when you used our softdevice, you must have SWI2 interrupt handler implemented somewhere to call&amp;nbsp;sd_ble_evt_get in a loop to pull the events from the softdevice. It is completely application responsibility to enable SWI2 interrupt and call&amp;nbsp;sd_ble_evt_get in a loop until your application pulled all events. It has always been like this with the softdevice architecture since knew softdevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190848?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 11:29:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd83ceb2-ff50-4bab-93b5-2311e563b1c2</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Thank you for the quick analysis. I&amp;#39;m going to apply the workaround you&amp;#39;ve mentioned. Would you consider this to be a bug in the SD or in the documentation? Will there be a fix for this?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using SD since version 6 and so far never stumbled over an issue like this.&lt;/p&gt;
&lt;p&gt;While analyzing this, I found this SDH module. I don&amp;#39;t use it, because it doesn&amp;#39;t provide any&amp;nbsp;service, that I could use to fulfill&amp;nbsp;my requirements but uses resources. I didn&amp;#39;t even&amp;nbsp;tried it out, because I would have to add an include path with the name &amp;quot;experimental&amp;quot; in it, which seemed to be not right for a project that once should go into production.&lt;/p&gt;
&lt;p&gt;Again, thanks for all the great support! Nordic has the best support I&amp;#39;ve ever experienced&amp;nbsp;and every time I can change the mind of my customers, I try to convince them to use chips from Nordic.&lt;/p&gt;
&lt;p&gt;I will let you know if the fix works for me.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Torsten&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190847?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 11:14:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddcce80b-e008-4659-bb77-aa40ec1f0d22</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Torsten,&lt;/p&gt;
&lt;p&gt;I figured out the problem you have. Looking at NVIC ISER and ISPR after connection&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-112a8792c27a43bfa8a141c5df8bf966/pastedimage1559646554491v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I can see that the SWI2 interrupt is not enabled and hence is always in the pending state. The reason is that you have not enabled it since&amp;nbsp;you never initialized SDH module&amp;nbsp;&amp;nbsp;nrf_sdh_enable_request in the SDK. If you do not want to have this module then you need to include the implementation of the SWI2_EGU2_IRQHandler&amp;nbsp;and enable this interrupt using NVIC_EnableIRQ so that all BLE events are passed to the application. Right now the softdevice is trying to tell the application that the connected event has arrived and the application has no way to pull it out since it has not enabled or implemented the&amp;nbsp;SWI2_EGU2_IRQHandler.&lt;/p&gt;
&lt;p&gt;Please look into the nrf_sdh module implemenation in the SDK and pull these modules into your project and call&amp;nbsp;softdevices_evt_irq_enable (atleast to enable this IRQ and service them)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190846?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 10:05:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7febf8a-722c-4719-82ca-da0439202125</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;that worked. I am compiling it now and will debug it today&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190845?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 08:34:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:012e347f-2632-43ed-8a7e-ac5e71276cc4</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m quite&amp;nbsp;sure because I&amp;#39;ve deleted the zip file. But I was a little bit surprised, by the speed (and problem-less) of the upload. I&amp;#39;ve renamed the zip file now.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Upload was, again quite fast. It should not contain a build_52 folder.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190844?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 08:29:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dcf3999d-b1e5-410c-9a36-4ba3a54429ce</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Torsten,&lt;/p&gt;
&lt;p&gt;Are you sure that you attached the correct zip? the one you attached now and the previous zip contents are same&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-112a8792c27a43bfa8a141c5df8bf966/pastedimage1559636968769v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190843?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 08:04:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:264a27e2-e5a7-48c6-a99c-806400543545</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Please find a new zip-file, with a Makefile in the root directory. You have to change the&amp;nbsp;NRF_SDK variable at line 5 of the Makefile, to match the location of your NRF SDK. Once SD and firmware are flashed and a generic GATT client connected to the device (advertises the name Torrox), pin 26 will toggle, once per call to `sd_app_evt_wait()`.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190842?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 07:18:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9304efea-01cf-4b2b-a1ee-9da2e07328ba</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Ok, no problem. I will provide you simple makefile.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190841?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 07:14:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd0d6169-93ab-4a93-923c-c64266fbfef8</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;that doesn&amp;#39;t work Torsten, I already tried that makefile. it still seems to use the cmake executables, but changing those hardcoded paths and compiler paths did not help much.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190840?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 06:41:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c47a324c-ffff-4f2d-9036-3bde364706da</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;there is a working directory (build_nrf52) that should contain a Makefile generated by cmake. So, if you have an arm_none_eabi_gcc in your path, just using that Makefile should be sufficient. If that doesn&amp;#39;t work for you, I will provide a hand written makefile.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190839?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 06:34:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8e8486c-85c7-43c1-8142-140348ee430a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Torsten,&lt;/p&gt;
&lt;p&gt;Sorry for delays. I tried to compile your project with no success. I am not an expert in cmake things but it looks like my working environment is not set correctly for it. Seems like cmake is taking clang as default compiler even after my efforts to set the compiler related ENV variables to point to arm-none-eabi-xxxx binaries.&lt;/p&gt;
&lt;p&gt;Is there any other way to compile your project?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190838?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 13:06:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86836a42-5dcf-40cc-abcd-63c985590699</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;find attached a copy of the checkout branched, that I&amp;#39;s stripped down, to a bare minimum. You will find a prebuild binary under ./build_nrf52/source/firmware&lt;/p&gt;
&lt;p&gt;To build the binaries from sources, change to the build_nrf52 folder and execute cmake&amp;nbsp;with the cache variable NRF_SDK set to the location of your nrf&amp;nbsp;SDK. For example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cmake -DNRF_SDK=~/CMSIS/nRF5_SDK_15.2.0_9412b96/ ..&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you have `arm-none-eabi-gcc&amp;#39; &amp;nbsp;and make installed, you should be able to directly flash the example with the make target `firmware.flash`.&lt;/p&gt;
&lt;p&gt;Let me know if I left out needed details or if you have any questions regarding the code.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Torsten&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190837?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 07:21:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dee67f2f-86e5-4260-adc1-2ab1b2a1b007</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Torsten&lt;/p&gt;
&lt;p&gt;I set this case to private, so you can upload the .zip file here. Private cases can only be seen by Nordic engineers and will be treated with confidentiality.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190836?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 15:08:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96184dba-b35c-4154-869f-2102e4174386</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve stripped the application down, to a&amp;nbsp;hand full of files. The application now basically just sets up the GATT data base and starts adverting. Again, as soon as a GATT client connects, the pin (pin&amp;nbsp;26) starts to toggle very frequently.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve prepaired a zip file containing a cmake&amp;nbsp;project build folder containing the binary. How can I send you the zip file?&lt;/p&gt;
&lt;p&gt;best regards,&lt;/p&gt;
&lt;p&gt;Torsten&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190835?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 13:31:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77fe2c18-54b2-4bde-ae56-f90fc75c9102</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Torsten&lt;/p&gt;
&lt;p&gt;As you might have guessed, I have had some assistance from Susheel on this case, and as you proposed. It seems like the next step would be to strip down your project so we can try to reproduce it here on our end. We&amp;#39;re guessing that you&amp;#39;re entering a critical region at some point in your code and just never exit, as this seems to be the only reason for the SWI2 to be disabled like this.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190834?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 10:16:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ef325bb-152a-4f9a-9fd1-6afdf4cf542b</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi Susheel,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;the code, I use to capture ISER and ISPR is really as shown above. I even moved the setting of the debug-pin behind the capturing to make sure that this doesn&amp;#39;t cause any modifications of registers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;So yes, SWI2 is pending, but disabled. The only reason, why this could cause a WFI instruction to not suspend the CPU, would be that the&amp;nbsp;SEVONPEND is set (which is not done by my application and which is neither set before calling `sd_app_evt_wait()` nor after&amp;nbsp;`sd_app_evt_wait()` returns).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I’m quite sure, that the pending event is 0x400000 and thus the SWI2_EGU2_IRQn is the cause for the returning of `sd_app_evt_wait()`, because if I clear that pending flag directly after `sd_app_evt_wait()` returns, the next calls to `sd_app_evt_wait()` will then not return immediately.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;When using&amp;nbsp;`sd_app_evt_wait()`,&amp;nbsp;`sd_app_evt_wait()` starts to return&amp;nbsp;immediately, after I connect (BLE) to the application. When I replace `sd_app_evt_wait()` by __WFI(), __WFI() will return&amp;nbsp;immediately even before I connect to the application. If I replace __WFI(), by „__SEV(); __WFI(); __WFI();“, the second __WFI() will put the CPU to sleep, as expected (during startup, after connection, during the connection) and the application works still as expected.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;I applied the workaround for&amp;nbsp;PAN_87 to find the cause, why a single __WFI() is not sufficient, but to no avail.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;To make sure, that there is no interrupt handler served with high frequency, I created an annotated list file of my application and walked through the interrupt vector table. I really found just the two application interrupt handlers (all others where defaults from the nordic startup file, that all just spin). I disabled the interrupts and removed the handlers (which would cause the default handler to be called), but found no difference in the behavior of the application.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;What could I try next? I could branch my software and strip it down to as small as possible to let you have a look at it? Maybe the quite old chip version on the Chip on the Eval board could be an issue? I could move to SD 6.1.1, but according to the release notes, there was no bigger changes. Anything else?&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;best regards,&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Torsten&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;BTW: Thank you for the time you all put into helping me!!!&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190833?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 06:59:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4903d04-28ec-4fc7-af81-f034503994ba</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;also&amp;nbsp;&lt;span&gt;ISER[ 0 ] is&amp;nbsp;&lt;/span&gt;&lt;span&gt;0x2000905 tells me that SWI2 interrupt is disabled.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;IF ISPR&amp;nbsp; = 400000 at that time, and your main is in loop calling sd_app_evt_wait, then it will not go to sleep. Try replacing sd_app_evt_wait with __WFE() iin a loop and see if you see the difference.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190832?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 06:53:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0375dc4-6436-492c-b89f-5aec078412d6</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote userid="4223" url="~/f/nordic-q-a/47671/unexpected-sd_app_evt_wait-returning/189196"] I&amp;#39;ve used 50000, 50010 and 55000. `ISPR[0]` is always `0x400000` and `ISPR[1]` is always 0. [/quote]
&lt;p&gt;Torsten,&lt;/p&gt;
&lt;p&gt;I think this thread took a different direction with the information you gave above. When you sniff this registers immediately after waking up from main thread, it should have told you which application interrupt source is waking the chip. Most likely it is the FPU that is the culprit as application tend to configure to use FPU instruction, but do not handle the FPU exeptions since they the FPU excpetions are not enabled by default, making them reside in the pending state for ever and telling the sd_app_evt_wait not to go to sleep.&lt;/p&gt;
&lt;p&gt;Are you sure the ISPR values you gave are correct? The beviour you see with wakeup and this ISPR value does not add up.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190831?ContentTypeID=1</link><pubDate>Tue, 28 May 2019 11:54:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b84464a3-6166-4b4f-979e-8b396af403fd</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;the only interrupts that are enabled by my application are `SPIM2_SPIS2_SPI2_IRQn` and `UARTE0_UART0_IRQn`. Both are configured with priority 7 and have quite short running IRQ handlers.&lt;/p&gt;
&lt;p&gt;My best guess was, that the&amp;nbsp;SEVONPEND flag in the&amp;nbsp;&lt;span&gt;SCB-&amp;gt;SCR would have been set, but it was not set (according to the debugger). But maybe `sd_app_evt_wait()` set the flag&amp;nbsp;before issuing&amp;nbsp;a WFE instruction and restores the flag (just wild guessing)?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There is nothing, that my application blocks on, except `sd_app_evt_wait()` (in a single place). The application is still quite easy to overview and there is nothing else in the application, that behaves strange or weird.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have a custom `assert()` function in my application and I&amp;#39;m using `assert` quite often. So, I added a test for the&amp;nbsp;SWI2_EGU2 pending flag in the&amp;nbsp;ISPR register in the assert macro implementation. I added asserts before and after a call to `sd_app_evt_wait()` and find, that after `sd_app_evt_wait()` returns, the pending flag is set, after a BLE client connects to the application.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I further added asserts to the end of my IRQ handlers. But still, the first time, that assert finds the SWI2_EGU2 pending flag being set, is after the call to `sd_ble_evt_get()`.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There is an `sd_app_evt_wait()` implementation in the SDK (which is according to my debugger, not in use), that simply issues the&amp;nbsp;__wfe compiler intrinsic. What does the Softdevice version of `sd_app_evt_wait()` looks like?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Torsten&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190830?ContentTypeID=1</link><pubDate>Tue, 28 May 2019 10:45:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24b5d956-ddb6-4937-a7c4-efcac1dca97b</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;I am a bit confused here. The ISPR bits say that SWI2 interrupt is pending, but ISER says that this interrupt is disabled. SWI2 interrupt needs to be enabled in the NVIC level for the application to be able to pull the BLE events. How did this interrupt get disabled?&lt;/p&gt;
&lt;p&gt;There are only two ways that this can occur. Either you have suspended the SoftDevice somewhere, or the SoftDevice &lt;strong&gt;handler&lt;/strong&gt; is suspended. Could you please check if you&amp;#39;ve done this somewhere in the application?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190829?ContentTypeID=1</link><pubDate>Tue, 28 May 2019 07:13:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:375c62ad-0b89-4107-b13f-361a42687a21</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Simon,&lt;/p&gt;
&lt;p&gt;the value of ISER[ 0 ] is&amp;nbsp;&lt;span&gt;0x2000905 and the value of ISER[ 1 ] is&amp;nbsp;&lt;/span&gt;&lt;span&gt;0x9. I had a look into the Softdevice Documentation, for the list of restricted peripherals. There, SWI2_EGU2_IRQn is listed as open, but with a footnote 7, which states:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt; Interrupt will be set to pending state by the SoftDevice on SoftDevice Event Notification, but the application may also set it to pending state.&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So I guess, that the SD uses SWI2_EGU2 as mean to notify the main thread to wake up. I just cleaned the pending flag directly after `sd_app_evt_wait()` returned and the application seems to work fine (on a first glance). I would expect&amp;nbsp;`sd_app_evt_wait()` to reset the pending flag, and thus to make it transparent for the user, how the SD communicates with&amp;nbsp;`sd_app_evt_wait()`. I&amp;#39;ve never noticed this behavior in previous versions of the SDK / SD.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could, simply resetting the pending flag be a valid solution to my problem?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There are no other sleep functions used in the application.&amp;nbsp;`sd_app_evt_wait()` is the only function, where the main thread goes to sleep and it is only called from the main loop.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Torsten&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190828?ContentTypeID=1</link><pubDate>Tue, 28 May 2019 06:28:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6b05dd5-1006-4367-b367-58174685995f</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Torsten&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve checked this out with my colleagues, and we would like you to check NVIC-&amp;gt;ISER registers as we suspect SWI2 is enabled somewhere, which causes the SWI2_EGU2_IRQn.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Another solution would be that the application is trying to go to sleep somewhere else than the main.c file. Can you confirm whether or not you are calling a sleep function somewhere else?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: unexpected sd_app_evt_wait() returning</title><link>https://devzone.nordicsemi.com/thread/190827?ContentTypeID=1</link><pubDate>Mon, 27 May 2019 12:27:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46b78f76-9e2b-432c-815a-1a9c09bbbd5c</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;I&amp;#39;m on a DK (PCA10040 V0.9.0), with some GPIOs and mainly SPIs and Timers in use. From the SDK, only&amp;nbsp;system_nrf52.c, gcc_startup_nrf52.S and the softdevice is in use. SDK Version is&amp;nbsp;15.2.0_9412b96.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>