cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 UART stops At High Temperature

JThom.15
Associate III

Hi,

I am Using an stm32f205 on our board. All the Uarts works fine at room temperature. But when the temp increases above 58 degress, messages started get missed in the uarts or sometimes it completely stops sending messages.

I am running the board at 120MHZ Here is my clock setup 

RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  RCC_OscInitStruct.PLL.PLLM = 13;
  RCC_OscInitStruct.PLL.PLLN = 195;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = 4;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
  {
    Error_Handler();
  }
 
Any help would be much appreciated 
10 REPLIES 10
TDK
Guru

HSI is not a particularly accurate source, especially over temperature. That's likely the cause of communication problems. Consider using an external crystal instead or other accurate clock source.

You can also adjust RCC_HSICALIBRATION_DEFAULT if you have a means of measuring/calibrating it.

If you feel a post has answered your question, please click "Accept as Solution".

Thanks for the response. Currently we don't have any source for measuring/calibrating HSI.

Is there any other hack around without using an external clock

Peter BENSCH
ST Employee

Well, the UART works asynchronously and the bits are already sampled with oversampling when UART signals are read in, so as @TDK mentioned, a clock with a corresponding accuracy is required. If you absolutely want to use UART, you must have an appropriate clock; stable communication cannot be guaranteed with internal clock sources.

Unfortunately, the STM32F2 does not yet have an ABR (Automatic Baud Rate, AN4908) function.

Regards
/Peter

In order 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.
Andrew Neil
Evangelist III

As the others have said, UART communication absolutely relies upon the accuracy of the clock - an uncalibrated RC really isn't going to be good enough over a wide temperature  range.

This is nothing specifically to do with STM32 - the same applies to any microcontroller.

 

BTW:

Use this button to properly post source code:

AndrewNeil_0-1707124989557.png

 

To get that extra row of icons, press this button:

AndrewNeil_1-1707124989564.png

LCE
Principal

Try to lower the baud rate, if nothing else works.

HSI is ... terrible...

Peter BENSCH
ST Employee

A lower baud rate will not help because the frequency stability of the HSI is relative and has the same effect on all derived baud rates. Only a stable clock can help here, which is unfortunately only available from HSI in a limited temperature range.

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

Our board has an esp32 also which is used to connect to internet. Would it be possible to use the Epoch timestamp to calibrate the HSI?

Adjust RCC_HSICALIBRATION_DEFAULT randomly until it works.

If you feel a post has answered your question, please click "Accept as Solution".

Yes thats what I am thinking, create a lookup table with calibration value and temperature/stm32 uptime variation