IMXRT1024 UART Get Receive and Send Byte Count

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

IMXRT1024 UART Get Receive and Send Byte Count

2,221 Views
Lukas_Frank
Senior Contributor I

Hi all, 

I am really stucked about how can I get receive or send count in data transfer. I have three question :

 

Q1 : How can I get send or receive data size on bus while I am using LPUART_WriteByte and LPUART_ReadByte? Like LPUART_TransferGetSendCount and LPUART_TransferGetReceiveCount?

Q2: I am not able to get receive count in LPUART hardware flow control example in SDK what is the correct usage of that? I am calling

  • int32_t count = 0;
  • LPUART_TransferGetReceiveCount(DEMO_LPUART,&g_lpuartHandle,&count);

lines after LPUART_TransferSendNonBlocking function.

Q3: In my case main purpose is detecting incoming byte count in LPUART Polling approach. Then I want to read bytes as many as detected count. How can I do that? I know RXCOUNT mask can help to me but I wonder about How can I catch or detect exact byte count that coming to the bus?

Q4: Why RXFIFOSIZE is always 0b001, so 4 word? I am debugging the transmission process in  a project that consist LPUART_TransferSendNonBlocking and LPUART_TransferReceiveNonBlocking, RXFIFOSIZE value in FIFO register.  I know there is a threshold in LPUART_Init. But why it is set up to 4word. Is that the upper limit for IMXRT1024 LPUART?

Thanks and Regards.

0 Kudos
Reply
7 Replies

2,202 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Lukas,

Maybe you can take a look to the LPUART_interrupt_transfer example. This example works with the FIFO size and waits until 8 bytes are received in the FIFO before send them out. You could use RX water mark as well to trigger interrupt when a certaing amount of bytes are received.

Best regards,

Felipe

0 Kudos
Reply

2,197 Views
Lukas_Frank
Senior Contributor I

Hi Dear @FelipeGarcia ,

 

I wish answer my questions seperatly to comphrend issue.

1-)I know it uses FIFO and 8 bytes but I am not interested waiting for 8 bytes before send them out. I am interested on how many bytes comes to my FIFO. I will evaluate it and action according to it. So fundamental issue is detecting incoming byte size! 
2-) Also in your RM it says FIFO can be 256 word but it is read only. What is the upper limit for FIFO? !

3-)Please let me know how to do that ? So which interrupt is firing for RXWATERMARK?

 

Thanks and Regards.

0 Kudos
Reply

2,181 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Lukas,

1) Do you mean you need to know the bytes you are going to receive before the MCU has received any? This is clearly not possible as you need to tell the MCU somehow how many bytes are going to be sent.

2) Could you please elaborate? You are correct, receive fifo can be 256 words but I am not sure what you mean by upper limit for FIFO.

3) Please find description in RDRF register of the reference manual.

Best regards,

Felipe

0 Kudos
Reply

2,166 Views
Lukas_Frank
Senior Contributor I

Hi @FelipeGarcia,

1- I just mean how to calculate it. No matter before or after transmission. Could you help me please?

2- I’m setting it to 256 with register assignment. However TX/RXCOUNT is not bigger than 4 when I watch it in debug. So, if the FIFO size can be 256 word why TX/RXCOUNT can’t be bigger than 4 while LPUART communication. It is representing number of datawords that are in the receive or transmit FIFO/buffer according to 44.6.1.13.4 in RM.

3-) Could you please help me about my other question about DMA? This is link :

EDMA Question Link: 

eDMA LPUART Question 

Thanks and Regards.

0 Kudos
Reply

2,139 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Lukas,

Maybe you can check lpuart_edma ring buffer example, this example copies received data to a buffer. If you check EXAMPLE_ReadRingBuffer function ringBufferIndex will tell you how many data you have received in the ring buffer. I think it will be a good starting point.

Best regards,

Felipe

0 Kudos
Reply

1,816 Views
snahmad
Contributor II

Are you saying using interrupt mode functions LPUART_TransferReceiveNonBlocking we cannot find how many bytes read/received?

 

Do we have to use DMA?

0 Kudos
Reply

2,162 Views
Lukas_Frank
Senior Contributor I

EDMA Question Link: 

 

eDMA LPUART Question 

0 Kudos
Reply