STM32CubeMX 4.22.1 STM32L476JGYx SystemClock_Config Bug
Hi guys.
I'm working in a STM32L476JGY based project using the board STEVAL-STLCS02V1.
The code generated by the Cube using the default clock configuration 'forgets' initialize the M value of the PLL struct, see original code:
/** System Clock Configuration
*/void SystemClock_Config(void){RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInit;/**Initializes the CPU, AHB and APB busses clocks
*/ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; RCC_OscInitStruct.MSIState = RCC_MSI_ON; RCC_OscInitStruct.MSICalibrationValue = 0; RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI; RCC_OscInitStruct.PLL.PLLN = 40; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7; RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }...
it's very strange that the call to HAL_RCC_OscConfig returns with a HAL_OK, but later, when the function tries to configure the PPLSAI1 it fails and the system is blocked on the _Error_Handler loop.
I fixed the problem initializing the M value on the PLL adding the following line:
RCC_OscInitStruct.PLL.PLLM = 1; // STM32CubeMX forgets that line.
#steval-stlcs02v1 #stm32l476jgyx #systemclock_config #stm32cubemx-4.22.1