Anda di halaman 1dari 134

Microcontrollers

Microcontrollers

Microcontrollers Microcontrollers  Specially designed microprocessors – It is small on chip computer  Highly integrated

Specially designed microprocessors

It is small on chip computer

Highly integrated chip includes all or most parts needed for controller

A typical microcontroller has:

bit manipulation

easy and direct access to I/O

quick and efficient interrupt processing

Microcontroller drastically reduces design cost

Worldwide Microcontroller

Worldwide

Microcontroller shipments

shipments

-- inin millions

millions ofof dollars

dollars --

'95 '96 '97
'95
'96
'97

'98

'99

00

4-bit

1826

1849

  • 1881 1856

   
  • 1816 1757

8-bit

5634

6553

  • 7529 8423

   
  • 9219 9715

16-bit

1170

1628

  • 2191 2969

   
  • 3678 4405

Worldwide Microcontroller

Worldwide

Microcontroller shipments

shipments

-- inin millions

millions --

'95 '96 '97
'95
'96
'97

'98

'99

00

4-bit

1100

  • 1100 1096

 

1064

1025

970

8-bit

1803

  • 2123 2374

 

2556

2681

2700

16-bit

157

227

313

419

501

585

Applications

Applications

Applications Applications  Appliances (microwave oven, refrigerators, television and VCRs, stereos)  Computers and computer equipment

Appliances (microwave oven, refrigerators, television and VCRs, stereos)

Computers and computer equipment (laser printers, modems, disk drives)

Automobiles (engine control, diagnostics, climate control),

Environmental control (greenhouse, factory, home) Instrumentation Aerospace Robotics, etc ...

Applications Applications  Appliances (microwave oven, refrigerators, television and VCRs, stereos)  Computers and computer equipment

Flavors

Flavors

Flavors Flavors  4, 8, 16, or 32 bit microcontrollers  specialized processors include features specific

4, 8, 16, or 32 bit microcontrollers specialized processors include features specific for

communications,

keyboard handling,

signal processing,

video processing, and other tasks.

Part 1
Part 1
Part 1
Part 1

Part 1

Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1

Popular Microcontrollers

Popular

Microcontrollers

Part 1 Popular Microcontrollers Popular Microcontrollers 8048 (Intel)  8051 (Intel and others)  80c196 (MCS-96)

8048 (Intel) 8051 (Intel and others) 80c196 (MCS-96) 80186,80188 (Intel) 80386 EX (Intel) 65C02/W65C816S/W65C134S (Western Design Center) MC14500 (Motorola)

Part 2
Part 2
Part 2
Part 2

Part 2

Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2

Popular Microcontrollers

Popular

Microcontrollers

Part 2 Popular Microcontrollers Popular Microcontrollers  68HC05 (Motorola)  68HC11 (Motorola and Toshiba)  683xx

68HC05 (Motorola) 68HC11 (Motorola and Toshiba) 683xx (Motorola) PIC (MicroChip) COP400 Family (National Semiconductor) COP800 Family (National Semiconductor) HPC Family (National Semiconductor) Project Piranha (National Semiconductor)

Part 3
Part 3
Part 3
Part 3

Part 3

Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3

Popular Microcontrollers

Popular

Microcontrollers

Part 3 Popular Microcontrollers Popular Microcontrollers Z8 (Zilog)  HD64180 (Hitachi)  TMS370 (Texas Instruments) 1802

Z8 (Zilog) HD64180 (Hitachi) TMS370 (Texas Instruments) 1802 (RCA) MuP21 (Forth chip) F21 (Next generation Forth chip)

Part 1
Part 1
Part 1
Part 1

Part 1

Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1

Programming

Programming Languages

Languages

Part 1 Programming Programming Languages Languages  Machine/Assembly language  Interpreters  Compilers  Fuzzy Logic

Machine/Assembly language Interpreters Compilers Fuzzy Logic and Neural Networks

Part 1
Part 1
Part 1
Part 1

Part 1

Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1

Development Tools

Development

Tools

Part 1 Development Tools Development Tools  Simulators  Resident Debuggers  Emulators  Java on

Simulators Resident Debuggers Emulators Java on Embedded Systems

Part 1 Development Tools Development Tools  Simulators  Resident Debuggers  Emulators  Java on

Choosing microcontoller

Choosing

microcontoller

Choosing microcontoller Choosing microcontoller  Technical support  Development tools  Documentation  Purchasing more devices

Technical support Development tools Documentation

Purchasing more devices at one manufacturer (A/D, memory, etc.)

Additional features (EEPROM, FLASH, LCD driver, etc.)

Microcontrollers

Microcontrollers

Microcontrollers Microcontrollers  Basic parts are: – C entral P rocessing U nit – RAM –

Basic parts are:

Central Processing Unit

RAM

EPROM/PROM/ROM or

FLASH Memory I/O serial or/and parallel

timers

interrupt controller

Optional parts are:

Watch Dog Timer

AD Converter

LCD driver

etc.

 

e

x

t

e

r

n

a

l

i

n

e

r

r

u

p

t

s

R O M i n t e r r u p t R A M c
R
O
M
i
n
t
e
r
r
u
p
t
R
A
M
c
o
n
t
r
o
l
C
P
U
b
u
s
4
I
/
O
s
e
r
O
S
C
c
o
n
t
r
o
l
p
o
r
t
s
p
o
T
x
DR
P
0P
2
P
1P
3
a
d
d
r
e
s
s
/
t i m e r t i m e r
t
i
m
e
r
t
i
m
e
r
i a r t
i
a
r
t

x

D

l

  • u

c

o

 

i

n

p

n

t

t

  • s

u

d

a

t

a

12/175

Intel

Intel 8051

8051

Intel Intel 8051 8051  A typical 8051 contains: – INTERNAL BUS P C H D

A typical 8051 contains:

INTERNAL BUS P C H D P H P 2 L A T C 1 2
INTERNAL BUS
P
C
H
D
P
H
P
2
L
A
T
C
1
2
8
x
8
4
K
x
8
R
A
R
R
A
M
R
O
M
P
C
L
D P
L
P
O
R
T
2
P
0
L
A
T
C
H
R
A
M
S
E
N
S
E
B
U
F
F
E
R
A
M
P
S
L
A
T
C
H
O
R
T
2
A
L
U
A
I
R
R
O
M
P
L
A
T
M
P
2
T
M
P
1
B
C
O
N
T
R
O
L
P
S
W
S
P
A
L
U
P 0 L A T C H S C O N P O R T 0
P
0
L
A
T
C
H
S
C
O
N
P
O
R
T
0
S
B
U
F
(
R
S
B
U
F
(
X
S
E
R
I A
P
O
R
T
T C O N E C ) T M O D M I T ) T
T
C
O
N
E
C
)
T
M
O
D
M
I
T
)
T
L
0
L
T
H
0
T
L
1
T
H
1
T
I
M
E
R
C
O
N
T
R
O
L
 

I

E

P

3

L

A

T

C

H

I

P

P

O

R

T

3

I

N

T

E

R

R

U

P

T

C

O

N

T

R

O

L

P 2 P
P
2
P

CPU with Boolean processor 5 or 6 interrupts:

2 external, 2 priority levels 2 or 3 16-bit timer/counters programmable full-duplex serial port 32 I/O lines (four 8-bit ports) RAM ROM/EPROM in some models

H

13/175

SECONDARY FUNCTIONS

Part 1

Intel

Intel 8051:

8051: Pin

Pin Description

Description

SECONDARY FUNCTIONS Part 1 Intel Intel 8051: 8051: Pin Pin Description Description VSS - Ground: 0V

VSS - Ground: 0V VCC - Power Supply P0.0-P0.7 - Port 0

Open drain, bi-directional I/O port

Pins that have 1s written to them float and can be used as high-impedance inputs

Multiplexed low-order address and data bus during accesses to external program and data memory

V C C V S S X T A L 1 X T A L 2
V
C
C
V
S
S
X
T
A
L
1
X
T
A
L
2
R
S
T
E
A
/
V
p
p
P
S
E
N
A
L
E
/
P
R
O
G
R
x
D
T
x
D
I
N
T
0
I
N
T
1
T
0
T
1
W
R
R
D
PORT 3
PORT 2
PORT 1
PORT 0
 

A

D

D

R

E

S

S

 

D

A

T

A

B

A

D

D

R

E

S

S

14/175

Part 2
Part 2
Part 2
Part 2

Part 2

Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2

Intel

Intel 8051:

8051: Pin

Pin Description

Description

Part 2 Intel Intel 8051: 8051: Pin Pin Description Description  P2.0-P2.7 - Port 2 

P2.0-P2.7 - Port 2

 

Bi-directional I/O port with internal pull-ups

Pins that have 1s written to them float and can be used as high-impedance inputs.

Port 2 emits high-order address byte during accesses to external program and data memory

P3.0-P3.7 - Port 3

 

Bi-directional I/O port with internal pull-ups

Pins that have 1s written to them float and can be used as high-impedance inputs.

Port 3 serves the special features:

RxD - Serial input port

TxD - Serial output port

INT0 - External interrupt

INT1 - External interrupt

T0 - Timer 0 external input

T1 - Timer 1 external input

WR - External data memory

write strobe RD - External data memory read strobe

Part 3
Part 3
Part 3
Part 3

Part 3

Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3

Intel

Intel 8051:

8051: Pin

Pin Description

Description

Part 3 Intel Intel 8051: 8051: Pin Pin Description Description  RST - Reset – A

RST - Reset

A high on this pin for two machine cycles resets the devices

ALE - Address Latch Enable

Output pulse for latching the low byte of address during an access to external memory

PSEN - Program Store Enable

Read strobe to external program memory

EA - External Access Enable

EA must be externally held low to enable device to fetch code from external memory locations.

XTAL1 - Crystal 1

Input to the inverting oscillator amplifier and input to internal clock generator circuits

XTAL2 - Crystal 2

Output from the inverting oscillator amplifier

Part 1
Part 1
Part 1
Part 1

Part 1

Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1

Intel

Intel 8051:

8051: Pin

Pin Configurations

Configurations

Part 1 Intel Intel 8051: 8051: Pin Pin Configurations Configurations  Dual In-Line Package  Plastic

Dual In-Line Package Plastic Lead Chip Carrier Plastic Quad Flat Pack

 

P

1

P

1

P

1

P

1

P

1

P

1

P

1

P

1

R

S

R

x

D

/

 

T

x

P

3

  • I T

N

0

/

  • I T

N

1

/

T

0

/

P

T

1

/

P

W

R

/

P

R

D

/

P

 

X

T

A

X

T

A

 

V

s

     
. 0 1 0 4 V c c . 1 2 9 3 P 0 .
   

.

0

 

1

 

0

  • 4 V

c

c

       

.

1

 

2

 

9

  • 3 P

0

.

0

/

A

D

0

     

.

2

 

3

 

8

  • 3 P

0

.

1

/

A

D

1

     

.

3

 

4

 

7

  • 3 P

0

.

2

/

A

D

2

     

.

4

 

5

 

6

  • 3 P

0

.

3

/

A

D

3

     

.

5

 

6

 

5

  • 3 P

0

.

4

/

A

D

4

     

.

6

 

7

 

4

  • 3 P

0

.

5

/

A

D

5

     

.

7

 

8

 

3

  • 3 P

0

.

6

/

A

D

6

     
 

T

 

9

 

2

  • 3 P

0

.

6

/

A

D

6

     

P

3

1

0

.

 

0

1

  • 3 E

A

D

/

   

1

1

 

0

  • 3 A

L

E

.

1

   

P

3

1

2

.

2

9

  • 2 P

S

E

N

     

P

3

1

3

.

3

8

  • 2 P

2

.

7

/

A

1

5

     
 

3

1

.

4

4

 

7

  • 2 P

2

.

6

/

A

1

4

     
 

3

1

.

5

5

 

6

  • 2 P

2

.

5

/

A

1

3

     
 

3

1

.

6

6

5

  • 2 P

2

.

4

/

A

1

2

     
 

3

1

.

7

7

 

4

  • 2 P

2

.

3

/

A

1

1

     
 

L

1

2

8

 

3

  • 2 P

2

.

2

/

A

1

0

     
 

L

1

1

9

 

2

  • 2 P

2

.

1

/

A

9

     
 

s

2

0

 

1

  • 2 P

2

.

0

/

A

8

     

17/175

 
 
Part 2
Part 2
Part 2
Part 2

Part 2

Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2

Intel

Intel 8051:

8051: Pin

Pin Configurations

Configurations

–6 –1 –40
–6
–1
–40
–7 –39 PQFP –17 –29 –18 –28
–7
–39
PQFP
–17
–29
–18
–28

1 NIC

16 P3.4/T0

31 P2.7/A15

2 P1.0

17 P3.5/T1

32 PSEN

3 P1.1

18 P3.6/WR

33 ALE

4 P1.2

19 P3.4/RD

34 NIC

5 P1.3

20 XTAL2

35 EA

6 P1.4

21 XTAL1

36 P0.7/AD7

7 P1.5

22 VSS

37 P0.6/AD6

8 P1.6

23 NIC

38 P0.5/AD5

9 P1.7

24 P2.0/A8

39 P0.4/AD4

10 RST

25 P2.1/A9

40 P0.3/AD3

11 P3.0/RxD

26 P2.2/A10

41 P0.2/AD2

12 NIC

27 P2.3/A11

42 P0.1/AD1

13 P3.1/TxD

28 P2.4/A12

43 P0.0/AD0

14 P3.2/INT0

29 P2.5/A13

44 VCC

15 P3.3/INT1

30 P2.6/A14

1

11

4 4 34 P LC C 1 2 22
4 4
34
P LC C
1 2
22

3 3

23

  • 1 VS S

P 1.5

  • 16 P 0.6/A D 6

3 1

  • 2 N IC

P 1.6

  • 17 P 0.5/A D 5

3 2

  • 3 P2 .0/A 8

P 1.7

  • 18 P 0.4/A D 4

3 3

  • 4 P2 .1/A 9

R ST

  • 19 P 0.3/A D 3

3 4

  • 5 P2 .2/A 10

P 3.0/R xD

  • 20 P 0.2/A D 2

3 5

  • 6 P2 .3/A 11

N IC

  • 21 P 0.1/A D 1

3 6

  • 7 P2 .4/A 12

P 3.1/T xD

  • 22 P 0.0/A D 0

3 7

  • 8 P2 .5/A 13

P 3.2/IN T 0

  • 23 V C C

3 8

  • 9 P2 .6/A 14

P 3.3/IN T 1

  • 24 N IC

3 9

  • 1 P2 .7/A 15

0

P3.4 /T0

  • 25 P 1.0

4 0

  • 1 PS EN

1

P3.5 /T1

  • 26 P 1.1

4 1

  • 1 A LE

2

P3.6 /W R

  • 27 P 1.2

4 2

  • 1 N IC

3

P3.4 /R D

  • 28 P 1.3

4 3

  • 1 EA

4

XT A L2

  • 29 P 1.4

4 4

  • 1 P0 .7/A D 7

5

XT A L1

  • 30 18/175

Part 1

Intel

Intel 8051:

8051: CPU

CPU

Part 1 Intel Intel 8051: 8051: CPU CPU  Primary elements are: – P 2 L

Primary elements are:

Part 1 Intel Intel 8051: 8051: CPU CPU  Primary elements are: – P 2 L
P 2 L A T C P O R T 2
P
2
L
A
T
C
P
O
R
T
2

eight bit ALU with associated registers A, B, PSW and SP

sixteen-bit Program Counter (PC) Data Pointer registers

INTERNAL BUS P C H D P H P 2 L A T C 1 2
INTERNAL BUS
P
C
H
D
P
H
P
2
L
A
T
C
1
2
8
x
8
4
K
x
8
R
A
R
R
A
M
R
O
M
P
C
L
D P
L
P
O
R
T
2
P
0
L
A
T
C
H
R
A
M
S
E
N
S
E
B
U
F
F
E
R
A
M
P
S
H
A
L
U
A
I
R
R
O
M
P
L
A
T
M
P
2
T
M
P
1
B
C
O
N
T
R
O
L
P
S
W
S
P
A
L
U
P 0 L A T C H S C O N P O R T 0
P
0
L
A
T
C
H
S
C
O
N
P
O
R
T
0
S
B
U
F
(
R
E
S
B
U
F
(
X
M
S
E
R
I
A
L
P
O
R
T
T C O N C ) T M O D I T ) T L 0
T
C
O
N
C
)
T
M
O
D
I
T
)
T
L
0
T
H
0
T
L
1
T
H
1
T
I
M
E
R
C
O
N
T
R
O
L
 

I

E

P

3

L

A

T

C

H

I

P

P

O

R

T

3

I

N

T

E

R

R

U

P

T

C

O

N

T

R

O

L

19/175

Part 2
Part 2
Part 2
Part 2

Part 2

Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2

Intel

Intel 8051:

8051: CPU

CPU

Part 2 Intel Intel 8051: 8051: CPU CPU  The ALU can manipulate one-bit as well

The ALU can manipulate one-bit as well as eight-bit data types

This features makes the 8051 especially well suited for controller-type applications

A total of 51 separated operations move and manipulate three data types:

Boolean (1-bit)

Byte (8-bit)

Address (16-bit)

Part 3
Part 3
Part 3
Part 3

Part 3

Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3

Intel

Intel 8051:

8051: CPU

CPU

Part 3 Intel Intel 8051: 8051: CPU CPU  Instruction types: – Arithmetic Operations – Logic

Instruction types:

Arithmetic Operations

Logic Operations for Byte Variables

Data Transfer Instructions

Boolean Variable Manipulation

Program Branching and Machine Control

Part 4
Part 4
Part 4
Part 4
Part 4

Part 4

Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4

Intel

Intel 8051:

8051: CPU

CPU

Part 4 Intel Intel 8051: 8051: CPU CPU  There are eleven addressing modes: – seven

There are eleven addressing modes:

seven for data

four for program sequence control

Most operations allow several addressing modes, bringing total number of instructions to 111, encompassing 255 of the 256 possible 8-bit instruction opcodes

8051 instruction set fares well at both real-time control and data intensive algorithms

Part 1
Part 1
Part 1
Part 1

Part 1

Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1
Part 1

Intel

Intel 8051:

8051: Memory

Memory Organization

Organization

Part 1 Intel Intel 8051: 8051: Memory Memory Organization Organization  Program memory is separate distinct

Program memory is separate distinct from data memory

Each memory type has a different addressing mechanism, different control signals, and a different functions

Architecture supports several distinct “physical” address spaces functionally separated at the hardware level:

On - chip program memory

On - chip data memory

Off - chip program memory

Off - chip data memory

On chip special function registers

Part 2
Part 2
Part 2
Part 2

Part 2

Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2
Part 2

Intel

Intel 8051:

8051: Memory

Memory Organization

Organization

Part 2 Intel Intel 8051: 8051: Memory Memory Organization Organization  Program (Code) memory – Holds

Program (Code) memory

Holds the actual 8051 program that is to be run

Limited to 64K may be found on-chip as ROM or EPROM may be stored completely off-chip in an external ROM or an external EPROM Flash RAM is also another popular method of storing a program Various combinations of these memory types may be used (e.g. 4 K on-chip and 64 KB off-chip)

Part 3
Part 3
Part 3
Part 3

Part 3

Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3
Part 3

Intel

Intel 8051:

8051: Memory

Memory Organization

Organization

Part 3 Intel Intel 8051: 8051: Memory Memory Organization Organization  External RAM – External RAM

External RAM

External RAM is any random access memory which is found off-chip

External RAM is slower

To increment an Internal RAM location by 1 requires only 1 instruction and 1 instruction cycle

To increment a 1-byte value stored in External RAM requires 4 instructions and 7 instruction cycles

While Internal RAM is limited to 128 bytes (256 bytes with an 8052), the 8051 supports External RAM up to 64K

Part 4
Part 4
Part 4
Part 4
Part 4

Part 4

Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4
Part 4

Intel

Intel 8051:

8051: Memory

Memory Organization

Organization

Part 4 Intel Intel 8051: 8051: Memory Memory Organization Organization  On-chip memory – Two types:

On-chip memory

Two types:

 

Internal RAM; and Special Function Register (SFR) memory

Internal RAM is on-chip so it is the fastest RAM available

Internal RAM is volatile, when the 8051 is reset this memory is cleared

Special Function Registers (SFRs) are areas of memory that control specific functionality of the 8051 processor

Part 1

Intel

Intel 8051:

8051: Memory

Memory Access

Access

Part 1 Intel Intel 8051: 8051: Memory Memory Access Access  PORT 2 : High byte

PORT 2 : High byte of address held for the duration of read or write cycle

PORT 0 : time multiplexed low byte of address with data byte

Signal ALE: used to capture the address byte into an external latch

E A P O R T 2 A 8 - A 1 5 A 8 -
E
A
P
O
R
T
2
A
8
-
A
1
5
A
8
-
A
1