Background tasks in deepSleep() ?

Posted on
  • Hello!

    I have an espruino original v1.3b with the latest 1.99 firmware, when I run this:

    reset()

    setDeepSleep(1);
    setBusyIndicator(LED1);
    setSleepIndicator(LED3);
    
    var t;
    
    setInterval(function () {
      t= E.getTemperature();
    }, 2222);
    

    save()

    and plug it into a wall charger, the blue light blips sometimes out of sync with the 2.2 seconds red light. Does it mean it's briefly coming out of deep sleep every now and then for some reason?

    https://youtu.be/4OzA4lZ5eC4

  • Yes, it is coming out of sleep a bit early sometimes.

    Basically the STM32F1 in the Espruino Original board can only wake up on the nearest second (not any more accurately), so what happens is:

    • STM32 is in deep sleep
    • STM32 wakes up <1 second before it has the task to do
    • Probably it notices that there's still some time to wait - it schedules a high speed timer to wake itself up at the correct time, and goes into a 'normal' sleep
    • Wakes up from sleep at the correct time to execute code
    • goes back to deep sleep

    The extra flashes are probably because of that...

  • With other timeouts it doesn't do it, for example 10000 ms. The Pico RTC alarm is more accurate and doesn't do it?

  • Gordon, my 1.3b original comes without the RTC xtal?

  • Yes, I believe the original boards that were produced for the KickStarter didn't have a low-speed oscillator. It's something I added for later revisions.

    For 10000 ms it's unlikely to do it because it's a multiple of 1 second, which the RTC can handle.

  • The current originals and Picos come with the RTC xtal?

  • PICOs were planned to have it populated, but for some reason it did not go into production, but can be after market populated with the - now available - RTC xtal component. There is a(t least one) conversation out there about it: Real time clock on Pico (rev 1.4). How it works on Espruino-Wifi, I don't know.

  • Thanks "allObjects". I can't solder such a tiny thing, much less the microscopic crapacitors :-)

    Gordon, how can I get some espruinos with the xtal in place and tested?

  • ...you hair-dry them... but yes, it's not one of everyone's basic tasks... I now that @DrAzzy does such things with success and, of course @Gordon. A custom order / service may get you there.

  • The WiFi boards and new Original boards both come with the low speed oscillator fitted (LSE) - unfortunately Pico wasn't because the chip in it requires a very specific type of crystal to work reliably, which I only found out just before production.

    So if you want a low speed oscillator:

    • If you get an Original from the online shop then I can guarantee it's the right one, but as long as the board you buy is a revision 1.4b (you could check with the seller) everything should be ok.
    • If you get a WiFi board from anywhere it'll be fine, since they all had the RTC fitted.
    • While the Espruino Bluetooth boards (Puck.js/Pixl.js/MDBT42Q) don't have a low speed oscillator, they do have some fancy calibration stuff that goes on using their high speed crystal, which means the RTC is still pretty accurate (20ppm, which is actually the same as the oscillator in the WiFi board!).

    Also worth noting that the non-Original boards can wake up from the RTC much more accurately (to 1/32k of a second) so the deepSleep issue you mentioned won't occur.

  • Ok, good to know, thanks!

    I have two originals and a Pico to play with, if I can pull it off "the espruino way" (in javascript), then I'll have to decide whether to use one or the other.

  • Even though the original board has way more GPIOs, I'm a proponent of using PICO. First, it has more - double - RAM / variables - 50% more flash, and is slightly faster, smaller foot print, and does not have the specialized prototype area, that - most of the time does anyway not cater to the specific needs you have - AND, may be the most helpful thing - the ports are all 5V tolerant.

    Should you really run out of GPIOs, there are easy ways to mend that: adding serially driven shift registers or port expanders.

    The issue that 8 pins are on 0.05" pitch is not really an issue because you can choose my or @Gordons approach to make all pins friendly to breadboard and 0.1" pitch: Breadboard friendly PICO (There are other options as well: shims from @Gordon and breakout boards fromn @DrAzzy).


    2 Attachments

    • breadBoardFriendlyPicoCreepyCrawler.png
    • breadBoardFriendlyPicoBoard.png
  • The lower the power the better for me, both in deep sleep and while running. Is that the mdbt42q?

  • Yes, the MDBT42Q definitely has the edge on power consumption - although it isn't as fast.

    Also on the MDBT42 you don't need setDeepSleep - the MCU handles everything automatically so you don't have to worry about it.

  • Good to know, thanks.

    IIRC l've seen a benchmarks folder somewhere in the repository in github? Are there any benchmarks to see anywhere?

  • Are there any benchmarks to see anywhere?

    No, there were a set of benchmarks produced for each build on the Original Espruino board, but that hasn't been done for years.

    It's been my plan to resurrect the per-build benchmarks and tests on the hardware, but that hasn't happened yet :(

  • Hey, thank you very much!

    I think I'll better ask the other power related things in another post, to keep things tidy.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Background tasks in deepSleep() ?

Posted by Avatar for Georg @Georg

Actions