2017-01-09 09:29 AM
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 #stm32f072Solved! Go to Solution.
2017-01-09 10:25 AM
Do you enable the DBGMCU clock on APB2 ??
RCC->APB2ENR |= RCC_APB2ENR_DBGMCUEN;
2017-01-09 10:25 AM
Do you enable the DBGMCU clock on APB2 ??
RCC->APB2ENR |= RCC_APB2ENR_DBGMCUEN;
2017-01-09 11:54 AM
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)
{
}
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
2017-02-21 09:33 AM
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.
2017-06-18 06:51 PM
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?
2021-01-07 05:13 AM
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.
2021-01-07 07:18 AM
Also in 'L0 and 'G0, but they call the given DBGEN there...
JW