cancel
Showing results for 
Search instead for 
Did you mean: 

USART2 USART_GetITStatus not evaluated correctly

garzarolli
Associate II
Posted on September 26, 2010 at 16:48

USART2 USART_GetITStatus not evaluated correctly

5 REPLIES 5
garzarolli
Associate II
Posted on May 17, 2011 at 14:08

I use Ride7 as compiler for an STM32f103RE.

Attached you will find a complete example,which copies data from com1 to com2 and vice versa. When you set a Breakpoint in the USART2 IRQ handler you will see that USART_GetITStatus us not evakuated correcty. You can simply add this function in the

STM32F10x_StdPeriph_Lib_V3.1.2 template.

Posted on May 17, 2011 at 14:08

Looks to be Ok.  And IRQ's certainly work on USART[1..3]

Others have had problems with RESET being define as something non-zero. Try using != 0

What compiler are you using? What assembler code is being generated? Does the behaviour change if you are not debugging it? What is the value you the USART interrupt register when it enters the IRQ?

Can you post/attach a complete compilable example?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
greg_t
Associate II
Posted on May 17, 2011 at 14:08

I think you clear the flags by reading in the first if statement

but I am not sure

Posted on May 17, 2011 at 14:08

Will take a look when I get a chance.

Two quick observations, the first, more than one interrupt bit can be set at once. So the IF ELSE IF ELSE .. construct will only address the first it encounters. Second, observing that an interrupt is set does not clear the interrupt (ie IT_ORE, IT_LBD). If you do not perform an action to clear the interrupt the M3 will keep servicing the interrupt over-and-over.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
garzarolli
Associate II
Posted on May 17, 2011 at 14:08

Hello,

thank you for the hints.

The error was I didn't switch on the right clock:

RCC_APB2PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);