GrumpyOldPizza / arduino-STM32L4

69 stars 61 forks source link

a way to reduce power consumption further #4

Closed 8bitbunny closed 7 years ago

8bitbunny commented 7 years ago

A possible way to achieve this is by disabling USB on request in the code, as right now it remains on at all times(?), consuming a bit power. or by simply adding a compile option for the usb port, example: Serial+Files Serial only Files only RAW HID No USB

GrumpyOldPizza commented 7 years ago

If USB is connected, then USB powers the board. So there is really no good point worrying about the 2.5mA for the USB-OTG part.

If USB is not connected, and the board is powered by say a battery, then USB is not powered (if you are running with 24MHz or 16MHz then voltage range 2 is used over voltage range 1 to save even more power. Upon connect (or disconnect) this switch happens automatically.

Without USB connected (at power on reset), there are also lower clocks possible (8MHz, 4MHz, 2MHz and 1MHz).

The idea of disabling part of the USB code (like USB/MSC) is under investigation, but for a different reason. Disabling USB/CDC is a bad idea for the standard Arduino IDE, as the download normally happens via USB/CDC. The USB code itself is about 12k, so not that big of an impact if you have 512k FLASH available.