You are on page 1of 25

Unit III

The 8051
Microcontroller
What is Microcontroller ?
 VLSI IC that contains a CPU (Processor) along with some
other peripherals like Memory (RAM and ROM), I/O Ports,
Timers/Counters, Communication Interface, ADC, etc.

 Microprocessor (developed before Microcontroller) is just


a Processor (CPU) .
Doesn’t have the above mentioned peripherals.
 To make it work or build a system around it, we need to
interface the peripherals separately.
Applications of 8051 MC
 Consumer Appliances -TV Tuners, Remote controls, Computers, Sewing Machines, etc.
 Home Applications -TVs, VCR, Video Games, Camcorder, Music Instruments, Home Security
Systems, Garage Door Openers, etc.
 Communication Systems -Mobile Phones, Intercoms, Answering Machines, Paging Devices,
etc.
 Office -Fax Machines, Printers, Copiers, Laser Printers, etc.
 Automobiles -Air Bags, ABS, Engine Control, Transmission Control, Temperature Control,
Keyless Entry, etc.
 Aeronautical and Space
 Medical Equipment
 Defense Systems
 Robotics
 Industrial Process and Flow Control
 Radio and Networking Equipment
 Remote Sensing
Overview of 8051 family

8051 original
member of Intel MC
8051 family.

8052,8031other
members.
Internal Architecture
8051 Microcontroller Features
 8 – Bit ALU: Heart of a microcontroller.
 RAM: 128 Bytes of RAM (Data memory) includes SFRs and Input /
Output Port Registers.
 ROM: 8051 has 4 KB of on-chip ROM (Program Memory).
 I/O Ports: four 8 – bit Input / Output Ports. Bit addressable and
bidirectional.
 Timers / Counters: Two 16 – bit Timers / Counters.
 Serial Port: 8051 supports full duplex UART Communication.
 External Memory: two 16 – bit address lines. each for RAM and ROM.
Total external memory 8051 access for RAM and ROM is 64KB (216 for
each type).
 Additional Features: Interrupts, on-chip oscillator, Boolean Processor,
Power Down Mode, etc.
8051 Hardware/Architecture
 Accumulator(Add E0H) - 8 bit register, for arithmetic and logical
operations. Also used to transfer data between external memory.
 B register (Add F0H)- used along with Accumulator for multiplication
and division. A and B registers together - MATH registers.
Mov 0f0h,#40H
 PSW (Program Status Word ,Add DOh). - 8 bit register which contains
the arithmetic status of ALU and the bank select bits of register banks.

 CY AC F0 RS1 RS0 OV - P :Flags


PSW
Contd..
 OV - overflow ,for large arithmetic result so can not be stored
in one reg.
P - parity
 Stack Pointer (SP) – Contains the address of the data item on
the top of the stack. Stack may reside anywhere on the internal
RAM.
For certain opcodes to store and retrieve data quickly.
 Program Counter (PC) – 16 bit PC contains the address of next
instruction to be executed.
On reset PC will set to 0000. After fetching every instruction PC
will increment by one.

Contd..
Data Pointer (DPTR) – DPH (Data pointer higher byte), DPL (Data pointer lower byte).
16 bit register to furnish address information for internal and external program memory
and for external data memory.
 Register Banks: 00h to 1Fh. 8 general-purpose registers R0 through R7 (R0, R1, R2, R3,
R4, R5, R6, and R7). four such register banks.
 Accept one byte of data
 Selection of active register bank can be done through RS1,RS0 bits of PSW
Special Function Registers (SFRs)
 Act as a control table that monitor and control the operation of the
8051 Microcontroller.
 In Internal RM Structure, the Address Space from 80H to FFH is
allocated to SFRs.
 Out of these 128 Memory Locations (80H to FFH), only 21 locations that
are actually assigned to SFRs.
 Each SFR has one Byte Address and also a unique name which specifies
its purpose.
 SFRs are a part of the Internal RAM Structure.
 first 128 Bytes (00H to 7FH) is for regular Internal RAM and next 128 Bytes
(80H to FFH) is for SFRs.
Contd..

 The Data Pointer -16-bit Register . combination of DPL


(Data
Pointer Low) and DPH (Data Pointer High) SFRs.
 Can be used as a single 16-bit register (as DPTR) or two
8-bit registers (as DPL and DPH).
separate addresses in the SFR Memory Space.
DPL = 82H and DPH = 83H.
 DPTR used by the programmer for addressing external memory
(Program – ROM or Data – RAM).
Contd..
Timers/Counters
 Two 16 bit timers and counters.
 Used for measurement of intervals to determine the pulse width of pulses.
 TL0/TH0 (Timer 0 Low/High)
The Timer 0 consists of two SFRs: TL0 and TH0. The TL0 - lower byte and the
TH0 is the higher byte and together they form a 16-bit Timer0 Register.
 TL1/TH1 (Timer 1 Low/High)
The TL1 and TH1 are the lower and higher bytes of the Timer 0.

TCON (Timer Control)
 Used to start or stop the Timers of 8051 Microcontroller.
Also contains bits to indicate if the Timers has overflowed.
The TCON SFR also consists of Interrupt related bits
TMOD (Timer Mode)
 The TMOD or Timer Mode register or SFR used to set the Operating
Modes of the Timers T0 and T1.
 The lower four bits are used to configure Timer0 and the higher four
bits are used to configure Timer1.
Pin diagram
Contd..
 Pins 1 – 8:- recognized as Port 1.
Different from other ports, this port doesn’t provide any other purpose..
 Pin 9:- RESET pin to set the micro-controller 8051 to its primary values,
 Pins 10 – 17:- recognized as Port 3.
This port supplies a number of other functions such as timer input,
Interrupts, serial communication indicators TxD & RxD, control indicators
for outside memory interfacing , WR & RD, etc
 Pins 18 and 19:- for interfacing an outer crystal to give system clock.
Contd..
 Pin 20:- Vss – ground (0 V) .
 Pins- 21-28:- recognized as Port 2 (P 2.0 – P 2.7) – other than serving
as Input/output port, senior order address bus indicators
multiplexed with this bi directional port.
 Pin- 29:- Program Store Enable or PSEN. Holds program code for
ext.mem.
 Pin-30:- External Access or EA input
used to permit or prohibit outer memory interfacing. For no outer
memory need, this pin connected to Vcc.
Contd..
 Pin-31:- Address Latch Enable or ALE/PROG is brought into play to de-
multiplex the address data indication of port 0 (for ext. memory
interfacing).
Also program pulse input during EPROM programing
 Pins 32-39: recognized as Port 0 (P0.0 to P0.7) –
other than serving as Input/output port, low order data & address bus
signals multiplexed with this port (to provide the use of outer memory
interfacing).
8051 Memory Organization
 Memory separated in Program Memory (ROM) and Data Memory (RAM).
 The Program memory - storing the program to be executed i.e. instructions.
 The Data Memory- storing temporary variable data and intermediate result
 original 8051 Microcontroller by Intel has 4KB of internal ROM.
External Memory
 For 4KB of Internal ROM, the address space is 0000H to 0FFFH.
If the address space i.e. the program addresses exceed this value,
then the CPU will automatically fetch the code from the external
Program Memory.
 For this, the External Access Pin (EA Pin) must be pulled HIGH i.e.
when the EA Pin is high, the CPU first fetches instructions from the
Internal Program Memory in the address range of 0000H to 0FFFFH
 if the memory addresses exceed the limit, then the instructions
are fetched from the external ROM in the address range of 1000H
to FFFFH.
Contd..

You might also like