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.

Related