Table of Contents
The File register of PIC Microcontroller
Basically there is a program memory (code) and data memory in the PIC microcontroller. The data memory is a Read/Write memory (static RAM) and it is also called the file register of PIC microcontroller. In this article, I will discuss various locations of file register and see how these locations are assessed using different instructions.
File Register Space Allocation
The file register is a Read/Write register used by the CPU for storing the data, scratch pad and internal registers operations. It can be used for performing the arithmetic and logical operations just like we use WREG register. The size of file register varies from 32 bytes to several thousands byte depending on the chip. Even within the same family this size varies from chip to chip. File register data memory is byte addressable which means we can access or store one byte of data at a time. The file register DATA RAM is divided into two sections:
- General Purpose Registers (GPRs)
- Special Function Registers (SFRs)
File register (Bytes) | SFR (Bytes) | GPRs (Bytes) | Available space for GPR(Byte) |
PIC12F508 | 32 | 7 | 25 |
PIC16F84 | 80 | 12 | 68 |
PIC18F1220 | 512 | 256 | 256 |
PIC18F452 | 1792 | 256 | 1536 |
PIC18F2220 | 768 | 256 | 512 |
PIC18F458 | 1792 | 256 | 1536 |
PIC18F8722 | 4096 | 158 | 3986 |
The general purpose registers are also known as General Purpose RAM (GP RAM).
Special Function Registers
The special function registers in PIC microcontrollers are almost fixed and they are around 100. They have specific bits for configuring the PIC microcontroller. For example we have built in Timers, ADC, PWM, USART modules present in PIC. In order to use these built in modules we need to configure them so that they can be used for the purposes they have been designed for. Timers registers are used for setting the timer either as event counter or for time delay routines. Some more examples of SFRs are port registers: PORTA, PORTB, PORTC, PORTD, PORTE and TRISA, TRISB, TRISC etc.
General Purpose RAM
The general purpose registers are the group of the RAM locations in the file register that are used for data storage and scratch pad. Each location can store 1 byte of data at a time. The number of RAM locations that are set aside for general purpose registers in the file register varies from chip to chip. The space that is not reserved for SFR is used for GPRs. Since SGRs are usually around 100 in count so the RAM space excluding the 100 bytes is available for general purpose registers. A large GPRs means it is more difficult to manage these registers if we are using an assembly language programming. However with over 1000 bytes, C compilers are used for managing the registers since it makes easier for the C compilers to store parameters and perform their job.
How to Determine the on-Chip ROM if the Memory Address is Given?
If you are given the memory address, then we can calculate the on-chip ROM easily by using the following method. Lets assume that the starting address is 00000H and ending address is 03FFFH then first calculate the address bit. 3FFFH needs 12 bits in total since each HEX digit is of 4-bits. Total number of bits are hence equal to 14 (0011 1111 1111 1111). This can be written as 214=24.210=16KB..
File Registers of PIC Microcontroller
Instruction Set of PIC18 Microcontroller