The S32K344 Lpuart transfer cannot receive data correctly when DMA enable

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

The S32K344 Lpuart transfer cannot receive data correctly when DMA enable

Jump to solution
302 Views
ZDDL
Contributor I
I use the Uart peripheral of S32K3 44 for RS485 communication, use Lpuart_Uart_Ip_AsyncSend() API can send data correctly, However, data cannot be received correctly using the DMA functionality, the received data is not what I want, it will lost some bytes.I don't know what is wrong with my project, hope someone can help me.
App can receive LPUART_UART_IP_EVENT_RX_FULL events, However, some bytes of the data in RxData buffer are missing.
Figure 1.png

Figure 1 is a screenshot of debugging, compared to serial port monitoring

Another question is that I have set LPUART_UART_IP_HAS_DMA_ENABLED = STD_ON, but when I trace into the API, the IDE shows that the macro definition is not available and the background is set to gray.
屏幕截图 2024-04-29 155422.png

Figure 2 

S32DS Platform version:3.5
RTD Build Version : S32K3_RTD_3_0_0_P07_D2306_ASR_REL_4_7_REV_0000_20230629
Attached is the Lpuart project I used.
here is my code:

 

/*==================================================================================================
 *   Project              : RTD AUTOSAR 4.7
 *   Platform             : CORTEXM
 *   Peripheral           : S32K3XX
 *   Dependencies         : none
 *
 *   Autosar Version      : 4.7.0
 *   Autosar Revision     : ASR_REL_4_7_REV_0000
 *   Autosar Conf.Variant :
 *   SW Version           : 3.0.0
 *   Build Version        : S32K3_RTD_3_0_0_D2303_ASR_REL_4_7_REV_0000_20230331
 *
 *   Copyright 2020 - 2023 NXP Semiconductors
 *
 *   NXP Confidential. This software is owned or controlled by NXP and may only be
 *   used strictly in accordance with the applicable license terms. By expressly
 *   accepting such terms or by downloading, installing, activating and/or otherwise
 *   using the software, you are agreeing that you have read, and that you agree to
 *   comply with and are bound by, such license terms. If you do not agree to be
 *   bound by the applicable license terms, then you may not retain, install,
 *   activate or otherwise use the software.
 ==================================================================================================*/

/**
 *   @file main.c
 *
 *   @addtogroup main_module main module documentation
 *   @{
 */

/* Including necessary configuration files. */
#include "Clock_Ip.h"
#include "CDD_Rm.h"
#include "Dma_Ip.h"
#include "Clock_Ip.h"
#include "Siul2_Port_Ip.h"
#include "Siul2_Dio_Ip.h"
#include "Lpuart_Uart_Ip.h"
#include "IntCtrl_Ip.h"
uint8_t RxData[128];
uint8_t TxData[128]={0x05, 0x04, 0x00, 0x00, 0x00, 0x02, 0x70, 0x4F};

void TestDelay(uint32 delay)
{
	static volatile uint32 DelayTimer = 0;
	while (DelayTimer < delay)
	{
		DelayTimer++;
	}
	DelayTimer = 0;
}

void UART2_Callback(const uint8 HwInstance,
		const Lpuart_Uart_Ip_EventType Event, void *UserData)
{
	(void) UserData;
	if (LPUART_UART_IP_INSTANCE_USING_2 == HwInstance)
	{
		switch (Event)
		{
		case LPUART_UART_IP_EVENT_RX_FULL:
			Lpuart_Uart_Ip_SetRxBuffer(LPUART_UART_IP_INSTANCE_USING_2,	RxData, 9);
			if(5==RxData[0])
			{
				RxData[9] = 0x55;
			}
			break;
		case LPUART_UART_IP_EVENT_TX_EMPTY:
			break;
		case LPUART_UART_IP_EVENT_END_TRANSFER:
			Siul2_Dio_Ip_WritePin(SEL_PORT, SEL_PIN, 0);
			break;
		case LPUART_UART_IP_EVENT_ERROR:
			break;
		}
	}
}

int main(void)
{
	/* Write your code here */
	Clock_Ip_Init(Clock_Ip_aClockConfig);

	Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
	Siul2_Dio_Ip_WritePin(EN_PORT,EN_PIN,1);

	Rm_Init(&Rm_Config);
	Dma_Ip_Init(&Dma_Ip_xDmaInitPB);

	Lpuart_Uart_Ip_Init(LPUART_UART_IP_INSTANCE_USING_2, &Lpuart_Uart_Ip_xHwConfigPB_2);
	Lpuart_Uart_Ip_AsyncReceive(LPUART_UART_IP_INSTANCE_USING_2, RxData, 9);

	IntCtrl_Ip_Init(&IntCtrlConfig_0);

	while (1)
	{
		TestDelay(4800000);
		Siul2_Dio_Ip_WritePin(SEL_PORT, SEL_PIN, 1);
		Lpuart_Uart_Ip_AsyncSend(LPUART_UART_IP_INSTANCE_USING_2, TxData, 8);

	}
	return 0;
}

/** @} */

 

 
0 Kudos
1 Solution
253 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @ZDDL,

I've downloaded your project and tested reception this way:

Julin_AragnM_0-1714515372534.png

I only modified the buffer size (to 8), and commented these lines from the Full Rx Event:

if(5==RxData[0])
{
	RxData[9] = 0x55;
}

As well as modifying the pins to PTA29 and PTA30 to test this in the S32K3X4-T172 EVB.

It seems reception is working properly, with or without the implemented delay:

Julin_AragnM_1-1714515488180.png

Best regards,
Julián

View solution in original post

6 Replies
281 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @ZDDL,

The MCL Integration Manual states that the Rx and Tx buffers should be allocated in the NON-CACHEABLE area.
 
image.png
 
Please try this fix in your project, as stated in this community post: UART sending by DMA has SBE error with S32K344 - NXP Community.
 
As for the macro definition, this is a visual bug that can be fixed by rebuilding the index:
 
Julin_AragnM_2-1714411104934.png

Best regards,
Julián.

0 Kudos
272 Views
ZDDL
Contributor I

@Julián_AragónM 

Thanks for your reply. I modified the Tx and Rx buffer definition according to your suggestion,

屏幕截图 2024-04-30 150504.png

but the  received data was still incorrect.

1.jpg

and, if i comment out this line("// TestDelay(4800000);"), it will send an additional unwanted frame before normal transmission, i don't know why.

 

0 Kudos
254 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @ZDDL,

I've downloaded your project and tested reception this way:

Julin_AragnM_0-1714515372534.png

I only modified the buffer size (to 8), and commented these lines from the Full Rx Event:

if(5==RxData[0])
{
	RxData[9] = 0x55;
}

As well as modifying the pins to PTA29 and PTA30 to test this in the S32K3X4-T172 EVB.

It seems reception is working properly, with or without the implemented delay:

Julin_AragnM_1-1714515488180.png

Best regards,
Julián

204 Views
ZDDL
Contributor I

@Julián_AragónM 

I used your modified project and only modified the port to fit my board, but the data I received was still wrong.

屏幕截图 2024-05-06 093514.png

When I was compiling the project, there was such a warning, I don't know if this is the root cause.

屏幕截图 2024-05-06 093232.png

0 Kudos
187 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @ZDDL,

Could this be a hardware issue with connections? 

Best regards,
Julián

0 Kudos
157 Views
ZDDL
Contributor I

You are right, it is a hardware issue, because I connected the logic analyzer on the TX and RX of the serial port, and the communication was normal after disconnecting the logic analyzer.

so,thanks a lot.

0 Kudos