cancel
Showing results for 
Search instead for 
Did you mean: 

Power consumption testing - beware the

gdp123a
Associate II
Posted on February 22, 2008 at 23:23

Power consumption testing - beware the

2 REPLIES 2
gdp123a
Associate II
Posted on May 17, 2011 at 12:24

The following might be obvious to ARM processor experts, but I thought I would mention it to hopefully save others from the same mistake I made. (Note: The current measurements mentioned below are only for comparison purposes, the values might be different on later versions of the chip and with different hardware and test instruments.)

Be careful using the infinite loop ''while (1) ;''. I was moving this statement around my program so I could stop the program and measure the current at various stages of hardware initialisation - however I was getting wildly fluctuating current measurements.

The statement ''while (1);'' compiles to the assembler branch (b) statement:

''address: b address''

It appears that this branch statement uses different amounts of current, depending on the address of the branch (something to do with prefetches).

For example, if running from FLASH, 3V 2MHz, the current consumption I measured was:

For address= 0XXXXXXX0h, ..X2h, X8h, XAh => 0.9 mA

For address= 0XXXXXXX4h, ..X6h, XCh, XEh => 3.0 mA

From my tests, the first figure represents the minimum power consumption possible from a piece of assembler - and the second figure represents the maximum. In other words, the same loop structure represents both the best and worst power consumption, depending on where it is placed.

In general, the current consumption varies significantly depending on the type of code executed (it would be interesting to know what code ST used to determine its typical current consumption).

So if you have to use software delays loops, (sometimes it's simpler than using SLEEP or STOP), avoid a small loop such as:

''address: subs r0, r0, #1 ''

'' bne address ''

this loop uses 2.7mA. A larger loop which reads an IO port many times before branching uses much less power - eg. 1.2mA.

Greg.

gdp123a
Associate II
Posted on May 17, 2011 at 12:24

I've just discovered how easy the Systick is to use (refer to FWLIB Systick example) and that it works fine when combined with the sleep command (for some reason I thought that maybe the systick would be switched off with the sleep command).

Anyway, I now have a simple and very low power method of delaying while I wait for the RTC crystal to stabilise (after reset).

(FWLIB suggestion: where the program loops waiting for a Systick interrupt, the WFI command could be inserted)

Greg