<?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>Is critical section needed for glitch-less implementation of CPU sleep?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52277/is-critical-section-needed-for-glitch-less-implementation-of-cpu-sleep</link><description>Hello, 
 I have the same question as mentioned in this article: 
 https://devzone.nordicsemi.com/f/nordic-q-a/19252/how-to-avoid-interrupt-handling-is-not-missed-with-sd_app_evt_wait 
 Additional question, just to make sure: For a glitch-free implementation</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 Sep 2019 13:50:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52277/is-critical-section-needed-for-glitch-less-implementation-of-cpu-sleep" /><item><title>RE: Is critical section needed for glitch-less implementation of CPU sleep?</title><link>https://devzone.nordicsemi.com/thread/210449?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 13:50:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fea000e6-4607-4a04-bba7-51b177f7ee95</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;No problem, if you have&amp;nbsp;masked&amp;nbsp;all interrupts you&amp;nbsp;need to enable SEVONPEND (&lt;a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/BABGGICD.html"&gt;ARM infocenter&lt;/a&gt;) to wake on pending interrupts. Otherwise, it may end up sleeping forever as you said.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is critical section needed for glitch-less implementation of CPU sleep?</title><link>https://devzone.nordicsemi.com/thread/210436?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 13:34:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be36eaf5-f3e8-4c97-b0ee-c9f180d94a19</guid><dc:creator>Mr_BLE</dc:creator><description>&lt;p&gt;Sorry for asking more deeply:&lt;/p&gt;
&lt;p&gt;You said, the event register will be set AFTER the ISR is serviced. Does that mean, if I use the enter critical section function before calling sd_app_evt_wait() then the CPU will go to sleep and never wake up due to disabled ISR&amp;#39;s and never setted event register?&lt;/p&gt;
&lt;p&gt;Or is it more likely that the event register is ALWAYS set, regardles if ISR is called or not?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is critical section needed for glitch-less implementation of CPU sleep?</title><link>https://devzone.nordicsemi.com/thread/210424?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 13:24:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:936db3c7-686c-4ac3-b947-87c96c6fdc93</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Yes,&amp;nbsp;you&amp;#39;ve understood it correctly:&amp;nbsp;the event register will be set after the ISR is serviced and it will become cleared by the next wfe instruction.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is critical section needed for glitch-less implementation of CPU sleep?</title><link>https://devzone.nordicsemi.com/thread/210421?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 13:15:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ae24002-190a-42d3-b334-cb9c9fe2f6ae</guid><dc:creator>Mr_BLE</dc:creator><description>&lt;p&gt;Thanks for answering. I understand now.&lt;/p&gt;
&lt;p&gt;The only thing I did not know was that the event register will still be set - even after the ISR is serviced.&lt;/p&gt;
&lt;p&gt;And the event register is only cleared by calling &amp;quot;__WFE()&amp;quot; - did I get this right?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is critical section needed for glitch-less implementation of CPU sleep?</title><link>https://devzone.nordicsemi.com/thread/210411?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 12:57:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a03362c-63bd-4eb1-aabe-8887bdd5288f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I saw the ticket you linked to, but I wasn&amp;#39;t sure what you meant by glitch-free in this context and suspected that maybe you had some other concerns than what the OP had. So to answer your question: critical regions should be redundant for this case. As pointed by the accepted answer, the event register will be set after the ISR is serviced so&amp;nbsp;&lt;span&gt;sd_app_evt_wait() will return immediately and reread the flag. You are thus eliminating the possibility of a race condition.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is critical section needed for glitch-less implementation of CPU sleep?</title><link>https://devzone.nordicsemi.com/thread/210405?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 12:39:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:425baf02-32a2-4b6e-a491-52980bf9cbf8</guid><dc:creator>Mr_BLE</dc:creator><description>&lt;p&gt;The creator of the above mentioned article showed an example code which fits exactly my needs to show an example. The creator showed a first and a second implementation of the code. Do you know what I mean, or should I copy the code in here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is critical section needed for glitch-less implementation of CPU sleep?</title><link>https://devzone.nordicsemi.com/thread/210384?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 11:58:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54828440-ded7-468b-92ac-28da7b661707</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Would it be possible to&amp;nbsp;include some snippets of your code here? I&amp;#39;m not sure I understand what you&amp;#39;re trying to achieve in your code. E.g., Is it some code you have&amp;nbsp;that has to be processed without interruption from other higher priority interrupts? Is it timing critical and/or exposed to race conditions from other application-level interrupts? Are you using a scheduler?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>