Disable peripherals in debug mode on STM32F4xx

Have you ever used watchdog in your application? Have you ever debug your application when watchdog was enabled and you hit stop? Watchdog did not stop in this case and when you pressed “continue” in your debugger, your program starts over because WDG has reset your system. One choice is that you remove line where you initialize IWDG, but you then must recompile and redownload and all that stuff. Wasting useful time.

To avoid this problem, STM32 devices have possibility to disable some peripherals when you are in debug mode. And one of that peripherals is also WDG timer which won’t count and won’t reset your system when you will be in debug mode, even if you enable it somewhere in your code. This gives you a possibility to STOP execution in your program (breakpoint) anytime and continue program without worries about system reset.

DBGMCU (DeBuG MicroController Unit) is called sectionĀ in STM32 with possibility to disable other peripherals when you are in debug mode. For STM32F4xx series, you can disable these peripherals:

Basically all timers only can be disabled with CAN and I2C. So, to disable IWDG in debug mode, you can do like in example below.



Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...