8051microcontroller-111122104537-phpapp02
TRANSCRIPT
-
8/11/2019 8051microcontroller-111122104537-phpapp02
1/42
-
8/11/2019 8051microcontroller-111122104537-phpapp02
2/42
Contents:Contents:
IntroductionIntroductionBlock Diagram andBlock Diagram and Pin Description of the 8051Pin Description of the 8051
RegistersRegisters
Memor mapping in 8051Memor mapping in 8051
!tack in the 8051!tack in the 8051
I"# Port ProgrammingI"# Port Programming$imer$imer
InterruptInterrupt
-
8/11/2019 8051microcontroller-111122104537-phpapp02
3/42
Why do we need to learnWhy do we need to learn
Microprocessors/controllers?Microprocessors/controllers? The microprocessor is the core of
computer systems.
Nowadays many communication, digitalentertainment, portable devices, arecontrolled by them.
A designer should now what types ofcomponents he needs, ways to reduceproduction costs and product reliable..
-
8/11/2019 8051microcontroller-111122104537-phpapp02
4/42
-
8/11/2019 8051microcontroller-111122104537-phpapp02
5/42
The necessary tools for aThe necessary tools for a
microprocessor/controllermicroprocessor/controller
&'(# &entral 'rocessing (nit
$/)# $nput /)utput
*us# Address bus + !ata bus
Memory# AM + )M
Timer
$nterrupt
%erial 'ort
'arallel 'ort
-
8/11/2019 8051microcontroller-111122104537-phpapp02
6/42
-
8/11/2019 8051microcontroller-111122104537-phpapp02
7/42
R&M R#M
I"#
Port$imer
!erial
C#M
PortMicrocontroller
CP%
A smaller computer
On-chip RAM, ROM, I/O ports(((
!ampleMotorola"s $#)), Intel"s #%*), +ilo"s +# an' PIC )$
A sinle chip
Microcontroller .
-
8/11/2019 8051microcontroller-111122104537-phpapp02
8/42
Microprocessor
CPU is stan'-alone, RAM,
ROM, I/O, timer are separate
'esiner can 'eci'e on theamount of ROM, RAM an'
I/O ports(
e!pansie
ersatility
eneral-purpose
Microcontroller
0 CPU, RAM, ROM, I/O an'
timer are all on a sinle chip
0 fi! amount of on-chip ROM,RAM, I/O ports
0 for applications in 1hich cost,
po1er an' space are critical
0 sinle-purpose
Microprocessor s( Microcontroller
-
8/11/2019 8051microcontroller-111122104537-phpapp02
9/42
m&e''e' system means the processor is em&e''e' into that
application(
An em&e''e' pro'uct uses a microprocessor or microcontroller to 'o
one tas2 only(
In an em&e''e' system, there is only one application soft1are that is
typically &urne' into ROM(
!ampleprinter, 2ey&oar', i'eo ame player
m&e''e' System
-
8/11/2019 8051microcontroller-111122104537-phpapp02
10/42
)( meetin the computin nee's of the tas2 efficiently an' cost
effectiely
0 spee', the amount of ROM an' RAM, the num&er of I/O ports
an' timers, si3e, pac2ain, po1er consumption
0 easy to upra'e
0 cost per unit
4( aaila&ility of soft1are 'eelopment tools
0 assem&lers, 'e&uers, C compilers, emulator, simulator,
technical support
5( 1i'e aaila&ility an' relia&le sources of the microcontrollers(
6hree criteria in Choosin a Microcontroller
-
8/11/2019 8051microcontroller-111122104537-phpapp02
11/42
Block DiagramBlock Diagram
CP%
#n'chip
R&M
#n'chip
R#M for
program
code
( I"# Ports
$imer 0
!erial
Port#!C
Interrupt
Control
)*ternal interrupts
$imer 1
$imer"Counter
Bus
Control
$*D R*DP0 P1 P+ P,
&ddress"Data
Counter
Inputs
-
8/11/2019 8051microcontroller-111122104537-phpapp02
12/42
-
8/11/2019 8051microcontroller-111122104537-phpapp02
13/42
Pin Description of the 8051Pin Description of the 8051
-0123
45-6-----0-1-2-3-4-56
06543210
-6543210-
'-.6'-.-'-.'-.'-.0'-.1'-.2
'-.3%T78!9'.67T8!9'.-
7T69'.07T-9'.1
8TA:8TA:-
;N!
7$NT69'.
7$NT-9'.
7!9'.37W9'.2
-
8/11/2019 8051microcontroller-111122104537-phpapp02
14/42
Wednesday, %eptemb Mahdi "assanpour
&reated by bibe&reated by bibe
-
8/11/2019 8051microcontroller-111122104537-phpapp02
15/42
7iure 8a9( 6A: Connection to #%*)7iure 8a9( 6A: Connection to #%*)
&
,0p-
&-
,0p-
8TA:
8TA:-
;N!
Usin a ;uart3 crystal oscillator
-
8/11/2019 8051microcontroller-111122104537-phpapp02
16/42
Pins of 8051Pins of 8051 +"(+"(
RS6pin = reset
> It is an input pin an' is actie hih normally lo1 (
6he hih pulse must &e hih at least 4 machine cycles(
> It is a po1er-on reset(
Upon applyin a hih pulse to RS6, the
microcontroller 1ill reset an' all alues in reisters
1ill &e lost( Reset alues of some #%*) reisters
-
8/11/2019 8051microcontroller-111122104537-phpapp02
17/42
-igure ./ Po2er'#n R)!)$ Circuit-igure ./ Po2er'#n R)!)$ Circuit
5% p7
5% p7
#(4 ?
)% u7
@
cc
))(%*=4 MB3
A/PP)
4
RS6
5)
)=
)#
=
-
8/11/2019 8051microcontroller-111122104537-phpapp02
18/42
Pins of 8051Pins of 8051 ,"(,"(
/Apin 5) e!ternal access> 6here is no on-chip ROM in #%5) an' #%54 (
> 6he /A pin is connecte' to GN to in'icate the co'e is
store' e!ternally(
> /PSN A: are use' for e!ternal ROM(
> 7or #%*), /A pin is connecte' to cc(
> D/E means actie lo1(
/PSNpin 4=proram store ena&le
> 6his is an output pin an' is connecte' to the O pin of the
ROM(
-
8/11/2019 8051microcontroller-111122104537-phpapp02
19/42
Pins of 8051Pins of 8051 ("(("(
A:pin 5% a''ress latch ena&le
>It is an output pin an' is actie hih(
>#%*) port % proi'es &oth a''ress an' 'ata(
>6he A: pin is use' for 'e-multiple!in the a''ressan' 'ata &y connectin to the G pin of the F:S5F5latch(
I/O port pins
>6he four ports P%, P), P4, an' P5(
>ach port uses # pins(
>All I/O pins are &i-'irectional((
-
8/11/2019 8051microcontroller-111122104537-phpapp02
20/42
Wednesday, %eptemb Mahdi "assanpour
-
8/11/2019 8051microcontroller-111122104537-phpapp02
21/42
Bar'1are Structure of I/O PinBar'1are Structure of I/O Pin
ach pin of I/O ports
> Internal CPU &us communicate 1ith CPU
> A latch store the alue of this pin
latch is controlle' &y D Rea' latch ) rea' alue from internal latch> A transistor M) ate
Gate%. open
Gate). close
-
8/11/2019 8051microcontroller-111122104537-phpapp02
22/42
! :atch! :atch##
-
8/11/2019 8051microcontroller-111122104537-phpapp02
23/42
Wednesday, %eptemb Mahdi "assanpour
-
8/11/2019 8051microcontroller-111122104537-phpapp02
24/42
Wednesday, %eptemb Mahdi "assanpour
-
8/11/2019 8051microcontroller-111122104537-phpapp02
25/42
Wednesday, %eptemb Mahdi "assanpour
-
8/11/2019 8051microcontroller-111122104537-phpapp02
26/42
Wednesday, %eptemb Mahdi "assanpour
-
8/11/2019 8051microcontroller-111122104537-phpapp02
27/42
Wednesday, %eptemb Mahdi "assanpour
-
8/11/2019 8051microcontroller-111122104537-phpapp02
28/42
Other PinsOther Pins
P), P4, an' P5 hae internal pull-up resisters(
>P), P4, an' P5 are not open 'rain(
P% has no internal pull-up resistors an' 'oes not
connects to cc insi'e the #%*)(>P% is open 'rain(
>Compare the fiures of P)( an' P%((
Bo1eer, for a prorammer, it is the same to proramP%, P), P4 an' P5(
All the ports upon RS6 are confiure' as output(
-
8/11/2019 8051microcontroller-111122104537-phpapp02
29/42
Wednesday, %eptemb Mahdi "assanpour
-
8/11/2019 8051microcontroller-111122104537-phpapp02
30/42
Port % 1ith Pull-Up ResistorsPort % 1ith Pull-Up Resistors
P%(%P%()P%(4P%(5P%(P%(*P%($P%(F
D!5000
8351
8451
cc10 6
Port0
-
8/11/2019 8051microcontroller-111122104537-phpapp02
31/42
Port 5 Alternate 7unctionsPort 5 Alternate 7unctions
)F)FRRP5(FP5(F
)$)$
-
8/11/2019 8051microcontroller-111122104537-phpapp02
32/42
R)!)$ alue of !ome 8051 Registers:R)!)$ alue of !ome 8051 Registers:
0000DP$R0003!P
0000P!7
0000B0000&CC
0000PC
Reset alueRegister
R&M are all ero
-
8/11/2019 8051microcontroller-111122104537-phpapp02
33/42
Registers
A
H
R%
R)
R5
R
R4
R*
RF
R$
PB P:
PC
P6R
PC
Some #%*) )$-&it Reister
Some #-&itt Reisters of
the #%*)
-
8/11/2019 8051microcontroller-111122104537-phpapp02
34/42
Memory mapping in 8051Memory mapping in 8051
ROM memory map in 8051 family
%%%%B
%777B
%%%%B
)777B
%%%%B
F777B
#F*)
A6#=C*)#F*4
A6#=C*4
0
S*%%%-54
4
from Atmel Corporationfrom allas Semicon'uctor
-
8/11/2019 8051microcontroller-111122104537-phpapp02
35/42
RAM memory space allocation in the 8051
F7B
5%B
47B
4%B
)7B
)FB)%B
%7B
%FB
%#B
)#B
%%BReister Han2 %
(Stac2)Register Bank 1
Reister Han2 4
Reister Han2 5
Hit-A''ressa&le RAM
Scratch pa' RAM
-
8/11/2019 8051microcontroller-111122104537-phpapp02
36/42
!tack in the 8051!tack in the 8051
6he reister use' to accessthe stac2 is calle' !P 8stac2
pointer9 reister(
6he stac2 pointer in the #%*)is only # &its 1i'e, 1hichmeans that it can ta2e alue%% to 77B(
-
8/11/2019 8051microcontroller-111122104537-phpapp02
37/42
Timer #Timer #
-
8/11/2019 8051microcontroller-111122104537-phpapp02
38/42
)
-
8/11/2019 8051microcontroller-111122104537-phpapp02
39/42
TM)! egisterTM)! egister##
;ate # When set, timer only runs while $NT76,-9 ishigh.
&/T #&ounter/Timer select bit.
M- # Mode bit -. M6 # Mode bit 6.
-
8/11/2019 8051microcontroller-111122104537-phpapp02
40/42
T&)N egister#T&)N egister#
T>-# Timer - overflow flag.
T-# Timer - run control bit.
T>6# Timer 6 overflag.
T6# Timer 6 run control bit.
$=-# =ternal interrupt - edge flag. $T-# =ternal interrupt - type flag.
$=6# =ternal interrupt 6 edge flag.
$T6# =ternal interrupt 6 type flag.
$nterrupt #$nterrupt #
-
8/11/2019 8051microcontroller-111122104537-phpapp02
41/42
$nterrupt #$nterrupt #
-
8/11/2019 8051microcontroller-111122104537-phpapp02
42/42
$nterrupt =nable egister #$nterrupt =nable egister #
=A :Global enable/disable. --- : ndefined.
=T #=nable Timer interrupt. =% #=nable %erial port interrupt. =T- #=nable Timer - interrupt.
=8- #=nable =ternal - interrupt. =T6 # =nable Timer 6 interrupt. =86 # =nable =ternal 6 interrupt..