Review Questions 1. Write a note on PIC18 registers. 2. What is the function of WREG register in PIC microcontroller? 3. Explain the status register of PIC18. 4. What are SFRS ?
Registers of PIC18F
•
The memory of the PIC is divided into a series of registers. Each of the
registers has its own address and memory locations.
•
According to the type of working and usage, the registers in PIC are classified
as :
■
Special
Function Registers (SFRS): Used for control and status of the
controller and peripheral functions
■
General
Purpose Registers (GPRS): Used for data storage and
scratchpad operations in the user's application.
■
WREG
working register (acts as an Accumulator) - Used to
perform arithmetic or logical functions.
■
Status
register that stores flags - Indicates the status of the operation done by ALU.
■
Registers
- hold memory address
•
Bank Select Register (BSR): 4-bit register used in direct
addressing the data memory.
•
File Select Registers (FSRs).: 16-bit registers used
as memory pointers in indirect addressing data memory.
•
Program Counter (PC): 21-bit register that holds the program
memory address while executing programs. This means that the PIC18 family can
access program addresses 000000 to 1FFFFFH, a total of 2M bytes of code.
•
Stack Pointer (SP): PIC18 has a 5-bit stack pointer. It is
used to access the stack.
•
It
is 8-bits wide.
•
It
is used for ALU operations.
•
The
WREG register is the same as the accumulator in other microprocessors.
•
The
contents of WREG register are used for all arithmetic and logic one / two- operand
instructions.
•
It is not an addressable register.
•
The status register is an 8-bit register. It is also referred to as flag
register.
•
The
status register contains the arithmetic status of the ALU. It contains five
flag bits Z, DC, C, OV and. These bits are set or cleared according to the
result of arithmetic or logical instructions.
•
Remaining three bits: 5, 6, and 7 are unimplemented and read as 0.
•
CLRF
STATUS instruction clears the upper three bits and set the Z bit. This leaves the
Status register as 000u uluu (where u = Unchanged).
•
Only
BCF, BSF, SWAPF, MOVFF and MOVWF instructions are used to alter the status
register, because these instructions do not affect the Z, C, DC, OV or N bits
from the status register.

•
Carry (C) flag: This flag is set if there is an
overflow out of bit 7. The carry flag also serves as a borrow flag for
subtraction.
•
Digital Carry (DC) flag: This flag is set if there is an
overflow out of bit 3 i.e. carry from lower nibble to higher nibble (bit 3 to
bit 4). This flag is used for BCD operations and it is not, available for the
programmer. It is also known as Auxiliary Carry flag.
•
Zero (Z) flag: The zero flag sets if the result of
operation in ALU is zero and flag resets if result is non zero. The zero flag
is also set if a certain register content becomes zero following an increment
or decrement operation of that register.
•
Over (OV) flag: This flag is set whenever the result of
a signed number operation is too large, causing the high-order bit to overflow
into the sign bit.
•
Negative (N) flag: After the execution of arithmetic or
logical operations, if bit7 of the result is 1, the N flag is set indicating
result is negative. If bit7 is 0, the number will be considered as positive
number.
•
The
Special Function Registers (SFRs) are registers used by the CPU and peripheral
modules for controlling the desired operation of the device. These registers
are implemented as static RAM.
•
Table
18.5.1 shows the list of SFRS. The SFRS are classified into two sets:
■
Registers associated with the core function and
■
Registers
associated with peripheral functions.
•
Here, we will discuss the registers related to the core functions, while those
related to the peripheral functions are discussed in the respective sections.

1.
This is not a physical register.
2.
These registers are not implemented on the PIC18F248 and PIC18F258. Table
18.5.1 Special Function Register map for PIC18FXX8 family
Review Questions
1. Write a note on
PIC18 registers.
2. What is the
function of WREG register in PIC microcontroller?
3. Explain the
status register of PIC18.
4. What are SFRS ?
Microprocessors and Microcontrollers: Unit V: (b) Introduction to RISC Based Architecture : Tag: : Introduction to RISC Based Architecture - Registers of PIC18F