PIC 16f877a Memory organization
We look into the memory organization of the PIC microcontroller in this blog post. We do this to determine the microcontroller unit(MCU) efficiency on whether it is capable of retrieving the instruction and data in one cycle and to find the size and limitation of each memory area.
PIC microcontroller consists of three kinds of memory:
- Program memory
- Data memory
- Data EEPROM
The program written by the user is stored in this memory. The program counter then executes the commands one by one. It can have three types of memories:
- Flash EEPROM
Read-Only Memory or ROM is a non-volatile memory used for storing data permanently. The program stored in ROM cannot be changed again hence it is used in cases where no modification of program is needed. Microcontrollers which have ROM are cheaper than ones which have EPROM or FLASH memory. PIC16CR65 and PIC16CR72 are the examples of microcontrollers which have the ROM memory and denoted by “R” in part number.
EPROM stands for Erasable Programmable Read Only Memory. As the name implies, the program stored in the memory can be erased multiple times using an ultraviolet eraser. The time to erase can vary from 5 to 30 minutes. PIC16C74B/JW EPROM microcontroller are available in market and “JW” is denoted by windowed package.
Data can be written or erased using electrical signals within a few seconds in this memory. PIC16F77 and PIC16F877 are examples of microcontroller which the flash memory. In these devices “F” is denoted by part number.
Program Memory Architecture
PIC16F877A has 8K words * 14 bits of flash program memory which can be electrically erased and reprogrammed. Program memory is divided into four pages in which the program is stored.
Each time the main program execution starts at address 0000 – Reset Vector. The address 0004 is “reserved” for the “interrupt service routine” (ISR). The program starts after the interrupt vector if an interrupt is used, otherwise, the program starts at the beginning of the reset vector.
Stack temporarily holds all parameters of variables. It works like a circular buffer which means that the 9th push in the stack overwrites the value from the first push and so on. The stack space is not part of either program or data space and the stack pointer is not readable or writeable. In the PIC microcontrollers, a special block of RAM is used as stack memory.
Data Memory Organisation
Data memory is separated into multiple banks which contain the General Purpose and Special Function Registers. The number of registers vary depending on the microcontroller, for PIC16F877A, the number of banks are 4, from BANK0 to 4. Each bank extends up to 128 bits
The selection of the banks are determined by control bits RP1, RP0 in the STATUS registers. Together the RP1, RP0 and the specified 7 bits effectively form a 9 bit address. The first 32 locations of Banks 1 and 2, and the first 16 locations of Banks 2 and 3 are reserved for the mapping of the Special Function Registers.
Read Relevant Blogs:
Also can visit for related information