You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I was naively going to use a busy-wait delay for stuff under 100us

    That's fine. I'd do:

    var sleepTime = 0;
    function utilTimerReschedule(time) { sleeptime = time; }
    function handleIRQ() {
      do {
       handleTimer();
      while (sleepTime<100us and not_going_for_too_long);
    }
    

    Do I need to handle long intervals

    No - just schedule for the maximum and Espruino will just do the handler, realise nothing is needed, and do nothing.

    IRAM

    Wow, that sucks. Could be a pain trying to track that all down, although not as bad as if it executed JS!

    setTimeout

    Ahh, no - so setTimeout executes JS, but since the JS takes a while to execute I provided some utility stuff that you can use for doing pulses/etc via IRQ. Main one is digitalPulse, but also Waveform uses it for recording/playing back sound, and it's also used for analogWrite(...,{soft:true})

    jshSleep

    On STM32, jshSleep should put the processor to sleep for the amount of time given, so that it wakes either after that time or when there's an IRQ from Serial, GPIO, Utility Timer, SysTick, etc. If setDeepSleep is 1 and there's nothing in the utility timer then it'll go into proper low power sleep.

    If it's given 0xFFF..FFF then that means it should only wake up if there's an IRQ - not after a time period.

About

Avatar for Gordon @Gordon started