0% found this document useful (0 votes)
6 views29 pages

Chapter 2 - 8051 Microcontroller

Uploaded by

seyoum shimels
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
6 views29 pages

Chapter 2 - 8051 Microcontroller

Uploaded by

seyoum shimels
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 29

Chapter 2 - 8051

Microcontroller
CHAPTER OBJECTIVES
 Understand the architecture of 8051 microcontroller
 State the pins and thier function of 8051 microcontroller
 Discuss the basic circuits required fot the functioning of
8051 microcontroller
 Discuss the memory organizations of 8051
microcontroller
 Explain the interfacing of external memory of 8051

microcontroller
CONTENT
Introduction
8051 architecture
8051 basic circuit
Memory organization
Interfacing external memory
1. INTRODUCTION
The 8051 microcontroller is a basic
microcontroller, it is first introduced by the ‘Intel
Corporation’ since 1970.
It is developed by the 8086 processor
architecture.
The 8051 is a family of the microcontroller,
which has been developed by different
manufactures such as Philips, Atmel, Dallas,
and so on.
The 8051 microcontroller has been used in
lots of embedded products from small
children’s toys to large automotive systems.
1. INTRODUCTION (CONT.)
 Even though Intel developed 8051 Microcontrollers, more
than 20 semiconductor manufacturers are still
producing 8051 compatible microcontrollers i.e.
processors based on MCS-51 Architecture.
 Some of the 8051 Microcontrollers produced by different
manufacturers are:
 Atmel (AT89C51, AT89S51),

 Phillips (S87C654),

 STC Micro (STC89C52),

 Infineon (SAB- C515, XC800),

 Siemens (SAB-C501),

 Silicon Labs (C8051),

 NXP (NXP700, NXP900), etc.


1. INTRODUCTION (CONT.)
 Some of the microcontrollers of 8051 family are given as follows
ON-CHIP ON-CHIP 16-BIT NO. OF FULL
DEVICE DATA PROGRAM TIMER/CO VECTORE DUPLEX
MEMORY MEMORY UNTER D I/O
(bytes) (bytes) INTERUP
TS

8031 128 None 2 5 1

8032 256 None 2 6 1

8051 128 4k ROM 2 5 1

8052 256 8k ROM 3 6 1

8751 128 4k EPROM 2 5 1

8752 256 8k EPROM 3 6 1

AT89C51 128 4k Flash Memory 2 5 1

AT89C52 256 8k Flash memory 3 6 1


2. 8051 ARCHITECTURE
 Simplified architecture of 8051 microcontroller
2. 8051 ARCHITECTURE (CONT.)
Architecture of
8051
microcontroller
2. 8051 ARCHITECTURE (CONT.)
 Consists of
 4K bytes internal ROM

 128 bytes internal RAM

 Four 8-bit I/O ports (P0 - P3).

 One serial interface

 Two 16-bit timers/counters

 Only 1 on chip oscillator (external crystal)

 6 interrupt sources (2 external , 3 internal, Reset)

 64K external code (program) memory(only read)PSEN

 64K external data memory(can be read and write) by RD,WR

 Code memory is selectable by EA (internal or external)

 The 8051 is an 8-bit processor, meaning that the CPU can work on
only 8 bits of data at a time.
 Data larger than 8 bits has to be broken into 8-bit pieces to be

processed by the CPU.


2. 8051 ARCHITECTURE (CONT.)
 The basic architecture of 8051 consists of:
 On-chip RAM: Random access memory of 128 byte is used for

data storage in 8051.


 RAM as a non-volatile memory consists of register banks,

stacks for temporary data storage and some special function


registers.
 On-chip ROM: 8051 consists of 4KB ROM for program storage.

 ROM as a volatile memory helps in permanent data storage.

 Timers and Counters: Timer helps in providing delay between

the events.
 In 8051, there are two timer pins T0, T1.
 If these pins are used in the counter mode, we can count the

external pulses.
 In T0, it is possible to store 16 bit data. This is done by storing

the lower 8 bit in TL0 and the upper 8 bit in TH0. Similarly, we
can store 16 bit data in T1 also.
 TMOD and TCON helps in the timer operation.
2. 8051 ARCHITECTURE (CONT.)
The basic architecture of 8051 consists of:
 Serial Port: In order, to perform the serial communication, TXD and RXD pins
are used.
 TXD pin is used for transmitting the serial data and the RXD pin is used

for the receiving of the data.


 SCON register is used to control the operation of the serial
communication.
 Input and Output Ports: P0, P1. P2. P3 form the four ports of 8051
microcontroller.
 Each of the port is 8 bit wide.

 Port P0 is used as I/O port and as a Lower Order Address bus.

 Port P2 can be used as I/O port and higher order bus A8 to A15.

 Port P3 can be used as I/O pin and each pin of port 3 has special

functions.
 Oscillator – This is used to provide clock to the 8051 microcontroller.
 The crystal frequency can vary from 4MHz to 30MHz.

 Interrupts - Interrupts are requests which are used to handle special


events or routines known as Interrupt Service Routines.
 INT0 and INT1 are the basic interrupt pins used in 8051.
2. 8051 ARCHITECTURE (CONT.)
The basic architecture of 8051 consists of (cont.):
 Arithmetic Logic Unit - This unit is used for arithmetic calculations.
 Accumulator (A register) – This register is used for arithmetic
operations.
 B register – This is an 8bit register that is bit addressable and is
used for two instructions only like MUL AB and DIV AB.
 Program Counter – is a 16 bit register that helps to access address
from 0000H to FFFFH.
 Program Counter is used to address the next instruction to be

executed from the ROM.


 Flag Bits and PSW register – The flag bits are used to indicate the
arithmetic condition of the ACC.
 Program Status Word (PSW) is the flag resister in 8051.

 This register consists of four flags like

 Carry, Auxiliary Carry Flag,


 Register Select 1, Register Select 0,

 Parity Flag,

 Overflow flag.
3. 8051 PIN DESCRIPTION
 The PIN arrangement of 8051 microcontroller:
3. 8051 PIN DESCRIPTION (CONT.)
 Pins 1 to 8 − these pins are known as Port 1.
 This port doesn’t serve any other functions. It is internally pulled up, bi-
directional I/O port.
 Pin 9 − It is a RESET pin, which is used to reset the microcontroller
to its initial values.
 Pins 10 to 17 − these pins are known as Port 3.
 This port serves some functions like interrupts, timer input, control signals,
serial communication signals RxD and TxD, etc.
 Pins 18 & 19 − these pins are 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 − these pins are known as Port 2.
 It serves as I/O port.
 Higher order address bus signals are also multiplexed using this port.
3. 8051 PIN DESCRIPTION (CONT.)
 Pin
29 − this is PSEN pin which stands for Program Store
Enable.
 It is used to read a signal from the external program memory.
 Pin30 − this is EA pin which stands for External Access
input.
 It is used to enable/disable the external memory interfacing.
 Pin31 − this is ALE pin which stands for Address Latch
Enable.
 It is used to demultiplex the address-data signal of port.
 Pins 32 to 39 − these pins are known as Port 0.
 It serves as I/O port.
 Lower order address and data bus signals are multiplexed using this

port.
 Pin 40 − this pin is used to provide power supply to the
circuit.
4. 8051 BASIC CIRCUIT
 The following image shows the basic circuit of the 8051
microcontroller
4. 8051 BASIC CIRCUIT (CONT.)
 The minimal interface required for it to work
 Power supply

 Pins 40 and 20 (VCC and GND) of the 8051 Microcontroller are

connected to +5V and GND respectively.


 Reset Circuit

 A logic HIGH (+5V) on Reset Pin for a minimum of two machine

cycles (24 clock cycles) will reset the 8051 Microcontroller.


 Consists of a capacitor, a resistor and a push button and this type of

reset circuit provides a Manual Reset Option.


 If you remove the push button, then the reset circuit becomes a

Power-On Reset Circuit.


 Oscillator Circuit or the Clock Circuit.

 A Quartz Crystal Oscillator is connected across XTAL1 and XTAL2 pins

i.e. Pins 19 and 18.


 The capacitors C1 and C2 can be selected in the range of 20pF to

40pF.
 The frequency of this crystal determines the machine cycle.

 With 8051 family we can use a crystal having frequency from 3 to 24

MHz
4. 8051 BASIC CIRCUIT (CONT.)
The minimal interface required for it to work (cont.)
 PSEN: Pin 29. This is an output pin. PSEN stands for “program
store enable”.
 In 8051 we leave this pin unconnected until otherwise mentioned.
 ALE/PROG: Pin 30. ALE refers to address latch enable.
 In 8051 we leave this pin unconnected until otherwise mentioned.

 EA/VPP: The EA pin no. 31 is known as external access.


 The 8051 microcontrollers have on chip ROM so the EA/VPP is set
to one (or Vcc).
 In case there is no on- chip ROM, like in case of 8031 we set this pin
equal to zero.
 This pin cannot be left unconnected.
4. 8051 BASIC CIRCUIT (CONT.)
Arranging the circuit board/module
 40 pin base has been mounted on the PCB (printed circuit board) as shown
in the figure below instead of directly soldering the microcontroller to
PCB which maybe damaged while soldering.
5. MEMORY ORGANIZATION
 It is how the processor accesses each memory and how to interface
external memory with 8051 Microcontroller.
 The 8051 Microcontroller Memory is separated in
 Program Memory (ROM)- used for storing the program to be

executed i.e. instructions.


 Data Memory (RAM)- used for storing temporary variable data and

intermediate results.
 8051 Microcontroller has both Internal ROM and Internal RAM.
 If the internal memory is inadequate, you can add external memory

using suitable circuits.


 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.
 Almost all modern 8051 Microcontrollers, like 8052 Series, have 8KB

of Internal Program Memory (ROM) in the form of Flash Memory


(ROM) and provide the option of reprogramming the memory.
5. MEMORY ORGANIZATION (CONT.)
Program Memory (ROM) of 8051
 In case of 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 and if the
memory addresses exceed the limit, then the instructions are fetched from the
external ROM in the address range of 1000H to FFFFH.
5. MEMORY ORGANIZATION (CONT.)
Program Memory (ROM) of 8051 (cont.)
 There is another way to fetch the instructions: ignore the
Internal ROM and fetch all the instructions only from the
External Program Memory (External ROM).
 For this scenario, the EA Pin must be connected to GND. In this
case, the memory addresses of the external ROM will be from
0000H to FFFFH.
5. MEMORY ORGANIZATION (CONT.)
Data Memory (RAM) of 8051
 Stores temporary data and intermediate results that are generated and
used during the normal operation of the microcontroller.
 Original Intel’s 8051 Microcontroller had 128B of internal RAM.
 But almost all modern variants of 8051 Microcontroller have 256B of
RAM.
 The first 128B i.e. memory addresses from 00H to 7FH is divided in to
 Working Registers (organized as Register Banks) -The first 32Bytes i.e.

memory from addresses 00H to 1FH consists of 32 Working Registers that


are organized as four banks with 8 Registers in each bank
 Bit–Addressable Area -16 Bytes -20H to 2FH- used to store bit values such

as status of motors, LEDS etc


 General Purpose RAM (also known as Scratchpad area)- 80 bytes ranging

from 30H to 7FH


 Special function registers -128 bytes adressed from 80-FF0 is used for
 Instruction register

 Data pointer

 Stack pointer

 PSW, timers, IO ports, ACC and B registers


5. MEMORY ORGANIZATION (CONT.)
Data Memory (RAM) of 8051 (cont)
5. MEMORY ORGANIZATION (CONT.)
Data Memory (RAM) of 8051 (cont.)
5. MEMORY ORGANIZATION (CONT.)
Data Memory (RAM) of 8051 (cont.)- SFR
5. MEMORY ORGANIZATION (CONT.)
Data Memory (RAM) of 8051 (cont.)- SFR
 SFRs Memory addresses are only direct addressable.
 Even though some of the addresses between 80H and FFH
are not assigned to any SFR, they cannot be used as
additional RAM area.
 In some microcontrollers, there is an additional 128B of
RAM, which share the memory address with SFRs i.e. 80H
to FFH.
 But, this additional RAM block is only accessed by

indirect addressing.
5.1. INTERFACING EXTERNAL MEMORY
A typical 8051 Microcontroller has 4KB of ROM and 128B of
RAM (most modern 8051 Microcontroller variants have 8K ROM
and 256B of RAM).
 The designer of an 8051 Microcontroller based system is not
limited to the internal RAM and ROM present in the 8051
Microcontroller.
 There is a provision of connecting both external RAM and

ROM i.e. Data Memory and Program.


 A maximum of 64KB of Program Memory (ROM) and Data

Memory (RAM) each can be interface with the 8051


Microcontroller.
 The reasons are
 Complex programs written in high – level languages often

tend to be larger and occupy more memory.


 Chips like 8031 or 8032, which doesn’t have any internal

ROM, have to be interfaced with external ROM.


5.1 INTERFACING EXTERNAL MEMORY (CONT.)
 The following image shows the block diagram of interfacing 64KB of
External RAM and 64KB of External ROM with the 8051
Microcontroller.

You might also like