cancel
Showing results for 
Search instead for 
Did you mean: 

I can't make timer stop while debuging

Carlos Zelayeta
Associate
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
1 ACCEPTED SOLUTION

Accepted Solutions
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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

6 REPLIES 6
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
Up vote any posts that you find helpful, it shows what's working..
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) 
 { 
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Posted on February 21, 2017 at 17:33

Thanks for the hint on the clock, I've been searching for an hour and this is the only place that mentions it and it fixed my issue.

Posted on June 19, 2017 at 01:51

Wow, thanks heaps Clive. I was struggling with that myself.

Suggestion to ST: Please implement that line in your __HAL_DBGMCU_FREEZE_xxx macros! I simply didn't know that was necessary and that's the whole point of having a macro, isn't it?

jnewcomb
Associate II

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.

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

JW