What does RCC mean on STM32?

 On STM32, RCC stands for Reset and Clock Control.

It’s a big central block inside the microcontroller that is responsible for:



  1. Clocks (the “C” in RCC)
    RCC generates and distributes clocks to:

    • The CPU core

    • Buses (AHB, APB1, APB2, etc.)

    • Peripherals (GPIO, USART, SPI, I²C, TIM, ADC, etc.)

    Typical things RCC does:

    • Select clock sources: HSI (internal), HSE (external crystal), PLL, LSI, LSE, etc.

    • Set prescalers to divide clocks for different buses.

    • Choose the system clock (SYSCLK) and derived clocks like HCLK, PCLK1, PCLK2.

  2. Resets (the “R” in RCC)
    RCC can reset:

    • The entire chip (system reset)

    • Individual peripherals (e.g. reset just USART1, SPI2, etc.)

    This is used to:

    • Bring peripherals to a known default state

    • Recover a misconfigured peripheral by toggling its reset bit.

  3. Enabling / disabling peripheral clocks
    Before you can use most peripherals on STM32, you must enable their clock in RCC.
    Examples:

    // HAL example __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_USART2_CLK_ENABLE();

    Or at register level (depends on family):

    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; // Enable GPIOA clock RCC->APB1ENR |= RCC_APB1ENR_USART2EN; // Enable USART2 clock

    If you don’t enable the RCC clock:

    • The peripheral’s registers may appear “dead” or read as zero.

    • Your code may HardFault when trying to use it.

  4. Where you see RCC in practice

  • In CubeMX / CubeIDE, the “Clock Configuration” tab is basically configuring the RCC.

  • In code, anything named like __HAL_RCC_XXX_CLK_ENABLE(), RCC_CFGR, RCC_CR, etc. is part of this block.

  • When you see diagrams like “STM32 Clock Tree” in the datasheet – that’s all RCC-related.

评论

此博客中的热门博文

Detailed Explanation of STM32 HAL Library Clock System

How To Connect Stm32 To PC?

How to add a GPS sensor to ESP32 for Wokwi?