2025-04-21 8:46 PM - last edited on 2025-04-22 9:27 AM by mƎALLEm
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;
2025-04-21 10:21 PM
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
2025-04-22 8:51 AM
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
2025-04-22 9:26 AM
2025-04-22 5:05 PM
Thank you. I will try.
2025-04-25 7:39 PM
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;
2025-04-26 2:35 AM - edited 2025-04-26 4:14 AM
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".
2025-04-26 8:02 AM
Thank you. I will try.