Skip to main content
Senior
April 22, 2025
Question

Help with SystemClock_Config

  • April 22, 2025
  • 5 replies
  • 804 views

How to combine settings in SystemClock_Config to use both keyboard and ADC examples?

In keyboard project there is the follow setting in SystemClock_Config:

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 32;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV5;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4;

In ADC sample:

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI
|RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

5 replies

KnarfB
Super User
April 22, 2025

There are so many examples and versions, it would be helpful if you gave as many details as possible, e.g. by referring to https://github.com/STMicroelectronics/STM32CubeWB/tree/master

There is no combination, it is "either or". And the 2nd settings make little sense to me as they activate several competing clocks (HSI/HSE/HSI48).

hth

KnarfB

GS2Author
Senior
April 26, 2025

What about:

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI
|RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 32;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV5;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4;
GS2Author
Senior
April 22, 2025

Thank you for response.

The first project is - https://github.com/stm32-hotspot/STM32WB-BLE-HID-Selfie/blob/164a8d2e9745f3a159ba92a056bd01e4a384f72a/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_Hid_Selfie

The second project I am trying to use for ADC is - C:\Users\USER\STM32Cube\Repository\STM32Cube_FW_WB_V1.20.0\Projects\P-NUCLEO-WB55.Nucleo\Examples\ADC\ADC_SingleConversion_TriggerSW_IT

mƎALLEm
Technical Moderator
April 22, 2025

Hello @GS2 ,

Please kindly use </> button to share a code. Refer to this post. I'm editing your post.

Thank you for your understanding.

"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."
GS2Author
Senior
April 23, 2025

Thank you. I will try.

Pavel A.
Super User
April 26, 2025

Usually to understand the clock settings, the Clocks view of CubeMX is very helpful (besides reading the fine RM).

On this view you see the clock sources and frequencies of relevant modules.

So, decide which OSC  you want to have in the merged project (usually HSE with PLL),  then tweak the controls so that these frequencies remain same.  Click "Generate code".

 

GS2Author
Senior
April 26, 2025

Thank you. I will try.

mƎALLEm
Technical Moderator
May 14, 2025

Hello @GS2 ,

Could you please state on this case.

If your question has been answered please accept as solution the comment that provided it or tell how you solved you issue and accept it as solution.

Thank you

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