2015-07-22 10:49 PM
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, Ifollow the progresses./** System Clock Configuration */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; __PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 24; RCC_OscInitStruct.PLL.PLLN = 360; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 2; RCC_OscInitStruct.PLL.PLLR = 2; HAL_RCC_OscConfig(&RCC_OscInitStruct); HAL_PWREx_ActivateOverDrive(); RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1 |RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); } 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? #clock #cubemx #systemclock_config
2015-07-23 02:17 AM
Hi,
I suggest you to check your HSE source configuration, it seems that the clocks settings are not correct so the SystemCoreClock value is not updated. According to your settings it’s not clear how you can reach the 168M!! RCC_OscInitStruct.PLL.PLLM = 24;
RCC_OscInitStruct.PLL.PLLN = 360;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
-Syrine-
2015-07-23 05:13 AM
Sorry about the fault of my code. The other project code is copied.
I tested again with my system. - STM32F4-DISCOVERY - Third Party Development KIT - My custom board 1. The generation code for STM32F4-Discovery works well. The system clock value is 168M. 2. The generation code for third party dev kit does not show the Max Speed 168M. just only 16M. However, STM32F4-Dicovery show the max speed 168M. The modified standard peripheral library code for third party dev kit works well. (just only the HSE_VALUE as 8M, PLL_M as 8, and PLL_N as 336) 3. The generation code for my custom board does not show the MAX Speed 180M. also just 16M. However, the Standard Peripheral Library code works well in my custom board. The system clock speed show 180M. (HSE_VALUE as 26M, PLL_M as 26, and PLL_N as 360) The following is my capture of the system clock speed. - CubeMX generated Code for Third Party Dev Kit - Standard Peripheral Library for Third Party Dev Kit - CubeMX generated Code for Custom Board - Standard Peripheral Library for Custom Board The CubeMX generated code shows just only 16M, but the Standard Peripheral Library code works well as 168M and 180M. Why the difference happens?2015-07-23 06:25 AM
Are we sure it's actually running from the HSE or PLL?
The number suggests that it's running from the HSI. So I'd go look if there are any errors returned by the function. And then go look at the RCC registers and decompose the actual settings the system is running with.2015-07-23 07:47 AM
Please use the same configuration as in this figure
-Syrine-2015-07-27 02:58 AM
This is my clock configuration for CubeMX.
Do you want this configuration?
I wonder that the difference between Discovery and tird party development kit. - Clock Configuration for Third Party Dev Kit- Clock Configuration for Custom Board