AnsweredAssumed Answered

Is it working SystemClock_Config() function generated by the STM32CubeMX 4.9?

Question asked by just4you on Jul 23, 2015
Latest reply on Jul 27, 2015 by just4you
I'd update the CubeMX and Firmware library.
STM32CubeMX Software V4.9.0 / 10 July 2015
STM32CubeF4 Firmware Package V1.7.0 / 01-July-2015

However, this still generate the wrong clock configuration code.

Why this fault is not fixed in the CubeMX 4.9?


In order to check the clock configuration, I follow the progresses.

01./** System Clock Configuration
02.*/
03.void SystemClock_Config(void)
04.{
05.  
06.  RCC_OscInitTypeDef RCC_OscInitStruct;
07.  RCC_ClkInitTypeDef RCC_ClkInitStruct;
08.  
09.  __PWR_CLK_ENABLE();
10.  
11.  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
12.  
13.  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
14.  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
15.  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
16.  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
17.  RCC_OscInitStruct.PLL.PLLM = 24;
18.  RCC_OscInitStruct.PLL.PLLN = 360;
19.  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
20.  RCC_OscInitStruct.PLL.PLLQ = 2;
21.  RCC_OscInitStruct.PLL.PLLR = 2;
22.  HAL_RCC_OscConfig(&RCC_OscInitStruct);
23.  
24.  HAL_PWREx_ActivateOverDrive();
25.  
26.  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1
27.                              |RCC_CLOCKTYPE_PCLK2;
28.  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
29.  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
30.  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
31.  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
32.  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
33.  
34.  HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1);
35.  
36.  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
37.  
38.  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
39.  
40.}

1. Set the break point at the 36 line.
2. Step into the HAL_RCC_GetHCLKFreq() function.
3. Check the SystemCoreClock value in the watch window.


I expect this value is 168M but it shows 16M.

Is it correct?

Outcomes