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

- A.1 Block consistency
  - Example of block mapping with an STM32F107x MCU
  - Example of block remapping with an STM32F107x MCU
    - Figure 730. Block remapping - Example 1
- A.2 Block inter-dependency
  - Example of block remapping of SPI in full-duplex master mode with an STM32F107x MCU
    - Figure 732. Block inter-dependency - SPI signals assigned to PB3/4/5
    - Figure 733. Block inter-dependency - SPI1_MISO function assigned to PA6
- A.3 One block = one peripheral mode
  - Example of STM32F107x MCU
- A.4 Block remapping (STM32F10x only)
  - Example
- A.5 Function remapping
  - Example using STM32F415x
- “Keep Current Signals placement” is unchecked)
  - Example
- A.7 Setting and clearing a peripheral mode
- A.8 Mapping a function individually

# Appendix A STM32CubeMX pin assignment rules

The following pin assignment rules are implemented in STM32CubeMX:

- Rule 1: Block consistency

- Rule 2: Block inter-dependency

- Rule 3: One block = one peripheral mode

- Rule 4: Block remapping (only for STM32F10x)

- Rule 5: Function remapping

- Rule 6: Block shifting (only for STM32F10x)

- Rule 7: Setting or clearing a peripheral mode

- Rule 8: Mapping a function individually (if Keep Current Placement is unchecked)

- Rule 9: GPIO signals mapping

## A.1 Block consistency

> When setting a pin signal (provided there is no ambiguity about the corresponding peripheral mode), all the pins/signals required for this mode are mapped and pins are shown in green (otherwise the configured pin is shown in orange).

> When clearing a pin signal, all the pins/signals required for this mode are unmapped simultaneously and the pins turn back to gray.

### Example of block mapping with an STM32F107x MCU

> If the user assigns I2C1_SMBA function to PB5, then STM32CubeMX configures pins and modes as follows:

- I2C1_SCL and I2C1_SDA signals are mapped to the PB6 and PB7 pins, respectively (see Figure 728).

- I2C1 peripheral mode is set to SMBus-Alert mode.

> Figure 728. Block mapping

### Example of block remapping with an STM32F107x MCU

> If the user assigns GPIO_Output to PB6, STM32CubeMX automatically disables I2C1 SMBus-Alert peripheral mode from the peripheral tree view and updates the other I2C1 pins (PB5 and PB7) as follows:

- If they are unpinned, the pin configuration is reset (pin grayed out). • If they are pinned, the peripheral signal assigned to the pins is kept and the pins are highlighted in orange since they no longer match a peripheral mode (see Figure 729).

  > Figure 729. Block remapping

#### Figure 730. Block remapping - Example 1

## A.2 Block inter-dependency

> On the Pinout view, the same signal can appear as an alternate function for multiple pins. However it can be mapped only once.

> As a consequence, for STM32F1 MCUs, two blocks of pins cannot be selected simultaneously for the same peripheral mode: when a block/signal from a block is selected, the alternate blocks are cleared.

### Example of block remapping of SPI in full-duplex master mode with an STM32F107x MCU

> If SPI1 full-duplex master mode is selected from the tree view, by default the corresponding SPI signals are assigned to PB3, PB4 and PB5 pins (see Figure 732).

> If the user assigns to PA6 the SPI1_MISO function currently assigned to PB4,

> STM32CubeMX clears the PB4 pin from the SPI1_MISO function, as well as all the other pins configured for this block, and moves the corresponding SPI1 functions to the relevant pins in the same block as the PB4 pin (see Figure 733).

> (by pressing CTRL and clicking PB4 to show PA6 alternate function in blue, then drag and drop the signal to pin PA6)

#### Figure 732. Block inter-dependency - SPI signals assigned to PB3/4/5

#### Figure 733. Block inter-dependency - SPI1_MISO function assigned to PA6

## A.3 One block = one peripheral mode

> When a block of pins is fully configured in the Pinout view (shown in green), the related peripheral mode is automatically set in the Peripherals tree.

### Example of STM32F107x MCU

> Assigning the I2C1_SMBA function to PB5 automatically configures I2C1 peripheral in SMBus-Alert mode (see Peripheral tree in Figure 734).

> Figure 734. One block = one peripheral mode - I2C1_SMBA function assigned to PB5

## A.4 Block remapping (STM32F10x only)

> To configure a peripheral mode, STM32CubeMX selects a block of pins and assigns each mode signal to a pin in this block. In doing so, it looks for the first free block to which the mode can be mapped.

> When setting a peripheral mode, if at least one pin in the default block is already used,

> STM32CubeMX tries to find an alternate block. If none can be found, it either selects the

> functions in a different sequence, or unchecks , and remaps all the blocks to find a solution.

### Example

> STM32CubeMX remaps USART3 hardware-flow-control mode to the (PD8-PD9-PD11PD12) block, because PB14 of USART3 default block is already allocated to the SPI2_MISO function (see Figure 735).

## A.5 Function remapping

> To configure a peripheral mode, STM32CubeMX assigns each signal of the mode to a pin. In doing so, it will look for the first free pin the signal can be mapped to.

### Example using STM32F415x

When configuring USART3 for the Synchronous mode, STM32CubeMX discovered that the default PB10 pin for USART3_TX signal was already used by SPI. It thus remapped it to PD8 (see Figure 736).

A.6 Block shifting (only for STM32F10x and when

## “Keep Current Signals placement” is unchecked)

> If a block cannot be mapped and there are no free alternate solutions, STM32CubeMX tries to free the pins by remapping all the peripheral modes impacted by the shared pin.

### Example

With the Keep current signal placement enabled, if USART3 synchronous mode is set first, the Asynchronous default block (PB10-PB11) is mapped and Ethernet becomes unavailable (shown in red) (see Figure 737).

> Unchecking allows STM32CubeMX shifting blocks around and freeing a block for the Ethernet MII mode. (see Figure 738).

## A.7 Setting and clearing a peripheral mode

> The Peripherals panel and the Pinout view are linked: when a peripheral mode is set or cleared, the corresponding pin functions are set or cleared.

## A.8 Mapping a function individually

> When STM32CubeMX needs a pin that has already been assigned manually to a function (no peripheral mode set), it can move this function to another pin, only if is unchecked and the function is not pinned (no pin icon).