Nordic nrf52840 GPIO numbering.?

I am trying to figure out how the GPIO for Arduino is defined, because the micro has ports A, B, etc, and every port has its own number. Somewhere this translation is done to enable us to use decimal values.

The serial port works fine via the virtual port, thus I assume the old dev kit is still OK, the LEDs do have a supply, but the MCU never turns output low to shine a LED.

I using the old Nordic Dev Kit. “Ini” file looks like this

[env:nrf52840_dk]
;platform = nordicnrf52
platform = https://github.com/platformio/platform-nordicnrf52.git
framework = arduino
board = nrf52840_dk
build_flags = -D NRF52840_DK ; another try
; build_flags = -D LED_BLINK=13 ; Tried a few thumb sucks
  1. How do I convert P0.13, P1.09 for instance to a number?
  2. Can special Ports like I2C, SPI, etc, can I used the above number at instantiation?
  3. Analogue port numbering scheme, can that also use the above number?

I need to make up my own ‘board’ for my custom design.
NS I looks at variant.c but it does not define all the ports, and even If I used this translation it still does not work. (g_ADigitalPinMap)

Example : P0.13 => 13,

But this is how the translation works.

Look at:

and

and

Using digitalWrite(1, HIGH); translates into accessing g_ADigitalPinMap[1] which contains the number 12, i.e., P0.12.

If you wanted to access all pins, then use the Generic variant, by using board_build.variant = Generic in the platformio.ini. With that variant, the Arduino pin number is exactly equal to the GPIO number, in ascending order. 0 = P0.00, 31 = P0.31, 32 = P1.00, …

1 Like

Thanks, I try the board_build.variant = Generic in the platformio.ini and do the lookup myself.
Regards

Like always, you have the know-how, it works, Thanks

Forgot to set the solved tag…