<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic S32K118 LPUART RX only one byte in S32K</title>
    <link>https://community.nxp.com/t5/S32K/S32K118-LPUART-RX-only-one-byte/m-p/2274134#M55855</link>
    <description>&lt;P&gt;I am trying to configure LPUART on S32K118 MCU.&lt;BR /&gt;&lt;BR /&gt;Sending works fine and I can consistently get TX_EMPTY callback followed by an END_TRANSFER callback.&lt;/P&gt;&lt;P&gt;Now I am also trying to receive an arbitrary amount of bytes with asinc_receive. I tried setting the RX_BUFFER size to 1, writing the byte to a buffer and then calling SetRxBuffer to increase it by one, but I could never receive more than one byte without ending up in the ERROR callback. I figured maybe setting the RX buffer is too slow at updating the buffer and therefore runs into error before next byte is received.&lt;BR /&gt;&lt;BR /&gt;I then tried to use IDLE detection, which once again worked for single bytes reception, but ran into the ERROR callback if more than one byte is sent to it again.&lt;BR /&gt;&lt;BR /&gt;I have incresed the IDLE line detection frame count to MAX, tried aborting and starting the receive at various locations in the code, but still end up in the error callback event.&lt;BR /&gt;&lt;BR /&gt;What could the issue be?&lt;BR /&gt;&lt;BR /&gt;I will provide the appropriate code snippets:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void LPUART1_handler(void){
	Lpuart_Uart_Ip_IrqHandler(UART_INST);
	return;
}

void LPUART_callback(const uint8 HwInstance, const Lpuart_Uart_Ip_EventType Event, const void *UserData){
	(void)HwInstance;
	(void)UserData;
	// Check hardware instance if using 2 UART instances
	switch (Event)
	{
		case LPUART_UART_IP_EVENT_RX_FULL:
			ASMV_KEYWORD("nop");
			// rb_push_byte(&amp;amp;ring_buffer, byte_buffer);
			// Lpuart_Uart_Ip_SetRxBuffer(UART_INST, &amp;amp;byte_buffer, 1U);
			break;
		case LPUART_UART_IP_EVENT_TX_EMPTY:
			ASMV_KEYWORD("nop");
			break;
		case LPUART_UART_IP_EVENT_END_TRANSFER:
			ASMV_KEYWORD("nop");
			//Gpio_Dio_Ip_WritePin(DEBUG_LED_PORT, DEBUG_LED_PIN, LED_ON);
			Lpuart_Uart_Ip_AsyncReceive(UART_INST, rx_buffer, 64U);
			break;
		case LPUART_UART_IP_EVENT_ERROR:
			ASMV_KEYWORD("nop");
			break;
		#if (LPUART_UART_IP_ENABLE_TIMEOUT_INTERRUPT == STD_ON)
		case LPUART_UART_IP_EVENT_IDLE_STATE:
			// ASMV_KEYWORD("nop");
			// TODO: Write contents of rx_buffer to ring buffer
			UART_status = Lpuart_Uart_Ip_GetReceiveStatus(UART_INST, &amp;amp;bytesLeft);

			uint32 received = 64U - bytesLeft;

			if (received &amp;gt; 0)
				rb_write(&amp;amp;ring_buffer, rx_buffer, received);

			// Lpuart_Uart_Ip_AsyncReceive(UART_INST, rx_buffer, 64U);
			break;
		#endif
		default:
			ASMV_KEYWORD("nop");
			break;
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;initialising:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Initialising UART with ring buffer
	rb_init(&amp;amp;ring_buffer, ring_data, RING_BUFFER_SIZE);

	Lpuart_Uart_Ip_Init(UART_INST, &amp;amp;Lpuart_Uart_Ip_xHwConfigPB_1 );	//BAUD 115200
	
	// Arming the receive buffer
	#if (LPUART_UART_IP_ENABLE_TIMEOUT_INTERRUPT == STD_ON)
	Lpuart_Uart_Ip_AsyncReceive(UART_INST, rx_buffer, RING_BUFFER_SIZE);
	#else
	Lpuart_Uart_Ip_AsyncReceive(UART_INST, &amp;amp;byte_buffer, 1U);
	#endif&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;main loop:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;for(;;)
    {
		// DO SMART STUFF
		if (rb_available(&amp;amp;ring_buffer) != 0){
			rb_consume(&amp;amp;ring_buffer, rb_available(&amp;amp;ring_buffer));
			Lpuart_Uart_Ip_AbortReceivingData(UART_INST);
		}
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jan 2026 10:00:57 GMT</pubDate>
    <dc:creator>HiddenSquid</dc:creator>
    <dc:date>2026-01-05T10:00:57Z</dc:date>
    <item>
      <title>S32K118 LPUART RX only one byte</title>
      <link>https://community.nxp.com/t5/S32K/S32K118-LPUART-RX-only-one-byte/m-p/2274134#M55855</link>
      <description>&lt;P&gt;I am trying to configure LPUART on S32K118 MCU.&lt;BR /&gt;&lt;BR /&gt;Sending works fine and I can consistently get TX_EMPTY callback followed by an END_TRANSFER callback.&lt;/P&gt;&lt;P&gt;Now I am also trying to receive an arbitrary amount of bytes with asinc_receive. I tried setting the RX_BUFFER size to 1, writing the byte to a buffer and then calling SetRxBuffer to increase it by one, but I could never receive more than one byte without ending up in the ERROR callback. I figured maybe setting the RX buffer is too slow at updating the buffer and therefore runs into error before next byte is received.&lt;BR /&gt;&lt;BR /&gt;I then tried to use IDLE detection, which once again worked for single bytes reception, but ran into the ERROR callback if more than one byte is sent to it again.&lt;BR /&gt;&lt;BR /&gt;I have incresed the IDLE line detection frame count to MAX, tried aborting and starting the receive at various locations in the code, but still end up in the error callback event.&lt;BR /&gt;&lt;BR /&gt;What could the issue be?&lt;BR /&gt;&lt;BR /&gt;I will provide the appropriate code snippets:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void LPUART1_handler(void){
	Lpuart_Uart_Ip_IrqHandler(UART_INST);
	return;
}

void LPUART_callback(const uint8 HwInstance, const Lpuart_Uart_Ip_EventType Event, const void *UserData){
	(void)HwInstance;
	(void)UserData;
	// Check hardware instance if using 2 UART instances
	switch (Event)
	{
		case LPUART_UART_IP_EVENT_RX_FULL:
			ASMV_KEYWORD("nop");
			// rb_push_byte(&amp;amp;ring_buffer, byte_buffer);
			// Lpuart_Uart_Ip_SetRxBuffer(UART_INST, &amp;amp;byte_buffer, 1U);
			break;
		case LPUART_UART_IP_EVENT_TX_EMPTY:
			ASMV_KEYWORD("nop");
			break;
		case LPUART_UART_IP_EVENT_END_TRANSFER:
			ASMV_KEYWORD("nop");
			//Gpio_Dio_Ip_WritePin(DEBUG_LED_PORT, DEBUG_LED_PIN, LED_ON);
			Lpuart_Uart_Ip_AsyncReceive(UART_INST, rx_buffer, 64U);
			break;
		case LPUART_UART_IP_EVENT_ERROR:
			ASMV_KEYWORD("nop");
			break;
		#if (LPUART_UART_IP_ENABLE_TIMEOUT_INTERRUPT == STD_ON)
		case LPUART_UART_IP_EVENT_IDLE_STATE:
			// ASMV_KEYWORD("nop");
			// TODO: Write contents of rx_buffer to ring buffer
			UART_status = Lpuart_Uart_Ip_GetReceiveStatus(UART_INST, &amp;amp;bytesLeft);

			uint32 received = 64U - bytesLeft;

			if (received &amp;gt; 0)
				rb_write(&amp;amp;ring_buffer, rx_buffer, received);

			// Lpuart_Uart_Ip_AsyncReceive(UART_INST, rx_buffer, 64U);
			break;
		#endif
		default:
			ASMV_KEYWORD("nop");
			break;
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;initialising:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Initialising UART with ring buffer
	rb_init(&amp;amp;ring_buffer, ring_data, RING_BUFFER_SIZE);

	Lpuart_Uart_Ip_Init(UART_INST, &amp;amp;Lpuart_Uart_Ip_xHwConfigPB_1 );	//BAUD 115200
	
	// Arming the receive buffer
	#if (LPUART_UART_IP_ENABLE_TIMEOUT_INTERRUPT == STD_ON)
	Lpuart_Uart_Ip_AsyncReceive(UART_INST, rx_buffer, RING_BUFFER_SIZE);
	#else
	Lpuart_Uart_Ip_AsyncReceive(UART_INST, &amp;amp;byte_buffer, 1U);
	#endif&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;main loop:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;for(;;)
    {
		// DO SMART STUFF
		if (rb_available(&amp;amp;ring_buffer) != 0){
			rb_consume(&amp;amp;ring_buffer, rb_available(&amp;amp;ring_buffer));
			Lpuart_Uart_Ip_AbortReceivingData(UART_INST);
		}
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2026 10:00:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K118-LPUART-RX-only-one-byte/m-p/2274134#M55855</guid>
      <dc:creator>HiddenSquid</dc:creator>
      <dc:date>2026-01-05T10:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: S32K118 LPUART RX only one byte</title>
      <link>https://community.nxp.com/t5/S32K/S32K118-LPUART-RX-only-one-byte/m-p/2289385#M55946</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;receiving byte by byte would work normally, just you need to advance rxbuffer using &lt;SPAN&gt;SetRxBuffer&amp;nbsp;&lt;/SPAN&gt;before new byte is received. From your code I see you commented it out, sometimes you call&amp;nbsp;&lt;SPAN&gt;Lpuart_Uart_Ip_AsyncReceive with 1 byte, then with 64. Also you Abort receiving at some place.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Simple example for &lt;SPAN&gt;single-byte mode&amp;nbsp;&lt;/SPAN&gt;is given on&amp;nbsp;&lt;A href="https://community.nxp.com/t5/S32K-Knowledge-Base/RTD600-IP-S32K312-EVB-Lpuart-interrupt-echo/ta-p/2141060," target="_blank"&gt;https://community.nxp.com/t5/S32K-Knowledge-Base/RTD600-IP-S32K312-EVB-Lpuart-interrupt-echo/ta-p/2141060,&lt;/A&gt;&amp;nbsp;so you can refer to it.&amp;nbsp;&lt;BR /&gt;Note RTD&amp;nbsp;&lt;SPAN&gt;does not differentiate between TX and RX end events directly, but you can use user flag as mentioned on&amp;nbsp;&lt;A href="https://community.nxp.com/t5/S32K/S32K3-RTD-5-0-0-LPUART-Distinguishing-between-TX-and-RX-when-end/m-p/2073417/highlight/true#M47446" target="_blank"&gt;https://community.nxp.com/t5/S32K/S32K3-RTD-5-0-0-LPUART-Distinguishing-between-TX-and-RX-when-end/m-p/2073417/highlight/true#M47446&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR, Petr&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2026 10:32:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K118-LPUART-RX-only-one-byte/m-p/2289385#M55946</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2026-01-07T10:32:26Z</dc:date>
    </item>
  </channel>
</rss>

