<?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 the reason for wakeup from idle and GPIO interrupt unresponsive in idle</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108515/how-to-check-the-reason-for-wakeup-from-idle-and-gpio-interrupt-unresponsive-in-idle</link><description>I am working on an ongoing project where some minor power management is implemented: 
 
 suspend is called when measurements go to idle. But while debugging the application behaves strangely. The system goes into suspend after power up as intended, deactivates</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Feb 2024 15:41:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108515/how-to-check-the-reason-for-wakeup-from-idle-and-gpio-interrupt-unresponsive-in-idle" /><item><title>RE: How to check the reason for wakeup from idle and GPIO interrupt unresponsive in idle</title><link>https://devzone.nordicsemi.com/thread/471609?ContentTypeID=1</link><pubDate>Thu, 29 Feb 2024 15:41:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5aac8fb-8ac3-4876-9de1-7154ad9c9c94</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;It is confusing, but literally every hardware event in the data sheet labelled &amp;quot;EVENTS_blahblah&amp;quot; (ie tons of them) will wake up from SYSTEM_ON if and only if the corresponding &amp;quot;ENABLE&amp;quot; register for the peripheral with the event is enabled and the conditions for the hardware event occurs. This has nothing to do with interrupts whether enabled or not; additionally a hardware event under active and enabled conditions can trigger an interrupt if and only if the corresponding interrupt is also enabled. A hardware Event can be triggered by hardware (eg uart rx character), implicitly by software (eg setting Tasks-Start and getting Events-Started, or explicitly by software (eg setting an Event in the EGU).&lt;/p&gt;
&lt;p&gt;Many hardware events once triggered in an enabled peripheral will keep generating interrupts (if enabled) and waking up from SYSTEM_ON until the hardware event is explicitly cleared (aka level-sensitive not edge-sensitive). If not enabling interrupts for a specific hardware event the hardware event must be cleared in foreground code otherwise remaining in SYSTEM_ON sleep is not possible. It is possible to write code which checks every peripheral for 1) is it enabled and 2) are there any active hardware events for that peripheral; yes a pain.&lt;/p&gt;
&lt;p&gt;This is effectively nothing to do with Zephyr, by the way, other than when Zephyr secretly clears the events for you. Normal practice is to clear the events within interrupts; which implies the interrupts corresponding to each possible enabled event must be enabled and embed the correct code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check the reason for wakeup from idle and GPIO interrupt unresponsive in idle</title><link>https://devzone.nordicsemi.com/thread/471600?ContentTypeID=1</link><pubDate>Thu, 29 Feb 2024 15:17:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:577d2ff8-2809-45ae-bf9e-4193158aab8c</guid><dc:creator>Bjoern Bialy</dc:creator><description>&lt;p&gt;For me the problem is what even qualifies as a wakeup from the SYSTEM ON idle. In the data sheet it just says &amp;quot;wake on any event&amp;quot;, but what kind of event? If it were really any event, then the MCU would never keep sleeping, as something will always happen.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check the reason for wakeup from idle and GPIO interrupt unresponsive in idle</title><link>https://devzone.nordicsemi.com/thread/470291?ContentTypeID=1</link><pubDate>Thu, 22 Feb 2024 14:16:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d754a61-86f5-46e5-b8bc-ea3a42a3ff66</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]The first problem is now that I don&amp;#39;t even know what triggered the wakeup from idle. Is there any way to check the wakeup reason? Debugging does not help here as the reason is obfuscated by the OS. Maybe a register value?[/quote]
&lt;p&gt;There are generally two power saving modes in nRF52833:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="System ON mode" href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/power.html?cp=5_1_0_4_2_3#unique_184089196"&gt;System ON mode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="System OFF mode" href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/power.html?cp=5_1_0_4_2_2#unique_64273339"&gt;System OFF mode&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Reason for wakeup from SystemOFF mode can be read from the&amp;nbsp;&lt;a title="RESETREAS" href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/power.html?cp=5_1_0_4_2_6_10#register.RESETREAS"&gt;RESETREAS&lt;/a&gt;&amp;nbsp;register.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since you are using&amp;nbsp;PM_STATE_SUSPEND_TO_IDLE, the system will likely enter SystemON mode. In this mode, every HW event will wake the CPU and continue execution. Events will be visible in the EVENTS_* register in each peripheral, but if you do not know which peripheral caused the wakeup, it is not trivial to find the actual event. Are you only seeing this behavior when debugging the application, or does it also wakeup in normal operation mode?&lt;/p&gt;
&lt;p&gt;Technically it would be possible to enable interrupts for&amp;nbsp;&lt;a title="EVENTS_SLEEPEXIT" href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/power.html?cp=5_1_0_4_2_6_4#register.EVENTS_SLEEPEXIT"&gt;EVENTS_SLEEPEXIT&lt;/a&gt;&amp;nbsp;event with high interrupt priority and step through the application to see what code is executed after wakeup, but I have not tested this in nRF Connect SDK.&lt;/p&gt;
[quote user=""]For the second problem I am not even sure how the GPIO interrupt is supposedly linked to the wakeup. Is there a resource with an appropriate example? Most examples with the interfaces used in the code only handle the power down but not the power up, or it is thread triggered and not by interrupt.[/quote]
&lt;p&gt;The interrupt handling is primarily done in the lower layer driver implementations in Zephyr, and events are passed from driver to application handlers to take appropriate action.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>