cancel
Showing results for 
Search instead for 
Did you mean: 

Missing, ghost, unwanted Interrupts -USART2-

damien23
Associate II
Posted on May 27, 2010 at 16:20

Missing, ghost, unwanted Interrupts -USART2-

#ore-txe
4 REPLIES 4
John F.
Senior
Posted on May 17, 2011 at 13:52

The interrupt could be entered as a result of a usart overrun error (ORE: Overrun error). This bit is set by hardware when the word currently being received in the shift register is ready to be transferred into the RDR register while RXNE=1. An interrupt is generated if RXNEIE=1 in the USART_CR1 register. It is cleared by a software sequence (a read to the USART_SR register followed by a read to the USART_DR register).

if overrun, read status register first ...

  if(USART1->SR & USART_FLAG_ORE)

  {

    variable = (int8_t)(USART1->SR & (uint8_t)0xFF);  //read status

  }

  //then read data register ...

John F.

damien23
Associate II
Posted on May 17, 2011 at 13:52

I agree that an overrun can cause that kind of an interrupt.

But the first thing I do when entering this IT is read SR register (which is 0x80), and only TXE is activated.

Secondly, according STM32 ref manual, figure 259, ORE occurs only when EIE (error interrupt enable) is activated, but mine is 0 (CR3 = 0x0000)

damien23
Associate II
Posted on May 17, 2011 at 13:52

OK, found.

Big Nerd mistake...

I had another interrupt (timered) that desactivated this USART2 instead of USART3.

Too much communication lines on this controller !!!

Posted on May 17, 2011 at 13:52

You need to clear all the interrupts you detect. If you don't clear the IT bit the interrupt will keep re-entering.

There are also perhaps race conditions where one interrupt occurs, and a second occurs as you service the first. While you service the first you detect/clear the second. It might be possible to enter a second time to find all interrupts pending are clear.

The biggest cause however, of interrupt crap storms on the STM32 is the failure to clear a pending interrupt before leaving. The tail chaining will basically prevent any user/foreground code from running.

In overrun/underrun conditions you must read the DR to clear the USART

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..