2019-02-26 07:18 PM
I am working on STM32L462CE MCU and my requirement is to change the baudrate of UART at run-time. So, how I do that?. Can you please give me the solution for this. First set to 9600bps, after 921600 and at last 115200.
2019-02-26 07:43 PM
First make sure all data currently being transmitted is completed i.e checking status of TXE and TC
You can then disable the USART, change the BRR, and then reenable the USART
2019-02-26 08:26 PM
Thanks for your reply !!! @Community member .
Can you give me one sample code for that?
2019-02-26 09:25 PM
I think this was covered within the last month.
Spin on TC/TXE to confirm pending data has transited. ie ready to take more, the previous stuff completed.
Call HAL_UART_Init() with the an updated baud rate field.
Not super difficult. Couple of minutes effort.
2019-02-26 09:58 PM
I tested it and give me the status zero.
MX_UART4_Init_9600(); // baudrate 9600
G3_Baudrate_set(); // send cmd to other chip
uint8_t status = LL_USART_IsActiveFlag_TC(&huart4);
printf("stauts = %x\r\n",status);
HAL_UART_DeInit(&huart4); //uart de-init
MX_UART4_Init_921600(); //set the baud rate 921600
Still UART initialization failed.
2019-03-04 09:49 PM
Can somebody help on this? How UART baudrate changed at run-time?.
2019-03-04 09:54 PM
What's this "G3_Baudrate_set(); // send cmd to other chip"?
Are you trying to ghange the other end baudrate AFTER you change your end's?
2019-03-04 10:05 PM
It just a command for baudrate change request to the other connected chip with UART .
My requirement is to set baudrate 9600 -> 912600 -> 115200.