<?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>Trying to define 2 interrupt handlers for the same pin, one for up one for down</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61480/trying-to-define-2-interrupt-handlers-for-the-same-pin-one-for-up-one-for-down</link><description>Hi 
 I am working with nrf52832 NORDIC soc with Segger with nrf52 sdk 16 
 
 I have looked at the &amp;quot;pin_change_int_pca_10040&amp;quot; example and tried to play with it a little bit 
 
 If I change the &amp;quot;GPIOTE_CONFIG_IN_SENSE_TOGGLE(bool)&amp;quot; from &amp;#39;true&amp;#39; to &amp;#39;false</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 May 2020 21:11:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61480/trying-to-define-2-interrupt-handlers-for-the-same-pin-one-for-up-one-for-down" /><item><title>RE: Trying to define 2 interrupt handlers for the same pin, one for up one for down</title><link>https://devzone.nordicsemi.com/thread/252051?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 21:11:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f805653c-9bdf-4bc2-8e32-ef64b6506113</guid><dc:creator>mtsunstrum</dc:creator><description>&lt;p&gt;I am not so sure nrfx_gpiote is doing exactly what we think it should be doing ...&lt;/p&gt;
&lt;p&gt;I am working thru some issues now ... so not 100% sure on all of this.&lt;/p&gt;
&lt;p&gt;But here is my findings: SDK 16.0.0&lt;/p&gt;
&lt;p&gt;For @ziv123 question, possibly one might expect you can code it as follows:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;// Set up to use more accurate PIN events, not PORT events ...&lt;br /&gt;//&amp;nbsp; &amp;nbsp; &amp;nbsp;Detect both rising/falling edges ...&lt;br /&gt;nrfx_gpiote_in_config_t signal_intr_config = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);&lt;/p&gt;
&lt;p&gt;// Set up Pin 22 as a GPIOTE input, with interrupt handler ...&lt;br /&gt;//&amp;nbsp; &amp;nbsp;... understand we cannot have separate isr for rising / falling edge ... OK&lt;br /&gt;err_code = nrfx_gpiote_in_init(22, &amp;amp;signal_intr_config, isr_my_input_signal_handler);&lt;br /&gt;APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;// Set Pin 22 to generate event when it goes from Lo to Hi level&lt;br /&gt;nrf_gpiote_event_configure(0, 22, NRF_GPIOTE_POLARITY_LOTOHI);&lt;/p&gt;
&lt;p&gt;// Set Pin 22 to generate event when it goes from Hi to Lo level&lt;br /&gt;nrf_gpiote_event_configure(1, 22, NRF_GPIOTE_POLARITY_HITOLO);&lt;/p&gt;
&lt;p&gt;// Enable GPIOTE Pin 22 to generate event(s), enable interrupts.&lt;br /&gt;nrfx_gpiote_in_event_enable(22, true);&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Answering his question, we cannot have seperate ISRs ... but other issues seem unexpected:&lt;/p&gt;
&lt;p&gt;With above code, I appear to see following concerns:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GPIOTE seems to be configured in PORT events, not PIN events (high accuracy)&lt;/li&gt;
&lt;li&gt;Event 1 for&amp;nbsp;NRF_GPIOTE_POLARITY_HITOLO is not enabled ... ie. not set into Event mode&lt;/li&gt;
&lt;li&gt;Seems we cannot have 2 events configured for same pin time&lt;/li&gt;
&lt;li&gt;Appears to be a limitation of code implemented in&amp;nbsp;&lt;span&gt;nrfx_gpiote_in_event_enable()&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;On call into&amp;nbsp;isr_my_input_signal_handler(), &amp;#39;action&amp;#39; parameter appears to only return &amp;#39;action&amp;#39; value of toggle&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;... does NOT appear to return the actual hi/lo or lo/hi transition.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Would not want to read the GPIO pin, because pin state could be lost by that time.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;Trying to work around these issues right now ... not sure if others are seeing the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to define 2 interrupt handlers for the same pin, one for up one for down</title><link>https://devzone.nordicsemi.com/thread/250755?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 13:32:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f9b1a93-d099-4109-985a-7e88ada1ba94</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1) There are two modes how GPIOTE can work: using PIN or PORT events. PIN events can be set individually for up to 8 pins to monitor rising/falling/both edges, the response is very fast, but it has a disadvantage - relatively high power consumption because it requires high-frequency clock to remain active.&lt;br /&gt;PORT event is&amp;nbsp;set for the whole port and can be configured only to monitor high or low pin state (though logic similar to PIN event is emulated in gpiote library), the response is slower, but power consumption is very low, and it can be used to wake up device from power-down mode.&lt;br /&gt;The bool value you&amp;#39;ve asked about chooses mode - true for PIN event, false for PORT event.&lt;/p&gt;
&lt;p&gt;2) You cannot set two interrupt handlers for pin change event, but gpiote driver passes pin state to your handler - there&amp;#39;s no need to have two different handlers.&lt;/p&gt;
&lt;p&gt;3) GPIO works like in any other microcontroller - you can read and control pin state, direction, pullup/pulldown by software. GPIOTE is mainly intended to interact with other peripheral modules through events and tasks - a very powerful mechanism. You can read about tasks, events and PPI &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fperipheral_interface.html&amp;amp;cp=4_0_0_5_0_4&amp;amp;anchor=concept_jjw_45z_vr"&gt;here&lt;/a&gt;,&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fppi.html&amp;amp;cp=4_0_0_5_15"&gt;here&lt;/a&gt;&amp;nbsp;and &lt;a href="https://natersoz.net/2019/04/07/nordic-tasks-and-events/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to define 2 interrupt handlers for the same pin, one for up one for down</title><link>https://devzone.nordicsemi.com/thread/250436?ContentTypeID=1</link><pubDate>Mon, 18 May 2020 12:21:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92624330-7954-48ce-929a-8bce83c2306f</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;well i have found that i can use &amp;quot;nrf_gpio_pin_read()&amp;quot; on the pin in the pin in handler, but i wonder if that is the only or the best way to achive that&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i have tried to change the action parameter of the handler and it seems it will not change after init so it is not clear why it is passed to the handler function in the example&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>