Search code examples
contiki

Calclulate Power consumption when CPU don't change to LPM Mode in Contiki


I need to calculate power consumption of CPU. According to this formula.

Power(mW) = cpu * 1.8 / time.

Where time is the sum of cpu + lpm.

I need to measure at the start of certain process and at the end, however the time passed it is to short, and cpu don't change to lpm mode as seen in the next values taken with powertrace_print().

all_cpu all_lpm all_transmit all_listen 116443 1514881 148 1531616 17268 1514881 148 1532440

Calculating power consumption of cpu I got 1.8 mW (which is exactly the value of current draw of CPU in active mode).

My question is, how calculate power consumption in this case?


Solution

  • If MCU does not go into a LPM, then it spends all the time in active mode, so the result of 1.8 mW you get looks correct.

    Perhaps you want to ask something different? If you want to measure the time required to execute a specific block of code, you can add RTIMER_NOW() calls at the start and end of the block.

    The time resolution of RTIMER_NOW may be too coarse for short-time operations. You can use a higher frequency timer for that, depending on your platform, e.g. read the TBR register for timing if you're compiling for a msp430 based sensor node.