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

Can not I increase the size of the RX FIFO in the UART?

Hi.

I am developing the nRF52832 using the NRFX module of the SDK version 15.2.0.

We convert the UART signal to RS485 and communicate with RS485 to the outside.

RS485 communication method is Modbus rtu.

However, the problem is that when the READ_HOLDINGRESISTER command is requested by Modbus, the length of the request header exceeds 6 bytes of RX FIFO, and the data is truncated.

So I tried to receive 8 bytes, but the problem was that the data did not come in normally and the data was pushed in.

Please share your knowledge with the following sources.

 

#include "nrfx.h"
#include "nrfx_uart.h"

#define UART_ID    0

void main()
{
  nrfx_uart_t nrfx_uart = NRFX_UART_INSTANCE(UART_ID);
    nrfx_uart_config_t uart_config = 
  {
    .pseltxd            = 31,          
    .pselrxd            = 30,
    .pselcts            = 18,
    .pselrts            = 19,
    .p_context          = NULL,
    .hwfc               = NRF_UART_HWFC_DISABLED,
    .parity             = NRF_UART_PARITY_EXCLUDED,
    .baudrate           = NRF_UART_BAUDRATE_19200,
    .interrupt_priority = NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY
  };
  nrfx_err_t err = nrfx_uart_init(uart, &uart_config, NULL);
  pinMode(18, OUTPUT);
  pinMode(19, OUTPUT);

  digitalWrite(18, LOW);
  digitalWrite(19, LOW);

  nrfx_uart_rx_enable(&nrfx_uart);
  char ch[8];
  while(nrfx_uart_rx_ready(&nrfx_uart))
  {
    if(nrfx_uart_rx(&nrfx_uart, &ch[0], 8))
    {
      // print ch[]
    }
    else
    {
       nrfx_uart_errorsrc_get(&nrfx_uart);
    }
  }
}

In fact, the Modbus request header is 8 bytes, which is truncated to 6 bytes and read. If you read 8 bytes like the source above, the truncated byte will be read together. Can not you make the size of RX FIFO buffer larger in NRFX?

Related