cancel
Showing results for 
Search instead for 
Did you mean: 

ST32F103ZE USART not receiving?

henk2
Associate II
Posted on September 08, 2010 at 13:08

ST32F103ZE USART not receiving?

11 REPLIES 11
Posted on May 17, 2011 at 14:06

 

I thought this was okay although a little expanded:

 

 

(A) = (USART1->CR2&~USART_CR2_STOP) will clear bits 12 and 13 in a copy of CR2 to make room for eventually setting both bits

 

 

(B) = (~USART_CR2_STOP_1&~USART_CR2_STOP_0) will also clear bits 12 and 13 (or set one or both if needed)

 

 

So USART1->CR2=(A) | (B) will clear bits 12 and 13 of CR2 meaning using 1 stopbit.

You shouldn't be ORing them, B ends up being something like 0xCFFF, and so does CR2. The net effect will be to break the USART.

Would strongly suggest tracing/stepping through with a JTAG Debugger, and looking at the register settings. Also I'd recommend using the library code, as you get less involved in the low level stuff and have more portable code. Or you can spend hours debugging your code..

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

Hi dive1,

Your program works!

I didn't read your last post until now starting to reply.

I compared your program to mine step by step.

It turned out only to be the stopbit setting.

Your conclusion is right.

What I replied about 'or-ing' is completely bullshit. (apollogize)

I changed the '|' by '&' and my program also runs.

Now I'v a headache because I hit myself with a hammer ten times on my head.

8 hours spend on such a STUPID failure. (@*@

mailto:&@^#*&%

#)

But beneath that I learned a lot about the clocks and sequences. (didn't know that the AF clock also should be enabled e.t.c.)

It was your program that helped me out.

so THANKS!

Henk