0

I have a 24CL256 external EEPROM, to which I wish to write 30,000 bytes of 8-bit data, reading from the built-in ADC of an ESP8266.

Here is my code:

void setup() {
  Serial.begin(115200);
  Wire.begin(D2, D1);
  Wire.setClock(400000UL);
  Serial.flush(); // flush the transmit buffer
  delay(100);
  Serial.flush();
  delay(1000);
}

void writeData(uint16_t *address) {
  uint8_t data = analogRead(A0) << 2;
  // ESP has 10-bit ADC, convert to 8 bit data
  Wire.beginTransmission(0xA0); // Address for I2C EEPROM
  Wire.write((*address) >> 8); // address of write pointer
  Wire.write((*address) & 0xFF);
  Wire.write(data >> 4); // MSB
  Wire.write(data & 0xFF); // LSB
  Wire.endTransmission();
}

void loop() {
  if(indx < 30000) {
    unsigned long currentMicros = micros();
    // 8KHz sample rate = sampling at 125uS
    if(currentMicros - previousMicros > 125) {
      previousMicros += 125;
      writeData(addr);
      addr += 2;
      indx += 1;
      Serial.println(indx);
    }
  }
}

The Serial.println() stops after a couple of 1000 Samples and resets ESP throwing error

wdt reset
load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v4ceabea9

I suspect there is some timer issue, but I'm not quite sure. Any help is appreciated.

  • @dda can you help me in this? – Ashish K Jan 12 '18 at 18:16
  • As the name implies WatchDog Timer (wdt) indicates something took to long. The only obvious thing I can think of is that I2C was held up to long. I would check how long Wire.endTransmission() is taking. – jdwolf Jan 13 '18 at 1:07
  • 1
    try putting a yield() as the last thing in loop – Jaromanda X Jan 13 '18 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.