How do I change the Baud rate of a UART/USART whilst running?
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);
