Cut here for exception decoder error

This is my code, if I remove the if statement inside the last while loop everything works fine but with the if statement the code only runs untill the last while statement. The code creates two arrays and compares the both to find values with a difference of 0.5.What am I doing wrong?


void setup(){
  Serial.begin(115200);
 }
void loop() {
  float array1[64];
  float array2[64];
  String uval1 = "";
  String uval2 = "";
  String uval3 = "";
  int i = 0;
  int j = 0;
  int k = 0;
  int l = 0;
  int m = 0;
  while (i < 64) {
     array1[i] = random(2000,3000)/100.0;
     array2[i]= array1[i];
     uval1+=array1[i];
     uval1+=",";
     i++;
    }
     Serial.println("array1=" + uval1);
     delay(1000);
 
  while (j<5){
    float value=random(2000,3000)/100.0;
    int index=random(0,64);
    array2[index]=value;
    Serial.println((String)value+" at "+index);
    j++;
    }
while (k < 64) { 
  uval2+=array2[k];
  uval2+=",";
  k++;
}
Serial.println("array2=" + uval2); 
delay(1000); 
while (l<64){
  if  ((array1[l]+0.5)<array2[l] || array2[l]<(array1[l]-0.5)){
    Serial.print((String)array2[l]+" at "+l);
    array1[l]=array2[l];
    l++;
  }
delay(10000);
}}

**Exception:

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3584, room 16
tail 0
chksum 0xb0
csum 0xb0
v2843a5ac
~ld
Soft WDT reset

stack>>>

ctx: cont
sp: 3ffffb90 end: 3fffffc0 offset: 01a0
3ffffd30: 00000000 3ffe8610 41ae6666 4020128d
3ffffd40: 41ae6666 41e228f6 41a9c28f 41ca28f6
3ffffd50: 41b7c28f 41ba3d71 41d47ae1 41af47ae
3ffffd60: 41a6f5c3 41e9d70a 41e0b852 41cc28f6
3ffffd70: 41b1d70a 41b88f5c 41cd47ae 41d6b852
3ffffd80: 41dcb852 41e7eb85 41ee7ae1 41ca8f5c
3ffffd90: 41ae147b 41b43d71 41deb852 41b1c28f
3ffffda0: 41ba147b 41d26666 41a0a3d7 41d93333
3ffffdb0: 41bf47ae 41db47ae 41eb999a 41c2cccd
3ffffdc0: 41dd5c29 41a2b852 41b63d71 41b4e148
3ffffdd0: 41abae14 41cca3d7 41a35c29 41a1999a
3ffffde0: 41e03d71 41c747ae 41b71eb8 41ee8f5c
3ffffdf0: 41a7ae14 41e570a4 41c75c29 41c88f5c
3ffffe00: 41ddeb85 41c95c29 41d43d71 41c9ae14
3ffffe10: 41ddc28f 41af1eb8 41c9d70a 41d46666
3ffffe20: 41b347ae 41e0cccd 41c00000 41e3eb85
3ffffe30: 41d770a4 41b2147b 41b71eb8 41c651ec
3ffffe40: 41ae6666 41e228f6 41a9c28f 41ca28f6
3ffffe50: 41b7c28f 41ba3d71 41d47ae1 41af47ae
3ffffe60: 41eee148 41e9d70a 41e0b852 41cc28f6
3ffffe70: 41b1d70a 41b88f5c 41cd47ae 41d6b852 **

Hi @srinidhi777
These delays are too big and catch ESP.
put the function " yield(); "
before the delay(10000) function;

RV mineirin

yield();
delay(10000);
like this? Sorry I'am new to arduino programming.
@ruilviana

@srinidhi777
test this sketch:

void setup() {
  Serial.begin(115200);
}
void loop() {
  float array1[64];
  float array2[64];
  String uval1 = "";
  String uval2 = "";
  String uval3 = "";
  int i = 0;
  int j = 0;
  int k = 0;
  int l = 0;
  int m = 0;
  while (i < 64) {
    array1[i] = random(2000, 3000) / 100.0;
    array2[i] = array1[i];
    uval1 += array1[i];
    uval1 += ",";
    i++;
  }
  Serial.println("array1=" + uval1);
  delay(1000);

  while (j < 5) {
    float value = random(2000, 3000) / 100.0;
    int index = random(0, 64);
    array2[index] = value;
    Serial.println((String)value + " at " + index);
    j++;
  }
  while (k < 64) {
    uval2 += array2[k];
    uval2 += ",";
    k++;
  }
  Serial.println("array2=" + uval2);
  delay(1000);
  while (l < 64) {
    if  ((array1[l] + 0.5) < array2[l] || array2[l] < (array1[l] - 0.5)) {
      Serial.print((String)array2[l] + " at " + l);
      array1[l] = array2[l];
      l++;
    }

    delay(10000);
  }
  yield();
}

Your post was MOVED to it's current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

It only prints till Serial.println("array2=" + uval2); and then returns garbage values in a single line :frowning:
@ruilviana

ESP32 or ESP8266?

@srinidhi777
Add a Serial.println(" ");

Thus:
Serial.begin(115200);
Serial.println(" "); // < < < ------ Add this line

to separate the data ESP prints at boot from your data.

I have teste here;

Serial monitor printout

array1=22.56,26.04,21.90,28.95,24.80,29.05,20.01,20.42,29.76,27.26,23.85,24.02,25.51,23.92,29.74,20.57,20.46,23.23,24.77,23.48,24.45,28.93,28.34,20.87,22.13,24.70,28.12,28.77,27.46,27.61,25.44,29.01,23.41,24.64,25.19,27.20,20.21,25.89,22.64,27.93,21.66,27.80,28.89,27.50,26.02,20.36,21.99,22.35,27.51,28.78,29.78,28.01,26.49,20.64,27.45,25.11,20.40,20.34,28.93,26.98,25.73,25.53,20.71,25.74,
29.39 at 54
20.89 at 51
21.15 at 53
24.58 at 36
23.24 at 43
array2=22.56,26.04,21.90,28.95,24.80,29.05,20.01,20.42,29.76,27.26,23.85,24.02,25.51,23.92,29.74,20.57,20.46,23.23,24.77,23.48,24.45,28.93,28.34,20.87,22.13,24.70,28.12,28.77,27.46,27.61,25.44,29.01,23.41,24.64,25.19,27.20,24.58,25.89,22.64,27.93,21.66,27.80,28.89,23.24,26.02,20.36,21.99,22.35,27.51,28.78,29.78,20.89,26.49,21.15,29.39,25.11,20.40,20.34,28.93,26.98,25.73,25.53,20.71,25.74,

Consider for a moment what happens when the while loop is running BUT l++; does not get executed. Number in l not increment, l stays on 0 ,array cell data in 0 does not equate, no increment l, test data in array cell 0, data in array cell 0 does not equate, l not increment, test data in array cell 0, data in array cell 0 does not equate, l not increment, test data in array cell 0, data in array cell 0 does not equate, l not increment, loop forever. TRIGGER WDT!!!!

put ++l outside of the if statement but inside the while.

1 Like

hey solved it! the l++ was inside the if statement and not while, thank you for helping tho

Does it work if you print them separately?

  Serial.print("array2=");
  Serial.println(uval2);