Hi everybody 8)
I'm trying to full 128Ko of data into a 24LC1025 i2c eeprom...
Here is the connection I made to an arduino 2009 and the eeprom:
Pin 1 -> GND
Pin 2 -> GND
Pin 3 -> VCC
Pin 4 -> GND
Pin 5 -> Analog4
Pin 6 -> Analog5
Pin 7 -> GND
Pin 8 -> VCC
Here I made this sketch based on a lot of samples I've see in through the web:
#include <Wire.h>
#define disk1 0x50 //Address of 24LC256 eeprom chip
void setup(void)
{
Serial.begin(9600);
Wire.begin();
writeEEPROM(disk1, 2, 21);
writeEEPROM(disk1, 32768, 145);
writeEEPROM(disk1, 65538, 203);
Serial.println(readEEPROM(disk1, 2), DEC);
Serial.println(readEEPROM(disk1, 32768), DEC);
Serial.println(readEEPROM(disk1, 65538), DEC);
}
void loop(){}
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data )
{
if( eeaddress > 65535 )
eeaddress = eeaddress | B00001000;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.write(data);
Wire.endTransmission();
delay(5);
}
byte readEEPROM(int deviceaddress, unsigned int eeaddress )
{
byte rdata = 0xFF;
if( eeaddress > 65535 )
eeaddress = eeaddress | B00001000;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.endTransmission();
Wire.requestFrom(deviceaddress,1);
if (Wire.available()) rdata = Wire.read();
return rdata;
}
And I get this result with the serial monitor :
203
145
203
Normally I have to get these values:
21
145
203
So there is a problem, I think the arduino goes to 0 after the 65535 value... I tried to change all the unsigned ints with longs but I have the same thing... I added this line of code but it doesn't work
if( eeaddress > 65535 )
eeaddress = eeaddress | B00001000;
So I'm limited only to 64Ko instead of 128Ko... such a shame!!!
Please help
Only one detail, I don't want to use any external library except the wire i2c library, because I will combine tlc5940 + DMX + LCD i I think the arduino will be limited with the internal timers... but I made some tests with wire and I didn't detected any problem...
Regards