<?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_read_pin doesn&amp;#39;t seem to be working</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10246/nrf_gpio_read_pin-doesn-t-seem-to-be-working</link><description>I am trying to read if an input is 0 or 1 but for some reason it takes the first one its offered and then it does not change anymore. 
 int main(void)
{
 nrf_gpio_cfg_output(24);
 
 nrf_gpio_cfg_input(26, NRF_GPIO_PIN_NOPULL);	

 for(;;)
 { </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Nov 2019 11:54:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10246/nrf_gpio_read_pin-doesn-t-seem-to-be-working" /><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/222328?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2019 11:54:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e95b4818-b235-4b44-b533-6fac0f9e299c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can refer to the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__gpio__hal.html?cp=6_1_6_9_0_13_0_20#ga76870ecdd68f3e26eeea7ea3c5ad6b55"&gt;API documentation&lt;/a&gt;. If you need more assistance, please create a new question as this thread is old.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/222311?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2019 10:57:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a91bd05d-505d-4f2a-bdad-23ee1df6e0c7</guid><dc:creator>diya</dc:creator><description>&lt;p&gt;hii sir,&lt;/p&gt;
&lt;p&gt;how to use the nrf_gpio_pin_read(pin_number) in our required application?can you tell what directory or headerfile or makefile is required for using the gpio functions&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38046?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2015 10:32:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d229ed21-6785-4a29-b1c0-661666c61c45</guid><dc:creator>LuGr</dc:creator><description>&lt;p&gt;Made a mistake while updating the code it was actually in the main code but wasn&amp;#39;t at my computer while typing but as I can get the nrf_gpio_pin_read() to work on other pins than the one I was using originally I recon the question is resolved as the problem does not seem to be with the function but rather with the pins I was using. If more problems show up around these pins i&amp;#39;ll create a new question.  Thank you for your time and help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38045?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 15:47:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48b22c6c-0b03-4c44-8fad-b3678c1750a1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Does the updated code you have compile without warnings? It is not legal to put statements outside a function body. Move your calls to &lt;code&gt;nrf_gpio_cfg_output()&lt;/code&gt; and &lt;code&gt;nrf_gpio_cfg_input()&lt;/code&gt; inside &lt;code&gt;main()&lt;/code&gt;, and see if that solves the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38044?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 15:31:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8d7ff8a-b5a7-4a93-97c7-852e34fc2796</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;What do you mean you declared it above main? Is it called somewhere? Can you post the complete code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38042?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 15:23:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:687f4798-8936-4a5b-ab5b-0b76251307bd</guid><dc:creator>LuGr</dc:creator><description>&lt;p&gt;The VDD is 3.3V and I forgot to post the pin declaration as I declared the IO above main. In the final product the GPIOTE/PPI will be used to handle this but at the moment I am prototyping hardware and found it strange that some pins do not work as input on two boards and some pins do and was unable to find why in the product specifications or other documents.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38043?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 15:03:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6f59289-65a7-4c74-94ea-caf76670979b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;What is the supply voltage (VDD)? In the last code snipped of your updated post you do not configure the input pin (26) as a input, and if you do not, &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/group__nrf__gpio.html#ga76870ecdd68f3e26eeea7ea3c5ad6b55"&gt;&lt;code&gt;nrf_gpio_pin_read()&lt;/code&gt;&lt;/a&gt; will not return a valid value. Note that in general you would want do do this differently, using GPIOTE so that you get events instead of polling the pin. For a real product that makes much more sense.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38039?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 10:34:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:901d1e2d-0150-43eb-b45f-0af78d62e462</guid><dc:creator>LuGr</dc:creator><description>&lt;p&gt;I&amp;#39;ve measured the comperator output and the logical high is 3.28V and the low is 0.01V. But after trying out some more pins I&amp;#39;ve found I can read the logical high and low with pin 10 not sure what the difference between it and the other pins is as I&amp;#39;ve yet to discern it from the product specifications.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38040?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 10:19:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a2ffbea-93a1-4b50-ba5f-2540f6a6b286</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;What is the voltage of the logical 0 and logical 1 out of your external comparator (in to the GPIO)? According to Section 8.23 in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.pdf.ps/nRF51422_PS_v3.1.pdf"&gt;Product Specification&lt;/a&gt; a logical high is between 0.7*VDD and VDD and a logical low is between VSS and 0.3 VDD.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38048?ContentTypeID=1</link><pubDate>Fri, 13 Nov 2015 14:57:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af395cd7-0d25-42d9-9b90-f9a51b7ba157</guid><dc:creator>LuGr</dc:creator><description>&lt;p&gt;I had verified the error with the debugger and an oscilloscope but after loading a couple of example projects using the read function it started to work. I am not sure what solved the problem eventually.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38047?ContentTypeID=1</link><pubDate>Fri, 13 Nov 2015 14:35:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88663341-f5a6-431e-854f-5fca389970f0</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I do not see a problem with your code. Have you verified with a debugger or in another way that you always read the same value? I did a small modification to your code in order to run the code on the nRF51 DK and this code works for me:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define BUTTON_1 17
#define LED_1 21

int main(void)
{
   nrf_gpio_cfg_output(LED_1);

   nrf_gpio_cfg_input(BUTTON_1, NRF_GPIO_PIN_PULLUP); 

   for(;;)
   {      
      if(nrf_gpio_pin_read(BUTTON_1) == 0)
      {
         nrf_gpio_pin_toggle(LED_1);
      }
   }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The intensity of the LED will be a bit dimmed when button 1 is pressed down, as the duty cycle of the LED will be 50% due to the toggling. When the button is not pressed the LED will either be off or glowing at 100%.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_gpio_read_pin doesn't seem to be working</title><link>https://devzone.nordicsemi.com/thread/38041?ContentTypeID=1</link><pubDate>Fri, 13 Nov 2015 14:05:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d91857b-5741-4b30-afd2-586388cc2c18</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I&amp;#39;m a bit uncertain about your code. If you execute it like  you show, &lt;code&gt;nrf_gpio_pin_read()&lt;/code&gt; is only called once, and so it is no wander that it never changes. Or do you call it in a loop, just that you did not include the code for it? If you can post more of your code or a better explanation we will not have to make so many assumptions, and it will be easier to find a good answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>