• An odd but very reproducible issue here. The following very simple code runs flawlessly on Picos (2v01 and 1v99) when powered by USB connected to a computer (with or without IDE). But when powered by battery (5-6V), or a 5V (250mA) breadboard power supply, or USB connected to a 5V (1A or 2.4A output) wall wart, it will hang for about 0.5 seconds, either in the on or off state, then continue to run normally. This hanging first occurs within about 20 seconds and continues to occur periodically, typically within 20 second intervals. I have reproduced this on 4 different Picos.

    let on = true;
    function toggle() {
      on = !on;
      digitalWrite(LED1, on);
    }
    setInterval(toggle, 50);
    

    The code itself, which is from the "Getting Started" code on the Espriuno.com website, is not of interest to me, but I am trying to track down the cause of a similar hanging issue in a project I am working on. My project works fine until I run it apart from the computer. I kept stripping code and hardware away trying to find the source of the hanging until no hardware and virtually no code was left, just a setInterval(myFunction, 50) statement. Is there some issue with the Pico itself and moderately rapid setInterval calls, and if so, how does keeping a USB connection to a computer overcome that issue? The hanging is clearly detectable at faster intervals as well. Not sure about slower ones.

About

Avatar for jeffs @jeffs started