Tutorial 5:  EEPROM Persistent Data Store

The PIC16F877 has a 256 byte EEPROM store which can be used to store medium and long term data. This tutorial shows how to access the EEPROM to store and retrieve bytes. A STIMULUS8 component configured for edge triggered step mode is used to deliver numbers 0 through 255 to PORTB. The value on PORTB is read and written to an EEPROM cell using the wake from sleep method. The value is then read back from the EEPROM and written out to PORTB which is connected to a DIGITAL8 component which displays the value. Port B is read again and written to the EEPROM cell a second time using polling technique to detect the EEPROM write completion. The EEPROM write complete interrupt is used on the second writing to the EEPROM to place a rising edge on PORTE<0> which request the next value from the stimulus component. The second value written to the EEPROM cell is then read and its value written out to PORTD. This is repeated for value 0 to 255, and reads and writes to all EEPROM cells.

Download FEATURE877_Tutorial5.zip and unzip into folder <your path>\Tutorial 5

Filename Version Description
tut5.pjt 1.0 MPLAB (2.3) Project
tut5.asm 1.0 PIC16F877 Assembler code
tut5.hex 1.0 Precompiled HEX
tut5.lst 1.0 Precompiled LST
tut5.vbb 1.0 Virtual Breadboard simulation
Stimulus0to255.csv 1.0 Stimulus file that increments from 1 to 256

Running the Simulation

Open tut5.vbb and press RUN.

Code Walk Through

 

Features Demonstrated

TRISE/PORTE

TRISB/PORTB

TRISC/PORTC

TRISD/PORTD

EEPROM READ

EEPROM WRITE

EEPROM Interrupt

EEPROM Wakeup from Interrupt