Vous êtes sur la page 1sur 22

8051 Basic Component

• CPU
• 128 bytes internal RAM
• 4K bytes internal ROM
• Four 8-bit I/O ports (P0 - P3).
• Two 16-bit timers/counters
• One serial port

CPU RAM ROM


A single chip
I/O Serial Microcontroller
Timer COM
Port Port
8051
Schematic
Pin out
8051 P1.0 1 40 Vcc

Foot Print
P1.1 2 39 P0.0(AD0)
P1.2 3 38 P0.1(AD1)
P1.3 4 37 P0.2(AD2)
P1.4 5 36 P0.3(AD3)
P1.5 6 35 P0.4(AD4)
P1.6 7 34 P0.5(AD5)
P1.7 8 8051 33 P0.6(AD6)
RST 9 (8031) 32 P0.7(AD7)
(RXD)P3.0 10 (8751) 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(8951)
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14)
(T1)P3.5 15 26 P2.5(A13)
(WR)P3.6 16 25 P2.4(A12)
(RD)P3.7 17 24 P2.3(A11)
XTAL2 18 23 P2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)
8051 Internal Block Diagram - Architecture
Features of 8051
• 8 Bit CPU with Registers A(Accumulator) and B
• 16 bit Program Counter and Data Pointer(DPTR)
• Arithmatic Logic Unit with 8 bit Program Status Word (PSW)
• 8 –bit Stack Pointer (SP)
• Internal ROM or EPROM with 4K capacity
• Internal RAM of 128 bytes
• Four Register banks each containing 8 registers R0-R7
• 16 bytes of RAM which are bit addressable
Features of 8051
• 80 bytes of general purpose 8 bit Data memory
• 32 Input/Output pins arranged as 4- 8 bit ports P0 – P3
• 2 - 16 bit Timer/Counters T0 & T1
• Serial Port - Full Duplex , data Transmitter/ Receiver with Buffer SBUF
• Control Registers : TCON, TMOD , SCON , PCON ,IP and IE
• 6 interrupt sources (2 external , 3 internal, Reset)
• Oscillator and Clock Circuits
• 64 K External code (program) memory (only read) by PSEN
• 64K External data memory(can be read and write) by RD,WR
Block Diagram
External Interrupts

Interrupt 4k 128 bytes Timer 0


Control ROM RAM Timer 1

CPU

OSC Bus
4 I/O Ports Serial
Control

P0 P2 P1 P3 TXD RXD
Addr/Data
Functions of Each Block
• 1. CPU- Central Processing Unit comprising of ALU
and Control units
ALU-Arithmetic and Logic Unit perform the
arithmetic and logical operations like addition,
subtraction , multiplication, logical AND,OR etc.
To do this operations one operand should be in
Accumulator, another may in B register or in general
purpose register. Mostly the result of the ALU
operations are in A register. Some results are in B
register also.
Oscillator
2.Oscillator provides clock for the Timimg &
control unit.
Crystal oscillator provides stability and
perfect clock. So crystal oscillator is used in
this microcontroller.
In 8051 Microcontroller all the operations
are executed based on the clock frequency
only and it is @ 12 MHz
3.INTERRUPT CONTROL

All the external and internal interrupts


are managed by the interrupt control
unit.
8051 has five interrupts. The SFRs
Interrupt Enable (IE) & Interrupt Priority
(IP) decide the interrupt operations
4.BUS CONTROL
• In 8051 has 8 bit internal bus connecting all
the blocks. The various sources and
destination of data are managed by the bus
control unit.
• It also control the external address buses AD0-
AD7 & A8-A15 using control signals, namely
External Access (EA), Program Store Enable
(PSEN), and Address Latch Enable (ALE)
5.ON CHIP ROM
• The 8051 has 4 kilobytes of inbuilt ROM.
• It is otherwise called program memory.
Usually program-code are stored in ROM.
• To store program into ROM , programmer is
needed. If more area is required in ROM, an
external ROM may be connected.
• Maximum of 64kb ROM memory can be used ,
using AD0-AD7 & A8-A15
6.ON CHIP RAM

• The 8051 has inbuilt 128 bytes of RAM


• They are used as data memory.
• 128 bytes From Address 00H to 7FH
• 32 bytes for 4 Register Banks – each with 8
registers
• 16 Bit addressable locations
• 80 General purpose locations used as scratch pad
• If the system needs more memory, external RAM
may be connected up to 64kb, using AD0-AD7 &
A8-A15
7.I/O PORTS

• There are four I/O ports in 8051.


• These are named as P0,P1 ,P2,P3.
• All are bidirectional.
• Each port have its address, latch, output driver
and input buffer.
• By default all ports are output.
• To make any port as input port , it should be
initialized by sending ‘1’ level in each pin.
8.SERIAL PORT

• TXD and RXD are used for serial port.


• The SFRs SCON & SBUF manage the serial port
operation
9.TIMER/COUNTER

• There are two 16 bit timer/counter are in


8051 - T0 & T1.
• Each one may be used either as Timer or
Counter.
• The SFRs TCON,TMOD manage the
Timer/Counter operation in various modes
Stack
• STACK It is a part of RAM in which data will be stored temporary
during execution of program and is handled by the Stack Pointer the
Stack Pointer has the address of top of the stack.
• STACK works on last in first out(LIFO) principle.
• PUSH is used to store data into stack.
• POP is used to retrieve data from stack.
• During the execution of CALL instructions, the microcontroller
stores the content of program counter in the stack memory.
• During the RET instructions , the content of stack is moved in to
program counter.
Machine Cycle
Machine Cycle
INTERRUPTS
• The interrupts refer to a notification, communicated to
the controller, by a hardware device or software
• Whenever an interrupt occurs the controller completes
the execution of the current instruction in the main
program and starts the execution of a program called
Interrupt Service Routine (ISR).
• ISR is a piece of code (program) that tells the processor
or controller what to do when the interrupt occurs.
• After the execution of ISR, controller returns back to
the instruction in the main program from where it has
jumped (before the interrupt was received).
8051 Interrupts
Interrupt Flag Vector Address

External interrupt 0 IE0 0003H

Timer 0 TF0 000BH

External interrupt 1 IE1 0013H

Timer 1 TF1 001BH

Serial port RI/TI 0023H


Comparison of 8051 Family
Members

Vous aimerez peut-être aussi