Quick Walkthrough: STM32CubeIDE
STM32CubeIDE includes several features that make it easy to develop and debug STM32 applications, including:
A graphical user interface (GUI) for configuring the STM32 microcontroller and its peripherals
Integrated development tools for writing, building and debugging code
Support for various programming languages, including C, C++, and assembly.
Supports a range of debugging tools, including single-stepping, breakpoints, and trace support.
Integration with many popular third-party tools, including version control and software testing tools.
Here is a brief guide for getting started with the IDE.
Workspaces
In STM32CubeIDE, a workspace is a directory where you can store your STM32 projects and other related files. When you create a new project in STM32CubeIDE, you can select a workspace where you want to save the project files.
You can create multiple workspaces in STM32CubeIDE and switch between them as needed. This can be useful if you want to organize your projects into different groups or categories or if you want to keep different sets of projects separate from each other.
When STM32CubeIDE starts up, it asks which workspace must be used. This may be changed at any time by selecting [File]>[Switch Workspace] and navigating to another folder
Note that when you create a new project in STM32CubeIDE, the project files are stored in a subdirectory within the selected workspace. This lets you quickly locate and access your project files within the workspace directory.
Information Center
On the first launch, the information centre comes up. The STM32CubeIDE Information Center is a comprehensive resource for information about STM32CubeIDE and the STM32 microcontroller ecosystem. It provides detailed documentation on the various features and functionality of STM32CubeIDE, as well as specialized reference materials and examples to help users get started with developing applications for STM32 microcontrollers.
Image goes here
The Information Center provides access to information about the product and how to use it through hyperlinks to manuals and the STMicroelectronics website. Users can easily find the latest news and resources by clicking on these links.
Creating and Building projects
- Creating a new project
Here are the steps for creating a new embedded project in STM32CubeIDE using the STM32 Project wizard:
Open STM32CubeIDE and go to the "File" menu.
Select "New," then "STM32 Project" to launch the STM32 Project wizard.
In the STM32 Project wizard, select the target microcontroller or board you want to use for your project.
Click "Next" to proceed to the next page of the wizard.
On the next page, enter a name for your project and select the desired settings for the project. This may include options for the target language, binary type, project type, and any code generation options.
Click "Finish" to create the project.
The STM32CubeMX window will open, allowing you to configure your project's peripherals, clock, middleware, and power consumption. Once you have configured the project, you can click the "Generate Code" button to generate the necessary source and project files.
After the code has been generated, you can use the STM32CubeIDE editor to write and edit your code, build and debug your project, and program the microcontroller.
- Adding source files
To add source files to your project in STM32CubeIDE, follow these steps:
Go to the "Project Explorer" pane on the left side of the window. This pane shows the files and directories that are included in your project.
Right-click on the project name or any existing source folder within the project, and select "New" from the context menu.
From the "New" menu, select the type of file you want to add. For example, you can choose "Source File" to add a new C or C++ file to your project.
Enter a name for the File and click "Finish."
The new File will be created and added to your project. You can then use the STM32CubeIDE editor to write and edit the code for the File.
You can add existing source files to your project by right-clicking on the project name or an existing source folder and selecting "Import" from the context menu. This allows you to choose an existing file from your file system and add it to your project.
- Building a project
To build a project in STM32CubeIDE, follow these steps:
Make sure that all of the source files that you want to include in the build are saved and up-to-date.
Go to the "Project" menu and select "Build Project." Alternatively, you can use the "Build" button on the toolbar.
STM32CubeIDE will start the build process, which involves compiling and linking the source code to create an executable file. If there are any errors in your code, STM32CubeIDE will display them in the "Problems" pane at the bottom of the window. You can double-click on an error to go to the location of the error in the source code.
If the build process is successful, STM32CubeIDE will create a binary file (e.g., a ".hex" file) that can be loaded onto the microcontroller. You can use the "Program" button on the toolbar to load the binary File onto the microcontroller and run your program.
Perspectives
In STM32CubeIDE, a perspective is a pre-defined layout that organizes the various views and editors in the main window to suit a specific task or workflow. For example, the "Debug" perspective might show the editor and variables views, while the "C/C++" perspective might show the editor and project explorer views.
You can switch between perspectives in STM32CubeIDE by going to the "Window" menu and selecting "Perspective," then choosing the desired perspective from the list. STM32CubeIDE includes some pre-defined perspectives, including:
C/C++: This perspective is optimized for editing and building C and C++ code. It includes the editor, project explorer, and console views.
Debug: This perspective is optimized for debugging code. It includes the editor, variables, and console views.
Git: This perspective is optimized for working with Git version control. It includes the Git repository, history, and console views.
System Workbench for STM32: This perspective is based on the Eclipse CDT (C/C++ Development Tools) and includes the editor, project explorer, and console views.
You can customize the layout and contents of a perspective by dragging and dropping views and editors within the main window or by going to the "Window" menu and selecting "Customize Perspective." This allows you to create a perspective tailored to your specific needs and workflow.
Debugging
STM32CubeIDE includes several tools and features for debugging STM32 microcontroller applications. To start debugging, you need to have a project open in STM32CubeIDE and a debugging device (e.g., a JTAG or SWD debugger) connected to your microcontroller.
Here are the basic steps for debugging a project in STM32CubeIDE:
Go to the "Run" menu and select "Debug Configurations."
In the "Debug Configurations" window, select the debug configuration you want to use and click "Debug."
STM32CubeIDE will start the debug session and load the program onto the microcontroller. The program will begin running and pause at the first line of code.
Use the debugging tools (e.g., breakpoints, single-stepping) to control the execution of the program and inspect the state of the microcontroller.
After debugging, go to the "Run" menu and select "Terminate" to end the debug session.
STM32CubeIDE provides several features to help you debug your code, including setting breakpoints, stepping through the code line by line, inspecting variables, and viewing the call stack. You can access these features through the "Debug" perspective, which can be opened by going to the "Window" menu and selecting "Perspective" then "Debug."
Further reading
For more detailed information about STM32CubeIDE and its features, refer to the STM32CubeIDE documentation.
Subscribe to my newsletter
Read articles from Asogwa Emmanuel directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Asogwa Emmanuel
Asogwa Emmanuel
As an Electronics and Communications undergrad, I am deeply interested in the design of embedded systems in programmable logic, robotics and problem-solving. These domains excite me and drive my passion for learning and creating innovative solutions.