cancel
Showing results for 
Search instead for 
Did you mean: 

Why can not change DBGMCU->CR in STM32F103

Bpan.1
Associate

I'm use STM32F103C8T6. I use DBGMCU->CR = DBGMCU_CR_TRACE_IOEN to change the value of DBGMCU->CR, but the operation is failed after POR, the register is alway read 0.

I suspect that the cause of this problem is the the debug component is not be powered up or not be clocked, so I try to power up debug component by set DP CTRL/STAT register to 0x50000000 by sending data to SWD port, and then the DBGMCU->CR can be changed as expected.

So my question is: how to power up debug component from application directly, rather than using the debug port?

3 REPLIES 3
Uwe Bonnes
Principal III

Here some code I use in bl*ckm*g*c:

+      while(1) {

+              ctrlstat = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT);

+              uint32_t check = ctrlstat & (ADIV5_DP_CTRLSTAT_CSYSPWRUPACK |

+                                                                       ADIV5_DP_CTRLSTAT_CDBGPWRUPACK);

+              if (check == (ADIV5_DP_CTRLSTAT_CSYSPWRUPACK |

+                                        ADIV5_DP_CTRLSTAT_CDBGPWRUPACK))

+                      break;

+              if (platform_timeout_is_expired(&timeout)) {

+                      DEBUG_INFO("DEBUG Power-Up failed\n");

+                      return;

+              }

+      }

Using SWD port to power up debug component is succussfull, I tested it. I want to power up it in application code, not SWD port.

Check DBGMCU or AFIO clock enabled.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..