How to set DBGMCU_CR register on MDK?

IDE:MDK5.23.0.0

MCU:STM32F103RET6

Code generate:STM32CubeMX

Q1:How to set the DBGMCU_CR register on MDK?

I tried two solutions to set DBGMCU_CR on MDK, but failed.

Solution 1

Add the conf_STM32F103RE.ini file on Options->Debug->Initialization file.

It seems the settings is invalid.

When the system run the main function first line, the DBGMCU_CR is 0x00000307.

Q2:The reason why the system run to main function theDBGMCU_CR is 0x00000307?It says the reset value is 0x00000000 in rm0008.

Solution 2

Exchange the file at DebugConfig folder and set the DbgMCU_CR from 0x00000007 to 0x00000000.

The DbgMCU_CR register value is 0x00000007 after compile.

Q3:The reason why the original DbgMCU_CR is 0x00000007?What settings on mdk caused this result?

Both two solutions failed, when the system run the main function first line, the DBGMCU_CR is 0x00000307.

I want to set the DBGMCU_CR register to 0x00000000, so the IWDG will reset the system when the system in stop mode.

If I set the DBGMCU_CR register to 0x00000000 on main function, the IWDG will reset the system when the system in stop mode.

Thanks for your attention.

More questions in this forum