<?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>NRF_GPIO-&amp;gt;IN reading wrong value/pin</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49864/nrf_gpio--in-reading-wrong-value-pin</link><description>Hello, 
 I have the following issue when trying to detect which GPIO triggered the interrupt: 
 
 For my low power application, I was trying to connect two switches to the nRF52DK, via the GPIOs (11 and 12). 
 The switches are connected between GND and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 Jul 2019 13:15:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49864/nrf_gpio--in-reading-wrong-value-pin" /><item><title>RE: NRF_GPIO-&gt;IN reading wrong value/pin</title><link>https://devzone.nordicsemi.com/thread/200543?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2019 13:15:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:796392c2-7041-42e8-8f4a-f641e5941f2a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for the update, and for pointing out that you may need to adjust the number of events in sdk_config.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_GPIO-&gt;IN reading wrong value/pin</title><link>https://devzone.nordicsemi.com/thread/200541?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2019 13:12:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ffbe2e1-527f-4877-939b-ec0f4369641a</guid><dc:creator>Heiner</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;I tried it again with your recommendation&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/49864/nrf_gpio--in-reading-wrong-value-pin/199757"]set the .high_accuracy flag to &amp;#39;false&amp;#39;[/quote]
&lt;p&gt;and that worked. Thank you for the explanation.&lt;/p&gt;
&lt;p&gt;It might be useful for other people reading this thread to know, that you also have to modify&amp;nbsp;&lt;code&gt;GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS&lt;/code&gt;&lt;span&gt;&amp;nbsp;in&amp;nbsp;&lt;/span&gt;&lt;code&gt;sdk_config.h to the number of low power events, or else it won&amp;#39;t work correctly.&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Tank you again for your help.&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Sincerely,&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Heiner&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_GPIO-&gt;IN reading wrong value/pin</title><link>https://devzone.nordicsemi.com/thread/199757?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 11:45:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b21294ab-b631-4bee-b486-de76bad10bb8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Heiner,&amp;nbsp;&lt;/p&gt;
[quote user="Heiner"]could you please refer to an example or point me to an explanation on how this is achieved?[/quote]
&lt;p&gt;The driver will use PORT events if you set the .high_accuracy flag to &amp;#39;false&amp;#39; when you configure the input. I.e., it should be sufficient to&amp;nbsp;just change the accuracy flag in your original code in order to use PORT event.&amp;nbsp;&lt;/p&gt;
[quote user="Heiner"]I can not really understand, why&amp;nbsp;a comparison with the&amp;nbsp;NRF_GPIO-&amp;gt;IN register would return TRUE, even if the&amp;nbsp;wrong bit is toggled.[/quote]
&lt;p&gt;&amp;nbsp;IN is not latched and&amp;nbsp;should always return the current pin state. To check if the DETECT signal has been raised for a particular pin you need to check the LATCH registers. Also, note that LATCH must be manually cleared to detect the next input transition. Recommend to use the GPIOTE/button handler library instead of creating your own code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_GPIO-&gt;IN reading wrong value/pin</title><link>https://devzone.nordicsemi.com/thread/199536?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2019 12:51:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81881230-eb31-44cb-836f-86cc5ce05557</guid><dc:creator>Heiner</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/49864/nrf_gpio--in-reading-wrong-value-pin/199262"]configuring the driver to use PORT events[/quote]
&lt;p&gt;could you please refer to an example or point me to an explanation on how this is achieved?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;In the&amp;nbsp;GPOITE documentation it is only stated: &amp;quot;&lt;span&gt;Turning off high accuracy&amp;nbsp;[...] enables the low-power feature&amp;quot; and &amp;quot;The following code example shows how to use a pin to detect toggling using high accuracy&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There&amp;#39;s no example on how to use the low accuracy function of the driver, neither it&amp;#39;s&amp;nbsp;explained how to &lt;span style="font-size:12px;"&gt;configure&lt;/span&gt;&amp;nbsp;the driver to use a PORT event instead, at least not in that section.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/49864/nrf_gpio--in-reading-wrong-value-pin/199262"]look up the addresses in the memory view[/quote]
&lt;p&gt;That worked, thank you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However I&amp;#39;m even more confused now, because the registers actually change as expected. I even changed my GPIOs to #30 and #31, to move them as far from the button GPIOs as possible, but the problem remains.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;I can not really understand, why&amp;nbsp;a comparison with the&amp;nbsp;NRF_GPIO-&amp;gt;IN register would return TRUE, even if the&amp;nbsp;wrong bit is toggled.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;From my understanding it should only return TRUE once, when for example Bit 31 is changing from 1 to 0 and I compare&amp;nbsp;&amp;nbsp;~NRF_GPIO-&amp;gt;IN &amp;amp; 1&amp;lt;&amp;lt;31.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;~NRF_GPIO-&amp;gt;IN &amp;amp; 1&amp;lt;&amp;lt;30 should not return true in this case, if Bit 30 is still 1.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Sincerely,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Heiner&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_GPIO-&gt;IN reading wrong value/pin</title><link>https://devzone.nordicsemi.com/thread/199262?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 12:05:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d655783a-85f4-4247-80ab-62d7be869e50</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]Using&amp;nbsp;the nrf GPIOTE driver works, but I wanted a solution that consumes less power, as this is for a low power application.[/quote]
&lt;p&gt;The driver would become low power if you configured it to use the PORT event instead of the IN events. Excerpt from the driver documentation:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/hardware_driver_gpiote.html?cp=5_1_2_0_3"&gt;&lt;em&gt;Input pins can be configured to be controlled in different modes:&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/hardware_driver_gpiote.html?cp=5_1_2_0_3"&gt;&lt;em&gt;High accuracy: An independent GPIOTE event is used to detect changes on the pin. If a pin is configured to be controlled in this mode, a high frequency clock is required.&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/hardware_driver_gpiote.html?cp=5_1_2_0_3"&gt;&lt;em&gt;Low accuracy/low power: A PORT event senses level changes on the pin. One PORT event can be used for multiple pins. Therefore, it is not that accurate and cannot be used to track high-speed pin changes. On the other hand, if a pin is configured in this mode, the system can turn off the high frequency clock when sleeping.&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So I would suggest that you to go revert back to the working configuration and make sure you configuring the driver to use PORT events. You may also consider using the&amp;nbsp;&lt;a title="Button handling library" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_button.html?cp=5_1_3_7"&gt;Button handling librar&lt;/a&gt;y&amp;nbsp;on top to handle debouncing if that&amp;#39;s necessary for your design.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user=""]However they would both have to be high, before one switch could toggle an interrupt. If one switch was low it wouldn&amp;#39;t work for some reason.[/quote]
&lt;p&gt;PORT events are triggered by the DETECT signal. This is explained in more detail in the GPIO chapter of the product specification (&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/gpio.html?cp=3_1_0_19_0#concept_o12_bgv_bs"&gt;link&lt;/a&gt;).&amp;nbsp;&lt;/p&gt;
[quote user=""]Looking at the LOG output (since NRF_GPIO-&amp;gt;IN is restricted memory, that I cannot debug) it does seem like one pin is triggering both if clauses.[/quote]
&lt;p&gt;&amp;nbsp;This is a limitation imposed by Segger embedded Studio, but you can look up the addresses in the memory view as a work-around.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>