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,

     

    Could you try to add your .overlay configuration to the SPM?

    This is done by creating "../nrf/samples/nrf9160/spm/nrf9160_pca10090.overlay" and adding your &uart0 configuration.

    Note: you need to re-import the project in SES (or regenerate using CMake) to get the new overlay to take effect.

     

    Kind regards,

    Håkon

  • Hi,

    I tried to use UART 2. For that I changed overlay file in spm, nrf9160_pca10090ns.dts_compiled files for UART and SPM. While compiling there is error in uart_nrfx_uarte.c file. After starting SES it always modify nrf9160_pca10090ns.dts_compiled file for UART and come backs to previous values. I am not understanding how to use UART2 and how to assign external gpio pins to UART0 or UART1. For UART program there is no overlay file. 

Reply
  • Hi,

    I tried to use UART 2. For that I changed overlay file in spm, nrf9160_pca10090ns.dts_compiled files for UART and SPM. While compiling there is error in uart_nrfx_uarte.c file. After starting SES it always modify nrf9160_pca10090ns.dts_compiled file for UART and come backs to previous values. I am not understanding how to use UART2 and how to assign external gpio pins to UART0 or UART1. For UART program there is no overlay file. 

Children
No Data
Related