2022-05-04 08:16 AM
Hi all,
Is there any method to debug timer interrupts using VSCode? I am currently using the STM32G4 series. it would be really nice if anyone can point out a way to debug.
I am using OpenOCD.
Thanks
Roshan
2022-05-04 09:26 AM
Are you using an Stlink?
I have never used VSCode but it looks like you can use the debugger in VSCode
You could add breakpoints inside the timer ISR, i sometimes toggle GPIOs or use PWMs if i need to calibrate Timers
2022-05-04 09:55 AM
Pick tools where you can drive the debugger.
VSCode, probably in the minority here.
Instrument your code so you can understand real-time / dynamic flow.
Learn to do static-analysis so you can walk your code and understand the logic you implemented, single-stepping code generally should be a last resort, and clearly useless for high speed / real-time code that needs to move a million times faster than your fingers/eyes.
2022-09-21 06:18 AM
Official STM32 support including debugging and RTOS awareness is now available on VSCode, please check out the recent post at the Microsoft blog: Importing ST projects into Visual Studio Code - C++ Team Blog (microsoft.com).
This allows importing STM32CubeIDE projects for your STM32G4, be it STM32CubeMX generated or provided in the STM32CubeG4 firmware package.
2023-05-31 01:36 PM - edited 2023-11-20 09:10 AM
Another alternative, which is really simple to setup and gives you more debug tools then VSCode offers, is to use VSCode for edit/compile/debug and STM32CubeIDE for advanced debug scenarios only. (RTOS, data tracing, interrupt analysis, fault analysis, etc...). Not what you are asking for, but maybe still useful to you - or someone else!
Using STM32CubeIDE as a "debugger only tool" is actually a use case that we support. There is a simple project wizard that helps you to configure "debug only" where the user only has to point to the VSCode built elf-file. The wizard then sets up a minimal CubeIDE project. No code, only the metadata needed to configure the debugger.
How to do this? Here is a small guide:
Step1: In CubeIDE click: File > Import > C/C++ > STM32 Cortex-M Executable
Step2: Point to the elf-file of the VS Code managed project. Select the MCU/CPU/Core
Step3: Generate the debug configuration. Possibly enable RTOS-debug or tracing, or whatever...
Step4: Click Debug! Now you are in the debugger.
The elf-file contains all the symbol information needed to do source code level stepping. No need to manually configure anything else to have a full-blown debug session going.
The project inside STM32CubeIDE looks like this:
It just creates the required .project/.cproject files and some .launch-files to keep everythin together but no source code. You can keep this project at a separate location then the VSCode project if you want. It all depends on where you choose to open your STM32CubeIDE workspace...
Not a full-blown VS Code solution. But, at least a convenient way to use the STM32CubeIDE debugger with a project managed inside any other 3rd party IDE / toolchain combination.
Enjoy! :)