Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 16

UNIT 6 : INTEL 8051 MICRCONTROLLER

Distinguish between Microrocessor !n" Microcontro##er


$%No Microrocessor Microcontro##er
1
2 A microprocessor is a general
purpose device which is called a
CPU
A microcontroller is a dedicated chip which
is also called single chip computer.
3 A microprocessor do not contain
onchip I/OPorts, Timers, emories
etc..
A microcontroller includes !A, !O,
serial and parallel inter"ace, timers,
interrupt circuitr# $in addition to CPU% in a
single chip.
& icroprocessor instructions are
mainl# ni''le or '#te addressa'le
icrocontroller instructions are 'oth 'it
addressa'le as well as '#te addressa'le.
( icroprocessor 'ased s#stem
design is comple) and e)pensive
icrocontroller 'ased s#stem design is
rather simple and cost e""ective.
& The Instruction set o"
microprocessor is comple) with
large num'er o" instructions.
The instruction set o" a icrocontroller is
ver# simple with less num'er o"
instructions.
* +g, *-*&,*-*( +g, *-&.,A/!
.
T'(E$ O) MICROCONTROLLER$:
icrocontrollers can 'e classi"ied on the 'asis o" internal 'us width, architecture, memor# and
instruction set as 01'it,*1'it,.(1'it and 321'it micrcontrollers.
.% *+bit Microcontro##ers, These 01'it microcontrollers are small si2e, minimum pin count
and low cost controllers which are widel# used "or 3+4 5 3C4 displa# drivers
,porta'le 'atter# chargers etc.. Their power consumption is also low.
2% 8+bit Microcontro##ers: These are the most popular and widel# used
microcontrollers .A'out &&6 o" all CPUs sold in the world are *1'it microcontrollers
onl#. The well 7nown *1'it microcontroller is *-&. which was designed '# Intel in the
#ear .8*- "or the use in em'edded s#stems. A/! icrocontrollers.
3% 16+bit Microcontro##ers : 9hen the microcontroller per"orms .(1'it arithmetic and
logical operations at an instruction, the microcontroller is said to 'e a .(1'it
microcontroller. The# "ind applications in dis7 drivers, modems,printers,scanners and
servomotor control. +)amples o" .(1'it microcontrollers are Intel *-8( "amil#
0% ,-+.it Microcontro##ers: These microcontrollers used in applications li7e Automative
control, Communication networ7s,!o'otics,Cell phones ,:P!; 5 P4As etc. +)amples
o" .(1'it microcontrollers are A! <.
INTEL 8051 MICRCONTROLLER :
The *-&. microcontroller is a ver# popular *1'it microcontroller introduced '# Intel in the #ear
.8*.. The *-&. is 'ased on an *1'it CI;C core with =arvard architecture.
2
;alient "eatures :
The salient "eatures o" *-&. icrocontroller are
* 'it CPU with two *1'it registers A 5 >.
.(1'it Program counter$PC% and .(1'it 4ata pointer $4PT!%.
* 'it Program ;tatus 9ord$P;9% ?lag !egister.
* 'it ;tac7 Pointer$;P%.
0-8( '#tes on chip program memor# $!O%.
.2* '#tes on chip data memor#$!A%.
*1'it data 'us,.(1'it address 'us.
Two 1.( 'it timers T
-
and T
..
?ive Interrupts $3 internal and 2 e)ternal%.
?our *1'it Ports $PO!T-, PO!T.,PO!T2,PO!T3% .
One icrosecond instruction c#cle with .2 =2 Cr#stal.
One "ull duple) serial communication port.
/rchitecture 0 b#oc1 "i!gr!2 o3 8051 2icrocontro##er:
The architecture o" the *-&. microcontroller can 'e understood "rom the 'loc7 diagram.
The 'loc7 diagram o" *-&. microcontroller is shown in ?ig 'elow. It consists o" an *1'it A3U,
one *1'it P;9$Program ;tatus !egister%, A and > registers , .(1'it Program counter , .(1'it
4ata pointer register$4PT!%,.2* '#tes o" !A and 0-8( '#tes o" !O and "our parallel I/O
ports.
3
)ig%,% .#oc1 Di!gr!2 o3 8051 Microcontro##er
/rith2etic !n" Logic!# Unit:+
*-&. has *1'it A3U which can per"orm all the *1'it arithmetic and logical operations in one
machine c#cle. The A3U is associated with two registers A 5 >
/ !n" . Registers ,
The A and > registers are special "unction registers which hold the results o" man# arithmetic
and logical operations o" *-&..The A register is also called the /ccu2u#!tor and as it@s name
suggests, is used as a general register to accumulate the results o" a large num'er o" instructions.
># de"ault it is used "or all mathematical operations and also data trans"er operations 'etween
CPU and an# e)ternal memor#.
The R registers,
The A!A registers are a set o" eight registers that are named !-, !., !2,!3,!0,!&,!(, !<. The
A!A registers are also used to temporaril# store values.
0
(rogr!2 Counter4(C5 :
*-&. has a .(1'it program counter .The program counter alwa#s points to the address o" the ne)t
instruction to 'e e)ecuted. A"ter e)ecution o" one instruction the program counter is incremented
to point to the address o" the ne)t instruction to 'e e)ecuted.It is the contents o" the PC that are
placed on the address 'us to "ind and "etch the desired instruction. ;ince the PC is .(1'it width ,
*-&. can access program addresses "rom ----= to ????=.
$t!c1 (ointer Register 4$(5 :
It is an *1'it register which stores the address o" the stac7 top. i.e the ;tac7 Pointer is used to
indicate where the ne)t value to 'e removed "rom the stac7 should 'e ta7en "rom.
9hen a value is pushed onto the stac7, the *-&. "irst increments the value o" ;P and then stores
the value at the resulting memor# location.
;imilarl# when a value is popped o"" the stac7, the *-&. returns the value "rom the memor#
location indicated '# ;P, and then decrements the value o" ;P.
;P is modi"ied directl# '# the *-&. '# si) instructions, PU;=, POP, ACA33, 3CA33, !+T,
and !+TI.
D!t! (ointer Register4D(TR5 : It is a .(1'it register which is the onl# user1accessi'le.
4PT!, as the name suggests, is used to point to data. It is used '# a num'er o" commands which
allow the *-&. to access e)ternal memor#. 9hen the *-&. accesses e)ternal memor# it will
access e)ternal memor# at the address indicated '# 4PT!. This 4PT! can also 'e used as two
*1registers 4P= and 4P3.
(rogr!2 $t!tus Register 4($65 : The *-&. has a *1'it P;9 register which is also7nown as
?lag register.In the *1'it register onl# (1'its are used '# *-&..The two unused 'its are user
de"ina'le 'its.In the (1'its "our o" them are conditional "lags .The# are Carr# BCC,Au)iliar#
Carr#1AC, Parit#1P,and Over"low1O/ .These "lag 'its indicate some conditions that resulted
a"ter an instruction was e)ecuted.
&
The 'its P;93 and P;90 are denoted as !;- and !;. and these 'its are used th select the
'an7 registers o" the !A location. The meaning o" various 'its o" P;9 register is shown
'elow.
CC P;9.< Carr# ?lag
AC P;9.( Au)iliar# Carr# ?lag
?O P;9.& ?lag - availa'le "or general purpose .
!;. P;9.0 !egister >an7 select 'it .
!;- P;9.3 !egister 'an7 select 'it -
O/ P;9.2 Over"low "lag
111 P;9.. User di"ina'le "lag
P P;9.- Parit# "lag .set/cleared '# hardware.
The selection o" the register >an7s and their addresses are given 'elow.
R$1 R$0 Register .!n1 /""ress
- - - --=1-<=
- . . -*=1-?=
. - 2 .-=1.<=
. . 3 .*=1.?=
(
Me2or7 org!ni8!tion in 8051
The *-&. microcontroller has .2* '#tes o" Internal !A and 0-8( '#tes o" Internal !O .
.% Intern!# R/M O) 8051: The !A is also 7nown as 4ata memor#. The *-&. has onl# .2*
'#tes o" Internal !A 'ut it supports (07> o" e)ternal !A. As the name suggests, e)ternal
!A is an# random access memor# which is o""1chip. ;ince the memor# is o""1chip it is not
as "le)i'le in terms o" accessing, and is also slower. This Internal !A is "ound on1chip on
the *-&. .;o it is the "astest !A availa'le, and it is also the most "le)i'le in terms o"
reading, writing, and modi"#ing it@s contents. Internal !A is volatile, so when the *-&. is
reset this memor# is cleared.
The .2* '#tes o" internal !A is organi2ed as 'elow.
$i% ?our register 'an7s $>an7-, >an7., >an72 and >an73% each o" *1'its $total 32 '#tes%. The
de"ault 'an7 register is >an7-.
$ii% .( '#tes o" 'it addressa'le area and
<
$iii% *- '#tes o" general purpose area as shown in the diagram 'elow.
-5 Intern!# ROM 4On 9chi ROM5:
The !O is 7nown as program memor#. The program memor# is also 7nown as Code
memor# .This Code memor# holds the actual *-&. program that is to 'e e)ecuted.The
*-&. microcontroller has 07> o" on chip !O 'ut it can 'e e)tended up to (07>.
The CO4+ segment is accessed using the program counter $PC% "or opcode "etches and
'# 4PT! "or data. The e)ternal !O is accessed when the +A$active low% pin is
*
connected to ground. 9hen the Internal !O address is e)ceeded the *-&. automaticall#
"etches the code '#tes "rom the e)ternal program memor#.
$(ECI/L )UNCTION RE:I$TER$ 4$)Rs5 :
In *-&. microcontroller there certain registers which uses the !A addresses "rom *-h to ??h
and the# are meant "or certain speci"ic operations .These registers are called ;pecial "unction
registers $;?!s%.;ome o" these registers are 'it addressa'le also.
8
The list o" ;?!s and their "unctional names are given 'elow. In these ;?!s some o" them are
related to I/O ports $P-,P.,P2 and P3% and some o" them are meant "or control operations
$TCOD,;COD, PCOD..% and remaining are the au)illar# ;?!s, in the sense that the# donEt
directl# con"igure the *-&..
$%No $72bo# N!2e o3 $)R
. ACCF Accumulator
2 >F >1!egister
3 P;9F Program ;tatus word register
0 ;P ;tac7 Pointer !egister
&
4PT!
4P3 4ata pointer low '#te
4P= 4ata pointer high '#te
( P-F Port -
P.F Port .
* P2F Port 2
8 P3F Port 3
.- IPF Interrupt Priorit# control
.. I+F Interrupt +na'le control
.2 TO4 Timer mode register
.3 TCODF Timer control register
.0 T=- Timer - =igher '#te
.& T3- Timer - 3ower '#te
.( T=. Timer .=igher '#te
.< T3. Timer . lower '#te
.* ;CODF ;erial control register
.8 ;>U? ;erial 'u""er register
2- PCOD Power control register
The F in"ic!tes the bit !""ress!b#e $)Rs
.-
T!b#e:$)Rs o3 8051 Microcontro##er
(!r!##e# i ;o orts :
The *-&. microcontroller has "our parallel I/O ports , each o" *1'its .;o, it provides the user 32
I/O lines "or connecting the microcontroller to the peripherals. The "our ports are P- $Port -%,
P.$Port.% ,P2$Port 2% and P3 $Port3%. Upon reset all the ports are output ports.
(ORT 0:
Port - is an *1'it I/O port with dual purpose. The *-&. multiple)es address and data lines
through port - to save the pins.
In general these pins are used as input or output. 'ut I" e)ternal memor# is used, these
port pins are used "or the lower address '#te address/data $A4
-
1A4
<.
A3+ indicates whether P- has address or data. 9hen A3+ G -, it provides data 4-14<,
and when A3+ G. it provides address and data.
(ort 1:
Port . occupies a total o" * pins $pins . through *%.
It has no dual application and acts onl# as input or output port.
Upon reset, Port . is con"igured as an output port.
To con"igure it as an input port , port 'its must 'e set i.e a high 'it must 'e sent to all the port
pins.
(ort - :
Port 2 is also an eight 'it parallel port. $pins 2.1 2*%. It can 'e used as input or output port. As
this port is provided with internal pull1up resistors it does not need an# e)ternal pull1up resistors.
Upon reset, Port 2 is con"igured as an output port.
(ORT , , Port3 is also an *1'it parallel port with dual "unction.$ pins .- to .<%. The port pins
can 'e used "or I/O operations as well as "or control operations. The details o" these additional
..
operations are given 'elow in the ta'le. Upon reset port 3 is con"igured as an output port . I" the
port is to 'e used as input port, all the port 'its must 'e made high '# sending ?? to the port.
>its P3.2 and P3.3 are meant "or e)ternal interrupts.
>its P3.0 and P3.& are used "or Timers - and . and P3.( and P3.< are used to provide the write
and read signals o" e)ternal memories connected in *-&. 'ased s#stems
(ort , bit (in No )unction
P3.- .- !)4
P3.. .. T)4
P3.2 .2
P3.3 .3
P3.0 .0 T-
P3.& .& T.
P3.( .(
P3.< .<
T!b#e: (ORT , !#tern!te 3unctions
.2
(IN Di!gr!2 o3 8051 Microcontro##er :
The *-&. microcontroller is availa'le as a 0- pin 4IP chip and it wor7s at H& volts 4C. Among
the 0- pins , a total o" 32 pins are allotted "or the "our parallel ports P-,P.,P2 and P3 i.e each
port occupies *1pins .The remaining pins are /CC, :D4, ITA3., ITA32, !;T, +A
,A3+,P;+D.
.3
<T/L1=<T/L-, These two pins are connected to Juart2 cr#stal oscillator which runs the on1
chip oscillator. The Kuart2 cr#stal oscillator is connected to the two pins along with a capacitor o"
3-p? as shown in the circuit. I" we use a source other than the cr#stal oscillator, it will 'e
connected to ITA3. and ITA32 is le"t unconnected.
.0
R$T, The !+;+T pin is an input pin and it is an active high pin. 9hen a high pulse is applied to
this pin the microcontroller will reset and terminate all activities. Upon reset all the registers
e)cept PC will reset to ---- /alue and PC register will reset to ---< value.
4E>tern!# /ccess5: This pin is an active low pin. This pin is connected to ground when
microcontroller is accessing the program code stored in the e)ternal memor# and connected to
/cc when it is accessing the program code in the on chip memor#. This pin should not 'e le"t
unconnected.
4(rogr!2 $tore En!b#e5 : This is an output pin which is active low. 9hen the
microcontroller is accessing the program code stored in the e)ternal !O ,this pin is connected
to the O+ $Output +na'le% pin o" the !O.
/LE 4/""ress #!tch en!b#e5: This is an output pin, which is active high% 9hen connected to
e)ternal memor# , port - provides 'oth address and data i.e address and data are multiple)ed
through port - .This A3+ pin will demultiple) the address and data 'us .9hen the pin is =igh ,
the A4 'us will act as address 'us otherwise the A4 'us will act as 4ata 'us.
.&
.(

You might also like