cancel
Showing results for 
Search instead for 
Did you mean: 

HSI clock config is not correct for NUCLEO L432KC, with drivers version 1.16

SAkhi.951
Associate III

I have setup UART1 clocked with HSI clock, with drivers version 1.16

Which led to incorrect output on the line.

0693W00000BdfgFQAR.pngSame code with drivers version 1.14 worked completely fine. See picture.

Turns out HSI trimming value is not correct in clock setup

RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
 
  /** Initializes the CPU, AHB and APB busses clocks
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
/* RCC_HSICALIBRATION_DEFAULT seems to be wrong */
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB busses clocks
  */

in different versions of drivers it is hardcoded to different value:

v 1.14 - 0x10u

v 1.16 - 0x40u

Also, when I entered debug mode and checked actual value in the register, in first case it was the same, but in second case it was 0, instead of 0x40u.

 0693W00000BdflKQAR.pngSubstituting value manually to 0x10u solved the issue.

Please, check it.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Sadly, this is a longstanding issue that was introduced in July 2020 and still persists a year later. What's worse is the older version of HAL worked correctly in this regard.

https://community.st.com/s/question/0D53W00000PosYBSAZ/is-stm32l4cube-v1160-rcchsicalibrationdefault-set-up-properly-for-stm32l432kc

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

View solution in original post

1 REPLY 1
TDK
Guru

Sadly, this is a longstanding issue that was introduced in July 2020 and still persists a year later. What's worse is the older version of HAL worked correctly in this regard.

https://community.st.com/s/question/0D53W00000PosYBSAZ/is-stm32l4cube-v1160-rcchsicalibrationdefault-set-up-properly-for-stm32l432kc

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