Skip to main content
SAkhi.951
Associate III
July 14, 2021
Solved

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

  • July 14, 2021
  • 1 reply
  • 1382 views

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.

This topic has been closed for replies.
Best answer by TDK

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

1 reply

TDK
TDKBest answer
Super User
July 14, 2021

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