STM32 RCC Clock Tree

STM32 PLL Clock Tree Calculator

Compute PLLM, PLLN, PLLP and PLLQ for STM32F4, STM32F7 and STM32H7 boards, flag out-of-spec VCO or APB limits, and emit ready-to-compile HAL RCC init code.

Nucleo MCO bypass is 8 MHz; Black Pill crystal is 25 MHz
Board presets:
All clock domains stay within STM32F767 / F746 (216 MHz max) datasheet bounds. Recommended Flash wait states at 3.3 V: FLASH_LATENCY_7.
SYSCLK / HCLK216.00 MHzHCLK 216.00 MHz (max 216)
VCO In / Out432.0 MHzInput 2.00 MHz
APB1 / TIMx54.00 MHzTimers run at 108.00 MHz
APB2 / TIMx108.00 MHzTimers run at 216.00 MHz
PLL48CLK (PLLQ)48.00 MHz48.00 MHz exact (USB OTG FS / RNG valid)
STM32CubeHAL RCC snippet
/* STM32F767 / F746 (216 MHz max) - SYSCLK 216.00 MHz, APB1 54.00 MHz, APB2 108.00 MHz */
RCC_OscInitTypeDef osc = {0};
osc.OscillatorType = RCC_OSCILLATORTYPE_HSE;
osc.HSEState = RCC_HSE_BYPASS; /* use RCC_HSE_ON for quartz crystal */
osc.PLL.PLLState = RCC_PLL_ON;
osc.PLL.PLLSource = RCC_PLLSOURCE_HSE;
osc.PLL.PLLM = 4;
osc.PLL.PLLN = 216;
osc.PLL.PLLP = RCC_PLLP_DIV2;
osc.PLL.PLLQ = 9;
HAL_RCC_OscConfig(&osc);

RCC_ClkInitTypeDef clk = {0};
clk.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
clk.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
clk.AHBCLKDivider = RCC_SYSCLK_DIV1;
clk.APB1CLKDivider = RCC_HCLK_DIV4;
clk.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&clk, FLASH_LATENCY_7);

STM32 clock tree constraints

Clock startup bugs rarely fail loudly on a bench. A wrong PLLM value or missing HSE bypass flag causes HAL_RCC_OscConfig() to spin forever on RCC_CR_HSERDY.

StageFormulaDesign check
VCO inputf_in / PLLMKeep inside 1 to 2 MHz on F4/F7 (1 to 16 MHz on H7).
VCO output(f_in / PLLM) * PLLN100 to 432 MHz on F4/F7; 192 to 960 MHz wide range on H7.
SYSCLKf_VCO / PLLPMust stay at or below part maximum (168, 180, 216 or 480 MHz).
USB / SDIO / RNGf_VCO / PLLQMust hit 48 MHz for USB OTG FS without SOF errors.

Frequently asked questions

QuestionAnswer
Why does STM32F4/F7 recommend a 2 MHz PLL VCO input?ST reference manuals RM0090 and RM0410 specify a 1 to 2 MHz PLL input range and recommend 2 MHz to keep PLL jitter low. Setting PLLM equal to HSE/2 satisfies this rule cleanly.
Why do STM32 timers run at 2x the APB clock?When an APB1 or APB2 prescaler is greater than 1, the internal RCC clock tree doubles the timer kernel clock. A 42 MHz APB1 bus with /4 prescaler drives TIM2 through TIM7 at 84 MHz.
What happens if Flash wait states are set too low before switching SYSCLK?The CPU fetches corrupted instructions from Flash and traps in HardFault or BusFault immediately after RCC_CFGR switches to PLLCLK. Always raise FLASH_ACR.LATENCY before switching to a higher frequency.