HAL RCC Overview

Introducing RCC

group RCC_Introduction

  • The RCC (Reset and Clock Control) Hardware Abstraction Layer (HAL) provides a comprehensive set of APIs to interface with the STM32C5xx RCC peripheral.

  • It simplifies the configuration, initialization and management of system and peripheral clocks, reset control, and privilege attributes.

  • The driver supports multiple oscillators (HSI, PSI, HSE, LSE, LSI). HSI oscillator is split into three independent clock outputs: HSIS, HSIDIV3, and HSIK. PSI oscillator is split into three independent clock outputs: PSIS, PSIDIV3, and PSIK.

  • Key features include configuration of all bus prescalers, highly flexible peripheral kernel clock control, clock security system management (CSS), low-power clock gating and system reset to default states.

  • Peripheral clock management APIs allow enabling, disabling, and resetting clocks on various buses (AHB, APB) with fine-grained control.

  • Privileged access levels attributes management functions allow configuration of privileged and public access rights to RCC resources.

  • The HAL RCC driver ensures some degree of portability and consistent behavior across STM32C5xx microcontroller series for common features, facilitating robust, privilege, and power-efficient clock and reset management in diverse embedded applications.

Module and files

The following diagram illustrates the RCC module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the RCC module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.

@startuml
<style>
componentDiagram {
   arrow {
      FontSize 8
   }
}
</style>

title RCC Software Component Diagram

package "HAL/LL" {
    [HAL_SERVICE]
    [HAL_RCC]
    [LL_RCC]
}

package "Low Layer" {
    [CMSIS]
    [RCC Interrupt routine service]
}

package "HW" {
    [STM32_HW]
}

[Appli] --> [HAL_RCC] : HAL RCC API
[Appli] <-- [HAL_RCC] : HAL RCC callback
[HAL_RCC] --> [LL_RCC] : LL RCC API
[HAL_RCC] --> [CMSIS]: direct access
[HAL_RCC] -l-> [HAL_SERVICE] : HAL_GetTick
[HAL_RCC] <-- [RCC Interrupt routine service]
[LL_RCC] --> [CMSIS]:RCC register def
[STM32_HW] -u--> [RCC Interrupt routine service]: RCCx Irq
[STM32_HW] <-u-- [LL_RCC] : RCC registers R/W
@enduml

Configuration table

The following table lists the configuration defines for the HAL RCC module, specifying their locations, default values, and descriptions:

group RCC_Configuration_Table

Configuration inside the RCC driver

Config defines

Description

Default value

Note

PRODUCT

from IDE

Defined

The selected product (ex STM32C562xx)

PERIPHERAL

from CMSIS

Defined

Peripheral available on the selected product

USE_ASSERT_DBG_PARAM

from IDE

None

When defined, enable the params assert

USE_HAL_CHECK_PARAM

from hal_conf.h

0

When set, parameters are checked in runtime

USE_HAL_RCC_MODULE

from hal_conf.h

1

When set, HAL RCC module is enabled

USE_EXTERNAL_ENV

from IDE

Defined

When set, ext. oscillators values are defined

LSE_VALUE

From stm32_external_env.h

32 KHz

Frequency of LSE oscillator (USE_EXTERNAL_ENV)

HSE_VALUE

From stm32_external_env.h

24 or 48 MHz

Frequency of HSE oscillator (USE_EXTERNAL_ENV)

HSI_VALUE

st32c5xxxx.h

144 MHz

Frequency of HSI oscillator

HSI48_VALUE

st32c5xxxx.h

48 MHz

Frequency of HSI48 oscillator

HSI_RESET_VALUE

st32c5xxxx.h

48 MHz

Frequency of system core clock after reset

USE_HAL_RCC_RESET_PERIPH_CLOCK_MANAGEMENT

from hal_conf.h

0

When set, RCC peripherals configuration reset

USE_HAL_RCC_RESET_RTC_DOMAIN

from hal_conf.h

0

When set, Resources under backup domain reset