2025-09-16 1:02 AM
Hello everyone,
I'm working with the STM32WL30 and I'm trying to change the baud rate of the USART peripheral. However, I'm encountering some issues when I change the baud rate.
The function I wrote for changing the baud rate looks like this:
void changeBaudRate(uint16_t baudRate) {
// start USART reset
RCC->APB1RSTR |= RCC_APB1RSTR_USARTRST;
// disable interrupt
NVIC_DisableIRQ(USART1_IRQn);
// stop reset
RCC->APB1RSTR &= ~RCC_APB1RSTR_USARTRST;
// set BRR
USART1->BRR = 16000000 / baudRate;
// set CR1
USART1->CR1 = USART_CR1_RXNEIE_RXFNEIE | USART_CR1_TE | USART_CR1_RE | USART_CR1_UE;
// set IR prio
NVIC_SetPriority(USART1_IRQn, 1);
// enable IR
NVIC_EnableIRQ(USART1_IRQn);
}
When I changed the baud rate for the first time, everything works fine and I receive the messages. If I change the baudrate to another value, I won't receive messages on the new baud rate, but still with the previously configured baud rate. When I debug the baud rate change, I can see, that the BRR was changed to the new value, but somehow the peripheral still uses the previous BRR value.
I also used this logic with a STM32G0 controller without any problems.
Thank you in advance for your help!
Best regards,
Philipp