<?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>Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97220/detect-click-and-double-click-after-deep-sleep</link><description>Hello 
 When nrf52832 wakes up from a deep sleep, some times calling nrf_gpio_pin_latch_get does not return the button in pressed state. Perhaps it is some timing issue. 
 I would like to know what is the best way to detect a simple or a double click</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Mar 2023 14:39:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97220/detect-click-and-double-click-after-deep-sleep" /><item><title>RE: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/414175?ContentTypeID=1</link><pubDate>Wed, 08 Mar 2023 14:39:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edb91c4a-a7b3-4198-98c6-c68040c9d03f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;When you configure the gpio connected to the button to have sense/detect mechanism that could wake the chip from system off, then after wakeup the device will reset. I do not understand how you expect an interrupt handler to run here from the gpio&amp;#39;s activity before the reset happened.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Imagine you pressed a button, configured with detect and interrupt enabled. But this interrupt configuration in system off mode will do nothing but wake the chip. When you press the button when your device is in system off mode, no interrupt handlers can run as the only thing your system can do is wake up with a reset. And after the reset, the NVIC inside ARM cortex do not remember that there was an interrupt handler before the reset that was not handled and needs to handle even after the reset. At reset all pending interrupt bits are cleared to reset status.&lt;/p&gt;
&lt;p&gt;I think sometimes when you see your ISR being called could be that it is called after the system wakes up, you still see some debounce on the button which generates new interrupt on the gpio line and causes the ISR to be called after the wakeup. This can only happen if the sequence is like below.&lt;/p&gt;
&lt;p&gt;system_off_enter-&amp;gt;press_button.&amp;gt;wakeup_chip-&amp;gt;reset-&amp;gt;gpiote reconfigured with interrupt callback-&amp;gt;debounce from button-&amp;gt; new pin state change causes interrupt-&amp;gt; interrupt callback called.&lt;/p&gt;
&lt;p&gt;And the thing that you do not see this consistently gives me more confidence that what you are seeing is debounce spread over system off.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/414145?ContentTypeID=1</link><pubDate>Wed, 08 Mar 2023 13:24:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a8bdf97-149a-4168-b3c4-cdcd3911f72c</guid><dc:creator>Marcelo Aleks</dc:creator><description>&lt;p&gt;&lt;span&gt;Yes, the system wakes up after reset, but I cannot always detect which button woke the system. Also, if I set an interrupt handler, sometimes the callback is not called.&amp;nbsp; When I hold the button down for a longer time (&amp;gt;500ms), everything works&lt;br /&gt;&lt;br /&gt;It seems to be a timing problem.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Do you know how much time it takes to reset the nrf52832?&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div id="gtx-anchor" style="height:13.3565px;left:7.99304px;position:absolute;top:106.163px;width:285.014px;"&gt;&lt;/div&gt;
&lt;div class="jfk-bubble gtx-bubble" style="left:135px;top:-49px;"&gt;
&lt;div id="bubble-7" class="jfk-bubble-content-id"&gt;
&lt;div id="gtx-host" style="max-width:400px;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="jfk-bubble-closebtn-id jfk-bubble-closebtn"&gt;&lt;/div&gt;
&lt;div class="jfk-bubble-arrow-id jfk-bubble-arrow jfk-bubble-arrowdown" style="left:142.5px;"&gt;
&lt;div class="jfk-bubble-arrowimplbefore"&gt;&lt;/div&gt;
&lt;div class="jfk-bubble-arrowimplafter"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/414118?ContentTypeID=1</link><pubDate>Wed, 08 Mar 2023 12:24:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14fe6b3e-2e94-4662-920b-d6e4ffcc4379</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Not sure how that makes a difference. After deep sleep, the wakeup causes a system reset. And then you should still reconfigure the GPIOs (just to be sure) after the reset caused by wakeup from system off.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/414091?ContentTypeID=1</link><pubDate>Wed, 08 Mar 2023 11:16:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa737abb-f338-4442-a30b-4636809e3dc4</guid><dc:creator>Marcelo Aleks</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; I meant after deep sleep.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Rgds&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/414022?ContentTypeID=1</link><pubDate>Wed, 08 Mar 2023 08:36:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7aadc18-5d56-466a-8f34-e3fac08881ae</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Marcelo,&lt;/p&gt;
&lt;p&gt;I am assuming you have tried to use&amp;nbsp;v2.2.0\zephyr\samples\basic\button sample to test your button. It is very strange behavior that you say that interrupt requests are not being handled as expected. Can&amp;nbsp;you elaborate more on that?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The LATCH feature only works when you have enabled the SENSE functionality in the GPIO which would enable the DETECT signal required for the latch register to function correctly.&lt;/p&gt;
&lt;p&gt;I am assuming that you have configured the SENSE in PIN_CNF[X] register and that in your code when you read the latch register you always clear it to &amp;quot;0&amp;quot;. The button feature works properly on DK, so it must either be a configuration issue or some other capacitance issue on your board.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/413810?ContentTypeID=1</link><pubDate>Tue, 07 Mar 2023 12:38:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fe3823d-3022-408b-8b46-b5449dfc886f</guid><dc:creator>Marcelo Aleks</dc:creator><description>&lt;p&gt;&lt;span&gt;I am using Zephyr, and even with interrupts enabled, I am sometimes experiencing issues where interrupt requests are not being handled as expected. Specifically, I have observed that the interrupt handler is not being called when an interrupt occurs, and as a result, important tasks are not being executed in a timely manner. This behavior seems to occur sporadically, and I have been unable to determine a specific pattern or trigger for when it happens.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Best regards, Marcelo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/413800?ContentTypeID=1</link><pubDate>Tue, 07 Mar 2023 12:03:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71dd1e2b-b6f9-469f-8d6f-7ed824bfaddc</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;In the nRF5 SDK the &lt;strong&gt;app_button_init()&lt;/strong&gt; sets a detection delay which by default in our samples is set to be &lt;strong&gt;APP_TIMER_TICKS(50)&lt;/strong&gt; which is 50 in number of timer ticks.&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: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/413667?ContentTypeID=1</link><pubDate>Mon, 06 Mar 2023 23:33:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79bc952b-e9c8-43d9-98fc-fde44a298447</guid><dc:creator>Marcelo Aleks</dc:creator><description>&lt;p&gt;Thank you Simonr!&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div class="flex-1 overflow-hidden"&gt;
&lt;div class="react-scroll-to-bottom--css-alhdw-79elbk h-full dark:bg-gray-800"&gt;
&lt;div class="react-scroll-to-bottom--css-alhdw-1n7m0yu"&gt;
&lt;div class="flex flex-col items-center text-sm dark:bg-gray-800"&gt;
&lt;div&gt;
&lt;div class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"&gt;
&lt;div&gt;
&lt;div class="flex flex-grow flex-col gap-3"&gt;
&lt;div&gt;
&lt;div class="markdown prose w-full break-words dark:prose-invert light"&gt;
&lt;p&gt;&lt;span&gt;I am suspecting timing issues as well. &lt;br /&gt;Do you happen to know if there is a default pre-defined debounce interval? &lt;br /&gt;&lt;br /&gt;I am asking because sometimes, mostly, I am not able to detect when the button is pressed. Additionally, also&amp;nbsp; the interrupt handler is frequently not called.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Rgds&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"&gt;
&lt;div&gt;
&lt;div class="flex justify-between"&gt;
&lt;div class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-3 md:gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="w-full h-32 md:h-48 flex-shrink-0"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="absolute bottom-0 left-0 w-full border-t md:border-t-0 dark:border-white/20 md:border-transparent md:dark:border-transparent md:bg-vert-light-gradient bg-white dark:bg-gray-800 md:!bg-transparent dark:md:bg-vert-dark-gradient"&gt;
&lt;div class="relative flex h-full flex-1 md:flex-col"&gt;
&lt;div class="flex ml-1 mt-1.5 md:w-full md:m-auto md:mb-2 gap-0 md:gap-2 justify-center"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id="gtx-anchor" style="height:13.3565px;left:7.99304px;position:absolute;top:186.261px;width:116.357px;"&gt;&lt;/div&gt;
&lt;div class="jfk-bubble gtx-bubble" style="left:51px;top:72px;"&gt;
&lt;div id="bubble-2" class="jfk-bubble-content-id"&gt;
&lt;div id="gtx-host" style="max-width:400px;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="jfk-bubble-closebtn-id jfk-bubble-closebtn"&gt;&lt;/div&gt;
&lt;div class="jfk-bubble-arrow-id jfk-bubble-arrow jfk-bubble-arrowdown" style="left:58px;"&gt;
&lt;div class="jfk-bubble-arrowimplbefore"&gt;&lt;/div&gt;
&lt;div class="jfk-bubble-arrowimplafter"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect click and double click after deep sleep</title><link>https://devzone.nordicsemi.com/thread/413022?ContentTypeID=1</link><pubDate>Thu, 02 Mar 2023 12:49:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7018dba0-d66e-414d-bb20-8dbe17042a40</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Marcelo&lt;/p&gt;
&lt;p&gt;But the device does indeed wake up every time you press a button, correct, even though the&amp;nbsp;&lt;span&gt;&lt;strong&gt;nrf_gpio_pin_latch_get&amp;nbsp;&lt;/strong&gt; does not return the correct button state always. My guess is that the reason you&amp;#39;re seeing the incorrect button state is because of debouncing, so at the time of reading the button state, the button is read as being in the incorrect state because it is &amp;quot;bouncing back&amp;quot; from the pressed state (or unpressed state). I&amp;#39;m not sure what SDK you&amp;#39;re working on, but the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_button.html"&gt;button handling library&lt;/a&gt;&amp;nbsp;in the nRF5 SDK for example has a button handler that also handles debouncing so that the correct value of a button will be reported every time.&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;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>