This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Custom Board Pin Mapping

Hi Nordic Team!

After developing our firmware on the nRF52 HDK, we designed our custom board, and we're starting to write our custom board configuration file.

The main problem I have is that there's no official documentation on how to do this.

From what I gathered around the forum, is that I need to define my custom board file assigning each pin it's function, and then change the board flag on the make file (see here).

On the other hand, there's also the possibility of editing the nrf_drv_config.h file (see here).

Finally, certain pins have to be configured trough their register if they want to be used for GPIO or other peripheral drivers (see here and here).

So my question is, do I have to do all three? Is writing the custom_board enough?

As a reference here's the mapping needed for our board design:

  • GPIO Inputs: P0.00, P0.19, P0.20, P0.26, P0.29 and P0.30
  • GPIO Outputs: P0.13, P0.17, P0.18, P0.21, P0.31
  • Analog Inputs: AIN0, AIN1, AIN2, and AIN3
  • TWI: P0.11(SCL) and P0.12 (SDA)
  • UART: P0.28(TXD), P0.29(RXD), P.027(CTS) and P0.25(RTS)
  • SPI: P0.14(MOSI), P0.15 (MISO) and P0.16 (SCK)
  • PWM: P0.09

Our firmware is based on the nRF52832 using S132 SD and SDK ver 11.0 and we're using a GCC based environment.

Thanks in advance

  • Hi,

    You are not required to create a custom_board.h, but it is convenient to have all peripheral pin defines in a common file. This also makes it easier to switch between different boards, given that the rest of the source files is setup to use the common defines. There is a short description of how to create the file here, but I would recommend that you start with the pca10040.h board file if you have developed your firmware using the nRF52 DK.

    You can use the defined from custom_board.h in nrf_drv_config.h, for configuration of TWI, UART etc. As the NFC and reset pins have special functions, they have to be configured if you want to use these for general GPIO.

    Best regards,

    Jørgen

  • Jørgen.

    Thanks for your reply. I already created custom_board.h file according to my hardware design. I don't really understand how to map this in the nrf_drv_config.h . For example, in the pca_10040.h file, the SCL and SDA pins are define as pin number 27 and 26, yet in the nrf_drv_config.h they're define like this:

    #define TWI0_ENABLED 1
    
    #if (TWI0_ENABLED == 1)
    #define TWI0_USE_EASY_DMA 0
    
    #define TWI0_CONFIG_FREQUENCY    NRF_TWI_FREQ_100K
    #define TWI0_CONFIG_SCL          0
    #define TWI0_CONFIG_SDA          1
    #define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
    
    #define TWI0_INSTANCE_INDEX      0
    #endif
    

    Finally, how and where (custom_board.h or nrf_drv_config.h) do I configure the NFC and the nRESET pin (P0.21) to work as GPIO?

  • I forgot to write this on my previous comment.

    Since I only have one button, and all the LED's in my system are access trough a I2C I/O expander, I'm not planning in using the BSP. Is this OK or I need to define a BSP file for my custom board?

  • I understand that this can be a bit confusing, as there are a lot of defines and not always that easy to figure out which one is used. In the end, it is the pins configured in the initialization of the module that will be used. The pins defined in nrf_drv_config.h is the default pins used when initializing an interface without providing a configuration structure. The defines in the board header file can be used to set the defaut pins in nrf_drv_config.h or in any other source file, but you are not required to use these defines, you can just as well use pin numbers or defines set somewhere else in the code. Changing the defines in the board header does not have any effect unless they are used somewhere else in the code.

  • Jørgen.

    So If I create a custom_board.h file and for example, initialize a TWI interface (in my app) assigning the correspondent pin defined in the custom_board.h file, it will suffice?

    Also, and sorry to be this repetitive, how can I configure the NFC and the nRESET pin (P0.21) to work as GPIO?

    Thanks again.

Related