S32K312 UART QUERY

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

S32K312 UART QUERY

2,486 Views
Neo1096
Contributor III

I need to receive a continuously sent uart data without idle time, with a baud rate of 115200. I consider using DMA and a 250us timer to do this. Each timer interrupts the query to receive a few bytes of data, and then reads the data out and places it in a overwritable circular buffer. (Or send out the read data for testing)

Theoretically, the 250us received data only contains 2 complete bytes. Sending too many bytes to the chip will cause an abnormal number of bytes read.

May I ask if there is a solution to achieve a stable read uart data stream without idle time? Thank you

0 Kudos
Reply
8 Replies

2,475 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Neo1096

According to your idea, isn't it just polling through the timer?

And the LPUART module of S32K312 already has a 4-word deep RX FIFO.

0 Kudos
Reply

2,473 Views
Neo1096
Contributor III
Yes, but using Lpuart_Uart_Ip_GetReceiveStatus to obtain the data length often leads to data loss. Is there a stable solution? Are there any examples?
0 Kudos
Reply

2,471 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Neo1096

"Yes, but using Lpuart_Uart_Ip_GetReceiveStatus to obtain the data length often leads to data loss"

Please provide your test method and test project, and I will help you check the possible causes of the problem.

0 Kudos
Reply

2,411 Views
Neo1096
Contributor III

Neo1096_1-1751425096743.png

How to configure the polling mode? Are there any routines that directly read data from the FIFO?

0 Kudos
Reply

2,405 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Neo1096

1.polling

Senlent_0-1751434689874.png

2. Or

Senlent_1-1751434761217.png

"

Lpuart_Uart_Ip_AsyncReceive()
while(Lpuart_Uart_Ip_GetReceiveStatus()==........)

"

 

3.Enable Interrupt

step1:Lpuart_Uart_Ip_AsyncReceive(0, Rx_Buffer, 1);//start receiver 1 byte

step2:In Uart interrupt handler

void Uart0_Callback(const uint8 HwInstance, const Lpuart_Uart_Ip_EventType Event, void *UserData)
{
	if(Event == LPUART_UART_IP_EVENT_RX_FULL)
	{
		Rx_BuffIndex++;
		if(Rx_BuffIndex >= Max_Rx_length)
		{
			Rx_BuffIndex = 0;
		}
		Lpuart_Uart_Ip_SetRxBuffer(0, &Rx_Buffer[Rx_BuffIndex], 1U);//start receive process again
	}

}

"

4.DMA+Idle,

This has been demonstrated in the previous answer.

 

The above are the four methods that can be thought of at present. As for how you want to process the received buffer data, this is an application problem and you need to find a way to solve it yourself.

0 Kudos
Reply

2,402 Views
Neo1096
Contributor III

Neo1096_0-1751442802452.png

I sent 10 0As. The first one failed to receive, while the following 9 variables were correct. What could be the reason for this?

How do I know how many variables I have received in the timer interrupt?

The timer interrupt is 7500/30,000000 = 250us, and the baud rate is 115200. Shouldn't it only receive 2 bytes?

0 Kudos
Reply

2,460 Views
Neo1096
Contributor III

The code is attached.

0 Kudos
Reply

2,463 Views
Neo1096
Contributor III

Neo1096_1-1751354634788.pngNeo1096_2-1751355756632.png

In the array, five numbers were received, but the baud rate is 115200 and the timer is 250us. Theoretically, only two complete bytes can be received, so the remainingBytes is 28. I will lose the last three data.

 

If the data sent at one time exceeds the preset array range and there is no time to update it, one piece of data will be lost. For example, in the figure, if 1 to 32 is sent, only 30 can be received, and Rx_Buffer[0] cannot be updated to 31

0 Kudos
Reply