lancaster-university / codal-microbit-v2

CODAL target for the micro:bit v2.x series of devices
MIT License
41 stars 50 forks source link

Larger power consumption when the display is not cleared before `uBit.power.off()` #378

Open microbit-carlos opened 9 months ago

microbit-carlos commented 9 months ago

When something is shown in the display and we go into "power off" mode in battery power, we see a much larger power consumption.

We expect an average of around 35 uA @ 3.0V, but in this case we see around 850 uA.

Simply running uBit.display.clear() before uBit.power.off() resolves the issue, so we probably have some event running on the background to do with the display pins.

#include "MicroBit.h"

MicroBit uBit;

int main() {
    uBit.init();

    uBit.display.printChar('X');
    uBit.sleep(100);
    // uBit.display.clear();    // <-- Uncommenting this fixes the power consumption

    while (true) {
        if (uBit.buttonA.isPressed()) {
            uBit.sleep(500);
            uBit.power.off();
        }
        uBit.sleep(100);
    }
}

It's quite possible this might be a side effect of https://github.com/lancaster-university/codal-microbit-v2/commit/03c05e2c881b5db73be04d3cb8b9da1a37144061 from PR https://github.com/lancaster-university/codal-microbit-v2/pull/366, so we might have to look into a way to ensure the pin events are disabled without disabling GPIOTE completely.

microbit-carlos commented 9 months ago

Looking at the time between high current peaks confirms that we have something running on a 4ms interval:

image