SDK 2.1 UART Rx Overflow handling bug

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

SDK 2.1 UART Rx Overflow handling bug

2,809 次查看
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.

标签 (1)
6 回复数

2,302 次查看
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 项奖励
回复

2,302 次查看
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

2,302 次查看
NicolasP
Contributor IV

Hi,

Same problem with SDK 2.4.1 and K22FN51212

Best regards,

Nicolas

0 项奖励
回复

2,302 次查看
paulsandys
Contributor II

FRDM-KL25Z

0 项奖励
回复

2,302 次查看
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 项奖励
回复

2,302 次查看
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 项奖励
回复