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

Want to use UART 1 with nRF9160 DK to print output on the console from another MCU

I am unable to read any uart input when I configure UART1 with nRF9160DK.

Please let me know if anything is wrong in my code/config

main.c

/*

* 

*

* SPDX-License-Identifier: Apache-2.0

*/

#include <zephyr.h>
//#include <misc/printk.h>
//#include <logging/log.h>
#include <drivers/uart.h>

static u8_t uart_buf[1024];

void uart_cb(struct device *x)
{
	uart_irq_update(x);
	int data_length = 0;

	if (uart_irq_rx_ready(x)) 
        {
		
                data_length = uart_fifo_read(x, uart_buf, sizeof(uart_buf));
		uart_buf[data_length] = 0;
	}
	printk("%s", uart_buf);
}

void main(void)
{
	struct device *uart1 = device_get_binding("UART_1");

	uart_irq_callback_set(uart1, uart_cb);
	uart_irq_rx_enable(uart1);
	printk("UART1 loopback start!\n");
	while (1) {
		k_cpu_idle();
	}
}

nrf9160dk_nrf9160ns.overlay

/ {
	chosen {
		zephyr,bt-uart=&uart1;
	};
};
&uart1 {
compatible = "nordic,nrf-uarte";
	current-speed = <115200>;
	status = "okay";
	tx-pin = <00>;
	rx-pin = <01>;
	rts-pin = <0xFFFFFFFF>;
	cts-pin = <0xFFFFFFFF>;
};

prj.conf

CONFIG_SERIAL=y
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_BSD_LIBRARY_TRACE_ENABLED=n
CONFIG_MAIN_STACK_SIZE=4096

I cannot see any data on my console even after sending data continuously to the console. Please guide me through the problem. I am also attaching the folder.

I add the folder in : D:\Softwares\SDK\v1.3.0\nrf\samples\nrf9160\uart

Parents Reply Children
Related