meetjestad / mjs_firmware

8 stars 4 forks source link

MJS2020: More powersaving #19

Open matthijskooijman opened 3 years ago

matthijskooijman commented 3 years ago

For MJS2020, I now implemented basic powersaving based on the STM32 "Stop" mode, resulting in about 3.6mA while sleeping. This mode stops all core clocks and some peripherals, puts the internal regulator in a low-power mode and is the lowest-power mode that preserves memory contents ("Standby mode" is even lower power, but greatly complicates programming because memory contents is lost, and the gain is limited - 0.45μA for stop, 0.29μA for standby).

There are still more things that can be done to improve power usage, both to improve the sleep power usage, as well as improve the overall power usage.

matthijskooijman commented 3 years ago

Wrt to stop mode and peripherals:

All this is with the 0.0.10 core version. It seems that git master has seen significant changes in how this locking and powersaving works, see also https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/125. The overall approach is still the same, except that now the USB stack completely shuts down when VBUS is not present (which won't help for us), but also when USBDevice.detach() is called, which is ideal.

It seems we could even try using USB suspend mode to keep the USB device enumerated during stop.