cancel
Showing results for 
Search instead for 
Did you mean: 

debugging in STOP mode

trevor23
Associate III
Posted on January 07, 2014 at 17:37

I develop a lot of low power applications using STM32 and I'd like the ability to use the debugger while in low power STOP mode. My code works as expected in release mode (i.e. no debugger) but when debugging as soon as the processor enters STOP mode it exits STOP mode. Even if I disable all interrupt sources that could wake it up (RTC alarm and EXTI pin interrupts) it still exits STOP mode immediately. I have added the following at the beginning of main to setup the debug register:

#ifdef DEBUG
DBGMCU->CR = DBGMCU_STOP;
#endif

Processor: STM32F103 (same issue on STM32F101) Tool chain: Rowley Crossworks for ARM 1.7 build 22 JTAG: ARM-USB-TINY (Olimex) I would appreciate any ideas. Regards Trevor #dbg_standby #dbg_stop #dbg_sleep
9 REPLIES 9
chen
Associate II
Posted on January 07, 2014 at 18:00

Hi

I am not that famailiar with the STM32F103 series, I work with the F4 series.

You want to debug the ARM core while it is in STOP mode?!?

How can you debug the processor when it is stopped/suspended/halted/not running?

'' I'd like the ability to use the debugger while in low power STOP mode.''

Surely this is not possible!

''but when debugging as soon as the processor enters STOP mode it exits STOP mode.''

Well, yes as soon as the processor enter stop mode, the debugger will be sending debug commands which will probably wake the processor/core.

As I understand it, one way to achieve low power while running is to change (lower) the clock to a very low speed (try KHz)

I beleive the F0 series are the ultra low power series but again - I have no experience with them (yet)

trevor23
Associate III
Posted on January 08, 2014 at 00:03

Thanks for your response.

''How can you debug the processor when it is stopped/suspended/halted/not running?''

By setting the DBG_STOP bit in the DBGMCU_CR register (as per code above), see section 31.16.3 of the reference manual here: 

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/CD00171190.pdf

''Surely this is not possible!''

 

I think it is. See section 1.2.6 of this low power app note for further evidence of this feature: 

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/CD00171691.pdf

Has anyone had this working?

chen
Associate II
Posted on January 08, 2014 at 10:08

Hi Trevor

OK, it is possible to debug in the low power modes - I stand corrected.

However, from reading the description - it is faking it - the clocks are not being stopped in the normal way.

The power consumption will not be lowered in when debugging.

From the description - it is also highly dependant on how the tool chain has implemented (if at all) the debug in low power mode.

''but when debugging as soon as the processor enters STOP mode it exits STOP mode.''

Like I said - it sounds like the debugger is sending debug messages which take the core out of STOP mode.

It sounds like

Rowley Crossworks for ARM 1.7 build 22

JTAG: ARM-USB-TINY (Olimex)

does not support it properly.

frankmeyer9
Associate II
Posted on January 08, 2014 at 10:19

First, I have not trying to debug in STOP mode, too.

By setting the DBG_STOP bit in the DBGMCU_CR register (as per code above), see section 31.16.3 of the reference manual here: ...

 

 ...

 

I think it is. See section 1.2.6 of this low power app note ...

 

The cited app note is rather vague in this regard:

''However, by setting some configuration bits in the DBGMCU_CR register, the software can  be debugged even when using the low-power modes extensively.''

 

This implies to me that setting the DBG_STOP bit might not suffice.

Have you tried the CrossWorks support or forum ?

IMHO, the version 1.7 is rather old, current version is, AFAIK, 2.3. Not sure if, and how, it supports low power states during debugging.

chen
Associate II
Posted on January 08, 2014 at 11:00

Hi

You got me thinking.

Most tool chains use a GDB interface to achieve inter-changeability with different debuggers.

GDB comes from Unix. I do not think that GDB under Unix would support low power/suspend.

So I think it is unlikely that any tool chain will support 'debugging a processor' while in a low power/suspend mode

Amel NASRI
ST Employee
Posted on January 21, 2014 at 16:45

Hello Trevor,

Are you using WFE to enter stop mode?

If it is the case, try to call it twice and put breakpoint after the call of second WFE.

In fact, in debug mode, there is an internal signal  in the core which wakes-up the MCU

as soon as WFE is executed.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Zanon.Luciano
Senior
Posted on September 21, 2015 at 12:55

Hi Trevor

I have the same problem as you...

Did you solved it?

ygkim550
Associate II
Posted on October 01, 2015 at 02:41

   __DBGMCU_CLK_ENABLE() ; // (RCC->APB2ENR |= (RCC_APB2ENR_DBGMCUEN))

 HAL_EnableDBGStopMode();  //  SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);

//  DBG_SLEEP, DBG_STOP, DBG_STANDBY 

hassan
Associate II
Posted on October 19, 2015 at 16:11

systick clock is not disabled when debug stop mode is set. disable systick before entering stop mode.