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

Cannot Receive data using UARTE with nRF52832

Hi everyone,

I'm now using nRF52832 to communicate with a device using UARTE.

In my application, i need to constantly send a control packet to the device, to keep it responsive to the control (~15ms between each data).

I don't want my application to be blocked, so i decide to use UARTE to do it automatically, and the TX part is working perfectly.

But the RX part is just not working at all, there are two issues:

1. With a valid waveform observed on the oscilloscope, the UARTE library returns framing error.

The RX buffer is filled with the data, while the RX byte count in i) p_event->data.error.rxtx.bytes and ii) p_event->data.rxtx.bytes are zero.

2. With a valid waveform observed on the oscilloscope, the UARTE library will not returns any event. The RX buffer receives nothing.

Here is the setting of the UARTE:

Here is how i start the RX task:

Here is the SDK config setting:

Please share your experience if you had the same issues to me, thank you!!

BR,

Jonathan

  • Hi Jonathan, 

    How big is the size of the rx buffer ? (rx_len) ? 
    Please be aware that even though there is variable rxtx.bytes, it's not possible to count the number of byte received. You only receive the number of bytes in your rx buffer (rx_len) when all bytes are received (event NRFX_UARTE_EVT_RX_DONE). This is due to the limitation of the UARTE hardware that there is no register keeping track of number of bytes currently arrived. 

    To solve this issue we have made a new and more advanced UART library. This library allow you to query the number of bytes received and also have a timeout if not all the bytes are arrived. Please have a look here.
    The example for it is at \examples\peripheral\libuarte

  • Hi Hung Bui,

    Thanks for your reply. I have defined a 64 bytes RX buffer, and the payload i need to receive is max. 30 bytes.

    The device only replies upon request from nRF52, so it is unlikely that the buffer will overflow.

    My problem is UARTE cannot receive data or have framing error with a valid UART waveform.

    How does libuarte help to solve the problem? Is there any bug fix or improvement compared to the old nrfx_uarte library?

    I did compare the libuarte & nrfx_uarte library.

    I found that in libuarte, it will initialize the events in the following sequence:

    In nrfx_uarte library, it initializes the events in this way:

    Is it the reason why i cannot receive data with UARTE?

    BR,

    Jonathan

  • The libuarte wouldn't solve the issue if it's at lower level (as I mentioned, it's more on the higher level where you can have a time out and can check how many bytes received). 


    I would suggest you to test with the simple uart example in \examples\peripheral\uart to check if it work. You can also test using the loop back option the provided in the code. 

  • Finally i found that the device would return with a BREAK before the data.

    I was focusing on the data part and overlook the BREAK in the waveform.

    After i handled the BREAK, the UARTE RX driver works perfectly!

    Thanks for your help.

  • Sounds great Jonathan. I would suggest to use a Logic analyzer when debugging UART (or other digital signals) it can analyze the protocol and most likely can catch the BREAK signal.