<?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>GPIOs pins to be set to send command</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52025/gpios-pins-to-be-set-to-send-command</link><description>Hi everyone, 
 
 for a project, we need to interface an analog sensor which is not using standard protocols like I2C or SPI. 
 Instead, it uses 6 pins to receive commands. So, if I need to send for example command 0x24, I need to set this value on the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Sep 2019 10:43:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52025/gpios-pins-to-be-set-to-send-command" /><item><title>RE: GPIOs pins to be set to send command</title><link>https://devzone.nordicsemi.com/thread/209382?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2019 10:43:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26c02c74-95ff-4560-a270-aae6e1a18933</guid><dc:creator>lbe</dc:creator><description>&lt;p&gt;Of course, I did not consider using NRF_P1-&amp;gt;OUT directly &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Your solution is cleaner, thanks for the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOs pins to be set to send command</title><link>https://devzone.nordicsemi.com/thread/209372?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2019 09:51:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97a17146-9dbf-421b-9049-f3f0f49f2714</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Ah.. or presuming you are using port1 just something like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SENSOR_FIRST_PIN_PORT1 1

void writeCommandPort1(uint8_t value)
{
    uint32_t pin_mask = 0xF &amp;lt;&amp;lt; SENSOR_FIRST_PIN_PORT1;
    NRF_P1-&amp;gt;OUT = (NRF_P1-&amp;gt;OUT &amp;amp; ~pin_mask) | (value &amp;lt;&amp;lt; SENSOR_FIRST_PIN_PORT1);  
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOs pins to be set to send command</title><link>https://devzone.nordicsemi.com/thread/209347?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2019 09:00:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:874d6538-8d79-41d5-a641-05d619851baf</guid><dc:creator>lbe</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;this code is part of a pretty large project and I cannot share it.&lt;br /&gt;But I found the reason to the warning: since SENSOR_FIRST_PIN = NRF_GPIO_PIN_MAP(1,1), this means that&lt;/p&gt;
&lt;p&gt;the pin_mask is =&amp;nbsp;33, so the pin_mask value falls out of the possible range for a uint32_t value....&lt;/p&gt;
&lt;p&gt;The solution I found is to use the following code&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void writeCommandPort(uint8_t value)
{
    uint64_t pin_mask = 0xFLL &amp;lt;&amp;lt; SENSOR_FIRST_PIN;
    NRF_GPIO-&amp;gt;OUT = (NRF_GPIO-&amp;gt;OUT &amp;amp; ~pin_mask) | ((uint64_t)value &amp;lt;&amp;lt; SENSOR_FIRST_PIN);  
}


//Where SENSOR_FIRST_PIN = NRF_GPIO_PIN_MAP(1,1) &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Essentially, I used 64 bits value for the mask, since the pins I am going to modify are &amp;gt; 32.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I still need to test it, so I would appreciate any feedback if you think there is something wrong with this solution,&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOs pins to be set to send command</title><link>https://devzone.nordicsemi.com/thread/209250?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2019 16:18:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3dbe4781-7111-4dd5-a24b-3fd42e68a692</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Tried your code, but couldn&amp;#39;t get the warning. Maybe you can share a small SES project + main.c I can run on a nRF52840?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>