How to change the uart baudrate dinamically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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);- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-01-31 1: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-01-31 8:44 AM
What do you mean, 'seems not to work'?
What, exactly, does happen?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-01-31 9: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);
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-02-01 12:50 PM
Ok I will try. Regards.
