<?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>How to set GPIO as open drain ouput mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4555/how-to-set-gpio-as-open-drain-ouput-mode</link><description>I want to use a GPIO as input pin and output pin at the same time with an external pull-up resistor. Thanks.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Mar 2017 02:40:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4555/how-to-set-gpio-as-open-drain-ouput-mode" /><item><title>RE: How to set GPIO as open drain ouput mode</title><link>https://devzone.nordicsemi.com/thread/16160?ContentTypeID=1</link><pubDate>Tue, 14 Mar 2017 02:40:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22a09494-edae-4493-8551-7eeb3d8044a6</guid><dc:creator>Jack-h</dc:creator><description>&lt;p&gt;Hi,why I configured this like you,but my ds18b20 also be invalid?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set GPIO as open drain ouput mode</title><link>https://devzone.nordicsemi.com/thread/16159?ContentTypeID=1</link><pubDate>Tue, 25 Nov 2014 21:13:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85c6b673-20c6-4ddc-a2f6-f88d9f8d34e9</guid><dc:creator>JiachengWang</dc:creator><description>&lt;p&gt;Its my mistake. The pin is connected to LED, some voltage go to LED, after changed the pin, I got 3.3v output. Yes, the pin can be written as 1 or 0. However, when I try to read the pin, it is always 0 even the pin is HIGH state, so I change the above code with &amp;quot;GPIO_PIN_CNF_INPUT_Connect &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos&amp;quot;, that I can read 1 or 0. Does this change make sene ? Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set GPIO as open drain ouput mode</title><link>https://devzone.nordicsemi.com/thread/16158?ContentTypeID=1</link><pubDate>Tue, 25 Nov 2014 14:07:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8152611c-b05e-49e6-a995-57355b59122e</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;That sounds strange. What resistor value are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set GPIO as open drain ouput mode</title><link>https://devzone.nordicsemi.com/thread/16157?ContentTypeID=1</link><pubDate>Mon, 24 Nov 2014 15:35:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b8c70f8-2f9a-4b4c-a8a5-f5ae693e3b86</guid><dc:creator>JiachengWang</dc:creator><description>&lt;p&gt;Thanks.
However, the output voltage is only about 2.0v when write 1 to the pin, no matter the pin is pulled up to 3.3v or 5.0v. How to get 3.3v output? Thanks again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set GPIO as open drain ouput mode</title><link>https://devzone.nordicsemi.com/thread/16156?ContentTypeID=1</link><pubDate>Mon, 24 Nov 2014 14:04:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72b3e8ff-10c3-498b-9316-c4834a515612</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;If you intend to control a GPIO pin signal with a connected external pullup resistor with a scenario like in the image bolow&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/GPIO-as-open-drain.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;then you can configure the pin in the following manner:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;	NRF_GPIO-&amp;gt;PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)		
                                  | (GPIO_PIN_CNF_DRIVE_S0D1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos)
				  				  | (GPIO_PIN_CNF_PULL_Disabled &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)
								  | (GPIO_PIN_CNF_INPUT_Disconnect &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos)
								  | (GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;then when you write 0 to the pin, it will drive it to low signal with drive strength of 0.5mA max (standard drive strength). If you write 1 to the pin, it will be disconnected and the external pullup resistor will drive the pin to high signal.&lt;/p&gt;
&lt;p&gt;If you change the configuration to&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(GPIO_PIN_CNF_DRIVE_H0D1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;then the pin will be driven to low signal with max 5mA current (high drive strength) when you write 0 to it. When you write 1 it will be disconnected.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 25.11.2014&lt;/strong&gt;
You can use &lt;a href="https://github.com/NordicSemiconductor/nrf51-powerdown-examples/blob/master/system-on-wakeup-on-gpio/main.c"&gt;this&lt;/a&gt; example directly to test this, just replace the LED configuration line with the configuration code listed above, then you should be able to set pin p0.08 pin by pressing button 0 and clear pin p0.08 with pressing button 1. Remember to change the configuration of the example if necessary so that it fits to your development/evaluation kit, see &lt;a href="https://devzone.nordicsemi.com/question/21549/how-to-port-nrf51822-development-kit-examples-to-the-nrf51822-evaluation-kit/?answer=21550#post-id-21550"&gt;this thread&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>