Skip to main content
OBA.1
Associate
May 24, 2023
Question

Hi, I need to work with USART auto baud rate detection on STM32G0.

  • May 24, 2023
  • 2 replies
  • 1371 views

 I did the USART configuration as mentioned in AN4908. However, the UART_FLAG_ABRF flag is always reset.

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
May 24, 2023

Not sure your presentation is sufficient to understand or replicate what you tried.

Have you reviewed the problem in the context of the Reference Manual?

https://www.st.com/resource/en/application_note/an4908-stm32-usart-automatic-baud-rate-detection-stmicroelectronics.pdf

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
OBA.1
OBA.1Author
Associate
May 24, 2023

hi, sure! i have set the config as defined below:

/*##-2- Configure the AutoBaudRate method */ UartHandle.AdvancedInit.AdvFeatureInit =UART_ADVFEATURE_AUTOBAUDRATE_INIT; UartHandle.AdvancedInit.AutoBaudRateEnable = UART_ADVFEATURE_AUTOBAUDRATE_ENABLE; /*Uncomment your appropriate mode */ //UartHandle.AdvancedInit.AutoBaudRateMode = UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT; //UartHandle.AdvancedInit.AutoBaudRateMode = UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE; //UartHandle.AdvancedInit.AutoBaudRateMode = UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME; //UartHandle.AdvancedInit.AutoBaudRateMode = UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME; if (HAL_UART_Init(&UartHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* Wait until Receive enable acknowledge flag is set */ while(__HAL_UART_GET_FLAG(&UartHandle,UART_FLAG_REACK) == RESET) {} /* Wait until Transmit enable acknowledge flag is set */ while(__HAL_UART_GET_FLAG(&UartHandle,UART_FLAG_TEACK) == RESET) {} /* Loop until the end of Autobaudrate phase */ while(__HAL_UART_GET_FLAG(&UartHandle,UART_FLAG_ABRF) == RESET) {}

However the UART_FLAG_ABRF flag is always reset ! so this loop is blocked!

ST Employee
October 19, 2023

Hello,
Your configuration is OK! However, the receiver waits for the first character on the RX line (coming from the transmitter) which should be the frame 0x7F. Then it calculates the baud and updates the BRR by hardware.
The operation's completion is signaled by ABREF flag being set to 1.

So, make sure that the frame was sent correctly by transmitter by checking the TDR register.

Kind regards,