Skip to main content
Bpan.1
Associate
July 23, 2020
Question

Why can not change DBGMCU->CR in STM32F103

  • July 23, 2020
  • 2 replies
  • 1341 views

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?

This topic has been closed for replies.

2 replies

Uwe Bonnes
Chief
July 23, 2020

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;

+              }

+      }

Bpan.1
Bpan.1Author
Associate
July 23, 2020

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.

Tesla DeLorean
Guru
July 23, 2020

Check DBGMCU or AFIO clock enabled.

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