SDK 2.1 UART Rx Overflow handling bug

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

SDK 2.1 UART Rx Overflow handling bug

1,964 Views
paulsandys
Contributor II

I think there's a logical bug in fsl_uart.c

 

/* If RX overrun. */

if (UART_S1_OR_MASK & base->S1) {
/* Read base->D to clear overrun flag, otherwise the RX does not work. */
 while (base->S1 & UART_S1_RDRF_MASK) {
      (void) base->D;
 }

 

 

The "while (base->S1 & UART_S1_RDRF_MASK)" creates a problem when the routine gets preempted by another interrupt. The RDRF can be set again, causing the routine to eat up extra bytes and/or generate additional Rx OR interrupts. After removing the while loop and reading "(void) base->D;" exactly once, the problems go away.

Labels (1)
6 Replies

1,457 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Paul,

Which chip do you used?

I randomly check one SDK package (FRDM-K22),

it just read D once :

pastedImage_1.png

BR

Alice

0 Kudos
Reply

1,457 Views
biafra
Senior Contributor I

Hi Alice_Yang‌,

It's the same in the latest SDK for TWR-K65F180M (2.4.1 2018-09-14).

Many thanks

Biafra

1,457 Views
NicolasP
Contributor IV

Hi,

Same problem with SDK 2.4.1 and K22FN51212

Best regards,

Nicolas

0 Kudos
Reply

1,457 Views
paulsandys
Contributor II

FRDM-KL25Z

0 Kudos
Reply

1,457 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

Thanks for your sharing , I will report it to the SDK team.

And I recommend you can use the UART driver file of FRDM-KL26.

I also attached it for you.

Hope it helps

Alice

0 Kudos
Reply

1,457 Views
paulsandys
Contributor II

I've wrote my own IRQ handler.

It would be very useful if the UART async driver could callback after receiving "special" character specified in the xfer structure, similar to SPI. (I.E.  NewLine, CarriageReturn, NULL or whatever)

0 Kudos
Reply