You are viewing an older revision! See the latest version

Power Management

Here is a simple code example showing how to get started on using the power management features to reduce the power levels on mbed. The code blinks the LEDs using a bit less than half of the normal power levels. This code is based on some power control information in the forums at http://mbed.org/users/no2chem/notebook/mbed-power-controlconsumption/ and some new experimental firmware that allows the USB interface chip to reduce power levels at http://mbed.org/users/simon/notebook/interface-powerdown/

#include "mbed.h"
#include "PowerControl/PowerControl.h"
#include "PowerControl/EthernetPowerControl.h"
// Need PowerControl *.h files from this URL
// http://mbed.org/users/no2chem/notebook/mbed-power-controlconsumption/

// Function to power down magic USB interface chip with new firmware
#define USR_POWERDOWN    (0x104)
int semihost_powerdown() {
    uint32_t arg;
    return __semihost(USR_POWERDOWN, &arg);
}

DigitalOut myled1(LED1);
DigitalOut myled2(LED2);
DigitalOut myled3(LED3);
DigitalOut myled4(LED4);

Ticker blinker;
int count=1;
void blink() {
    count = count << 1;
    if (count > 0x08) count = 0x01;
    myled1 = count & 0x01;
    myled2 = count & 0x02;
    myled3 = count & 0x04;
    myled4 = count & 0x08;
}
int main() {
    int result;
// Normal mbed power level is around 690mW
//
// If you don't need networking...
// Power down Ethernet interface - saves around 175mW
// Also need to unplug network cable - just a cable sucks power
    PHY_PowerDown();
// If you don't need the PC host USB interface....
// Power down magic USB interface chip - saves around 150mW
// Needs new firmware (URL below) and USB cable not connected
// http://mbed.org/users/simon/notebook/interface-powerdown/
    result = semihost_powerdown();
// Power comsumption is now around half
//
// use Ticker interrupt and Sleep instead of wait - saves around 70mW
// Sleep waits for an interrupt instead of executing instructions
    blinker.attach(&blink, 0.0625);
    while (1) {
        Sleep();
    }
}


All wikipages