Tag Archives: eeprom

24C1024 I2C EEPROM 128KB

24CXX I2C EEPROM Interface using SoftI2C lib

In this tutorial I will show you how to use our easy to use open source Soft I2C library to access a 24C64 EEPROM chip. We discussed the library in our previous tutorial. The functions developed in this tutorial will use services of the I2C library to read and write the EEPROM. The EEPROM access mainly contains only two routines. BOOL EEWriteByte(uint16_t address,uint8_t data); BOOL EEReadByte(uint16_t address ,uint8_t* data); The first one write a 8 bit data to a memory location specified by the variable address, since a EEPROM can have more that 256 bytes of storage that is why the address variable is 16 bit. The second function reads the memory location specified by the variable address and stores the read data in variable data. Both the function return EE_SUCCESS on success and EE_IO_ERROR on failure. How to develop the EEPROM Write function? We open the datasheet of 24C64A (64kbit) EEPROM and try to understand the random read and random write function. The figure 8 on page number 11 clearly describes the write steps. You just need to translate the figure into proper call to our Soft I2C lib API’s. BOOL EEWriteByte(uint16_t address,uint8_t data) { SoftI2CStart(); //SLA+W if(!SoftI2CWriteByte(EEPROM_WRITE_ADDRESS)) { SoftI2CStop(); //I2C i/o error return EE_IO_ERROR; } //Address HIGH if(!SoftI2CWriteByte(address>>8)) { SoftI2CStop(); //I2C i/o error return EE_IO_ERROR; } //Address LOW […]