<?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>Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64513/pin-interrupt-polarity-timing-issue</link><description>I am using the GPIOTE driver to attach interrupts to a pin in a very timing critical environment (using sensors like this ). 
 To me, it seems like there is quite the significant delay between the signal on the pin and the handler function call. 
 The</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 06 Aug 2020 19:57:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64513/pin-interrupt-polarity-timing-issue" /><item><title>RE: Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/thread/263495?ContentTypeID=1</link><pubDate>Thu, 06 Aug 2020 19:57:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aaf9eafd-2430-497f-b1db-eee4300c9c74</guid><dc:creator>Daniel Dakhno</dc:creator><description>&lt;p&gt;had to patch the following:&lt;/p&gt;
&lt;p&gt;nrf_drv_gpiote.c line 758:&lt;/p&gt;
&lt;p&gt;&lt;em&gt; handler(pin, polarity);&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;replaced with&lt;/p&gt;
&lt;p&gt;&lt;em&gt; handler(pin, (sense == NRF_GPIO_PIN_SENSE_HIGH) ? NRF_GPIOTE_POLARITY_LOTOHI : NRF_GPIOTE_POLARITY_HITOLO);&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/thread/263195?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 11:25:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c665d0c2-133e-4a67-974f-b717fa9b01ad</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;You&amp;#39;re right.. I agree, API design is weird. You can tweak nrfx_gpiote.c interrupt handler to return sense value instead of polarity. From other side, in low-accuracy mode you should not loose any event - each next event will signal an opposite value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/thread/263172?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 10:10:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4844160-f6da-45aa-8579-f2a76ee783cf</guid><dc:creator>Daniel Dakhno</dc:creator><description>&lt;p&gt;AFAIK my callback only gets passed&amp;nbsp;NRF_GPIOTE_POLARITY_TOGGLE, which is neither value...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/thread/263171?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 10:08:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:145247df-4d92-4433-b636-02181f729696</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;In low-accuracy mode, your callback will be called with right value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/thread/263170?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 10:06:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f965bc40-e47a-4279-9be9-ac56c0a18748</guid><dc:creator>Daniel Dakhno</dc:creator><description>&lt;p&gt;and how do i get that value? using gpio_read only gives me the value at runtime of the handler.&lt;/p&gt;
&lt;p&gt;So, how do i get that value at the time of the interrupt?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/thread/263169?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 10:04:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78a507d9-1077-46d4-b668-1f7121d62f1e</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;With millisecond resolution, you can use low-accuracy mode. In this mode, toggle is emulated by library - it changes sense level every time an event is coming, and you&amp;#39;ll get exactly the value that pin has at the time of an event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/thread/263144?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 08:46:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79120780-b9c3-4244-93b8-d05a32758746</guid><dc:creator>Daniel Dakhno</dc:creator><description>&lt;div&gt;
&lt;div&gt;I am not too worried about timing, I can live with a few milliseconds of delay.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;p&gt;I am worried about the useless polaritiy passed to my interrupt handler.&lt;/p&gt;
&lt;p&gt;Is there any way to get the precise direction with a TOGGLE-interrupt handler?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt polarity timing issue</title><link>https://devzone.nordicsemi.com/thread/263134?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 08:24:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:239de544-cedc-4ec2-be6b-810c9d5458d6</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Hi Daniel,&lt;/p&gt;
&lt;p&gt;do you use hi-accuracy mode for gpiote?&lt;/p&gt;
&lt;p&gt;The nrfx_gpiote driver is not optimized for very time-critical tasks, you can look at&amp;nbsp;nrfx_gpiote_irq_handler in nrfx_gpiote.c to see&amp;nbsp;the size of code it runs when interrupt is detected. Using gpiote peripheral directly (without nrfx layer), you can write much shorter code that only checks signal level on a single pin and clears interrupt status. Another thing - when BLE stack is enabled, you cannot ensure time constraints because softdevice interrupts always have higher priority, and if an input signal changes multiple times while gpiote interrupt is blocked, you&amp;#39;ll receive only one event.&lt;/p&gt;
&lt;p&gt;If you need very precise timings, the best way is to pass an event to a timer or rtc via PPI to capture an exact timestamp by hardware.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>