Reducing power. (STM32F072)

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Reducing power. (STM32F072)

Postby rew » Sun Feb 26, 2017 9:49 am

I've been making an application and when it goes "off" it keeps on dissipating 30mA from the powersupply (12V).

The bulk of that goes through two linear regulators to the 3.3V input on the CPU. I would like to aim for less than 10mA. Not an ambitious target I'd say....

So because everybody says that you only enable peripherals that you need to save power, when there was nothing to do, I started disabling peripherals, but that didn't help much.

Looking at the STM32F072 datasheet (page 56 and following on my version), I see that "with all peripherals enabled" I should expect about 27mA at 48MHz, and something like 15mA with all peripherals disabled. So even when I disable ALL peripherals, that wouldn't be enough to hit my target. On the other hand, reducing the clock frequency to 1MHz WOULD do the trick, even much better than my not-so-ambitious target.

Looking at the table a bit more, leads me to think that maybe running at 1MHz off the internal oscilator is not possible. Then I'll have to settle for 8Mhz.

So... I would just mess with the RCC clock registers and select a 1MHz clock. Chibios just goes in "slowmotion" and I need to make my "check the buttons" task run about 50 times more often. (i.e. sleep for 2 ticks instead of 100).

Oh... My board has an USB connection. In the field nobody will be using it. I'm just using it for debugging and uploading firmware. If USB stops working in "off" mode, that's fine with me. Is the USB low level task maybe going to go bonkers and hog all of my CPU time?

Oh... As the core clock frequency has such a marked effect, I would have expected that enabling WFI has a significant effect. (according to the datasheet, this turns the core clock OFF). This appears to be not the case. Is this normal? Or maybe I have a "always runnable" task (unintentional). So how would I debug that? How do I find what task keeps my CPU active?


Any objections to this approach?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Reducing power. (STM32F072)

Postby Giovanni » Sun Feb 26, 2017 2:58 pm

Hi,

Is the WFI in the idle thread actually reached? if not then you have a running thread at higher priority. You may also try increasing flash wait states, that would reduce consumption without screwing up timings (same frequency).

Giovanni

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: Reducing power. (STM32F072)

Postby rew » Sun Feb 26, 2017 3:36 pm

Yes, when I hit control-C in gdb, I regularly see the WFI instruction as where it was interrupted. Not always, say about 50/50.

IIRC the flash runs at something like 45ns timing, so that above 24MHz, one waitstate is required. On F405, you'd need up to 4 waitstates because you can run the CPU at up to 168MHz, but the F072 only goes up to 48MHz. So only one waitstate is required. Do you think bits above bit-0 have been implemented in the waitstate register?

Edit: There ARE three bits: Documentation states: 000 : zero wait state, 001: One wait state. The other combinations are UNDOCUMENTED, not reserved or something sensible like that. No I can't increase waitstates above one.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Reducing power. (STM32F072)

Postby Giovanni » Sun Feb 26, 2017 5:35 pm

50-50 is a lot, this means that your CPU is running a lot. Do you have CPU intensive tasks? perhaps it is there where you could optimize. Reducing that percentage would have a huge impact in consumption.

Giovanni

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: Reducing power. (STM32F072)

Postby rew » Mon Feb 27, 2017 8:56 am

Yeah... 1) I should measure more accurately.
2) I should disable the SPI-display-stuff that I no longer need. That thing needs a lot of very small delays that are done busy waiting. I'll see if I can reduce power that way.

steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: Reducing power. (STM32F072)

Postby steved » Mon Feb 27, 2017 2:35 pm

Is a hardware a solution a possibility?

Swapping your linear regulator for something like this would probably get you under your target immediately, and isn't vastly expensive.

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: Reducing power. (STM32F072)

Postby rew » Mon Feb 27, 2017 3:51 pm

The application is a bit cost sensitive.... Replacing the EUR 0.3 linear regulator by an EUR 4,- one is not really a good idea. I should be able to get a factor of 100 under target by software alone. And "do in software what you can" is one of the main things in this project.

And lastly, the 30mA @3.3V is 100mW. Convert that from 12V at 80% efficiency and you need 10.4mA at 12V. Add to that the 5mA of no-load-current, and... still too much....

(The MCP1703 that I have has a very low quescent current. so if I get the software right, I should be able to go really low, even if I'm throwing away 75% of the available power.... ).

Update: Got rid of the SPI display stuff. Now I get about 27.2mA from the powersupply. (this number sounds familiar, it could very well be that I measured exactly the same before.). Out of ten times I hit ^C in the debugger, the program was in WFI ten out of ten times.

Update2: Put CPU in HSI only (8MHz, PLL off). CPU current is now down to 4.1 mA. It seems that something has changed with respect to my "total curretn consumption", My initial measurement showed that almost nothing went into "not the CPU", but now I'm seeing about 15mA being lost. Investigating.....

Update3: Removed the ACS712 from power.... saves 10mA. Now down to 10.2 mA overall, 4.1mA for the CPU. 6.1 mA remains to be found.... :-) (That could be the LM1117-5.0 that I'm using as the 5V regulator. )

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: Reducing power. (STM32F072)

Postby rew » Tue Feb 28, 2017 7:32 am

Update4: I tried measuring the consumption of the lm1117, but the board stopped working. Probably not related to the measuring attempt, but the measuring infrastructure was dismantled again in diagnosing the "stopped working"..... Anyway, the data sheet says to expect 5-10mA so six sounds reasonable.
Does anybody know a cheap regulator that can handle more than 16V? I'll need 60mA max.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 17 guests