Interfacing EEPROM with PIC Microcontroller

Interfacing EEPROM with PIC Microcontroller

Contents

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
    24C64 Pin Diagram
    24C64 Pin Diagram

    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.

 Device Addressing

24C64 EEPROM Device Addressing
24XX64 EEPROM Device Addressing

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.


Read the Next Page to read about reading and writing data from/to EEPROM. Please Jump to this page if you don’t need detailed explanation.

Share this post

  • Hi Ligo Sir

    I am designing a speedometer cum odometer for my motor cycle.I need your help.My compiler is Mikro C.How can i store the odometer readings to external eeprom if the readings exceed 8 bit data?How can i store if the kilometer exceeds 255?Your earliest reply is expected.Give me the mikro c code also.Thanks in advance.I am using pic16f877a and 24c02 eeprom.Need to store km readings and read it back and display it on lcd(16×2).

  • if i will use 2 eeprom in the i2c bus.first address will be 1010000 and second device adress will be 1010001 ??

  • Hi Ligo, may I plz have the code for C18 compiler?? Actually i need to write a code for Library Management system by using PIC18F4550 microcontroller.

  • oh, i got it now!u mean we hardwire the address of each EEPROMs by setting or grounding their A0,A1, A2 pins differently in 8 different combinations(since 3 bits are used), thus generating a particular address to each EEPROM, right? thanks a great deal

  • You can connect pins A0, A1, A2 of the eeprom to different status (VDD or VSS) … and you can address a particular eeprom as explained in the Device Addressing Section…

  • if we are connecting more than 1 EEPROMs then, (here since we can join 8 EEPROMs), how does the EEPROMs know that the a particular 3 bit code varying from 000 to 111 is meant for them?is there a code to assign those 3 bit codes to respective EEPROMs??

  • See the section Device Addressing…
    You can see that there are 8bits for addressing…
    Higher 4 bits (1010) is preset in the device.. next 3 bits are the status of A2, A1, A0 of the device and the last bit specifies whether we want to write or read from the device…….
    By using A2,A1,A0 we can connect up to 8 EEPROM to an I2C Bus….


  • >