<?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>Button causes repeated interrupt callback</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/126210/button-causes-repeated-interrupt-callback</link><description>I&amp;#39;m trying to make the basic Button sample work but am having problems. 
 The physical button is a latching button. Press it and it moves in with a click and physically stays there. Press again and with a click, the latch releases and the button pops</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 20 Dec 2025 11:34:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/126210/button-causes-repeated-interrupt-callback" /><item><title>RE: Button causes repeated interrupt callback</title><link>https://devzone.nordicsemi.com/thread/557482?ContentTypeID=1</link><pubDate>Sat, 20 Dec 2025 11:34:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:484dbf90-19b0-46af-b0d1-3ff54dc4806a</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;Good news. It&amp;#39;s working :-)&lt;/p&gt;
&lt;p&gt;The full story:&lt;/p&gt;
&lt;p&gt;Tested again with breadboard and battery just to be sure, this time with an LED connected into the switch circuit. It works fine. Note that the LED embedded within the switch is permanently powered in the test circuit and so is always on. The external LED is in a circuit which is switched by the button and behaves as expected.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Button-Electronics-Test.mp4"&gt;devzone.nordicsemi.com/.../Button-Electronics-Test.mp4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My logic analyzer triggers successfully on&amp;nbsp;rising edge. So I tried the button configured in code with&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;ret = gpio_pin_interrupt_configure_dt(&amp;amp;button,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;GPIO_INT_EDGE_BOTH);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;(which I thought I&amp;#39;d already tested, according to comments in my code!)&lt;/p&gt;
&lt;p&gt;And waddayouknow, it works. Not sure why I thought this wasn&amp;#39;t working before (or in fact why it *wasn&amp;#39;t* working!).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v3.1.1-e2a97fe2578a ***
*** Using Zephyr OS v4.1.99-ff8f0c579eeb ***
button test v35
Button is ready 
Button configured for input
LED is ready 
LED configured for output 
Button attached to interrupt
Set up button at gpio@50000000 pin 6
Press the button
Button state=1
Button pressed at 125004
Button state=0
Button pressed at 212011&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Note that I still have pullup specified in the DTS so this might also be significant.&lt;/p&gt;
&lt;pre&gt; start_stop_btn: start_stop_gpio_connector {&lt;br /&gt; /* &lt;br /&gt; * &amp;#39;gpios&amp;#39; property is a phandle-array that takes:&lt;br /&gt; * 1. Phandle to the GPIO controller (&amp;amp;gpio0 refers to the node with label &amp;#39;gpio0&amp;#39;)&lt;br /&gt; * 2. The pin number (e.g., 13)&lt;br /&gt; * 3. The flags (e.g., GPIO_ACTIVE_LOW for an active-low LED)&lt;br /&gt; */&lt;br /&gt; gpios = &amp;lt;&amp;amp;gpio0 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)&amp;gt;;&lt;br /&gt; label = &amp;quot;Start/stop button&amp;quot;;&lt;br /&gt; };&lt;/pre&gt;
&lt;p&gt;Thanks for the support, both technical and moral!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Button causes repeated interrupt callback</title><link>https://devzone.nordicsemi.com/thread/557327?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 12:59:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d747bdd2-de2a-4a40-96c3-cd5db6d55ead</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;I initially tested with a battery and breadboard and it seemed fine. I&amp;#39;m going to double check that though now that you&amp;#39;ve mentioned it.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Button causes repeated interrupt callback</title><link>https://devzone.nordicsemi.com/thread/557326?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 12:56:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b020b100-ef54-4167-9d6b-4aca52291b9e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Have you verified that simply connecting the button pin directly to vdd or gnd works without any problem?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Button causes repeated interrupt callback</title><link>https://devzone.nordicsemi.com/thread/557323?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 12:42:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e8dccbc-c554-4669-a392-85332c57ca9b</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/kme"&gt;Kenneth&lt;/a&gt;&amp;nbsp;, thanks for your response. I&amp;#39;m aware of debouncing but only ever seen one or two &amp;quot;extra&amp;quot; callbacks where debouncing needs to be applied. This is a rapid stream of hundreds.&lt;/p&gt;
&lt;p&gt;The code I&amp;#39;m using is basically the Button sample that ships with Zephyr:&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/basic/button"&gt;https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/basic/button&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I think I&amp;#39;ve tried all possible interrupt configuration flags (see above) but in the off/button out state always get massive numbers of callbacks.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure this is a simple case of needing to debounce. I can do this in code but there will still be a storm of callbacks being processed. Debouncing in code will just mask this.&lt;/p&gt;
&lt;p&gt;The pullup/antenna theory seems more plausible but the pullup flag didn&amp;#39;t solve the problem.&lt;/p&gt;
&lt;p&gt;Mysterious.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Button causes repeated interrupt callback</title><link>https://devzone.nordicsemi.com/thread/557320?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 12:22:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b4b838f-b088-4069-92b7-816a6156754e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Debouncing is a normal problem with buttons, normally adding a capacitor on the input or in software add a timer on button press that prevent debounce to trigger multiple key presses. If that is not the problem, check if it&amp;#39;s related to using edge vs. level when configuring the pin. And if that it not the problem, then I suggest to take a look at any example project in ncs to compare with your own project, also measuring on the the pin using a logic analyzer in case you are not overlooking something can be a good idea.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Button causes repeated interrupt callback</title><link>https://devzone.nordicsemi.com/thread/557306?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 11:06:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21461af3-3eff-4bbf-acf7-bdf6354a7ac0</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;Thank you! This sounds very likely the problem but with the following in my DTS file, the behaviour still occurs:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        start_stop_btn: start_stop_gpio_connector {
            /* 
             * &amp;#39;gpios&amp;#39; property is a phandle-array that takes:
             * 1. Phandle to the GPIO controller (&amp;amp;gpio0 refers to the node with label &amp;#39;gpio0&amp;#39;)
             * 2. The pin number (e.g., 13)
             * 3. The flags (e.g., GPIO_ACTIVE_LOW for an active-low LED)
             */
            gpios = &amp;lt;&amp;amp;gpio0 6 (GPIO_ACTIVE_LOW  | GPIO_PULL_UP)&amp;gt;;
            label = &amp;quot;Start/stop button&amp;quot;;
        };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;--- 9999 messages dropped ---
Button pressed at 422836
Button state=0
Button pressed at 422838
Button state=0
Button pressed at 422841
Button state=0
Button pressed at 422843
Button state=0
Button pressed at 422846
Button state=0
Button pressed at 422848
Button state=0
Button pressed at 422851
Button state=0
Button pressed at 422853
Button state=0
Button pressed at 422856
Button state=0
Button pressed at 422858
Button state=0
Button pressed at 422861
Button state=0
Button pressed at 422863
Button state=0
Button pressed at 422866
Button state=0
Button pressed at 422868
Button state=0
Button pressed at 422871
Button state=1
Button pressed at 422873&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;FYI I tried PULL_DOWN as well but got no callbacks at all with this flag.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Button causes repeated interrupt callback</title><link>https://devzone.nordicsemi.com/thread/557303?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 10:36:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27955631-78f0-4341-b1f3-70458c5cf375</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;No pullup enabled. Button cable goes high impedance when disconnected and works as an antenna. Pin now detects random inputs - usually at a very rapid rate.&lt;/p&gt;
&lt;p&gt;Workaround: Enable the pullup resistor in the DT overlay.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>