Menu

#558 STM32 USARTv1: serial interrupt hang on overrun (and other) error

2.6.8
closed
None
Medium
2.6.7
True
2015-04-19
2015-02-27
No

I have found this bug during testing STM32F401 with HAL serial module on speed 2MBit from FTDI chip.
The reason of this bug, that on such speed I got a lot of overrun error and very quickly got ORE=1 with RXNE=0 (the same problem https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex%5Fmx%5Fstm32%2FUSART%20ORE%3D1%2C%20but%20RXNE%3D0&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=1574)

The dirty patch which fix this problem:

Index: os/hal/ports/STM32/LLD/USARTv1/serial_lld.c
===================================================================
--- os/hal/ports/STM32/LLD/USARTv1/serial_lld.c (revision 7702)
+++ os/hal/ports/STM32/LLD/USARTv1/serial_lld.c (working copy)
@@ -165,11 +165,13 @@

   /* Data available.*/
   osalSysLockFromISR();

-  while (sr & USART_SR_RXNE) {
+  while (sr & (USART_SR_RXNE | USART_SR_ORE | USART_SR_NE | USART_SR_FE  | USART_SR_PE)) {
     /* Error condition detection.*/
     if (sr & (USART_SR_ORE | USART_SR_NE | USART_SR_FE  | USART_SR_PE))
       set_error(sdp, sr);
-    sdIncomingDataI(sdp, u->DR);
+    uint8_t b = u->DR;
+    if (sr & USART_SR_RXNE)
+      sdIncomingDataI(sdp, b);
     sr = u->SR;
   }
   osalSysUnlockFromISR();

Discussion

  • Giovanni Di Sirio

    Hi,

    Thanks for the patch, fixed in both 2.6.8 and 3.0.0.

    Giovanni

     
  • Giovanni Di Sirio

    • assigned_to: Giovanni Di Sirio
    • Milestone: 3.0.0 --> 2.6.8
    • Fixed in Repository: False --> True
     
  • Giovanni Di Sirio

    • status: open --> closed
     

Log in to post a comment.

Auth0 Logo