EmbeddedRelated.com
Forums

STM32F0x1 Sleep Mode Conundrum

Started by Tim Wescott February 28, 2014
Any time I ask a really specific question here it always seems to go by 
the wayside.  But what the heck -- it's Friday, it's late, and my @#$% 
processor won't go to sleep!!!

Anyone have any mileage with the ST Arm Cortex parts and sleep mode?  
I've got a STM32F303 that doesn't really need it that goes to sleep 
beautifully, and I've got an STM32F051 in an application where low power 
is critical that isn't going to sleep at all!!!

I'm calling the "wfe" instruction, I've tried calling the "wfi" 
instruction instead, and got no difference.  I've dug through the manuals 
for the past two hours looking for that magic "oh, by the way, you need 
to setorclear this magic bit", all to no avail.

So, any help is appreciated.  Even wild-ass suggestions, as long as they 
come from the ARM Cortex world.

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Tim Wescott <tim@seemywebsite.really> wrote:
> Any time I ask a really specific question here it always seems to go by > the wayside. But what the heck -- it's Friday, it's late, and my @#$% > processor won't go to sleep!!!
> Anyone have any mileage with the ST Arm Cortex parts and sleep mode? > I've got a STM32F303 that doesn't really need it that goes to sleep > beautifully, and I've got an STM32F051 in an application where low power > is critical that isn't going to sleep at all!!!
> I'm calling the "wfe" instruction, I've tried calling the "wfi" > instruction instead, and got no difference. I've dug through the manuals > for the past two hours looking for that magic "oh, by the way, you need > to setorclear this magic bit", all to no avail.
> So, any help is appreciated. Even wild-ass suggestions, as long as they > come from the ARM Cortex world.
Is the SLEEPONEXIT bit set by chance? -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
On Sat, 01 Mar 2014 12:06:50 +0000, Uwe Bonnes wrote:

> Tim Wescott <tim@seemywebsite.really> wrote: >> Any time I ask a really specific question here it always seems to go by >> the wayside. But what the heck -- it's Friday, it's late, and my @#$% >> processor won't go to sleep!!! > >> Anyone have any mileage with the ST Arm Cortex parts and sleep mode? >> I've got a STM32F303 that doesn't really need it that goes to sleep >> beautifully, and I've got an STM32F051 in an application where low >> power is critical that isn't going to sleep at all!!! > >> I'm calling the "wfe" instruction, I've tried calling the "wfi" >> instruction instead, and got no difference. I've dug through the >> manuals for the past two hours looking for that magic "oh, by the way, >> you need to setorclear this magic bit", all to no avail. > >> So, any help is appreciated. Even wild-ass suggestions, as long as >> they come from the ARM Cortex world. > > Is the SLEEPONEXIT bit set by chance?
I am not setting it, but I'll check its state the next time I'm in the room with the board and report back here. I assume it should be zero -- yes? -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
On 01/03/2014 01:10, Tim Wescott wrote:
> Any time I ask a really specific question here it always seems to go by > the wayside. But what the heck -- it's Friday, it's late, and my @#$% > processor won't go to sleep!!! > > Anyone have any mileage with the ST Arm Cortex parts and sleep mode? > I've got a STM32F303 that doesn't really need it that goes to sleep > beautifully, and I've got an STM32F051 in an application where low power > is critical that isn't going to sleep at all!!! > > I'm calling the "wfe" instruction, I've tried calling the "wfi" > instruction instead, and got no difference. I've dug through the manuals > for the past two hours looking for that magic "oh, by the way, you need > to setorclear this magic bit", all to no avail. > > So, any help is appreciated. Even wild-ass suggestions, as long as they > come from the ARM Cortex world. >
I have had success with the 152 part using ST's library function: PWR_EnterSTOPMode( PWR_Regulator_LowPower, PWR_SLEEPEntry_WFI ); The 152 is an M3 part, your 303 is an M4, so there may be differences on the 051, which is an M0. Is there an equivalent library function that you could use as a reference for the 051? Ultimately it comes down to calling the WFI instruction within the library function, but it may include some chip specific code prior to the WFI instruction itself. If it helps the low power specific parts that use the above reference library function can be found in the source file STM32L_low_power_tick_management.c of the demo documented on the following page: http://www.freertos.org/STM32L-discovery-low-power-tickless-RTOS-demo.html Regards, Richard. + http://www.FreeRTOS.org Designed for microcontrollers. More than 107000 downloads in 2013. + http://www.FreeRTOS.org/plus IoT, Trace, Certification, FAT FS, TCP/IP, Training, and more...
On Mon, 03 Mar 2014 11:00:21 +0000, FreeRTOS info wrote:

> On 01/03/2014 01:10, Tim Wescott wrote: >> Any time I ask a really specific question here it always seems to go by >> the wayside. But what the heck -- it's Friday, it's late, and my @#$% >> processor won't go to sleep!!! >> >> Anyone have any mileage with the ST Arm Cortex parts and sleep mode? >> I've got a STM32F303 that doesn't really need it that goes to sleep >> beautifully, and I've got an STM32F051 in an application where low >> power is critical that isn't going to sleep at all!!! >> >> I'm calling the "wfe" instruction, I've tried calling the "wfi" >> instruction instead, and got no difference. I've dug through the >> manuals for the past two hours looking for that magic "oh, by the way, >> you need to setorclear this magic bit", all to no avail. >> >> So, any help is appreciated. Even wild-ass suggestions, as long as >> they come from the ARM Cortex world. >> >> > I have had success with the 152 part using ST's library function: > > PWR_EnterSTOPMode( PWR_Regulator_LowPower, PWR_SLEEPEntry_WFI ); > > The 152 is an M3 part, your 303 is an M4, so there may be differences on > the 051, which is an M0. Is there an equivalent library function that > you could use as a reference for the 051? Ultimately it comes down to > calling the WFI instruction within the library function, but it may > include some chip specific code prior to the WFI instruction itself. > > If it helps the low power specific parts that use the above reference > library function can be found in the source file > STM32L_low_power_tick_management.c of the demo documented on the > following page: > http://www.freertos.org/STM32L-discovery-low-power-tickless-RTOS-
demo.html
> > Regards, > Richard. > > + http://www.FreeRTOS.org Designed for microcontrollers. More than > 107000 downloads in 2013. > > + http://www.FreeRTOS.org/plus IoT, Trace, Certification, FAT FS, > TCP/IP, Training, and more...
I found their STM32F0xx library, and looked at the function you mention -- all it does is to clear or set SLEEPDEEP depending on whether you want sleep or stop, then call your choice of WFI or WFE. So, no dice. But at least I know that I'm doing what ST intends. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On Fri, 28 Feb 2014 19:10:07 -0600, Tim Wescott wrote:

> Any time I ask a really specific question here it always seems to go by > the wayside. But what the heck -- it's Friday, it's late, and my @#$% > processor won't go to sleep!!! > > Anyone have any mileage with the ST Arm Cortex parts and sleep mode? > I've got a STM32F303 that doesn't really need it that goes to sleep > beautifully, and I've got an STM32F051 in an application where low power > is critical that isn't going to sleep at all!!! > > I'm calling the "wfe" instruction, I've tried calling the "wfi" > instruction instead, and got no difference. I've dug through the > manuals for the past two hours looking for that magic "oh, by the way, > you need to setorclear this magic bit", all to no avail. > > So, any help is appreciated. Even wild-ass suggestions, as long as they > come from the ARM Cortex world.
How odd. It seems to be connected with having the system tick clock enabled. I had inadvertently left in some code that runs that. My power consumption is still about two orders of magnitude above what I want, but I think that's a board problem, not the processor. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On Tue, 04 Mar 2014 12:03:38 -0600, Tim Wescott wrote:

> On Fri, 28 Feb 2014 19:10:07 -0600, Tim Wescott wrote: > >> Any time I ask a really specific question here it always seems to go by >> the wayside. But what the heck -- it's Friday, it's late, and my @#$% >> processor won't go to sleep!!! >> >> Anyone have any mileage with the ST Arm Cortex parts and sleep mode? >> I've got a STM32F303 that doesn't really need it that goes to sleep >> beautifully, and I've got an STM32F051 in an application where low >> power is critical that isn't going to sleep at all!!! >> >> I'm calling the "wfe" instruction, I've tried calling the "wfi" >> instruction instead, and got no difference. I've dug through the >> manuals for the past two hours looking for that magic "oh, by the way, >> you need to setorclear this magic bit", all to no avail. >> >> So, any help is appreciated. Even wild-ass suggestions, as long as >> they come from the ARM Cortex world. > > How odd. It seems to be connected with having the system tick clock > enabled. I had inadvertently left in some code that runs that. > > My power consumption is still about two orders of magnitude above what I > want, but I think that's a board problem, not the processor.
And for some strange reason I need two in a row. And not WFE followed by a NOP -- it wants two WFE instructions in a row. Ah, the ways of the ARM are mysterious. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Tim Wescott <tim@seemywebsite.really> wrote:
...
> My power consumption is still about two orders of magnitude above what I > want, but I think that's a board problem, not the processor.
Any floating lines? They draw much unwanted current. -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
On Tue, 04 Mar 2014 20:13:34 +0000, Uwe Bonnes wrote:

> Tim Wescott <tim@seemywebsite.really> wrote: > ... >> My power consumption is still about two orders of magnitude above what >> I want, but I think that's a board problem, not the processor. > > Any floating lines? They draw much unwanted current.
I found some, and figured out the magic finger-ring combination to go really to sleep. I'm down to 250uA at this point, but I'd like to get lower still. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Uwe Bonnes <bon@hertz.ikp.physik.tu-darmstadt.de> writes:

> Tim Wescott <tim@seemywebsite.really> wrote: > ... >> My power consumption is still about two orders of magnitude above what I >> want, but I think that's a board problem, not the processor. > > Any floating lines? They draw much unwanted current.
errata says something about excess current for analog pins on certain packages "Additional current consumption in the range of tens of &mu;A per pin can be observed if VDDA is higher than VDDIO" <http://www.st.com/st-web-ui/static/active/jp/resource/technical/document/errata_sheet/DM00058837.pdf> -- John Devereux