The document provides information on the 8051 microcontroller architecture. It discusses the oscillator, program counter, data pointer, registers A and B, flags and program status word, internal memory including RAM, stack pointer, special function registers, internal ROM, input/output pins including the four ports, counters, timers, and interrupts. The 8051 is an 8-bit microcontroller with 40 pins, 128 bytes of internal RAM, 4KB of internal ROM, and features like timers, counters, serial port, and interrupts that allow it to be used in embedded systems.
4. Oscillator
Clock pulses by which internal operations are synchronized
Pins XTAL1 and XTAL2 to form an oscillator
Quartz crystal and capacitors are used
Crystal frequency is the microcontroller frequency
8051 can run at 1-16MHz.
Ceramic resonators can be used - but not accurate
Clock frequency f
Smallest interval of time -pulse P- time taken to complete one simple instruction
5. Program Counter
8051 has 2 16 bit registers - one for program counter(PC), one for data pointer
(DPTR)
Used to hold the address of a byte in memory
Program instruction bytes are fetched from locations in memory that are
addressed by the PC
After every fetch the PC in incremented.
Does not have an internal address
6. Data pointer
Made up of 2 8 bit registers, DPH, DPL
This under the control of program instructions
Used to store addresses for internal and external code access
7. A and B CPU registers
Math or CPU Registers are A and B Registers from these two Register 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:
● 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.
8. 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.
Ex: MUL A,B – When this instruction is executed, data inside A and data inside B is multiplied and answer is stored in A.
Register B can also be used for other general purpose operations.
9. Flags and 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.
11. Internal memory
Internal RAM
● 8051 has 128 B internal Random Access
Memory.
● Data Memory is used for temporarily
storing data and intermediate results
created and used during the operation of
the microcontroller.
● It mainly contains register banks ,
Read/write data, bit addressable
registers and stack.
● Address range is 0000H to FFFFH.
● PSEN(bar) is used to allow usage of
Internal ROM or not
12. Stack pointer
● Stack pointer is a small (8bit) register that stores
address of the last program request in a stack
● It is a specialized buffer which store data from
the top to down
● Direct address of SP is 81H and it is only byte
addressable
Which means can’t access individual bits
of stack pointer
● After a system reset SP is initialized as 07H and
data can be stored to stack from 08H onwards
● To store something new in system stack, the SP
must be incremented by 1 first and then execute
the “store” command
13. Special Function registers
● A Special Function Register (or Special
Purpose Register, or simply Special Register) is
a register within a microprocessor that controls
or monitors the various functions of a
microprocessor.
● The 8051 Microcontroller Special Function
Registers are used to program and control
different hardware peripherals like Timers,
Serial Port, I/O Ports etc.
● some special registers in some processor
architectures require special instructions to
modify them.
● In fact, by manipulating the 8051
Microcontroller Special Function Registers
(SFRs).
● Internal RAM Structure, the Address Space
from 80H to FFH is allocated to SFRs.
● The main difference of the SFRs is the address
space
14. Internal ROM
● The original 8051 Microcontroller by Intel has 4KB of internal ROM.
● Some variants of 8051 like the 8031 and 8032 series doesn’t have any internal ROM (Program
Memory) and must be interfaced with external Program Memory with instructions loaded in it.
● In case of 4KB of Internal ROM, the address space is 0000H to 0FFFH.
● ignore the Internal ROM and fetch all the instructions only from the External Program Memory (External
ROM).
15. Input / Output pins
● There are 40 input/output pins in 8051 microcontroller.
● Only 32 input/output pins allow the microcontroller to be connected with the peripheral
devices.
● The rest of the pins are dedicated to VCC, GND, XTAL1, XTAL2, RST, ALE, EA’ and PSEN’.
16. Pins 1 to 8 These pins don’t serve any other functions. It is internally pulled up, bi-directional I/O
port.
Pin 9 Used to reset the microcontroller to its initial values.
Pins 10 to 17 Serves some functions like interrupts, timer input, control signals, serial communication
signals RxD and TxD, etc.
Pins 18 & 19 Used for interfacing an external crystal to get the system clock.
Pin 20 This pin provides the power supply to the circuit.
Pins 21 to 28 Higher order address bus signals are also multiplexed using this port.
Pin 29 Used to read a signal from the external program memory.
Pin 30 Used to enable/disable the external memory interfacing.
Pin 31 Used to demultiplex the address-data signal of port.
Pins 32 to 39 Lower order address and data bus signals are multiplexed using this port.
Pin 40 Used to provide power supply to the circuit.
17. Ports of the 8051 microcontroller
● There are 4 I/O ports each of 8 bit.
● According to the ports of ,
Port 0
❖ There are two functions of the characterized.
❖ When the external memory is used lower address byte(address (AOA7) is applied on it.else all bits of this port are configured as I/O.
❖ When P0 port is configured as an output then other ports consisting of pins with built-in pull up resistor connected by 5v power supply.
Port 1
❖ It is a true I/O port also does not have any alternative functions as in P0.
❖ This port can be generally configured as general I/O only.
❖ It has a built-in built-up resistor and is completely compatible with TTL circuits.
Port 2
❖ It is a similar to P0 when the external memory is used.
❖ Port 2 is can be used for higher address byte with addresses A8-A15.
❖ This port can be used as a general I/O port similar port 1 when the memory is no added
Port 3
❖ Therefore ,functions are similar to other ports except that the logic 1 must be applied to appropriate bit of the P3 register.
18. Counters
A counter is a device that stores (and sometimes displays) the number of times a particular event or
process occurred, with respect to a clock signal. It is used to count the events happening outside the
microcontroller. In electronics, counters can be implemented quite easily using register-type circuits such
as a flip-flop.
The Counter different as a timer given this below point
● The register is incremented considering 1 to 0 transition at its corresponding to an external input pin
(T0, T1).
● Maximum count rate is 1/24 of the oscillator frequency.
● A counter uses an external signal to count pulses.
19. Timers
● A timer is a specialized type of clock that is used to measure time intervals. A timer that counts from zero upwards for
measuring the time elapsed is often called a stopwatch.
● The 8051 has two timers, Timer 0 and Timer 1. They can be used as timers or as event counters. Both Timer 0 and Timer 1
are 16-bit wide. Since the 8051 follows an 8-bit architecture, each 16 bit is accessed as two separate registers of low-byte
and high-byte.
Timer 0 Register
● The 16-bit register of Timer 0 is accessed as low- and high-byte. The low-byte register is called TL0 (Timer 0 low byte) and
the high-byte register is called TH0 (Timer 0 high byte). These registers can be accessed like any other register. For
example, the instruction MOV TL0, #4H moves the value into the low-byte of Timer #0.
Timer 1 Register
● The 16-bit register of Timer 1 is accessed as low- and high-byte. The low-byte register is called TL1 (Timer 1 low byte) and
the high-byte register is called TH1 (Timer 1 high byte). These registers can be accessed like any other register. For
example, the instruction MOV TL1, #4H moves the value into the low-byte of Timer 1.
TMOD (Timer Mode) Register
● Both Timer 0 and Timer 1 use the same register to set the various timer operation modes. It is an 8-bit register in which the
lower 4 bits are set aside for Timer 0 and the upper four bits for Timers. In each case, the lower 2 bits are used to set the
timer mode in advance and the upper 2 bits are used to specify the location.
20. interrupts
Type of interrupts in 8051 Microcontroller
The 8051 microcontroller can recognize five different events that cause the main program to interrupt from the normal execution.
1. Timer 0 overflow interrupt- TF0
2. Timer 1 overflow interrupt- TF1
3. External hardware interrupt- INT0
4. External hardware interrupt- INT1
5. Serial communication interrupt- RI/TI
These external interrupts can be edge triggered or level triggered. When an interrupt occurs, the microcontroller executes
the interrupt service routine so that memory location corresponds to the interrupt that enables it.