Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In a tight loop, mostly deep sleeping, takes 600 milliseconds to go back to sleep #405

Open
microbit-carlos opened this issue Feb 12, 2024 · 1 comment
Labels
Milestone

Comments

@microbit-carlos
Copy link
Collaborator

With a bare minimum programme like this one:

#include "MicroBit.h"

MicroBit uBit;

int main() {
    uBit.init();

    while (true) {
        uBit.power.deepSleep(1000);
    }
}
image

It takes about 600 msec to fully go to deep sleep:
image

@microbit-carlos
Copy link
Collaborator Author

microbit-carlos commented Feb 12, 2024

Okay, if in the infinite loop the programme yields for a second we see a lower time to go to sleep:

    while (true) {
        uBit.power.deepSleep(1000);
        uBit.sleep(1000);
    }

So top level view:
image

If we zoom in, we can see the first half (one second) with uBit.sleep() and the half (one second) with uBit.power.deepSleep():
image
image

And if we zoom into at the 2nd half, when it is going into uBit.power.deepSleep(), we can see that it takes about 95 ms to go to sleep:
image

So it must be the combination of going to sleep and waking up in short succession that causes the 600 ms delay.

We can also see that the first 100ms of being awake are spending more power, so that's likely how long it takes for CODAL to try to wake and restore everything.
image

@microbit-carlos microbit-carlos added this to the v0.2.68 milestone Feb 27, 2024
@microbit-carlos microbit-carlos modified the milestones: v0.2.68, low power May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant