cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030 USART Auto-Baudrate Behavior Differences Between Two MCU of Same Famlies

FSS1
Associate

I am currently experimenting with STM32F030RCTX and STM32F030CCTX devices.
My goal is to use RS485 with auto-baudrate detection, since I have modules that operate either at 115200 baud or 500k baud.

  • On STM32F030RCTX, I use USART1.

  • On STM32F030CCTX, I use USART3.

  • The UART init functions are identical, except for the instance selection.

Example init function:

void mcu_UART3_Init(void)
{
    huart3.Instance                           = USART3;
    huart3.Init.BaudRate                      = 115200;
    huart3.Init.WordLength                    = UART_WORDLENGTH_8B;
    huart3.Init.StopBits                      = UART_STOPBITS_1;
    huart3.Init.Parity                        = UART_PARITY_NONE;
    huart3.Init.Mode                          = UART_MODE_TX_RX;
    huart3.Init.HwFlowCtl                     = UART_HWCONTROL_NONE;
    huart3.Init.OverSampling                  = UART_OVERSAMPLING_16;
    huart3.Init.OneBitSampling                = UART_ONE_BIT_SAMPLE_DISABLE;
    huart3.AdvancedInit.AdvFeatureInit        = UART_ADVFEATURE_AUTOBAUDRATE_INIT;
    huart3.AdvancedInit.AutoBaudRateEnable    = UART_ADVFEATURE_AUTOBAUDRATE_ENABLE;
    huart3.AdvancedInit.AutoBaudRateMode      = UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME;

    if (HAL_RS485Ex_Init(&huart3, UART_DE_POLARITY_HIGH, 16, 16) != HAL_OK)
    {
        Error_Handler();
    }
}

 

Observed Behavior

  • With STM32F030RCTX (USART1):
    As soon as the device receives a 0x55 frame on any time, the auto-baudrate detection automatically starts. I don’t need to trigger anything manually (no explicit “autobaudrate request”).

  • With STM32F030CCTX (USART3):
    I see different behavior. It does not automatically start the auto-baudrate detection in the same way on any time. It starts only beggining, but my first message is not 0x55, so auto baudrate detection is going off untill i activate again.

Application Context

I have a module that must communicate with different products:

  • One product works at 115200 baud.

  • Another product works at 500k baud, and it is able to send the required 0x55 sync character.

Because of this:

  • I always start the UART at 115200.

  • If the connected product is the 115200 one → no issue.

  • If the connected product is the 500k one → it should send a 0x55 to let my MCU perform auto-baudrate and switch correctly.

The issue:

  • If the very first byte received is 0x55, then auto-baudrate works as expected.

  • But if the first byte is not 0x55, then I need a way to re-trigger auto-baudrate later.

  • On STM32F030RCTX, this seems to “just work”.

  • On STM32F030CCTX, it does not behave the same way.

Additional Concern

	// Frame Error
	if((__HAL_UART_GET_IT(huart, UART_IT_FE) != RESET))
	{
		__HAL_UART_CLEAR_IT(huart, UART_CLEAR_FEF);

		if(huart->Instance == RS485_UART_MODULE)
		{
			if(++fe_streak > 4)
			{
				fe_streak = 0;
				huart->Instance->CR2 &= ~(USART_CR2_ABREN);
				huart->Instance->CR2 |=  USART_CR2_ABREN;
			}
		}
	}
	else
	{
		fe_streak = 0;
	}

One possible workaround is to re-trigger auto-baudrate when a Frame Error is detected.
However, this creates a new problem:

If the system is communicating with the 115200-baud product (which does not have the ability to send a 0x55 sync character), then any spurious frame error would cause the MCU to restart auto-baudrate detection. In this case the USART would be left waiting for a 0x55 that will never arrive, effectively blocking communication with the 115200-baud device.

My Question to the Community

  • Is there any documented difference between USART1 (on STM32F030RCTX) and USART3 (on STM32F030CCTX) regarding auto-baudrate hardware behavior?
  • On STM32F030CCTX, do I need to explicitly toggle ABREN (disable/enable) when I want to re-arm the auto-baudrate detection, while USART does it automatically?
  • Or am I missing a step in the initialization sequence for USART3 RS485 with auto-baudrate?
  • Any insights from others who faced the same difference between USART1 vs USART3 on the STM32F0 family would be highly appreciated.

Thanks :)

3 REPLIES 3
Amel NASRI
ST Employee

Hi @FSS1 ,

I can help answering the first question:


Is there any documented difference between USART1 (on STM32F030RCTX) and USART3 (on STM32F030CCTX) regarding auto-baudrate hardware behavior?

Based on the following table from the product reference manual RM0360, both USART1 and USART3 have the same features implementation:

AmelNASRI_0-1755787677532.png

-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.

Pavel A.
Super User

If the system is communicating with the 115200-baud product (which does not have the ability to send a 0x55 sync character), then any spurious frame error would cause the MCU to restart auto-baudrate detection. In this case the USART would be left waiting for a 0x55 that will never arrive, effectively blocking communication

Detection based on a single byte transmission doesn't seem robust. This point deserves additional design effort.

Do they use the same stepping of the IC? See DEVID reported, likely via SYSCFG or DBGMCU, check RM.

Should be able to clear or reset via APBxRSTR or perhaps UART Enable bit.

Could also make a different method if Rx pin maps to TIMx_CHx pin or with EXTI,and timing your own patterns or sequences.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..