2010-09-08 04:08 AM
ST32F103ZE USART not receiving?
2011-05-17 05:06 AM
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..
2011-05-17 05:06 AM
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