AnsweredAssumed Answered

I2C in M24256W EEPROM

Question asked by ioniriondo on Oct 23, 2012
Latest reply on Oct 24, 2012 by ioniriondo

Hi! I'm programming an EEPROM with the i2c protocol, and i'm having problems with it. I'm trying to write one byte in the EEPROM to read it, but the problem is that I'm not able to read that byte.

 

Waching it with an osciloscope, seems like al the data it's sent right, but when reading it, the value that it returns is FFh even when I set 00h as the byte to write. In the Datasheet it is speficied that the power-on default value for the EEPROM is FFh.

 

After some modifications I achieve to return a 00h, but again, now always returns a 00h even if a write for example a 50h.

 

I've been  searching a lot about this EEPROM but there is few information about it. This is my code for wrting and reading:

 

void I2C1ByteWriteM24256( _SOFT_U8BITS u8deviceaddress, _SOFT_U8BITS u8highaddress, _SOFT_U8BITS u8lowaddress, _SOFT_U8BITS u8bytevalue){

 

        _SOFT_U8BITS u8address

 

       u8address = u8deviceaddress;

       u8address = u8address << 1;

       u8address = u8address | 0x00;

 

       i2c1_Start();

       I2C1_D = u8address;//((u8deviceaddress << 1) | 0x00);//Write mode

       i2c1_Wait();

       I2C1_D = u8highaddress;

       i2c1_Wait();

       I2C1_D = u8lowaddress;

       i2c1_Wait();

       I2C1_D = u8bytevalue;

       i2c1_Wait();

       i2c1_Stop();

       Pause();

 

_SOFT_U8BITS I2C1RandomAddresSReadM24256(  _SOFT_U8BITS u8deviceaddress, _SOFT_U8BITS u8highaddress, _SOFT_U8BITS u8lowaddress){

 

       _SOFT_U8BITS u8address;

       _SOFT_U8BITS u8addressW;

       _SOFT_U8BITS u8addressR;

 

       _SOFT_U8BITS u8return_value;

 

       u8address = u8deviceaddress;

       u8addressW = (u8address << 1) | MWSR; //0x00 Para escritura

 

       u8address = u8deviceaddress;

       u8addressR = (u8address << 1) | MRSW; //0x01 Para lectura

 

       i2c1_Start();

       i2c1_write_byte (u8addressW);

       i2c1_Wait();

       i2c1_write_byte (u8highaddress);

       i2c1_Wait();

       i2c1_write_byte (u8lowaddress);

       i2c1_Wait();

 

       i2c1_RepeatedStart();

       i2c1_write_byte (u8addressR);

       i2c1_Wait();

       i2c1_EnterRxMode();

       u8return_value = i2c_read_byte();

       i2c1_Wait();

       i2c1_DisableAck();

       i2c1_Stop();

       u8return_value = i2c_read_byte();

       Pause();

 

       return(u8return_value);

 

 

 

Outcomes