Skip to main content
Carlos Zelayeta
Associate
January 9, 2017
Solved

I can't make timer stop while debuging

  • January 9, 2017
  • 6 replies
  • 5766 views
Posted on January 09, 2017 at 18:29

Hello.

I have a problem trying to stop a timer in debug mode.

I am using a NUCLEO-F072RB. I use timer 7, one of the basic timers, to generate an interrupt.

In order to be able to stop the timer in debug, mannually with breakpoint, I set the DBGMCU_APB1_FZ as stated in the reference manual (RM0091, 9.4).

My code is the following:

int main(void){ 
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 
 HAL_Init(); 
 /* Configure the system clock */ 
 SystemClock_Config(); 
 /* Initialize all configured peripherals */ 
 MX_TIM7_Init(); 
 /* USER CODE BEGIN 2 */
 HAL_DBGMCU_EnableDBGStandbyMode(); 
 HAL_DBGMCU_EnableDBGStopMode();
 DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_TIM7_STOP; 
 while (1) 
 { 
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

When I run the debugger, none of the DBG registers changes its values and the timer doesn't stop when stopping execution.

I would like to know where the DBGMCU configuration lines should be placed, or if there is something else that needs to be configured.

Thanks in advance,

Carlos

#debug #timer #stm32f072
This topic has been closed for replies.
Best answer by Tesla DeLorean
Posted on January 09, 2017 at 19:25

Do you enable the DBGMCU clock on APB2 ??

RCC->APB2ENR |= RCC_APB2ENR_DBGMCUEN;

6 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
January 9, 2017
Posted on January 09, 2017 at 19:25

Do you enable the DBGMCU clock on APB2 ??

RCC->APB2ENR |= RCC_APB2ENR_DBGMCUEN;

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Carlos Zelayeta
Associate
January 9, 2017
Posted on January 09, 2017 at 19:54

Thank you very much!

I inserted the suggested line and it started working.

I paste the working code:

int main(void){ 
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 
 HAL_Init(); 
 /* Configure the system clock */ 
 SystemClock_Config(); 
 /* Initialize all configured peripherals */ 
 MX_TIM7_Init(); 
 /* USER CODE BEGIN 2 */
 RCC->APB2ENR |= RCC_APB2ENR_DBGMCUEN; //enable MCU debug module clock
 HAL_DBGMCU_EnableDBGStandbyMode(); 
 HAL_DBGMCU_EnableDBGStopMode();
 DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_TIM7_STOP; //enable timer 7 stop 
 while (1) 
 { 
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

jnewcomb
Associate
January 7, 2021

Don't get caught out, like me obviously... This thread is specific to STM32F0xx series (RCC_APB2ENR @ bit 22 is RCC_APB2ENR_DBGMCUEN_Pos)

Other devices are different. Correct if mistaken, they don't even have a DBGMCUEN flag to enable.

waclawek.jan
Super User
January 7, 2021

Also in 'L0 and 'G0, but they call the given DBGEN there...

JW