Hi @Wan
Keep in mind that example software is meant to be used as reference for implementing the different features, not as final applications, as some routines may be unoptimized. I can see you are using the SW workaround from this community post: Solved: S32K3_UART_IDLE_EVENT_BUG_RTD400 - NXP Community.
You can try setting a flag inside the callback and aborting and processing the received message in the main code, instead of doing all of that inside the handler.
You also mentioned that after POR, system crashes. Try adding a delay to make sure the UART module is initialized correctly before receiving messages.
For example, in callback:
void Uart_Callback(const uint8 HwInstance, const Lpuart_Uart_Ip_EventType Event, void *UserData)
{
if (HwInstance == UART_INSTANCE && Event == LPUART_UART_IP_EVENT_IDLE_STATE)
{
Actual_Rx_length = Max_Rx_length - Lpuart_Uart_Ip_apStateStructure->RxSize; /*get the actual received size*/
uart_data_ready = true;
}
}
And in main:
while (1)
{
if (uart_data_ready)
{
uart_data_ready = false;
Lpuart_Uart_Ip_AbortReceivingData(UART_INSTANCE);
Lpuart_Uart_Ip_SyncSend(UART_INSTANCE, Rx_Buffer, Actual_Rx_length,50000);
memset(Rx_Buffer, 0, sizeof(Rx_Buffer));
Lpuart_Uart_Ip_AsyncReceive(UART_INSTANCE, Rx_Buffer, Max_Rx_length);
}
}
Best regards,
Julián