STM32CubeIDE and STM32CubeMX together form a complete development platform for STM32
Beginner’s guide to STM32CubeIDE and STM32CubeMX. Learn to create, configure, and program STM32 microcontrollers with step-by-step examples.
Introduction
If you’re getting started with STM32 microcontrollers, you’ve likely heard of STM32CubeIDE and STM32CubeMX. These are powerful tools provided by STMicroelectronics that make firmware development for STM32 devices faster and more efficient.In this guide, we’ll walk through what these tools are, how they work together, and how you can set up your first STM32 project from scratch.
🔹 What is STM32CubeIDE?
STM32CubeIDE is a comprehensive C/C++ development platform designed for STM32 microcontrollers and microprocessors. It provides an all-in-one environment that combines peripheral configuration, code generation, compilation, and debugging within a single tool.
Built on the ECLIPSE™/CDT framework, STM32CubeIDE uses the GCC toolchain for code development and GDB for debugging. It also supports the integration of numerous ECLIPSE™ plugins, allowing developers to expand its functionality as needed.
All features of STM32CubeMX are seamlessly integrated, offering a unified experience that saves both installation and development time. After selecting an STM32 MCU, MPU, or preconfigured board, STM32CubeIDE automatically creates the project and generates the initialization code. At any point in development, users can revisit and modify peripheral or middleware configurations and regenerate the initialization code — without affecting their existing user code.
It combines multiple STM32 tools into one package:
- Code editing (C/C++ editor)
- Code compilation using GCC toolchain
- Debugging with ST-Link or J-Link
- Peripheral configuration via STM32CubeMX integration
Essentially, it’s a complete development ecosystem for STM32 — from initialization to debugging.
🔹 What is STM32CubeMX?
STM32CubeMXis a graphical configuration tool that helps you:
- Configure MCU peripherals using an intuitive GUI
- Generate initialization code automatically
- Set up clock trees, GPIO pins, and middleware components
It eliminates the need to manually configure complex registers and ensures your project starts with a clean, well-structured HAL (Hardware Abstraction Layer) setup.
🔹Why STM32CubeIDE?
👉 STM32CubeIDE features powerful build and stack analyzers that give developers valuable insights into project status and memory usage. It also includes advanced debugging tools such as real-time views of CPU core registers, memory, and peripheral registers. Additionally, it supports live variable monitoring, the Serial Wire Viewer (SWV) interface, and a fault analyzer to help identify and resolve issues efficiently during development.
👉 STM32CubeMXby carreduce power consumption and improve system efficiency.
👉The STM32Cube framework includes both the Hardware Abstraction Layer (HAL) and Low-Layer (LL) drivers, offering consistent interfaces that closely represent the hardware. The LL drivers enable the generation of faster and smaller binaries, making them ideal for performance-critical applications. Since embedded systems operate with limited resources, keeping the firmware narrow is essential for efficient operation.
👉The HAL layer abstracts the hardware interface, enabling seamless code portability across different STM32 microcontrollers.
👉Supports both ST-LINK (by STMicroelectronics) and J-Link (by SEGGER) debug probes.
👉Allows importing projects from Atollic® TrueSTUDIO® and AC6 System Workbench for STM32 (SW4STM32).
Setting Up STM32CubeIDE & STM32CubeMx
1Download and Install
Download the latest version from the official STMicroelectronics website:
STM32CubeIDE STM32CubeMXCreate Your Fisrt project using STM32CubeIDE and STM32CubeMx
First, open the STM32CubeMXandselect an MCU or choose a development board.STM32F103 microcontroller, we’ll use the STM32 (commonly known as the B board). As this board isn’t listed under standard boards, you’ll need to select it manually using the MCU select. For more details about the Blue Pill board, you can refer to the provided specification
linkOpen STM32CubeMx Application and you see First screen is as given below to select MCU
Write STM32F103C8T6 in part finder search box

First, enable the System Tick Timer and System Wire interface to allow programming the MCU using the ST-Link programmer. You can refer to the provided link for a detailed guide on how to download and debug programs in the MCU using the ST-Link programmer.

Next, open the Clock Configuration tab and choose the desired system clock source. In this example, we’re using an external crystal oscillator (HSE) as the system clock.


Here, we’re creating a simple built-in LED blink program to understand how STM32CubeIDE and CubeMX work. The on-board LED is connected to GPIO pin PC13. In the Pin Configuration tab, set PC13 to Output mode. You can also adjust its label, mode, speed, and pull-up/pull-down settings using the GPIO configuration table.

Go to the Project Manager tab, enter your project name and file path, then select STM32CubeIDE as the toolchain/IDE. Once done, the tool will automatically generate the basic project structure and initialization code for you.

After code generation, you’ll be prompted with a message asking, “Do you want to open your project in the IDE?”Click Y, and your project will automatically open in STM32CubeIDE .Now open your Project in IDE you will see screen as given below

Project folder hierarchy have two main folder Core and Driver both have include file and its source file. Core have main file and system files.
Source code- Write down it on While() in main.c file
/* USER CODE END WHILE */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, SET);
HAL_Delay(10);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, RESET);
HAL_Delay(10);
/* USER CODE BEGIN 3 */
Program Execution
- 👉 First, build the program, then on the top toolbar, navigate to Run → Debug → STM32 MCU C/C++ Application, and click OK to start debugging.
- 👉 When the Debug Configuration window appears, go to the Debugger tab and select your preferred debug probe — in this case, ST-LINK (OpenOCD). Then click Apply followed by OK.
- 👉 In the Debug Configuration window, navigate to the Debugger tab and choose your debug probe — here, ST-LINK (OpenOCD). Click Apply, then OK.
ST-Link Interface with Bluepill in below image.

Conclusion
STM32CubeIDE and STM32CubeMX together form a complete development platform for STM32 microcontrollers. They simplify peripheral configuration, code generation, and debugging — ideal for both beginners and professionals.
Whether you’re blinking an LED or developing a complex IoT device, CubeIDE provides the foundation for fast and efficient STM32 programming.
thanks, helped me on the part where i have to put my code in the main.c file. am new to c programming and am coming from 8 bits pic/avr using ldmicro. want to learn the stm32.
ReplyDeletetaurai mirimi
tmirimi@gmail.com
thanks, helped me on the part where i have to put my code in the main.c file. am new to c programming and am coming from 8 bits pic/avr using ldmicro. want to learn the stm32.
ReplyDeletetaurai mirimi
tmirimi@gmail.com
Thanks for the tutorial. It was very helpful. My suggestion is to change the source code of a 10 to 1000 ms delay, only so we will notice the LED flashing.
ReplyDelete