<?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 bits of register via mask</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16499/set-bits-of-register-via-mask</link><description>Sorry for probably stupid question.. 
 All the time in SDK we set need bits through the mask, for example 
 NRF_GPIOTE-&amp;gt;CONFIG[idx] |= (pin &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos) &amp;amp; GPIOTE_CONFIG_PSEL_Msk) 
 I can&amp;#39;t understand why we don&amp;#39;t just write such way:</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 18 Sep 2016 11:47:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16499/set-bits-of-register-via-mask" /><item><title>RE: set bits of register via mask</title><link>https://devzone.nordicsemi.com/thread/63144?ContentTypeID=1</link><pubDate>Sun, 18 Sep 2016 11:47:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fddc20c3-fd84-4a43-9701-d44ba4219285</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;What do you get if you specify pin as 0xffffffff, or in fact anything larger than 31? ANDing with the mask ensures that even if you entirely misuse the macro, you don&amp;#39;t leak into other bits of the config register.&lt;/p&gt;
&lt;p&gt;Since usually pin is a constant known at compile time, it doesn&amp;#39;t matter at all, the compiler will turn the whole thing into a constant.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>