Skip to main content
COSEBE
Senior
May 18, 2021
Solved

Disable interrupts while Stepping Debug

  • May 18, 2021
  • 6 replies
  • 5510 views

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

This topic has been closed for replies.
Best answer by mattias norlander

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.

6 replies

mattias norlander
ST Employee
May 20, 2021

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
May 21, 2021

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
COSEBEAuthor
Senior
May 21, 2021

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

mattias norlander
ST Employee
May 27, 2021

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.

Osto
Senior
May 21, 2021

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

Piranha
Principal III
June 5, 2021

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.