Skip to main content
Visitor II
June 4, 2024
Question

How to change baud rate of serial port uart in runtime stm32f4?

  • June 4, 2024
  • 2 replies
  • 3147 views

 

Hi everybody,

I use UART6 of STM32F437 and want to change baud rate between baud rate 115200, 460800 and 921600 in runtime

I've followed some answers from a post here:

https://stackoverflow.com/questions/57283327/how-to-change-the-uart-baud-rate-after-running-on-stm32-board

USART6 -> CR1 &= ~(USART_CR1_UE);

USART6 -> BRR = NEWVALUE;

USART6 -> CR1 |= USART_CR1_UE;

But still can't seem to get the baud rate to change. Has anyone change the baud rate of the UART successful?

/****************************************************/

Thanks and brgs 

    This topic has been closed for replies.

    2 replies

    Super User
    June 4, 2024

    Have you checked the Datasheet and/or Reference Manual ?

    https://www.st.com/en/microcontrollers-microprocessors/stm32f437ai.html#documentation

    (Product Page doesn't seem to be working for me at the moment)

    Super User
    June 4, 2024

    Rather than just UE, does it help if you (also) clear TE and/or RE for the change?

     

    sonminhAuthor
    Visitor II
    June 5, 2024

    Thanks for your reply

     

    Can you talk clearly? Do you have sample code to change baud rate uart runtime

    Graduate II
    June 5, 2024

    As @Andrew Neil said, try to disable TE & RE in CR1 before changing baud rate.

    From RM0090:

    30.6.3 Baud rate register (USART_BRR)
    Note: The baud counters stop counting if the TE or RE bits are disabled respectively.