In this article, we are going to learn about Interfacing External EEPROM with a PIC microcontroller. All the microcontrollers do not have EEPROM but sometimes, we need to save some information in EEPROM while the MCU does not have any. In that case, external EEPROM is the only solution. So in this article, we’ll see how we can interface external EEPROM with a PIC microcontroller. So let’s start!

Disclaimer: Electricity is always dangerous. Proper skill is required to work with electricity. Do work at your own risk. The author will not be responsible for any misuse or harmful act or any mistake you make. The contents of this website are unique and copyright protected. Kindly don’t do any nonsensical act copying and claiming it as yours. Most of the articles published here are kept as open-source to help you. Take the knowledge for free and use it, but if you are interested you can buy the ready resources offered here. If you need any help or guide feel free to comment below, the author will try to help you. Thanks.

Table of Contents

About External EEPROM:

External EEPROM ICs are available in wide ranges of memory capacity and size. But one common thing is the interface mechanism. Most of the EEPROMs support the I2C protocol. Some common External EEPROMs are:

The 24 series have wide ranges of memory capacity ICs available. We can use anyone that is suitable for our work. Let’s get to the work directly.

Circuit Diagram:

For this test project, I’ll use the simple and common PIC microcontroller, PIC16F73. And another common EEPROM 24C08.

Here, R1 & R2 are important to use. The other pins of the IC are the address pins. If you want to use multiple ICs, then you need to address them separately utilizing those address pins.

A0, A1, A2 are the address pins. The datasheet of this IC describes all.

That means, if you want to read from the IC, then the control byte will be 1010 A0 A1 A2 1. I mean, if your IC’s address pins are (A0~A2) are all 0, then it will be: 1010 000 1 = 0xA1. Similarly, if you want to write, then it will be 0xA0. Now, let’s code for it.

mikroC code:

// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections

// Software I2C connections
sbit Soft_I2C_Scl           at RC3_bit;
sbit Soft_I2C_Sda           at RC4_bit;
sbit Soft_I2C_Scl_Direction at TRISC3_bit;
sbit Soft_I2C_Sda_Direction at TRISC4_bit;
// End Software I2C connections

unsigned short read_EEPROM(unsigned short address)
  unsigned short r_data;
  Soft_I2C_Start();// issue I2C start signal
  Soft_I2C_Write(0xA0); // send byte via I2C (device address + W)

void write_EEPROM(unsigned short address,unsigned short w_data)
  Soft_I2C_Start(); // issue I2C start signal
  Soft_I2C_Write(0xA0); // send byte via I2C (device address + W)

int a=0;
char txt[]="00";
int k=0;

void main()
  TRISA = 0x0F;//RA0 input
  TRISB = 0x00;//all output
  TRISC = 0xFF;//all input
  ADCON1= 0x07;//all digital
  ADCON0= 0x00;//ADC OFF

  Soft_I2C_Init();           // Initialize Soft I2C communication
  Lcd_Init();                // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);       // Clear LCD display
  Lcd_Cmd(_LCD_CURSOR_OFF);  // Turn cursor off
     a = 0;
     a = read_EEPROM(0);
     txt[0] = a/10 + 48;
     txt[1] = a%10 + 48;
     Lcd_Out(1,1,"Read from EEPROM");


}//void main

As PIC16F73 does not have a master i2C, we used software i2C. There is no complex part in this code.



This article was not a complete project, but it is more than that. It explores an option for MCU to use EEPROM. Anyway, if you feel that this article helps you, don’t forget to share it with others. Thanks.


Also let me know what do you want to get as the next article, comment below!

This article may be helpful for you too: Not Enough ROM/RAM error with micro-controllers


Mithun K. Das; B. Sc. in EEE from KUET; Head of R&D @ M's Lab Engineering Solution. "This is my personal blog. I post articles on different subjects related to electronics in the easiest way so that everything becomes easy for all, especially for beginners. If you have any questions, feel free to ask through the contact us page." Thanks.

1 Comment

R K Hamy · December 15, 2021 at 8:23 am

Many Thanks for the tutorial

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *