Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PowerControl by
main.cpp
00001 #include "mbed.h" 00002 #include "PowerControl/PowerControl.h" 00003 #include "PowerControl/EthernetPowerControl.h" 00004 00005 #if 0 00006 int main() { 00007 //turn OSC1 down 00008 PHY_PowerDown(); 00009 wait(5); 00010 LPC_GPIO1->FIODIR = 0x8000000; 00011 LPC_GPIO1->FIOCLR = 0x8000000; 00012 wait(5); 00013 LPC_GPIO1->FIOSET = 0x8000000; 00014 wait(5); 00015 PHY_PowerUp(); 00016 } 00017 #else 00018 // Need PowerControl *.h files from this URL 00019 // http://mbed.org/users/no2chem/notebook/mbed-power-controlconsumption/ 00020 00021 // Function to power down magic USB interface chip with new firmware 00022 #define USR_POWERDOWN (0x104) 00023 int semihost_powerdown() { 00024 uint32_t arg; 00025 return __semihost(USR_POWERDOWN, &arg); 00026 } 00027 00028 DigitalOut myled1(LED1); 00029 DigitalOut myled2(LED2); 00030 DigitalOut myled3(LED3); 00031 DigitalOut myled4(LED4); 00032 00033 Ticker blinker; 00034 int count=1; 00035 00036 void blink() { 00037 count = count << 1; 00038 if (count > 0x08) count = 0x01; 00039 myled1 = count & 0x01; 00040 myled2 = count & 0x02; 00041 myled3 = count & 0x04; 00042 myled4 = count & 0x08; 00043 } 00044 00045 int main() { 00046 int result; 00047 // Normal mbed power level for this setup is around 690mW 00048 // assuming 5V used on Vin pin 00049 // If you don't need networking... 00050 // Power down Ethernet interface - saves around 175mW 00051 // Also need to unplug network cable - just a cable sucks power 00052 PHY_PowerDown(); 00053 00054 // If you don't need the PC host USB interface.... 00055 // Power down magic USB interface chip - saves around 150mW 00056 // Needs new firmware (URL below) and USB cable not connected 00057 // http://mbed.org/users/simon/notebook/interface-powerdown/ 00058 // Supply power to mbed using Vin pin 00059 result = semihost_powerdown(); 00060 // Power consumption is now around half 00061 00062 // Turn off clock enables on unused I/O Peripherals (UARTs, Timers, PWM, SPI, CAN, I2C, A/D...) 00063 // To save just a tiny bit more power - most are already off by default in this short code example 00064 // See PowerControl.h for I/O device bit assignments 00065 // Don't turn off GPIO - it is needed to blink the LEDs 00066 Peripheral_PowerDown(0xFFFF7FFF); 00067 00068 // use Ticker interrupt and Sleep instead of a wait for time delay - saves up to 70mW 00069 // Sleep halts and waits for an interrupt instead of executing instructions 00070 // power is saved by not constantly fetching and decoding instructions 00071 // Exact power level reduction depends on the amount of time spent in Sleep mode 00072 blinker.attach(&blink, 0.625);//0.0625 almost no difference 00073 while (1) { 00074 //Sleep(); 00075 DeepSleep(); 00076 //PowerDown(); 00077 //DeepPowerDown(); 00078 } 00079 } 00080 #endif
Generated on Tue Aug 16 2022 21:09:06 by
 1.7.2
 1.7.2 
    