Dear Nordic-Support Team,
Introduction
I have read through some sources (tickets and documentation) but I am still struggling to see the big picture of UART configuration in context of the nRF9160 DK. I noticed that even the terminology changes across different sources.
For example: in the tickets https://devzone.nordicsemi.com/f/nordic-q-a/47652/nrf9160-dk-uart-configuration and https://devzone.nordicsemi.com/f/nordic-q-a/68810/how-to-configue-an-external-uart-from-nrf9160-dk UART0 and UART1 are mentioned as primary and secondary UARTs which are forwarded through the virtual comports VCOM0 and VCOM2 respectively. However, Nordic's documentation (https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf91_dk%2FUG%2Fnrf91_DK%2Fboard_controller.html&anchor=board_controller and https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf91_dk%2FUG%2Fnrf91_DK%2Fhw_switches_uart_if.html) states, that UART1 and UART2 are forwarded though the virtual comports VCOM0 and VCOM2.
Thus, it would be great if you could help me to understand the big picture about how the different UARTs are set up per default and how they can be configured.
Device tree files
Because of the different terminology in the sources I have read, I had a look at the device tree files of the nRF9160, the nRF52840, and the nRF9160 DK in the Nordic Connect SDK.
The device tree file of the nRF9160 suggests that the nRF9160 chip has four UART interfaces. Is that correct? To get the terminology straight, I will call them UART_9160_[0,1,2,3] in the following.
# ncs\v1.9.1\zephyr\dts\arm\nordic\nrf9160_common.dtsi # [...] uart0: uart@8000 { compatible = "nordic,nrf-uarte"; reg = <0x8000 0x1000>; interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>; status = "disabled"; label = "UART_0"; }; uart1: uart@9000 { compatible = "nordic,nrf-uarte"; reg = <0x9000 0x1000>; interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>; status = "disabled"; label = "UART_1"; }; uart2: uart@a000 { compatible = "nordic,nrf-uarte"; reg = <0xa000 0x1000>; interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>; status = "disabled"; label = "UART_2"; }; uart3: uart@b000 { compatible = "nordic,nrf-uarte"; reg = <0xb000 0x1000>; interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>; status = "disabled"; label = "UART_3"; }; # [...]
The device tree file of the nRF52840 suggests that the nRF52840 chip has two UART interfaces. Is that correct? To get the terminology straight, I will call them UART_52840_[0,1] in the following.
# ncs\v1.9.1\zephyr\dts\arm\nordic\nrf52840.dtsi # [...] uart0: uart@40002000 { /* uart can be either UART or UARTE, for the user to pick */ /* compatible = "nordic,nrf-uarte" or "nordic,nrf-uart"; */ compatible = "nordic,nrf-uarte"; reg = <0x40002000 0x1000>; interrupts = <2 NRF_DEFAULT_IRQ_PRIORITY>; status = "disabled"; label = "UART_0"; }; # [...] uart1: uart@40028000 { compatible = "nordic,nrf-uarte"; reg = <0x40028000 0x1000>; interrupts = <40 NRF_DEFAULT_IRQ_PRIORITY>; status = "disabled"; label = "UART_1"; }; # [...]
The device tree file of the nRF9160 DK suggests that the nRF9160 DK exposes three UART interfaces to the user via the board's pins and/or via the virtual comports of the J-Link debug probe. Is that correct? To get the terminology straight, I will call them UART_DK_[0,1,2] in the following.
# ncs\v1.9.1\zephyr\boards\arm\nrf9160dk_nrf9160\nrf9160dk_nrf9160_common.dts # [...] &uart0 { status = "okay"; current-speed = <115200>; tx-pin = <29>; rx-pin = <28>; rx-pull-up; rts-pin = <27>; cts-pin = <26>; cts-pull-up; }; arduino_serial: &uart1 { status = "okay"; current-speed = <115200>; tx-pin = <1>; rx-pin = <0>; rx-pull-up; rts-pin = <14>; cts-pin = <15>; cts-pull-up; }; &uart2 { tx-pin = <24>; rx-pin = <23>; }; # [...]
General Questions
Assuming my assumptions about the device tree files are correct. Can you please answer the following questions?
- How do the different UART entities UART_9160_[0,1,2,3], UART_52840_[0,1], and UART_DK_[0,1,2] relate to each other?
- Why does the nRF9160 DK only expose three UART entities while the nRF9160 has four?
- How can I configure which UART entity is exposed through which pins of the nRF9160 DK
- Which UART entities are forwarded per default through the virtual comports?
- How can I configure which UART entities are forwarded through the virtual comports?
- How can I stop an UART entity from being forwarded through the virtual comports?
- Assuming that UART_DK_0 is the "primary" UART used for console and AT data traffic, would it mess with the nRF9160 DK if UART_DK_0 would additionally be used to communicate to other external devices?
Use case specific questions
I would like to use the UARTs of the nRF9160 DK in the following way:
- Attach sensors which communicate, with a certain serial protocol, to one UART via the pins of the nRF9160 DK. This UART should not be exposed via the virtual comports
- Attach a second class of sensors, which communicate with another serial protocol, to a second UART via the pins of the nRF9160 DK. This UART should not be exposed via the virtual comports
- Communicate (e. g. send commands to my user application on the nrf9160 from a PC) with the nRF9160 DK over a third UART which is only exposed via a virtual comport but not via the pins of the nRF9160 DK
Can you please provide some configuration suggestions for e. g. an overlay-file and/or prj.conf-file-settings for that use case of mine and mention caveats if there are any?
Final remarks
I am aware that answering this ticket might take some effort but I really like to get this topic straight. Thus, thank you allot for your help!