You are on page 1of 42

Dr. Y. Narasimha Murthy.Ph.

D
yayavaram@yahoo.com
INTEL 8051 MICRCONTROLLER
Itro!uctio "
A decade back the process and control operations were totally implemented by the
Microprocessors only. But now a days the situation is totally changed and it is occupied by the
new devices called Microcontroller. The development is so drastic that we cant find any
electronic gadget without the use of a microcontroller. This microcontroller changed the
embedded system design so simple and advanced that the embedded market has become one of
the most sought after for not only entrepreneurs but for design engineers also.
What is a Microcontroller?
A single chip computer or A CP with all the peripherals like !AM" !#M" $%# Ports"
Timers " A&Cs etc... on the same chip. 'or e() Motorolas *+,," $ntels +-.," /ilogs /+ and
P$C ,*0 etc1
MICROPROCE##OR# $ MICROCONTROLLER#"
Micro%roc&ssor"
A CP built into a single 234$ chip is called a microprocessor. $t is a general5purpose device
and additional e(ternal circuitry are added to make it a microcomputer. The microprocessor
contains arithmetic and logic unit 6A37" $nstruction decoder and control unit" $nstruction
register" Program counter 6PC7" clock circuit 6internal or e(ternal7" reset circuit 6internal or
e(ternal7 and registers. But the microprocessor has no on chip $%# Ports" Timers " Memory etc.
'or e(ample" $ntel +-+. is an +5bit microprocessor and $ntel +-+*%+-++ a ,*5bit microprocessor.
The block diagram of the Microprocessor is shown in 'ig.,
,
'i(.1 )*oc+ !ia(ram o, a Micro%roc&ssor.
MICROCONTROLLER "
A microcontroller is a highly integrated single chip" which consists of on chip CP 6Central
Processing nit7" !AM 6!andom Access Memory7" 8P!#M%P!#M%!#M 68rasable
Programmable !ead #nly Memory7" $%# 6input%output7 9 serial and parallel" timers" interrupt
controller. 'or e(ample" $ntel +-., is +5bit microcontroller and $ntel +-:* is ,*5bit
microcontroller. The block diagram of Microcontroller is shown in 'ig.;.
;
Fig.2.Block Diagram of a Microcontroller
<
Disti(uish -&t.&& Micro%roc&ssor a! Microcotro**&r
#.No Micro%roc&ssor Microcotro**&r
, A microprocessor is a general
purpose device which is called a
CP
A microcontroller is a dedicated chip which
is also called single chip computer.
; A microprocessor do not contain
onchip $%#Ports" Timers" Memories
etc..
A microcontroller includes !AM" !#M"
serial and parallel interface" timers"
interrupt
circuitry 6in addition to CP7 in a single
chip.
/ Microprocessors are most
commonly used as the CP in
microcomputer systems
Microcontrollers are used in small"
minimum component designs performing
control5oriented applications.
= Microprocessor instructions are
mainly nibble or byte addressable
Microcontroller instructions are both bit
addressable as well as byte addressable.
. Microprocessor instruction sets are
mainly intended for catering to
large volumes of data.
Microcontrollers have instruction sets
catering to the control of inputs and
outputs.
* Microprocessor based system
design is comple( and e(pensive
Microcontroller based system design is
rather simple and cost effective
0 The $nstruction set of
microprocessor is comple( with
large number of instructions.
The instruction set of a Microcontroller is
very simple with less number of
instructions. 'or" e() P$C microcontrollers
have only <. instructions.
+ A microprocessor has >ero status
flag
A microcontroller has no >ero flag.
E1OL2TION O' MICROCONTROLLER# "
=
The first microcontroller TM4,--- was introduced by Te(as $nstrumentsin the year
,:?=. $n the year ,:?*" Motorola designed a Microprocessor chip called *+-, which replaced
its earlier chip *+-- with certain add5on chips to make a computer. This paved the way for the
new revolution in the history of chip design and gave birth to a new entity called
@Microcotro**&r3. 3ater the $ntel company produced its first Microcontroller +-=+ with a
CP and ,A bytes of 8P!#M" *= Bytes of !AM an +5Bit Timer and ;? $%# pins in ,:?*. Then
followed the most popular controller +-., in the year ,:+- with =A bytes of !#M",;+ Bytes of
!AM " a serial port" two ,*5bit Timers " and <; $%# pins. The +-., family has many additions
and improvements over the years and remains a most acclaimed tool for todays circuit
designers. $BT83 introduced a ,* bit microcontroller +-:* in the year ,:+; . 3ater $BT83
introduced +-c,:* series of ,*5bit Microcontrollers for mainly industrial applications.
Microchip" another company has introduced an +5bit Microcontroller P$C ,*C*= in the year
,:+..The <;5bit microcontrollers have been developed by $BM and Motorola. MPC .-. is a <;5
bit !$4C controller of Motorola. The =-< CA is a <; 5bit !$4C embedded controller of $BM.
$n recent times A!M company 6Advanced !$4C machines7 has developed and introduced <; bit
controllers for high5end application devices like mobiles " $pods etc...
TYPE# O' MICROCONTROLLER# "
Microcontrollers can be classified on the basis of internal bus width" architecture" memory and
instruction set as =5bit"+5bit",*5bit and <;5bit micrcontrollers.
45-it Microcotro**&rs) These =5bit microcontrollers are small si>e" minimum pin count and
low cost controllers which are widely used for low end applications like 38& D 3C& display
drivers "portable battery chargers etc.. Their power consumption is also low. The popular =5bit
controllers are !enasa M<=.-, which is a ;- pin &$P chip with =kB of !#M";.* Bytes of
!AM";5Counters and ,= $%# Pins. 4imilarly ATAM+*; series from ATM83.
85-it Microcotro**&rs " These are the most popular and widely used microcontrollers .About
..E of all CPs sold in the world are +5bit microcontrollers only.The +5bit microcontroller has
+5bitinternal bus and the A3 performs all the arithmetic and logical operations on a byte
instruction. The well known +5bit microcontroller is +-., which was designed by $ntel in the
year ,:+- for the use in embedded systems. #ther +5bit microcontrollers are $ntel +-<,%+-.; and
.
Motorola MC*+FC,, and A2! Microcontrollers" Microchips P$C Microcontrollers ,;C.00 "
,*C.0 and ,*C.-. etc...
165-it Microcotro**&rs " Ghen the microcontroller performs ,*5bit arithmetic and logical
operations at an instruction" the microcontroller is said to be a ,*5bit microcontroller. The
internal bus width of ,*5bit microcontroller is of ,*5bit. These microcontrollers are having
increased memory si>e and speed of operation when compared to +5bit microcontrollers.These
are most suitable for programming in Fighlevel languages like C or C
HH
.They find applications
in disk drivers"modems"printers"scanners and servomotor control. 8(amples of ,*5bit
microcontrollers are $ntel +-:* family and Motorola MC*+FC,; and MC*+<<; families" The
performance and computing capability of ,* bit microcontrollers are enhanced with greater
precision as compared to the +5bit microcontrollers.
/75)it Microcotro**&rs "These microcontrollers used in highend applications like Automative
control" Communication networks"!obotics"Cell phones "CP!4 D P&As etc..'or
80)P$C<;"A!M ?"A!M: "4FA!P 3F?:.;- "ATM83 <; 6A2!7 "Te(as $nstruments 9.
TM4<;-';+-;(%;+-<( etc..are some of the popular <;5bit microcontrollers.
COMMERCI8L MICROCONTROLLER#
There are various manufacturers who are supplying various types of microcontrollers suitable
for different applications depending on the power consumption and the available features..They
are given below in tables . 'irst the various members of $BT83 ., family are given in below
table.
INTEL MC# 51 'ami*y
Microcotro**&r O chi% R8M
9)yt&s:
O chi% %ro(ram
m&mory
Tim&rs;Cout&rs It&rru%ts #&ria* %orts
+-<, ,;+ Bone ; . ,
+-<; ;.* Bone < * ,
+-., ,;+ =A !#M ; . ,
+-.; ;.* +A !#M < * ,
+?., ,;+ =A 8P!#M ; . ,
*
+?.; ;.* +A 8P!#M < * ,
The following table gives the =5bit microcontrollers from different manufacturers.
45)it Microcotro**&rs.
85)it Microcotro**&rs.
?
165)it Microcotro**&rs
The following table gives the list of P$C microcontrollers from Micro chip $nc
Microcontroller Pins $%# 3ines #n chip A&Cs 8P!#M
0 ,; words
#n chip !AM
6Bytes7
,*C.= ,+ ,; Bone .,; ;.
,*C.. ;+ ;- Bone .,; ;=
,*C.* ,+ ,; Bone ,k ;.
,*C.? ;+ ;- Bone ;k ?;
,?C=;A =- << Bone ;k ;<;
,?C=< =- << Bone =k =.=
,?C== =- << Bone +k =.=
,?C?, ,+ ,< +bit A&Cs ,k(,= <*
,?C?.; =- << ,-Bit A&C +k(,* *?+
MICROCONTROLLER DE1ELOPMENT TOOL#"
To develop an assembly language program we need certain program development tools.
An assembly language program consists of Mnemonics which are nothing but short abbreviated
+
8nglish instructions given to the controller.The various development tools reIuired for
Microcontroller programming are e(plained below.
1. E!itor " An 8ditor is a program which allows us to create a file containing the assembly
language statements for the program. 8(amples of some editors are PC write Gordstar. As we
type the program the editor stores the AC4$$ codes for the letters and numbers in successive
!AM locations. $f any typing mistake is done editor will alert us to correct it. $f we leave out a
program statement an editor will let you move everything down and insert a line. After typing all
the program we have to save the program . This we call it as source file. The ne(t step is to
process the source file with an assembler.
8() 4ample. asm
7.8ss&m-*&r " An Assembler is used to translate the assembly language mnemonics into
machine language6 i.e binary codes7. Ghen you run the assembler it reads the source file of your
program from where you have saved it. The assembler generates a filee with the e(tension .h&<.
This file consists of he(adecimal values encoding a seIuence of data and their starting offset or
absolute address.
/.Com%i*&r " A compiler is a program which converts the high level language program like @CJ
into binary or machine code. sing high level languages it is easy to manage comple( data
structures which are often reIuired for data manipulation. Because of its ease " fle(ibility and
debug options now a days the compilers have become very popular in the market. Compilers
like Aeil "!ide and $A! workbench are very popular.
/. D&-u((&r;#imu*ator " A debugger is a program which allows e(ecute the program" and
troubleshoot or debug it. The debugger allows to look into the contents of registers and memory
locations after the program runs. Ge can also change the contents of registers and memory
locations and rerun the program. 4ome debuggers allows to stop the program after each
instruction so that you can check or alter memory and register contents. This is called single step
debug. A debugger also allows to set a breakpoint at any point in the program. $f we insert a
break point " the debugger will run the program up to the instruction where the breakpoint is put
and then stop the e(ecution.
:
A simulator is a software program which virtually e(ecutes the instructions similar to a
microcontroller and shows the results. This will help in evaluating the results without committing
any errors. By doing so we can detect the possible logic errors
INTEL 8051 MICRCONTROLLER "
The +-., microcontroller is a very popular +5bit microcontroller introduced by $ntel in
the year ,:+, and it has become almost the academic standard now a days. The +-., is based on
an +5bit C$4C core with Farvard architecture. $ts +5bit architecture is optimi>ed for control
applications with e(tensive Boolean processing. $t is available as a =-5pin &$P chip and works at
H. 2olts &C. The salient features of +-., controller are given below.
#8LIENT 'E8T2RE# " The salient features of +-., Microcontroller are
i. = AB on chip program memory 6!#M or 8P!#M77.
ii. ,;+ bytes on chip data memory6!AM7.
iii. +5bit data bus
iv. ,*5bit address bus
v. <; general purpose registers each of + bits
vi. Two 5,* bit timers T- and T,
vii. 'ive $nterrupts 6< internal and ; e(ternal7.
i(. 'our Parallel ports each of +5bits 6P#!T-" P#!T,"P#!T;"P#!T<7 with a total of <; $%#
lines.
(. #ne ,*5bit program counter and #ne ,*5bit &PT! 6 data pointer7
(i. #ne +5bit stack pointer
(ii. #ne Microsecond instruction cycle with ,; MF> Crystal.
(iii. #ne full duple( serial communication port.
8RC=ITECT2RE $ )LOC> DI8?R8M O' 8051 MICROCONTROLLER"
,-
The architecture of the +-., microcontroller can be understood from the block diagram.
$t has Farward architecture with !$4C 6!educed $nstruction 4et Computer7 concept. The block
diagram of +-., microcontroller is shown in 'ig <. below,.$t consists of an +5bit A3" one +5
bit P4G6Program 4tatus !egister7" A and B registers " one ,*5bit Program counter " one ,*5bit
&ata pointer register6&PT!7",;+ bytes of !AM and =kB of !#M and four parallel $%# ports
each of +5bit width.
'i(./. )*oc+ Dia(ram o, 8051 Microcotro**&r
+-., has +5bit A3 which can perform all the +5bit arithmetic and logical operations in one
machine cycle. The A3 is associated with two registers A D B
8 a! ) R&(ist&rs ) The A and B registers are special function registers which hold the results
of many arithmetic and logical operations of +-.,.The A register is also called the 8ccumu*ator
and as its name suggests" is used as a general register to accumulate the results of a large
number of instructions. By default it is used for all mathematical operations and also data
transfer operations between CP and any e(ternal memory.
,,
The B register is mainly used for multiplication and division operations along with A register.
M3 AB ) &$2 AB.
$t has no other function other than as a location where data may be stored.
Th& R r&(ist&rs) The K!K registers are a set of eight registers that are named !-" !," etc. up to
and including !?. These registers are used as au(illary registers in many operations. The K!K
registers are also used to temporarily store values.
Pro(ram Cout&r9PC: " +-., has a ,*5bit program counter .The program counter always points
to the address of the ne(t instruction to be e(ecuted. After e(ecution of one instruction the
program counter is incremented to point to the address of the ne(t instruction to be e(ecuted.$t is
the contents of the PC that are placed on the address bus to find and fetch the desired
instruction.4ince the PC is ,*5bit width "+-., can access program addresses from ----F to
''''F "a total of *kB of code.
#tac+ Poit&r R&(ist&r 9#P: " $t is an +5bit register which stores the address of the stack top. i.e
the 4tack Pointer is used to indicate where the ne(t value to be removed from the stack should
be taken from. Ghen a value is pushed onto the stack" the +-., first increments the value of 4P
and then stores the value at the resulting memory location. 4imilarly when a value is popped off
the stack" the +-., returns the value from the memory location indicated by 4P" and then
decrements the value of 4P. 4ince the 4P is only +5bit wide it is incremented or decremented by
two . 4P is modified directly by the +-., by si( instructions) P4F" P#P" ACA33" 3CA33"
!8T" and !8T$. $t is also used intrinsically whenever an interrupt is triggered.
#T8C> i 8051 Microcotro**&r " The stack is a part of !AM used by the CP to store
information temporarily. This information may be either data or an address .The CP needs this
storage area as there are only limited number of registers. The register used to access the stack is
called the 4tack pointer which is an +5bit register..4o"it can take values of -- to '' F.Ghen the
+-., is powered up "the 4P register contains the value -?.i.e the !AM location value -+ is the
first location being used for the stack by the +-., controller
,;
There are two important instructions to handle this stack.#ne is the P4F and the #ther
is the P#P. The loading of data from CP registers to the stack is done by P4F and the
loading of the contents of the stack back into aCP register is done by P#P.
80 ) M#2 !* "L<. F
M#2 !, "L;, F
P4F *
P4F ,
$n the above instructions the contents of the !egisters !* and !, are moved to stack and
they occupy the -+ and -: locations of the stack.Bow the contents of the 4P are incremented by
two and it is -A
4imilarly P#P < instruction pops the contents of stack into !< register.Bow the contents of the
4P is decremented by ,
$n +-., the !AM locations -+ to ,' 6;= bytes7 can be used for the 4tack.$n any program if we
need more than ;= bytes of stack "we can change the 4P point to !AM locations <-5?' F.this
can be done with the instruction M#2 4P"L 00.
Data Poit&r R&(ist&r9DPTR: " $t is a ,*5bit register which is the only user5accessible.
&PT!" as the name suggests" is used to point to data. $t is used by a number of commands which
allow the +-., to access e(ternal memory. Ghen the +-., accesses e(ternal memory it will
access e(ternal memory at the address indicated by &PT!. This &PT! can also be used as two
+5registers &PF and &P3.
Pro(ram #tatus R&(ist&r 9P#@: " The +-., has a +5bit P4G register which is alsoknown as
'lag register.$n the +5bit register only *5bits are used by +-.,.The two unused bits are user
definable bits.$n the *5bits four of them are conditional flags .They are Carry 9CM"Au(iliary
Carry5AC" Parity5P"and #verflow5#2 .These flag bits indicate some conditions that resulted
after an instruction was e(ecuted.
,<
The bits P4G< and P4G= are denoted as !4- and !4, and these bits are used th select the
bank registers of the !AM location. The meaning of various bits of P4G register is shown
below.
CM P4G.? Carry 'lag
AC P4G.* Au(iliary Carry 'lag
'# P4G.. 'lag - available for general purpose .
!4, P4G.= !egister Bank select bit ,
!4- P4G.< !egister bank select bit -
#2 P4G.; #verflow flag
555 P4G., ser difinable flag
P P4G.- Parity flag .set%cleared by hardware.
The selection of the register Banks and their addresses are given below.
R#1 R#0 R&(ist&r )a+ 8!!r&ss
- - - --F5-?F
- , , -+F5-'F
, - ; ,-F5,?F
, , < ,+F5,'F
M&mory or(aiAatio " The +-., microcontroller has ,;+ bytes of $nternal !AM and =kB of
on chip !#M .The !AM is also known as &ata memory and the !#M is known as program
memory. The program memory is also known as Code memory .This Code memory holds the
actual +-., program that is to be e(ecuted. $n +-., this memory is limited to *=A .Code
memory may be found on5chip" as !#M or 8P!#M. $t may also be stored completely off5chip
in an e(ternal !#M or" more commonly" an e(ternal 8P!#M. The +-., has only ,;+ bytes of
$nternal !AM but it supports *=kB of e(ternal !AM. As the name suggests" e(ternal !AM is
any random access memory which is off5chip. 4ince the memory is off5chip it is not as fle(ible
interms of accessing" and is also slower. 'or e(ample" to increment an $nternal !AM location by
,=
,"it reIuires only , instruction and , instruction cycle but to increment a ,5byte value stored in
8(ternal !AM reIuires = instructions and ? instruction cycles. 4o" here the e(ternal memory is
? times slower.
It&ra* R8M O' 8051 "
This $nternal !AM is found on5chip on the +-., .4o it is the fastest !AM available" and it is also
the most fle(ible in terms of reading" writing" and modifying its contents. $nternal !AM is
volatile" so when the +-., is reset this memory is cleared. The ,;+ bytes of internal !AM is
organi>ed as below.
6i7 'our register banks 6Bank-"Bank," Bank; and Bank<7 each of +5bits 6total <; bytes7. The
default bank register is Bank-. The remaining Banks are selected with the help of !4- and
!4, bits of P4G !egister.
6ii7 ,* bytes of bit addressable area and
6iii7 +- bytes of general purpose area 64cratch pad memory7 as shown in the diagram below.
This area is also utili>ed by the microcontroller as a storage area for the operating stack.
,.
The <; bytes of !AM from address -- F to ,'F are used as working registers organi>ed as four
banks of eight registers each.The registers are named as !-5!? .8ach register can be addressed
by its name or by its !AM address.
'or 80 ) M#2 A" !? or M#2 !?"L-.F
It&ra* ROM 9O Bchi% ROM:" The +-., microcontroller has =kB of on chip !#M but it
can be e(tended up to *=kB.This !#M is also called program memory or code memory. The
C#&8 segment is accessed using the program counter 6PC7 for opcode fetches and by &PT!
for data. The e(ternal !#M is accessed when the 8A6active low7 pin is connected to ground or
,*
the contents of program counter e(ceeds -'''F.Ghen the $nternal !#M address is e(ceeded the
+-., automatically fetches the code bytes from the e(ternal program memory.
#PECI8L '2NCTION RE?I#TER# 9#'Rs: " $n +-., microcontroller there certain registers
which uses the !AM addresses from +-h to ''h and they are meant for certain specific
operations .These registers are called 4pecial function registers 64'!s7.4ome of these registers
are bit addressable also.
The list of 4'!s and their functional names are given below. $n these 4'!s some of them are
related to $%# ports 6P-"P,"P; and P<7 and some of them are meant for control operations
6TC#B"4C#B" PC#B..7 and remaining are the au(illary 4'!s" in the sense that they donNt
directly configure the +-.,.
,?
#.No #ym-o* Nam& o, #'R 8!!r&ss 9=&<:
, ACCO Accumulator 0E0
; BO B5!egister 0'0
< P4GO Program 4tatus word register 0DO
= 4P 4tack Pointer !egister 81
.
&PT!
&P3 &ata pointer low byte 87
&PF &ata pointer high byte 8/
* P-O Port - 80
P,O Port , C0
+ P;O Port ; 08
: P<O Port < 0)
,- $PO $nterrupt Priority control 0)8
,, $8O $nterrupt 8nable control 088
,; TM#& Tmier mode register 8C
,< TC#BO Timer control register 88
,= TF- Timer - Figher byte 8C
,. T3- Timer - 3ower byte 88
,* TF, Timer ,Figher byte 8D
,? T3, Timer , lower byte 8)
,+ 4C#BO 4erial control register C8
,: 4B' 4erial buffer register CC
;- PC#B Power control register 80
Th& O i!icat&s th& -it a!!r&ssa-*& #'Rs
Ta-*&"#'Rs o, 8051 Microcotro**&r
P8R8LLEL I ;O PORT# :
,+
The +-., microcontroller has four parallel $%# ports " each of +5bits .4o" it provides the user <;
$%# lines for connecting the microcontroller to the peripherals. The four ports are P- 6Port -7"
P,6Port,7 "P;6Port ;7 and P< 6Port<7. pon reset all the ports are output ports. $n order to make
them input" all the ports must be set i.e a high bit must be sent to all the port pins. This is
normally done by the instruction @48TBJ.
8() M#2 A"L-''F P A Q ''
M#2 P-"A P make P- an input port
PORT 0"
Port - is an +5bit $%# port with dual purpose. $f e(ternal memory is used" these port pins are used
for the lower address byte address%data 6A&-5A&?7" otherwise all bits of the port are either input
or output.. nlike other ports" Port - is not provided with pull5up resistors internally "so for
P#!T- pull5up resistors of nearly ,-k are to be connected e(ternally as shown in the fig.;.
Dua* ro*& o, %ort 0) Port - can also be used as address%data bus6A&-5A&?7" allowing it to be
used for both address and data. Ghen connecting the +-., to an e(ternal memory" port -
provides both address and data. The +-., multiple(es address and data through port - to save the
pins. A38 indicates whether P- has address or data. Ghen A38 Q -" it provides data &-5&?" and
when A38 Q, it provides address and data with the help of a ?=34<?< latch.
Port 1" Port , occupies a total of + pins 6pins , through +7. $t has no dual application and acts
only as input or output port. $n contrast to port -" this port does not need any pull5up resistors
,:
since pull5up resistors connected internally. pon reset" Port , is configured as an output port.
To configure it as an input port " port bits must be set i.e a high bit must be sent to all the port
pins. This is normally done by the instruction @48TBJ. 'or 8( )
M#2 A" L-''F P AQ'' F80
M#2 P,"A P make P, an input port by writing ,s to all of its pins
Port 7 " Port ; is also an eight bit parallel port. 6pins ;,5 ;+7. $t can be used as input or output
port. As this port is provided with internal pull5up resistors it does not need any e(ternal pull5up
resistors. pon reset" Port ; is configured as an output port. $f the port is to be used as input port"
all the port bits must be made high by sending '' to the port. 'or e("
M#2 A" L-''F P AQ'' he(
M#2 P;" A P make P; an input port by writing all ,s to it
Dua* ro*& o, %ort 7 ) Port; lines are also associated with the higher order address lines A+5A,..
$n systems based on the +?.," +:.," and &4.---" Port; is used as simple $%# port.. But" in +-<,5
based systems" port ; is used along with P- to provide the ,*5bit address for the e(ternal
memory. 4ince an +-<, is capable of accessing *=A bytes of e(ternal memory" it needs a path for
the ,* bits of the address. Ghile P- provides the lower + bits via A-5A?" it is the Rob of P; to
provide bits A+5A,. of the address. $n other words" when +-<, is connected to e(ternal memory"
Port ; is used for the upper + bits of the ,* bit address" and it cannot be used for $%# operations.
PORT / ) Port< is also an +5bit parallel port with dual function.6 pins ,- to ,?7. The port pins
can be used for $%# operations as well as for control operations. The details of these
additional operations are given below in the table. Port < also do not need any e(ternal pull5up
resistors as they are provided internally similar to the case of Port; D Port ,. pon reset port <
is configured as an output port . $f the port is to be used as input port" all the port bits must be
made high by sending '' to the port. 'or e("
M#2 A" L-''F P AQ '' he(
M#2 P<" A P make P< an input port by writing all ,s to it
8*t&rat& 'uctios o, Port / " P<.- and P<., are used for the !(& 6!eceive &ata7 and T(&
6Transmit &ata7 serial communications signals. Bits P<.; and P<.< are meant for e(ternal
;-
interrupts. Bits P<.= and P<.. are used for Timers - and , and P<.* and P<.? are used to provide
the write and read signals of e(ternal memories connected in +-<, based systems
#.No Port / -it Pi No 'uctio
, P<.- ,- !(&
; P<., ,, T(&
< P<.; ,;
= P<.< ,<
. P<.= ,= T-
* P<.. ,. T,
? P<.* ,*
+ P<.? ,?
Ta-*&" PORT / a*t&rat& ,uctios
It&rru%t #tructur&)

An interrupt is an e(ternal or internal event that disturbs the
microcontroller to inform it that a device needs its service. The program which is associated with
the interrupt is called the it&rru%t s&rvic& routi& 6$4!7 or it&rru%t ha!*&r. pon receiving
the interrupt signal the Microcontroller " finish current instruction and saves the PC on stack.
Sumps to a fi(ed location in memory depending on type of interrupt 4tarts to e(ecute the
interrupt service routine until !8T$ 6return from interrupt7pon e(ecuting the !8T$ the
microcontroller returns to the place where it was interrupted. Cet pop PC from stack
The +-., microcontroller has 'I1E interrupts in addition to !eset. They are
Timer - overflow $nterrupt
Timer , overflow $nterrupt
8(ternal $nterrupt -6$BT-7
8(ternal $nterrupt ,6$BT,7
4erial Port events 6buffer full" buffer empty" etc7 $nterrupt
;,
8ach interrupt has a specific place in code memory where program e(ecution 6interrupt service
routine7 begins.
8(ternal $nterrupt -) ---< F
Timer - overflow) ---B F
8(ternal $nterrupt ,) --,< F
Timer , overflow) --,B F
4erial $nterrupt ) --;< F
pon reset all $nterrupts are disabled D do not respond to the Microcontroller. These interrupts
must be enabled by software in order for the Microcontroller to respond to them. This is done by
an +5bit register called $nterrupt 8nable !egister 6$87.
It&rru%t Ea-*& R&(ist&r "
8A ) Clobal enable%disable. To enable the interrupts this bit must be set Figh.
555 ) ndefined5reserved for future use.
8T; ) 8nable %disable Timer ; overflow interrupt.
84 ) 8nable%disable 4erial port interrupt.
8T, ) 8nable %disable Timer , overflow interrupt.
80, ) 8nable%disable 8(ternal interrupt,.
8T- ) 8nable %disable Timer - overflow interrupt.
80- ) 8nable%disable 8(ternal interrupt-
pon reset the interrupts have the following priority.6Top to down7.

The interrupt with the
highest P!$#!$TM gets serviced first.
,. 8(ternal interrupt - 6$BT-7
;;
;. Timer interrupt- 6T'-7
<. 8(ternal interrupt , 6$BT,7
=. Timer interrupt, 6T',7
.. 4erial communication 6!$HT$7
Priority can also be set to @highJ or @lowJ by +5bit $P register.5 $nterrupt priority register
IP.7: reserved
$P.*) reserved
$P..) Timer ; interrupt priority bit 6+-.; only7
$P.=) 4erial port interrupt priority bit
$P.<) Timer , interrupt priority bit
$P.;) 8(ternal interrupt , priority bit
$P.,) Timser - interrupt priority bit
$P.-) 8(ternal interrupt - priority bit
TIMER# i 8051 Microcotro**&rs " The +-., microcontroller has two ,*5bit timers
Timer - 6T-7 and Timer ,6T,7 which can be used either to generate accurate time delays or as
event counters. These timers are accessed as two +5bit registers T3#" TF# D T3, "TF,
because the +-., microcontroller has +5bit architecture.
TIMER 0 " The Timer - is a ,*5bit register and can be treated as two +5bit registers 6T3- D
TF-7 and these registers can be accessed similar to any other registers like A"B or !,"!;"!<
etc1
8( ) The instruction Mov T3-"L-? moves the value -? into lower byte of Timer-.
4imilarly Mov !."TF- saves the contents of TF- in the !. register.
;<
TIMER 1 " The Timer , is also a ,*5bit register and can be treated as two +5bit registers 6T3, D
TF,7 and these registers can be accessed similar to any other registers like A"B or !,"!;"!<
etc1
8( ) The instruction M#2 T3,"L-. moves the value -. into lower byte of Timer,.
4imilarly M#2 !-"TF, saves the contents of TF, in the !- register
TMOD R&(ist&r " The various operating modes of both the timers T- and T, are set by an +5bit
register called TM#& register. $n this TM#& register the lower =5bits are meant for Timer - and
the higher =5bits are meant for Timer,.
?8TE) This bit is used to start or stop the timers by hardware .Ghen CAT8Q , "the timers can
be started % stopped by the e(ternal sources. Ghen CAT8Q -" the timers can be started or stopped
by software instructions like 48TB T!- or 48TB T!,
C;T 9c*oc+;Tim&r: " This bit decides whether the timer is used as delay generator or event
counter. Ghen C;T D 0 Ethe Timer is used as delay generator and if C%TQ, the timer is used as
an event counter. The clock source for the time delay is the crystal freIuency of +-.,.
;=
M1EM0 9Mo!&: " These two bits are the timer mode bits. The timers of the +-., can be
configured in three modes.Mode-" Mode, and Mode;.The selection and operation of the modes
is shown below.
#.No M0 M1 Mo!& O%&ratio
, - - - ,<5bit Timer mode
+5bit Timer%counter. TF( with T3( as .5bit
prescalar
; - , , ,*5bit Timer mode.,*5bit timer %counter
without pre5scalar
< , - ; +5bit auto reload. TF( contains a value that
is to be loaded into T3( each time it
overflows
= , , < 4plit timer mode
PIN Dia(ram o, 8051 Microcotro**&r " The +-., microcontroller is available as a =- pin &$P
chip and it works at H. volts &C. Among the =- pins " a total of <; pins are allotted for the four
parallel ports P-"P,"P; and P< i.e each port occupies +5pins .The remaining pins are 2CC"
CB&" 0TA3," 0TA3;" !4T" 8A "P48B.
FT8L1EFT8L7) These two pins are connected to Tuart> crystal oscillator which runs the on5
chip oscillator. The Iuart> crystal oscillator is connected to the two pins along with a capacitor of
<-p' as shown in the circuit. $f we use a source other than the crystal oscillator" it will be
connected to 0TA3, and 0TA3; is left unconnected.
;.
R#T) The !848T pin is an input pin and it is an active high pin. Ghen a high pulse is applied to
this pin the microcontroller will reset and terminate all activities. pon reset all the registers
e(cept PC will reset to ---- 2alue and PC register will reset to ---? value.
9E<t&ra* 8cc&ss:" 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 memory and connected to
2cc when it is accessing the program code in the on chip memory. This pin should not be left
unconnected.
9Pro(ram #tor& Ea-*&: " This is an output pin which is active low. Ghen the
microcontroller is accessing the program code stored in the e(ternal !#M "this pin is connected
to the #8 6#utput 8nable7 pin of the !#M.
;*
8LE 98!!r&ss *atch &a-*&:" This is an output pin" which is active high. Ghen connected to
e(ternal memory " port - provides both address and data i.e address and data are multiple(ed
through port - .This A38 pin will demultiple( the address and data bus .Ghen the pin is Figh "
the A& bus will act as address bus otherwise the A& bus will act as &ata bus.
P0.05 P0.098D058D0: " The port - pins multiple(ed with Address%data pins .$f the
microcontroller is accessing e(ternal memory these pins will act as address%data pins otherwise
they are used for Port - pins.
P7.05 P7.09885815: " The port; pins are multiple(ed with the higher order address pins .Ghen
the microcontroller is accessing e(ternal memory these pins provide the higher order address
byte otherwise they act as Port ; pins.
P1.05 P1.0 "These +5pins are dedicated for Port, to perform input or output port operations.
P/.05 P/.0 "These +5pins are meant for Port< operations and also for some control operations
like !ead"Grite"Timer-"Timer, "$BT-"$BT, "!(& and T(&
8DDRE##IN? MODE# O' 8051 "
The way in which the data operands are accessed by different instructions is known as the
addressing modes. There are various methods of denoting the data operands in the instruction.
The +-., microcontroller supports mainly . addressing modes. They are
,.$mmediate addressing mode
;.&irect Addressing mode
<.!egister addressing mode
=. !egister $ndirect addressing mode
..$nde(ed addressing mode
Imm&!iat& a!!r&ssi( mo!& " The addressing mode in which the data operand is a constant and
it is a part of the instruction itself is known as $mmediate addressing mode. Bormally the data
must be preceded by a L sign. This addressing mode can be used to transfer the data into any of
the registers including &PT!.
;?
8() M#2 A " L ;? F ) The data 6constant7 ;? is moved to the accumulator register
A&& !, "L=. F ) Add the constant =. to the contents of the accumulator
M#2 &PT! "L +;=.F )Move the data +;=. into the data pointer register.
M#2 P,"L;, F
Dir&ct a!!r&ssi( mo!&) The addressing mode in which the data operand is in the !AM
location 6-- 5?'F7 and the address of the data operand is given in the instruction is known as
&irect addressing mode. The direct addressing mode uses the lower ,;+ bytes of $nternal !AM
and the 4'!s
M#2 !," =;F ) Move the contents of !AM location =; into !, register
M#2 =:F"A ) Move the contents of the accumulator into the !AM location =:.
A&& A" .*F ) Add the contents of the !AM location .* to the accumulator
R&(ist&r a!!r&ssi( mo!& )The addressing mode in which the data operand to be manipulated
lies in one of the registers is known as register addressing mode.
M#2 A"!- ) Move the contents of the register !- to the accumulator
A&& A"!* )Add the contents of !* register to the accumulator
M#2 P," !; ) Move the contents of the !; register into port ,
M#2 !." !; ) This is invalid .The data transfer between the registers is not allowed.
R&(ist&r I!ir&ct a!!r&ssi( mo!& "The addressing mode in which a register is used as a
pointer to the data memory block is known as !egister indirect addressing mode.
M#2 A"U !- )Move the contents of !AM location whose address is in !- into 8
6accumulator7
M#2 U !, " B ) Move the contents of B into !AM location whose address is held by !,
Ghen !- and !, are used as pointers" they must be preceded by U sign
;+
O& o, th& a!vata(&s o, r&(ist&r i!ir&ct a!!r&ssi( mo!& is that it ma+&s acc&ssi( th&
!ata mor& !yamic tha static as i th& cas& o, !ir&ct a!!r&ssi( mo!&.
I!&<&! a!!r&ssi( mo!& " This addressing mode is used in accessing the data elements of
lookup table entries located in program !#M space of +-.,.
8( ) M#2C A"U AH&PT!
The ,*5bit register &PT! and register A are used to form the address of the data element stored
in on5chip !#M. Fere C denotes code .$n this instruction the contents of A are added to the ,*5
bit &PT! register to form the ,*5bit address of the data operand.
It&r,aci( o, 8DC 0804 to 8051 Microcotro**&r "
A&C -+-= is a single channel analog to digital converter i.e." it can take only one analog
signal. A&C -+-= has + bit resolution. The higher resolution A&C gives smaller step si>e. 4tep
si>e is smallest change that can be measured by an A&C. 'or an A&C with resolution of + bits"
the step si>e is ,:..<m2 6.2%;..7. The time taken by the A&C to convert analog data into
digital form depends on the freIuency of clock source. The conversion time of A&C -+-= is
around ,,-us. To use the internal clock a capacitor and resistor are used as shown in the circuit.
The input to the A&C is given from a regulated power supply and a ,-A potentiometer
The 8051 Microcontroller is used to provide the control signals to the ADC. C!chip
select" pin o# ADC is directl$ connected to ground. The pin P1.1% P1.0 and P1.& are
connected to the pin '(% (D and I)T( o# the ADC respectivel$. 'hen the input
voltage #ro* the preset is varied the output o# ADC varies also varies.
;:
'rom the circuit it is clear that the A&C interfaced directly to the microcontroller. The Port, is
used as an input port which receives the digital data from the A&C.Port pins P;.. and P;.* are
used for 4#C and 8#C operation.Ghen the conversion is over the A&C will send an interrupt
signal to the microcontroller through the pin P;.? .Bow the Microcontroller receives digital data
through the Port,.This data after conversion to decimal data is displayed on the 3C& module .
The assembly language program for A&C is given below .
M#2 P, " -'' F P Make the port, high and configure port, as $nput port
)8C>) C3! P;.* P Ceneration of 4#C pulse
48TB P;.. P
LOOP SB P;.? " 3##P P Gait for conversion" $s conversion overV
C3! P;.. P 8nable !ead the digital data
<-
M#2 A "P, P !ead digital data through Port,
48TB P;.. P &isable read after read operation
CA33 &$4P3AM P &isplay the data on 3C& module
4SMP BACA P Continue the conversion process
#t&%%&r motor It&r,aci(
A stepper motor is a device that translates electrical pulses into mechanical movement. The
stepper motor rotates in steps in response to the applied signals. $t is used in applications such as
disk drives" dot matri( printers" plotters and robotics.$t is mainly used for position control.
4tepper motors have a permanent magnet called rotor 6also called the shaft7 surrounded by a
stator . There are also steppers called variable reluctance stepper motors that do not have a PM
rotor. The most common stepper motors have four stator windings that are paired with a center5
tapped. This type of stepper motor is commonly referred to as a. four5phase or unipolar stepper
motor. The center tap allows a change of current direction in each of two coils when a winding is
grounded" thereby resulting in a polarity change of the stator.
<,
8##EM)LY L8N?28?E PRO?R8M
Main mov stepper" L-CF P move the code to phase, into the port
acall delay
mov stepper" L-*F P phase $$ code
acall delay
mov stepper" L-<F PPhase $$$ code
acall delay PCall delay subroutine program
mov stepper" L-:F PPhase $2 code
acall delay
sRmp Main
CA33 &83AM P!#C!AM )
mov r?"L=
wait;)
mov r*"L-''F
wait,)
mov r."L-''F
wait)
dRn> r."wait
dRn> r*"wait,
dRn> r?"wait;
ret
end

<;
80515#ERI8L COMM2NIC8TION "
)asics o, #&ria* commuicatio
&ata transfer between two electronic devices 68( Between a computer and microcontroller or a
peripheral device7 is generally done in two ways
6i7.4erial data Transfer and
6ii7.Parallel data Transfer
4erial communication uses only one or two data lines to transfer data and is generally used for
long distance communication. $n serial communication the data is sent as one bit at a time in a
timed seIuence on a single wire. 4erial Communication takes place in two methods"
Asynchronous data Transfer and 4ynchronous data Transfer.
#&ria* Data Tras,&r
8sychroous !ata tras,&r allows data to be transmitted without the sender having to send a
clock signal to the receiver. $nstead" special bits will be added to each word in order to
synchroni>e the sending and receiving of the data. Ghen a word is given to the A!T for
Asynchronous transmissions" a bit called the K4tart BitK is added to the beginning of each word
that is to be transmitted. The 4tart Bit is used to alert the receiver that a word of data is about to
be sent" and to force the clock in the receiver into synchroni>ation with the clock in the
transmitter.
<<
#&ria* !ata trasmissio

After the 4tart Bit" the individual bits of the word of data are sent .Fere each bit in the word is
transmitted for e(actly the same amount of time as all of the other bits. Ghen the entire data
word has been sent" the transmitter may add a Parity Bit that the transmitter generates. The Parity
bit may be used by the receiver to perform simple error checking. Then at least one 4top Bit is
sent by the transmitter. $f the 4top Bit does not appear when it is supposed to" the A!T
considers the entire word to be corrupted and will report a 'raming 8rror.
Baud rate is a measurement of transmission speed in asynchronous communication " it represents
the number of bits%sec that are actually being sent over the serial link. The Baud count includes
the overhead bits 4tart" 4top and Parity that are generated by the sending A!T and removed by
the receiving A!T.
$n the #ychroous !ata tras,&r method the receiver knows when to @readJ the ne(t bit
coming from the sender. This is achieved by sharing a clock between sender and receiver. $n
most forms of serial 4ynchronous communication" if there is no data available at a given time to
transmit" a fill character will be sent instead so that data is always being transmitted.
4ynchronous communication is usually more efficient because only data bits are transmitted
between sender and receiver" however it will be more costly because e(tra wiring and control
circuits are reIuired to share a clock signal between the sender and receiver.
&evices that use serial cables for their communication are split into two categories.
,. &T8 6&ata Terminal 8Iuipment7. 8(amples of &T8 are computers" printers D terminals.
;. &C8 6&ata Communication 8Iuipment7. 8(ample of &C8 is modems.
Para**&* Data Tras,&r "
Parallel communication uses multiple wires 6bus7 running parallel to each other" and can
transmit data on all the wires simultaneously. i.e all the bits of the byte are transmitted at a time.
<=
4o" speed of the parallel data transfer is e(tremely high compared to serial data transfer. An +5bit
parallel data transfer is +5times faster than serial data transfer. Fence with in the computer all
data transfer is mainly based on Parallel data transfer. But only limitation is due to the high
cost "this method is limited to only short distance communications.
Di,,&r&c&s -&t.&& #&ria* !ata tras,&r a! Para**&* !ata tras,&r
#.No #&ria* Commuicatio Para**&* Commuicatio
, &ata is transmitted bit after the bit in a
single line
&ata is transmitted simultaneously
through group of lines6Bus7
; &ata congestion takes place Bo" &ata congestion
< 3ow speed transmission Figh speed transmission
= $mplementation of serial links is not an
easy task.
Parallel data links are easily
implemented in hardware
.. $n terms of transmission channel costs
such as data bus cable length" data bus
buffers" interface connectors" it is less
e(pensive
$t is more e(pensive
* Bo " crosstalk problem Crosstalk creates interference between
the parallel lines.
? Bo effect of inter symbol interference and
noise
Parallel ports suffer e(tremely from
inter5symbol interference 6$4$7 and
noise" and therefore the data can be
corrupted over long distances.
+ The bandwidth of serial wires is much
higher.
The bandwidth of parallel wires is much
lower.
: 4erial interface is more fle(ible to
upgrade % without changing the hardware
Parallel data transfer mechanism rely on
hardware resources and hence not
fle(ible to upgrade.
,- 4erial communication work effectively
even at high freIuencies.
Parallel buses are hard to run at high
freIuencies.
#ERI8L COMM2NIC8TION IN 8051 MICROCONTROLLER
<.
The +-., has two pins for transferring and receiving data by serial communication. These two
pins are part of the Port<6P<.- DP<.,7 .These pins are TT3 compatible and hence they reIuire a
line driver to make them !4;<; compatible .Ma(;<; chip is one such line driver in use. 4erial
communication is controlled by an +5bit register called 4C#B register"it is a bit addressable
register.
#CON 9#&ria* cotro*: r&(ist&r "
4M- 4C#B.? 4erial port mode selector
4M, 4C#B.* 4erial port mode selector
4M; 4C#B.. sed for multiprocessor mode communication
6not applicable for +-.,7
!8B 4C#B.= !eceive enable. 4et or cleared by making this bit
either , or - foe enable %disable reception.
TB+ 4C#B.< :
th
data bit transmitted in modes ; and <
!B+ 4C#B.; :
th
data bit received in modes ; and <.it is not
used in mode - D mode ,.$f 4M; Q - !B+ is the
stop bit .
T$ 4C#B., Transmit interrupt flag
!$ 4C#B.- !eceive interrupt flag.
M- " 4M, )

These two bits of 4C#B register determine the framing of data by
specifying the number of bits per character and start bit and stop bits. There are = serial
modes.
4M- 4M,
- - ) 4erial Mode -
<*
- , ) 4erial Mode ," + bit data" , stop bit" , start bit
, - ) 4erial Mode ;
, , ) 4erial Mode <
!8B 6!eceive 8nable7 also referred as 4C#B.=. Ghen it is high"it allows the +-., to
receive data on the !(& pin. 4o to receive and transfer data !8B must be set to ,.Ghen
!8BQ-"the receiver is disabled. This is achieved as below
48TB 4C#B.=
D C3! 4C#B.=
T$ 6Transmit interrupt7 is the &, bit of 4C#B register. Ghen +-., finishes the transfer of
+5bit character" it raises the T$ flag to indicate that it is ready to transfer another byte.
The T$ bit is raised at the beginning of the stop bit.
!$ 6!eceive interrupt7 is the &- bit of the 4C#B register. Ghen the +-., receives data
serially "via !(&" it gets rid of the start and stop bits and places the byte in the 4B'
register. Then it raises the !$ flag bit to indicate that a byte has been received and should
be picked up before it is lost. !$ is raised halfway through the stop bit.
Commuicatio throu(h R#7/7
A personal computer has a serial port known as communication port or C#M Port used to connect a
modem for e(ample or any other device" there could be more then one C#M Port in a PC. 4erial ports are
controlled by a special chip called A!T 6niversal Asynchronous !eceiver Transmitter7.
!4 ;<; standard describes a communication method where information is sent bit by bit on a
physical channel. The R# sta!s ,or R&comm&!&! #ta!ar!.The information must be broken
up in data words. The length of a data word is variable.
$t is one of the popularly known interface standard for serial communication
between &T8 D &C8. This !45;<;5C is the commonly used standard when data are
transmitted as voltage .This standard was first developed by 8lectronic industries
association68$A7. 'or the !45;<;C" a ;. pin & type connector is used . &B5;.P male and
<?
&B5;.4 female. !45;<; standard was first introduced in ,:*-s by Telecommunications
$ndustry Association6T$A7.
It&r,aci( th& 8051 Microcotro**&r to PC"
As the !45;<; standard is developed earlier to TT3 devices "a 4A!T such as +;., is not
directly compatible with these signal levels .Because of this "voltage transistors called line
drivers and line receivers are used to interface TT3 logic with !45;<; signals . The line driver
MC ,=++ is used to convert !45;<; to TT3.The microcontroller is connected to the PC using
the &B: connector.

The T(& and !( & pins are connected to the T$ in and !$ in pins of the MA0 ;<; $C and the T$
out and !$ in pins of the MA0 $C are connected to the !(& and T(& pins of the &B: connector
as shown in the interface diagram.
INTER'8CIN? DC MOTOR5 8051
<+
A &C motor runs with the help of &irect Current. $t produces torIue by using both electricity and
magnetic fields. The &C motor has rotor" stator" field magnet" brushes" shaft" commutator. The
&C motor reIuires more current to produce initial torIue than in running state.$nterfacing the &C
motor directly to +-., microcontroller is not possible. Because the &C motor uses large current
6;--5<--mA in small &C motors7 to run. Ghen this current flow into the +-., microcontroller"
the $C will get damaged. Therefore we use a driving circuit with an opto isolator and a +&,8
Dual -./ridge driver. The opto.isolator provides additional protection to the
*icrocontroller.

Continuous" sustained operation of the motor will cause the 3;:< &ual F5Bridge driver to
overheat. 4o"a suitable heat sink must be used.
8ss&m-*y La(ua(& %ro(ram
<:
INTER'8CIN? D8C 58051 MICROCONTROLLER
The DAC 0800 is a si*ple *onolithic 8.0it D1A converter. It has #ast settling ti*e o#
100ns. It can 0e directl$ inter#aced to TT+% CM2% PM2 and others. It operates at
3.54 to 5184 suppl$. The nu*0er o# data 0it inputs decides the resolution o# the
DAC since the nu*0er o# analog output levels is e6ual to &% 7here n is the nu*0er
o# data 0it inputs. There#ore% an 8.input DAC such as the DAC0808 provides &58
discrete voltage !or current" levels o# output.
The interfacing circuit is shown below. port ,6+ bits of the microcontroller is connected to the
input data lines of &AC5-+.The reference current is determined by the resistor !, and the
reference voltage 2 ref. The resistor !; is generally eIual to !, to match the input impedance of
reference source. The output 6taken from pin number = is observed either on a digital multimeter
or on a cathode ray oscilloscope.
OR? 0000= R&mar+s
M8IN CLR P1.0
CLR P1.1
CLR P1.7
#ET) P7.0
MONITOR
#ET) P1.0 Ea-*& th& =5-ri!(& !riv&r
GN) P7.0 CLOC>@I#E
CLR P1.1 01 is ,or Cout&r c*oc+.is&
#ET) P1.7
#GMP MONITOR
CLOC>@I#E #ET) P1.1 10 is ,or c*oc+.is&
CLR P1.7
#GMP MONITOR
=-
The output current Io is calculated as #ollo7s:
$o Q 2ref%!,WAo%; H A,%= H A;%+ H 1 HA?%;.*X
The output voltage 4o is o0tained as #ollo7s: 4o 9Io : (1
8ss&m-*y La(ua(& Pro(ram
M24 A% ;DATA: < !A" 9 ;Data
TA(T : M24 ,0-% A < !port .1" 9 !A"
I)C A
+=MP TA(T < (epeat
555555555555555555555(((555555555555555555555
=,
RE'ERENCE ) Muhammed Ali Ma>idi" Sanice Cillies Pie Ma>idi" @The +-., Microcontroller
and 8mbedded 4ystemsJY Pearson 8ducationAsia.
=;

You might also like