Uart receive data

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

Uart receive data

843 Views
frank涛李
Contributor II

Hi NXP,

There is problem about the function "status_t UART_TransferReceiveNonBlocking(UART_Type *base, uart_handle_t *handle, uart_transfer_t *xfer, size_t *receivedBytes)" in driver fsl_uart.c of K66 MCU. If my xfer defined as follow "uart_transfer_t RvBuffer={DataBuffer,50U};",and my ring buffer size is 100 by call function "UART_TransferStartRingBuffer(UART0, &RingBufferHandle, rxRingBuffer, 100);"does it mean that only when there are 50 bytes data received in ring buffer,the callback function of UART would be called?

Second question: When there are different length UART data frame like 30,40,8 and so on during communication,can I use function "UART_TransferReceiveNonBlocking(UART_Type *base, uart_handle_t *handle, uart_transfer_t *xfer, size_t *receivedBytes)" and set the datasize of xfer to 40 ? In the other words,what I should do to use function UART_TransferReceiveNonBlocking( ) correctly in fixed data frame length communication and varying data frame communication ?

It's would be better to give example code and related detailed documents. Waiting online...

Best regards, Frank

0 Kudos
1 Reply

563 Views
jorge_a_vazquez
NXP Employee
NXP Employee
This question was answered internally.
Regarding your question,

Does it mean that only when there are 50 bytes data received in ring buffer,the callback function of UART would be called?
Yes, the size of the buffer you set in the Xfer would be the one that defines what trigger the callback, so if you define 50, then until you receive 50 data the callback will be triggered.

When there are different length UART data frame like 30,40,8 and so on during communication,can I use function "UART_TransferReceiveNonBlocking(UART_Type *base, uart_handle_t *handle, uart_transfer_t *xfer, size_t *receivedBytes)" and set the datasize of xfer to 40 ?
In the other words,what I should do to use function UART_TransferReceiveNonBlocking( ) correctly in fixed data frame length communication and varying data frame communication ?
Yes, you can use the API UART_TransferReceiveNonBlocking with different datasize in the xfer, so the callback will be triggered until you receive all the data you define, then you can define other datasize in xfer and call the API function again.
 
There is an example for ringbuffer in the sdk, it is named as UART_interrupt_rb_transfer, you can located under driver examples.
Best regards
Jorge Alcala
0 Kudos