Block Diagram of 8051 Microcontroller
Microcontroller has built in RAM for internal processing and it has two bus
It has 8 bit processing unit and 8 bit and 8 bit and 8 bit accumulator, and have 8 bit and 16 bit registers.
It monitors controls all operations that are performed in microcontroller, its function is to read program written in ROM memory and do the executed task.
Interrupts are subroutine call that interrupts microcontrollers main operation or work and causes it to execute some other program which is more important at that time it can be explain as the microcontroller terminates or pause the main program at the occurrence of interrupt. There are five interrupts sources in 8051 microcontroller, 2 external interrupts, 2 timer interrupts, 1 serial port interrupts.
Microcontroller requires programmers which is the collection of instruction, these programs tells microcontroller to do specific task. These instruction sets requires memory on which they can be saved and read by microcontroller to perform operation . The memory which is used to store the program of microcontroller is known as program memory. It is known as ROM (read only memory), and the memory which is used to temporarily store data for operation is knows as data memory Known as ‘RAM’, micro controller has program memory and 128 bytes of data memory.
Bus: Bus is a collection of wires work as communication channel or media of transfer data.
Two types of Buses are there:
Address Bus- 16 bit address bus used to address memory location
Data bus- Carry 8 bit data.
As we know microcontroller is a digital circuit device hence it requires clock for operation. 8051 has an on chip oscillators which work as clock source for CPU. The output pulse of oscillator are stable therefore it enables synchronized work of all parts of 8051 microcontroller.
As we know microcontroller is used in embedded system therefore to connect it to the other machine or devices, or peripherals we require I/O interfacing ports for this microcontroller has 7 input output ports to connect other peripherals.
Microcontroller has two 16 bit timers and counters. The timers are used for measurement of intervals to determine pulse width etc.
ALU: This unit is for arithmetic calculations.
Accumulator (A): 8 bit addressable used for arithmetic operations.
B (register) – used only for two instructions MUL AB and DIV AB.
Program counter (pc)- It is a 16 bit register, by this 8051 can access program address from 0000H to FFFFH a total of 64 kb of code.
Flag bits register and PSW registers: Flag bit register in 8051 is called as program status word (PSW). It is an 8 bit and bit addressable special purpose register, means each bit can be set or reset independently.
There are 4 flag in 8051.
P- Parity flag- PSW 0.0
If <1> then odd number of 1 in accumulator
If <0> then even number of 1 in accumulator
Overflow flag: Used to detect error in signed arithmetic operations.
Carry flag: it is used to detect errors in unsigned arithmetic operations, and affected after 8 bit addition and subtraction.
Stack in 8051:
Stack is use to store the data temporally 08H to 1FH can be used as stack in RAM locations.
Stack pointer (SP): It is 8 bit register, it indicate current RAM address available for stack.