Re: NRF5 UART problem

Chettimada, Vinayak Kariappa

Hi Tiago,


I see you do not use h/w flow control or interrupt driven Rx. There is only 6 bytes FIFO in UART peripheral hence, if your implementation does not poll in fast, you will loose bytes.

Optimise your implementation or interrupt driven rx or h/w flowcontrol (last one being the safest option).





From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of Tiago Primini
Sent: Wednesday, December 20, 2017 12:10 AM
To: zephyr-devel@...
Subject: [Zephyr-devel] NRF5 UART problem


Hi everyone!


I am developing a firmware responsible to communicate with a sfm10R2 Wisol modem through a serial interface. The wisol shield is coupled in my nRF52832 nordic board. I am trying to get SigfoxID and PAC number from the modem using AT$I=id command, but there is something strange in some responses from modem: sometimes the response did not come with \r\n, for example, AT$I=10 and AT$I=11, which are the commands to get SigfoxID and PAC number respectively:

AT$I=10\r\n or AT$I=10\0\n

Response = A B C D E F F F F F F F ... (the first 6 digits are correct)

AT$I=11\r\n or AT$I=11\0\n

Response = 1 2 3 4 5 6 6 6 6 6 6 6 6 ... (again, the first 6 digits are correct)

Every time a response has more than 6 digits I could read just only the first 6. I could check this using all ids from AT$I=id and sending an invalid command (in this case the response is: E R R O R : : : : : : : : : : : : : ... (repeated ":" and there is no \r\n or \n or \n))

But executing some tests commands (short responses) I can get the correct response, for example:

AT\r\n or AT\0\n

Response = O K \r \n (it seems ok to me) 

Response = O K \r \n (it seems ok to me)


I am working on the serial configuration according to vendor requirements:

baud rate: 9600
data bits: 8
stop bits: 1
parity: none
flow control: false

I am not using interrupt driven and I am just writing and reading from UART_0 using simple commands: uart_poll_out and uart_poll_in, following there is the code I am using to test this application:

#include <zephyr.h>
#include <logging/sys_log.h>
#include <uart.h>

#define BUF_MAXSIZE 20

static void run_command(const char *command) {
  struct device *uart_dev = device_get_binding(CONFIG_UART_NRF5_NAME);

  int i;
  unsigned char sent_char;
  for (i = 0; i < strlen(command); i++) {
    sent_char = uart_poll_out(uart_dev, command[i]);

    if (sent_char != command[i]) {
      printk("expect send %c, actual sent %c\n", command[i], sent_char);
    } else {
      printk("sent char = %c\n", sent_char);
  sent_char = uart_poll_out(uart_dev, '\0');
  printk("sent char = %c\n", sent_char);
  sent_char = uart_poll_out(uart_dev, '\n');
  printk("sent char = %c\n", sent_char);

  unsigned char recv_char;

  int counter = 0;
  int counterMax = 10;
  while (uart_poll_in(uart_dev, &recv_char) == -1 && counter <= counterMax) {
    printk("waiting for new message[%02d/%02d]...\n", counter, counterMax);

  printk("%c ", recv_char);

  counter = 0;
  int x = 0;
  while (counter < BUF_MAXSIZE && x == 0) {
    int x = uart_poll_in(uart_dev, &recv_char);
    printk("%c ", recv_char);

void main(void)

  while (true) {



my prj.conf:






T. Primini

Join to automatically receive all group messages.