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

NRF9160KD UART configuration

hello all,

nRF Connect SDK: 1.5.0

nRF Connect Toolchain: 1.5.0

Desktop OS: Windows 10

I'm currently using nrf9160dk to explore the GNSS features. I take a look at the sample example of gps and was able to read NMEA protocols out of the VCOM via micro USB port. The next step I want to do is to route the output of NMEA code to the external UART pins which are P0.28, P0.29 for TX/RX.

I also read the thread, 

https://devzone.nordicsemi.com/f/nordic-q-a/45476/connecting-uart1-to-a-periph-on-nrf9160-dk?ReplySortBy=CreatedDate&ReplySortOrder=Ascending

So I try to configure the 

CONFIG_BOARD_PCA10090_UART0_ARDUINO=y

But I checked the dependency file in zephyr_config.c, it seems there is not such parameter anymore. I guess the name has been changed since the thread is 2-yr old. So what's the current parameter I should change?

in config.c file the params related to UART are

GEN_ABSOLUTE_SYM(CONFIG_UART_INTERRUPT_DRIVEN, 1);
GEN_ABSOLUTE_SYM(CONFIG_HAS_HW_NRF_UARTE0, 1);
GEN_ABSOLUTE_SYM(CONFIG_HAS_HW_NRF_UARTE1, 1);
GEN_ABSOLUTE_SYM(CONFIG_HAS_HW_NRF_UARTE2, 1);
GEN_ABSOLUTE_SYM(CONFIG_HAS_HW_NRF_UARTE3, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_CONSOLE_ON_DEV_NAME, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_CONSOLE, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_CONSOLE_INIT_PRIORITY, 60);
GEN_ABSOLUTE_SYM(CONFIG_UART_NRFX, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_0_NRF_UARTE, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_0_ENHANCED_POLL_OUT, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_0_INTERRUPT_DRIVEN, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_0_NRF_TX_BUFFER_SIZE, 32);
GEN_ABSOLUTE_SYM(CONFIG_UART_1_NRF_UARTE, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_1_INTERRUPT_DRIVEN, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_1_ENHANCED_POLL_OUT, 1);
GEN_ABSOLUTE_SYM(CONFIG_UART_1_NRF_TX_BUFFER_SIZE, 32);
GEN_ABSOLUTE_SYM(CONFIG_NRF_UARTE_PERIPHERAL, 1);

Another question I have is, to change the serial comm baudrate, what's the proper method to do that?

UPDATE on 2021/04/14:

It works for me now. After working with Matt (our local FAE), we found there is no such option to add following code to prj.conf file.

CONFIG_BOARD_PCA10090_UART0_ARDUINO=y

or

CONFIG_BOARD_NRF9160DK_UART0_ARDUINO=y
which is mentioned in this thread (2 years ago):

https://devzone.nordicsemi.com/f/nordic-q-a/45476/connecting-uart1-to-a-periph-on-nrf9160-dk?ReplySortBy=CreatedDate&ReplySortOrder=Ascending

The current option has been moved to device tree, so I added an overlay file to the zephyr sample project: hello_world and build it for nrf9160dk_nrf52840 board. It's a separate project for the nrf52840 chip on the nrf9160dk. here is a diagram from hardware user guide,

U7 is controlled by nRF52 chip and we only need the hardware setting from hello_world project. More specifically, from the hardware user manual,

we need to flip the 'nRF91_UART1_CTRL' pin which is controlled by nRF52 chip. 

After figure that out, all you need is an overlay file in the hello_world project folder, name it 'nrf9160dk_nrf52840.overlay' and put the following code into it,

&vcom0_pins_routing {
    compatible = "nordic,nrf9160dk-optional-routing";
    control-gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
    status = "okay";
};

I struggled with the syntax error at the beginning, I found the guideline is helpful, 

http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/dts/howtos.html#set-devicetree-overlays

  • Hello,

     

    So what's the current parameter I should change?

     It has changed name to CONFIG_BOARD_NRF9160DK_UART0_ARDUINO.

     

    Another question I have is, to change the serial comm baudrate, what's the proper method to do that?

    You can change the current-speed parameter in overlay

    &uart0 {
      status = "okay";
      current-speed = <115200>;
      tx-pin = <28>;
      rx-pin = <29>;
    };

  • No, it doesn't work. Here is the error I got.

    C:/ncs/v1.5.0/nrf/samples/nrf9160/gps_bc_test/prj.conf:13: warning: attempt to assign the value 'y' to the undefined symbol BOARD_NRF9160DK_UART0_ARDUINO

    It looks like there is no such param named CONFIG_BOARD_NRF9160DK_UART0_ARDUINO, which is kind of what I expected because I can't find it in the lib file, config.c. 

    With that been added to prj.conf file, the Segger Embedded Studio doesn't allow me to create the solution. I got 

    create_nordic_project.py failed (1) error

    here is the full log file. 

    Creating solution gps_bc_test.emProject
      C:/ncs/v1.5.0/toolchain/opt/bin/cmake.exe -GNinja -DBOARD=nrf9160dk_nrf9160ns -DBOARD_DIR=C:\ncs\v1.5.0\zephyr\boards\arm\nrf9160dk_nrf9160 -BC:\ncs\v1.5.0\nrf\samples\nrf9160\gps_bc_test\build_nrf9160dk_nrf9160ns -SC:\ncs\v1.5.0\nrf\samples\nrf9160\gps_bc_test -DNCS_TOOLCHAIN_VERSION=1.5.0 -DEXTRA_KCONFIG_TARGETS=menuconfig_ses -DEXTRA_KCONFIG_TARGET_COMMAND_FOR_menuconfig_ses=C:\ncs\v1.5.0\toolchain\segger_embedded_studio/html/configure_nordic_project_menuconfig.py
      -- Application: C:/ncs/v1.5.0/nrf/samples/nrf9160/gps_bc_test
      -- Zephyr version: 2.4.99 (C:/ncs/v1.5.0/zephyr)
      -- Found Python3: C:/ncs/v1.5.0/toolchain/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
      -- Found west (found suitable version "0.9.0", minimum required is "0.7.1")
      -- Board: nrf9160dk_nrf9160ns, Revision: 0.7.0
      -- Cache files will be written to: C:/ncs/v1.5.0/zephyr/.cache
      -- Found dtc: C:/ncs/v1.5.0/toolchain/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
      -- Found toolchain: gnuarmemb (C:/ncs/v1.5.0/toolchain/opt)
      -- Found BOARD.dts: C:/ncs/v1.5.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160ns.dts
      -- Generated zephyr.dts: C:/ncs/v1.5.0/nrf/samples/nrf9160/gps_bc_test/build_nrf9160dk_nrf9160ns/zephyr/zephyr.dts
      -- Generated devicetree_unfixed.h: C:/ncs/v1.5.0/nrf/samples/nrf9160/gps_bc_test/build_nrf9160dk_nrf9160ns/zephyr/include/generated/devicetree_unfixed.h
      -- Generated device_extern.h: C:/ncs/v1.5.0/nrf/samples/nrf9160/gps_bc_test/build_nrf9160dk_nrf9160ns/zephyr/include/generated/device_extern.h
      Parsing C:/ncs/v1.5.0/nrf/samples/nrf9160/gps_bc_test/Kconfig
      Loaded configuration 'C:/ncs/v1.5.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160ns_defconfig'
      Merged configuration 'C:/ncs/v1.5.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160ns_0_7_0.conf'
      Merged configuration 'C:/ncs/v1.5.0/nrf/samples/nrf9160/gps_bc_test/prj.conf'
      -- Configuring incomplete, errors occurred!
      Including boilerplate (Zephyr base): C:/ncs/v1.5.0/zephyr/cmake/app/boilerplate.cmake
      -- Using NCS Toolchain 1.5.0 for building. (C:/ncs/v1.5.0/toolchain/cmake)
      
      C:/ncs/v1.5.0/nrf/samples/nrf9160/gps_bc_test/prj.conf:13: warning: attempt to assign the value 'y' to the undefined symbol BOARD_NRF9160DK_UART0_ARDUINO
      
      error: Aborting due to Kconfig warnings
      
      CMake Error at C:/ncs/v1.5.0/zephyr/cmake/kconfig.cmake:262 (message):
        command failed with return code: 1
      Call Stack (most recent call first):
        C:/ncs/v1.5.0/zephyr/cmake/app/boilerplate.cmake:534 (include)
        C:/ncs/v1.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
        C:/ncs/v1.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
        CMakeLists.txt:9 (find_package)
      
      
      
      error: cmake failed
      create_nordic_project.py failed (1)

    how can I switch the output interface from USB to UART?

  • You need to build the board controller for nrf9160dk_nrf52840, and put the CONFIG_BOARD_NRF9160DK_UART0_ARDUINO=y in prj.conf. You can build the Zephyr "hello_world" sample.

  • I tried to build and flash the hello_world project from Zephyr/sample, but still no luck. Same error happened.

    C:/ncs/v1.5.0/zephyr/samples/hello_world/prj.conf:2: warning: attempt to assign the value 'y' to the undefined symbol BOARD_NRF9160DK_UART0_ARDUINO
    which component controls U7 (nRF91_UART1_CTRL)? I found limited info from 

    https://infocenter.nordicsemi.com/pdf/nRF9160_DK_HW_User_Guide_v1.0.pdf

    Full error log: 

    Creating solution hello_world.emProject
      C:/ncs/v1.5.0/toolchain/opt/bin/cmake.exe -GNinja -DBOARD=nrf9160dk_nrf52840 -DBOARD_DIR=C:\ncs\v1.5.0\zephyr\boards\arm\nrf9160dk_nrf52840 -BC:\ncs\v1.5.0\zephyr\samples\hello_world\build_nrf9160dk_nrf52840 -SC:\ncs\v1.5.0\zephyr\samples\hello_world -DNCS_TOOLCHAIN_VERSION=1.5.0 -DEXTRA_KCONFIG_TARGETS=menuconfig_ses -DEXTRA_KCONFIG_TARGET_COMMAND_FOR_menuconfig_ses=C:\ncs\v1.5.0\toolchain\segger_embedded_studio/html/configure_nordic_project_menuconfig.py
      -- Application: C:/ncs/v1.5.0/zephyr/samples/hello_world
      -- Zephyr version: 2.4.99 (C:/ncs/v1.5.0/zephyr)
      -- Found Python3: C:/ncs/v1.5.0/toolchain/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
      -- Found west (found suitable version "0.9.0", minimum required is "0.7.1")
      -- Board: nrf9160dk_nrf52840, Revision: 0.7.0
      -- Cache files will be written to: C:/ncs/v1.5.0/zephyr/.cache
      -- Found dtc: C:/ncs/v1.5.0/toolchain/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
      -- Found toolchain: gnuarmemb (C:/ncs/v1.5.0/toolchain/opt)
      -- Found BOARD.dts: C:/ncs/v1.5.0/zephyr/boards/arm/nrf9160dk_nrf52840/nrf9160dk_nrf52840.dts
      -- Generated zephyr.dts: C:/ncs/v1.5.0/zephyr/samples/hello_world/build_nrf9160dk_nrf52840/zephyr/zephyr.dts
      -- Generated devicetree_unfixed.h: C:/ncs/v1.5.0/zephyr/samples/hello_world/build_nrf9160dk_nrf52840/zephyr/include/generated/devicetree_unfixed.h
      -- Generated device_extern.h: C:/ncs/v1.5.0/zephyr/samples/hello_world/build_nrf9160dk_nrf52840/zephyr/include/generated/device_extern.h
      Parsing C:/ncs/v1.5.0/zephyr/Kconfig
      Loaded configuration 'C:/ncs/v1.5.0/zephyr/boards/arm/nrf9160dk_nrf52840/nrf9160dk_nrf52840_defconfig'
      Merged configuration 'C:/ncs/v1.5.0/zephyr/boards/arm/nrf9160dk_nrf52840/nrf9160dk_nrf52840_0_7_0.conf'
      Merged configuration 'C:/ncs/v1.5.0/zephyr/samples/hello_world/prj.conf'
      -- Configuring incomplete, errors occurred!
      Including boilerplate (Zephyr base): C:/ncs/v1.5.0/zephyr/cmake/app/boilerplate.cmake
      -- Using NCS Toolchain 1.5.0 for building. (C:/ncs/v1.5.0/toolchain/cmake)
      
      C:/ncs/v1.5.0/zephyr/samples/hello_world/prj.conf:2: warning: attempt to assign the value 'y' to the undefined symbol BOARD_NRF9160DK_UART0_ARDUINO
      
      error: Aborting due to Kconfig warnings
      
      CMake Error at C:/ncs/v1.5.0/zephyr/cmake/kconfig.cmake:262 (message):
        command failed with return code: 1
      Call Stack (most recent call first):
        C:/ncs/v1.5.0/zephyr/cmake/app/boilerplate.cmake:534 (include)
        C:/ncs/v1.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
        C:/ncs/v1.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
        CMakeLists.txt:5 (find_package)
      
      
      
      error: cmake failed
      create_nordic_project.py failed (1)

    Dev kit info:

  • I determined that this setting has been moved into the device tree. The setting for this can be seen in the nrf9160dk_52840.dts file and can be adjusted using a .overlay file to change the routing of the UART pins.

    vcom0_pins_routing: switch-nrf91-uart1 {
    compatible = "nordic,nrf9160dk-optional-routing";
    control-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>;
    status = "okay";
    };

Related