<?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>nRF52840 pin addressing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107982/nrf52840-pin-addressing</link><description>As part of efforts for providing MicroPython support, we are specifying the pin definitions for the Arduino Nano 33 BLE Sense . This Arduino board, is based upon the nRF52840 chip with the open source schematics available here . 
 We have a preliminary</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Feb 2024 12:53:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107982/nrf52840-pin-addressing" /><item><title>RE: nRF52840 pin addressing</title><link>https://devzone.nordicsemi.com/thread/467165?ContentTypeID=1</link><pubDate>Thu, 01 Feb 2024 12:53:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75d2625b-1cc8-4ea9-8cd5-09fd4b623ab5</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;From a chip perspective, the firmware should always refer to the Px.xx GPIO numbers (for digital pins). The physical pin naming can differ between package type and board.&lt;/p&gt;
&lt;p&gt;In nRF52840, there are two GPIO ports (P0 and P1, each with its own &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/gpio.html#topic"&gt;base address&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;All digital peripherals where you can assign pins use 6 bits for port and pin, where the port is the 6th bit (1&amp;lt;&amp;lt;5), see for instance &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/spim.html#register.PSEL.SCK"&gt;SPIM&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/uarte.html#register.PSEL.RTS"&gt;UARTE&lt;/a&gt;&amp;nbsp;and &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/pwm.html#register.PSEL.OUT-0-3"&gt;PWM&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;How you interface with the GPIOs determine how you should reference this from the firmware. Our GPIO HAL functions provides a macro function to define pins, &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/v2.11.0/hal/nrf_gpio.h#L81"&gt;NRF_GPIO_PIN_MAP(port, pin)&lt;/a&gt;&amp;nbsp;that handles conversion to correct port (adding 32 to the pin number for port1, similar to the description in your linked Zephyr documentation). When the GPIO HAL APIs are used to control GPIOs, the port number is &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/v2.11.0/hal/nrf_gpio.h#L629"&gt;decoded&lt;/a&gt; to interface the correct port base address. If you are interfacing everything through nrfx APIs, it should be safe to use this for GPIO definitions.&lt;/p&gt;
&lt;p&gt;I have no experience with MicroPython, so can&amp;#39;t give any specific recommendations for best practice in this environment.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>