Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

Output toggle loop hangs the system on beta4

ZanderoxZanderox USA
edited May 2016 in Mongoose OS

This simple output toggle loop hangs the system on beta4. Kills the AP as well. It runs for a few seconds before the hang. Same results with GPIO 0 and GPIO 2.

GPIO.setMode(2, GPIO.OUT, GPIO.PULLUP);
while(true) {
GPIO.write(2, true);
GPIO.write(2, false);
}

Comments

  • I can say more,
    while(true) {}; will kill system as well.
    ESP8266 works in cooperative multitasking mode,
    so,
    try to rewrite you code in this way:

    setTimeout(function() { GPIO.write(2, !GPIO.read(2)) }, 100);
    
  • Ah, yes. Kick watchdog Sys.wdtFeed() would also fix this. Interesting that nodemcu doesn't hang with similar loop. Guess they manage watchdog differently, if at all.

  • SergeySergey Dublin, Ireland
    edited June 2016

    We intentionally do not feed watchdog from within the interpreter, relying on developers knowing what they do. Busy loop in C is going to hang the system for the same reason.

Sign In or Register to comment.