Interfacing EEPROM with PIC Microcontroller
What is an EEPROM ?
EEPROM is an abbreviation for Electrically Erasable Programmable Read Only Memory and it is a Non-Volatile memory. It is used in computers and other electronic devices to store data that must me saved during no power supply. EEPROM is a class of ROM (Read Only Memory) which can be electrically erased in bit by bit and able to store new data. A small amount of EEPROM (usually 128/256 bytes) is available internally with PIC Microcontrollers. I have already posted about Using Internal EEPROM of PIC Microcontroller. But if the amount of data that we required to store in EEPROM is large, say in the order of Kilobytes then we have to interface external EEPROM with PIC Microcontroller.
There are many types of EEPROM chips are available from a number of manufactures. 24C series are the one of the most popular serial EEPROMs. It uses I2C (Inter-Integrated Circuit) bus to interface with Microcontroller and are available up to 128KB. I2C is a multi-master serial single ended computer bus used to interface low speed devices to a cellphone, embedded system, mother board or other electronic devices.
Here we are using 24C64 64K serial EEPROM. 24C64 works as a slave device on I2C bus. Register access can be obtained by implementing a START signal followed by device identification address. Then each memory locations can be accessed by using its address until a STOP condition is executed.
Pin Descriptions of 24C64 EEPROM
- A0, A1, A2 – Chip Address Inputs : These inputs are used for multiple device operations. The logic levels on
these input pins are compared with the corresponding bits in the slave address and the chip is selected if the compare is true. Thus up to eight devices can be connected to same bus using different chip select bit combinations.
- WP – Write Protect : When this pin is kept LOW (grounded) normal read and write operations are possible but when it is HIGH (Vcc) write operations will be inhibited. The internal PULL DOWN resistor of this pin keep the device unprotected when it is left floating.
- Vcc and Vss : Vcc is the positive DC supply pin. The device is able to work with in 1.8 to 5.5V range. Vss is the ground pin (0v).
- SDA – Serial Data : This is bidirectional pin used to transfer data and address to and from the device.
- SCL – Serial Clock : This pin is used to synchronize data transfer through SDA.
Control Byte is the first byte received by a slave device after receiving start signal from a master device. For 24C64 first 4 bits are control code (1010) for the device identification. Next 3 bits of the control byte are Chip Select Bits (A2, A1, A0). These bits allows us to connect up to eight 24XX64 devices on the same bus. The Chip Select Bits of control byte must be correspond to the logic levels of A2, A1, A0 of the device to be selected. The last bit of Control Byte is used to define the operation to be performed. It is set to 1 when read operation is to be performed and set to 0 when write operation is to be performed.