cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F2 RXNE flag FROM SR register clear without reason

haye
Associate II

Hello,

I am using UART4 from a STM32F2. I am sending a data then my RXNE FLAG from SR register go from 0 to 1. Without doing anything (no read of the DR register and no clearing manually the flag) it go back to 0 after some time. So I am missing the data in my IT routine.

I can't figure out why this happening. Could someone have an idea of what the issue could be ?

19 REPLIES 19
berendi
Principal

Do you watch the data register in the debugger? Unfortunately the UART peripheral has no way of knowing whether it was read by the program running on the MCU or by the debugger, and resets the flags in both cases.

What does the SR register contain, are there any other flags set?

Thank you for your answer. Yes I am checking the DR content and he is still with my data in but the flag still go to 0.

I have done a pointer to the adress directly to check the content. The content is still here and the flag is still going to zero. Does checking the content of the adres is equivalent to read it ?

TDK
Guru

> Does checking the content of the adres is equivalent to read it ?

Yes. Reading the register in any manner will reset the flag.

If you feel a post has answered your question, please click "Accept as Solution".

> Does checking the content of the adres is equivalent to read it ?

Yes. How could they be different?

haye
Associate II

Ok so if I not read it how could I know if the debugguer is doing it ? Because my original problem is in my application I am sending and receiving data and it's working well but from time to time I am missing the last byte and I think is due to this flag reset. But I can't figure why this could happen. I've test to just check the SR flag. Not doing action on DR and got same results

TDK
Guru

> Ok so if I not read it how could I know if the debugguer is doing it ?

The debugger only does what you ask it to do. Don't set watchpoints at this register. Don't view peripheral addresses.

Attach a logic analyzer on the traces and see what it's actually doing. Unlikely that the SR flag is not behaving properly. Check for UART error flags. Might be a timing issue.

If you feel a post has answered your question, please click "Accept as Solution".
haye
Associate II

Ok thanks this is what i've done in the second part no action to the DR register with the debugguer and none with my code also. And still this reset. The issue is I am using old IDE and don't get tracer for this one.Question is this problem could happenned with a bad configuration of the peripheral ? or any other reason ?

> I am using UART4 from a STM32F2. I am sending a data then my RXNE FLAG from SR register go from 0 to 1.

RXNE should be set when you *receive* data, not when *sending* it from the STM32 USART.

> Without doing anything (no read of the DR register and no clearing manually the flag) it go back to 0 after some time.

How do you know?

JW