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();
	}
}

Parents
  • Hi Jagruti,

    I am kind of facing a similar problem. For me even the UART1 isnt working. Can you share the details of the prj.cfg and overlay files of your working UART1?

  • Hello

    These are the prj.conf and nrf9160_pca10090ns.overlay files:

    prj.conf:

    CONFIG_SERIAL=y
    CONFIG_TRUSTED_EXECUTION_NONSECURE=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_UART_1_NRF_UARTE=y
    CONFIG_UART_0_NRF_UARTE=y
    CONFIG_UART_2_NRF_UARTE=y
    CONFIG_BSD_LIBRARY_TRACE_ENABLED=n

    nrf9160_pca10090ns.overlay:

    &uart0 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <16>;
    	rx-pin = <14>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };
    
    &uart1 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <1>;
    	rx-pin = <0>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };
    
    &uart2 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <10>;
    	rx-pin = <11>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };

    To use UART0, you need to change the pin configuartion in overlay file of SPM

    nrf9160_pca10090.overlay for SPM:

    &uart0 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <16>;
    	rx-pin = <14>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };

    Best Regards,

    Jagruti

Reply
  • Hello

    These are the prj.conf and nrf9160_pca10090ns.overlay files:

    prj.conf:

    CONFIG_SERIAL=y
    CONFIG_TRUSTED_EXECUTION_NONSECURE=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_UART_1_NRF_UARTE=y
    CONFIG_UART_0_NRF_UARTE=y
    CONFIG_UART_2_NRF_UARTE=y
    CONFIG_BSD_LIBRARY_TRACE_ENABLED=n

    nrf9160_pca10090ns.overlay:

    &uart0 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <16>;
    	rx-pin = <14>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };
    
    &uart1 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <1>;
    	rx-pin = <0>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };
    
    &uart2 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <10>;
    	rx-pin = <11>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };

    To use UART0, you need to change the pin configuartion in overlay file of SPM

    nrf9160_pca10090.overlay for SPM:

    &uart0 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <16>;
    	rx-pin = <14>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };

    Best Regards,

    Jagruti

Children
Related