I2C Eeprom fails to write more than 2 bytes

Hi everyone.

In the past i've been able to page-write to my eeprom and had no problems. I haven't had much need for writing as i've been using the eeprom as a security-key for a project.

Now when i go to write it fails and appears to be only succesfully writing 2 bytes/addresses

Any pointers would be great as i'm bewildered as to why it no longer works. Cheers.

#include <Wire.h>

#define DEV_ADDR 0x50

const char* HASH = "SPAM";



void i2c_eeprom_write_page( int deviceaddress, unsigned int eeaddresspage, byte* data, byte length ) {
  Wire.beginTransmission(deviceaddress);
  Wire.send((int)(eeaddresspage >> 8)); // MSB
  Wire.send((int)(eeaddresspage & 0xFF)); // LSB
  byte c;
  for ( c = 0; c < length; c++)
    Wire.send(data[c]);
  Wire.endTransmission();
}

byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) {
  byte rdata = 0xFF;
  Wire.beginTransmission(deviceaddress);
  Wire.send((int)(eeaddress >> 8)); // MSB
  Wire.send((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
  Wire.requestFrom(deviceaddress,1);
  if (Wire.available()) rdata = Wire.receive();
  return rdata;
}

void write_hash(){
  i2c_eeprom_write_page(DEV_ADDR, 0, (byte *)HASH, sizeof(HASH));
  delay(100);
}

boolean check_hash(){
  // checks to see if the hash n the eeprom matches the constant
  static int addr = 0;
  byte b = i2c_eeprom_read_byte(DEV_ADDR, addr);
  while (b != 0){
    if (b != HASH[addr])
      return false;
    addr++;
    b = i2c_eeprom_read_byte(DEV_ADDR, addr);
  }
  return true;
}

void print_hash(){
  int addr = 0;
  byte b = i2c_eeprom_read_byte(DEV_ADDR, addr);
  while (b != 0){
    Serial.print((char)b);
    addr++;
    b = i2c_eeprom_read_byte(DEV_ADDR, addr);
  }
  Serial.println();
}

void setup() {  
  Serial.begin(115200);
  Wire.begin(); 
}

void loop() {
  write_hash();
  if (check_hash() == false){
    Serial.println("BAD");
  }
  else{ 
    Serial.println("ALL GOOD");
    print_hash();  
  }
  delay(2000);
}

Try adding a delay after the write/read operations.

I found about 3ms worked with my I2C EEPROM, but your mileage may vary.