0% found this document useful (0 votes)
53 views6 pages

8051 Microcontroller

The document discusses the 8051 microcontroller, its major components including registers, arithmetic logic unit, program counter, data pointer, internal RAM and ROM, ports, timers and counters, program status word, and data and address bus. It also compares microcontrollers and microprocessors and describes the register banks and flag bits of the 8051 microcontroller.

Uploaded by

rajendra dahare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views6 pages

8051 Microcontroller

The document discusses the 8051 microcontroller, its major components including registers, arithmetic logic unit, program counter, data pointer, internal RAM and ROM, ports, timers and counters, program status word, and data and address bus. It also compares microcontrollers and microprocessors and describes the register banks and flag bits of the 8051 microcontroller.

Uploaded by

rajendra dahare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

8051 Microcontroller

The 8051 Microcontroller is one of the most popular and most commonly used microcontrollers in various
fields like embedded systems, consumer electronics, automobiles, etc.
A complete computer system manufactured on a single chip is called a microcontroller.
Features of a microcontroller are similar to that of a microprocessor like registers, ALU, program counter,
flags, stack pointer, etc. Along with these common features, a microcontroller has some additional features
such as a clock circuit, internal RAM, ROM, serial and parallel 1/O counter containing on-chip program
memory. A microcontroller can also be referred as a 'microcomputer'. It is single chip microcomputer.
It consists of are four parallel 8-bit ports, which are programmable as well as addressable as per the
requirement.
8051 is an 8 – bit Microcontroller i.e. the data bus of the 8051 Microcontroller (both internal and external) is
8 – bit wide.

 Major components of intel 8051 microcontroller:


1} 8-bit CPU with register A (accumulator) and register B. 2} Arithmetic and logic unit (ALU).
3} 16-bit program counter (PC). 4} 16-bit data pointer (DPTR)
5} Internal RAM and ROM. 6} Four 8-bit ports: port 0, port 1, port 2, port 3
7} Timers and counter. 8} PSW (program status word).
9} Data and address bus.

1] Register:
 Accumulator: ACC is the accumulator register. It is 8-bit register. It is also used for data transfer between
8051 and any external memory. Register are usually known as data storage devices. 8051 microcontroller
has 2 register, namely Register A and Register B. Register A serves as an accumulator while register B
function as a general purpose register. These register are used to stored output of mathematical and logical
instruction.
 Register B: The B register is used with the A register for multiplication and division operations. For other
instruction it is treated as a scratch pad register.

2] Arithmetic and logic unit (ALU): The ALU can perform arithmetic and logical operations on 8-bit data. All
arithmetic and logical operation are perform by ACC Addition, multiplication, subtraction with carry come under
arithmetic operation. Logical AND, OR and exclusive OR(XOR) come under logical operation.

1|Page
3] Program counter (PC): A program counter is a 16-bit register and it has no internal address. The basic function of
program counter is to fetch from memory the address of the next instruction to be executed. The PC holds the
address of the next instruction residing in memory and when a command is encountered, it produces that
instruction. This way the PC increments automatically, holding the address of the next instructions.

4] Data pointer (DPTR): The data pointer or DPTR is a 16-bit register. It is made up two 8-bit registers called DPH
and DPL. Separate addresses assigned to each of DPH and DPL. These 8-bit registers are used for the storing memory
addresses that can be used to access internal and external data/code.

5] Internal RAM and ROM:


ROM: A code of 4K memory is incorporated as on-chip ROM in 8051. The 8051 ROM is a non-volatile Memory
meaning that its contents cannot be altered and hence has a similar range of data and program memory, i.e., they
can address program memory as well as a 64K separate block of data memory.
RAM: The 8051 microcontroller is composed of 128 bytes of internal RAM. This is a volatile memory since its
contents will be lost if power is switched off. These 128 bytes of internal RAM are divided into 32 working registers
which in turn consistute 4 register banks ( bank 0- bank 3 ) with each bank consisting of 8 registers (R0-R7). There are
128 addressable bits in the internal RAM.

6] Four 8-bit parallel ports:


Port 0: When there is no external memory present, this port acts as a general purpose input/output port. In the
presence of external memory, it functions as a multiplexed address and data bus. It perform dual role.
Port 1: This port is used for various interfacing activities. This 8-bit port is a normal I/O port i.e., it does not perform
dual functions.
Port 2: similar to port 0.
Port 3: Port P3 behaves as a dedicated I/O port.

7] Timers and counters: Synchronization among internal operations can be achieved with the help of clock circuits
which are responsible for generating clock pulses. During each clock pulse a particular operation will be carried out,
thereby, assuring synchronization among operations. For the formation of an oscillator, we are provided with two
pins XTAL and XTAL2 which are used for connecting a resonant network in 8051 microcontroller device.

8] PSW (Program status word): Program status word or PSW is a hardware register which is a memory location
which holds a program’s information and also monitors the status of the program his is currently being executed.
Generally, the instruction of the result of a program is a stored in a single bit register called a ‘flag’. There are 7 flags
in the PSW of 8051. Among these flags, 4 are math flags and 3 are general purpose or user flags.
The 4 math flags are: 1} Carry (C) 2} Auxiliary carry (AC) 3} Overflow (OV) 4} Parity (P)
The 3 general purpose flags or user flags are: 1} F0 2} GF0 3} GF 1

9] Data and Address bus: A bus is group of wires using which data transfer takes place from one location to another
within a system. Buses reduce the number of paths or cables needed to set up connection between components.
There are mainly two kinds of buses - Data Bus and Address Bus

Data Bus: The purpose of data bus is to transfer data. It acts as an electronic channel using which data travels. Wider
the width of the bus, greater will be the transmission of data.

Address Bus: The purpose of address bus is to transfer information but not data. The information tells from where
within the components, the data should be sent to or received from. The capacity or memory of the address bus
depends on the number of wires that transmit a single address bit.

2|Page
Comparison of microcontroller and microprocessor

REGISTER BANKS:
The 8051 microcontroller has a total of 128 bytes of RAM. Lets discuss the allocation of these 128 bytes of RAM and
examine their usage as register and stack.
RAM [Random Access Memory] space allocation in 8051:
There are 128 bytes of RAM in the 8051. This 128 bytes of RAM inside the 8051 are assigned addresses 00 to 7FH.
This 128 bytes are divided into three different groups as follows.
1. Total of 32 bytes from locations 00 to 1F hex are set aside for register banks and the stack.
2. Total of 16 bytes from locations 20H to 2FH are set aside for bit addressable Read/Write memory.

3|Page
3. Total of 80 bytes from locations 30H to 7FH are used for read and write storage. These 80 bytes locations of
RAM are widely used for the purpose of storing data and parameters by 8051 programmers.
RAM Allocation in the 8051:

Register Banks in the 8051:


32 bytes of RAM are set aside for the register banks and stack. These 32 bytes are divided into 4 banks of registers in
which each bank has 8 registers, R0 - R7. RAM locations from 0 to 7 are set aside for bank 0 of R0 - R7. 'R0' is the
RAM location 0 of Bank 0, 'R1' is the RAM location 1, 'R2' is the RAM location 2 of Bank 0, and so on up to 'R7' is the
RAM location 7 of Bank 0. The second bank of registers R0 - R7 starts at RAM location 08H and goes to location 0FH.
The third bank of R0-R7 starts at memory location 10H and goes to location 17H.The fourth bank of R0-R7 starts at
memory location 18H and goes to location 1FH.
8051 Register Banks and their RAM addresses :

Note: Bank 1 used the same RAM space as the stack. We must either not use register Bank 1, or we must allocate
another area of RAM for the stack

4|Page
8051 Flag Bits and PSW Register

The program status word (PSW) register is an 8-bit register, also known as flag register. It is of 8-bit wide
but only 6-bit of it is used. The two unused bits are user-defined flags. Four of the flags are called
conditional flags, which means that they indicate a condition which results after an instruction is executed.
These four are CY (Carry), AC (auxiliary carry), P (parity), and OV (overflow). The bits RS0 and RS1 are
used to change the bank registers. The following figure shows the program status word register.
The PSW Register contains that status bits that reflect the current status of the CPU.

We can select the corresponding Register Bank bit using RS0 and RS1 bits.

 CY, the carry flag − This carry flag is set (1) whenever there is a carry out from the D7 bit. It is
affected after an 8-bit addition or subtraction operation. It can also be reset to 1 or 0 directly by an
instruction such as "SETB C" and "CLR C" where "SETB" stands for set bit carry and "CLR" stands
for clear carry.

5|Page
 AC, auxiliary carry flag − If there is a carry from D3 and D4 during an ADD or SUB operation, the
AC bit is set; otherwise, it is cleared. It is used for the instruction to perform binary coded decimal
arithmetic.
 P, the parity flag − The parity flag represents the number of 1's in the accumulator register only. If
the A register contains odd number of 1's, then P = 1; and for even number of 1's, P = 0.
 OV, the overflow 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. It is used only to detect errors in signed
arithmetic operations.

6|Page

You might also like