4д. A map of the STM32CubeMX windows: what is configured where
The classic STM32CubeMX 6 shows up in almost every section of the handbook: in one it enables a UART, in another it sets up DMA, in a third it produces a project for CMake. But each section looks into one or two windows, and the program as a whole is described nowhere. That makes it hard for a beginner: it is unclear in which tab to look for the checkbox you need and where to go and read next.
This section is a guide to the windows. For each window: what it is for, what is done in it, where people usually stumble and in which section the topic is covered in detail. The program here is CubeMX 6 for all series except C5, G5 and H7P; those have their own STM32CubeMX 2 (section 4г).
Sources: the UM1718 user manual (Rev 50, February 2026) — the pages
are given with every statement; the STM32CubeMX 6.18.1 database (the db folder,
database release DB.6.0.181): MCU and board descriptions, clock trees, battery
models, the toolchain list and the debug pin modes of the STM32F103.
What it is called in the documentation
Original Meaning New Project window the window for choosing an MCU, a board or an example for a new project MCU Selector MCU search by series, package, memory and peripherals Board Selector ST board search: the MCU and its pins are filled in at once Example Selector a new project from a ready-made ST example Cross Selector finding an STM32 replacement for a foreign or old part Pinout & Configuration the pins and peripherals tab Component list the left-hand list of blocks and middleware, by category Mode panel a block's mode panel: which signals and on which pins Configuration panel a block's parameter panel: speed, width, interrupts Keep Current Signals Placement do not move already assigned signals when new modes are added Clock Configuration the clock tree tab Project Manager the tab for name, toolchain and generation rules Advanced Settings tab the order of init calls and the choice of HAL or LL Power Consumption Calculator an estimate of current and battery life, step by step In plain words. CubeMX is a questionnaire about the chip. First you choose the chip itself, then you tick which blocks you need and on which pins, then you draw the frequencies, then you say which environment the project is for. The button at the bottom of the questionnaire writes the code. Here: where each sheet of the questionnaire is and where to read how to fill it in correctly.
4д.1 Windows and the order of work
CubeMX 6 has two levels of windows. First, the home window and the new project window: that is where the MCU or the board is chosen. Then the project window opens with four tabs at the top: Pinout & Configuration, Clock Configuration, Project Manager and Tools. At the top right is the GENERATE CODE button.
The order for a new project is always the same:
| Step | Window | What is done | Details in |
|---|---|---|---|
| 1 | New Project | choose an MCU or a board | sections 2, 2ж, 0ж |
| 2 | Pinout & Configuration | debug in SYS, crystal in RCC, block modes | sections 8, 7, 9 |
| 3 | Clock Configuration | core and bus frequencies | sections 6, 174 |
| 4 | Project Manager | name, folder, toolchain, code options | sections 4б, 115а |
| 5 | GENERATE CODE | the project on disk | sections 4б, 115а |
Steps 2 and 3 are linked: an external crystal is first enabled in RCC on the pins
tab, and only after that does its branch come alive in the clock tree. Everything
chosen is kept in a single .ioc file — it is opened again, the settings are changed
and the code is generated anew.
4д.2 Choosing the MCU and the board
The New Project window opens from the home window. It has four tabs (UM1718, p. 71):
- MCU Selector — MCU search. Filters: series, line, package, peripherals, memory size, number of pins, price (p. 72). If the part number is known, it is simply typed into the search-by-part-number field — the list narrows down to one or two packages. The table of results can be exported to Excel, and the parts you need can be marked with a star (p. 73). The CubeMX 6.18.1 database has 2240 MCU descriptions.
- Board Selector — ST board search by type, series and peripherals (p. 74). Once a board is chosen, both the MCU and the pins of the LEDs, buttons and debug UART are already assigned and pinned: CubeMX will not move them on its own. The database has 277 board presets.
- Example Selector — a project from an ST example for a specific board. Some examples are marked as unfinished: a project made from them may not build (p. 75).
- Cross Selector — a replacement: you give the part number of a foreign or old chip, CubeMX suggests a close STM32 (p. 71).
Which MCU to take is covered in section 2, the BlackPill board in section 2ж, the first purchase and the first project in section 0ж. For STM32L5 the selection also asks whether to enable TrustZone (p. 71); what that changes is in sections 2б and 2е.
Typical mistakes. The wrong package is chosen: the F103C8 and F103R8 have the same memory, but 48 and 64 pins, and a project will not fit a different package. A clone board (BluePill, BlackPill) will not be found in Board Selector — it is started from the MCU in MCU Selector, and the LED and the crystal are assigned by hand.
4д.3 Pinout & Configuration: pins, peripherals, GPIO, NVIC, DMA
The main tab. On the left is the list of blocks (Component list), alphabetical or by category: System Core, Analog, Timers, Connectivity, Middleware and Software Packs and others — the set depends on the MCU (p. 214, 552). On the right is a picture of the package (Pinout view). Between them are the Mode and Configuration panels of the selected block (UM1718, p. 87).
Block mode. The Mode panel selects how a block works: a UART — asynchronous or synchronous, a timer — with which channels. CubeMX itself looks for pins for the signals and highlights conflicts (p. 90). A block in grey italics is unavailable: its pins are already taken; the tooltip on the name explains by what. Middleware (USB, FatFs, LwIP) can be enabled only after the mode of its block: first USB or SDIO, then the stack (p. 90).
Pins by hand. Clicking a pin in the picture gives a list of its functions — this is how GPIO_Output, GPIO_EXTI and alternate functions are assigned. The Keep Current Signals Placement checkbox in the Pinout menu forbids CubeMX to move already assigned signals; by default it is cleared, and it is set when the board is already routed (p. 95).
SYS and RCC are the first two items of System Core. SYS selects the debug interface and the HAL time base source (Timebase Source). RCC enables the external HSE crystal and the LSE watch crystal — without this they are absent from the clock tree (p. 181). For the STM32F103 the database has 11 modes of the Debug item, and each turns into its own call in the initialization code:
No Debug -> __HAL_AFIO_REMAP_SWJ_DISABLE
Serial Wire -> __HAL_AFIO_REMAP_SWJ_NOJTAG
JTAG (4 pins) -> __HAL_AFIO_REMAP_SWJ_NONJTRST
JTAG (5 pins) -> __HAL_AFIO_REMAP_SWJ_ENABLE
GPIO. The GPIO window (a button in System view or the System Core category)
sets the initial output level, the mode, the pull, the speed and your own name for
the pin (User Label). The default speed is Low, to save power; for SPI
at tens of megahertz it is raised (p. 107). Your own name ends up in main.h
as LED_Pin and LED_GPIO_Port. Pin electrics are in section 8, connecting
sensors in section 95.
NVIC. The window shows only the interrupts of enabled blocks; system ones
cannot be disabled (p. 111). The checkbox enables the calls HAL_NVIC_SetPriority and
HAL_NVIC_EnableIRQ. With FreeRTOS a column appears that does not let you
raise a priority above the threshold allowed for RTOS calls from
interrupts (p. 112). Priorities are covered in section 7, interrupts under an
RTOS in section 28.
DMA. A DMA stream is added with the Add button in the DMA window or on the DMA Settings tab in the parameters of the block itself (p. 100, 109). The same place has the mode — normal or circular, address increment, a width of 8, 16 or 32 bits, FIFO and bursts of 1, 4, 8 or 16 (p. 110). How it works is in section 9, circular UART reception in section 16б.
The HAL timer and an RTOS. By default HAL counts time from SysTick. With FreeRTOS, UM1718 advises giving HAL another timer — TIM1, TIM6 and the like — in SYS → Timebase Source (p. 123): SysTick then belongs entirely to the RTOS. The structure of FreeRTOS is section 24.
Peripherals by category are in their own sections: timers — 13, ADC — 14, DAC — 15, UART — 16, I²C — 17, SPI — 18, CAN — 19, USB — 20, FatFs — 42, lwIP — 106в.
4д.4 Clock Configuration: the tree and the solver
The tab draws the clock tree: sources, dividers, multipliers, multiplexers. The lines in use are highlighted, values out of the allowed range are in red (UM1718, p. 180–181). The CubeMX 6.18.1 database has 68 clock tree files for various series and lines.
You can work with the tree in two ways. The direct way — choose the source, the PLL multiplier and the bus dividers. The reverse way — type the frequency you need for HCLK or a bus into the field, and the solver picks the multipliers and dividers itself (p. 181–182). If it finds a solution, the tree is rebuilt; if not, it suggests another source or says the frequency cannot be reached. A field can be locked with the right mouse button (Lock), and the solver will not touch it — this is how 48 MHz for USB is held while the core is being tuned (p. 182).
The same place has crystal failure protection (CSS) for HSE and LSE, if the MCU
supports it (p. 182). The result goes into SystemClock_Config() in main.c and into
the crystal frequencies in stm32xxxx_hal_conf.h (p. 181).
What HSE, HSI, PLL and buses are is in section 6; how to choose a crystal and its capacitors is in section 174; 48 MHz for USB without a crystal is in section 20а.
Typical mistakes. The HSE branch is grey — the crystal is not enabled in RCC on the pins tab (p. 187). The frequency in the HSE field does not match the crystal on the board — the whole tree will be off by the same factor: the BluePill has an 8 MHz crystal, the BlackPill 25 MHz. A red field must not be ignored: the code will be generated, but the bus frequency will be outside the datasheet.
4д.5 Project Manager: Project, Code Generator, Advanced Settings
Three tabs (UM1718, p. 190).
Project — the project name and folder (the name also gives the name of the .ioc),
the Basic or Advanced structure, the toolchain (Toolchain/IDE), heap and
stack sizes, the firmware package version (p. 192–193). The default heap and stack are
0x200 and 0x400 bytes; with middleware that is often too little (p. 193). The
6.18.1 database lists the CMake, EWARM, MDK-ARM and Makefile toolchains, plus
STM32CubeIDE. If CMake is chosen, a compiler field appears: GCC or
Starm-Clang (p. 191). Some fields become read-only after saving
— they are changed via Save Project As (p. 191). The Middlewares and
Utilities folders are reserved for generation: do not put your own files there (p. 192).
Code Generator — what to copy from the package: all libraries, only the needed files, or reference the package without a copy (p. 196). Below are the file options (p. 197):
- the initialization of each block in a
.c/.hpair, or everything inmain.c; - a backup of the previous files with the
.bakextension; - keep user code on regeneration — only between the
USER CODEmarkers, not in your own files; - delete files that are no longer needed;
- all free pins to analog mode for the sake of idle current;
USE_FULL_ASSERTinhal_conf.
Advanced Settings — the HAL or LL driver for each block, the order of the
MX_..._Init() calls and a checkbox that removes a call altogether so that you
call it yourself (p. 199). Clearing the Visibility (Static) checkbox makes the
init function visible from other files (p. 200).
Where it is covered: the CubeIDE project and the USER CODE markers in section 4б, a CMake
project from .ioc in section 115а, Keil in section 4а, a build with no
generator at all in section 4в, HAL and LL in sections 5 and 5а, heap and stack in sections 11
and 25.
Typical mistakes. Your own code outside the USER CODE markers in a generated
file — the next generation will erase it. A toolchain is chosen that is not on the
machine: the project will be created, but there is nothing to build it with. The order
MX_DMA_Init() after a block that uses DMA is a common cause of
silent DMA in older versions; the order is checked in Advanced Settings.
4д.6 Tools: Power Consumption Calculator and others
The Tools tab is auxiliary; it is not needed for a first project.
Power Consumption Calculator (UM1718, p. 329). You describe a sequence of steps: the mode (Run, Sleep, Stop…), the frequency, the enabled peripherals, the duration. The calculator works out the average current, the lifetime on the selected battery, the performance in DMIPS and the maximum ambient temperature. The database has 29 battery models — from an alkaline AA to a lithium CR2032. For L0, L1, L4, L4+, G0, G4, H7 and WB there is a transition checker: it will not let you add a step that cannot be reached from the previous one (p. 329). The calculator does not know the current of the inputs and outputs — it is added by hand (p. 329). Power modes are in section 10, Stop 2 and Shutdown on L4 and U5 in section 10а.
Compare Projects compares two .ioc files, including on different
MCUs: peripherals, parameters, structure (p. 317). Handy before moving
to another MCU.
External Tools — a list of other ST programs with links and a launcher (p. 317). For MPUs there is also DDR Suite (p. 353), and for H5, H7, U5, N6 and a number of other series — Memory Management Tool, the memory map (p. 359).
A typical mistake. Taking the calculator's figure for a measurement. It is an estimate from the datasheet; the real idle current of a board is eaten by the regulator, the power LED and the pull-ups — those are measured (section 10).
4д.7 Pitfalls
The MCU does not answer the debugger after the first flashing. On the STM32F103 the
No Debug mode in SYS — the default value — turns into
__HAL_AFIO_REMAP_SWJ_DISABLE: the SWD pins become ordinary GPIO. Set
Serial Wire before generating; an already flashed MCU is reached by connecting under
reset (section 35б).
Regeneration erased the code. Only the code between the
USER CODE BEGIN and USER CODE END markers in generated files is kept (UM1718,
p. 197). Your own modules go into your own files.
A block is grey and will not enable. Its pins are already taken by another block. The tooltip on the name shows by whom; a different order of enabling or a cleared Keep Current Signals Placement checkbox helps (p. 95).
The frequency in the tree is right, but not on the board. The HSE field holds the frequency of the wrong crystal, or HSE is not enabled in RCC and the core runs from HSI. Compare with the crystal on the board and with the RCC registers (section 6).
HAL_Delay hangs in an interrupt. An interrupt with a priority above SysTick waits for a tick that will never come. Priorities are in the NVIC window (section 7).
The project opened in a new CubeMX version and offered a migration. Before
agreeing, save a copy of the .ioc: after migration the old version may
not open it.
4д.8 Summary
- The order: MCU → Pinout & Configuration (SYS, RCC, modes) → Clock Configuration → Project Manager → GENERATE CODE.
- MCU — MCU Selector (2240 descriptions in the 6.18.1 database), board — Board Selector (277 presets), example — Example Selector, replacement — Cross Selector.
- On the pins tab: SYS — debug and the HAL timer, RCC — crystals, GPIO — speed and names, NVIC — priorities, DMA — in the block's parameters.
- The clock tree is solved in both directions; a locked field is not touched by the solver; the HSE branch is dead until the crystal is enabled in RCC.
- Project Manager: the toolchain (CMake — GCC or Starm-Clang), heap 0x200 and stack
0x400 by default, a
.c/.hpair, HAL or LL, the order ofMX_..._Init(). - Tools: the consumption calculator with 29 batteries — an estimate, not a measurement.
- On the F103
No Debugturns SWD off: set Serial Wire.
Next: section 5 "ST's three levels of abstraction" — CMSIS, HAL and LL.