2018-01-30 12:53 PM
Hi. I need to change the uart baudrate dinamically.
I have tryied this but sems to not work. Have you got an example to show?
serial->Init.BaudRate= BaudRate;
serial->Init.WordLength = UART_WORDLENGTH_8B; serial->Init.StopBits = UART_STOPBITS_1; serial->Init.Parity = UART_PARITY_NONE; serial->Init.Mode = UART_MODE_TX_RX; serial->Init.HwFlowCtl = UART_HWCONTROL_NONE; serial->Init.OverSampling = UART_OVERSAMPLING_16; serial->Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; serial->AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; HAL_UART_Init(serial);2018-01-31 01:49 AM
Hi
Gottardello.Deni
,May I know the STM32 product you are using?
There are some STM32 series where USART automatic baud rate detection is supported and it depends on USART instance.
Have a look to
(STM32 USART automatic baud rate detection) for more details.-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2018-01-31 08:44 AM
What do you mean, 'seems not to work'?
What, exactly, does happen?
2018-01-31 09:32 AM
One must first make sure all data currently being transmitted is flushed.
You can then disable the USART, change the BRR, and then reenable the USART
There is significant opportunity for receive data loss, and you should clear framing, parity or overrun type errors that might be induced.
The HAL structures for USART should have global and long term scope
Changing the rate like this should be sufficient, you could DeInit or disable if it appears not to be.
serial->Init.BaudRate= DifferentBaudRate;
HAL_UART_Init(serial);
2018-02-01 12:50 PM
Ok I will try. Regards.