Getting strange reboots
Posted: Wed Sep 14, 2016 5:23 pm
The following code keeps an LED on while it is running. The code below works perfectly.
However when I change "for(q=0;q<10;q++)" to "for(q=0;q<10000;q++)" it runs fine for a few seconds and the LED on the ESP8266 flashes and the LED the code is controlling goes out for a second or two, so I guess the ESP8266 rebooted. The entire code is below.
Does anyone have any idea why it would be acting like this?
Code: Select all
for(q=0;q<10;q++) {
for(y=0;y<20;y++) {
if(y<20) {
/* One cycle of HIGH */
for(x=0;x<8;x++) {
for(i=0;i<8;i++) {
digitalWrite(serialIn, HIGH);
digitalWrite(srck, HIGH);
digitalWrite(srck, LOW);
}
digitalWrite(latch, HIGH);
digitalWrite(latch, LOW);
}
} else {
/* One cycle of LOW */
for(x=0;x<8;x++) {
for(i=0;i<8;i++) {
digitalWrite(serialIn, LOW);
digitalWrite(srck, HIGH);
digitalWrite(srck, LOW);
}
digitalWrite(latch, HIGH);
digitalWrite(latch, LOW);
}
}
}
}
However when I change "for(q=0;q<10;q++)" to "for(q=0;q<10000;q++)" it runs fine for a few seconds and the LED on the ESP8266 flashes and the LED the code is controlling goes out for a second or two, so I guess the ESP8266 rebooted. The entire code is below.
Code: Select all
int srck = 15;
int latch = 13;
int reset = 12;
int serialIn = 14;
int x = 0;
int i = 0;
int y = 0;
int z = 0;
int q = 0;
void setup() {
pinMode(srck, OUTPUT);
pinMode(latch, OUTPUT);
pinMode(reset, OUTPUT);
pinMode(serialIn, OUTPUT);
digitalWrite(srck, LOW);
digitalWrite(latch, LOW);
digitalWrite(reset, LOW);
digitalWrite(serialIn, LOW);
digitalWrite(reset, HIGH);delay(1);
digitalWrite(reset, LOW);delay(1);
}
void loop() {
for(q=0;q<10000;q++) {
for(y=0;y<20;y++) {
if(y<20) {
/* One cycle of HIGH */
for(x=0;x<8;x++) {
for(i=0;i<8;i++) {
digitalWrite(serialIn, HIGH);
digitalWrite(srck, HIGH);
digitalWrite(srck, LOW);
}
digitalWrite(latch, HIGH);
digitalWrite(latch, LOW);
}
} else {
/* One cycle of LOW */
for(x=0;x<8;x++) {
for(i=0;i<8;i++) {
digitalWrite(serialIn, LOW);
digitalWrite(srck, HIGH);
digitalWrite(srck, LOW);
}
digitalWrite(latch, HIGH);
digitalWrite(latch, LOW);
}
}
}
}
}
Does anyone have any idea why it would be acting like this?