platformio arduino vscode how to use P1.0~P1.15

Hello,

i.m now use vscode platformio arduino framework.  win10 x64,   nRF52840DK

install github.com/.../platform-nordicnrf52.git

     

platformio.ini
[env:nrf52_dk]
platform = nordicnrf52
framework = arduino
board = nrf52_dk

question:

1. in varian.cpp   g_ADigitalPinMap

Why use a messy array to represent pins? And there are some missing pins, such as P0.0   P1.0~P1.15. It would be more convenient to use sequential numbers directly, such as 0=P0.0,     5=P0.5,   32=P1.0,   33=P1.1

2. in wiring_digital.c

void digitalWrite( uint32_t ulPin, uint32_t ulVal )
{
  if (ulPin >= PINS_COUNT) {  //PINS_COUNT==26
    return;
  }
 
it mens cnn't use P0.30    P1.0~P1.15   ?  how to do now
 
 
thanks
Best regards
Parents
  • Hello,

    Some of the GPIOs are reserved for specific functions (for example: crystal, NFC, UART, external memory, buttons, LEDs) and are not available for general use on the DK.

    For example, P0.00 and P0.01 are used for the 32.768 kHz crystal and are not available on the connectors, and P0.09 and P0.10 are used for NFC by default. P0.11–P0.16 and P0.24–P0.25 are used for buttons and LEDs, and other pins are used for external memory or not routed to headers at all. This is why the mapping is not simply 0=P0.0, 5=P0.5, 32=P1.0, etc. The array only includes pins that are available and safe to use as general-purpose I/O on the DK hardware, which is why some pins are skipped or missing in the mapping. 

    You can read this documentation about Connector interface connector interface.

    The digitalWrite function checks if the pin number is less than PINS_COUNT ( 26 in your code). The pins which are not included in this mapping by default you cannot access them using standard Arduino functions unless you modify the core or the pin mapping array.

    From the following table 

    I can see P0.30 is included in the analog pin mapping for the nRF52840 DK and should be accessible as analog input A4 when using the Arduino framework on this board. If you are unable to access P0.30, you may need to check or modify the pin mapping array in your Arduino core to ensure it is included. 

    So, I think the limitation is not due to the hardware, but rather the software mapping in the Arduino core. 

Reply
  • Hello,

    Some of the GPIOs are reserved for specific functions (for example: crystal, NFC, UART, external memory, buttons, LEDs) and are not available for general use on the DK.

    For example, P0.00 and P0.01 are used for the 32.768 kHz crystal and are not available on the connectors, and P0.09 and P0.10 are used for NFC by default. P0.11–P0.16 and P0.24–P0.25 are used for buttons and LEDs, and other pins are used for external memory or not routed to headers at all. This is why the mapping is not simply 0=P0.0, 5=P0.5, 32=P1.0, etc. The array only includes pins that are available and safe to use as general-purpose I/O on the DK hardware, which is why some pins are skipped or missing in the mapping. 

    You can read this documentation about Connector interface connector interface.

    The digitalWrite function checks if the pin number is less than PINS_COUNT ( 26 in your code). The pins which are not included in this mapping by default you cannot access them using standard Arduino functions unless you modify the core or the pin mapping array.

    From the following table 

    I can see P0.30 is included in the analog pin mapping for the nRF52840 DK and should be accessible as analog input A4 when using the Arduino framework on this board. If you are unable to access P0.30, you may need to check or modify the pin mapping array in your Arduino core to ensure it is included. 

    So, I think the limitation is not due to the hardware, but rather the software mapping in the Arduino core. 

Children
No Data
Related