How to clear the UART Rx Buffer and reset the pointer to first array?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to clear the UART Rx Buffer and reset the pointer to first array?

3,479 Views
ericchan
Contributor I

Dear NXP Staff,

I am using LPC 54114 for software development. I try to modified the Example "usart_dma_transfer" to read in UART data array through UART_Rx pin,the data is stored in 40 bytes Rx buffer and all the 40 bytes data in the Rx buffer will sent out through UART Tx pin. (The length of data receive is shorter than 40 bytes.)

In my data Rx test (Please see attached pic.), the first data array is well received.
For second array, the data is accumulate after the first array.
After third array received, part of data is shift to next 40 bytes Rx Buffer.

My question is that , how can I clear all data in Rx Buffer after each data read and move the data pointer to the first byte of the data array, so that all new incoming data is located at the first byte of the Rx buffer?

Please advise if there are any command/instruction can do so.

My testing code is also attached for your reference.

Thanks,
Eric

0 Kudos
3 Replies

3,440 Views
marek-trmac
NXP Employee
NXP Employee

Hi Eric,

I'd recommend to use circular buffer. Circular buffer - Wikipedia 

Regards

Marek

Regards,
Marek
0 Kudos

3,407 Views
ericchan
Contributor I

Hi Marek,

I tried to use the circular buffer, But when I read the data I found some data is not ready in the RX buffer, only first half of data is ready. I have to delay sometime and the 2nd half of data is ready in the buffer . Is there any method or status flag to read and show the 2nd half of data is ready in the buffer?

(Please see the detail in the attached picture) 

Regards,

Eric

0 Kudos

3,375 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Eric,

I see you use DMA transfer, how about use DMA interrupt or flag,

after DMA finish transfer for tow data, use UART TX to send.

 

0 Kudos