cancel
Showing results for 
Search instead for 
Did you mean: 

I'm a STMCube Newbie. I'm under the impression when I set up the clocks in STM32CubeIDE, it should generate all the clock configurations. Right now I'm not getting the RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; Should it be there. See clock config

FPHIL.1
Associate

0693W00000Y9NDWQA3.png

3 REPLIES 3
Sarra.S
ST Employee

Hello @FPHIL.1​ and welcome to ST Community,

After configuring the Clock tree in stm32Cube and generating the code, you shall find something like this

0693W00000Y9SzuQAF.png 

the RCC_PeriphCLKInitTypeDef PeriphClkInit = {0} functions is used to configure all peripherals clocks settings, such as frequency and prescaler. It is important to understand that all peripherals need to be properly configured to receive the correct clock frequency.

Hope that helps!

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.

Your image is what I get. But I was expecting this as well:

void SystemClock_Config(void)

{

 RCC_OscInitTypeDef RCC_OscInitStruct = {0};

 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

.

. // whats in your image plus vvvvvv

.

.

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;

 PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;

 PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSI;

 PeriphClkInit.PLLSAI1.PLLSAI1M = 2;

 PeriphClkInit.PLLSAI1.PLLSAI1N = 8;

 PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7;

 PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;

 PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2;

 PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_ADC1CLK;

 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

 {

  Error_Handler();

 }

What reference should I use on what to add to the generated code (like this) for other clock configuration details?.

Sincere thanks,

Fred

Was it solved? I have the same issue.