<?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>GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7417/gpio-pullups-and-direction</link><description>If I write a zero to the output register, and enable the pullup on the same pin, can I switch between driven low output and input with pullup simply by settting/clearing the DIR bit? Will the pullup still be in circuit when the output is enabled? I have</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 06 Jun 2015 13:03:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7417/gpio-pullups-and-direction" /><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26391?ContentTypeID=1</link><pubDate>Sat, 06 Jun 2015 13:03:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a155405-5f31-4f70-b37a-241b5fd81e7c</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;No problem. Thanks for confirming things.&lt;/p&gt;
&lt;p&gt;John&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26387?ContentTypeID=1</link><pubDate>Thu, 04 Jun 2015 12:39:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44e8e524-86ec-4111-94c9-7dfedeb3500f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I have this confirmed and to my ignorance, I was testing it all wrong. I did two mistakes, I choose a GPIO pin that is connected to an onboard LED and my logic analyzer trigger was not sampling fast enough .Sorry for that John. The pullup configuration stays when you change the Pin direction.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26390?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 19:15:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb4c7d68-c413-4643-8d45-e8e65528d063</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;This is very confusing, Logic analyzer should have caught that. I will ask the architect now to confirm on this and will update this thread tomorrow.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26392?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 14:08:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d28ec19b-4ca7-421f-acdd-3e34cf8d7363</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;Well we&amp;#39;ll have to agree to disagree on that, then. I haven&amp;#39;t connected a logic analyser, but I have used a low current LED with a 220R resistor in series, and I am getting a dim glow, consistent with a pullup being enabled.&lt;/p&gt;
&lt;p&gt;Using exactly this code(LED is on P0.17)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;   NRF_GPIO-&amp;gt;DIRCLR = (1UL &amp;lt;&amp;lt; 17);		// Set as ip
    NRF_GPIO-&amp;gt;PIN_CNF[17] |= GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos; // Set pullup

    SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[17]);
    nrf_start_timer_ms(2000);	// Set timeout at 2 seconds

    	while (NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0] == 0)
    	  {
    	  }


    NRF_GPIO-&amp;gt;DIRSET = (1UL &amp;lt;&amp;lt; 17);		// Set as op
    SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[17]);
    nrf_start_timer_ms(2000);	// Set timeout at 2 seconds

    	while (NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0] == 0)
    	  {
    	  }


    NRF_GPIO-&amp;gt;DIRCLR = (1UL &amp;lt;&amp;lt; 17);		// Set as ip
    SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[17]);

    while(1);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;John&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26389?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 13:43:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c579b25-9269-43d8-bee3-76ba6aff2d08</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;my bad, i just typed in the code in this answer, but when i tested i used DIR register.
And to elaborate, the PIN_CNF still reads that the pullup configuration stays but I don&amp;#39;t see that really effecting the pin state on logic analyzer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26388?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 12:12:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da45a080-6e49-40ca-bc4f-dc5b73e6548c</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;Sorry, the code tages got screwed up there!
But as you can see, if you use DIRSET and DIRCLR correctly, the pullup does seem to persist.&lt;/p&gt;
&lt;p&gt;John&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26386?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 12:10:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4c511cb-7d9c-4769-8446-d384f8e45cfc</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;NRF_GPIO-&amp;gt;DIRCLR = (1UL &amp;lt;&amp;lt; BUTTON_NORTH);		// Set as ip
NRF_GPIO-&amp;gt;PIN_CNF[BUTTON_NORTH] |= GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos; // Set pullup&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[BUTTON_NORTH]);
NRF_GPIO-&amp;gt;DIRSET = (1UL &amp;lt;&amp;lt; BUTTON_NORTH);		// Set as op
SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[BUTTON_NORTH]);
NRF_GPIO-&amp;gt;DIRCLR = (1UL &amp;lt;&amp;lt; BUTTON_NORTH);		// Set as ip
SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[BUTTON_NORTH]);

while(1);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;0&amp;gt;  PIN_CNF = 0000000E
0&amp;gt;&lt;br /&gt;
PIN_CNF = 0000000F
0&amp;gt;&lt;br /&gt;
PIN_CNF = 0000000E
0&amp;gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26385?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 12:06:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65c70122-6cb4-4a84-aadd-09313e268a31</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;I think you are using the wrong register. It should be DIR, rather than DIRSET.
I just wrote the following snippet of code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_GPIO-&amp;gt;DIR &amp;amp;= ~(1UL &amp;lt;&amp;lt; BUTTON_NORTH);		// Set as ip
NRF_GPIO-&amp;gt;PIN_CNF[BUTTON_NORTH] |= GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos; // Set pullup

SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[BUTTON_NORTH]);
NRF_GPIO-&amp;gt;DIR |= (1UL &amp;lt;&amp;lt; BUTTON_NORTH);		// Set as op
SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[BUTTON_NORTH]);
NRF_GPIO-&amp;gt;DIR &amp;amp;= ~(1UL &amp;lt;&amp;lt; BUTTON_NORTH);		// Set as ip
SEGGER_RTT_printf(0, &amp;quot;PIN_CNF = %08x\n\r&amp;quot;, NRF_GPIO-&amp;gt;PIN_CNF[BUTTON_NORTH]);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and the output on the Segger RTT shows the PIN_CNF rgister to be:
0x0000000e
0x0000000f
0x0000000e&lt;/p&gt;
&lt;p&gt;So I believe the pullup does persist if you use the DIR register to chage direction.&lt;/p&gt;
&lt;p&gt;I will re-write this to use the DIRSET and DIRCLR registers...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;while(1);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26384?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 11:28:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8fc53aa-63ed-49a8-8c1f-1d5c86534a07</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I think this came as a side effect of being able to set direction either from DIR register or in PIN_CNF register. i will bring this to notice of right people.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26383?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 11:16:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bafbf9c-e60f-4e05-a7e1-72726673f4cc</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;Thanks for the answer, but I have to say that sounds like a crazy system to me! Some things about the nRF51822 are great, others, like this and the compromised PWM capability, are not so great.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO pullups and direction</title><link>https://devzone.nordicsemi.com/thread/26382?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 09:54:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad987cb0-16e9-417e-a202-e0204d2008e0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I have tried the both ,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_GPIO-&amp;gt;DIRSET |= (1UL &amp;lt;&amp;lt; LED_1);
NRF_GPIO-&amp;gt;PIN_CNF[LED_1] |=  GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos;	

NRF_GPIO-&amp;gt;DIRSET &amp;amp;= ~(1UL &amp;lt;&amp;lt; LED_1);
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;pre&gt;&lt;code&gt;NRF_GPIO-&amp;gt;DIRSET &amp;amp;= ~(1UL &amp;lt;&amp;lt; LED_1);
NRF_GPIO-&amp;gt;PIN_CNF[LED_1] |=  GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos;	

NRF_GPIO-&amp;gt;DIRSET |= (1UL &amp;lt;&amp;lt; LED_1);
while(1);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and the pullup wasn&amp;#39;t there. So i am concluding that it will be reset to no_pull everytime we change pin direction&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>