cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G050 Debug with IWDG enabled

BlazejK
Associate II

I enabled IWDG on my STM32G050C8T6 and it works correctly but I also want to be able to debug the MCU with IWDG enabled. According to the MCU family's reference manual I should set  bit 12 (DBG_IWDG_STOP) of DBG APB freeze register 1 (DBG_APB_FZ1) to disable IWDG clock counter when the core is halted.

The DBG APB freeze register 1 can be written by debugger under system reset.

BlazejK_0-1735630035425.png

But I do not know how to write to this register. I tried to change it using STM32CubeProgrammer but it does not work.

BlazejK_1-1735630179780.png

I also tried to do this using st-link utility and gdb but the DBG_APB_FZ1 is still 0.

BlazejK_2-1735630247355.png

How to set this register so I can debug my device with IWDG enabled?

 

 

2 REPLIES 2
Sarra.S
ST Employee

Hello @BlazejK

You can do this either with STM32Cubeprogrammer, through the OB tab, look for the DBG_APB_FZ1 register and set bit 12 (DBG_IWDG_STOP), apply the changes and reset the device.

Or, you can do that by SW, by writing a mask to the DBGMCU register: 

DBGMCU->APB1FZ1 |= (1 << 12); 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @Sarra.S 

Thank you for replying.

Unfortunately there is no DBG_APB_FZ1 register in OB tab.

BlazejK_0-1735634071142.png

And trying to set this bit in software was the first thing I tried to do since I have already used this option in other STM32 device family (and it was working there) but with the current MCU when I set the appropriate bit and then read the register the register is 0 (debug variable equals 0).

  SET_BIT( DBG->APBFZ1, DBG_APB_FZ1_DBG_IWDG_STOP );
  uint32_t debug = DBG->APBFZ1;