Ar-zz-duboy / Arduboy

Core library for the Arduboy.
https://www.arduboy.com
Other
330 stars 96 forks source link

Incorporate complete USB power saving when not using USB #14

Open joshgoebel opened 9 years ago

joshgoebel commented 9 years ago

Ref: http://harizanov.com/2013/02/power-saving-techniques-on-the-atmega32u4/

Not only do you power USB down you also have to freeze the clock.

shogerr commented 9 years ago

Perhaps we can create a development branch and include this for some testing. What do you think?

joshgoebel commented 9 years ago

My core lib repository already has code for most of this.

shogerr commented 9 years ago

Can you link to the relevant code? Thanks.

joshgoebel commented 8 years ago

Actually all the work I've done so far is in the main repository now.

joshgoebel commented 8 years ago

So far, this issue itself is still open though. USB sucks power from the battery constantly, and that's what this issue was meant to address.

joshgoebel commented 8 years ago

For anyone else who wants to tackle this is what needs to happens:

  1. Power down USB fully according to the link above
  2. You want to hook the VBUSTI interrupt and when you see it power USB back up.

Then test to see if this actually works and lets you reflash the device. Or we could just turn off USB by default when on battery power and to reflash you have to plug your Arduboy in then turn it on.

The power savings he reports for turning off USB are almost 50% (for the CPU):

delay(8000);  // 11.35mA

power_usb_disable();
delay(8000);  //9.97mA

USBCON |= (1 << FRZCLK);             // Freeze the USB Clock              
PLLCSR &= ~(1 << PLLE);              // Disable the USB Clock (PPL) 
USBCON &=  ~(1 << USBE  );           // Disable the USB  
delay(8000);  // 5.3mA