<?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>Set and clear GPIO pins at the same time</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16777/set-and-clear-gpio-pins-at-the-same-time</link><description>Hey, 
 currently I use nrf_gpio_pins_set() and and nrf_gpio_pins_clear() from nrf_gpio.h to set and clear specific GPIO ports, respectively. If I want to change the current state of -say- 4 GPIO ports at once (some of them may be cleared, some of them</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 Oct 2016 17:42:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16777/set-and-clear-gpio-pins-at-the-same-time" /><item><title>RE: Set and clear GPIO pins at the same time</title><link>https://devzone.nordicsemi.com/thread/64174?ContentTypeID=1</link><pubDate>Mon, 03 Oct 2016 17:42:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc472d7b-b856-40ae-b888-111eb5d1ed07</guid><dc:creator>NewtoM</dc:creator><description>&lt;p&gt;Thank you both!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set and clear GPIO pins at the same time</title><link>https://devzone.nordicsemi.com/thread/64173?ContentTypeID=1</link><pubDate>Mon, 03 Oct 2016 08:39:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d3400e2-e0c2-4e10-b2a4-e02087a9400a</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi NewtoM&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t think of any concerns when accessing GPIO-&amp;gt;OUT, other than making sure you don&amp;#39;t change bits in the register that you are not supposed to change.
There is no way to accept multiple answers unfortunately, but RK&amp;#39;s answer already got more upvotes so I suggest you accept that ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set and clear GPIO pins at the same time</title><link>https://devzone.nordicsemi.com/thread/64175?ContentTypeID=1</link><pubDate>Sat, 01 Oct 2016 20:03:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0787f0e-d0eb-43c8-95e3-67a90dda66e5</guid><dc:creator>NewtoM</dc:creator><description>&lt;p&gt;Thanks RK, thanks Torbjørn,&lt;/p&gt;
&lt;p&gt;now I see the idea. If I look at the &lt;code&gt;nrf_gpio_pins_toggle()&lt;/code&gt; function, I see how the &lt;code&gt;GPIO-&amp;gt;OUT&lt;/code&gt; register state read. Is there anything I should be aware of when directly reading/writing the &lt;code&gt;OUT&lt;/code&gt; register?&lt;/p&gt;
&lt;p&gt;And can I accept both answers? :)&lt;/p&gt;
&lt;p&gt;NewtoM&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set and clear GPIO pins at the same time</title><link>https://devzone.nordicsemi.com/thread/64172?ContentTypeID=1</link><pubDate>Fri, 30 Sep 2016 15:12:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dba04ae7-e887-401e-9434-223d472a3b78</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi NewtoM&lt;/p&gt;
&lt;p&gt;If you want to do this you probably have to bypass the nrf_gpio functions, and write directly to the GPIO registers.
Fortunately it isn&amp;#39;t as scary as it sounds ;)&lt;/p&gt;
&lt;p&gt;To set/clear many pins at once you can write to the OUTSET or OUTCLR registers in the NRF_GPIO peripheral.&lt;/p&gt;
&lt;p&gt;If you want to set &lt;em&gt;and&lt;/em&gt; clear many pins at once you have to use the OUT register.&lt;/p&gt;
&lt;p&gt;Say you want to set pins P0.08-P0.011 to 0xA you could do it like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pin_mask = 0xF &amp;lt;&amp;lt; 8;
NRF_GPIO-&amp;gt;OUT = (NRF_GPIO-&amp;gt;OUT &amp;amp; ~pin_mask) | (0xA &amp;lt;&amp;lt; 8);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can still use the nrf_gpio driver to configure the outputs, and set/clear individual pins.&lt;/p&gt;
&lt;p&gt;-Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set and clear GPIO pins at the same time</title><link>https://devzone.nordicsemi.com/thread/64171?ContentTypeID=1</link><pubDate>Fri, 30 Sep 2016 12:32:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8aa1db9c-2e42-4e7d-a402-9b6be0bafdeb</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Read the GPIO port to get the current state, set and clear bits in that value, then write it back.&lt;/p&gt;
&lt;p&gt;Just as there is a GPIO-&amp;gt;OUTSET and a GPIO-&amp;gt;OUTCLR register, so there is a GPIO-&amp;gt;OUT register you can write to set the whole register at once.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>