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

UARTE: Why does the ENDRX value not change from zero once the MAXCNT number of bytes have been received?

Folks,

Been struggling for a couple of days with a comms issue that I assumed were at the other end of my system, but am starting to think it's at the nRF52 UART end and I do not understand how this thing works. I suspect I don't understand this bizarre UART correctly, so am hoping someone can tell me what I am am missing.

Normally with DMA (well on  other Cortex Mx devices) you'd set the target number of bytes to receive in one register, set it going and once the requisite number of bytes had been received you'd get a flag being set to tell you that reception was complete.

I have set up the UARTE reception to get X bytes of data by setting the RXD.MAXCNT register to be X.

Originally I started with three and then noticed the manual seemed to be saying it should be greater than four, so tried changing it to five (and senidng more bytes INTO the nRF), but it does not help at all.

If I poll the UART by doing this:

if (NRF_UARTE0->EVENTS_ENDRX != 0) 

{

// Stuff here

}

On the rare occasions it does enter the // Stuff here bit, the EVENTS_ENDRX is still 0 in the debugger! :-o

If I poll for activity simply on the EVENTS_RXDRDY I am 100% definitely getting all the data being sent into the nRF correctly. It is just the EVENTS_ENDRX just never gets set to anything other than zero.

What am I missing here? I am clearly totally misunderstanding something with this UART. Does the ENDRX not actually work? Is there a hardware bug with it? Or am I just expecting STM/Atmel/NXP type behaviour that doesn't happen with this device? Or am I just driving it incorrectly?

FWIW, my code for starting off a reception is:

void StartDMAReceiveFromExLRT(uint8_t *BufferStart)
{



    NRF_UARTE0->TASKS_STOPRX = 1; -<---- tried with or wothout this  
    NRF_UARTE0->RXD.MAXCNT = 5;
    NRF_UARTE0->RXD.PTR = (uint32_t)BufferStart;
    NRF_UARTE0->TASKS_STARTRX = 1;

}

As an aside, I actually just want to check for three bytes most of the time. Can I simply not do a DMA receive for only three bytes?

Many thanks.

  • DiBosco,

    I have run into the same issue that you describe. Your post has been very helpful to confirm what I have noticed.

    I totally agree with you that the design of the UARTE, with "Easy-DMA" is defective.

    What bothers me is not that there is a problem with the UARTE, but that Nordic does not document this behavior in the errata sheet or in the data sheet or some other logical place. It is up to us (the programmers) to waste enormous time and effort only to discover that things do not work as expected.

    Hopefully, Nordic will have some mercy on us and add examples, notes and limitations to the documentation.

    And now back to work with the UARTE and its "Easy-DMA" Disappointed

Related