UART receive faillure

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

UART receive faillure

2,339 Views
Hanchun
Contributor I

 

Hi NXP engineer, sometimes the UART receiving interrupted and the value of event is 0x03 in rxCallback function. What is the reason?   And I tried to initiate UART again, but failled

Hanchun_0-1682326200128.png

 

0 Kudos
17 Replies

1,980 Views
RachelGomez123
Contributor I

Hello! The event value of 0x03 in the rxCallback function usually indicates a framing error. This means that the received data has an incorrect start/stop bit or parity bit.

To address this issue, you may want to check the following:

Ensure that the baud rate setting on both the transmitting and receiving sides of the UART are the same. Mismatched baud rates can cause framing errors.
Make sure that the data format settings (start/stop bits, parity, etc.) are the same on both sides.
Check that the physical connection of the UART is secure and has no interference.
If you have already attempted to re-initiate the UART but have failed, it could be due to another issue such as incorrect initialization or configuration settings. I would recommend reviewing your code to see if there are any other issues that may be causing the UART to fail. Additionally, you may want to check the error logs or debugging information to see if there are any other clues to the cause of the failure.

 

Regards,

Rachel Gomez

0 Kudos

1,971 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @RachelGomez123,

If there was a framing error detected, you would find it in the lpuartState structure, becasue the LPUART has a flag for it.

Possible reasons for 0x3 status:

LPUART_RX_OVERRUN, LPUART_FRAME_ERR, LPUART_PARITY_ERR, LPUART_NOISE_DETECT

I agree, the bus must be measured using an oscilloscope to confirm a correct baudrate / format.

 

BR, Daniel

0 Kudos

2,326 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Hanchun,

The callback with UART_EVENT_ERROR is called from

lpuart_driver.c

LPUART_DRV_ErrIrqHandler()

Possible reasons: LPUART_RX_OVERRUN, LPUART_FRAME_ERR, LPUART_PARITY_ERR, LPUART_NOISE_DETECT

Can you place breakpoints at the lines where the callback is called?

 

Thank you,

BR, Daniel

0 Kudos

2,325 Views
Hanchun
Contributor I

Thanks for your reply!

 

I  have placed the breakpoint where I called this function. When the error occurred, the process enter into this function.

0 Kudos

2,318 Views
danielmartynek
NXP TechSupport
NXP TechSupport

What error do you get there?

 

Thanks,

BR, Daniel

0 Kudos

2,316 Views
Hanchun
Contributor I

the value of event is 0x03, I don't the further reason.

0 Kudos

2,313 Views
danielmartynek
NXP TechSupport
NXP TechSupport

For example, if LPUART_RX_OVERRUN occurs, STATUS_UART_RX_OVERRUN is stored in the lpuartState structure, and the rxCallback() with UART_EVENT_ERROR (0x3) is called.

danielmartynek_0-1682345911828.png

 

 

Thank you,

BR, Daniel

0 Kudos

2,302 Views
Hanchun
Contributor I

I have checked the reason is RX_OVERRUN, and there two questions that I want to confirm:

1. what is the further reason that course UART OVERRUN?

2. If LPUART_RX_OVERRUN occurs, is there a good solution to recover the communication?

0 Kudos

2,279 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Hanchun,

1.

The error (STAT[OR]) occurs when the software fails to prevent the receive data register from overflowing with data.

You could increase the interrupt priority level of the LPUART_RX interrupt, or increase the system clock frequency, or use the DMA.

2.

The data in the shift register are lost when STAT[OR] = 1.

Regarding the driver, please refer to the SDK documentation.

Righ-click on the LPAURT component:

danielmartynek_0-1682514657843.png

danielmartynek_1-1682514792026.png

 

There is no need to reinitialize the driver.

You can call another transfer function.

 

BR, Daniel

 

 

 

0 Kudos

2,261 Views
Hanchun
Contributor I

Hi @danielmartynek 

 

But the  LPUART_DRV_GetReceiveStatus() just can be used to monitor the status of reception.  If LPUART_RX_OVERRUN, the reception process will be interrupted. It can't recover by itself. How can I avoid this error occurs. 

 

 

Hanchun

0 Kudos

2,233 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @Hanchun,

The error means the data in the shift register are lost, the transfer is terminated with the error.

You can call another Receive() function.

As I said, you can avoid the issue by increasing the interrupt priority or by using DMA.

 

Regards,

Daniel

 

0 Kudos

2,085 Views
Hanchun
Contributor I

Hi @danielmartynek , I tried using DMA that is not effective to avoid this issue. My crystal oscillator is 8MHz, the baud rate is 460800. The period of communication is 200ms.  Is there any other solution to solve this issue from software?    The chip is S32K144

0 Kudos

2,073 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Hanchun,

Have you just tried setting the highest priority to the UART interrupt?

As already discussed, the overrun is rather simple, the SW for some reasons fails to read the RX FIFO in time. That is clearly an application issue.

Is the baudrate on the bus 460800 bps?

Have you measured that?

 

BR, Daniel

 

 

0 Kudos

2,031 Views
Hanchun
Contributor I

Hi @danielmartynek 

 

I tried by DMA. There was not the OVERRUN issue, but missed 1% of the receiving data. I set the baud rate to be 460800, but didn't measure that.

  

The time of testing duration: 9 hours

Baud rate: 460800 

Data transfer period: 200 ms

Data length: 32 bytes

Another device total TX data size: 142350

S32K144 total RX data size:  140853

 

What is the possible reason causing the loss of data?  I think the problem is very serious.

0 Kudos

2,025 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @Hanchun,

As I said, this is an application issue.

You need to read the LPUART or DMA error flags and evaluate it.

Also, you should monitor the bus externally.

 

BR, Daniel

0 Kudos

2,003 Views
Hanchun
Contributor I

Hi @danielmartynek 

Thanks for the explaining again.

There is not any error flag of DMA.

I used two external UART tool to monitor the bus, and found the data missing. 

0 Kudos

2,266 Views
Hanchun
Contributor I

Thanks for your reply, I will try these solutions that you provide.

 

Hanchun

0 Kudos