STM32CubeMX

Table Of Contents

- STM32CubeMX documentation
- CubeMX User Manual
  - 1 STM32Cube overview
  - 2 Getting started with STM32CubeMX
  - 3 Installing and running STM32CubeMX
  - 4 STM32CubeMX user interface
  - 5 STM32CubeMX tools
  - 6 STM32CubeMX C Code generation overview
  - 7 Code generation for dual-core MCUs (STM32H7 dual-core product lines only)
  - 8 Code generation with TrustZone enabled (STM32L5 series only)
  - 9 Device tree generation (STM32MPUs only)
  - 10 Support of additional software components using CMSIS-Pack standard
  - 11 Tutorial 1: From pinout to project C code generation using an MCU of the STM32F4 series
  - 12 Tutorial 2 - Example of FatFs on an SD card using STM32429I-EVAL evaluation board
  - 13 Tutorial 3 - Using the Power Consumption Calculator to optimize the embedded application consumption and more
  - 14 Tutorial 4 - Example of UART communications with an STM32L053xx Nucleo board
  - 15 Tutorial 5: Exporting current project configuration to a compatible MCU
  - 16 Tutorial 6 - Adding embedded software packs to user projects
  - 17 Tutorial 7 - Using the X-Cube-BLE1 software pack
  - 18 Creating LPBAM projects
  - Appendix A STM32CubeMX pin assignment rules
  - Appendix B STM32CubeMX C code generation design choices and limitations
  - Appendix C STM32 microcontrollers power consumption parameters
  - Appendix D STM32Cube embedded software packages
  - Revision history
- Release Notes
  - Release details
  - Release fixes
  - Known limitations
    - Miscellaneous
    - 2.1. When selecting microcontrollers in the STM32C0 series
    - 2.2. When selecting microcontrollers in the STM32G0 series
    - 2.3. When selecting microcontrollers in the STM32G4 series
    - 2.4. When selecting microcontrollers in the STM32H5 series
    - 2.5. When selecting microcontrollers in the STM32H7 series
    - 2.6. When selecting dual-core microcontrollers in the STM32H7 series
    - 2.7. When selecting microcontrollers in the STM32L5 series
    - 3.4. How to improve the wake-up from Stop sequences without relying on the global SystemClock_Config()
    - 3.3. List pinout-compatible microcontrollers
    - 3.2. DDR binaries for the STM32MP1 boards
    - 3.1. Command line authentication required
    - 2.21. Symbolic links on Ubuntu
    - 2.20. User manual
    - 2.19. DDR test suite
    - 2.18. STM32CubeIDE toolchain
    - 2.13. When selecting microcontrollers in the STM32WL series
    - 2.11. When selecting microcontrollers in the STM32WB series
    - 2.17. When using additional software packs
    - 2.16. When using the Example Selector
    - 2.15. When using the Memory Management Tool
    - 2.14. When selecting microprocessors in the STM32MP1 series
    - 2.11.1. When selecting microcontrollers in the STM32WB0 product lines
    - 2.12. When selecting microcontrollers in the STM32WBA series
    - 2.13.1. When selecting microcontrollers in the STM32WL33 product lines
    - 2.10. When selecting microcontrollers in the STM32U5 series
    - 2.9. When selecting microcontrollers in the STM32U3 series
    - 2.8. When selecting microcontrollers in the STM32N6 series
- Running STM32CubeMX in command-line mode
- FAQ
- Community

### On this page

- 5.1 External Tools
- 5.2 Compare Projects
  - 5.2.1 User interface of the Compare Projects tool
    - Figure 365. Compare the current non saved project with another project
  - 5.2.3 The output of the comparison
  - 5.2.4 Saving the comparison result of the two projects
    - Figure 370. Choosing the Excel format to save the comparison result
    - Figure 372. Comparison result in Excel format - Peripherals and middleware
- 5.3 Power Consumption Calculator view
  - 5.3.1 Building a power consumption sequence
    - Figure 374. Power Consumption Calculator default view
    - Selecting a battery model (optional)
    - Managing sequence steps
    - Adding a step
    - Moving a step
    - Using the transition checker
  - 5.3.2 Configuring a step in the power sequence
    - Using interpolation
    - Importing pinout
    - Selecting/deselecting all peripherals
  - 5.3.3 Managing user-defined power sequence and reviewing results
    - Figure 384. Power Consumption Calculator view after sequence building
    - Managing the whole sequence (load, save and compare)
    - Managing the results charts and display options
    - Overview of the Results summary area

# 5 STM32CubeMX tools

## 5.1 External Tools

> This panel is accessible from the home page. It provides an overview of the tools relevant for the STM32 product portfolio (see Figure 356):

## 5.2 Compare Projects

> This new feature is designed to enable the comparison of two projects, based on the same or on different microcontrollers. This tool allows users to efficiently analyze and correlate similarities and differences in IP configurations and project structure between two projects.

### 5.2.1 User interface of the Compare Projects tool

> The user can activate this function from the Tools panel by clicking the Compare Projects field (see Figure 357), or from the home page (see Figure 358) by clicking ACCESS TO COMPARE PROJECT under Other services (even before creating any project).

> Figure 357. Reaching Compare Project from the Tools panel

> The tool is composed of:

- Two main panels, named Project 1 and Project 2.

  - Each field contains a “Browse” button from where we can load the desired .ioc file.

  - The check box “Use Current project” in the first panel is to use the opened project in STM32CubeMX instead of loading a saved one in the local device.

- Three check boxes, named Project 1, Project 2, and “Show differences only”:

  - Once the second project is loaded, the Project 1 and Project 2 check boxes are checked systematically, indicating that the output table contains all the parameters of Project 1 and Project 2 (whether they are different or not).

  - If the user wants to see only the parameters that are different between the two projects, it can check “Show differences only”.

- Refresh button: once clicked, it performs an instantiated comparison. • Export button: allows users to save or transfer the result of the comparison to an external file in Excel format.

> Figure 359. User interface of the Compare Projects tool

1. Load the first project from the local device (Figure 360).

   - Once the first .ioc is loaded, a popup appears to indicate the need to upload the second .ioc.

2. Load the second project (Figure 361).

   - After uploading the second .ioc file, the output is displayed in the UI (Figure 362).

   - If the user uploads the same .ioc file (having the same path) into the two fields, a popup appears to indicate that it is irrelevant to perform a comparison (Figure 363).

   - If the two projects have the same structure and the user checks “Show differences only”, only the headers of the respective tables “Target”, “Peripherals & Middleware”, and “Project Settings” are shown, no data are displayed (Figure 364).

> Figure 364. The result of comparing two projects having the same structure

> The user has the following options for comparing a current project:

1. Load a project from local and start comparing it as the current project (Project 1).

2. Compare a newly created project (after configuration), even unsaved, with a saved project, see Figure 365.

3. Compare a currently open project with itself (the popup blocking the comparison of two similar projects does not appear), see Figure 366:

   1. Load a the first project saved on the local as the current project (current project automatically ticked and the configuration can be modified after loading)

   2. Load the same project file from the local in the Project 2 field.

#### Figure 365. Compare the current non saved project with another project

### 5.2.3 The output of the comparison

> After starting the comparison, the following elements are added to the UI:

> Target table ( Figure 367): provides a comparison of the parameters used in each project. It clearly shows differences in:

- Part numbers

- Number of IOs

- Package types

- Core configurations

- Available flash memory sizes

> The Target table is composed of 3 column:

- Structure: a listing of the MCU parameters.

- Project 1: the values corresponding to the MCU parameters of the first project.

- Project 2: the values corresponding to the MCU parameters of the second project.

> The user has the option to:

- Side-by-side comparison: showing data from both projects simultaneously.

- Individual inspection: inspect each file separately by selecting the Project 1 or Project 2 checkbox.

- Focus on differences: exclusively view the differences between 2 projects by checking ‘Show differences only’.

> The Target table offers a quick and straightforward overview of key differences between the two projects. It represents an invaluable tool for project migrations and initial hardware evaluations.

> Peripherals & Middleware table ( Figure 368): displays the differences and similarities in the configuration of each peripheral or middleware used in the two projects (the subparameters and the corresponding values).

> The data are presented by lines. It is composed of the following columns:

- Category name

- IP name

- Mode

- Parameters settings

- Project 1

- Project 2

> The table includes a highlighting feature, which uses color coding to visually differentiate parameters:

- Specific parameters for project 1 are marked in blue color

- Specific parameters for project 2 are marked in pink color

- The common parameters for the two projects are marked in black color

> All peripheral categories are displayed collectively, with the option of sorting in alphabetical order.

> Project Settings table ( Figure 369), helping the users to know the software environment required for each project, and to determine the necessary tools for ensuring project compatibility and facilitating migration. The table contains information about the firmware package used for each MCU and about the toolchain used for building each project.

> It is composed of three columns:

- Settings:

- CustomerFirmwarePackage

- FirmewarePackage

- ProjectStructure

- TargetToolchain

- Project 1

- Project 2

> Figure 369. Project Settings table

### 5.2.4 Saving the comparison result of the two projects

> In the user interface of the “Compare Projects” tool, there is an Export button that allows users to save the result of the comparison in an external Excel file.

> By clicking the Export button, a window named Save appears to allow the user to choose a name for the resulting file and save it ( Figure 370).

> The available format:

- The result is exported into three sheets in an Excel format (Figure 371).

- Each sheet represents a table (Target, Peripherals & Middleware, Projects Settings).

> If the user wants to get only the differences in the exported file, they should click on “Show differences only”.

#### Figure 370. Choosing the Excel format to save the comparison result

#### Figure 372. Comparison result in Excel format - Peripherals and middleware

## 5.3 Power Consumption Calculator view

> For an ever-growing number of embedded systems applications, power consumption is a major concern. To help minimizing it, STM32CubeMX offers the Power Consumption Calculator tab (see Figure 374), which, given a microcontroller, a battery model and a user-defined power sequence, provides the following results:

- Average current consumption

> Power consumption values can be taken from the datasheet or interpolated from a user specified bus or core frequency.

- Battery life

- Average DMIPs

> DMIPs values are directly taken from the MCU datasheet and are neither interpolated nor extrapolated.

- Maximum ambient temperature (TAMAX)

> According to the chip internal power consumption, the package type, and a maximum junction temperature of 105 °C, the tool computes the maximum ambient temperature to ensure good operating conditions.

> Current T AMAX implementation does not account for I/O consumption. For an accurate estimate, I/O consumption must be specified using the Additional Consumption field. The formula for I/O dynamic current consumption is specified in the microcontroller datasheet.

> The Power Consumption Calculator view allows developers to visualize an estimate of the embedded application consumption and lower it further at each power sequence step:

- make use of low power modes when available

- adjust clock sources and frequencies based on the step requirements • enable only the peripherals necessary for each phase.

> For each step the user can choose V BUS as possible power source instead of the battery, impact battery life. If power consumption measurements are available at different voltage levels, STM32CubeMX also proposes a choice of voltage values (see Figure 377).

> An additional option, the transition checker, is available for STM32L0, STM32L1, STM32L4, STM32L4+, STM32G0, STM32G4, STM32H7 and STM32WB series. When enabled, the transition checker detects invalid transitions within the currently configured sequence. It ensures that only possible transitions are proposed to the user when a new step is added.

### 5.3.1 Building a power consumption sequence

> The default starting view is shown in Figure 374.

#### Figure 374. Power Consumption Calculator default view

Selecting a VDD value

> From this view and when multiple choices are available, the user must select a V DD value.

#### Selecting a battery model (optional)

> Optionally, the user can select a battery model. This can also be done once the power consumption sequence is configured.

> The user can select a predefined battery or choose to specify a new battery that best matches its application (see Figure 375).

> Figure 375. Battery selection

Power sequence default view

> The user can now proceed and build a power sequence.

#### Managing sequence steps

> Steps can be reorganized within a sequence ( Add new, Delete a step, Duplicate a step, move Up or Down in the sequence) using the set of Step buttons (see Figure 376).

> The user can undo or redo the last configuration actions by clicking the Undo button in the Power Consumption Calculator view or the Undo icon from the main toolbar

> Figure 376. Step management functions

#### Adding a step

> There are two ways to add a new step:

- Click Add in the Power Consumption panel. The New Step window opens with empty step settings.

- Or, select a step from the sequence table and click Duplicate. A New Step window opens duplicating the step settings (see Figure 377).

> Figure 377. Power consumption sequence: New Step default view

> Once a step is configured, resulting current consumption and T AMAX values are provided in the window.

Editing a step

> To edit a step, double-click it in the sequence table, this opens the Edit Step window.

#### Moving a step

> By default, a new step is added at the end of a sequence. Click the step in the sequence table to select it and use the Up and Down buttons to move it elsewhere in the sequence. Deleting a step

> Select the step to be deleted and click the Delete button.

#### Using the transition checker

> Not all transitions between power modes are possible. The Power Consumption Calculator power menu proposes a transition checker to detect invalid transitions or restrict the sequence configuration to only valid transitions.

> Enabling the transition checker option prior to sequence configuration ensures that the user will be able to select only valid transition steps.

> Enabling the transition checker option on an already configured sequence will highlight the sequence with a green frame if all transitions are valid (see Figure 378), or in fuchsia if at least one transition is invalid (fuchsia frame with description of invalid step highlighted in fuchsia, see Figure 379). In the latter case, the user can click the Show log button to find out how to solve the transition issue (see Figure 380).

> Figure 378. Enabling the transition checker option on an already configured sequence - All transitions valid

> Figure 379. Enabling the transition checker option on an already configured sequence - At least one transition invalid

### 5.3.2 Configuring a step in the power sequence

> The step configuration is performed from the Edit Step and New Step windows. The graphical interface guides the user by forcing a predefined order for setting parameters.

> Their naming may differ according to the selected MCU series. For details on each parameter, refer to glossary in Section 5.3.4 and to Appendix C, or to the electrical characteristics section of the datasheet.

> The parameters are set automatically by the tool when there is only one possible value (in this case, the parameter cannot be modified and is grayed out). The tool proposes only the configuration choices relevant to the selected MCU.

> To configure a new step:

1. Click Add or Duplicate to open the New step window or double-click a step from the sequence table to open the Edit step window.

2. Within the open step window, select in the following order:

- The Power Mode

  > Changing the Power Mode resets the whole step configuration.

- The Peripherals

> Peripherals can be selected/deselected at any time after the Power Mode is configured.

- The Power scale

> The power scale corresponds to the power consumption range (STM32L1) or the power scale (STM32F4).

> Changing the Power Mode or the Power Consumption Range discards all subsequent configurations.

- The Memory Fetch Type

- The VDD value if multiple choices available

- The voltage source (battery or VBUS)

- A Clock Configuration

> Changing the Clock Configuration resets the frequency choices further down.

- When multiple choices are available, the CPU Frequency (STM32F4) and the AHB Bus Frequency/CPU Frequency(STM32L1) or, for active modes, a user specified frequency. In this case, the consumption value will be interpolated (see Using interpolation).

3. Optionally set

   - A step duration (1 ms is the default value)

   - An additional consumption value (expressed in mA) to reflect, for example, external components used by the application (external regulator, external pull-up, LEDs or other displays). This value added to the microcontroller power consumption will impact the step overall power consumption.

4. Once the configuration is complete, the Add button becomes active. Click it to create the step and add it to the sequence table.

#### Using interpolation

> For steps configured for active modes (Run, Sleep), frequency interpolation is supported by selecting CPU frequency as User Defined and entering a frequency in Hz (see Figure 381).

> Figure 381. Interpolated power consumption

#### Importing pinout

> Figure 382 illustrates the example of the ADC configuration in the Pinout view: clicking Enable IPs from Pinout in the Power Consumption Calculator view selects the ADC peripheral and GPIO A ( Figure 383).

> The Enable IPs from Pinout button allows the user to automatically select the peripherals that have been configured in the Pinout view.

#### Selecting/deselecting all peripherals

> Clicking Enable All IPs allows the user to select all peripherals at once.

> Clicking Disable All IPs removes them as contributors to the consumption.

> Figure 383. Power Consumption Calculator configuration window:

> ADC enabled using import pinout

### 5.3.3 Managing user-defined power sequence and reviewing results

> The configuration of a power sequence leads to an update of the Power Consumption Calculator view (see Figure 384):

- The sequence table shows all steps and step parameters values. A category column indicates whether the consumption values are taken from the datasheet or are interpolated.

- The sequence chart area shows different views of the power sequence according to a display type (e.g. plot all steps, plot low power versus run modes)

- The results summary provides the total sequence time, the maximum ambient temperature (TAMAX), plus an estimate of the average power consumption, DMIPS, and battery lifetime provided a valid battery configuration has been selected.

#### Figure 384. Power Consumption Calculator view after sequence building

#### Managing the whole sequence (load, save and compare)

> From the power menu (see Figure 385), the current sequence can be saved, deleted or compared to a previously saved sequence that will be displayed in a dedicated popup window.

Figure 385. Sequence table management functions

#### Managing the results charts and display options

> In the Display area, select the type of chart to display (e.g. sequence steps, pie charts, consumption per peripherals). You can also click External Display to open the charts in dedicated windows (see Figure 386).

> Right-click on the chart to access the contextual menus: Properties, Copy, Save as png picture file, Print, Zoom menus, and Auto Range to reset to the original view before zoom operations. Zooming can also be achieved by mouse selecting from left to right a zone in the chart and Zoom reset by clicking the chart and dragging the mouse to the left.

> Figure 386. Power Consumption: Peripherals consumption chart

#### Overview of the Results summary area

> This area provides the following information (see Figure 387):

- Total sequence time, as the sum of the sequence steps durations.

- Average consumption, as the sum of each step consumption weighed by the step duration.

- The average DMIPS (Dhrystone million instructions per second) based on Dhrystone benchmark, highlighting the CPU performance for the defined sequence.

- Battery life estimation for the selected battery model, based on the average power consumption and the battery self-discharge.

- TAMAX: highest maximum ambient temperature value found during the sequence.