<?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>GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33820/gpiote-interrupt-stops-firing-after-thousands-of-successful-calls</link><description>Hi, 
 We&amp;#39;re running into a frustrating and tricky to debug issue with handling interrupts on the nrf52832. We have an active-low interrupt to pin 28, that is activated periodically (usually at 1 Hz but pushed to 1 kHz to reproduce this bug more quickly</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 13 May 2018 11:20:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33820/gpiote-interrupt-stops-firing-after-thousands-of-successful-calls" /><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/131765?ContentTypeID=1</link><pubDate>Sun, 13 May 2018 11:20:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e68d330f-b3d5-432a-a7ee-624e54a60f52</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi, the behavior is documented in the datasheet:&lt;br /&gt; &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/gpiote.html?cp=2_1_0_20#concept_knz_kww_lr"&gt;http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/gpiote.html?cp=2_1_0_20#concept_knz_kww_lr&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problematic behavior here is this: &amp;quot;Putting the system into System ON IDLE while DETECT is high will not cause DETECT to wake the system up again. Make sure to clear all DETECT sources before entering sleep.&amp;quot;&lt;/p&gt;
&lt;p&gt;So before entering sleep make sure that both signals are high.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/131575?ContentTypeID=1</link><pubDate>Wed, 09 May 2018 15:56:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bdb22c7-2904-42e2-a780-11908ed411bf</guid><dc:creator>charles</dc:creator><description>&lt;p&gt;Thanks for the response, Kenneth. Could you point us to anything in the nRF52832 datasheet or nRFSDK v14.0 docs that describe this behavior in more detail? Is there an errata we missed somewhere?&lt;/p&gt;
&lt;p&gt;The gpiote API seems to encourage multiple input pin port events (it allows you to register up to 4 by default), but it sounds like using that in a straightforward manner is guaranteed to fail in this not-uncommon scenario where multiple events happen in a short timespan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/131484?ContentTypeID=1</link><pubDate>Wed, 09 May 2018 11:13:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8439102c-656b-4a0e-8865-0949eb57f799</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi, I believe it is a race conditions by having two input pins both configured with wakeup on port event, and if both go low at the same time, you may end up in a deadlock until both are high again. Having a timer to handle this, or possible better, do a check before you return to sleep or exit your interrupt handler that&amp;nbsp;both pins are high may help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/131406?ContentTypeID=1</link><pubDate>Tue, 08 May 2018 19:35:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a94c051-9e85-4e7a-ae3e-57786265ae4a</guid><dc:creator>rjshade</dc:creator><description>&lt;p&gt;Pinging this thread as it hasn&amp;#39;t seen any activity, but &amp;quot;a&lt;span&gt;&amp;nbsp;support engineer has been assigned to your ticket&amp;quot; 12 days ago.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any thoughts from Nordic on what may be the problem here?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/130348?ContentTypeID=1</link><pubDate>Mon, 30 Apr 2018 20:29:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79f7277e-aa60-4ebc-be7d-b96644473814</guid><dc:creator>rjshade</dc:creator><description>&lt;p&gt;Update: this does seem to be a bad interaction between two peripheral interrupts. We have two sensor interrupt lines connected to separate GPIO pins. Both of these are configured as active-low, low-accuracy GPIOTE interrupts. Everything seems to work until *both of these pins go low at the same time* and then we appear to get into a state where we never again get interrupted.&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt; for the periodic timer idea: I added a 2 Hz timer in our main loop that just reads pin state and logs it. I also added logging inside the IRQ handlers for sensors A and B:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;...
3.807 sensor_A.c:175 Sensor A IRQ: sensor_a: 0, sensor_b: 1
3.809 sensor_B.c:34 Sensor B IRQ: sensor_a: 1, sensor_b: 0
3.897 sensor_A.c:175 Sensor A IRQ: sensor_a: 0, sensor_b: 1
3.903 sensor_A.c:175 Sensor A IRQ: sensor_a: 0, sensor_b: 1
3.908 main.c:147 MAIN: sensor_a: 1, sensor_b: 1
3.910 sensor_1.c:175 sensor_a: sensor_a: 0, sensor_b: 1
3.916 sensor_1.c:175 sensor_a: sensor_a: 0, sensor_b: 1
4.408 main.c:147 MAIN: sensor_a: 0, sensor_b: 0
4.908 main.c:147 MAIN: sensor_a: 0, sensor_b: 0
5.408 main.c:147 MAIN: sensor_a: 0, sensor_b: 0
5.908 main.c:147 MAIN: sensor_a: 0, sensor_b: 0
6.408 main.c:147 MAIN: sensor_a: 0, sensor_b: 0
6.908 main.c:147 MAIN: sensor_a: 0, sensor_b: 0
7.408 main.c:147 MAIN: sensor_a: 0, sensor_b: 0
7.908 main.c:147 MAIN: sensor_a: 0, sensor_b: 0
8.408 main.c:147 MAIN: sensor_a: 0, sensor_b: 0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As expected, inside the interrupt handler for Sensor A we see that Sensor A&amp;#39;s GPIO pin value is low, and B&amp;#39;s is high. Vice versa in Sensor B&amp;#39;s interrupt handler. You can then see that from timestamp 4.408 onwards both GPIO pins are low, but our interrupt handlers never get called.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/130341?ContentTypeID=1</link><pubDate>Mon, 30 Apr 2018 18:37:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:939e70f1-f89e-4ed5-8cb3-7d1591dd0bd1</guid><dc:creator>rjshade</dc:creator><description>&lt;p&gt;This unanswered post from a year ago sounds like it is describing the same sort of problem:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/29053/gpiote-simultaneous-interrupts"&gt;devzone.nordicsemi.com/.../gpiote-simultaneous-interrupts&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/130334?ContentTypeID=1</link><pubDate>Mon, 30 Apr 2018 16:17:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d71fe840-3a86-45a7-b3e0-b95b897bfcd2</guid><dc:creator>charles</dc:creator><description>&lt;p&gt;That&amp;#39;s very interesting, and could possibly explain what we&amp;#39;re seeing; thank you for responding! I&amp;#39;m curious to hear what Nordic support thinks...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/130164?ContentTypeID=1</link><pubDate>Fri, 27 Apr 2018 19:15:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d82b01b-8976-4981-b28d-5cdceb699bcd</guid><dc:creator>koniho</dc:creator><description>&lt;p&gt;In low-accuracy mode - only a single interrupt is generated for all inputs. Typically, the event handler would have to determine which signal triggered the GPIOTE. What if another unrelated GPIOTE event was triggered right before the GPIOTE of interest was generated? Would that result in the the GPIOTE of interest being missed forever?&lt;/p&gt;
&lt;p&gt;I think we might be running into a similar issue ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/129855?ContentTypeID=1</link><pubDate>Wed, 25 Apr 2018 21:49:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37e26ce9-5626-4220-9e9a-38dfef7904f4</guid><dc:creator>charles</dc:creator><description>&lt;p&gt;A periodic app_timer is triggering the TWI write. The peripheral asserts a pin that connects to the nRF52832, which we see in &amp;quot;interrupt goes low&amp;quot;. The pin is only de-asserted when we issue a subsequent TWI read to read the results, so it&amp;#39;s effectively a latching mechanism.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s very interesting to us that setting high accuracy mode on the GPIOTE configuration &amp;quot;fixes&amp;quot; this, and we never see any &amp;quot;missed&amp;quot; interrupts. This led to the question of the data sheet: we expect low-accuracy GPIOTE events to miss pulse functions, but will we ever miss simple step functions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE interrupt stops firing after thousands of successful calls</title><link>https://devzone.nordicsemi.com/thread/129853?ContentTypeID=1</link><pubDate>Wed, 25 Apr 2018 21:04:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d0c8770-de4a-46ac-9c4e-c3992e63b7a0</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Perhaps a race hazard, even though the transactions are slow .. what is driving the &amp;#39;scope trace? Is s_drv volatile? How is it related to drv? Often even if this behaviour is never observed, a periodic test doesn&amp;#39;t hurt, typically driven by an independent timed event:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        // Test for interrupt signal from active-low /DRDY signal
        if (!mAfeSampleDataReady)
        {
            // Check for missed interrupt, perhaps due to hardware race hazard
            if (TimeSinceLastPacket &amp;gt; 10)
            {
                // Looks suspicious, check if the signal indicates data ready
                if (nrf_gpio_pin_read(ADS_DRDY_PIN) == 0)
                {
                    // Set sample pending signal, as it should have been set
                    mAfeSampleDataReady = true;
                    // Update error log
                    mAfeLateDrdyCount++;
                }
                else
                {
                    // Looks like AFE has ceased streaming, try to recover it
                    amInitialized = false;
                    // Update error log
                    mAfeRestartCount++;
                }
            }
        }
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>