Interfacing external EEPROM with PIC Microcontroller

In this project “Interfacing external EEPROM with PIC Microcontroller”, we will see how we can easily interface EEPROM via I2C Protocol. The need of external EEPROM as a permanent storage of data in any project is enhanced. So now question how to interface external EEPROM with PIC Microcontroller?

Project description:

In this project “Interfacing external EEPROM with PIC Microcontroller”, I used FM24C64 (EEPROM) and UART Port to receive data which have to be store. For interfacing EEPROM with PIC , see in figure that we have to connect SDA (Serial Data) pin of EEPROM with SDA pin of PIC Microcontroller and as well as SCL(Serial Clock) pin of EEPROM with SCL pin of PIC Microcontroller. Data from microcontroller is being send serially and store accordingly with given address. So for storing data to EEPROM we should send the address first to store the data. The communication is done between microcontroller and EEPROM through I2C communication protocol.

Interfacing external EEPROM with PIC Microcontroller

I2C Protocol:

To Know “Interfacing external EEPROM with PIC Microcontroller”, we have to know at least the basic of I2C Protocol. In I2C Protocol all devices  are connected parallaly as a slave with I2C bus see the bellow figure.

I2C Device addressing:

Every device connected as a slave have specified 7 bit or 10 bit address. For this project I use FM24C64 and it also has specified address. The spacified address for FM24C84 is

 1 0 1 0 a0 a1 a2 R/W = 10100000 (A0H for Write as per above circuit connection).

                                    = 10100001 (A1H for Read as per above circuit connection).

 I2C Protocol to write data at slave:

As we know in I2C communication data is being send serially. So it definite has some steps/protocol to write data in slave. In bellow you will find those steps for communicate with FM24C64 in Mikroc pro for PIC.

I2C1_Init(100000);                       // initialize I2C communication

I2C1_Start();                                 // issue I2C start signal

I2C1_Wr(0xA0);                          // send byte via I2C  (device address + W)

I2C1_Wr(Address1);                // send byte (address of EEPROM location)

I2C1_Wr(Address2);                // send byte (address of EEPROM location)

I2C1_Wr(Data);                         // send data (data to be written)

I2C1_Stop();                               // issue I2C stop signal

 See the bellow block diagram of that. 

Interfacing external EEPROM with PIC Microcontroller schematic

  I2C Protocol to read data at slave:

As like write protocol in i2c has specified protocol for read data from slave also. In bellow you will find those steps for communicate with FM24C64 in Mikroc pro for PIC.

I2C1_Start();                                 // issue I2C start signal

I2C1_Wr(0xA0);                          // send byte via I2C  (device address + W)

I2C1_Wr(address0);                // send byte (data address0)

I2C1_Wr(address1);                // send byte (data address1)

I2C1_Repeated_Start();       // issue I2C signal repeated start

I2C1_Wr(0xA1);                     // send byte (device address + R)

Take = I2C1_Rd(0);             // Read the data (NO acknowledge)

I2C1_Stop();                          // issue I2C stop signal

 

For more detail: Interfacing external EEPROM with PIC Microcontroller

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation and engineering. My writing style is clear and simple, and I am skilled in using infographics and diagrams. I am a great researcher and am able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter