I want to use UART.
I checked the waveform and UART does not send data.
Here is my code. build and run are successful. Any help?
I connect UART RX and TX directly, which means p16 and p15 are connected by a jumper.
SEGGER IDE V4.16
nrf version: v0.4.0
<main.c>
#include <zephyr.h>
#include <misc/printk.h>
#include <uart.h>
#include <string.h>
#include <stdlib.h>
/* nRF9160 DK voltage = 3.0V
non sucure
board name: nrf9160_pca10090ns
nrf9160_pca10090ns.overlay */
static u8_t uart_buf[1024];
void uart_cb(struct device *x)
{
printk("uart_cb start!!\n");
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 uart_send_str(struct device *uart, char *send_str){
for (uint8_t i = 0; i < strlen(send_str); i++) {
uart_poll_out(uart, send_str[i]);
}
}
void main(void)
{
struct device *uart_wifi = device_get_binding("UART_1");
if (!uart_wifi) {
printk("error\r\n");
}
uart_irq_callback_set(uart_wifi, uart_cb);
uart_irq_rx_enable(uart_wifi);
char *Cmd = "AT\r\n";
printk("Start!\n");
while (1) {
printk("----loop start!----\n");
uart_send_str(uart_wifi, Cmd);
k_cpu_idle();
k_sleep(2000);
}
}
<prj.conf> CONFIG_SERIAL=y CONFIG_TRUSTED_EXECUTION_NONSECURE=y # CONFIG_BSD_LIBRARY_TRACE_ENABLED=n CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_UART_1_NRF_UARTE=y
<nrf9160_pca10090ns.overlay>
&uart1 {
status = "ok";
current-speed = <115200>;
tx-pin = <16>;
rx-pin = <15>;
};