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

Serial UARTE Rx fails with continuous timeout error

Hi,

I have a custom board with nrf52840 with UARTE1 instance enabled for RS485 communication.

I have 2 boards on the same configuration and trying to send data to each other.

below is the UARTE instance used

NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uarte1_drv_config,
                      24, 25,
                      RTS_PIN_NUMBER, CTS_PIN_NUMBER,
                      NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
                      NRF_UART_BAUDRATE_115200,
                      UART_DEFAULT_CONFIG_IRQ_PRIORITY);

NRF_SERIAL_QUEUES_DEF(serial1_queues, SERIAL_FIFO_TX_SIZE, SERIAL_FIFO_RX_SIZE);
NRF_SERIAL_BUFFERS_DEF(serial1_buffs, SERIAL_BUFF_TX_SIZE, SERIAL_BUFF_RX_SIZE);
NRF_SERIAL_CONFIG_DEF(serial1_config, NRF_SERIAL_MODE_DMA,
                      &serial1_queues, &serial1_buffs, NULL, sleep_handler);
NRF_SERIAL_UART_DEF(serial1_uarte, 1);                      

Serial UARTE is initialized with the above configurations.

The problem is after sometimes randomly, the device gives me continuous timeout error when I try to read data.

But it is transmitting data I can confirm this because the other device is able to receive the data sent. 

Once it goes into this mode, the only way to come out is either a restart or a re-init of serial UARTE. If I re-init, it works for some more time and again goes back to this mode randomly.

could anyone please guide me in the right direction to fix this.

PS: I am also using a direction pin (pin no 40) which I CLEAR to Rx data and SET to Tx data.

Parents Reply Children
  • Hi,

    Yes I have the error NRF_SERIAL_EVENT_DRV_ERR. and checking on the error it seems to be 

    NRF_UARTE_ERROR_FRAMING_MASK error in the nrf_uarte_error_mask_t.
    I would like to know how to overcome this.
    As of now I am just doing de-init and init of the serial instance. this works fine for some more time, again it goes into this state. this is random again, sometimes 50s sometimes 2mins. Sometimes the re-init also doesn't solve it, I get the same error till I do 4-5 re-inits
  • This error mostly happens when there is inaccuracies between the clocks used between two UART devices. You can first try to understand why how much inaccurate clock you are using on your end or on the peer's end If the inaccuracy turned out to be on the nRF device clock, then it depends on the 16M clock used. If you are using an external crystal clock, I would check the spec of that crystal to see how much this clock can deviate than the required 16MHz.

    When it comes to how to handle the framing error, the easiest way is to reset the UART driver like what you already are doing. But the clocks will deviate again causing the frame error to happen soon in the future.

    You should first try to understand the cause of the framing error first. Study the clocks you are using and measure the clock drifts between your clock and the peer uart clock.

  • Hi,

    We are using the same hardware configuration in both devices, so I doubt there will be any clock deviation. Just want to know what else could be the reason for this?

    We are also using other interrupts for some sensors, could that also have any impact on this?

  • if you have XTAL HFCLK on both peer and this device, then there are times when RC HFCLK is on before your turn on the XTAL. I would like to understand more, if you enable the same clock on both ends before the first transaction is started? and also keep using the same clocks through ? I have not seen framing errors on UART if the clocks on both devices are exactly the same. Can you please shed more light on how and where you enable the HFCLK?

  • HFCLK

    Hi,

    We are using the internal clock for this communication. and the baud rates are set as per the code above.

    I am using nrf_serial_write() and nrf_serial_read() functions to write and read. I am not aware of the HFCLK you are mentioning. Could you please let me know where it needs to be set/configured?

Related