Professional Documents
Culture Documents
The code that is written by the user to perform a specific task by the MCU is stored in the FPM (Flash Program
Memory) of the MCU. Flash memory makes it possible to program a MCU many times because it is re-writable,
this memory can be written and erased many times. The chip RAM Data Memory is used for storing data once
the power is OFF or after CPU reset, this memory will be cleared and lose all its content. Random Access
Memory location are also called GPR or General Purpose Registers, these two memories it has faster
response time 3 memory is EEPROM memory. EEPROM memory can be read/write electrically and can be
rd
accessed through program code, EEPROM memory is used to store data which is cannot be loss during the
operation or power loss / reset, such as configuration, parameters, settings which could be entered one and
stored in the EEPROM.
The data on the EEPROM / Flash Memory can be read/write during normal operations over full VDD range.
These memories are not mapped at the register file space, instead it can be accessed through Special
Function Registers (SFR) for read/write operations, according to the PIC18F452 datasheet (You can download
the datasheet below), at page 105 it has following Special Function Registers: EECON1 | EECON2 | EEDATA |
EEADR | EEADRH.
Note: The Address ranges from 00h to FFh for devices having 256 bytes while for 128 bytes devices it is 00h to
7Fh.
EEDATA register hold 8-bit data for read/write and EEADR holds the address of EEPROM memory location to
be accessed. PIC Microcontrollers usually have 128/256 bytes of data EEPROM memory with address ranging
from 00h to FFh. The PIC18F45K22 has 256 bytes of EEPROM memory.
The data-sheet explains how data can be read or written to the EEPROM, but to make things easier, we are
going to use the XC8 EEP library which simplifies everything for us.