Hi all,
I have no experience on Nordic products. I have struggled with this issue for several days. My goal is communication between nrf9160 and nrf52840 through UART. In order to provide it, my setup is below:
In nrf9160;
#include <zephyr.h> #include <sys/printk.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 *uart = device_get_binding("UART_2"); uart_irq_callback_set(uart, uart_cb); uart_irq_rx_enable(uart); printk("UART loopback start!\n"); while (1) { k_cpu_idle(); } }
-- In nrf9160_pca10090ns.overlay;
&uart2 { current-speed = <115200>; status = "okay"; tx-pin = <10>; rx-pin = <11>; rts-pin = <12>; cts-pin = <13>; };
In nrf52840, I'm using uart example of nrf SDK 16 which is located at /nRF5_SDK_16.0.0/examples/peripheral/uart
I just changed the following lines on this example:
... uint8_t cr = 66; //while (app_uart_get(&cr) != NRF_SUCCESS); while (app_uart_put(cr) != NRF_SUCCESS); ...
In this way, nrf52 sending the character of 'B' to nrf91. And, nrf91 is waiting on ready state.
The cable setup is also below.
Is there any idea about my mistake? Thanks a lot.