Tipo cosi!?
#include <Wire.h>
#define disk1 0x50 //Address of 24LC512 eeprom chip
void setup(void)
{
Serial.begin(9600);
Wire.begin();
unsigned int address = 0;
writeEEPROM(disk1, address, 123);
Serial.print(readEEPROM(disk1, address), DEC);
}
void loop(){}
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data )
{
Wire.beginTransmission(deviceaddress);
Wire.send((int)(eeaddress >> 8)); // MSB
Wire.send((int)(eeaddress & 0xFF)); // LSB
Wire.send(data);
Wire.endTransmission();
delay(5);
}
byte readEEPROM(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;
}
Victor795:
Se sai scrivere una locazione sulla eeprom puoi creare un loop e scrivere 0xFF ( 255 decimale) su ogni locazione presente nella eeprom.Se non ricordo male quando sono nuove le locazioni hanno valore 0xFF