Software dea when UART Idle recive data by interruptS

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Software dea when UART Idle recive data by interruptS

299 次查看
Wan
Contributor III

hello Nxp Engier

         Softwaret  Environment the RTD 4.0.0020240726 , IDE is S32DS 3.6.1 ,chipes is S32K310

        I encountered a situation where the interrupt function would go haywire after power-on when I used interrupt to receive serial port data. I found that when there are fewer tasks to handle in the interrupt, the system does not crash. However, when there are many tasks to handle in the interrupt, it is certain that the system will crash when receiving more than ten serial data packets upon power-on. Even after enabling DMA in the case of many interrupt handling tasks, the system can still receive a certain number of serial data packets before crashing. I hope to get some help.

Wan_0-1752423357275.png

  

  I provided a serial port receiving demo. I found that the LED blinking executed within the while(1) often gets stuck.

 

标记 (1)
0 项奖励
回复
1 回复

257 次查看
Julián_AragónM
NXP TechSupport
NXP TechSupport

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

 

0 项奖励
回复