2022-05-24 01:53 AM
I've followed some answers from a post here:
But still can't seem to get the baud rate to change. Has anyone had any luck trying to dynamically change the baud rate of the UART?
/****************************************************/
USART6 -> CR1 &= ~(USART_CR1_UE);
USART6 -> BRR = NEWVALUE;
USART6 -> CR1 |= USART_CR1_UE;
/****************************************************/
huart.Instance->BRR = UART_BRR_SAMPLING8(HAL_RCC_GetPCLK2Freq(), new_baudrate);
/****************************************************/
HAL_UART_DeInit(instance[bus].handle);
instance[bus].handle->Init.BaudRate = baud;
HAL_UART_Init(instance[bus].handle);
Solved! Go to Solution.
2022-05-30 07:02 AM
Here is a follow up and answer to the problem.
The issue was that The UART was part way through a interrupt transmission while I was changing the Baud rate. Having a static variable that keeps track of a message being sent has solved this issue.
2024-06-04 02:12 AM
Hi,
I meet the same problem as you, Have you change baud rate successful?
Thanks and brgs