9 years, 2 months ago.

power saving LPC1768

for me it doesn't work unless I turn on another Peripheral

PCRIT The I2C0 interface power/clock control bit. 0 PCSPI The SPI interface power/clock control bit. 0

Peripheral_PowerDown(0xFF7F7FFF);

everything else is 1

so did I turned on only 2 Peripherals ? or did i turned off 2 Peripheral only?

0

#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);
}
Serial device(p28, NC);  // tx, rx

DigitalOut led1(LED1);


Ticker blinker;
int count=1;
 
void blink() {

   led1=!led1;
}
 
int main() {
    int result;
// Normal mbed power level for this setup is around 690mW
// assuming 5V used on Vin pin
// If you don't need networking...
// Power down Ethernet interface - saves around 175mW
// Also need to unplug network cable - just a cable sucks power
blinker.attach(&blink, 1.2);
    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/
// Supply power to mbed using Vin pin
    result = semihost_powerdown();
// Power consumption is now around half
 
// Turn off clock enables on unused I/O Peripherals (UARTs, Timers, PWM, SPI, CAN, I2C, A/D...)
// To save just a tiny bit more power - most are already off by default in this short code example
// See PowerControl.h for I/O device bit assignments
// Don't turn off GPIO - it is needed to blink the LEDs
        Peripheral_PowerDown(0xFE7F7FFF);// led:(0xFF7F7FFF); ---- led+serial:0xFE7F7FFF ------  
 
// use Ticker interrupt and Sleep instead of a wait for time delay - saves up to 70mW
// Sleep halts and waits for an interrupt instead of executing instructions
// power is saved by not constantly fetching and decoding instructions
// Exact power level reduction depends on the amount of time spent in Sleep mode
    
    while (1) {
        Sleep();
    }
}

is there a way to wake mbed from Deep sleep because it consumes less power

Question relating to:

by the way, running this code draws 86mA @5v. when i use DeepSleep .. it draws less then that mybe 55mA which is much better ..

I searched about it, deep sleep mode does not turn the watch dog off .. but I couldn't apply simon's code into the code any help ?

posted by hsn alattar 07 Apr 2015

2 Answers

8 years, 10 months ago.

thought I'd confirm power measurements on mbed LPC1768 (96MHz). Measurements were OK for Sleep(), peripherals ON, peripherals OFF, PHY off, and DeepSleep(). I pasted in the semihost_powerdown(), but it seemed to have NO effect (5v power into Vin, USB not connected)?? PowerDown() and DeepPowerDown() measured the same as DeepSleep()

140.0 ma  while(1);  default settings  (hacked USB cable for DMM current measurements)
127.9 ma  Sleep()
  91.6 ma  PHY off
  86.7 ma  all peripherals OFF ( 109.5ma all ON)
  59.6 ma  DeepSleep()

Any thoughts on how to get semihost_powerdown() to work?

Did you update the firmware for the interface as stated above?

// 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/
// Supply power to mbed using Vin pin
    result = semihost_powerdown();
// Power consumption is now around half
posted by Wim Huiskamp 02 Aug 2015

Ahhh. I had never updated firmware (above results were with 16457). I upgraded to 141212 and semihost_powerdown() seemed to work. Sleep() with peripherals off and PHY off was 112.4 ma, then adding semihost_powerdown() dropped to 51.8ma, then 19.6ma with DeepSleep().

generally power consumption was higher with newer firmware (?). With hacked USB cable and default settings (while(1)), power was 169.8 ma

Also, the commentary suggested that semihost_powerdown() would have no effect if USB cable was plugged in. With the 141212 firmware that was NOT the case. luckily, my power testing program had a 12 second blink prolog that allowed me time to copy new program to MBED before the USB disk disappeared from semihost_powerdown()

posted by tom dunigan 02 Aug 2015

Dear Tom,

I got the same (more or less the same) results as you after I ungraded the firmware to 141212.

It looks like the power that saved by adopting the PHY off reduces a lot.

Any ideas? Thanks in advance.

posted by Tony YI 13 Sep 2016
7 years, 9 months ago.

I did some experiments and I got several findings as follows.

When using the firmware 141212:

1. Both mbed_interface_powerdown() (mentioned in https://developer.mbed.org/handbook/Beta) and semihost_powerdown() (mentioned in https://developer.mbed.org/users/simon/notebook/interface-powerdown/) do shut down the magic interface.

2. With magic interface off only, the power consumption of a simple program (1 LED blinking) is about 72 mA.

3. With PHY off only, the power consumption of a simple program (1 LED blinking) is about 112 mA.

4. With both magic interface and PHY off, the power consumption of a simple program (1 LED blinking) is about 67 mA.

5. If you want to program your mbed with magic interface off in the last program, you need to hold the reset button and plug-in the USB cable and download the new program into the mbed.

When using the firmware mentioned in (https://developer.mbed.org/users/simon/notebook/interface-powerdown/):

1. The mbed_interface_powerdown() does not work but the semihost_powerdown() works fine.

2. With magic interface off only, the power consumption of a simple program (1 LED blinking) is about 104mA.

3. With PHY off only, the power consumption of a simple program (1 LED blinking) is about 96 mA.

4. With both magic interface and PHY off, the power consumption of a simple program (1 LED blinking) is about 67 mA.

5. If you want to program your mbed with magic interface off in the last program, download the new program like usual.

It looks like both firmware can achieve 67 mA power consumption when magic and PHY are off. However, using the second firmware may have better flexibility than the first one when you need to reprogram your mbed frequently.