Tutorial 6:  FLASH Persistent Data Store

In addition to the 256 Bytes of EEPROM used as a persistent Data Store in Tutorial 5, the PIC16F877 can read and write to its own FLASH program space. This tutorial repeats the reading and writing of Tutorial 5, except this time the first 256 bytes of program page 3 FLASH is used to store the data. Each Flash word is 14 bits, and is accessed by a high and a low address and data register. The FLASH word is packed with the low byte of Sample N and the first 6bits of Sample N+1. The result is that when the FLASH word is read back again, the high 6-bit nibble is written to PORTC and the low byte is written to PORTD so that as the Stimulus is incremented the HIGH byte loops on 63 (6-bits) and low byte loops on 255 (8-bits)

Download FEATURE877_Tutorial6.zip and unzip into folder <your path>\Tutorial 6

Filename Version Description
tut6.pjt 1.0 MPLAB (2.3) Project
tut6.asm 1.0 PIC16F877 Assembler code
tut6.hex 1.0 Precompiled HEX
tut6.lst 1.0 Precompiled LST
tut6.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

FLASH READ

FLASH WRITE