2026-01-27 11:05 PM
Why is it that when I set the clock frequency of the STM32 to a high frequency (180 MHz), the code will crash, but when I set it to a low frequency (72 MHz), the code can run normally?
2026-01-27 7:50 PM - last edited on 2026-01-28 3:52 AM by mƎALLEm
Threads murged for the same question.
Why is it that when I set the clock frequency of the STM32 to a high frequency (180 MHz), the code will crash, but when I set it to a low freque
void SystemClock_Config (void)
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
*/
HAL_RCC_PWR CLK_ENABLE ();
HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1);
*/
RCC_OscInitStruct. OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct. HSEState = RCC_HSE ON;
RCC_OscInitStruct. PLL. PLLState = RCC_PLL_ON;
RCC_OscInitStruct. PLL. PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct. PLL. PLLM = 4;
RCC_OscInitStruct. PLL. PLLN = 180;
RCC_OscInitStruct. PLL. PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct. PLL. PLLQ = 2;
RCC_OscInitStruct. PLL. PLLR = 2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL OK)
{
Error Handler () ;
}
RCC_ClkInitStruct. ClockType = RCC CLOCKTYPE HCLK | 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;
if (HAL PWREx EnableOverDrive () != HAL OK)
{
Error Handler () ;
}
if (HAL RCC_ClockConfig (&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL OK)
{
Error Handler();
}Edited to apply source code formatting - please see How to insert source code for future reference.
2026-01-27 8:27 PM - edited 2026-01-27 8:27 PM
Please edit your post to have a proper title and post your question within the message.
Please indicate the full part number of the chip you are using.
How to write your question to maximize your chance... - STMicroelectronics Community
2026-01-28 12:17 AM - edited 2026-01-28 12:19 AM
Hello @乒乓 and welcome to the ST community,
What crystal value you've attached to HSE? you should not exceed 8MHz in that configuration.
2026-01-28 12:40 AM
The external clock I configured is 8 MHz.
2026-01-28 12:41 AM
2026-01-28 1:37 AM - edited 2026-01-28 1:39 AM
What board are you using? ST board or custom board?
If custom board, post the schematics.
2026-01-28 3:41 AM
User has created a duplicate post on this here:
The issue of clock configuration for STM32F446RCT6 - STMicroelectronics Community
2026-01-28 4:13 AM
Is the crystal really 8 MHz?
The MCU might get in trouble when you configure 8 MHz but the reality is e.g. 16 MHz...
2026-01-28 4:18 AM
@mfgkw wrote:
Is the crystal really 8 MHz?
The MCU might get in trouble when you configure 8 MHz but the reality is e.g. 16 MHz...
This is what I'm suspecting.