<?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 Behavior with GPIO_INT_EDGE_BOTH Interrupt on Button Release in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117935/unexpected-behavior-with-gpio_int_edge_both-interrupt-on-button-release-in-nrf-connect-sdk</link><description>I&amp;#39;m encountering an issue with the use of the GPIO interrupt type GPIO_INT_EDGE_BOTH on a GPIO connected to a button. When pressed, the button pulls the GPIO to GND, and when released, it sets it to VDD. Searching online, I found that others have faced</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Jan 2025 11:41:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117935/unexpected-behavior-with-gpio_int_edge_both-interrupt-on-button-release-in-nrf-connect-sdk" /><item><title>RE: Unexpected Behavior with GPIO_INT_EDGE_BOTH Interrupt on Button Release in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/518424?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2025 11:41:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd01d3cc-ba0b-4a19-8677-7bb2ce5b509d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I guess that is correct. Most of our samples doesn&amp;#39;t use this, since they use a custom library that you can find in:&lt;/p&gt;
&lt;p&gt;NCS\nrf\lib\dk_buttons_and_leds.c&lt;/p&gt;
&lt;p&gt;That also has a small (hardcoded) debounce of 1ms.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected Behavior with GPIO_INT_EDGE_BOTH Interrupt on Button Release in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/517984?ContentTypeID=1</link><pubDate>Fri, 10 Jan 2025 15:03:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b96a2ca7-e177-4300-bf82-84474deef9b1</guid><dc:creator>Andrea Verdecchia</dc:creator><description>&lt;p&gt;Thank you for your suggestions, but I was hoping to avoid implementing software debounce, as I read &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/112194/zephyr-debounce-support"&gt;here&lt;/a&gt; that Zephyr natively &lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/zephyr/build/dts/api/bindings/input/gpio-keys.html#dtbinding-gpio-keys"&gt;supports debounce&lt;/a&gt;, which should be set to 30ms by default. Am I wrong, or is this correct? Also, as you&amp;rsquo;ve already noticed, the callback invocation pattern is always the same, so it doesn&amp;rsquo;t seem like a coincidence that I always get the 1-0 sequence when releasing the button.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected Behavior with GPIO_INT_EDGE_BOTH Interrupt on Button Release in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/517969?ContentTypeID=1</link><pubDate>Fri, 10 Jan 2025 14:38:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04bc8058-6e68-4dbe-83e7-4c87e1934a44</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;What you are seeing is probably a bounce. It is however, a little bit strange if it is consistent in the pattern that you are seeing. Is it always like that, or is it a coincidence that you always get one touchState 1 before the touchState 0 in your log?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Either way, I would say that a small debounce would do the trick here. You can introduce a small delay before you read the pin state. You can see an example on how this is done in the dk_buttons_and_leds.c in NCS (ncs\nrf\lib\dk_buttons_and_leds\dk_buttons_and_leds.c), where they use&amp;nbsp;k_work_reschedule to scan the buttons 1ms later.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Alternatively, you can do something like this, and use a timer to check that the button was held for at least some time, to rule out the bounce signals:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/3175.long_5F00_press_5F00_v2.zip"&gt;devzone.nordicsemi.com/.../3175.long_5F00_press_5F00_v2.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here the &amp;quot;debounce&amp;quot; is set to 10 seconds, so that is really more of a long press detection. But if you set it to something like 100ms or 50ms, it would act more like a debounce.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Another alternative is to add some passive components (capacitor) close to the button pin, so that the signal doesn&amp;#39;t bounce as much when the button is being pressed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>