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

nrf52840 uart issue

Hi Team. There is a connection between nrf52840 and esp32-wroom over uart. Uart settings: baud rate - 115200, data - 8bit,  HWFC - disable, Parity - excluded, stop bit - 0 (one stop bit). The problem is the following: while receiving data form esp32 i faced framing error (UARTE0->ERRORSRC = 0x04). What can cause the error and how to fix it? thanks

Parents
  • Framing errors are usually down to the receiving UART not being in synchronisation with the transmitting UART e.g. you start to check for data part way through the transmission of a data byte.

    An obvious thing to check are that both devices have their UARTs set to the same configuration and that the accuracy of the baud rates between the chips is acceptable.

    Another cause could be down to power modes of the devices, for example if your nRF52 is in a sleep state when transmission starts it may miss the start of the data. You could protect against this by using HWFC (or raising another gpio line prior to transmission to wake up the nRF52); you accepting framing errors to start with and transmit some sacrificial data to give the UARTs a chance to synchronise or not place the nRF52 into a very low power, deep sleep state.

  • thanks for reply, i'd like clarify some points. I use nrf52840-dk powered via USB and esp32 also powered via USB and connected to dev board using 3 wires (GND, TX, RX). Also, every 10ms the abort rx function called (in order to get to RX event). Is it save approach to use abort rx function to receive bytes?

Reply Children
  • Do you mean nrfx_uart_rx_abort?

    This function stops reception and returns data received at the point at which you've called it. So I wouldn't use that. It's normally one to use when you're shutting down communications.

    By far better to initialise the UART with an event handler and work with that rather than trying to poll for data. See nrfx_uart_init. The UART has a 6 byte internal buffer I believe. 

    Alternatively using some of the library code such as the serial library may prove beneficial to your architecture.

  • Regarding nrf_drv_uart_rx_abort() I use it in order to invoke NRF_DRV_UART_EVT_RX_DONE, i'm not using polling mode. And I figure out that esp32 config is the following baud rate = 115200, data bits = 8, stop bits = 1, and parity = N, and it says  in datasheet on nrf52840 (actual rate: 115108). Can this mismatch be a cause of framing error? Could you please, share an example how to use internal 6 byte buffer with event together? Because, as far as i understand in serial there is no event usage. Should I use p_event->data.rxtx.p_data[0] this approach? if so, will i get the hole buffer or only one byte?

Related