cancel
Showing results for 
Search instead for 
Did you mean: 

How does STM32CubeMX determine my peripheral’s maximum frequency range as seen in the clock tree?

Stefanie LAU
ST Employee

How does STM32CubeMX determine my peripheral’s maximum frequency range as seen in the clock tree?

Introduction

One of the many features included in STM32CubeMX is the ability to allow users to select and configure the MCU’s or MPU’s clocks through a GUI (graphical user interface).

 

In the clock configuration tab, users can:

  • select from various clock sources
  • apply different pre-scalers to adjust the clock sources to various peripherals and buses
  • configure individual peripheral frequencies with the click of a button

The clock tree configuration feature is “smart” in the sense that it can detect errors in clock configuration, highlight and report these errors to the user and automatically run its resolver to help fix the configuration issues.
For example, here in this .ioc file (STM32CubeMX’s file extension) we see several peripheral’s clock configurations highlighted in pink. In addition, we also can see a ‘x’ in a circle next to our clock configuration tab. This is STM32CubeMX’s way of letting us know that it detects a clock configuration issue.
969.png
To receive some additional information on what is wrong with the configuration, simply use the mouse to hover over the highlighted pink boxes. STM32CubeMX will then report more on the error(s) detected.
971.png
We’ve figured out what the exact issue is with the clock configuration, but now the question is: how does STM32CubeMX determine that the SAI2 and SAI3’s clock source frequency must be =< 75MHZ?
In every device’s reference manual depending on additional STM32 configuration(s) selected, users can find a list of peripherals and its’ maximum frequency.
In our example above, we’ve selected to configure the STM32H753IIKx device. This means that we need to refer to its corresponding reference manual, RM0433 “STM32H742, STM32H743/753 and STM32H750 Value line advanced Arm-based 32-bit MCUs” for the list of the device’s peripherals and maximum allowed frequency list.
In RM0433, Table 59. Kernel clock distribution overview provides the exact information we’re looking for:
972.png
In table 59 we see that the maximum frequency of SAI2 and SAI3 can go up to 150MHz, but only if the device’s VOS (run mode voltage scaling) is configured as VOS0. A maximum frequency of 75MHz is allowed if the device’s VOS is configured as VOS3.
Earlier we didn’t confirm the device’s configured VOS, so let’s do that now. To configure the device’s VOS or check the current VOS configurations, follow the steps below:
 

Step 1. In STM32CubeMX, start by navigating to the Pinout & Configuration tab.

974.png

 

Step 2.On the most left-hand side of the screen navigate to the ‘categories’ tab, click to expand on the system core section, and select ‘RCC’.

976.png
 

Step 3. Now in the middle of the screen, look under the configuration section and in particular focus on the power parameters section.

977.png

Step 4. From this configuration window, you will now be able to select and configure the device’s power regulator voltage scale as desired.

978.png
Upon reviewing the example .ioc file and the device’s configured power regulator voltage scale as VOS3, now it makes sense why STM32CubeMX was showing an error message when we tried to configure the SAI2 and SAI3’s peripheral to be 100MHZ.
To resolve the clock configuration error, we simply can adjust the power regulator voltage scale configuration to VOS2 and above or reduce the SAI2 and SAI3’s peripheral’s voltage in the clock configuration tree to be 75MHz or less.

Relevant Documentation and Links


STM32CubeMX is a graphical tool that allows users to configure STM32 MCUs (microcontrollers) and MPUs (microprocessors) quickly and simply. In addition, the tool also assists in generating the corresponding initialization C code for the Arm Cortex-M core(s) or partial Linux device tree for Arm Cortex-A cores.
Version history
Last update:
‎2022-11-10 06:59 AM
Updated by: