Hello

Welcome lekule blog

Hi, I`m Sostenes, Electrical Technician and PLC`S Programmer.
Everyday I`m exploring the world of Electrical to find better solution for Automation.
together in the world. #lekule86
Join us on

Different Types of Registers used in 8051 Microcontroller

Register is a main part in the microcontrollers and processors that provide a fast way to collect and store data. If we want to manipulate data with a controller or processor by performing addition, subtraction, and so on, we cannot do that directly in the memory, but it needs registers to process and store the data. Microcontrollers contain several types of registers that can be classified according to their content or instructions that operate in them.

Different Types of Registers in the 8051 Microcontroller


Register

A register is a small place in a CPU that can store small amounts of the data used for performing various operations such as addition and multiplication and loads the resulting data on main memory. Registers contain the address of the memory location where the data is to be stored. The size of the register is very important for modern controllers. For instance, for a 64-bit register, a CPU tries to add two 32-bit numbers and gives a 64-bit result.

Types of Registers

The 8051 microcontroller contains mainly two types of registers:
  • General purpose registers (Byte addressable registers)
  • Special function registers (Bit addressable registers)
8051 RAM Memory
8051 RAM Memory


The 8051 microcontroller consists of 256 bytes of RAM memory, which is divided into two ways, such as 128 bytes for general purpose and 128 bytes for special function registers (SFR) memory. The memory which is used for general purpose is called as RAM memory, and the memory used for SFR contains all the peripheral related registers like Accumulator, ‘B’ register, Timers or Counters, and interrupt related registers.

General Purpose Registers

General Purpose Memory
General Purpose Memory


The general purpose memory is called as the RAM memory of the 8051 microcontroller, which is divided into 3 areas such as banks, bit-addressable area, and scratch-pad area. The banks contain different general purpose registers such as R0-R7, and all such registers are byte-addressable registers that store or remove only 1-byte of data.

Banks and Registers

The B0, B1, B2, and B3 stand for banks and each bank contains eight general purpose registers ranging from ‘R0’ to ‘R7’. All these registers are byte-addressable registers. Data transfer between general purpose registers to general purpose registers is not possible. These banks are selected by the Program Status Word (PSW) register.
General Purpose Registers
General Purpose Registers

PSW (Program Status Word) Register

The PSW register is a bit and byte-addressable register. This register reflects the status of the operation that is carried out in the controller. The PSW register determines bank selection by a RS1 and RS0, as shown below. The physical address of the PSW starts from D0h and the individual bits are accessed with D0h to D7h.

PSW Registers
PSW Registers


Carry Flag (C): The Address of the Carry flag is D7. This carry flag is affected when the bit is generated from the 7th position.
When C=0 carry resets
C=1 carry sets
Carry Flag
Carry Flag


Auxillary Flag(AC): The address of the auxiliary carry is D5. This auxiliary carry is affected when a bit is generated from the 3rd position to the 4th position.
AC=0 auxiliary is reset
AC=1 auxiliary is set
Auxiliary Carry (AC)
Auxiliary Carry (AC)


 Overflow Flag (OV): The address of the overflow flag is D2. When a bit is generated from the 6th position to the 7th position, then the overflow flag is affected.
OV=0 overflow flag resets
OV=1 overflow flag sets
Overflow Flag
Overflow Flag


Parity Flag (P): The address of the parity flag is D0. While performing arithmetic operations, if the result is 1, then the parity flag is set – otherwise reset.


RS1 and RS0

The RS1 and RS0, the bits in PSW register, are used to select different memory location (bank0 to bank4) in the RAM memory.
Bank selection Registers
Bank selection Registers

The following is an example for using this register.

The following example demonstrates addition of two numbers and then the storage of final value in the Bank1 register using assembly level program.

Org 0000h
MOV PSW,#00h
MOV A, 15
ADD A, 20
MOV 00h, A
END


Assembly program to move 6 natural numbers in bank0 register R0-R5
Org 0000h (starting addresses declaration)
MOV PSW, #00h (open the bank0 memory)
MOV r0, #00h (starting address of bank0 memory)
MOV r1, #01h
MOV r2, #02h
MOV r2, #03h
MOV r3, #04h
MOV r4, #05h
END


Assembly program to move 6 natural numbers in bank1 register R0-R7
Org 0000h (starting addresses declaration)
MOV PSW, #08h (open the bank1 memory)
MOV r0, 00h (value send to the bank1 memory)
MOV r1, 02h
MOV r2, 02h
MOV r2, 03h
MOV r3, 04h
MOV r4, 05h
MOV r5, 06h
MOV r6, 07h
MOV r7, 08h
END

Special Function Registers (SFR)


Special function registers are upper RAM memory in the 8051 microcontroller. These registers contain all peripheral related registers like P0, P1, P2, P3, timers or counters, serial port and interrupts-related registers. The SFR memory address starts from 80h to FFh. The SFR register is implemented by bit-address registers and byte-address registers.

 Special Function Registers (SFR)



Special Function Registers (SFR)
The accumulator, B register, Po, P1, P2, P3, IE registers are bit-addressable register remaining all are byte-addressable registers.


Accumulator
The accumulator which is also known as ACC or A is a bit as well as a byte-addressable register by an address of the accumulator. If you want to use a bit-addressable register, you can use a single bit (E0) of register and you can use an 8-bit of the accumulator as a byte-addressable register. The accumulator holds the results of most Arithmetic and logical operations.


Accumulator register
Accumulator register


The Assembly program for subtraction used with an Accumulator
Org 0000h
MOV R0, #09h
MOV A, #03h (1byte data)
SUBB A, 01h (1byte data)
END


B-Register
The B-register is a bit and byte-addressable register. You can access 1-bit or all 8-bits by a physical address F0h. Suppose to access a bit 1, we have to use f1. The B register is only used for multiplication and division operations.
B-Register
B-Register


The Assembly program for multiplication used with a B-Register
Org 0000h
MOV A, #09h
MOV B, #03h
MUL A, B (Final value stored in A)
END
The Assembly program for Division used with a B-Register
Org 0000h
MOV A, #09h
MOV B, #03h
DIC A, B (Final value stored in A)
END


Port Registers
The 8051 microcontroller consists of 4-input and output ports (P0, P1, P2, and P3) or 32-I/O pins. Each pin is designed with a transistor and P registers. The pin configuration is very important for a microcontroller that depends on the logic states of the registers. The pin configuration as input given by 1 or output 0 depends on the logic states. If logic 1 is applied to the bit of the P register, the output transistor switches off the appropriate pin that acts as an input pin.

Port Registers of 8051
Port Registers of 8051


Assembly program to toggle LEDs of Port0
ORG 0000h
RETURN: MOV P0, #00h
ACALL DEL1
MOV P0, #0FF
ACALL DEL1
SJMP RETURN
DEL1: MOV R2, #200
DEL: DJNZ R0, #230
DJNZ R2, DEL
RET
END


Counters and registers
Many microcontrollers consist of one or more timers and counters. The timers are used to generate precious time delay and the source for the timers is crystal oscillator. The counters are used to count the number of external events – for instance, the objective counter , and the source for counters are external pulses applied across the counter pin.

The 8051 microcontroller consists of two 16-bit timers and counters such as timer 0 and timer 1. Both the timers consist of a 16-bit register in which the lower byte is stored in the TL and the higher byte is stored in the TH. The Timer can be used as a counter as well as for timing operation that depends on the source of the clock pulses to the counters.

The Counters and Timers in 8051 microcontroller contain two special function registers: TMOD (Timer Mode Register) and TCON (Timer Control Register), which are used for activating and configuring timers and counters.

Types of Shift Register

Shift registers are a type of sequential logic circuits that are mainly used for storage of digital data. The shift registers are bit-addressable registers that store only one bit of data. The shift registers are constructed with flip-flops – a group of flip-flops connected as a chain so that the output from one flip-flop becomes the input of the next flip-flop.

All the flip-flops are driven by the clock signals that are implemented by the D-flip-flap. The shift registers are mainly used for serial communication.


These are classified into 4- types:
  • Serial in Serial out (SISO)
  • Serial in Parallel out (SIPO)
  • Parallel in Serial out (PISO)
  • Parallel in Parallel out (PIPO)
D- flipflop register
D- flipflop register.

These are all different types of registers in an 8051 microcontroller. We hope that we have successfully given you relevant content with appropriate program for each register. Furthermore, for any sort of help to know the coding of several other registers, you can contact us by commenting below.

Share this:

ABOUTME

Hi all. This is deepak from Bthemez. We're providing content for Bold site and we’ve been in internet, social media and affiliate for too long time and its my profession. We are web designer & developer living India! What can I say, we are the best..

Post a Comment
My photo

Hi, I`m Sostenes, Electrical Technician and PLC`S Programmer.
Everyday I`m exploring the world of Electrical to find better solution for Automation. I believe everyday can become a Electrician with the right learning materials.
My goal with BLOG is to help you learn Electrical.

Labels

LEKULE TV EDITORIALS ARTICLES DC ROBOTICS DIGITAL SEMICONDUCTORS GENERATOR AC EXPERIMENTS MANUFACTURING-ENGINEERING REFERENCE FUNDAMENTAL OF ELECTRICITY ELECTRONICS ELECTRICAL ENGINEER MEASUREMENT TRANSDUCER & SENSOR VIDEO ARDUINO RENEWABLE ENERGY AUTOMOBILE TEARDOWN SYNCHRONOUS GENERATOR DIGITAL ELECTRONICS ELECTRICAL DISTRIBUTION CABLES AUTOMOTIVE MICROCONTROLLER PROTECTION SOLAR DIODE AND CIRCUITS BASIC ELECTRICAL ELECTRONICS MOTOR SWITCHES CIRCUIT BREAKERS CIRCUITS THEORY PANEL BUILDING ELECTRONICS DEVICES MIRACLES SWITCHGEAR ANALOG MOBILE DEVICES WEARABLES CAMERA TECHNOLOGY COMMUNICATION GENERATION BATTERIES FREE CIRCUITS INDUSTRIAL AUTOMATION SPECIAL MACHINES ELECTRICAL SAFETY ENERGY EFFIDIENCY-BUILDING DRONE CONTROL SYSTEM NUCLEAR ENERGY SMATRPHONE FILTER`S POWER BIOGAS BELT CONVEYOR MATERIAL HANDLING RELAY ELECTRICAL INSTRUMENTS ENERGY SOURCE PLC`S TRANSFORMER AC CIRCUITS CIRCUIT SCHEMATIC SYMBOLS DDISCRETE SEMICONDUCTOR CIRCUITS WIND POWER C.B DEVICES DC CIRCUITS DIODES AND RECTIFIERS FUSE SPECIAL TRANSFORMER THERMAL POWER PLANT CELL CHEMISTRY EARTHING SYSTEM ELECTRIC LAMP FUNDAMENTAL OF ELECTRICITY 2 BIPOLAR JUNCTION TRANSISTOR 555 TIMER CIRCUITS AUTOCAD BLUETOOTH C PROGRAMMING HYDRO POWER LOGIC GATES OPERATIONAL AMPLIFIER`S SOLID-STATE DEVICE THEORRY COMPUTER DEFECE & MILITARY FLUORESCENT LAMP HOME AUTOMATION INDUSTRIAL ROBOTICS ANDROID ELECTRICAL DRIVES GROUNDING SYSTEM CALCULUS REFERENCE DC METERING CIRCUITS DC NETWORK ANALYSIS ELECTRICAL SAFETY TIPS ELECTRICIAN SCHOOL ELECTRON TUBES FUNDAMENTAL OF ELECTRICITY 1 INDUCTION MACHINES INSULATIONS USB ALGEBRA REFERENCE HMI[Human Interface Machines] INDUCTION MOTOR KARNAUGH MAPPING USEUL EQUIATIONS AND CONVERSION FACTOR ANALOG INTEGRATED CIRCUITS BASIC CONCEPTS AND TEST EQUIPMENTS DIGITAL COMMUNICATION DIGITAL-ANALOG CONVERSION ELECTRICAL SOFTWARE GAS TURBINE ILLUMINATION OHM`S LAW POWER ELECTRONICS THYRISTOR BOOLEAN ALGEBRA DIGITAL INTEGRATED CIRCUITS FUNDAMENTAL OF ELECTRICITY 3 PHYSICS OF CONDUCTORS AND INSULATORS SPECIAL MOTOR STEAM POWER PLANTS TESTING TRANSMISION LINE C-BISCUIT CAPACITORS COMBINATION LOGIC FUNCTION COMPLEX NUMBERS CONTROL MOTION ELECTRICAL LAWS INVERTER LADDER DIAGRAM MULTIVIBRATORS RC AND L/R TIME CONSTANTS SCADA SERIES AND PARALLEL CIRCUITS USING THE SPICE CIRCUIT SIMULATION PROGRAM AMPLIFIERS AND ACTIVE DEVICES APPS & SOFTWARE BASIC CONCEPTS OF ELECTRICITY CONDUCTOR AND INSULATORS TABLES CONDUITS FITTING AND SUPPORTS ELECTRICAL INSTRUMENTATION SIGNALS ELECTRICAL TOOLS INDUCTORS LiDAR MAGNETISM AND ELECTROMAGNETISM PLYPHASE AC CIRCUITS RECLOSER SAFE LIVING WITH GAS AND LPG SAFETY CLOTHING STEPPER MOTOR SYNCHRONOUS MOTOR AC METRING CIRCUITS BECOME AN ELECTRICIAN BINARY ARITHMETIC BUSHING DIGITAL STORAGE MEMROY ELECTRICIAN JOBS HEAT ENGINES HOME THEATER INPECTIONS LIGHT SABER MOSFET NUMERATION SYSTEM POWER FACTORS REACTANCE AND IMPEDANCE INDUCTIVE RECTIFIER AND CONVERTERS RESONANCE SCIENTIFIC NOTATION AND METRIC PREFIXES SULFURIC ACID TROUBLESHOOTING TROUBLESHOOTING-THEORY & PRACTICE 12C BUS APPLE BATTERIES AND POWER SYSTEMS DC MOTOR DRIVES ELECTROMECHANICAL RELAYS ENERGY EFFICIENCY-LIGHT INDUSTRIAL SAFETY EQUIPMENTS MEGGER MXED-FREQUENCY AC SIGNALS PRINCIPLE OF DIGITAL COMPUTING QUESTIONS REACTANCE AND IMPEDANCE-CAPATIVE SEQUENTIAL CIRCUITS SERRIES-PARALLEL COMBINATION CIRCUITS SHIFT REGISTERS WIRELESS BUILDING SERVICES COMPRESSOR CRANES DIVIDER CIRCUIT AND KIRCHHOFF`S LAW ELECTRICAL DISTRIBUTION EQUIPMENTS 1 ELECTRICAL DISTRIBUTION EQUIPMENTS B ELECTRICAL TOOL KIT ELECTRICIAN JOB DESCRIPTION INDUSTRIAL DRIVES LAPTOP SCIENCE THERMOCOUPLE TRIGONOMENTRY REFERENCE UART oscilloscope BIOMASS CONTACTOR ELECTRIC ILLUMINATION ELECTRICAL SAFETY TRAINING ELECTROMECHANICAL FEATURED FILTER DESIGN HARDWARE JUNCTION FIELD-EFFECT TRANSISTORS NASA NUCLEAR POWER VALVE COLOR CODES ELECTRIC TRACTION FLEXIBLE ELECTRONICS FLUKE GEARMOTORS INTRODUCTION LASSER PID PUMP SEAL ELECTRICIAN CAREER ELECTRICITY SUPPLY AND DISTRIBUTION MUSIC NEUTRAL PERIODIC TABLES OF THE ELEMENTS POLYPHASE AC CIRCUITS PROJECTS REATORS SATELLITE STAR DELTA VIBRATION WATERPROOF