Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By cal
#21645
FlyingHacker wrote:
cal wrote:Moin Kolban,
The reset is done by the watchdog timer if your code blocks the main loop for too long.
Using long delays on the esp8266 will typically lead to trouble.


"Delay" might not be the ideal choice of words, as I believe that the delay() function (even delay(0)) allows the Wifi code to run if needed, and resets the watchdog timer. A loop that takes a long time without any calls to delay() (or other methods of feeding the watchdog) will causes a watchdog reset.

Just a little clarification.CMIIAW


Moin FlyingHacker,

Thanks for the clarification.
I try to be accurate but the arduino ide on the esp8266 is a weak spot for me.
I know the nodemcu and the xtos/ets delays but don't know the espduino one.
Do you have a code pointer to the delay function and the main function that calls the classic sketch loop()? (github url?)
I think I understand the needs of the underlying xtos based SDK but want to understand how that is met
by the espduino delay/loop constructs.

I tried to locate them online but failed.

Thanks,
Cal
User avatar
By Marty
#21651 Thanks to all who have responded.

I have read a lot about the ESP devices and had not seen anything about this feature(?). It pretty much makes using interrupts out of the question, at least for me.

I did some further investigating to see what other limitations could be caused by the watchdog timer. I did a couple of very simple sketches with the ESP to see if they continue to run without stopping. First I did this:
Code: Select allvoid setup() {
  Serial.begin(115200);
  unsigned long time, duration;
  time = micros();
  for (int i = 0; i < 100; i++){
    delay(1000);
  }
  duration = micros() - time;
  Serial.print(" \n\nTime: ");
  Serial.println(duration);
}

This worked fine. There was no display evidence of a wdt reset. The time to count to 1 second, 100 times took, on average, about 100.31 seconds. The same sketch run on an Arduino UNO took 100.0006 seconds. So maybe the 31ms. error is cause by the wdt reset occurring but not stopping the sketch or printing.

Next, I inserted a signal to the ESP that goes high for 100ms. every 10 seconds. On the ESP, I polled every 1ms. to find, and then time, the positive pulses. This was my code:
Code: Select allint inPin = 13;

void setup() {
  Serial.begin(115200);
  pinMode(inPin, INPUT);
}

void loop() {
  unsigned long time, duration;
  boolean level;
 
  do{
    level = digitalRead(inPin);
    delay(1);
  }while (level == false);
 
  time = micros();
 
  do{
    level = digitalRead(inPin);
    delay(1);
  }while (level == true);
 
  duration = micros() - time;
 
  Serial.print("\n\nPulse Width: ");
  Serial.print(duration);
  Serial.println(" microseconds");

}


This also worked fine. If the watchdog timer came into play, it was not obvious.

Now, I have hope for this device, after all.

Is there documentation, that I missed, that gives in-depth information of the operation ( like the watchdog timer) of the ESP devices?

Thanks again
User avatar
By FlyingHacker
#21652 Glad you are making progress.

I have not tried pin interrupts on the ESP yet, though I think it supports them... at least according to this:

https://github.com/esp8266/Arduino#basi ... -functions


What if you used an interrupt like you wanted, but your main loop called delay(0) or yield() or similar? Also, I *think* that every time the main loop() function is called the equivalent of yield() (which according to my last link is the same as delay(0)) occurs, and the watchdog is reset and the wifi code gets to run. So you could simply have a blank loop() perhaps.

Does that do what you want?

As far as docs go, check the wiki (link at top) for some stuff. I have not read all the Expressif docs yet. That page I link to in this post has a lot of info crammed into a small space. I refer to it frequently.