Go Down

Topic: Atmel 24C256 showing up at wrong I2C address (Read 3 times) previous topic - next topic

PaulS

You pass the data into the i2c_eeprom_write_byte function as a byte. You store the byte in an int. Then, you cast the int to a byte to actually write it. Why?

You are converting the address to two bytes, then casting the bytes as ints to specify the two byte address. Why?

AlxDroidDev

I basically copied those functions from http://arduino.cc/playground/Code/I2CEEPROM and changed here and there to make it work somehow, but nothing writes to the memory.


This is how the code is currently standing:

Code: [Select]
uint8_t i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data ) {
    Wire.beginTransmission(deviceaddress);
    Wire.write((byte)(eeaddress >> 8)); // MSB
    Wire.write((byte)(eeaddress & 0xFF)); // LSB
    Wire.write(data);
    return Wire.endTransmission();
}

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


Learn to live: Live to learn.
Showing off my work: http://arduino.cc/forum/index.php/topic,126197.0.html

dannable

For what they cost I'd bin it and get a new one! Even if they had a batch especially made that had a different bus address you would still expect to be able to write and read the device.

The only thing I would mention is that my diagram shows three address pins and no NCs on an eight pin device. But you grounded the NC in any case.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

vj1953

HI,

Can you see if it works with a smaller serial data rate. I think some of the I2C eeprom parts support frequencies from 10kHz to 100kHz and then at 400khz

AlxDroidDev


HI,

Can you see if it works with a smaller serial data rate. I think some of the I2C eeprom parts support frequencies from 10kHz to 100kHz and then at 400khz


How do I do that?

HW or SW?
Learn to live: Live to learn.
Showing off my work: http://arduino.cc/forum/index.php/topic,126197.0.html

Go Up