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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

7,265件の閲覧回数
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 件の賞賛
返信
3 返答(返信)

7,226件の閲覧回数
marek-trmac
NXP Employee
NXP Employee

Hi Eric,

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

Regards

Marek

Regards,
Marek


NOTE: If you find the answer useful, kindly click on [ACCEPT AS SOLUTION] button
0 件の賞賛
返信

7,193件の閲覧回数
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 件の賞賛
返信

7,161件の閲覧回数
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 件の賞賛
返信