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

Problem with UART0 on nRF9160dk

Hello,

I am trying to do communication with external module using UART0. But when I connect pin P0.28 (RX of UART0) to external module to receive the data, there is no data on terminal. Same way I tried with UART1 and it worked. I connect pin P0.00 (RX of UART1) to external sensor and the data was on the terminal. So what is the probem with UART0? How can I see the sensor data. I tried to change UART0 pins to P0.10 and P0.11 as TX and RX respectively but still there is no data. For my project I want to use 2 UART, so it is necessary for me that other UART also works.

The code is

#include <zephyr.h>
#include <misc/printk.h>
#include <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 *uart = device_get_binding("UART_0");

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

Related