SFR
SFR
hardware peripherals like Timers, Serial Port, I/O Ports etc, we use some special registers in
8051 microcontroller called Special Function Register (SRF) (or Special Purpose Register,
or simply Special Register).
In order to assess or change the operating mode of the 8051 Microcontroller. This will be
done by manipulating the 8051 Microcontroller Special Function Registers (SFRs).
In 8051 micro controller there are 21 Special function registers (SFR) and this includes
Register A, Register B, Processor Status Word (PSW), PCON etc. So, it required 21 unique
locations for these 21 special function registers and the size of each register is of 1 byte.
Some of these special function registers are bit addressable registers (which means you
can access 8 individual bits inside a single byte), while some others are only byte
addressable registers.
General Purpose Registers
We know that a register is a storage element that can be store bits of information.
8051 microcontroller has 4 registers bank . These are B0, B1, B2, and B3 stand for Bank0,
Bank1, Bank2, Bank3 respectively and each bank contains eight general purpose registers
ranging from ‘R0’ to ‘R7’.
These are 32 general purpose registers address from 00h to 1Fh.
The address range of Register Bank 0 ( 00 h to 07 h)
The address range of Register Bank 1 ( 08 h to F h)
The address range of Register Bank 2 ( 10 h to 17 h)
The address range of Register Bank 3 ( 18 h to 1F h)
These Register Banks are selected with the help of PSW (Program Status Word) Register
bits i.e. RS0, RS1.
Special Function Registers (SFR’s)
In 8051 micro controller there are 21 Special function registers
(SFR) and this includes Register A, Register B, Processor Status
Word (PSW), PCON etc. There are 21 unique locations for these 21
special function registers and each of these register is of 1 byte
size.
The 21 SFR of 8051 Microcontroller are categorized into seven
groups these are:
•Math or CPU Registers: A and B Register
•Status Register: PSW (Program Status Word) Register
•Pointer Registers: DPTR (Data Pointer – DPL, DPH) and SP (Stack
Pointer) Registers
•I/O Port Latches: P0 (Port 0), P1 (Port 1), P2 (Port 2) and P3 (Port
3) Registers
•Peripheral Control Registers: PCON, SCON, TCON, TMOD, IE and
IP Registers
PSW (Program Status Word) Register:
The PSW (Program Status Word) Register is also called as Flag
Register. It is one of the important SFRs in 8051 microcontrollers. It
is also an 8-bit register. It consists of Flag Bits or status bits that
reflect the current state of the CPU. This will help the programmer
check the condition of the result and make decisions.
PSW flag register is addressable in both bit and byte. The physical
address of PSW starts from D0H. The individual bits are accessed
by using bit addresses D1, D2 … D7. The two unused bits are user-
defined flags. Four of the flags are called conditional flags, which
means that they indicate a condition that results after an