Hello everyone.
I was trying to read and write a data byte in a I2C EEPROM memory, but I couldn't make it works.
I'm using the MC9S08QE16CLC, EEPROM M24C64 and C.W. 10.4.
This is the method I'm using it to write:
#define ADDRESS 80 // Address of the devices(7bits address 1010000)
byte Write_byte(word dir, byte data){
byte buff[2];
word datasend;
Error_M = (EEPROM1_SelectSlave(ADDRESS));
buff[0] = (byte) dir;
buff[1] = data;
while(Regreso!= ERR_OK){
Regreso = EEPROM1_SendBlock(buff, 2, &datasend);
}
Error_M =EEPROM1_SendStop();
return ERR_OK;
}
And this one to read:
byte Read_byte(word dir,byte* data){
dir = (byte)(dir);
Regreso = 0;
Error_M =EEPROM1_SelectSlave(ADDRESS);
while(Regreso!= ERR_OK){
Regreso =EEPROM1_SendChar((byte)(dir));
}
Error_M =EEPROM1_RecvChar(data);
Error_M =EEPROM1_SendStop();
return ERR_OK;
}
To test these functions I did this at PE:
word direccion = 10; // Address where the data will be stored
byte pruebacargar = 0;
byte level =60;
ERR_Main = Write_byte(direccion, level);
ERR_Main = Read_byte(direccion, &pruebacargar);
I dont know what to do to make it works, I have read the data sheet but I think I missing something.
Please I need help.
Thank for Advanced.