2022-07-03 11:10 PM
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
Solved! Go to Solution.
2022-07-04 12:52 AM
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
2022-07-04 12:52 AM
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
2022-07-04 09:33 AM
Thank you very much for the speedy answer. :D
2022-07-05 12:39 AM
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