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

UNI. R.

NO-100070497676
Preface
This report is based on my industrial trainin as a part o! my enineerin deree at
""#$#$ %IR$ &IN'% #%$TT$())* at +edhaa,i -mbedded &ystems* %oshiarpur
!or the period o! .une /011 to .uly /011.
The report presents an e0hausti,e outline on Embedded Systems, 8051
microcontroller & its various interfaces.
$ll possibilities ha,e been tried !or ma1in the e0planation as illustrati,e as possible.
<<VIJAY KUMAR>>
1 2 3 a e
UNI. R.NO-100070497676
Table of Contents
1. $41no5ledement.
/. 6erti!i4ate.
7. Theory
a. Introdu4tion to -mbedded &ystems
b. 6omparison bet5een +i4ropro4essor 8 +i4ro4ontroller
4. Introdu4tion to 90:1 +i4ro4ontroller
4. 3ra4ti4al
a. &olderin Tips
b. ;6 3o5er &upply
4. Transistor as a &5it4h
d. <or1in 5ith =eil 6ompiler>$ssembler
e. (-; Inter!a4in
!. &5it4h Inter!a4in ? @ -0ternal InterruptA
. (6; Inter!a4in
:. +inor 3roBe4t ;etails
a. Introdu4tion to the proBe4t
b. #lo41 ;iaram
4. 6omponent (ist
d. 6ir4uit ;iaram
e. Te4hni4al ;etails
6. #iblioraphy.
/ 2 3 a e
UNI. R.NO-100070497676
1. Acknowledgements
I e0press my sin4ere than1s to the manaement o! our 4ollee !or i,in us the liberty
to 4hoose the most rele,ant industrial house !or our trainin proramme.
I am rate!ul to our 3rin4ipal +r. $Bit &inh !or their e04ellent 4o-ordination 5ith the
industry !or the Industrial Trainin and thus i,in us an opportunity to enhan4e our
te4hni4al s1ills in the sense o! industrial a4ti,ity.
(ast but not the least* I am e0tremely than1!ul to +r. Coesh =alia* +r. 'ur5inder
&inh and the other enineerin sta!! at +-;%$DI -+#-;;-; &C&T-+& !or
their mu4h-needed help and !or de,elopin in me a pro!essional attitude.
$bo,e all* I than1 my !amily 8 !riends !or their mu4h-needed help and in!ormation
o!!ered durin this period.
<<VIJAY KUMA!!
7 2 3 a e
UNI. R.NO-100070497676
". T#eor$
".a Introd%ct&on to 'mbedded ($stems
I)T*+UCTI*)
$n -mbedded produ4t uses the mi4ropro4essor?or mi4ro4ontrollerA to do a spe4i!i4
tas1 only. $ printer is an e0ample o! -mbedded system sin4e the pro4essor inside it
per!orms one tas1 only namely ettin the data and printin it.In 4ontrast to this
3entium based 36 4an be used !or any no. o! appli4ations su4h as 5ord pro4essor*
print ser,er* ban1 teller terminal* ,ideo ame player* net5or1 ser,er or internet
terminal.
&o!t5are !or ,ariety o! appli4ations 4an be loaded and run. O! 4ourse the reason a 36
4an per!orm multiple tas1 is that it has R$+ memory and an operatin system that
loads the appli4ation so!t5are into R$+ 8 lets the 63U run it. In an -mbedded
system there is only one appli4ation so!t5are that is typi4ally burned into RO+. $n
09636 4ontains or is 4onne4ted to ,arious -mbedded 3rodu4ts su4h as 1eyboard*
printer* modem* ;is4 4ontroller* &ound 4ard* 6;-Rom ;ri,er* +ouse 8 so on. -a4h
one o! these peripherals has a mi4ro4ontroller inside it that per!orms only one tas1.
Eor e0ample inside e,ery mouse there is mi4ro4ontroller to per!orm the tas1 o!
!indin the mouse position and sendin it to 36.
$lthouh mi4ro4ontroller are pre!erred 4hoi4e !or many -mbedded systems* There are
times that a mi4ro4ontroller is inadeFuate !or the tas1. Eor this reason in re4ent years
many manu!a4tures o! eneral purpose mi4ropro4essors su4h as INT-(* +otorolla*
$+; 8 6yri0 ha,e tareted their mi4ropro4essors !or the hih end o! -mbedded
mar1et. <hile INT-(* $+;* 6yri0 push their 096 pro4essors !or both the embedded
and des1top p4 mar1et* +otorolla is determined to 1eep the 69000 !amilies ali,e by
taretin it mainly !or hih end o! embedded system.
One o! the most 4riti4al needs o! the embedded system is to de4rease po5er
4onsumptions and spa4e. This 4an be a4hie,ed by interatin more !un4tions into the
63U 4hips.
$ll the embedded pro4essors based on the 096 and 69000 ha,e lo5 po5er
4onsumptions in additions to some !orms o! I>O* 6om port 8 RO+ all on a sinle
4hip. In hiher per!orman4e -mbedded system the trend is to interate more 8 more
!un4tion on the 63U 4hip 8 let the desiner de4ide 5hi4h !eature he>she 5ants to use.
4 2 3 a e
UNI. R.NO-100070497676
'M,'++'+ (Y(T'M
$n -mbedded &ystem employs a 4ombination o! hard5are 8 so!t5are to per!orm a
spe4i!i4 !un4tionG is part o! a larer system * 5or1s in a rea4ti,e and time-4onstrained
en,ironment. &o!t5are is used !or pro,idin !eatures and !le0ibility. %ard5are is
used !or per!orman4e ?8 sometimes se4urityA
$n embedded system is a spe4ial purpose system in 5hi4h the 4omputer is 4ompletely
en4apsulated by the de,i4e it 4ontrols. Unli1e a eneral purpose 4omputer* su4h as a
36* an embedded system per!orms prede!ined tas1s usually 5ith ,ery spe4i!i4 tas1s
desin enineers 4an optimiHe it redu4in the siHe and 4ost o! the produ4t. -mbedded
systems are o!ten mass produ4ed* so the 4ost sa,ins may be multiplied by million o!
items.
The 4ore o! any embedded system is !ormed by one or se,eral mi4ropro4essor or
mi4ro 4ontroller prorammed to per!orm a small number o! tas1s. In 4ontrast to a
eneral purpose 4omputer* 5hi4h 4an run any so!t5are appli4ation* the user 4hooses*
the so!t5are on an embedded system is semi-permanent* so it is o!ten 4alled !irm5are.
'-AMP.'( */ 'M,'++'+ (Y(T'M
o $utomated teller ma4hines ?$T+&A.
o 6ellular telephones and telephoni4 s5it4hes.
o 6omputer printers* 6opiers*;is1 dri,es ?!loppy dis1 dri,e and hard dis1 dri,eA
o %ome automation produ4ts li1e thermostat* air 4onditioners and se4urity
monitorin system*%ouse hold applian4es in4ludin mi4ro5a,e o,ens*
5ashin ma4hines* TD sets ;D; players>re4orders.
o +easurement eFuipment su4h as diital storae os4illos4opes* loi4 analyHers
and spe4trum analyHers.
o 3ersonal diital assistants ?3;$IsA* i.e.* small hand held 4omputer 5ith 31+:
and other appli4ations.
o <earable 4omputers.
: 2 3 a e
UNI. R.NO-100070497676
MIC*P*C'((* 0MPU1
$ mi4ropro4essor is a eneral-purpose diital 4omputer 4entral pro4essin unit
?63UA. 63U is stand-alone* R$+* RO+* I>O* timer are separate.The blo41 diaram
o! a mi4ropro4essor 63U is sho5n
#(O6= ;I$'R$+ OE $ +I6RO3RO6-&&OR
MIC*C*)T*..'( 0MCU1
$ mi4ro4ontroller is a true 4omputer on a 4hip. The desin in4orporates all o! the
!eatures !ound in mi4ro-pro4essor 63UJ $(U* 36* &3* and reisters. The 63U*
R$+* RO+* I>O ports* 4lo41 4ir4uit and timers are all on a sinle 4hip.
6 2 3 a e
CPU
'eneral-
3urpose
+i4ro-
pro4essor
AM *M
I2*
Port
T&mer
(er&al
C*M
Port
+ata ,%s
AM *M
I2*
Port
T&mer
(er&al
C*M
Port
CPU
$ sinle 4hip
UNI. R.NO-100070497676
".b Com3ar&son between M&cro3rocessors 4
M&crocontrollers56
M&cro3rocessor M&crocontroller
1.;esiner 4an de4ide on the
amount o! RO+* R$+ and I>O
ports.
/.-0pensi,e and ,ersatile

7.+ultipurpose
4.6on4erned 5ith rapid
mo,ement o! the 4ode 8 data
!rom the e0ternal addresses to
the 4hip.
1.Ei0ed amount o! on-4hip RO+*
R$+* I>O ports
/.Eor appli4ations in 5hi4h 4ost*
po5er and spa4e are 4riti4al
7.&pe4i!i4 purpose
4.6on4erned 5ith the rapid
mo,ement o! the bits 5ithin the
4hip.
T7' C')TA. P*C'((I)8 U)IT56
The 4entral pro4essin unit ?63UA does all the 4omputinJ it !et4hes* de4odes and
e0e4utes proram instru4tions and dire4ts the !lo5 o! data to and !rom memory. The
63U per!orms the 4al4ulations reFuired by proram instru4tions and pla4es the results
o! these 4al4ulations* i! reFuired* into memory spa4e. +ost 63Us are syn4hronous.
This means that they depend on the 4y4les o! a pro4essor 4lo41. $ 4lo41 enerates a
hih-!reFuen4y sFuare 5a,e usually dri,en by a 4rystal* a R6 ?resistor 4apa4itorA or
an e0ternal sour4e. The 4lo41 is sometimes re!erred to as an os4illator. The 4lo41
speed* or os4illation rate* is measured in meahertH ?+%HA* 5hi4h represents one
million 4y4les>se4ond.
Eor e0ample* i! the 4lo41 speed is 7 +%H then there are 7*000*000-4lo41
4y4les>se4ond. 6lo41 4on!iurations are mi4ro 4ontroller dependent.
One part o! the 63U is responsible !or per!ormin 4al4ulations and e0e4utin
instru4tions. This part is 4alled the arithmeti4 loi4 unit* or $(U. There are a ,ariety
o! subsidiary 4omponents* 5hi4h support the $(U. These 4omponents in4lude the
de4oder* the seFuen4er and a ,ariety o! reisters. The de4oder 4on,erts instru4tions
7 2 3 a e
UNI. R.NO-100070497676
stored in proram memory into 4odes* 5hi4h the $(U 4an understand. The seFuen4er
manaes the !lo5 o! data alon the mi4ro4ontrollerIs data bus. The 63U to
temporarily store ,ital data* 5hi4h are ,olatile* uses reistersJ they 4an 4hane durin
proram e0e4ution. +ost mi4ro 4ontroller reisters are memory-mapped* asso4iated
5ith a memory lo4ation* and 4an be used li1e any other memory lo4ation. Reisters
store the state o! the 63U. I! the 4ontents o! mi4ro 4ontroller memory and the 4ontents
o! these reisters are sa,ed it is possible to suspend proram operation !or an
inde!inite period o! time and restart e0a4tly in the state 5hen the proram 5as
suspended. The number and names o! reisters ,aries drasti4ally amon mi4ro
4ontrollers. %o5e,er there are 4ertain reisters* 5hi4h are 4ommon to most mi4ro
4ontrollers* althouh the names may ,ary.
EI'J #(O6= ;I$'R$+ OE 63U
T#ese &ncl%de5
1. T7' (TACK P*I)T'5 The sta41 pointer 4ontains the address o! the ne0t
lo4ation on the sta41. The address in the sta41 pointer is de4remented 5hen data is
pushed on the sta41 and in4remented 5hen data is popped !rom the sta41.
". T7' I)+'- '8I(T'5 The inde0 reister is used to spe4i!y an address 5hen
4ertain addressin modes are used. It is also 1no5n as the pointer reister. The
+i4ro4hip de,i4es use the name E&R ?!ile sele4t reisterA.
9 2 3 a e
UNI. R.NO-100070497676
9. T7' P*8AM C*U)T'JThe 36 holds the address o! the ne0t instru4tion in
proram memory spa4e. It 4ontains the address o! the ne0t instru4tion the 63U 5ill
pro4ess. $s ea4h instru4tion is !et4hed and pro4essed by the $(U* the 63U
in4rements the 36 and thereby steps throuh the proram stored in the proram
memory spa4e.
:. T7' ACCUMU.AT*5The a44umulator is a reister that 4an hold operands or
results o! operations as ne4essary. The +i4ro4hip de,i4es use the name < ?5or1inA
reister. Other reisters may re!le4t results !rom the instru4tion Bust e0e4uted* 4ontrol
the options a,ailable on the de,i4e* and enable a44ess to 4ertain areas o! memory.

9 2 3 a e
UNI. R.NO-100070497676
".c Introd%ct&on to ;<=1 M&crocontroller5
AT;>C=1 /rom ATM'. Cor3orat&on5
This popular 90:1 4hip has on-4hip RO+ in the !orm o! !lash memory. This is ideal
!or !ast de,elopment sin4e !lash memory 4an be erased in se4onds 4ompared to
t5enty minutes or more needed !or the earlier ,ersions o! the 90:1. To use the
$T996:1 to de,elop a mi4ro4ontroller-based system reFuires a RO+ burner that
supports !lash memoryJ %o5e,er* a RO+ eraser is not needed. Noti4e that in !lash
memory you must erase the entire 4ontents o! RO+ in order to proram it aain. The
3RO+ burner does this erasin o! !lash itsel! and this is 5hy a separate burner is not
needed. To eliminate the need !or a 3RO+ burner $tmel is 5or1in on a ,ersion o!
the $T996:1 that 4an be prorammed by the serial 6O+ port o! the 36.
$tmel +i4ro4ontroller $T996:1
7ardware feat%res
40 pin I4.
4 =bytes o! Elash.
1/9 #ytes o! R$+.
7/ I>O lines.
T5o16-#it Timer>6ounters.
Ei,e De4tor.
10 2 3 a e
UNI. R.NO-100070497676
T5o-(e,el Interrupt $r4hite4ture.
Eull ;uple0 &erial 3ort.
On 6hip Os4illator and 6lo41 6ir4uitry.

(oftware feat%res
#it +anipulations
&inle Instru4tion +anipulation
&eparate 3roram $nd ;ata +emory
4 #an1 O! Temporary Reisters
;ire4t* Indire4t* Reister and Relati,e $ddressin.
In addition* the $T996:1 is desined 5ith stati4 loi4 !or operation do5n to Hero
!reFuen4y and supports t5o so!t5are sele4table po5er sa,in modes. The Idle +ode
stops the 63U 5hile allo5in the R$+* timer>4ounters* serial port and interrupt
system to 4ontinue !un4tionin. The 3o5er ;o5n +ode sa,es the R$+ 4ontents but
!reeHes the os4illator disablin all other 4hip !un4tions until the ne0t hard5are reset.
The $tmel Elash de,i4es are ideal !or de,elopin* sin4e they 4an be reprorammed
easy and !ast. I! 5e need more 4ode spa4e !or our appli4ation* parti4ularly !or
de,elopin 99600 proBe4ts 5ith 6 lanuae. $tmel o!!ers a broad rane o!
mi4ro4ontrollers based on the 90:1 ar4hite4ture* 5ith on-4hip Elash proram memory.
11 2 3 a e
UNI. R.NO-100070497676
1/ 2 3 a e
UNI. R.NO-100070497676
PI) +'(CIPTI*) */ T7' AT;>C=" 56
90:1 !amily members 4ome in di!!erent pa41aes su4h ;I3?dual in line
pa41aeA*KE3?Kuad !lat pa41aeA* and ((6?leadless 4hip 4arrierA*they all ha,e 40
pins that are dedi4ated to ,arious !un4tions su4h as I>O* R;* <R* address* data and
interrupts.
EI'J 3IN ;I$'R$+ OE T%- 3996:1R;/
P&ns 16; JPort 1 J -a4h o! these pins 4an be 4on!iured as an input or an output.
P&n >J '('T5 It is an input and is a4ti,e hih. Upon applyin a hih pulse to this
pin the mi4ro4ontroller 5ill reset and terminate all a4ti,ities. This is o!ten re!erred to
as a po5er on reset .$4ti,atin a po5er on reset 5ill 4ause all ,alues the reisters to
be lost. It 5ill set proram 4ounter to all 0s.In order !or the R-&-T input to be
e!!e4ti,e it must ha,e a minimum duration o! t5o ma4hine 4y4les. In other 5ords the
hih pulse must be hih !or a minimum o! t5o ma4hine 4y4les be!ore it is allo5ed to
o lo5.
17 2 3 a e
UNI. R.NO-100070497676
P&ns 1<61?J Port 95 &imilar to port 1* ea4h o! these pins 4an ser,e as eneral input
or output. #esides* all o! them ha,e alternati,e !un4tionsJ
P&n 1<5 -+ &erial asyn4hronous 4ommuni4ation input or &erial syn4hronous
4ommuni4ation output.
P&n 115 T-+ &erial asyn4hronous 4ommuni4ation output or &erial syn4hronous
4ommuni4ation 4lo41 output.
P&n 1"5 I)T< Interrupt 0 input.
P&n 195 I)T1 Interrupt 1 input.
P&n 1:5 T< Timer 0 4lo41 input.
P&n 1=5 T1 Timer 1 4lo41 input.
P&n 1@5 A <rite to e0ternal ?additionalA R$+.
P&n 1?5 + Read !rom e0ternal R$+.
P&n 1;B 1>5 -TA."B -TA.1 JInternal os4illator input and output. $ FuartH
4rystal 5hi4h spe4i!ies operatin !reFuen4y is usually 4onne4ted to these pins. The
FuartH 4rystal os4illator 4onne4ted to LT$(1 and LT$(/ also needs t5o 4apa4itors o!
77 p! ,alue. One side o! ea4h 4apa4itor is 4onne4ted to the round. &peed re!ers to the
ma0imum os4illator !reFuen4y 4onne4ted to LT$( .<hen the 90:1 is 4onne4ted to a
4rystal os4illator is po5ered up 5e 4an obser,e the !reFuen4y on the LT$(/ pin
usin the os4illos4ope.
P&n "<5 8)+ J'round.
P&ns "16";5 Port " JI! there is no intention to use e0ternal memory then these port
pins are 4on!iured as eneral inputs>outputs. In 4ase e0ternal memory is used* the
hiher address byte* i.e. addresses $9-$1: 5ill appear on this port. -,en thouh
memory 5ith 4apa4ity o! 64=b is not used* 5hi4h means that not all eiht port bits are
used !or its addressin* the rest o! them are not a,ailable as inputs>outputs.
P&n ">5 P(') JI! e0ternal RO+ is used !or storin proram then a loi4 Hero ?0A
appears on it e,ery time the mi4ro4ontroller reads a byte !rom memory.
P&n 9<5 A.'5 $ddress (at4h enable is an output pin and is a4ti,e hih.
14 2 3 a e
UNI. R.NO-100070497676
<hen 4onne4tin an 9071 to e0ternal memory* port 0 pro,ides both address and data.
In other 5ords the 9071 multiple0es address and data throuh port 0 to sa,e pins. The
$(- pin is used !or demultiple0in the address and data by 4onne4tin to ' pin o! the
74(&777 4hip.
P&n 915 'A J -$ 5hi4h stands !or Me0ternal a44essN. It is an input pin and must be
4onne4ted to either D44 or 'N;.#y applyin loi4 Hero to this pin* 3/ and 37 are
used !or data and address transmission 5ith no reard to 5hether there is internal
memory or not. It means that e,en there is a proram 5ritten to the mi4ro4ontroller* it
5ill not be e0e4uted. Instead* the proram 5ritten to e0ternal RO+ 5ill be e0e4uted.
#y applyin loi4 one to the -$ pin* the mi4ro4ontroller 5ill use both memories* !irst
internal then e0ternal ?i! e0istsA.
P&ns 9"69>J Port < J 3ort 0 is also desinated as $;0-$;7 allo5in it to be used
!or both address and data. <hen 4onne4tin an 90:1>71 to an e0ternal memory* port 0
pro,ides both address and data. The 90:1 multiple0es address and data throuh port 0
to sa,e pins. $(- indi4ates i! p0 has address $0-$7.in the 90:1 based systems 5here
there is no e0ternal memory 4onne4tion the pins o! 30 must be 4onne4ted e0ternally to
101-ohm pull-up resistor. This is due to the !a4t that 30 is an open drain* unli1e 31* 3/
and 37
P&n :<5 D66J @:D po5er supply.
Memor$ (3ace Allocat&on
Internal *M
The 996:1 has 4= bytes o! on-4hip RO+. This 4= bytes RO+ memory
has memory addresses o! 0000 to 0EEEh. 3roram addresses hiher than 0EEEh*
5hi4h e04eed the internal RO+ 4apa4ity* 5ill 4ause the mi4ro4ontroller to
automati4ally !et4h 4ode bytes !rom e0ternal memory. 6ode bytes 4an also be !et4hed
e04lusi,ely !rom an e0ternal memory* addresses 0000h to EEEEh* by 4onne4tin the
e0ternal a44ess pin to round. The proram 4ounter doesnIt 4are 5here the 4ode isJ
the 4ir4uit desiner de4ides 5hether the 4ode is !ound totally in internal RO+* totally
in e0ternal RO+ or in a 4ombination o! internal and e0ternal RO+.
1: 2 3 a e
UNI. R.NO-100070497676
Internal AM
The 1/99 bytes o! R$+ inside the 90:1 are assined addresses 00 to 7Eh.
These 1/9 bytes 4an be di,ided into three di!!erent roups as !ollo5sJ
$ total o! 7/ bytes !rom lo4ations 00 to 1Eh are set aside !or reister ban1s and
the sta41.
$ total o! 16 bytes !rom lo4ations /0h to /Eh are set aside !or bit addressable
read>5rite memory and instru4tions.
$ total o! 90 bytes !rom lo4ations 70h to 7Eh are used !or read and 5rite
storae* or 5hat is normally 4alled a s4rat4h pad. These 90 lo4ations o! R$+
are 5idely used !or the purpose o! storin data and parameters by 90:1
prorammers.
P*8AMMI)8 M*+'. */ ;<=1 56
In prorammin model o! 90:1 di!!erent types o! reisters are a,ailable and these
reisters are used to store temporarily data . The in!ormation 4ould be a byte o! data to
be pro4essed or an address pointin to the data to be !et4hed the maBority o! reisters
is 90:1 are 9-bit reisters.
ACCUMU.AT* 0'8I(T' A15
$44umulator is a mathemati4al reister 5here all the arithmeti4 and loi4al operations
are done and a!ter e0e4ution o! instru4tions the output data is stored in the reister.
-,ery bit o! this reister is a44essible.
, '8I(T'5
# reister is same as that o! a44umulator o!. It is also an 9 bit reister and e,ery bit o!
this is a44essible. This is also a mathemati4al reister # 5hi4h is used mostly !or
multipli4ation and di,ision.
P(A 0P*8AM (TATU( A*+1 eg&ster5
3roram status 5ord reister is an 9 bit reister. It is also re!erred to as the !la
reister. $lthouh the 3&< reister is 9 bits 5ide* only 6 bits o! it are used by the
90:1. The unused bits are user-de!inable !las.
16 2 3 a e
UNI. R.NO-100070497676
Eour o! the !las are 4alled 4onditional !las* meanin that they indi4ate some
4onditions that result a!ter an instru4tion is e0e4uted. These !our are 6C ?4arryA* $6
?au0iliary 4arryA* 3 ?parityA and OD ?o,er!lo5A.
(P'CIA. /U)CTI*) '8I(T' 0(/1 M'M*Y
&pe4ial Eun4tion Reisters ?&ERsA are areas o! memory that 4ontrol spe4i!i4
!un4tionality o! the 90:1 pro4essor. Eor e0ample* !our &ERs permit a44ess to the
90:1s 7/ input>output lines. $nother &ER allo5s a proram to read or 5rite to the
90:1s serial port. Other &ERs allo5 the user to set the serial baud rate* 4ontrol and
a44ess timers* and 4on!iure the 90:1s interrupt system.
(/ T$3es
$s mentioned in the 4hart itsel!* the &ERs that ha,e a blue ba41round are &ERs
related to the I>O ports. The 90:1 has !our I>O ports o! 9 bits* !or a total o! 7/ I>O
lines. <hether a i,en I>O line is hih or lo5 and the ,alues read !rom the line are
4ontrolled by the &ERs in reen. The &ERs 5ith yello5 ba41rounds are &ERs* 5hi4h
in some 5ay 4ontrol the operation or the 4on!iuration o! some aspe4t o! the 90:1.
Eor e0ample* T6ON 4ontrols the timers* &6ON 4ontrols the serial port.
The remainin &ERs* 5ith reen ba41rounds* are Oother &ERs.O These &ERs 4an be
thouht o! as au0iliary &ERs in the sense that they donPt dire4tly 4on!iure the 90:1
but ob,iously the 90:1 4annot operate 5ithout them. Eor e0ample* on4e the serial port
has been 4on!iured usin &6ON* the proram may read or 5rite to the serial port
usin the &#UE reister.
(/ +'(CIPTI*)(
This se4tion 4o,ers ea4h o! the standard &ERs !ound in the abo,e &ER 4hart map.
P< 0P*T <B A++'(( ;<7B ,IT6A++'((A,.'15
This is input>output port 0. -a4h bit o! this &ER 4orresponds to one o! the pins on
the mi4ro4ontroller. Eor e0ample* bit 0 o! port 0 is pin 30.0* bit 7 is pin 30.7.
17 2 3 a e
UNI. R.NO-100070497676
<ritin a ,alue o! 1 to a bit o! this &ER 5ill send a hih le,el on the
4orrespondin I>O pin 5hereas a ,alue o! 0 5ill brin it to a lo5 le,el.
(P 0(TACK P*I)T'B A++'(( ;1715
This is the sta41 pointer o! the mi4ro4ontroller. This &ER indi4ates 5here the ne0t
,alue to be ta1en !rom the sta41 5ill be read !rom in Internal R$+. I! you push a
,alue onto the sta41* the ,alue 5ill be 5ritten to the address o! &3 @ 1. That is to say*
i! &3 holds the ,alue 07h* a 3U&% instru4tion 5ill push the ,alue onto the sta41 at
address 09h
+P.2+P7 0+ATA P*I)T' .*A27I87B A++'(('( ;"72;9715
The &ERs ;3( and ;3% 5or1 toether to represent a 16-bit ,alue 4alled the ;ata
3ointer. The data pointer is used in operations reardin e0ternal R$+ and some
instru4tions in,ol,in 4ode memory. &in4e it is an unsined t5o-byte inteer ,alue* it
4an represent ,alues !rom 0000h to EEEEh ?0 throuh 6:*:7: de4imalA.
PC*) 0P*A' C*)T*.B A++'(('( ;?715
The 3o5er 6ontrol &ER is used to 4ontrol the 90:1Ps po5er 4ontrol modes. 6ertain
operation modes o! the 90:1 allo5 the 90:1 to o into a type o! OsleepO mode that
reFuires mu4h less po5er. These modes o! operation are 4ontrolled throuh 36ON.
$dditionally* one o! the bits in 36ON is used to double the e!!e4ti,e baud rate o! the
90:1Ps serial port.
TC*) 0TIM' C*)T*.B A++'(('( ;;7B ,IT6A++'((A,.'1J
The Timer 6ontrol &ER is used to 4on!iure and modi!y the 5ay in 5hi4h the
90:1Ps t5o timers operate. This &ER 4ontrols 5hether ea4h o! the t5o timers is
runnin or stopped and 4ontains a !la to indi4ate that ea4h timer has o,er!lo5ed.
$dditionally* some non-timer related bits are lo4ated in the T6ON &ER. These
bits are used to 4on!iure the 5ay in 5hi4h the e0ternal interrupts are a4ti,ated
and also 4ontain the e0ternal interrupt !las* 5hi4h are set 5hen an e0ternal
interrupt has o44urred.
19 2 3 a e
UNI. R.NO-100070497676
TE1J Timer 1 o,er!lo5 !la.
TR1J Timer 1 run 4ontrol bit.
TE0J Timer 0 o,er!lo5 !la.
TR0J Timer 0 run 4ontrol bit.
I-1J -0ternal interrupt 1 ede !la.
IT1J -0ternal interrupt 1 type !la.
I-0J -0ternal interrupt 0 ede !la.
IT0J -0ternal interrupt 0 type !la.
TM*+ 0TIM' M*+'B A++'(('( ;>715
The Timer +ode &ER is used to 4on!iure the mode o! operation o! ea4h o! the
t5o timers. Usin this &ER proram may 4on!iure ea4h timer to be a 16-bit
timer* an 9-bit auto reload timer* a 17-bit timer* or t5o separate timers.
$dditionally* one may 4on!iure the timers to only 4ount 5hen an e0ternal pin is
a4ti,ated or to 4ount Oe,entsO that are indi4ated on an e0ternal pin.
19 2 3 a e
UNI. R.NO-100070497676
T.<2T7< 0TIM' < .*A27I87B A++'(('( ;A72;C715 These t5o
&ERs* ta1en toether* represent timer 0. Their e0a4t beha,ior depends on ho5 the
timer is 4on!iured in the T+O; &ERG ho5e,er* these timers al5ays 4ount up.
<hat is 4on!iurable is ho5 and 5hen they in4rement in ,alue.
T.12T71 0TIM' 1 .*A27I87B A++'(('( ;,72;+715
These t5o &ERs* ta1en toether* represent timer 1. Their e0a4t beha,ior depends
on ho5 the timer is 4on!iured in the T+O; &ERG ho5e,er* these timers al5ays
4ount up. <hat is 4on!iurable is ho5 and 5hen they in4rement in ,alue.
P1 0P*T 1B A++'(( ><7B ,IT6A++'((A,.'15
This is input>output port 1. -a4h bit o! this &ER 4orresponds to one o! the pins on
the mi4ro4ontroller. Eor e0ample* bit 0 o! port 1 is pin 31.0* bit 7 is pin 31.7.
<ritin a ,alue o! 1 to a bit o! this &ER 5ill send a hih le,el on the
4orrespondin I>O pin 5hereas a ,alue o! 0 5ill brin it to a lo5 le,el.
P(A 0P*8AM (TATU( A*+B A++'(('( +<7B ,IT6
A++'((A,.'15
The 3roram &tatus <ord is used to store a number o! important bits that are
set and 4leared by 90:1 instru4tions. The 3&< &ER 4ontains the 4arry !la* the
au0iliary 4arry !la* the o,er!lo5 !la* and the parity !la. $dditionally* the
3&< reister 4ontains the reister ban1 sele4t !las* 5hi4h are used to sele4t*
5hi4h o! the ORO reister ban1s are 4urrently sele4ted.
/0 2 3 a e
UNI. R.NO-100070497676
ACC 0ACCUMU.AT*B A++'(('( '<7B ,IT6A++'((A,.'15
The $44umulator is one o! the most used &ERs on the 90:1 sin4e it is in,ol,ed in
so many instru4tions. The $44umulator resides as an &ER at -0h* 5hi4h means
the instru4tion +OD $* Q/0h is really the same as +OD -0h* Q/0h. %o5e,er* it is
a ood idea to use the !irst method sin4e it only reFuires t5o bytes 5hereas the
se4ond option reFuires three bytes.
, 0, '8I(T'B A++'(('( /<7B ,IT6A++'((A,.'15
The O#O reister is used in t5o instru4tionsJ the multiply and di,ide
operations. The # reister is also 4ommonly used by prorammers as an
au0iliary reister to temporarily store ,alues.
,A(IC '8I(T'(56
T7' ACCUMU.AT*
The $44umulator is a eneral reister to a44umulate the results o! a lare number o!
instru4tions. It 4an hold an 9-bit ?1-byteA ,alue and is the most ,ersatile reister the
90:1 has due to the shear number o! instru4tions that ma1e use o! the a44umulator.
+ore than hal! o! the 90:1s /:: instru4tions manipulate or use the a44umulator in
some 5ay. Eor e0ample* i! you 5ant to add the number 10 and /0* the resultin 70
5ill be stored in the $44umulator. On4e you ha,e a ,alue in the $44umulator you may
4ontinue pro4essin the ,alue or you may store it in another reister or in memory.
T7' +ATA P*I)T' 0+PT1
The ;ata 3ointer ?;3TRA is the 90:1s only user-a44essible 16-bit ?/-byteA reister.
The $44umulator* ORO reisters* and O#O reister are all 1-byte ,alues.
;3TR* as the name suests* is used to point to data. It is used by a number o!
4ommands* 5hi4h allo5 the 90:1 to a44ess e0ternal memory. <hen the 90:1 a44esses
e0ternal memory* it 5ill a44ess e0ternal memory at the address indi4ated by ;3TR.
<hile ;3TR is most o!ten used to point to data in e0ternal memory* many
prorammers o!ten ta1e ad,antae o! the !a4t that itIs the only true 16-bit reister
/1 2 3 a e
UNI. R.NO-100070497676
a,ailable. It is o!ten used to store /-byte ,alues* 5hi4h ha,e nothin to do 5ith
memory lo4ations.
T7' P*8AM C*U)T' 0PC1
The 3roram 6ounter ?36A is a /-byte address* 5hi4h tells the 90:1 5here the ne0t
instru4tion to e0e4ute is !ound in memory. <hen the 90:1 is initialiHed 36 al5ays
starts at 0000h and is in4remented ea4h time an instru4tion is e0e4uted. It is important
to note that 36 isnIt al5ays in4remented by one. &in4e some instru4tions reFuire / or
7 bytes the 36 5ill be in4remented by / or 7 in these 4ases.
The 3roram 6ounter is spe4ial in that there is no 5ay to dire4tly modi!y its
,alue. That is to say* you 4anIt do somethin li1e 36R/470h. On the other hand* i!
you e0e4ute (.+3 /470h youI,e e!!e4ti,ely a44omplished the same thin.
It is also interestin to note that 5hile you may 4hane the ,alue o! 36 ?by
e0e4utin a Bump instru4tion* et4.A there is no 5ay to read the ,alue o! 36.
T7' (TACK P*I)T' 0(P1
The &ta41 3ointer holds an 9-bit ?1-byteA ,alue. The &ta41 3ointer is used to indi4ate
5here the ne0t ,alue to be remo,ed !rom the sta41 should be ta1en !rom. <hen you
push a ,alue onto the sta41* the 90:1 !irst in4rements the ,alue o! &3 and then stores
the ,alue at the resultin memory lo4ation. <hen you pop a ,alue o!! the sta41* the
90:1 returns the ,alue !rom the memory lo4ation indi4ated by &3 and then de4rements
the ,alue o! &3.
<hen the 90:1 is initialiHed &3 5ill be initialiHed to 07h. I! you immediately
push a ,alue onto the sta41* the ,alue 5ill be stored in Internal R$+ address 09h.
Eirst the 90:1 5ill in4rement the ,alue o! &3 ?!rom 07h to 09hA and then 5ill store the
pushed ,alue at that memory address ?09hA. &3 is modi!ied dire4tly by the 90:1 by si0
instru4tionsJ 3U&%* 3O3* $6$((* (6$((* R-T* and R-TI. It is also used
intrinsi4ally 5hene,er an interrupt is triere
// 2 3 a e
UNI. R.NO-100070497676
9. Pract&cal
9.a (older&ng T&3s
A#at &s solderC
&older is an alloy ?mi0tureA o! tin and lead* typi4ally 60S tin and 40S lead. It melts at
a temperature o! about /00T6. 6oatin a sur!a4e 5ith solder is 4alled UtinninI
be4ause o! the tin 4ontent o! solder.
(ead is poisonous and you should al5ays 5ash your hands a!ter usin solder. &older
!or ele4troni4s use 4ontains tiny 4ores o! !lu0* li1e the 5ires inside a mains !le0. The
!lu0 is 4orrosi,e* li1e an a4id* and it 4leans the metal sur!a4es as the solder melts. This
is 5hy you must melt the solder a4tually on the Boint* not on the iron tip. <ithout !lu0
most Boints 5ould !ail be4ause metals Fui41ly o0idise and the solder itsel! 5ill not
!lo5 properly onto a dirty* o0idised* metal sur!a4e.
The best siHe o! solder !or ele4troni4 4ir4uit boards is //s5 ?s5 R standard 5ire
aueA. Eor plus* 4omponent holders and other larer Boints you may pre!er to use
19s5 solder.
(afet$ Preca%t&ons
V )eDer to%c# t#e element or t&3 of t#e solder&ng &ron.
They are ,ery hot ?about 400T6A and 5ill i,e you a nasty burn.
V Take great care to aDo&d to%c#&ng t#e ma&ns fleE w&t# t#e t&3 of t#e &ron.
The iron should ha,e a heatproo! !le0 !or e0tra prote4tion. Ordinary plasti4 !le0 melts
immediately i! tou4hed by a hot iron and there is a ris1 o! burns and ele4tri4 sho41.
V Alwa$s ret%rn t#e solder&ng &ron to &ts stand w#en not &n %se.
Ne,er put it do5n on your 5or1ben4h* e,en !or a momentW
/7 2 3 a e
UNI. R.NO-100070497676
V Allow Fo&nts a m&n%te or so to cool down before $o% to%c# t#em.
V Aork &n a well6Dent&lated area.
The smo1e !ormed as you melt solder is mostly !rom the !lu0 and Fuite irritatin.
$,oid
breathin it by 1eepin you head to the side o!* not abo,e* your 5or1.
V Aas# $o%r #ands after %s&ng solder.
&older 4ontains lead.
Pre3ar&ng t#e solder&ng &ron
V Place t#e solder&ng &ron &n &ts stand and 3l%g &n.
The iron 5ill ta1e a !e5 minutes to rea4h its operatin temperature o! about 400T6.
V +am3en t#e s3onge &n t#e stand.
The best 5ay to do this is to li!t it out the stand and hold it under a 4old tap !or a
moment* then sFueeHe to remo,e e04ess 5ater. It should be damp* not drippin 5et.
V Aa&t a few m&n%tes for t#e solder&ng &ron to warm %3.
Cou 4an 4he41 i! it is ready by tryin to melt a little solder on the tip.
V A&3e t#e t&3 of t#e &ron on t#e dam3 s3onge.
This 5ill 4lean the tip.
V Melt a l&ttle solder on t#e t&3 of t#e &ron.
This is 4alled PtinninP and it 5ill help the heat to !lo5 !rom the ironIs tip to the Boint.
It only needs to be done 5hen you plu in the iron* and o44asionally 5hile solderin
i! you need to 5ipe the tip 4lean on the spone.
Mak&ng soldered Fo&nts
V 7old t#e solder&ng &ron l&ke a 3enB near t#e base of t#e #andle.
Imaine you are oin to 5rite your nameW
Remember to ne,er tou4h the hot element or tip.
V To%c# t#e solder&ng &ron onto t#e Fo&nt to be made.
+a1e sure it tou4hes both the 4omponent lead and the tra41.
%old the tip there !or a !e5 se4onds and...
V /eed a l&ttle solder onto t#e Fo&nt.
It should !lo5 smoothly onto the lead and tra41 to !orm a ,ol4ano shape. +a1e sure
you apply the solder to the Boint* not the iron.
V emoDe t#e solderB t#en t#e &ronB w#&le kee3&ng t#e Fo&nt st&ll.
/4 2 3 a e
UNI. R.NO-100070497676
$llo5 the Boint a !e5 se4onds to 4ool be!ore you mo,e the 4ir4uit board.
V Ins3ect t#e Fo&nt closel$.
It should loo1 shiny and ha,e a U,ol4anoI shape. I! not* you 5ill need to reheat it and
!eed in a little more solder. This time ensure that both the lead and tra41 are heated
!ully be!ore applyin solder.
9.b Power (%33l$
3o5er supplies are desined to 4on,ert hih ,oltae $6 mains to a suitable lo5
,oltae supply !or ele4troni4s 4ir4uits and other de,i4es. $ po5er supply 4an be
bro1en do5n into a series o! blo41s* ea4h o! 5hi4h per!orms a parti4ular !un4tion.

/or eEam3le a =V reg%lated s%33l$5
'ac# of t#e block #as &ts own f%nct&on as descr&bed below
1. Trans!ormer X steps do5n hih ,oltae $6 mains to lo5 ,oltae $6.
/. Re4ti!ier X 4on,erts $6 to ;6* but the ;6 output is ,aryin.
7. &moothin X smoothes the ;6 !rom ,aryin reatly to a small ripple.
4. Reulator X eliminates ripple by settin ;6 output to a !i0ed ,oltae.

TA)(/*M'
Trans!ormers 4on,ert $6 ele4tri4ity !rom one ,oltae to another 5ith little loss o!
po5er. Trans!ormers 5or1 only 5ith $6 and this is one o! the reasons 5hy
mains ele4tri4ity is $6. The t5o types o! trans!ormers
&tep-up trans!ormers in4rease ,oltae*
&tep-do5n trans!ormers redu4e ,oltae.
/: 2 3 a e
UNI. R.NO-100070497676
Transformer
+ost po5er supplies use a step-do5n trans!ormer to redu4e the danerously
hih mains ,oltae ?/70D in U=A to a sa!er lo5 ,oltae. The input 4oil is
4alled the primary and the output 4oil is 4alled the se4ondary. There is no
ele4tri4al 4onne4tion bet5een the t5o 4oils* instead they are lin1ed by an
alternatin maneti4 !ield 4reated in the so!t-iron 4ore o! the trans!ormer. The
t5o lines in the middle o! the 4ir4uit symbol represent the 4ore.
Trans!ormers 5aste ,ery little po5er so the po5er out is ?almostA eFual to the po5er
in. Note that as ,oltae is stepped do5n 4urrent is stepped up. The ratio o! the number
o! turns on ea4h 4oil* 4alled the turn ratio* determines the ratio o! the ,oltaes. $ step-
do5n trans!ormer has a lare number o! turns on its primary ?inputA 4oil 5hi4h is
4onne4ted to the hih ,oltae mains supply* and a small number o! turns on its
se4ondary ?outputA 4oil to i,e a lo5 output ,oltae.
T%rns rat&o G V3 G )3
Vs )s


And Power *%t G Power In
/6 2 3 a e
UNI. R.NO-100070497676
Vs Is G V3 I3

A#ere
V3 G 3r&mar$ 0&n3%t1 Doltage
)3 G n%mber of t%rns on 3r&mar$ co&l
I3 G 3r&mar$ 0&n3%t1 c%rrent
)s G n%mber of t%rns on secondar$ co&l
Is G secondar$ 0o%t3%t1 c%rrent
Vs G secondar$ 0o%t3%t1 Doltage
,I+8' 'CTI/I'
$ bride re4ti!ier 4an be made usin !our indi,idual diodes* but it is also a,ailable in
spe4ial pa41aes 4ontainin the !our diodes reFuired. It is 4alled a !ull-5a,e re4ti!ier
be4ause it uses all $6 5a,e ?both positi,e and neati,e se4tionsA. 1.4D is used up in
the bride re4ti!ier be4ause ea4h diode uses 0.7D 5hen 4ondu4tin and there are
al5ays t5o diodes 4ondu4tin* as sho5n in the diaram belo5. #ride re4ti!iers are
rated by the ma0imum 4urrent they 4an pass and the ma0imum re,erse ,oltae they
4an 5ithstand ?this must be at least three times the supply R+& ,oltae so the
re4ti!ier 4an 5ithstand the pea1 ,oltaesA. In this alternate pairs o! diodes 4ondu4t*
4hanin o,er the 4onne4tions so the alternatin dire4tions o! $6 are 4on,erted to the
one dire4tion o! ;6.

/7 2 3 a e
UNI. R.NO-100070497676
OUTPUT Full-wave Varying DC
(M**T7I)8
&moothin is per!ormed by a lare ,alue ele4trolyti4 4apa4itor 4onne4ted a4ross the
;6 supply to a4t as a reser,oir* supplyin 4urrent to the output 5hen the ,aryin
;6 ,oltae !rom the re4ti!ier is !allin. The diaram sho5s the unsmoothed
,aryin ;6 ?dotted lineA and the smoothed ;6 ?solid lineA. The 4apa4itor 4hares
Fui41ly near the pea1 o! the ,aryin ;6* and then dis4hares as it supplies 4urrent to
the output.
Note that smoothin sini!i4antly in4reases the a,erae ;6 ,oltae to almost the pea1
,alue ?1.4 Y R+& ,alueA. Eor e0ample 6D R+& $6 is re4ti!ied to !ull 5a,e ;6 o!
about 4.6D R+& ?1.4D is lost in the bride re4ti!ierA* 5ith smoothin this
in4reases to almost the pea1 ,alue i,in 1.4 Y 4.6 R 6.4D smooth ;6.
&moothin is not per!e4t due to the 4apa4itor ,oltae !allin a little as it dis4hares*
i,in a small ripple ,oltae. Eor many 4ir4uits a ripple 5hi4h is 10S o! the supply
,oltae is satis!a4tory and the eFuation belo5 i,es the reFuired ,alue !or the
smoothin 4apa4itor. $ larer 4apa4itor 5ill i,e !e5er ripples. The 4apa4itor ,alue
must be doubled 5hen smoothin hal!-5a,e ;6.
&moothin 4apa4itor !or 10S ripple* 6 R : Y Io
Vs H f
A#ere
C G smoot#&ng ca3ac&tance &n farads 0/1
/9 2 3 a e
UNI. R.NO-100070497676
Io G o%t3%t c%rrent from t#e s%33l$ &n am3s 0A1
Vs G s%33l$ Doltage &n Dolts 0V1B t#&s &s t#e 3eak Dal%e of t#e %nsmoot#ed
+C
f G freI%enc$ of t#e AC s%33l$ &n #ertJ 07J1B =<7J &n t#e UK
'8U.AT*


Doltae reulator I6s are a,ailable 5ith !i0ed ?typi4ally :* 1/ and 1:DA or ,ariable
output ,oltaes. They are also rated by the ma0imum 4urrent they 4an pass. Neati,e
,oltae reulators are a,ailable* mainly !or use in dual supplies. +ost reulators
in4lude some automati4 prote4tion !rom e04essi,e 4urrent ?Uo,erload prote4tionPA and
o,erheatin ?Uthermal prote4tionPA. +any o! the !i0ed ,oltae reulator I6s has 7 leads
and loo1 li1e po5er transistors* su4h as the 790: @:D 1$ reulator sho5n on the
riht. They in4lude a hole !or atta4hin a heat sin1 i! ne4essary.

Aork&ng of Power (%33l$
Transformer
/9 2 3 a e
UNI. R.NO-100070497676
The lo5 ,oltae $6 output is suitable !or lamps* heaters and spe4ial $6 motors. It is
not suitable !or ele4troni4 4ir4uits unless they in4lude a re4ti!ier and a smoothin
4apa4itor.
Transformer K ect&f&er

The ,aryin ;6 output is suitable !or lamps* heaters and standard motors. It is not
suitable !or ele4troni4 4ir4uits unless they in4lude a smoothin 4apa4itor.
Transformer K ect&f&er K (moot#&ng

The smooth ;6 output has a small ripple. It is suitable !or most ele4troni4 4ir4uits.

Transformer K ect&f&er K (moot#&ng K eg%lator
70 2 3 a e
UNI. R.NO-100070497676
D 2
C 1
1 0 0 0 u f
1 N 4 0 0 7
+ 5 V
V
L M 7 8 0 5
1 2
3
V I N V O U T
G
N
D
J 1
1
2
3
D 3
g n d
D 4
D 1
The reulated ;6 output is ,ery smooth 5ith no ripple. It is suitable !or all ele4troni4
4ir4uits.
9.c Trans&stor as (w&tc#
Trans&stor am3l&f$ c%rrent* !or e0ample they 4an be used to ampli!y the small
output 4urrent !rom a loi4 I6 so that it 4an operate a lamp* relay or other hih 4urrent
de,i4e. In many 4ir4uits a resistor is used to 4on,ert the 4hanin 4urrent to a
4hanin ,oltae* so the transistor is bein used to am3l&f$ Doltage.
$ transistor may be used as a sw&tc# ?either !ully on 5ith ma0imum 4urrent* or !ully
o!! 5ith no 4urrentA and as an am3l&f&er ?al5ays partly onA.
T$3es of trans&stor
There are t5o types o! standard transistors* )P) and
P)P* 5ith di!!erent 4ir4uit symbols. The letters re!er to
the layers o! semi4ondu4tor material used to ma1e the
transistor. +ost transistors used today are N3N be4ause
this is the easiest type to ma1e !rom sili4on. I! you are
ne5 to ele4troni4s it is best to start by learnin ho5 to use N3N transistors.
The leads are labelled base ?#A* collector ?6A and em&tter ?-A.
Test&ng &n a s&m3le sw&tc#&ng c&rc%&t
71 2 3 a e
Transistor 4ir4uit symbols
UNI. R.NO-100070497676
6onne4t the transistor into the 4ir4uit sho5n on the riht 5hi4h uses the transistor as a
s5it4h. The supply ,oltae is not 4riti4al* anythin bet5een : and 1/D is suitable.
This 4ir4uit 4an be Fui41ly built on breadboard !or e0ample. Ta1e 4are to in4lude the
101 resistor in the base 4onne4tion or you 5ill destroy the transistor as you test itW
I! the transistor is O= the (-; should liht 5hen the s5it4h is pressed and not liht
5hen the s5it4h is released.
To test a 3N3 transistor use the same 4ir4uit but re,erse the (-; and the supply
,oltae.
/&g5 3N3 and N3N transistor as a
s5it4h .
7/ 2 3 a e
UNI. R.NO-100070497676
9.d Aork&ng w&t# Ke&l Com3&ler2Assembler
1. Open =eil !rom the &tart menu
/. The Eiure belo5 sho5s the basi4 names o! the 5indo5s re!erred in this do4ument
(tart&ng a new Assembler ProFect
1. &ele4t Ne5 3roBe4t !rom the 3roBe4t +enu.
77 2 3 a e
UNI. R.NO-100070497676
/. Name the proBe4t UTole.a:1I
7. 6li41 on the &a,e #utton.
4. The de,i4e 5indo5 5ill be displayed.
:. &ele4t the part you 5ill be usin to test 5ith. Eor no5 5e 5ill use the ;allas
&emi4ondu4tor part ;&9964/0.
6. ;ouble 6li41 on the ;allas &emi4ondu4tor.
74 2 3 a e
UNI. R.NO-100070497676
7. &4roll do5n and sele4t the ;&9964/0 3art
9. 6li41 O=
7: 2 3 a e
UNI. R.NO-100070497676
Creat&ng (o%rce /&le
o 6li41 Eile +enu and sele4t Ne5.
o $ ne5 5indo5 5ill open up in the =eil I;-.
76 2 3 a e
UNI. R.NO-100070497676
o 5rite any 4ode on this !ile.
o 6li41 on Eile menu and sele4t &a,e asZ
77 2 3 a e
UNI. R.NO-100070497676
:. Name the !ile 5ith e0tension ?.asm !or assembly lanuae 4ode 8 .4 !or embedded
6 lanuae 4odeA.
6. 6li41 the &a,e #utton
$ddin Eile to the 3roBe4t
1. -0pand Taret 1 in the Tree +enu
79 2 3 a e
UNI. R.NO-100070497676
/. 6li41 on 3roBe4t and sele4t Tarets* 'roups* EilesZ
79 2 3 a e
UNI. R.NO-100070497676
7. 6li41 on 'roups>$dd Eiles tab
4. Under $,ailable 'roups sele4t &our4e 'roup 1
:. 6li41 $dd Eiles to 'roupZ button
40 2 3 a e
UNI. R.NO-100070497676
6. 6hane !ile type to $sm &our4e !ile?[.a[G [.sr4A
7. 6li41 on tole.a:1
9. 6li41 $dd button
9. 6li41 6lose #utton
10. 6li41 O= button 5hen you return to Taret* 'roups* EilesZ dialo bo0.
41 2 3 a e
UNI. R.NO-100070497676
11. -0pand the &our4e 'roup 1 in the Tree menu to ensure that the !ile 5as added to
the proBe4t.
6reatin %-L !or the 3art
1.6li41 on Taret 1 in Tree menu
/. 6li41 on 3roBe4t +enu and sele4t Options !or Taret 1
4/ 2 3 a e
UNI. R.NO-100070497676
7. &ele4t Taret Tab
4. 6hane Ltal ?+hHA !rom :0.0 to 11.0:9/
47 2 3 a e
UNI. R.NO-100070497676
:. &ele4t Output Tab
6. 6li41 on 6reate %e0 Eile 4he41 bo0
7. 6li41 O= #utton
9. 6li41 on 3roBe4t +enu and sele4t Rebuild all Taret Eiles
9. In the #uild <indo5 it should report U0 -rrors ?sA* 0 <arninsI
10. Cou are no5 ready to 3roram your 3art
44 2 3 a e
UNI. R.NO-100070497676
4: 2 3 a e
UNI. R.NO-100070497676
9.e Interfac&ng .'+5
.'+ ,as&cs5
.&g#t 'm&tt&ng +&odes or .'+Ls* are amon the most 5idely used o! all the types o!
diodes a,ailable. They are the most ,isible type o! diode* that emits a !airly narro5
band5idth o! either ,isible 4olored liht* in,isible in!ra-red or laser type liht 5hen a
!or5ard 4urrent is passed throuh them. $ O.&g#t 'm&tt&ng +&odeO or .'+ as it is
more 4ommonly 4alled* is basi4ally Bust a spe4ialiHed type o! 3N-Bun4tion diode* made
!rom a ,ery thin layer o! !airly hea,ily doped semi4ondu4tor material. <hen the diode
is Eor5ard #iased* ele4trons !rom the semi4ondu4tors 4ondu4tion band 4ombine 5ith
holes !rom the ,alen4e band* releasin su!!i4ient enery to produ4e photons o! liht.
#e4ause o! this thin layer a reasonable number o! these photons 4an lea,e the Bun4tion
and radiate a5ay produ4in a 4olored liht output.
Erom the table abo,e 5e 4an see that the main 3-type dopant used in the manu!a4ture
o! (iht -mittin ;iodes is 'allium?'a* atomi4 number 71A and the main N-type
dopant used is $rseni4 ?$s* atomi4 number 71A i,in the resultin 'allium $rsenide
?'a$sA 4rystal stru4ture* 5hi4h has the 4hara4teristi4s o! radiatin sini!i4ant amounts
o! in!rared radiation !rom its Bun4tion 5hen a !or5ard 4urrent is !lo5in throuh it.
#y also addin 3hosphorus ?3* atomi4 number 1:A* as a third dopant the o,erall
5a,elenth o! the emitted radiation is redu4ed to i,e ,isible red liht to the human
eye. Eurther re!inements in the dopin pro4ess o! the 3N-Bun4tion ha,e resulted in a
rane o! 4olors a,ailable !rom red* orane and amber throuh to yello5* and the
re4ently de,eloped blue (-; 5hi4h is a4hie,ed by inBe4tin nitroen atoms into the
4rystal stru4ture durin the dopin pro4ess.
46 2 3 a e
UNI. R.NO-100070497676
.&g#t 'm&tt&ng +&odes I6V C#aracter&st&cs.
(iht -mittin ;iode ?(-;A &4hemati4 symbol and its I-D 6hara4teristi4s 6ur,es
sho5in the di!!erent 4olours a,ailable.
#e!ore a liht emittin diode 4an OemitO any !orm o! liht it needs a 4urrent to !lo5
throuh it* as it is a 4urrent dependant de,i4e. $s the (-; is to be 4onne4ted in a
!or5ard bias 4ondition a4ross a po5er supply it should be Current Limited usin a
series resistor to prote4t it !rom e04essi,e 4urrent !lo5. Erom the table abo,e 5e 4an
see that ea4h (-; has its o5n !or5ard ,oltae drop a4ross the 3N-Bun4tion and this
parameter 5hi4h is determined by the semi4ondu4tor material used is the !or5ard
,oltae drop !or a i,en amount o! !or5ard 4ondu4tion 4urrent* typi4ally !or a
!or5ard 4urrent o! /0m$. In most 4ases (-;s are operated !rom a lo5 ,oltae ;6
supply* 5ith a series resistor to limit the !or5ard 4urrent to a suitable ,alue !rom say
:m$ !or a simple (-; indi4ator to 70m$ or more 5here a hih brihtness liht
output is needed.
.'+ (er&es es&stance.
The series resistor ,alue R
&
is 4al4ulated by simply usin *#mLs .aw* 1no5in the
reFuired !or5ard 4urrent I
E
* the supply ,oltae D
&
and the e0pe4ted !or5ard ,oltae
drop o! the (-;* D
E
at this 4urrent le,el as sho5n belo5.
47 2 3 a e
UNI. R.NO-100070497676
.'+ (er&es es&stor C&rc%&t
'Eam3le )o1.
$n amber 4oloured (-; is to be 4onne4ted to a :.0, stabilised po5er supply. Usin
the 4ir4uit abo,e 4al4ulate the series resistor reFuired to limit the !or5ard 4urrent to
less than 10m$.
,as&c c&rc%&t of ;<=1 5
The 90:1 has on-4hip os4illator but reFuires e0ternal 4lo41 to run it . +ost o!ten a
FuartH 4rystal os4illator to inputs LT$(1?pin 19A and LT$(/?pin19A . The KurtH
4rystal os4illator to LT$(1 and LT$(/ also needs t5o 4apa4itors o! 70p! ,alue .
One side o! ea4h 4apa4itor 4onne4ted to the round as sho5n in i,en belo5 !iure
O! basi4 4ir4uit .
3in 9 is the R-&-T pin . It is an input and a4ti,e hih?normally lo5A . Upon applyin
a hih pulse to this pin*the mi4ro4ontroller 5ill reset and terminate all a4ti,ities . This
O!ten re!erred to as a poweron reset. $4ti,atin a po5er-on reset 5ill 4ause all ,alues
in the reister to be lost. It 5ill set proram 4ounter to all 0s.
49 2 3 a e
UNI. R.NO-100070497676
/&g5 ,as&c c&rc%&t of ;<=1
,as&c 3rogram of ;<=1 5
or 0000h
aainJmo, 30*Q::h
l4all delay
mo, 30*Q0aah
l4all delay
lBmp aain
delayJ mo, r0*Q0!!h
hereJ dBnH r0*here
ret
end
49 2 3 a e
UNI. R.NO-100070497676
#y usin this proram* 5e 4he41ed the ,oltae le,el o! 90:1 as per the instru4tions
applied in the proram .
The 90:1 mi4ro4ontrollers 4an pro,ide only lo5 input 4urrent and sin4e their pins are
4on!iured as outputs 5hen ,oltae le,el on them is eFual to 0* dire4t 4onne4tin to
(-;s is 4arried out as it is sho5n in !iure ?(o5 4urrent (-;* 4athode is 4onne4ted
to output pinA.The resistor used here is 4urrent limitin resistor.
:0 2 3 a e
UNI. R.NO-100070497676
C&rc%&t +&agram5
Interfac&ng of ;<=1 w&t# .'+5
Program of .'+0bl&nk&ng1 5
or 0000h
aainJ mo, p0*Q0!!h
a4all delay
mo, p0*Q00h
a4all delay
sBmp aain
delay J mo, r1*Q0!!h
repeatJ mo, r0*Q0!!h
here J dBnH r0*here
:1 2 3 a e
UNI. R.NO-100070497676
dBnH r1*repeat
ret
end
,l&nk&ng %s&ng T&mer Interr%3t 3rogramm&ng5
or 0000h
mo, a*Q01h
setb ea
setb et1
mo, tl1*Q00h
mo, th1*Q00h
mo, tmod*Q10h
setb tr1
%-R-J mo, p0*a
&.+3 %-R-
or 001bh
4lr tr1
rr a
mo, tl1*Q00%
mo, th1*Q00%
:/ 2 3 a e
UNI. R.NO-100070497676
setb tr1
rti
end
(w&tc# &nterfac&ng w&t# ;<=15
(w&tc# 3rogramm&ng 5
:7 2 3 a e
UNI. R.NO-100070497676
or 0000h
hereJ Bnb p7./*led\on
Bnb p7.7*led\o!!
sBmp here
led\onJ mo, p/*Q0!!h
a4all delay
sBmp here
led\o!!J mo, p/*Q00h
a4all delay
sBmp here
delayJ mo, r0*Q0!!h
returnJ mo, r1*Q0!!h
loopJ dBnH r1*loop
dBnH r0*return
ret
end
(w&tc# 3rogramm&ng %s&ng eEternal &nterr%3t 5
:4 2 3 a e
UNI. R.NO-100070497676
or 0000h
sBmp home
or 0007h
mo, p0*Q0!!h
reti
or 0017h
mo, p0*Q00h
reti
homeJsetb ea
setb it0
setb it1
setb e00
setb e01
hereJ sBmp here
end
:: 2 3 a e
UNI. R.NO-100070497676
+C Motor Interfac&ng5
These are the motors that are 4ommonly !ound in the toys and the tape re4orders.
These motors 4hane the dire4tion o! rotation by 4hanin the polarity. +ost 4hips
4anPt pass enouh 4urrent or ,oltae to spin a motor. $lso* motors tend to be
ele4tri4ally noisy ?spi1esA and 4an slam po5er ba41 into the 4ontrol lines 5hen the
motor dire4tion or speed is 4haned.
&pe4ialiHed 4ir4uits ?motor dri,ersA ha,e been de,eloped to supply motors 5ith po5er
and to isolate the other I6s !rom ele4tri4al problems. These 4ir4uits 4an be desined
su4h that they 4an be 4ompletely separate boards* reusable !rom proBe4t to proBe4t.
$ ,ery popular 4ir4uit !or dri,in ;6 motors ?ordinary or earheadA is 4alled an %-
bride. ItPs 4alled that be4ause it loo1s li1e the 4apital letter P%P on 4lassi4 s4hemati4s.
The reat ability o! an %-bride 4ir4uit is that the motor 4an be dri,en !or5ard or
ba415ard at any speed* optionally usin a 4ompletely independent po5er sour4e.
C&rc%&t +&agram56
76,r&dge5
:6 2 3 a e
UNI. R.NO-100070497676
% bride loi4 is basi4ally pro,ide a !or5ard and re,erse loi4 to the motor.
The H-Bridge Circuit:
This circuit knon !s th" #$%ri&'" (n!)"& *or its to+o,o'ic!, si)i,!rit- to th"
,"tt"r .#./ is co))on,- us"& to &ri0" )otors1 In this circuit to o* *our
tr!nsistors !r" s","cti0",- "n!%,"& to contro, curr"nt *,o throu'h ! )otor1
:7 2 3 a e
UNI. R.NO-100070497676
O++osit" +!ir o* tr!nsistors (Tr!nsistor On" !n& Tr!nsistor Thr""/ is "n!%,"&2
!,,oin' curr"nt to *,o throu'h th" )otor1 Th" oth"r +!ir is &is!%,"&2 !n& c!n
%" thou'ht o* !s out o* th" circuit1
3- &"t"r)inin' hich +!ir o* tr!nsistors is "n!%,"&2 curr"nt c!n %" )!&" to
*,o in "ith"r o* th" to &ir"ctions throu'h th" )otor1 3"c!us" +"r)!n"nt$
)!'n"t )otors r"0"rs" th"ir &ir"ction o* turn h"n th" curr"nt *,o is
r"0"rs"&2 this circuit !,,os %i&ir"ction!, contro, o* th" )otor1
:.g .C+ Interfac&ng5
11 LCD Int"r*!cin' ith 8051 Microcontro,,"r4 Th" LCD
is c!,,"& 25162 %"c!us" it h!s 'ot 2 ,in"s o* 16 ch!r!ct"rs1
111 7&0!nt!'"s o* LCD4 LCDs !r" *!st r"+,!cin' th" L8D %!s"&
7$s"')"nt &is+,!-s %"c!us" o* *o,,oin' r"!sons4
!1 9ric"s o* LCDs !r" co)in' &on1
%1 LCDs c!n !,so &is+,!- nu)%"rs2 ch!r!ct"rs : 'r!+hics1
c1 ;"*r"sh contro,,"r is incor+or!t"& in th" LCD1
1.2 Pin Description of LCD: Th" LCD h!s 'ot tot!, o* 16 +ins< th"
&"scri+tion o* th" 9ins is 'i0"n %",o4
:9 2 3 a e
UNI. R.NO-100070497676
1. Vss, Vcc, Vee 4 =hi," Vcc !n& Vss +ro0i&" >50 !n& 'roun&
r"s+"cti0",-2 V"" is us"& *or contro,,in' LCD contr!st1
2. RS register se!ect": Th"r" !r" to 0"r- i)+ort!nt r"'ist"r insi&" th"
LCD1 Th" ;? +in is us"& *or th"ir s","ction1 I* ;?@0 th" instruction
co))!n& co&" r"'ist"r is s","ct"&2 !,,oin' th" us"r to s"n& !
co))!n& such !s c,"!r &is+,!-2 cursor !t ho)"2 "tc1 I* ;?@1 th" &!t!
r"'ist"r is s","ct"&2 !,,oin' th" us"r to s"n& &!t! to %" &is+,!-"& on
LCD1
#. R$% Re&d$%rite": ;A= in+ut !,,os th" us"r to rit" in*or)!tion to
LCD or r"!& in*or)!tion *ro) it1 Bor r"!&in' ;A=@1 !n& *or ritin'
+ur+os" ;A=@01
'. ( (n&)!e": Th" "n!%," +in is us"& %- th" LCD to ,!tch in*or)!tion
+r"s"nt"& to its D!t! +ins1 =h"n &!t! is su++,i"& to its &!t! +ins2 !
:9 2 3 a e
UNI. R.NO-100070497676
hi'h to ,o +u,s" )ust %" !++,- to this +in in or&"r *or th" LCD to ,!tch
in th" &!t! +r"s"nt !t th" &!t! +ins1
*. D+-D,: Th" 8$%it &!t! +ins 2 D0$D7 !r" us"& to s"n& in*or)!tion to th"
LCD or r"!& th" cont"nts o* LCD int"rn!, r"'ist"rs1 To &is+,!- ,"tt"r
!n& nu)%"rs " s"n& 7?CII co&" *or th" ,"tt"r 7$C2 !$D !n& nu)%"rs
0$E to th"s" +ins hi," )!kin' ;?@1 1 =" !,so us" ;?@0 to ch"ck th"
%us- *,!' %it to s"" i* th" LCD is r"!&- to r"c"i0" in*or)!tion1 D7 is th"
%us- *,!'2 i* D7 @ 12 it )"!ns LCD is %us- : i* D7 @ 02 it )"!ns LCD is
*r""1 D!t! shou,& %" 'i0"n to LCD on,- h"n LCD is *r""1
1.# Circuit Di&gr&-:
60 2 3 a e
UNI. R.NO-100070497676
1.' LCD- Co--&nd Codes:
1.* LCD Code:
org ++++h
-o. &,/#0h AA LCD is con*i'ur"& !s 2 ,in"2557 )!tri5
&c&!! co--&nd AA co))!n& su% routin" is c!,,"&
-o. &,/+( AA Dis+,!- ON2 cursor ON
&c&!! co--&nd
LCD is initi!,iD"&1
-o. &,/+1h AA LCD is c,"!r"&
&c&!! co--&nd
-o. &,/+1h AA ?hi*t &is+,!- ri'ht1
&c&!! co--&nd

61 2 3 a e
UNI. R.NO-100070497676
)&c2: -o. &,/0+h AA %rin' cursor to %"'innin' o* ,in"1
&c&!! co--&nd
-o. &,/343 AA 9rint ,"tt"r FMG on 1
st
s+!c" on ,in"1
&c&!! d&t&1 AA c!,, &!t!1 su%routin"
-o. &,/3(3 AA 9rint ,"tt"r F8G on 2
n&
s+!c" on ,in"1
&c&!! d&t&1
-o. &,/3D3 AA 9rint ,"tt"r FDG on 3
r&
s+!c" on ,in"1
&c&!! d&t&1
-o. &,/3H3
&c&!! d&t&1
AA9rints FM8D#77VIG
-o.&,/353
on *irst ,in"
&c&!! d&t&1
-o. &,/353
&c&!! d&t&1
-o. &,/3V3
&c&!! d&t&1
-o. &,/363
&c&!! d&t&1
s7-p )&c2 AA cursor is )o0"& to %"'innin' o* ,in"1 !n&
)"ss!'" is +rint"r !'!in1
co--&nd: &c&!! re&d8 AA it is ch"ck"& i* LCD is *r"" H
-o. p#,& AA &!t! is )o0"& to +ort3 !s it is conn"ct"& to
&!t! +ins o* LCD
c!r p1.* AA ;? @ 0 (co))!n& r"'ist"r is s","ct"&/
c!r p1.1 AA ;= @ 02 &!t! is %"in' ritt"n to LCD
set) p1., AA #i'h to Lo +u,s" to 8n!%," *or ,!tchin' th"
&!t!
c!r p1.,
ret
6/ 2 3 a e
UNI. R.NO-100070497676
d&t&1: &c&!! re&d8 AA it is ch"ck"& i* LCD is *r""H
-o. p#,& AA &!t! is )o0"& to +ort3 !s it is conn"ct"& to &!t!
+ins o* LCD
set) p1.* AA ;? @ 1 (&!t! r"'ist"r is s","ct"&/
c!r p1.1 AA ;= @ 02 &!t! is %"in' ritt"n to LCD
set) p1., AA #i'h to Lo +u,s" to 8n!%," *or ,!tchin' th" &!t!
c!r p1.,
ret
re&d8: set) p#., $$ r"!&- +in o* LCD (D7/
c!r p1.*
set) p1.1
repe&t:c!r p1.,
set) p1.,
7) p#.,,repe&t
ret
end
,%JJer56
7 %uDD"r or %""+"r is !n !u&io si'n!,in' &"0ic"2 hich )!-
%" )"ch!nic!,2 ","ctro)"ch!nic!,2 or 9i"Do","ctric1 T-+ic!, us"s o* %uDD"rs
!n& %""+"rs inc,u&" !,!r)s2 ti)"rs !n& con*ir)!tion o* us"r in+ut such !s !
)ous" c,ick or k"-strok"1
T8pes:
1.4ech&nic&!
7 Io- %uDD"r is !n "5!)+," o* ! +ur",- )"ch!nic!, %uDD"r1
2.(!ectro-ech&nic&!
8!r,- &"0ic"s "r" %!s"& on !n ","ctro)"ch!nic!, s-st") i&"ntic!, to
!n ","ctric %",, ithout th" )"t!, 'on'1 ?i)i,!r,-2 ! r",!- )!- %" conn"ct"& to
int"rru+t its on !ctu!tin' curr"nt2 c!usin' th" cont!cts to %uDD1 O*t"n th"s"
67 2 3 a e
UNI. R.NO-100070497676
units "r" !nchor"& to ! !,, or c"i,in' to us" it !s ! soun&in' %o!r&1 Th"
or& .%uDD"r. co)"s *ro) th" r!s+in' nois" th!t ","ctro)"ch!nic!, %uDD"rs
)!&"1
#.Pie9oe!ectric
9i"Do","ctric &isk %""+"r
7 +i"Do","ctric ",")"nt )!- %" &ri0"n %- !n osci,,!tin' ","ctronic circuit or
oth"r !u&io si'n!, sourc"2 &ri0"n ith ! +i"Do","ctric !u&io !)+,i*i"r1 ?oun&s
co))on,- us"& to in&ic!t" th!t ! %utton h!s %""n +r"ss"& !r" ! c,ick2 ! rin'
or ! %""+1
:ses:
7nnunci!tor +!n",s
8,"ctronic )"trono)"s
G!)" shos
Micro!0" o0"ns !n& oth"r hous"ho,& !++,i!nc"s
?+ortin' "0"nts such !s %!sk"t%!,, '!)"s
Circuit Di&gr&-:-
64 2 3 a e
'N;
UNI. R.NO-100070497676
Bu99er Code :-
org ++++h
here:set) p2.2
&c&!! de!&8
c!r p2.2
&c&!! de!&8
s7-p here
de!&8: -o. r+,/+ffh
repe&t:-o. r1,/+ffh
&g&in:d7n9, &g&in
d7n9, repe&t
ret
end
6: 2 3 a e
UNI. R.NO-100070497676
ProFect +eta&ls5
66 2 3 a e
UNI. R.NO-100070497676
@.,&b&l&ogra3#$
1. -;6 by &anBee, 'upta.
/. 90:1 +i4ro4ontroller by =ennith $yala
67 2 3 a e

You might also like