cancel
Showing results for 
Search instead for 
Did you mean: 

Missing code during Code Generation - STM32CubeIDE version 1.9.0

STehA.1
Associate II

Hi, I am using the STM32CubeIDE version 1.9.0 Code Generator feature (via the CubeMX graphical interface) and wanted to generate the 96 MHz sample clock for the I2S codec. Unfortunately, I found that the code generated under sub "void SystemClock_Config(void)" missing the I2S clock setting which supposed to look something like below:

//all these are not generated by the CubeMX code generator
  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
 
...
  PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S;
  PeriphClkInitStruct.PLLI2S.PLLI2SN = 192;
  PeriphClkInitStruct.PLLI2S.PLLI2SR = 2;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

My question is:

1) Am I missing anything while setting the CubeMX?

2) What will be the way out other than copy the code above into my project main.c file?

NOTE: I am comparing my code with respect to sample code given by other person then I know that the CubeMX Code Generator of my work lack of the above codes. I attached the photos of my CubeMX graphically setting and the code it produced (see attachment)

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Aziz BRIGUI
ST Employee

Hello @STehA.1​,

Thank you for posting,

The missing peripheral clock config you mentioned is generated under HAL_I2S_MspInit (in stm32f4xx_hal_msp.c), this function is called by MX_I2Sx_Init. So there's no need to add the code in SystemClock_Config.

If you have any further questions, do not hesitate to ask.

Best regards,

Aziz


In order 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.

View solution in original post

3 REPLIES 3
Aziz BRIGUI
ST Employee

Hello @STehA.1​,

Thank you for posting,

The missing peripheral clock config you mentioned is generated under HAL_I2S_MspInit (in stm32f4xx_hal_msp.c), this function is called by MX_I2Sx_Init. So there's no need to add the code in SystemClock_Config.

If you have any further questions, do not hesitate to ask.

Best regards,

Aziz


In order 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.
STehA.1
Associate II

Thank you very much for the speedy answer. :D

Aziz BRIGUI
ST Employee

Hello @STehA.1​,

Glad I could help,

If your issue is resolved, please close this post by clicking the "Select as Best" button on the previous answer. This will help other members of the community find this response more quickly.

Thanks for your contribution and do not hesitate to raise any issues or feedback.

Regards,

Aziz


In order 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.