Skip to main content
Andrew Neil
Super User
July 16, 2026
Question

Broken: Detect Debugger Active on Cortex-M0

  • July 16, 2026
  • 0 replies
  • 22 views

For a long time, on STM32F0, I have been using the RCC_APB2ENR_DBGMCUEN bit as a reliable indication that a debug session is active with CubeIDE - see:

 

But this seems to have broken recently:

  1. It now seems that RCC_APB2ENR_DBGMCUEN is not set unless the ‘Debug in low power modes’ option is set in the Debug Configuration.
  2. Even when RCC_APB2ENR_DBGMCUEN is set at the start of a debug session, doing a Reset during the session (‘Reset’  button on the toolbar) will clear it.

Or was this always the case, and I just happened to be (un)lucky enough never to notice it?

 

PS:

As noted in the linked thread, the DEBUGEN bit in DHCSR (the Debug Halting Control and Status Register) is not available on Cortex-M0 - so that cannot be used.