cancel
Showing results for 
Search instead for 
Did you mean: 

How to debug Timer interrupt

Roshan
Associate III

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

4 REPLIES 4
Javier1
Principal

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

we dont need to firmware by ourselves, lets talk

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Paolo ALBERELLI_O
Associate II

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.

mattias norlander
ST Employee

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


_legacyfs_online_stmicro_images_0693W00000blG6RQAU.png 

Step2: Point to the elf-file of the VS Code managed project. Select the MCU/CPU/Core


_legacyfs_online_stmicro_images_0693W00000blG6MQAU.png 

Step3: Generate the debug configuration. Possibly enable RTOS-debug or tracing, or whatever...


_legacyfs_online_stmicro_images_0693W00000blFdrQAE.png 

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:


_legacyfs_online_stmicro_images_0693W00000blG6vQAE.pngIt 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! :)