This article will help you to start STM32CubeIDE debugger. While debugging, developers have full access to the source code and can control as well as analyze program execution on C/C++ or assembly level.
Our first step before debugging is connecting the desired modules to STLINK-V3MODS programmer available in H40Rx module as shown below:
The Serial Wire Debug (SWD) interface enables real-time debugging. You will need an STM32-compatible programmer/debugger (e.g., ST-LINK V2 or ST-LINK V3 or the Nucleo board or H40R00 module) and a programming software tool (KEIL uVision IDE, STM32CubeIDE). Three module pads are needed for connection (plus GND): C (SWD Clock), D (SWD Data) and R (MCU Reset).
You will need to make the following connections between the programmer and the module (example provided for the programmer H40R00 module):
- For PC connection, connect USB Micro-B cable to your PC directly.
- For the host board (H40R00 module) three module pads are needed for connection (plus GND): C (SWD Clock), D (SWD Data) and R (MCU Reset):
Pin R (H40R00) >> Pin R (target module).
Pin C (H40R00) >> Pin C (target module).
Pin D (H40R00) >> Pin D (target module).
You need to connect GND between ST-LINK and the module. If your module is powered from a USB-UART cable connected to the same laptop that you connect the ST-LINK to, then, they both have a common ground, and you might not need a separate GND connection.
Hardware Debug:
The hardware debug requires you to connect the board to the computer. Once you enter STM32CubeIDE software, you should see the following workspace.
We’ll have to deal with the following drop lists:
1) File list: from this list we will import our firmware by following this sequence ⇒ File → Import → Projects from Folder or Archive → Import source: Directory → then pick your STM32CubeIDE folder from the latest firmware release of our modules on GitHub → Finish.
2) Project list.
3) Run list.
After importing the firmware, refer to the User folder as shown below, and start writing your topology with the help of this article if there is more than one module is being used, then refer to project.h file and uncomment the header. Finally, press on main.c folder after creating topology to create your own code.
When you finish writing your code, we recommend clicking on Clean Project then Build Project as shown below:
You should have 0 errors after building your project in order to continue. If you had a programming error, then solve it and redo building.
Make sure to check the module numbering that you wish to build according to the topology file, from the Project list and follow this sequence:
Project → Properties → C/C++ Build → Settings → Tool Settings → MCU GCC Compiler → Preprocessor → _module= “the desired number”.
Now edit the debug configuration from the list Run. Please make sure to pick the correct .elf file for the desired module by following the configuration illustrated below, finally click debug then resume, and your module should be ready to use.
You can also monitor the Live Expressions anytime from the right list of the software. (below is a simple example provided for live monitoring x, y, z parameters of IMU module).