cancel
Showing results for 
Search instead for 
Did you mean: 

USART1 IRQ Issue

longchair
Associate III
Posted on December 15, 2012 at 20:00

Hello everyone,

I am experiencing something strange with the use of USART1 on a STM32F103 in order to decode some stream coming from a RC Receiver.

The behaviour I am getting is that once initialized, the first data will come to the IRQ of usart. the RXNE_FLAG will be set on the first char of the packet.

I will get another IRQ for the second char, but the RXNE flag will no be set at this time.

is this normal ? I thought i should get a flag set for every byte and that using USART_receive would clear the flag. am i wrong ?

I guess that as long as I am only setting the RXNE interrupt, the IRQ handler will only be called when there is a char, but i was wondering if this behaviour was normal and if not what could be a reason for this.

just to make sure I have put the code I am using here in case theer is something i do wrong.

http://pastebin.com/GBXFM6pN

Thanks for your comments :)

Lionel.
1 REPLY 1
Posted on December 15, 2012 at 20:48

Well you should get an interrupt per byte, and clear it byte reading the data register.

You might get framing or parity errors also. The M3 can potentially re-enter an interrupt routine if the last thing it does is clear an interrupt. Pipelining, and bus delays can cause the source to remain asserted briefly, but enough to tail-chain back in. If you do some actual work, like writing the character to a fifo/ring buffer that will be sufficiently consuming. The re-entry condition will appear not to have any interrupts set in the USART/whatever, and you can just exit without doing anything. If the interrupt continually re-enters, something is still asserted, check the interrupt/status registers for the potential cause.

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