Top Banner
Overview Overview Introduction Introduction Block Diagram and Block Diagram and Pin Description of Pin Description of the 8051 the 8051 Registers Registers Memory mapping in Memory mapping in 8051 8051 Stack in the 8051 Stack in the 8051 I/O Port I/O Port Programming Programming Timers Timers Interrupts & Interrupts & Applications Applications
33
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Mcu51

OverviewOverview

IntroductionIntroductionBlock Diagram and Block Diagram and Pin Pin Description of the 8051Description of the 8051RegistersRegistersMemory mapping in 8051 Memory mapping in 8051 Stack in the 8051Stack in the 8051I/O Port ProgrammingI/O Port ProgrammingTimersTimersInterrupts &Interrupts &ApplicationsApplications

Page 2: Mcu51

Features :Features : The Intel 8051 is used in embedded The Intel 8051 is used in embedded

systemssystems 8-bit CPU8-bit CPU 4k bytes ROM for the program4k bytes ROM for the program 128 BYTES of RAM for variables128 BYTES of RAM for variables 32 I/O lines ( 4 PORTS WITH 8 EACH )32 I/O lines ( 4 PORTS WITH 8 EACH ) 2 timers2 timers 1 Serial port1 Serial port 6 interrupt sources6 interrupt sources Low cost (10-15 cents per chip)Low cost (10-15 cents per chip)

Page 3: Mcu51

Its not an exaggeration if I say that ,today there is no electronic gadget on the earth which is designed without a Microcontroller. Ex: communication devices, digital entertainment, portable devices etc…

Not believable ??? See the next slide

Why do we need to learn Why do we need to learn Microcontrollers ?Microcontrollers ?

Page 4: Mcu51

Personal information products: Cell phone, Personal information products: Cell phone, pager, watch, pocket recorder, calculatorpager, watch, pocket recorder, calculator

Laptop components: mouse, keyboard, modem, Laptop components: mouse, keyboard, modem, fax card, sound card, battery chargerfax card, sound card, battery charger

Home appliances: door lock, alarm clock, Home appliances: door lock, alarm clock, thermostat, air conditioner, TV remote, VCR, thermostat, air conditioner, TV remote, VCR, small refrigerator, exercise equipment, small refrigerator, exercise equipment, washer/dryer, microwave ovenwasher/dryer, microwave oven

Industrial equipment: Temperature/pressure Industrial equipment: Temperature/pressure controllers, Counters, timers, RPM Controllers controllers, Counters, timers, RPM Controllers

Toys: video games, cars, dolls, etc. Toys: video games, cars, dolls, etc.

Page 5: Mcu51

So, A good designer should always know what type of controller he/she is using ,their architecture, advantages , disadvantages , ways to reduce production costs and product reliability etc….

O.K ????O.K ????

Page 6: Mcu51

Microcontrollers from different Microcontrollers from different manufacturersmanufacturers

•Atmel •ARM •Intel

•8-bit •8XC42 •MCS48 •MCS51 •8xC251

•16-bit •MCS96 •MXS296

•National Semiconductor •COP8

•Microchip •12-bit instruction PIC •14-bit instruction PIC

•PIC16F84 •16-bit instruction PIC

•NEC

•Motorola •8-bit

•68HC05 •68HC08 •68HC11

•16-bit •68HC12 •68HC16

•32-bit •683xx

•Texas Instruments •TMS370 •MSP430

•Zilog •Z8 •Z86E02

Page 7: Mcu51

Then What is a Microcontroller ?

A smaller computer On-chip RAM, ROM, I/O ports... Example : Motorola’s 6811, Intel’s 8051,

Zilog’s Z8 and PIC 16X

RAM ROM

I/O Port

TimerSerial COM Port

CPU

A single chip Microcontroller

Page 8: Mcu51

EVOLUTIONEVOLUTION

Flashback !!!!Flashback !!!! In the year 1976, Motorola created a Microprocessor In the year 1976, Motorola created a Microprocessor

chip called 6801 which replaced its brother 6800 with chip called 6801 which replaced its brother 6800 with certain add-on chips to make a computer. This paved certain add-on chips to make a computer. This paved the way for the new revolution in the history of chip the way for the new revolution in the history of chip design and gave birth to a new entity calleddesign and gave birth to a new entity called

MICROCONTROLLER.MICROCONTROLLER.

The INTEL bagged the credit of producing the first The INTEL bagged the credit of producing the first Microcontroller 8048 with a CPU and 1K bytes of Microcontroller 8048 with a CPU and 1K bytes of EPROM, 64 Bytes of RAM an 8-Bit Timer and 27 EPROM, 64 Bytes of RAM an 8-Bit Timer and 27 I/O pins in 1976. I/O pins in 1976.

Page 9: Mcu51

Evolution Evolution contdcontd…… Then followed the most popular controller Then followed the most popular controller

8051 in the year 1980 with 4K bytes of 8051 in the year 1980 with 4K bytes of ROM,128 Bytes of ROM,128 Bytes of RAM RAM , a serial port, two 16-, a serial port, two 16-bit Timers , and 32 I/O pins.bit Timers , and 32 I/O pins.

The 8051 family has many additions and The 8051 family has many additions and improvements over the years and remains a improvements over the years and remains a most soughtafter tool for todays circuit most soughtafter tool for todays circuit designers.designers.

The same INTEL introduced a 16 bit The same INTEL introduced a 16 bit controller 8096 in the year 1982 controller 8096 in the year 1982

Page 10: Mcu51

Later INTEL introduced 80c196 series of 16-Later INTEL introduced 80c196 series of 16-bit microcontrollers for mainly industrial bit microcontrollers for mainly industrial applicationsapplications

Microchip, another company has introduced a Microchip, another company has introduced a microcontroller PIC 16C64 an 8-bit in the year microcontroller PIC 16C64 an 8-bit in the year 19851985..

32-bit microcontrollers have been developed by IBM 32-bit microcontrollers have been developed by IBM and Motorola-MPC 505 is a 32-bit RISC controller of and Motorola-MPC 505 is a 32-bit RISC controller of MotorolaMotorola

The 403 GA is a 32 -bit RISC embedded controller of The 403 GA is a 32 -bit RISC embedded controller of IBMIBM

Page 11: Mcu51

ARM ControllersARM Controllers

In recent times ARM company (Advanced In recent times ARM company (Advanced Risc machines) has developed and introduced Risc machines) has developed and introduced 32 bit controllers which are highend 32 bit controllers which are highend application devices,especially communication application devices,especially communication devices like mobiles , ipods etc..(Refer devices like mobiles , ipods etc..(Refer www.arm.com)www.arm.com)

Page 12: Mcu51

Types of Microcontrollers Types of Microcontrollers

Page 13: Mcu51

RESET CIRCUITARYRESET CIRCUITARY

X1

X2RST

Vcc

10 uF

8.2 K

30 pF

9

31

Page 14: Mcu51

8051 contains four I/O ports (P0 - P3)8051 contains four I/O ports (P0 - P3) Each port can be used as input or output Each port can be used as input or output

(bi-direction)(bi-direction)

Page 15: Mcu51

Important Features of 8051Important Features of 8051

4K bytes ROM4K bytes ROM 128 bytes RAM128 bytes RAM Four 8-bit I/O portsFour 8-bit I/O ports Two 16-bit timersTwo 16-bit timers Serial interfaceSerial interface 64K external code memory space64K external code memory space 64K data memory space64K data memory space

Page 16: Mcu51

MCS-51 “Family” of MCS-51 “Family” of MicrocontollersMicrocontollers

Feature 8031 8051 8052 8751 Feature 8031 8051 8052 8751 ROM ROM NONO 4kB 8kB 4kB UV Eprom 4kB 8kB 4kB UV Eprom

RAM (Bytes) 128 128 256 128RAM (Bytes) 128 128 256 128

TIMERS 2 2 3 2TIMERS 2 2 3 2

I/O PINS 32 32 32 32I/O PINS 32 32 32 32

SERIAL PORTS 1 1 1 1SERIAL PORTS 1 1 1 1

INTERRUPT INTERRUPT 6 6 8 66 6 8 6 SOURCESSOURCES

Page 17: Mcu51

On-Chip Facilities OverviewOn-Chip Facilities Overview(Original 8051)(Original 8051)

Parallel Input/Output PortsParallel Input/Output Ports System Clock GeneratorSystem Clock Generator Serial PortSerial Port TimersTimers Interrupt ControlInterrupt Control

Page 18: Mcu51

Microcontroller ArchitecturesMicrocontroller Architectures

CPUProgram + Data

Address Bus

Data Bus

Memory

Von NeumannArchitecture

CPUProgram

Address Bus

Data Bus

HarvardArchitecture

Memory

Data

Address Bus

Fetch Bus

0

0

0

2n

Page 19: Mcu51

““Original” 8051 Original” 8051 MicrocontrollerMicrocontroller

Oscillator and timing

4096 Bytes Program Memory

(ROM)

128 BytesData Memory

(RAM)

Two 16 Bit Timer/Event

Counters

8051 CPU

64 K Byte Bus Expansion

Control

Programmable I/O

Programmable Serial Port Full Duplex UART

Synchronous Shifter

Internal data bus

External interrupts

subsystem interrupts

Control Parallel portsAddress Data BusI/O pins

Serial InputSerial Output

Page 20: Mcu51

Pin Description of the 8051Pin Description of the 8051 The 8051 is a 40 pin The 8051 is a 40 pin

device, but out of device, but out of these 40 pins, 32 are these 40 pins, 32 are used for I/O. used for I/O.

24 of these are dual 24 of these are dual purpose, i.e. they can purpose, i.e. they can operate as I/O or a operate as I/O or a control line or as part control line or as part of address or data of address or data bus.bus.

Page 21: Mcu51

8051 CPU Registers8051 CPU Registers

A (8-bit Accumulator)B (8-bit register for Mul &Div)PSW (8-bit Program Status Word)SP (8-bit Stack Pointer)PC (16-bit Program Counter)DPTR (16-bit Data Pointer)

Page 22: Mcu51

RegistersRegisters

0706050403020100

R7R6R5R4R3R2R1R0

0F

08

17

10

1F

18

Bank 3

Bank 2

Bank 1

Bank 0

Four Register BanksEach bank has R0-R7

Page 23: Mcu51

Bit Addressable MemoryBit Addressable Memory20h – 2Fh (16 locations X 8-bits = 128 bits)

7F 78

1A

10

0F 08

07 06 05 04 03 02 01 00

27

26

25

24

23

22

21

20

2F

2E

2D

2C

2B

2A

29

28

Bit addressing:mov C, 1Ahormov C, 23h.2

Page 24: Mcu51

Special Function RegistersSpecial Function Registers

DATA registers

CONTROL registers

•Timers

•Serial ports

•Interrupt system

•Analog to Digital converter•Digital to Analog converter etc..

Addresses 80h – FFh

Direct Addressing is used to access SFRs

Page 25: Mcu51

Contd…Contd…

Page 26: Mcu51

List of RegistersList of Registers(*Denotes the SFRs)(*Denotes the SFRs)

Page 27: Mcu51

PSW REGISTERPSW REGISTER

Page 28: Mcu51

Memory mapping in 8051 Memory mapping in 8051

ROM memory map in 8051 family

0000H

0FFFH

0000H

1FFFH

0000H

7FFFH

80518752

4k

DS5000-32

8k 32k

from Atmel Corporation

from Dallas Semiconductor

Page 29: Mcu51

RAM memory space allocation in the 8051

7FH

30H

2FH

20H

1FH

17H

10H

0FH

07H

08H

18H

00H Register Bank 0

)Stack (Register Bank 1

Register Bank 2

Register Bank 3

Bit-Addressable RAM

Scratch pad RAM

Page 30: Mcu51

PORTS OF 8051PORTS OF 8051

8051 has 4 Ports. Port 0, Port1, Port2 , Port38051 has 4 Ports. Port 0, Port1, Port2 , Port3

Port 0 is a dual purpose port, it is Port 0 is a dual purpose port, it is located from pin 32 to pin 39 (8 pins). located from pin 32 to pin 39 (8 pins). To use this port as both input/output To use this port as both input/output ports each pin must be connected ports each pin must be connected externally to a 10 k ohm pull-up externally to a 10 k ohm pull-up resistor.This is because Port 0 is an resistor.This is because Port 0 is an open drain. open drain.

Simple ex: Simple ex: MOV A, #22MOV A, #22

BACK BACK MOV P0 ,A P0 ,A

ACALL DELAYACALL DELAY

CPL ACPL A

SJMP BACK SJMP BACK

Page 31: Mcu51

Port 0 with Pull-Up ResistorsPort 0 with Pull-Up Resistors

Page 32: Mcu51

Port 1 is a dedicated I/O port from pin 1 to pin 8.Upon reset it is configured as output. It is generally used for interfacing to external device thus if you need to connect to switches or LEDs, you could make use of these 8 pins, but it doesn’t need any pull-up resistors as it is having internally

Like port 0, port 2 is a dual-purpose port.(Pins 21 Like port 0, port 2 is a dual-purpose port.(Pins 21 through 28) It can be used for general I/O or as through 28) It can be used for general I/O or as the high byte of the address bus for designs with the high byte of the address bus for designs with external code memory. Likeexternal code memory. Like P1 ,Port2 also doesn’t P1 ,Port2 also doesn’t require any pull-up resistorsrequire any pull-up resistors

Ports….Ports….

Page 33: Mcu51

Ports contd…Ports contd…

Port 3 is also dual purpose but designers Port 3 is also dual purpose but designers generally avoid using this port unnecessarily for generally avoid using this port unnecessarily for I/O because the pins have alternate functions I/O because the pins have alternate functions which are related to special features of the 8051. which are related to special features of the 8051. Indiscriminate use of these pins may interfere Indiscriminate use of these pins may interfere with the normal operation of the 8051.with the normal operation of the 8051.

However, for a programmer, it is the same to program P0, P1, P2 and P3.

All the ports upon RESET are configured as output. To use any of the ports as an input port,it must be set(Programmed)