Sketch is erroring with a stack overglow

at least I think that is the error as I was advised in another thread. The purpose of this thread is to try and figure out how to use the exception processing feature. I have downloaded the “tools” as a folder under the sketch folder.
When I try and decode the exception, nothing happens.
I am using Arduino 1.8.5 and this is a screenshot.

Start by posting your program

This is a screenshot.

Why?

Please read [General guidance](General Guidance and How to use the forum - Project Guidance - Arduino Forum)
And
How to use this forum
Especially item #7 on posting code.
Why any one thinks posting an image of their code or error messages is a good idea is beyond me.

PerryBebbington:
Why?

Why any one thinks posting an image of their code or error messages is a good idea is beyond me.

Thank you Perry and this is why.
I followed the instructions for using the exceptions procedure which asked me to post the exception listing into its window and the meanings would be listed in its bottom section.
Well, I did as instructed and nothing happened.
I dont know how to show the open window of the exception processor with the stack posted to it and nothing happening.
My screenshot shows:

  1. the exception codes as issued by my program
  2. the exception processing window with my programs error codes
  3. the empty (blank) section of the exception processor where the interpretation of the error message should be listed.

So, I am eager to learn how I would be able to show you this.

UKHeliBob:
Start by posting your program

Thank you Heli, and I can do that but I was really trying to get some answers as to why the exception processor procedure did not work as I read it.

  1. Tools\ESP exception decoder. (Opens another window for me to post my exception in the top 1/2)
  2. I cut and pasted my exception into the provided window, top 1/2.
  3. The exception decoder did not display any interpretation. (Perhaps I invoked it incorrectly)

I can post the sketch but I would rather try and work it out myself.
I took the example sketch, "servo" and inserted a few "Servo.println"s to see if I could figure out why it is causing an error.

I don’t know how to show the open window of the exception processor with the stack posted to it and nothing happening.

That’s a bit vague. Can you not copy the text in the window? It looks like you selected it, does right click give you a copy option? If not, does CTL C copy it? You can then paste it here between code tags </> top left in the tool bar.

To be fair, I probably don’t know the answer to your question, but I do know that not following the forum rules puts people off answering. The rules are not there to be awkward, they are there to make it easier for us to help you.

Perry, it is not clear to me what it is that you want to see. This is the text of the stack error. And it is what I copy into the exception debugger.

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffd60 end: 3fffffc0 offset: 01b0
3fffff10:  3ffe864d 00000000 4c206573 402036f9  
3fffff20:  3ffe8647 0000014f 3ffee349 40202d40  
3fffff30:  40201801 3ffee46c 3ffe865b 3ffee32c  
3fffff40:  402018f8 3ffee46c 3ffe8641 40201904  
3fffff50:  402018f8 3ffee46c 3ffe8641 40201b01  
3fffff60:  3ffee46c 00000150 3ffee328 40201b18  
3fffff70:  3ffee46c 0000014f 3ffee328 402010a5  
3fffff80:  40202e95 0000000a 3ffee4d4 40202e8a  
3fffff90:  3fffdad0 00000000 3ffee32c 3ffee4d4  
3fffffa0:  3fffdad0 00000000 3ffee494 402022ac  
3fffffb0:  feefeffe feefeffe 3ffe84ec 40100e99  
<<<stack<<<

Perry, it is not clear to me what it is that you want to see

It was more a case of posting text as text rather than an image of text.

That's better. I'm sorry I don't know the answer, but there are some people here much cleverer than me, I hope one of them knows the answer.

It would also help to post your code in the same way.

Thank you.

I think that I have corrected it and I will try and explain why the stack overflow is happening. Mind you this is only my presumption, but it seems to be able to run without a crash.
I am posting this in case others might have a similar issue.
1st some background.
I am trying to get a servo to work using an example program named “servos”. The board is a Feather Huzzah.
The example runs fine if I leave it alone but I wanted to be able to see the value of some variables as the sketch progressed.
So i inserted a few “Serial.println” statemenrs. And they were causing the stack overflow.
After a lot of reading and multiple tests I came upon the yield() command.and an unknown “to me”, feature of esp8266 processors?.
Mind you that this is only my assumption of what is causing the crash. The esp8266 wants to proceed on his merry way and that is fine as long as a slooooo×wwwwww, Serial.print command is trying to execute. I think that the serial port buffer is filling up and causing the crash.
I put a yield() command before each for command, and I think that what it does is assure that the for command completes before it tries to execute the Serial.println.

I am away from my desk right now and am trying to post this from memory. I will post the actual code when i return.
So, I say to anyone being plagued with WDT exceptions, have a look at the yield() command.

I will post only the statements involved, not the complete sketch,

Original, bug free sketch. Runs with no crash

/*************************************************** 
  This is an example for our Adafruit 16-channel PWM & Servo driver
  Servo test - this will drive 8 servos, one after the other on the
  first 8 pins of the PCA9685

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/products/815
  
  These drivers use I2C to communicate, 2 pins are required to  
  interface.

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// you can also call it with a different address and I2C interface
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);

// Depending on your servo make, the pulse width min and max may vary, you 
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN  150 // This is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  600 // This is the 'maximum' pulse length count (out of 4096)
#define USMIN  600 // This is the rounded 'minimum' microsecond length based on the minimum pulse of 150
#define USMAX  2400 // This is the rounded 'maximum' microsecond length based on the maximum pulse of 600
#define SERVO_FREQ 50 // Analog servos run at ~50 Hz updates

// our servo # counter
uint8_t servonum = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("8 channel Servo test!");

  pwm.begin();
  // In theory the internal oscillator is 25MHz but it really isn't
  // that precise. You can 'calibrate' by tweaking this number till
  // you get the frequency you're expecting!
  pwm.setOscillatorFrequency(27000000);  // The int.osc. is closer to 27MHz  
  pwm.setPWMFreq(SERVO_FREQ);  // Analog servos run at ~50 Hz updates

  delay(10);
}

// You can use this function if you'd like to set the pulse length in seconds
// e.g. setServoPulse(0, 0.001) is a ~1 millisecond pulse width. It's not precise!
void setServoPulse(uint8_t n, double pulse) {
  double pulselength;
  
  pulselength = 1000000;   // 1,000,000 us per second
  pulselength /= SERVO_FREQ;   // Analog servos run at ~60 Hz updates
  Serial.print(pulselength); Serial.println(" us per period"); 
  pulselength /= 4096;  // 12 bits of resolution
  Serial.print(pulselength); Serial.println(" us per bit"); 
  pulse *= 1000000;  // convert input seconds to us
  pulse /= pulselength;
  Serial.println(pulse);
  pwm.setPWM(n, 0, pulse);
}

void loop() {
  // Drive each servo one at a time using setPWM()
  Serial.println(servonum);
  for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
    pwm.setPWM(servonum, 0, pulselen);
  }

  delay(500);
  for (uint16_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
    pwm.setPWM(servonum, 0, pulselen);
  }

  delay(500);

  // Drive each servo one at a time using writeMicroseconds(), it's not precise due to calculation rounding!
  // The writeMicroseconds() function is used to mimic the Arduino Servo library writeMicroseconds() behavior. 
  for (uint16_t microsec = USMIN; microsec < USMAX; microsec++) {
    pwm.writeMicroseconds(servonum, microsec);
  }

  delay(500);
  for (uint16_t microsec = USMAX; microsec > USMIN; microsec--) {
    pwm.writeMicroseconds(servonum, microsec);
  }

  delay(500);

  servonum++;
  if (servonum > 7) servonum = 0; // Testing the first 8 servo channels
}

As modified by me. Will crash

for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) 
  {
    pwm.setPWM(servonum, 0, pulselen);
    Serial.print(servonum);
    Serial.print("-");
    Serial.println(pulselen);
      
  }

With the yield() statement . Runs with no crash

for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) 
  {
    yield();
    pwm.setPWM(servonum, 0, pulselen);
      Serial.print(servonum);
     Serial.print("-");
     Serial.println(pulselen);
       
  }

Hello hextejas,
That's why you need to post everything that's asked for in the forum instruction, in the manner indicated; you get better answers that way. Probably someone might have spotted that you need to use yield() at some point.

AFAIK yield allows the ESP8266 to do its Wi-Fi related tasks regardless of whatever else is going on. If loop() takes too long and there is no yield() either then it restarts. I infer from that and your description that loop() is taking too long. I don't know how long 'too long' is, but I think maybe it's about 3ms. Some research will tell you the answer.

The NODEMCU has a watchdog timer that is enabled by default. If your application hogs the CPU for too long, the watchdog fires, and throws an exception. If your code has blocks that take a long time to run, put a yield() or a delay(1) in those long sections.

As an example, insert a while(1); in your code, and it will, for sure, fire the watchdog. Change it instead to while(1){ delay(1); }, and no exception occurs.

Regards,
Ray L.

PerryBebbington:
Hello hextejas,
That's why you need to post everything that's asked for in the forum instruction, in the manner indicated; you get better answers that way. Probably someone might have spotted that you need to use yield() at some point.

Thank you Perry but I was trying to make it easier on the readers. It would take a while to read the complete sketch and find the section that I am working in. I thought that it would make your life easier by posting only the relevant code.
In this case, I am still not convinced that posting the complete code is of any more benefit than what I have done above.

I thought that it would make your life easier by posting only the relevant code.

The problem with that is you are assuming you know which is the relevant code. If you knew that for sure then you would not need to ask us questions. If your code is really long then the answer is to create a short program that illustrates the problem. Often, just doing that is enough for people to find the problem themselves.

I am pretty much convinced that there is something fundamentally wrong with your code that is causing the problem. I suspect it is written in a way that is blocking so that it doesn't return to loop() often enough.

For what it is worth I had a lot of grief when I first used ESP8266s, to the point I bought an MKR WiFi 1010, which has an ESP32 in it, intending to give up on the ESP8266. However, as I improved my code, found out about quirks of the 8266 the problems disappeared, without me ever really knowing why. I really like both the 8266 and the 32 now I've got to grips with both of them, my problem now is I'm not creative enough to think of a use for all the computing power they have. They are fabulous bits of kit, I just wish I could do them justice with some wonderful project I've yet to think of.