<?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>Methods to put the nRF52 to sleep in a &amp;quot;spinlock loop&amp;quot;</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49010/methods-to-put-the-nrf52-to-sleep-in-a-spinlock-loop</link><description>We recently had an issue where a race-condition was caused because we handled entry to sleep mode a bit too carefully. Therefore, I wanted to discuss different methods to make the nRF52 go to sleep - mainly without the softdevice enabled. 
 The goal is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 Sep 2020 14:54:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49010/methods-to-put-the-nrf52-to-sleep-in-a-spinlock-loop" /><item><title>RE: Methods to put the nRF52 to sleep in a "spinlock loop"</title><link>https://devzone.nordicsemi.com/thread/267892?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 14:54:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c99c0e60-c18b-4615-8989-c270f2784040</guid><dc:creator>m.wagner</dc:creator><description>&lt;p&gt;I only &lt;a href="https://community.arm.com/developer/ip-products/processors/f/cortex-m-forum/13618/cortex-m-does-the-event-register-only-get-set-when-an-irq-changes-from-not-pending-to-pending/110449"&gt;posted the question in the community forums&lt;/a&gt;, but there was no satisfying answer, unfortunately.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Methods to put the nRF52 to sleep in a "spinlock loop"</title><link>https://devzone.nordicsemi.com/thread/267879?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 14:03:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4757962-0bff-46d9-a91b-3608fef0c1b3</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I would be interested to know what Arm replied.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Methods to put the nRF52 to sleep in a "spinlock loop"</title><link>https://devzone.nordicsemi.com/thread/195310?ContentTypeID=1</link><pubDate>Fri, 28 Jun 2019 09:20:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09969e7e-787e-4e7a-88eb-529276c611a1</guid><dc:creator>m.wagner</dc:creator><description>&lt;p&gt;Thank you. I&amp;#39;ll try to contact ARM to get a statement for first question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Methods to put the nRF52 to sleep in a "spinlock loop"</title><link>https://devzone.nordicsemi.com/thread/195305?ContentTypeID=1</link><pubDate>Fri, 28 Jun 2019 09:16:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38104496-6692-4980-9c86-dc98124fb401</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is a bit intricate, so I have discussed it with a few colleagues before answering. I suggest you ask ARM directly if you need more details.&lt;/p&gt;
[quote user=""]An IRQn will only set the event register if it changes from &amp;quot;not pending&amp;quot; to &amp;quot;pending&amp;quot;. (e.g. if a RADIO IRQ occurred but was not served (i.e. the pending bit was never cleared), and then a second RADIO IRQ occurrs, the event register will not be set.[/quote]
&lt;p&gt;This is a good question. This is in line with my understanding, so I believe you are correct. I cannot guarantee it, though.&lt;/p&gt;
[quote user=""]__WFI-based sleep needs masking interrupts when a flag is set from the IRQ_Handler.[/quote]
&lt;p&gt;I believe you are correct. We do not use WFI in the SoftDevice though and have less experience with it.&lt;/p&gt;
[quote user=""]Relevant interrupts must not be masked when using __WFE-based sleep, otherwise the system may not wake up.[/quote]
&lt;p&gt;&amp;nbsp;Yes. If you use buy_flag that is set form higher priority, then you cannot mask the interrupts that set the busy_flag.&lt;/p&gt;
[quote user=""]Care must be taken on the order of __WFE and __SEV calls in any case...[/quote]
&lt;p&gt;Yes. So the code snippet you have under the &amp;quot;WFE-based sleep function (wrong)&amp;quot; heading is definitely wrong.&lt;/p&gt;
[quote user=""]The more elaborate sleep function with __WFE(); __SEV(); __WFE(); is a power optimisation, requiring one loop iteration less to go to sleep than just calling __WFE();[/quote]
&lt;p&gt;Yes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>