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

Custom Board based on nRF9160 + GPIO Pin Mapping problem

Hello, 
I'm trying to map custom PIN mapping on my prototype board, based on nRF9160 DK.

I had to remove the UART0 pins and map them for my purpose, but when I'm trying to configure the pins:

int LED_RED = 28;
int LED_GREEN = 30;

int initializeDiode1 = gpio_pin_configure(gpio_dev, LED_RED, GPIO_DIR_OUT);
int initializeDiode2 = gpio_pin_configure(gpio_dev, LED_GREEN, GPIO_DIR_OUT);

and set their state to HIGH

gpio_pin_write(gpio_dev, LED_RED, 1);
gpio_pin_write(gpio_dev, LED_GREEN, 1);

Only the PIN number 30 actually create Voltage on output, but not the 28th.

Can you help me with that?
Thank you

  • Hi Marcin,

    How much have you based it on the nRF91DK? 

    Please try to update the .overlay file for the spm as well for your application.

  • Pin 28 is being used as the RX pin for UART0 in the default Device Tree for the devkit.  This is configured at: /zephyr/boards/arm/nrf9160_pca10090/nrf9160_pca10090_common.dts

    &uart0 {
    	status = "ok";
    	current-speed = <115200>;
    	tx-pin = <29>;
    	rx-pin = <28>;
    	rts-pin = <27>;
    	cts-pin = <26>;
    };
    

    Unless you modify the zephyr,console chosen attribute to not use UART0 for the console, the default configuration will initialize pin 28 for the UART.  I don't think the chip handles pin-mux conflicts very well.


    Additionally the 52840 on the DK configures P0.28 to go to VCOM0 on the FTDI chip.  If you want to use P0.28 on one of the Arduino headers you will need to modify the 52840 config to do so.

  • Basically the microchipnRF9160-SICA
    BAA-E2.1.8
    11YP5

    Is connected with the GPS, SIM card on the custom PCB.
    I can properly upload the code, but I cannot access previously defined pins (28,29,30,31) and (7 and 8)

    Overlay file does not change the availability of pin 28 and 30.

    Can I get any assist with that?

  • I removed uart0 from chosen {} and even changed the pin definitions in _common.dts but still without any result. Any information about how to change the config properly?


  • I think my initial answer was wrong about how to fix this.  What you want is to assign different pins to UART0 through the Device Tree.  We can do that with an overlay file.

    Create a file called exactly "nrf9160_pca10090ns.overlay" in the project source directory (at the same level as CMakeLists.txt).  It must be exactly "<board name you configured project with>.overlay" because the zephyr build process uses the board name when searching this for file in your project directory.

    I know that is has found my overlay file because the initial west build will dump something like this to the console:

    -- Loading ~/zephyr/boards/arm/nrf9160_pca10090/nrf9160_pca10090ns.dts as base
    -- Overlaying ~/zephyr/dts/common/common.dts
    -- Overlaying ~/nrf/experiment/shell_test/nrf9160_pca10090ns.overlay

    In the .overlay file define this.  Pick which pins you want to move the UART to (I chose 10-13 because those just happen to be free pins on the dev-kit):

    &uart0 {
        tx-pin = <10>;
        rx-pin = <11>;
        rts-pin = <12>;
        cts-pin = <13>;
    };
    

    This will modify the pins that get assigned. 

    You can verify this by looking at the header file the device tree system generates at: "build/zephyr/include/generated/generated_dts_board_unfixed.h"

    Before adding the overlay I get these definitions (which match the default config):

    #define DT_NORDIC_NRF_UARTE_40008000_CTS_PIN		26
    #define DT_NORDIC_NRF_UARTE_40008000_RTS_PIN		27
    #define DT_NORDIC_NRF_UARTE_40008000_RX_PIN		28
    #define DT_NORDIC_NRF_UARTE_40008000_TX_PIN		29

    After adding the overlay I get these definitions:

    #define DT_NORDIC_NRF_UARTE_40008000_CTS_PIN		13
    #define DT_NORDIC_NRF_UARTE_40008000_RTS_PIN		12
    #define DT_NORDIC_NRF_UARTE_40008000_RX_PIN		11
    #define DT_NORDIC_NRF_UARTE_40008000_TX_PIN		10

Related