delayMicroseconds() – crash · Issue #2240 · esp8266/Arduino · GitHub

ESP12F

I’m working on a PWM Routine (not finished still in progress) which did crash for some reason (code#1)

 

 

reason is that your whole routine is fully blocking for the cpu and it takes more than the watch dog permits (thus triggering soft wdt reset). The reason why it does not crash when you add delay() is that delay() actually switches the context back to the system while you are delaying and feeding the watchdog this way.

void delayMicroseconds(uint32_t us){
  uint32_t start = micros();
  while(micros() - start < us){}
}

void delay(uint32_t ms){
  uint32_t start = millis();
  while(millis() - start < ms){
    yield();//give the system a chance to execute
  }
}

 

 

 

Source: delayMicroseconds() – crash · Issue #2240 · esp8266/Arduino · GitHub

delayMicroseconds() – crash · Issue #2240 · esp8266/Arduino · GitHub was last modified: February 25th, 2018 by Jovan Stosic