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

How to enable UART in nRF9160 DK?

I'm trying to configure UART, but it doesn't work. I really appreciate it if you help me.

here is a code.

/* main.c */

void main(void)
{
        printk("Hello, World!\r\n");
        uart_wifi = device_get_binding("UART_1");
        if (!uart_wifi) {
		    printk("error\r\n"); // error happens.
	    }
	...
}

/* nRF9160_pca10090.dts */

/dts-v1/;
#include <nordic/nrf9160_xxaa.dtsi>

{
	model = "Nordic PCA10090 Dev Kit";
	compatible = "nordic,pca10090-dk", "nordic,nrf9160-xxaa";

	chosen {
		zephyr,console = &uart0;
        zephyr,wifi-uart = &uart1;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
	};

	aliases {
		led0 = &led0;
		led1 = &led1;
		led2 = &led2;
		led3 = &led3;
		sw0 = &button2;
		sw1 = &button3;
		sw2 = &button0;
		sw3 = &button1;
	};
	
....

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

&uart1 {
	status = "ok";
	current-speed = <115200>;
	tx-pin = <1>;
	rx-pin = <0>;
	rts-pin = <14>;
	cts-pin = <15>;
};

....

/* nRF9160_pca10090.dts_complied */

/dts-v1/;

/ {
	#address-cells = < 0x01 >;
	#size-cells = < 0x01 >;
	model = "Nordic PCA10090 Dev Kit";
	compatible = "nordic,pca10090-dk", "nordic,nrf9160-xxaa";

	chosen {
		zephyr,console = "/soc/uart@40008000";
		zephyr,wifi-uart = "/soc/uart@40009000";
		zephyr,sram = "/memory@20020000";
		zephyr,flash = "/flash-controller@40039000/flash@0";
		zephyr,code-partition = "/flash-controller@40039000/flash@0/partitions/partition@40000";
	};

	aliases {
		nrf-rtc1 = "/soc/rtc@40015000";
		nrf-clock = "/soc/clock@40005000";
		nrf-power = "/soc/power@40005000";
		nvmc = "/soc/nvmc@40039000";
		uart-0 = "/soc/uart@40008000";
		uart-1 = "/soc/uart@40009000";
		uart-2 = "/soc/uart@4000a000";
		uart-3 = "/soc/uart@4000b000";
		.....
	};

	soc {
		#address-cells = < 0x01 >;
		#size-cells = < 0x01 >;
		compatible = "simple-bus";
		interrupt-parent = < 0x01 >;
		ranges;

		nvic: interrupt-controller@e000e100 {
			compatible = "arm,v8m-nvic";
			reg = < 0xe000e100 0xc00 >;
			interrupt-controller;
			#interrupt-cells = < 0x02 >;
			arm,num-irq-priority-bits = < 0x03 >;
			phandle = < 0x01 >;
		};
		
		...

		uart0: uart@40008000 {
			compatible = "nordic,nrf-uarte";
			reg = < 0x40008000 0x1000 >;
			interrupts = < 0x08 0x01 >;
			status = "ok";
			label = "UART_0";
			current-speed = < 0x1c200 >;
			tx-pin = < 0x1d >;
			rx-pin = < 0x1c >;
			rts-pin = < 0x1b >;
			cts-pin = < 0x1a >;
		};

		uart1: uart@40009000 {
			compatible = "nordic,nrf-uarte";
			reg = < 0x40009000 0x1000 >;
			interrupts = < 0x09 0x01 >;
			status = "ok";
			label = "UART_1";
			current-speed = < 0x1c200 >;
			tx-pin = < 0x01 >;
			rx-pin = < 0x00 >;
			rts-pin = < 0x0e >;
			cts-pin = < 0x0f >;
		};
		
		...
	};
	...
};

Parents Reply Children
No Data
Related