Skip to main content
henk2
Associate II
September 8, 2010
Question

ST32F103ZE USART not receiving?

  • September 8, 2010
  • 11 replies
  • 2125 views
Posted on September 08, 2010 at 13:08

ST32F103ZE USART not receiving?

    This topic has been closed for replies.

    11 replies

    Tesla DeLorean
    Guru
    May 17, 2011
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..