Browse over 10,000 Electronics Projects

8051 Microcontroller Special Function Registers (SFRs)

8051 Microcontroller Special Function Registers (SFRs)

[tps_header][/tps_header]

In this tutorial, Electronics Hub website will take a look at the 8051 Microcontroller Special Function Registers or SFRs.

The internal RAM or Data Memory of the 8051 Microcontroller is divided in to General Purpose Registers, Bit Addressable Registers, Register Banks and Special Function Registers or SFRs.

The 8051 Microcontroller Special Function Registers are used to program and control different hardware peripherals like Timers, Serial Port, I/O Ports etc. In fact, by manipulating the 8051 Microcontroller Special Function Registers (SFRs), you can assess or change the operating mode of the 8051 Microcontroller.

As a reminder, the following image shows you the basic structure of 8051 Microcontroller’s Internal RAM.

 

8051 Microcontroller Special Function Registers (SFRs)

The 8051 Microcontroller Special Function Registers act as a control table that monitor and control the operation of the 8051 Microcontroller. If you observe in Internal RAM Structure, the Address Space from 80H to FFH is allocated to SFRs.

Out of these 128 Memory Locations (80H to FFH), there are only 21 locations that are actually assigned to SFRs. Each SFR has one Byte Address and also a unique name which specifies its purpose.

Since the SFRs are a part of the Internal RAM Structure, you can access SFRs as if you access the Internal RAM. The main difference is the address space: first 128 Bytes (00H to 7FH) is for regular Internal RAM and next 128 Bytes (80H to FFH) is for SFRs.

TIP: As only 21 of the possible 128 SFR memory locations are assigned, it is recommended that the remaining registers or memory locations are not accessed during programming.

Before going further, get an idea on 8051 MICROCONTROLLER ARCHITECTURE.

List of 8051 Microcontroller Special Function Registers

  • A or ACC
  • B
  • DPL
  • DPH
  • IE
  • IP
  • P0
  • P1
  • P2
  • P3
  • PCON
  • PSW
  • SCON
  • SBUF
  • SP
  • TMOD
  • TCON
  • TL0
  • TH0
  • TL1
  • TH1

Categories of 8051 Microcontroller Special Function Registers

All the 21 8051 Microcontroller Special Function Registers (SFRs) along with their functions and Internal RAM Address is given in the following table.

 

There are many ways to categorize these 21 Special Function Registers but I find the following way as an appropriate one. The 21 Special Function Registers of 8051 Microcontroller are categorized in to seven groups. They are:

Math or CPU Registers: A and B

Status Register: PSW (Program Status Word)

Pointer Registers: DPTR (Data Pointer – DPL, DPH) and SP (Stack Pointer)

I/O Port Latches: P0 (Port 0), P1 (Port 1), P2 (Port 2) and P3 (Port 3)

Peripheral Control Registers: PCON, SCON, TCON, TMOD, IE and IP

Peripheral Data Registers: TL0, TH0, TL1, TH1 and SBUF

CPU or Math Registers

A or Accumulator (ACC)

The Accumulator or Register A is the most important and most used 8051 Microcontroller SFRs. The Register A is located at the address E0H in the SFR memory space. The Accumulator is used to hold the data for almost all the ALU Operations.

Some of the operations where the Accumulator is used are:



Advertisement1


  • Arithmetic Operations like Addition, Subtraction, Multiplication etc.
  • Logical Operations like AND, OR, NOT etc.
  • Data Transfer Operations (between 8051 and External Memory)

The name “Accumulator” came from the fact this register is used to accumulate (or store) the result of all Arithmetic and most of the Logical Operations.

 

 

B (Register B)

The B Register is used along with the ACC in Multiplication and Division operations. These two operations are performed on data that are stored only in Registers A and B. During Multiplication Operation, one of the operand (multiplier or multiplicand) is stores in B Register and also the higher byte of the result.

In case of Division Operation, the B Register holds the divisor and also the remainder of the result. It can also be used as a General Purpose Register for normal operations and is often used as an Auxiliary Register by Programmers to store temporary results.

Register B is located at the address F0H of the SFR Address Space.

 

 

Program Status Word (PSW)

The PSW or Program Status Word Register is also called as Flag Register and is one of the important SFRs. The PSW Register consists of Flag Bits, which help the programmer in checking the condition of the result and also make decisions.

Flags are 1-bit storage elements that store and indicate the nature of the result that is generated by execution of certain instructions. The following image shows the contents of the PSW Register.

 

 

The following table describes the function of each flag.

 

 

Pages: 1 2 3

 


Top