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

nrf9160 DK UART_1

Hi, 

I am trying to read serial data via UART_1 with v1.2.0 SDK. According to dts-File UART_1 is configured with pin 0 and 1 on the devKit. 

I added 

CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_1_NRF_UARTE=y
CONFIG_BSD_LIBRARY_TRACE_ENABLED=y 

to the prj.conf. 

Unfortunately, I do not receive any data on UART_1. I already tried to use it with a system workqueue but it does not receive anything either. (I ensured that my transmitter is working)

My Code is (similar to the sample from rallare): 

void uart_cb(struct device *x){
LOG_INF("UART Data recevied");

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

LOG_INF("%s",uart_buf);

}


int uartComm_init(struct k_work_q *work_q)
{

int error = 0;

k_work_q_start(&uart_work_q, uart_stack_area, K_THREAD_STACK_SIZEOF(uart_stack_area), UART_PRIO);

LOG_INF("Init UART");

//UART binding
struct device *uart = device_get_binding("UART_1");
if (!uart)
LOG_ERR("Failed to get UART1");

uart_irq_callback_set(uart, uart_cb);
if(error) LOG_ERR("Error setting UART Callback");

uart_irq_rx_enable(uart);
if(error) LOG_ERR("Error enabling UART Interrupt");
else
LOG_INF("End init UART.");


return error;
}

Init UART is properly called:

Any ideas? 

Kind regards and thanks in advance, 

Manuel

Parents Reply Children
No Data
Related