0% found this document useful (0 votes)
78 views

To Microcontrollers: 8051 Microcontroller Suresh.P.Nair, HOD - ECE, RCET 1

This document provides an introduction to microcontrollers. It discusses why microprocessors and microcontrollers are needed in modern devices and defines the basic components of a microprocessor/controller, including the CPU, I/O, memory, timers, and interrupts. It then differentiates between microprocessors and microcontrollers, noting that microcontrollers have RAM, ROM, I/O and other components integrated onto a single chip. The rest of the document focuses on microcontrollers, describing their use in embedded systems, factors to consider when choosing a microcontroller, and an overview of the 8051 microcontroller including its features, pin descriptions and functions.

Uploaded by

Peace
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

To Microcontrollers: 8051 Microcontroller Suresh.P.Nair, HOD - ECE, RCET 1

This document provides an introduction to microcontrollers. It discusses why microprocessors and microcontrollers are needed in modern devices and defines the basic components of a microprocessor/controller, including the CPU, I/O, memory, timers, and interrupts. It then differentiates between microprocessors and microcontrollers, noting that microcontrollers have RAM, ROM, I/O and other components integrated onto a single chip. The rest of the document focuses on microcontrollers, describing their use in embedded systems, factors to consider when choosing a microcontroller, and an overview of the 8051 microcontroller including its features, pin descriptions and functions.

Uploaded by

Peace
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Introduction

to
Microcontrollers
8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 1
Why do we need to learn
Microprocessors/controllers?

• The microprocessor is the core of computer systems.

• Nowadays many communication, digital entertainment,


portable devices, are controlled by them.

• A designer should know what types of components he


needs, ways to reduce production costs and product
reliable.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 2


The necessary tools for a
microprocessor/controller
1. CPU: Central Processing Unit
2. I/O: Input /Output
3. Bus: Address bus & Data bus
4. Memory: RAM & ROM
5. Timer
6. Interrupt
7. Serial Port
8. Parallel Port

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 3


Microprocessors
• CPU for Computers
• No RAM, ROM, I/O on CPU chip itself
• Example: Intel's x86, Motorola’s 680x0

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 4


Microcontroller
• A smaller computer
• On-chip RAM, ROM, I/O ports...
• Example: Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 5


Microprocessor vs. Microcontroller
Microprocessor Microcontroller
• CPU is stand-alone, RAM, • CPU, RAM, ROM, I/O and
ROM, I/O, timer are separate timer are all on a single chip

• Designer can decide on the • Fix amount of on-chip ROM,


amount of ROM, RAM and I/O RAM, I/O ports
ports.
• For applications in which cost,
• Expansive power and space are critical

• Versatility • Not Expansive

• General-purpose • Single-purpose

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 6


Microcontrollers for Embedded Systems
• Home
– Appliances, intercom, telephones, security systems, garage door openers,
answering machines, fax machines, home computers, TVs, cable TV tuner,
VCR, camcorder, remote controls, video games, cellular phones, musical
instruments, sewing machines, lighting control, paging, camera, pinball
machines, toys, exercise equipment etc.

• Office
– Telephones, computers, security systems, fax machines, microwave, copier,
laser printer, color printer, paging etc.

• Auto
– Trip computer, engine control, air bag, ABS, instrumentation, security
system, transmission control, entertainment, climate control, cellular
phone, keyless entry

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 7


Choosing a Microcontroller
• 8-bit microcontrollers
– Motorola’s 6811
– Intel’s 8051
– Zilog’s Z8
– Microchip’s PIC

• There are also 16-bit and 32-bit microcontrollers


made by various chip makers

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 8


Criteria for Choosing a Microcontroller
• Meeting the computing needs of the task at hand
efficiently and cost effectively
– Speed
– Packaging
– Power consumption
– The amount of RAM and ROM on chip
– The number of I/O pins and the timer on chip
– How easy to upgrade to higher performance or lower power-
consumption versions
– Cost per unit

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 9


Criteria for Choosing a Microcontroller
• Availability of software development tools, such as
compilers, assemblers, and debuggers

• Wide availability and reliable sources of the


microcontroller
– The 8051 family has the largest number of diversified (multiple
source) suppliers
• Intel (original)
• Atmel
• Philips/Signetics
• AMD
• Infineon (formerly Siemens)
• Matra
• Dallas Semiconductor/Maxim
8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 10
8051 CPU Operation
1. Features
2. Pin Diagram
3. Block Diagram

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 11


8051 Microcontroller
• Intel introduced 8051, referred as MCS- 51, in
1981.

• The 8051 is an 8-bit processor


– The CPU can work on only 8 bits of data at a time

• The 8051 became widely popular after allowing


other manufactures to make and market any
flavor of the 8051.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 12


8051 Family
• The 8051 is a subset of the 8052
• The 8031 is a ROM-less 8051
– Add external ROM to it
– You lose two ports, and leave only 2 ports for I/O operations

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 13


8051 Features
• 64KB Program Memory address space
• 64KB Data Memory address space
• 4K bytes of on-chip Program Memory
• 128 bytes of on-chip Data RAM
• 32 bidirectional and individually addressable 1/0 lines
• Two 16-bit timer/counters
• Full duplex UART
• 6-source/5-vector interrupt structure with two priority
levels
• On-chip clock oscillator
8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 14
Pin Description of the 8051
• 8051 family members (e.g., 8751, 89C51, 89C52,
DS89C4x0)
– Have 40 pins dedicated for various functions such as I/O, RD,
WR, address, data, and interrupts.
– Come in different packages, such as
• DIP(dual in-line package),
• QFP(quad flat package), and
• LLC(leadless chip carrier)

• Some companies provide a 20-pin version of the 8051


with a reduced number of I/O ports for less demanding
applications
8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 15
Pin Diagram of the 8051

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 16


XTAL1 and XTAL2
• The 8051 has an on-chip oscillator but requires an
external clock to run it
– A quartz crystal oscillator is connected to inputs XTAL1 (pin19)
and XTAL2 (pin18)
– The quartz crystal oscillator also needs two capacitors of 30 pF
value

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 17


XTAL1 and XTAL2 …..
• If you use a frequency source other than a crystal
oscillator, such as a TTL oscillator:
– It will be connected to XTAL1
– XTAL2 is left unconnected

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 18


XTAL1 and XTAL2 …..
• The speed of 8051 refers to the maximum oscillator
frequency connected to XTAL.

• We can observe the frequency on the XTAL2 pin using


the oscilloscope.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 19


RST
• RESET pin is an input and is active high (normally low)
• Upon applying a high pulse to this pin, the microcontroller will
reset and terminate all activities
• This is often referred to as a power-on reset
• Activating a power-on reset will cause all values in the registers to
be lost

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 20


RST
• In order for the RESET input to be effective, it must have
a minimum duration of 2 machine cycles.
• In other words, the high pulse must be high for a
minimum of 2 machine cycles before it is allowed to go
low.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 21


EA’
• EA’, “external access’’, is an input pin and
must be connected to Vcc or GND

• The 8051 family members all come with on-


chip ROM to store programs and also have
an external code and data memory.

• Normally EA pin is connected to Vcc

• EA pin must be connected to GND to


indicate that the code or data is stored
externally.
8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 22
PSEN’ and ALE
• PSEN, “program store enable’’, is an
output pin

• This pin is connected to the OE pin of the


external memory.

• For External Code Memory, PSEN’ = 0

• For External Data Memory, PSEN’ = 1

• ALE pin is used for demultiplexing the


address and data.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 23


I/O Port Pins
• The four 8-bit I/O ports P0, P1, P2
and P3 each uses 8 pins.

• All the ports upon RESET are


configured as output, ready to be
used as input ports by the external
device.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 24


Port 0
• Port 0 is also designated as AD0-AD7.

• When connecting an 8051 to an external


memory, port 0 provides both address and
data.

• The 8051 multiplexes address and data


through port 0 to save pins.

• ALE indicates if P0 has address or data.


– When ALE=0, it provides data D0-D7
– When ALE=1, it has address A0-A7

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 25


Port 1 and Port 2
• In 8051-based systems with no external
memory connection:
– Both P1 and P2 are used as simple I/O.
• In 8051-based systems with external
memory connections:
– Port 2 must be used along with P0 to provide
the 16-bit address for the external memory.
– P0 provides the lower 8 bits via A0 – A7.
– P2 is used for the upper 8 bits of the 16-bit
address, designated as A8 – A15, and it cannot
be used for I/O.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 26


Port 3
• Port 3 can be used as input or output.

• Port 3 has the additional function of


providing some extremely important
signals

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 27


Pin Description Summary
PIN TYPE NAME AND FUNCTION
Vss I Ground: 0 V reference.
Vcc I Power Supply: This is the power supply voltage for normal,
idle, and power-down operation.
P0.0 - P0.7 I/O Port 0: Port 0 is an open-drain, bi-directional I/O port. Port
0 is also the multiplexed low-order address and data bus
during accesses to external program and data memory.
P1.0 - P1.7 I/O Port 1: Port I is an 8-bit bi-directional I/O port.

P2.0 - P2.7 I/O Port 2: Port 2 is an 8-bit bidirectional I/O. Port 2 emits the
high order address byte during fetches from external
program memory and during accesses to external data
memory that use 16 bit addresses.
P3.0 - P3.7 I/O Port 3: Port 3 is an 8 bit bidirectional I/O port. Port 3 also
serves special features as explained.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 28


Pin Description Summary
PIN TYPE NAME AND FUNCTION
RST I Reset: A high on this pin for two machine cycles while the
oscillator is running, resets the device.
ALE O Address Latch Enable: Output pulse for latching the low byte
of the address during an access to external memory.
PSEN* O Program Store Enable: The read strobe to external program
memory. When executing code from the external program
memory, PSEN* is activated twice each machine cycle,
except that two PSEN* activations are skipped during
each access to external data memory.
EA*/VPP I External Access Enable/Programming Supply Voltage: EA*
must be externally held low to enable the device to fetch
code from external program memory locations. If EA* Is
held high, the device executes from internal program
memory. This pin also receives the programming supply
voltage Vpp during Flash programming. (applies for 89c5x
MCU's)
8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 29
Internal RAM Structure

Direct
Addressing
Only
SFR [ Special Function
Direct & Registers]
Indirect
Addressing
128 Byte Internal RAM

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 30


Special Function Registers [SFR]

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 31


Program Status Word [PSW]

C AC F0 RS1 RS0 OV F1 P
Carry Parity
Auxiliary Carry User Flag 1
User Flag 0 Register Bank Select Overflow

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 32


8051 instructions that affects flag

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 33


128 Byte RAM
• There are 128 bytes of RAM in the 8051.
– Assigned addresses 00 to 7FH General Purpose
Area
• The 128 bytes are divided into 3 different
groups as follows:
BIT Addressable
1. A total of 32 bytes from locations 00 to 1F Area
hex are set aside for register banks. 128 BYTE
2. A total of 16 bytes from locations 20H to 2FH INTERNAL RAM
Reg Bank 3
are set aside for bit-addressable read/write
memory. Reg Bank 2
Register Banks
3. A total of 80 bytes from locations 30H to 7FH Reg Bank 1
are used for read and write storage, called Reg Bank 0
scratch pad RAM.

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 34


8051 RAM with addresses

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 35


8051 Register Bank Structure

Bank 3 R0 R1 R2 R3 R4 R5 R6 R7
Bank 2 R0 R1 R2 R3 R4 R5 R6 R7
Bank 1 R0 R1 R2 R3 R4 R5 R6 R7
Bank 0 R0 R1 R2 R3 R4 R5 R6 R7

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 36


8051 Register Banks with address

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 37


8051 Programming Model

8051 Microcontroller Suresh.P.Nair , HOD - ECE , RCET 38

You might also like