cancel
Showing results for 
Search instead for 
Did you mean: 

Disable interrupts while Stepping Debug

COSEBE
Senior

I use to develop with IAR.

I try to go to STM32CubeIDE.

I cannot find the way to stepping debug a program if an interrupt timer is running in background.

Is there an option like IAR "disable interrupts when stepping"

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

In general when the debugger steps through code we should set the DHCSR -> C_MASKINTS which will make sure the core does not enter an interrupt handler. In generl this works well across the STM32 protfolio. With the exception of a few Cortex-M7 based MCUs. STM32F746 is one of them. It contains an older core revision where the stepping behavior is different. See the link above.

So in your case the only option would be to set the freeze registers for all timers that you use.

View solution in original post

6 REPLIES 6
mattias norlander
ST Employee

Hi,

No there is no check-box to do this. Instead you will need either do it in code or as GDB run commands.

Easiest is probably to do it in code like this:

#ifdef DEBUG

__HAL_DBGMCU_FREEZE_TIM2();

#endif

Have a look at: stm32h7xx_hal.h (or equivalent xyz_hal.h file depending on your STM32 product)

mattias norlander
ST Employee

By the way which MCU are you using? There were some issues in early Arm revision of the Cortex-M7 with respect to single-stepping and interrupt firing (not being masked).

See this link: https://developer.arm.com/documentation/ka002944/latest

I think these issues are part of some STM32F7 products. Maybe some others STM32 products.

COSEBE
Senior

Thanks Mattias.

Here you talk about TIM2 in you example, but I have to do this with all interrupt ?

Will the interrupt continu working when MCU is in Debug Running mode ?

I am using STM32F746

Osto
Senior

You need to do this for all timers which you are using only, specially with timers for RTOS (if you have one)

In general when the debugger steps through code we should set the DHCSR -> C_MASKINTS which will make sure the core does not enter an interrupt handler. In generl this works well across the STM32 protfolio. With the exception of a few Cortex-M7 based MCUs. STM32F746 is one of them. It contains an older core revision where the stepping behavior is different. See the link above.

So in your case the only option would be to set the freeze registers for all timers that you use.

Piranha
Chief II

The solution to the problem is in my post there:

https://community.st.com/s/question/0D50X0000A4pIcQSQU/stm32f746-cortexm7-silicon-bug-singlestep-lands-in-interrupt-handler

Just ignore that one stubborn individual... I don't know if it works with OpenOCD or whatever is used in CubeIDE by default, but it definitely works with SEGGER's GDB Server.