HEFM Overview


Several members of the Microchip PIC microcontroller family, including the 16F14xx, 16F15xx and 16F17xx have replaced the data EEPROM present on older models with a block of Flash memory that is designed to provide the same high endurance (100K erase/write cycles).

This high endurance flash memory (HEFM) is a block of 128 locations found at the top of the Flash program memory. Each location can only be used to hold a byte variable (whereas the standard Flash memory for a mid-range Microchip PIC microcontroller will typically hold 14 bits of information).

The main difference between EEPROM and HEFM is that the former does allow byte-by-byte erase whereas the latter does not. With HEFM data must be erased before a write and this can only be performed in blocks (also referred to as rows) of a fixed size associated with the chip design.

The heflash.h library uses as an input the following variables which are available from the chips *.dat files supporting HEFM.

Variable Name





Size of an HEFM block in words



Starting address of HEFM



Ending address of HEFM


Whenever you update the hex file of your Microchip PIC microcontroller with your programmer you will erase the data that are stored in HEFM. If you want to avoid that you will have to flash your Microchip PIC microcontroller with software that allows memory exclusion when flashing. This is the case with Microchip PIC MPLAB IPE (Go to Advanced Mode/Enter password/Select Memory/Tick “Preserve Flash on Program”/ Enter Start and End address of your HEFM).