Problem using three UART ports in nRF5340 (nRF Connect SDK)

According to this discussion, all the 4 UARTs are functional in nRF5340. I intend to use multiple UART ports, and I modified this exercise solution to do so. I was able to use UART0 and UART1 for printing to the serial terminal. The pins for UART0 and UART1 have already been defined in the nrf5340_cpuapp_common-pinctrl.dtsi file as:

UART0: 

Tx: 20, Rx: 22

UART1: 

Tx: 1, Rx: 0

However, no pins have been defined for UART2 and UART3. In order to use UART1 and UART2 (in addition to UART0), I made the following changes:

1. Added the following to nrf5340_cpuapp_common-pinctrl.dtsi:

	uart2_default: uart2_default {
		group1 {
			psels = <NRF_PSEL(UART_TX, 2, 26)>;
		};
		group2 {
			psels = <NRF_PSEL(UART_RX, 2, 27)>;
			bias-pull-up;
		};
	};

	uart2_sleep: uart2_sleep {
		group1 {
			psels = <NRF_PSEL(UART_TX, 2, 26)>,
				<NRF_PSEL(UART_RX, 2, 27)>;
			low-power-enable;
		};
	}; 

2. Added the following to nrf5340_cpuapp_common.dts:

//Added later
 &uart1 {
	status = "okay";
	current-speed = <115200>;
	pinctrl-0 = <&uart1_default>;
	pinctrl-1 = <&uart1_sleep>;
	pinctrl-names = "default", "sleep";
};

//Added later
 &uart2 {
	status = "okay";
	current-speed = <115200>;
	pinctrl-0 = <&uart2_default>;
	pinctrl-1 = <&uart2_sleep>;
	pinctrl-names = "default", "sleep";
}; 

The code runs fine with UART0 and UART1. With UART2, the code builds, but nothing gets printed to the terminal.

Question-1: Is the pin assignment for UART2 correct? 

Question-2: Will UART2 by default be used with J-link (which seems to be the case with UART0 and UART1)?

Question-3: If I need to connect an external module through UART1, shall I have to change the default pin assignment?

Question-4: The nRF5340 Hardware documentation states that

           For nRF5340 DK v1.0.0, a third virtual COM port routed to the P24 connector of the DK is supported. The pins are labeled RxD, TxD, CTS, and RTS.

Is UART2 using the third virtual COM Port? If yes, how do I define these four pins stated above in my code? (I can see them on the board)

(I just starting exploring UART around a day ago and hence apologize if the doubts are too basic!)

Thanks

Sukriti

Related