I am trying to code p10 dot matrix display and iam getting the below error using ESP8266 controller

else if (scrollDirection == 2) {
    for (int i = -121; i <= WIDTH * PER_P10_W; i++) {
      yield();
      Serial.println(i);
      dmd.drawString(i, 2, MESSAGE1);
       yield();
    }
  }

while it runs from -121 to -80 and then gives error
ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3424, room 16

tail 0

chksum 0x2e

load 0x3fff20b8, len 40, room 8

tail 0

chksum 0x2b

csum 0x2b

v0004cb00

~ld

No idea.
Maybe post your whole sketch in code tags.

@lastchancename

#include <SPI.h>
#include <DMD2.h>
#include <fonts/Arial_Black_16.h>
#include <fonts/Arial14.h>
#include <Ticker.h> 

const int WIDTH = 5;
const int PER_P10_H = 16;
const int PER_P10_W = 32;
const int HEIGHT = 2;
const uint8_t *FONT = Arial_Black_16;
const uint8_t *FONT_new = Arial14;
const char *MESSAGE1 = "My String to scroll";
const char *MESSAGE2 = "[Innotronix]";

SPIDMD dmd(WIDTH, HEIGHT);

void setup() {
  Serial.begin(9600);
  dmd.setBrightness(50);
  dmd.begin();
  dmd.selectFont(FONT);
}

void loop() {
  
  String scrollText = "Your scrolling text here";
  int scrollDirection = 2; // 1 for up, -1 for down
int messageWidth = dmd.stringWidth(scrollText, FONT); 
  
  int cs = 16; // Adjust the value for font width
  int n = scrollText.length();
  int xdelay = 500; // Delay between scrolls

  // Scroll the text
  // while(true){
  if (scrollDirection == 1) {
    for (int i = HEIGHT*PER_P10_H; i >= -16; i--) {
      // dmd.clearScreen();
      dmd.selectFont(FONT);
      dmd.drawString(2, i, MESSAGE1 );
      delay(200);
    }
  } else if(scrollDirection == -1) {
    for (int i = -16; i <= HEIGHT*PER_P10_H ; i++) {
      // dmd.clearScreen();
      dmd.selectFont(FONT);
      dmd.drawString(cs, i, MESSAGE1);
      // delay(xdelay);
      delay(200);
  }
  }

else if (scrollDirection == 2) {
    for (int i = -121; i <= WIDTH * PER_P10_W; i++) {
      yield();
      Serial.println(i);
      dmd.drawString(i, 2, MESSAGE1);
       yield();
    }
  }
}

Without your hardware in front of me…
Is it possible you’re writing outside the display, or overflowing some other buffer ?

Maybe shrink the for loops by some, and see if the error still happens.

As you’ve discovered, this is a runtime error, not a compilation error, so it’s something dynamic that is changed while the code is running.
Most often a type overflow, or running out of bounds off a finite storage area.

This message means that the watchdog timer has been triggered. This happens when your code takes too long to finish executing loop(). However, adding yield() should fix this, if done correctly, because yield() "pats the dog" to reassure it that your code has not got stuck in an infinite loop somewhere.

@PaulRB Thank you for reply … I used yield(); but still the issue persist ...form the above code if i removed the line dmd.drawString(i, 2, MESSAGE1); then the for loop prints all values without any serial error... also i tried by putting yield(); inside the library code ...not worked..

Your could try increasing the baud rate, for example 115200.

Also please Auto-Format your code and post it again. That might help us spot an error about where the { } are placed.

@PaulRB tried changing baud rate not working

#include <SPI.h>
#include <DMD2.h>
#include <fonts/Arial_Black_16.h>
#include <fonts/Arial14.h>

const int WIDTH = 5;
const int PER_P10_H = 16;
const int PER_P10_W = 32;
const int HEIGHT = 2;
const uint8_t *FONT = Arial_Black_16;
const uint8_t *FONT_new = Arial14;
const char *MESSAGE1 = "Make in INDIA";
const char *MESSAGE2 = "[Innotronix]";

SPIDMD dmd(WIDTH, HEIGHT);

void setup() {
  Serial.begin(115200);
  dmd.setBrightness(50);
  dmd.begin();
  dmd.selectFont(FONT);
  // dmd.drawString(18, 0, MESSAGE1);
}

void loop() {
  String scrollText = "Your scrolling text here";
  int scrollDirection = 2;  // 1 for up, -1 for down
  int messageWidth = dmd.stringWidth(scrollText, FONT);
  // Set initial conditions for scrolling
  int cs = 16;  // Adjust the value for font width
  int n = scrollText.length();
  int xdelay = 500;  // Delay between scrolls

  if (scrollDirection == 1) {
    for (int i = HEIGHT * PER_P10_H; i >= -16; i--) {
      dmd.selectFont(FONT);
      dmd.drawString(2, i, MESSAGE1);
      delay(200);
    }
  } else if (scrollDirection == -1) {
    for (int i = -16; i <= HEIGHT * PER_P10_H; i++) {
      dmd.selectFont(FONT);
      dmd.drawString(cs, i, MESSAGE1);
      delay(200);
    }
  }

  else if (scrollDirection == 2) {
    for (int i = -121; i <= WIDTH * PER_P10_W; i++) {
      Serial.println(i);
      dmd.selectFont(FONT);
      dmd.drawString(i, 2, MESSAGE1);
      yield();
    }
  }
}

:thinking:

The other 2 directions have a delay() but the third has only a yield(). Do the other scroll directions work ok? What if you put delay(200) for all of them?

@PaulRB yes they work fine ...the issue is with only last for loop.. in this after some time the issue is repeated. if i put delay longer it will scroll slowly. there is no effect of delay in last loop.

If you use delay() in place of yield(), and different delays like 100, 200, is the error always at -80?

@PaulRB yes ... when i searched the issue and tried to resolve it by disabling the wdt still hardware wdt timmer resets the loop..i also tried using the interrupts...not worked.... do you have any idea why it is happening?

Are you using a standard font or custom font, generated by you?

@b707 using the fixed width fonts available in library...

Worth a shot ??

else if (scrollDirection == 2) 
{
  yield();
  for (int i = -121; i <= WIDTH * PER_P10_W; i++) 
  {
    //yield();
    Serial.println(i);
    dmd.drawString(i, 2, MESSAGE1);
     //yield();
  }
}

How did you find/calculate the values -121 and -80?

@PaulRB @runaway_pancake by using the Serial.println ..

I don't understand your response. Doesn't seem to answer questions from me or @runaway_pancake

Do not use WIDTH and HEIGHT names for your variables, it are predefined names of the AdafruitGFx library.

In general a bad idea name the variable with all upper letters - this names reserved for system and library macros.

@b707 okay...