-
Thanks! Your stopgap seems to be solving my problem. I can definitely wait a few seconds after boot before starting the loop. I can't use the setDeepSleep because I'm using a Serial port for radio. I'm considering switching to the analogWrite strategy that you suggest as well because I do need to pulse a pin in my actual project. Pulling a pin down is what triggers a read on a Lidar unit. Anyhow, I think I'm back in business. I know it isn't an energy efficient solution, but my unit will be plugged into wall power, so energy efficiency isn't my main concern. Thanks again.
-
Yes, I did setConsole() thing but it made no difference. I don't think it should apply anyhow since there are no console.log's in the code. It also doesn't matter whether I use save(), save on send, or just send the code without saving and keep the power on while switching between different power sources. Even without the Web IDE running, I get no hanging when powered by USB plugged in to computer. If I switch to any other power source (without stopping the program execution) hanging starts. If I switch back to USB/computer power (without stopping the program execution) hanging stops. I'm hoping someone else will confirm that they can see this happening.
-
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.
To close out this thread, I'd like to suggest an addition to documentation in relation to the page AkosLukacs mentioned above . At least for Pico users, Serial2 is also available as per the hardware reference, in case Serial1 is being used for something else, as was my case. Also it should be noted that while the Serial ports can receive occasional console data, they don't seem capable of keeping up with a constant stream, for instance sensor data that's being polled every few milliseconds. We may be used to watching that data scroll quickly down the console window of a PC, but it seems to overload a Serial port rather quickly. I think that sort of console.log just needs to be turned off. Thanks again for helping me get my project working.