Projects   /   Communication & Interfacing   /   PIC16F877A

Interfacing of PIC16F877 with (i2c based) 24LC64 EEPROM (Code + Proteus simulation)

This post provides the code for interfacing 24LC64 EEPROM with PIC16F877 microcontroller. This 24LC64 EEPROM has i2c based interface.

Published
Updated

At a glance

CategoryCommunication & Interfacing
PIC modelPIC16F877A
IncludesCircuit diagram · Proteus · Download files
Reading time~3 min
Jump to a section
  1. Code
  2. Downloads
  3. Quick Solutions to Questions related to Interfacing 24LC64 EEPROM with PIC16F877:
  4. Related projects

Summary of Interfacing of PIC16F877 with (i2c based) 24LC64 EEPROM (Code + Proteus simulation)

This article details interfacing a 24LC64 EEPROM with a PIC16F877 microcontroller using the I2C protocol. Written in C via MPLAB and HI-TECH C, the code stores the string 'Saeed' in the EEPROM and retrieves it for display on an LCD. The Proteus simulation confirms successful data storage and retrieval, utilizing specific RC pins for communication and pull-up resistors.

Parts used in Interfacing 24LC64 EEPROM with PIC16F877:

  • PIC16F877 microcontroller
  • 24LC64 EEPROM
  • LCD (4-bit mode)
  • RC4 pin (SDA)
  • RC3 pin (SCK)
  • 10K resistors
  • I2C Debugger Tool

PIC16F877 with 24LC64

This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the 'Downloads' section at the bottom of this page.

It is assumed that you know how to interface LCD with PIC16F877 microcontroller in 4bit mode. If you don't then please read this page first, before proceeding with this article. It is also assumed that you know how to use i2c module in PIC16F877, if you don't then please read this page first. You should also read how to write/read a byte in/from 24LC64 EEPROM from it's datasheet.

The result of simulating the code in Proteus is shown below.

PIC16F877 with 24LC64 Schematic

In the above circuit[1], RC4 pin is being used as SDA pin and RC3 pin is the SCK pin. Both of these pins are pulled up using 10K resistors as required for i2c protocol. 24LC64 EEPROM is the slave device, while PIC16F877 is configured to be the master. LCD is also attached with PIC16F877, just to show the values received from the EEPROM, otherwise it is not required in this circuit. Proteus provides an 'I2C Debugger Tool' which is attached on the SDA and SCK pins in the above circuit, this debugger shows all the activity on i2c bus[2]. It is attached in the circuit just for debugging purposes.

In the code, string 'Saeed' is stored in the 24LC64 EEPROM and then retrieved back and displayed on the LCD. As shown in Figure 1, 'Saeed' is correctly displayed on the LCD, this shows that it was stored and retrieved from 24LC64 EEPROM successfully.

Code

The code for the main function is shown below.

Downloads

24LC64 EEPROM interfacing with PIC16F877 code was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.

 

For more detail: Interfacing of PIC16F877 with (i2c based) 24LC64 EEPROM (Code + Proteus simulation)

  • How is the code written?
    The code is written in C language using MPLAB with the HI-TECH C compiler.
  • Which pins are used for SDA and SCK?
    RC4 pin is used as the SDA pin and RC3 pin is used as the SCK pin.
  • What type of resistors are required for the I2C protocol?
    Both SDA and SCK pins are pulled up using 10K resistors.
  • What is the role of the PIC16F877 in this circuit?
    The PIC16F877 is configured to be the master device while the EEPROM is the slave.
  • Can the LCD be removed from the circuit?
    Yes, the LCD is attached only to show values received from the EEPROM and is not required in the core circuit.
  • What tool is used for debugging the I2C bus?
    Proteus provides an I2C Debugger Tool which is attached on the SDA and SCK pins.
  • What string was stored and retrieved successfully?
    The string Saeed was stored in the 24LC64 EEPROM and retrieved back for display.
  • Which software versions were used for compilation and simulation?
    The code was compiled in MPLAB v8.85 with HI-TECH C v9.83, and simulation was made in Proteus v7.10.
Beginner Tutorials · PIC16F877A

PIC16F877 Driving LCD in 4-Bit Mode using PIC16F877 with Proteus Simulation

Introduction This microcontroller project shows how a PIC16F877 can drive an LCD display using 4-bit mode inside a Proteus simulation.The project demonstrates...

Programmers & ICSP · PIC16F877A

EPE PIC/LCD Demo using PIC16F877 with Proteus Simulation

IntroductionThe EPE PIC/LCD Demo is a classic microcontroller project that demonstrates how a PIC16F877 can fully control a PG12864F graphical LCD.Designed as...

Motors & Robotics · PIC16F877A

Efficient Sun-Following Robot: A Solar Tracker with Microcontroller Control

Abstract The impending global challenge of dwindling non-renewable fuel resources underscores the urgency of transitioning towards renewable energy alternatives like solar power....

Communication & Interfacing · PIC18F4520

CAN FD Node based on a PIC18 Microcontroller

The introduction sets the stage for an embedded systems project that involves developing a Embedded C CAN FD project using the MCP2517FD...

Communication & Interfacing

LAN9662 Gigabit Switch: Optimized for Industrial Ethernet

Introduction It should come as little surprise therefore that one element of what is now more commonly referred to in some circles...

Communication & Interfacing

PIC Microcontroller: Fundamentals & Applications for Students

Introduction Microcontrollers are the key components in the embedded systems market. A variety of embedded systems was formed and developed after the...

Ibrar Ayyub

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough...