s32k144 LPUART

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

s32k144 LPUART

1,910 Views
VanNgo285
Contributor I

Hi,
I created a project which receive and send the string through LPUART with my laptop. The LPUART_DRV_GetReceiveStatus() function always return STATUS_BUSY after rerceived the first string from my laptop. What wrong in my code ? Can I clear the Rx receive flag ?

My code below,

 

void Debug_HardwareInitialize(void)
{
	/* Initialize LPUART instance */
	LPUART_DRV_Init(INST_LPUART_1, &lpUartState1, &lpuart_1_InitConfig1);
	/* Install the callback for rx events */
	LPUART_DRV_InstallRxCallback(INST_LPUART_1, Debug_RxCallback, NULL);

	DebugPrint("\rDebug Init Complete");
}

static void Debug_RxCallback(void *driverState, uart_event_t event, void *userData)
{
	/* Unused parameters */
	(void)driverState;
	(void)userData;

	/* Check the event type */
	if(event == UART_EVENT_RX_FULL)
	{
		/* The reception stops when newline is received or the buffer is full */
		if((Debug.RxBuffer[Debug.RxCounter] != '\0') && (Debug.RxBuffer[Debug.RxCounter] != CTRL_C) && (Debug.RxBuffer[Debug.RxCounter] != LF) && (Debug.RxBuffer[Debug.RxCounter] != CR) && (Debug.RxCounter != (DEBUG_BUFFER_LEN - 2U)))
		{
			/* Update the Buffer index and the RxBuffer */
			Debug.RxCounter++;
			LPUART_DRV_SetRxBuffer(INST_LPUART_1, (uint8_t *)&Debug.RxBuffer[Debug.RxCounter], 1U);
		}
	}
}

void Debug_Process(void)
{

	LPUART_DRV_ReceiveData(INST_LPUART_1, (uint8_t *)Debug.RxBuffer, 1U);
	/* Wait for transfer to be completed  */
	while(LPUART_DRV_GetReceiveStatus(INST_LPUART_1, &bytesRemaining) == STATUS_BUSY);
	status = LPUART_DRV_GetReceiveStatus(INST_LPUART_1, &bytesRemaining);
	if(status != STATUS_SUCCESS)
	{
		DebugPrint("\rCOM: An error occurred! The application will stop!");
	}
	Debug.RxCounter++;
	Debug.RxBuffer[Debug.RxCounter] = 0U;

	DebugPrint("\rCOM: %s", Debug.RxBuffer);

	Debug.RxCounter = 0;
	memset(Debug.RxBuffer, 0, sizeof(Debug.RxBuffer));
}

 

Anyone know how to fix this problem ? Please support me.

Thanks

 

0 Kudos
Reply
2 Replies

1,865 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @VanNgo285 

I saw that your code is based on the SDK example (lpuart_echo_s32k1xx). Have you tried to run this example? If yes, did you have the same behavior? 

 

B.R.

VaneB

0 Kudos
Reply

1,833 Views
VanNgo285
Contributor I
Hi,
I'll try it
Thank you very much
0 Kudos
Reply