After reset the chip crawls along on its internal 64 MHz oscillator. This guide climbs to the full 480 MHz in six moves: raise the core voltage, set the flash wait states, start the 25 MHz oscillator, multiply it with PLL1, divide the buses, switch over. The order matters, and every number points at a page.
- What the chip runs from after reset and why a faster clock needs a higher core voltage (VOS)
- Which oscillator feeds the chip on this board and why it is used in bypass mode
- How the PLL turns 25 MHz into 480 MHz with M, N and P, and which ranges you must respect
- Why flash wait states and the bus dividers must be set before the switch
- STM32H750B-DK and a USB cable to CN14 (the ST-LINK connector)
- STM32CubeIDE installed
On this board
Pulled from the datasheet tables and the board schematic. Click a pin for everything the finder knows about it.
Where you start and where you can go
After reset the CPU runs from the HSI, the internal 64 MHz oscillator. All three PLLs are off, the core voltage is at its lowest level (VOS3) and the flash is set to a cautious 7 wait states. That is why your LED code worked with no clock setup at all.
The H750 can go much faster, but each speed needs a matching core voltage. The datasheet lists the maximum CPU clock for each VOS level:
- VOS3 (reset default): 200 MHz
- VOS2: 300 MHz
- VOS1: 400 MHz
- VOS0: 480 MHz
The buses have their own limits. At VOS0 the AXI and AHB buses may run at 240 MHz at most, and the APB buses at 120 MHz. So the target of this guide is 480 MHz CPU, 240 MHz AXI/AHB, 120 MHz APB.
Do you need 480 MHz? Not for blinking LEDs. It helps for graphics and big programs, and it costs more current and heat. ST's own example projects for this board run at 400 MHz, which is a fine choice too: the steps are the same with different numbers.
The datasheet attaches conditions to the 480 MHz row: it is available on silicon revision V, with a junction temperature of at most 105 °C, and only when the core is supplied by the LDO regulator. Look at the marking on top of your chip if you are unsure about the revision.
Where the 25 MHz comes from: oscillator X1
The HSE clock source is external. The user manual says the board has a 25 MHz oscillator X1 for the microcontroller and the Ethernet PHY (a second one, X3, serves the ST-LINK, and a 32.768 kHz crystal X2 serves the RTC).
An oscillator is a complete little module: it makes its own clean square wave. A bare crystal would need the MCU's own amplifier between OSC_IN and OSC_OUT. Here the MCU only has to listen, which is exactly what HSE bypass means.
You can see it on the schematic. X1 pin 3 (OUT) drives the net OSC_25M, and OSC_25M reaches PH0, the OSC_IN pin, through R79 (51 ohm). PH1, the OSC_OUT pin, is not connected to anything oscillator-like: its net is STMOD#17, a plain I/O on the STMod+ connector. In bypass mode the HSE amplifier is switched off and the pin is just an input, which the datasheet allows for clock signals between 4 and 50 MHz. In the register it is one bit: HSEBYP in RCC_CR, written while HSE is still off, then HSEON, then wait for HSERDY.
Why use HSE at all when HSI is built in? The internal RC oscillator is less accurate and drifts with temperature. A timer or UART derived from it is slightly off, and interfaces like USB and Ethernet need a precise reference.
Tip. In CubeMX this is the pin mode "BYPASS Clock Source" under RCC, High Speed Clock. Set the input frequency to 25 MHz in the Clock Configuration tab, or every number it shows will be wrong.
PLL1: 25 MHz × 192 / 5 / 2 = 480 MHz
A PLL multiplies a slow, steady clock. The recipe has three numbers (see VCO):
- M divides the input first. 25 MHz / 5 = 5 MHz into the PLL. The input must be 1 to 16 MHz.
- N multiplies inside the VCO. 5 MHz × 192 = 960 MHz. The wide VCO accepts 192 to 960 MHz for this chip revision.
- P divides the VCO down to the output. 960 / 2 = 480 MHz. This output,
pll1_p_ck, becomes the system clock.
Two settings tell the PLL what you are feeding it. PLL1RGE says which input range you use (4 to 8 MHz, code 10, because 5 MHz sits there) and PLL1VCOSEL = 0 chooses the wide VCO. Q and R are two more outputs from the same VCO. This guide does not use them; the code below copies ST's values (Q = 4, R = 2).
Mind the encoding. The register stores M as written (5), but N and P are stored minus one: N = 192 is written as 191, P = 2 as 1. The HAL hides this, direct register code does not.
The PLL fields cannot be changed while PLL1 is on, and the hardware will not let you switch PLL1 off while it is the system clock.
Why the order matters: power, flash, then clock
The six moves of the full sequence, and what each one protects:
- Raise the core voltage. Go from VOS3 to VOS1, then to VOS0. The core needs the higher voltage to switch reliably at high speed, so this comes before any clock change. VOS0 is reachable only from VOS1: set
ODENinSYSCFG_PWRCR(its clock must be on, bitSYSCFGENinRCC_APB4ENR) and wait until the regulator reports ready. On this board the regulator is the LDO: the user manual notes that the STM32H750B-DK supports LDO mode only, which is what VOS0 needs anyway. - Set the flash wait states. The flash cannot answer as fast as a 240 MHz bus asks, so the CPU waits. Table 17 in the reference manual says that for VOS0 and an AXI clock between 225 and 240 MHz you need 4 wait states. Write
LATENCYinFLASH_ACRand read it back. - Start HSE and wait for
HSERDY. - Configure and start PLL1 and wait for
PLL1RDY. - Set the bus dividers. AXI/AHB: divide by 2. All APB buses: divide by 2 again.
- Switch
SWinRCC_CFGRto PLL1 and wait untilSWSshows it took.
The dividers go before the switch for a simple reason: at the instant of the switch the AXI bus would otherwise see the full 480 MHz, twice its limit.
Nothing stops you from skipping a step. The chip simply misbehaves in odd ways: random hard faults or corrupted reads at high speed. After reset the flash is set to 7 wait states, so a wrong value only matters if you lower it too far.
The code
Both versions below do the same six moves. They compile against ST's headers (checked with the GNU Arm toolchain from CubeIDE; not run on the board). Call the function first thing in main(), before you use any peripheral.
The register version shows what the HAL does underneath. The HAL version is what CubeMX generates, give or take formatting. HAL sets only the LATENCY field of FLASH_ACR; WRHIGHFREQ (which Table 17 also lists) only matters when the flash is being programmed.
Two details worth a second look in the register version: HSEBYP is set before HSEON because it is only writable while HSE is off, and SystemCoreClockUpdate() recomputes the SystemCoreClock variable by reading these registers (it assumes HSE_VALUE is 25000000, which is the default in ST's system file).
#include "stm32h7xx.h" /* with STM32H750xx defined by the project */
#define WAIT_UNTIL(cond) do { } while (!(cond))
void clock_init_480mhz(void)
{
/* 1. Core voltage: VOS3 (reset value) -> VOS1 -> VOS0 (VOS0 needs the LDO) */
PWR->D3CR |= PWR_D3CR_VOS; /* VOS[1:0] = 11 = scale 1 */
WAIT_UNTIL(PWR->CSR1 & PWR_CSR1_ACTVOSRDY);
RCC->APB4ENR |= RCC_APB4ENR_SYSCFGEN; /* SYSCFG registers need their clock */
(void)RCC->APB4ENR;
SYSCFG->PWRCR |= SYSCFG_PWRCR_ODEN; /* overdrive on = scale 0 */
WAIT_UNTIL(PWR->CSR1 & PWR_CSR1_ACTVOSRDY);
/* 2. Flash: the AXI bus will run at 240 MHz in VOS0 -> 4 wait states (RM Table 17) */
FLASH->ACR = (FLASH->ACR & ~(FLASH_ACR_LATENCY | FLASH_ACR_WRHIGHFREQ))
| FLASH_ACR_LATENCY_4WS | FLASH_ACR_WRHIGHFREQ_1;
WAIT_UNTIL((FLASH->ACR & FLASH_ACR_LATENCY) == FLASH_ACR_LATENCY_4WS); /* read it back */
/* 3. HSE: X1 is a ready-made 25 MHz oscillator, so use bypass mode */
RCC->CR |= RCC_CR_HSEBYP; /* only writable while HSE is off */
RCC->CR |= RCC_CR_HSEON;
WAIT_UNTIL(RCC->CR & RCC_CR_HSERDY);
/* 4. PLL1: 25 MHz / M(5) * N(192) / P(2) = 480 MHz. PLL1 must be off while you write these. */
RCC->PLLCKSELR = (RCC->PLLCKSELR & ~(RCC_PLLCKSELR_PLLSRC | RCC_PLLCKSELR_DIVM1))
| RCC_PLLCKSELR_PLLSRC_HSE
| (5U << RCC_PLLCKSELR_DIVM1_Pos); /* 25 / 5 = 5 MHz into the PLL */
RCC->PLLCFGR = (RCC->PLLCFGR & ~(RCC_PLLCFGR_PLL1RGE | RCC_PLLCFGR_PLL1VCOSEL | RCC_PLLCFGR_PLL1FRACEN))
| RCC_PLLCFGR_PLL1RGE_2 /* input range 4 to 8 MHz */
| RCC_PLLCFGR_DIVP1EN | RCC_PLLCFGR_DIVQ1EN | RCC_PLLCFGR_DIVR1EN;
RCC->PLL1DIVR = ((192U - 1U) << RCC_PLL1DIVR_N1_Pos) /* VCO = 5 MHz * 192 = 960 MHz */
| ((2U - 1U) << RCC_PLL1DIVR_P1_Pos) /* P = 480 MHz: the CPU clock */
| ((4U - 1U) << RCC_PLL1DIVR_Q1_Pos) /* Q = 240 MHz (unused here) */
| ((2U - 1U) << RCC_PLL1DIVR_R1_Pos); /* R = 480 MHz (unused here) */
RCC->CR |= RCC_CR_PLL1ON;
WAIT_UNTIL(RCC->CR & RCC_CR_PLL1RDY);
/* 5. Bus dividers BEFORE the switch: AXI/AHB = 480/2 = 240 MHz, every APB = 240/2 = 120 MHz */
RCC->D1CFGR = RCC_D1CFGR_D1CPRE_DIV1 | RCC_D1CFGR_HPRE_DIV2 | RCC_D1CFGR_D1PPRE_DIV2;
RCC->D2CFGR = RCC_D2CFGR_D2PPRE1_DIV2 | RCC_D2CFGR_D2PPRE2_DIV2;
RCC->D3CFGR = RCC_D3CFGR_D3PPRE_DIV2;
/* 6. Switch the system clock to PLL1 and wait until the hardware confirms it */
RCC->CFGR = (RCC->CFGR & ~RCC_CFGR_SW) | RCC_CFGR_SW_PLL1;
WAIT_UNTIL((RCC->CFGR & RCC_CFGR_SWS) == RCC_CFGR_SWS_PLL1);
SystemCoreClockUpdate(); /* recompute the SystemCoreClock variable */
}void SystemClock_Config(void)
{
RCC_OscInitTypeDef osc = {0};
RCC_ClkInitTypeDef clk = {0};
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /* this board only has the LDO */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) { }
__HAL_RCC_SYSCFG_CLK_ENABLE(); /* needed for the next step */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); /* sets SYSCFG_PWRCR.ODEN */
while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) { }
osc.OscillatorType = RCC_OSCILLATORTYPE_HSE;
osc.HSEState = RCC_HSE_BYPASS; /* RCC_CR.HSEBYP + HSEON */
osc.PLL.PLLState = RCC_PLL_ON;
osc.PLL.PLLSource = RCC_PLLSOURCE_HSE;
osc.PLL.PLLM = 5; /* 25 / 5 = 5 MHz */
osc.PLL.PLLN = 192; /* VCO = 960 MHz */
osc.PLL.PLLP = 2; /* 480 MHz */
osc.PLL.PLLQ = 4;
osc.PLL.PLLR = 2;
osc.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; /* 4 to 8 MHz input */
osc.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
osc.PLL.PLLFRACN = 0;
if (HAL_RCC_OscConfig(&osc) != HAL_OK) Error_Handler();
clk.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 |
RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1;
clk.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
clk.SYSCLKDivider = RCC_SYSCLK_DIV1; /* CPU 480 MHz */
clk.AHBCLKDivider = RCC_HCLK_DIV2; /* AXI and AHB 240 MHz */
clk.APB3CLKDivider = RCC_APB3_DIV2; /* APB 120 MHz */
clk.APB1CLKDivider = RCC_APB1_DIV2;
clk.APB2CLKDivider = RCC_APB2_DIV2;
clk.APB4CLKDivider = RCC_APB4_DIV2;
if (HAL_RCC_ClockConfig(&clk, FLASH_LATENCY_4) != HAL_OK) Error_Handler(); /* writes FLASH_ACR.LATENCY */
}Tip. Want the safer 400 MHz that ST uses in its own examples? Stay in VOS1 (skip the ODEN part), use N = 160 so the VCO is 800 MHz, and set LATENCY to 4 as ST does (Table 17 would allow 2 at a 200 MHz bus). Everything else is identical.
Check that it really runs at 480 MHz
Do not trust a clock setup you have not read back. In the debugger, look at these registers (the Registers view or an expression):
RCC_CFGR.SWSmust read011: PLL1 is the system clock.RCC_CR.PLL1RDYandHSERDYmust be 1.FLASH_ACR.LATENCYmust read 4.SystemCoreClockshould be 480000000. With the HAL,HAL_RCC_GetSysClockFreq()returns the same number.
A quick physical check: run the busy-wait blink from the LED guide again. The LED should blink noticeably faster than at 64 MHz, because the same loop now runs several times faster (the speed-up is not exactly 7.5 times, since flash wait states and caches are in play). If it does not change at all, SWS will tell you the switch never happened.
If the chip hangs somewhere in the setup, the debugger will show which WAIT_UNTIL it is stuck in. The usual culprits: oscillator X1 not reaching OSC_IN (HSERDY never sets), or VOS0 not ready (see the pitfalls below).
Read the same thing in CubeMX
If you create your project in STM32CubeIDE, you never write the code above by hand. The same decisions appear in the Clock Configuration tab, and now you can read it. The exact labels differ a little between CubeMX versions:
- Under Pinout, RCC, High Speed Clock, choose "BYPASS Clock Source". Enter 25 as the HSE input frequency.
- Set the PLL source to HSE, /M = 5, ×N = 192, /P = 2. The system clock box should show 480.
- Set the CPU prescaler to /1 and the AHB prescaler to /2; all APB dividers to /2. The AXI line shows 240 MHz and the APB lines 120 MHz.
- Open RCC, Parameter Settings and pick "Power Regulator Voltage Scale 0" (the supply source is the LDO). CubeMX then chooses the flash latency for you.
CubeMX turns each of these choices into the HAL code in the second tab above. When a clock box turns red, the tool is telling you that one of the limits from this guide is broken.
Next, PLL2 and PLL3 are free for peripherals. In the display guide you will use PLL3 to make the slow pixel clock for the screen.
Common mistakes
- Setting the PLL up first and the voltage afterwards. At VOS3 the chip can only run 200 MHz, so it can crash the moment the switch happens.
- Forgetting the bypass bit. With
HSEONalone the MCU runs its crystal amplifier against an oscillator that already drives the pin. ST’s own examples for this board useRCC_HSE_ON. Bypass is the mode that matches an oscillator module; the difference on this board is not verified. - Trusting the wrong number for the VCO limit. The reference manual still says the wide VCO tops out at 836 MHz, while the rev V datasheet allows 960 MHz. For a part of your revision the datasheet wins, and ST’s own 480 MHz example for the Nucleo-H743ZI also runs the VCO at 960 MHz.
- Expecting 480 MHz on any chip. The datasheet gives it only for revision V devices at up to 105 °C junction temperature. Older revisions stop at 400 MHz.
- Writing PLL fields while PLL1 is on, or writing N and P without the minus one. The first is ignored by the hardware, the second gives the wrong frequency.
- Leaving a busy-wait delay or SysTick reload calculated for 64 MHz. After the change they run at the wrong speed. Recompute them from
SystemCoreClock.
Check yourself
Try to answer before opening. If you get stuck, the pages linked above have the answer.
Why do you raise the voltage scale before the clock, and lower the clock before the voltage when going back down?
The core needs a higher voltage to switch reliably at high speed. If the clock is faster than the voltage supports (for example 480 MHz at VOS3, which allows 200 MHz) the logic misbehaves. The reference manual states the rule in the PWR_D3CR description: when increasing performance, change the voltage scaling before increasing the system frequency; when decreasing, lower the frequency first.
ST’s LTDC example runs the CPU at 400 MHz from the same 25 MHz input. Which M, N and P does it use?
M = 5, N = 160, P = 2: 25 MHz / 5 = 5 MHz, × 160 = 800 MHz at the VCO, / 2 = 400 MHz. It stays in VOS1, with the AHB divided by 2 giving 200 MHz on the AXI bus.
What would go wrong if you switched SW to PLL1 while HPRE is still divide-by-1?
The AXI and AHB buses would run at 480 MHz, twice their 240 MHz limit at VOS0. Setting the dividers before the switch means the buses never see more than their limit.
Reading list
Every page this guide sent you to, by document. Reading them in order is a good revision.
| DS12556 | STM32H750xB datasheet | p.202p.220p.227 |
| RM0433 | RM0433 reference manual (STM32H742/743/753/750) | p.158p.201p.279p.304p.306p.309p.336p.345p.349p.382p.390p.393p.395p.396p.397p.399p.402p.470p.560 |
| UM2488 | UM2488 STM32H745I/H750B-DK Discovery kit user manual | p.11p.13 |
| MB1381 | MB1381 Discovery board schematic (H750XB variant) | sheet 3sheet 3 |
Search next
Each of these opens the finder with pins, registers, schematic hits and document pages for the term.