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

nRF9160 UART

Hello,

I tried to setup the UART example provided at this link: https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160

I open two COM ports, when I type data in one of the COM port it gets printed on the other one.
However, if I try to print the received letter/message I only get a 0 or 128 (in decimal). I do not get the correct string output.

What could be the issue? Thank you.

Kind regards
Corentin

Parents Reply
  • Sure. I also tried sending data from the nRF52840 to the nRF9160 through UART and the same thing happens, I only get 0 or 128 as data.

    In the main of the MQTT sample I added the following initialization for UART:

    struct device *uart = device_get_binding("UART_1");
    if (!uart) {
        printk("error\r\n"); // error happens.
    }
    
    uart_irq_callback_set(uart, uart_cb);
    uart_irq_rx_enable(uart);
    printk("UART loopback start!\n");

    The UART callback:

    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("data_length %d - ", data_length);
      printk("%d (", uart_buf[0]);
      printk("%s)\n", uart_buf);
    }

    The UART buffer:

    static u8_t uart_buf[1024];

    In the project config file I added:

    CONFIG_SERIAL=y
    CONFIG_UART_1_NRF_UARTE=y

    Thank you.

Children
Related