Skip to content

XPD Clock Management

IntergatedCircuits edited this page Nov 23, 2017 · 4 revisions

The STM32 device clocks management is a complex system with broad-ranging capabilities that are all controlled by the Reset and Clock Control (RCC) module. These functions can be separated to three distinct responsibilities, each of which are explained in a chapter below.

1 - System level clock sources control

The Core Clocks (CC) submodule of the XPD RCC drivers provides the necessary API to control the system oscillators and the system core clocks which are clocking the MCU core and the internal peripheral buses. Additionally, this submodule hosts the API for the following RCC-provided features:

  • Clock Security System (CSS)
  • Master Clock Output(s) (MCO)
  • Reset of all peripherals of an internal bus
  • Reading of system reset source(s)

A short walkthrough of the system clocks setup is presented here.

2 - Reset and clocking control of peripherals

The peripheral reset and clocking control API serves to reset and to enable or disable the clock of individual peripherals. An RCC_POS_{PERIPH} symbol is defined for each peripheral, which specifies the (clock) control bit position - relative to the first control bit. These symbols are automatically bound to the peripheral handles (when initialized via the NEW_{PERIPH}_HANDLE()), therefore the XPD API user does not have to bother with the clocking control. The peripheral's clock is always enabled within the XPD_{PERIPH}_Init(), and disabled within the XPD_{PERIPH}_Deinit() API call.

3 - Clock source configuration of selected peripherals

In order to achieve higher clock accuracy or frequency, certain peripherals have a multitude of clock sources available to select from. The Peripheral clock source (PC) submodules of these peripherals are implemented in the xpd_rcc_pc.c source files, as the configuration is done in the RCC module. However, the API definitions are included in each peripheral's respective namespaces (i.e. visible when xpd_{periph}.h is included), as each clock source configuration is only relevant for the given peripheral. The API typically consists of two functions:

  • XPD_{PERIPH}_ClockConfig() sets the selected clock source for the peripheral instance or type
  • XPD_{PERIPH}_GetClockFreq() calculates the peripheral's input clock frequency in Hz

+1 - Clock Recovery System

Although the CRS appears as a separate peripheral module, it is considered as part of the RCC functionality as it's sole purpose is to monitor and fine-tune the internal HSI48 oscillator. This module is not present on devices without an HSI48 oscillator.

Powered by STM32

Clone this wiki locally