The RCC decides how fast everything runs and which peripherals are powered at all. It picks a clock source (HSI inside the chip, or HSE from the board’s 25 MHz oscillator), multiplies it with a PLL, divides it down for the buses, and feeds each peripheral.
Two things from this chapter matter on day one. After reset every peripheral’s clock is off, so you enable it in an RCC_xxxENR register before touching the peripheral. And many peripherals (UART, ADC, SPI…) have a separate kernel clock chosen in an RCC_DxCCIPxR register; that clock, not the CPU clock, sets their baud rate or sample rate.
- Switching on the clock of a peripheral before you use it
- Running the CPU faster than the 64 MHz it starts with (up to 480 MHz)
- Choosing the kernel clock that sets a UART baud rate or an ADC conversion rate
- Finding out the bus clock a timer or peripheral actually receives
Read in this order
The shortest path through the documents. Each link opens the exact page; the line under it says what to look for.
- RM04338.1 RCC main featuresp.325What the RCC controls, on one page
- RM0433Figure 45. Top-level clock treep.337The clock tree figure: keep it open while you configure anything
- RM04338.5.11 Peripheral clock gating controlp.373Why peripherals start unclocked and how the enable bits work
- RM04338.5.2 Oscillators descriptionp.338HSI, HSE (and bypass), LSE, CSI: the possible sources
- RM04338.5.5 PLL descriptionp.345How M, N, P, Q, R turn 25 MHz into 480 MHz
- RM04338.5.8 Kernel clock selectionp.353Which clock each peripheral’s kernel can use
- UM24886.5 Clock sourcesp.13The board side: a 25 MHz oscillator (X1) and a 32.768 kHz crystal (X2)
Registers to learn first
In the order you usually program them. The other 46 registers of the chapter can wait until you need them.
| 1 | RCC_AHB4ENR | Clock enables for GPIO ports A–K (and other AHB4 peripherals) | p.457 |
| 2 | RCC_APB1LENR | Clock enables for APB1 peripherals: USART2/3, UART4/5/7/8, TIM2–7, I2C1–3… | p.461 |
| 3 | RCC_APB2ENR | Clock enables for APB2 peripherals: USART1/6, TIM1/8, TIM15–17, SPI1/4/5… | p.467 |
| 4 | RCC_CR | Switch oscillators and PLLs on, and wait for their ready flags | p.382 |
| 5 | RCC_PLLCKSELR | PLL source (HSI/CSI/HSE) and the input divider M | p.397 |
| 6 | RCC_PLL1DIVR | PLL1 multiplier N and output dividers P, Q, R | p.402 |
| 7 | RCC_D1CFGR | Prescalers for the CPU, AXI/AHB and APB3 buses | p.393 |
| 8 | RCC_D2CFGR | Prescalers for APB1 and APB2 (they also set the timer clocks) | p.395 |
| 9 | RCC_CFGR | System clock switch: HSI, CSI, HSE or PLL1 | p.390 |
| 10 | RCC_D2CCIP2R | Kernel clock choice for USARTs, I2C, RNG, USB… | p.415 |
All 56 registers in Reset and Clock Control (RCC)
Map of the chapter
Every reference-manual chapter has the same shape. Sections marked ● are in the reading order above.
Common mistakes
- Writing a peripheral’s registers before enabling its clock. The writes are ignored and reading back gives 0.
- Raising the CPU clock without first raising the flash wait states (
FLASH_ACR) and the voltage scale. The chip crashes on the next flash read. - Computing a baud rate from the CPU clock. USARTs use their kernel clock, chosen in
RCC_D2CCIP2R. - Forgetting that a timer clock is doubled when its APB prescaler is not 1. Check the timer clock rule in the RCC chapter.