You are reading a single comment by @Stevie and its replies. Click here to read the full conversation.
  • @Gordon - I checked the pulse example you gave above and it does work for me.

    @allObjects - Thanks for checking the data sheet. I did not check it myself, because the example suggested, that this could work. And for example the AVR Attiny allows a deep sleep but will maintain the pin values. Also for example the NXP LPC 810 which I often use as a barebones chip has a power mode which has very low consumption but still drives the IO pins.

    In any case, as written above, I tried the following as well:

    function onInit()
    {
      setInterval(function() {
        setDeepSleep(false);
        digitalWrite(LED2, true);
        setTimeout(function() {
          digitalWrite(LED2, false);
          setDeepSleep(true);
        }, 100);
      }, 1000);
      
      setDeepSleep(true);
    }
    

    If that would work, then I could achieve what I need. But it does not work either. Internally I would assume it does work because the pulse thing does work and it would have to disable the deep sleep according to your finding in the data sheet to be able to drive the pin.

    BTW: Although you can actually see the visual difference between a 3ms LED pulse and a 20ms LED pulse (the 20ms is much brighter), I did use the oszi as written in the original post to find out the time.

    For the interrupt driven operation: I think that's what @Gordon wants to make you believe :-). I don't think it is actually the case. In fact I believe it cannot be done. The way it usually works is that after initialization of the MCU, the processor then goes into a sort of main function which starts an endless loop. It will sleep in that loop until an interrupt occurs. In the interrupt handler it will have a very short routine which schedules some event. Then the loop in main wakes up and will handle the event. Then it goes to sleep again. I guess that's also why the documentation says that the deep sleep will come into effect when the current JavaScript execution is finished. That's when it returns to the main loop. Then it can sleep.

    If you would do everything in the interrupt then all other interrupts would be blocked and that would be bad for the IO timing if you do something which is longer than a few microseconds... And I wrote I believe it cannot be done in that pure way, because the loop is actually needed. Otherwise the CPU would crash (I believe). The least you need to have is something like "while(1) __WFI;".

About

Avatar for Stevie @Stevie started