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

NRFX_UARTE nrf52832 not receiving all bytes

Dear Nordic fellows,

I have a Rigado BMD-350 that can transmit correctly bytes to another device via UARTE, but who cannot receive data correctly.

I'm using SDK15.3.0, softdevice 6.1.1.

For debugging,  I disabled all the bluetooth stack, and I initialized only the UART module like this

void my_uarte_init()
{
  nrfx_uarte_config_t uart_conf;
  memset(&uart_conf,0,sizeof(uart_conf));
  uart_conf.baudrate           = NRF_UARTE_BAUDRATE_115200;//p_init->serial.baud;
  uart_conf.hwfc               = NRF_UARTE_HWFC_DISABLED;//p_init->serial.hwfc;
  uart_conf.interrupt_priority = APP_TIMER_CONFIG_IRQ_PRIORITY; // 7 
  uart_conf.p_context          = 0 ; //initialized by the nrfx init function
  uart_conf.parity             = NRF_UARTE_PARITY_EXCLUDED;//p_init->serial.parity;
  uart_conf.pselcts            = PIN_NOT_CONNECTED; //NOT_CONNECTED
  uart_conf.pselrts            = PIN_NOT_CONNECTED;
  uart_conf.pselrxd            = RX_PIN_NUMBER; //8
  uart_conf.pseltxd            = TX_PIN_NUMBER; //6

  m_uart_instance = (nrfx_uarte_t)NRFX_UARTE_INSTANCE(0); //initialize UARTE0. the cast is safe to do
  err_code = nrfx_uarte_init(&m_uart_instance,&uart_conf,handle_nrfx_event);

  memset(m_tmp_buffer,0,UART_RX_BUF_SIZE);
  memset(debug_buffer,0,UART_RX_BUF_SIZE);
  debug_buffer_idx=0;
  m_tmp_buf_idx=0;
  m_tmp_buffer[0]=0;
  nrfx_uarte_rx(&m_uart_instance,m_tmp_buffer,1);
}

Buffer are 250bytes long each.

For the debugging purposes, I receive only one byte per NRFX_UARTE_EVT_ENDRX event.

There are two problems:

  • the number of bytes received is not correct
  • Some messages are not received

This is the event handling function:

static void handle_nrfx_event(nrfx_uarte_event_t const *p_event ,void* p_context)
{
  my_uart_evt_t event;// set the status to "Processing command"
  switch(p_event->type)
  {
    case NRFX_UARTE_EVT_ERROR:
      event.type = UART_EVT_UART_ERROR;
      event.data.uart_err.err_code = p_event->data.error.error_mask;
      event.data.uart_err.data     = p_event->data.error.rxtx.p_data;
      event.data.uart_err.length    = p_event->data.error.rxtx.bytes;
      handler(&event);
      break;
    case NRFX_UARTE_EVT_TX_DONE://NRFX_UARTE_EVT_TX_DONE:
      event.type   = UART_EVT_CMD_SENT;
      handler(&event);  
      break;
    case NRFX_UARTE_EVT_RX_DONE://NRFX_UARTE_EVT_RX_DONE:
      //DEBUG
      memcpy(&(debug_buffer[debug_buffer_idx]),p_event->data.rxtx.p_data,p_event->data.rxtx.bytes);
      debug_buffer_idx += p_event->data.rxtx.bytes;
      nrfx_uarte_rx(&m_uart_instance,m_tmp_buffer,1);
      return;
  }
}

When I test the function, sending 11 bytes ({0xb0,0xb0,0x0b,0x87,0x02,0x54,0x45,0x53,0x54,0x30,0x34}) at 115200 baud, 8N1 the debug_buffer, which only stores received data, is as follows: (I bolded the changes on the debug_buffer)

0B 87 02 54 45 53 54 30 ...

After the second transmission of the same 11 bytes, the debug_buffer becomes:

0B 87 02 54 45 53 54 30 34 B0 B0 ...

After the third:

0B 87 02 54 45 53 54 30 34 B0 B0 0B 87 02 54 45 53 54 30 ...

If, instead, I use nrfx_uarte_rx(&m_uart_instance, m_tmp_buffer,11) the device won't display the first reception of data, but at the second transfer the debug_buffer will be

0B 87 02 54 45 53 54 30 34 B0 B0 ...

which is all the data, but with the first two bytes at the end

I think I initialized the nrfx_uarte module correctly, and I think the minimal receiving procedure is correct.

Does anyone have a suggestion on what the problem could be?

Edit: added SDK

Parents Reply Children
No Data
Related