Вы находитесь на странице: 1из 24

Experiment No.

-2c
~im:-Write a program to add two numbers laying at two memory location
and display the result.

~pparatus c
 c   c c c  c

Theory c
c  c  c c  c c  c c   c c  c  c c c c c
 cc cc  c c c ccc
c!c "c
c c c c c c c c#$c%&&c  c
c

c c c  cc c c c


c' c
cc  c c c cc

Program c

()c *%cc

()c *+cc

()c% *cc

%&&c% c

%&&c% cc

()c %c

,-&c

c
c

c
c
Experiment No: 3
~im:-Multiply two 8 bit numbers stored in external memory location 3000H
& 3001 H. store the result in memory location 3020 & 3021Hc

~pparatus c
 c   c c c  c

Theory c
c c  c c cc  c c c c ccc cc c
  c c c ccc
c!c "c c c c c c  c c c "c 
c c cc
!c
c  c c  c $c #.c    c c #.c   c
 ccc c%c c/c $  c
c
c c c 
c c c c
 ccc cc c c c c/c $   c c  cc  cc
  cc c%c c/c $  c
Program c
c
 cc

c
  cc
 ccc
cc
cc
 cc

c
  ccc
cc
 ccc
  c
c
c

c
c
Experiment No. 4
~im Write a program to check a number for being ODD or EVEN and show
the result on the display.

~pparatus cc
 c   cc c c  c

Theory !c "c c c$"c0   c


cc c.1/cc  c cc
%-&$c c  c
 c c c  c c %-&$c c c c c  c c (&&c
 
c cc,),-c1  c'$  c%c2cc cc,),-c 
c $  c
%2ccc c cc(&&c
Program cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
()c% *3c
%-.c% *c
4-5c-,67c
()c% c
14#8cc
-,67 ccccc()c% *c
cccccccccccccccccccccccccccccccccccccccccccccccccccc cccccc,-&c
c

cc c c c ccc

c
c
c

Experiment No. 5c
~im:-Study of interrupt structure of 8051/8031 microcontroller.
Theory :-c!" c c   cc9 $c c $ c cc c c

 c c "c c c0:(c&"c c c9   c  c c


c
 c c   c  c cc c c9 cc  c
  c c c c c
c  c  c
c "c c
c ; cc0:(c
"c

(c c0:(c"cc "c c   c c c c c
 c
 " c c c c7c9   c  c c c c c
   cc  c c   c%c   c cc$ cc   c
c c c cc "cc9   c c%c   c c c
   c c  c c   c $c  c7c   c $c
 cc c c   c  c  cc c $ c c

We have 4 interrupts:
<c 7 c=<cc
<c 7 =<c
<c ,9   c 
cc   c0-7c%-&c0-7c
+<c 1  c c   c'c 7c
These are the internal interrupts:
7 c=<cc
7 c=<c
1  c c   c'c 7c
These are the external interrupts:
c
0-7c
0-7c

c
c
Timer Flag Interrupt:c
c c  :  c" 
c c $c  c
 $c7><c c7>cc c cc7c $cc c cc
c   c$ c
 $ c c c c  c  cc c cc

Serial Port Interrupt c c  c c   cc$ c cc


c c'0c
c70 c7c c c$ c('c c "c c$c   c c c
  c7c70c cc c1(-c $  cc c
c c c cc  c
c'0c cc c1(-c $  cc c
c c c cc "c7c  c c
   c'0c?c70c c c cc c  c   c$ c c $ c c
1c c $ c
c c c  c c c  c c c c'0c?c
70c c c@ c c c9 c c c c

External Interrupt:c c


c   c  c c$ cc9   c  c c
0-7c c0-7c7c cc ccc c   c c c c   c $c
0,c c0,c c c7(-c $  c7c   c cc$c $$ c c"c
$$ c
The Interrupt Priority Register:-7c $  c 08c  c   c
  c c
   cc c "c c$c c
c   
c c c 81c 87c 86c 87(c 86c
c 8   c c2c $c$c   c
c 8   c c2c $c
c   cc
1c 8 c  c
c 0,Ac ' "c
c 0,Bc ' "c
c 0,c ' "c
81c 0,+c 1  c8 c0   c   c c
87c 0,cc 7 cc0   c   c c
86c 0, c ,9   c    c c c 0   c    c
 c
87c 0,c 7 cc0   c   c c
86(c 0,c ,9   c    c c 0   c    c
 c

c
c
c

The interrupt enable register :

E~ - - ES ET1 EX1 ET0 EX0

1c 8 c  c


,%c 0,Ac & c c c    c0c,%2 c c
   c
c c 
$c 0c
,%2c  c    c  c c
" c  c  c  c c
 $c c $c c c c
c 0,Bc ' "c
,7 c 0,c ' "c c  c9 c
,1c 0,+c 1  c8 c0   c  c
,7c 0,cc 7 cc0   c c c
,6c 0, c ,9   c    c c c 0   c  c
 c
,7c 0,c 7 cc0   c c c
,6c 0,c ,9   c    c c 0   c  c
 c
c
c

c
c
Experiment No. 6
~im:-Program to show the use of INT 0 and INT 1
Theory: -c7cCc   c c
c9   c 
c   c0-7cc c
0-7c #c c  " c c c    c c Cc    c c
   c 7c    c  c c   c  $ c 9 c c c c
   c "  c c c 9 c c    c  "c  9 c    c
"  c  c  c0-7cc cc c c  c  c 0-7cc cc c / c c
   c c  cc$c $$ c c"c $$ c!c
c
 c c $ c
c c  c0-7ccc c c c
 c  cc  c$c!" c
c
 cc
c c.,&cc  cc7c.,&Dc c c8ccc c
c
c9   c   c0-7cc  " c
Program cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
('Eccc
.48c%-0c
('Ecc
1,7/c80c
()c' * c
&4-5c' .c
',70c
('Eccc
%0- ()c0, *cCcc
. c14#8c. c
,-&c

c
c
Experiment No 7(a)
~im:-!  c c $ c c c c cc $c  c

~pparatus cc
 c   cc c c  c

Theory:c c  c cccc
 cc  c
c
c "c c $c cc
 cc $c  c c23c c9 c
c
cc&87'c c c  c c
 c c c c c  c 0  @c c c   c   c
c  c c   c
 c
 c c c  c c   c  c c 1  c  c c  c
D c    $c c   c 0c c   c  c c $  c  c c  c

c 
c  c   c -
c c c c c c   c   c
c  c c
  c c $c   c 0c c 9 c   c
c
c  c c   c  c

 c c  c cc c  c cc  c  c c  cD c   $c
  c 
c
c c  c c ccc c  c  c  c c
c   c c $c   c Ec c  $c c c c   c c   c c
$c  c

Program cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
()c' *c3c
17%'7 cc()c&87' *c
()c' *3c
/% ccc()c' &8.c
()6 %F&87'c
()c' %c
0-c&87'c
()c/ %c
()% 'c
4-,c% / -,c
%4#8c108c
-,c c4c108c
()c&8. ' c
()c% /c
()6cF&87' %c
0-c&87'c
()c% 'c
()6cF&87' %c
108ccccc &4-5cc' /%c
&4-5c' 17%'7c
,-&c

c
c
EXPERIMENT NO 7(b)c

~im:-!  c c $ c c c c cc$c  c

~pparatus cc
 c   cc c c  c

Theory cc c  c cccc


 cc  c
c
c "c c $c c
c cc$c  c c23c c9 c
c
cc c c c  c
c  c c c c c  c 0  @c c c   c   c
c  c c   c
 c
 c c c  c c   c  c c $   c  c c  c
D c    $c c  c0c c   c  c c  c  cc  c

c 
c  c   c -
c c c c c c   c   c
c  c c
  cc$c  c0c c9 c  c
c
c c c  c c

 c c  c cc c  c cc$   c  c c  cD c   $c
  c 
c
c c  c c ccc c  c  c  c c
c  cc$c  cEcc $c c c c  c c  cc
$c  c

Program cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
()c' c*c3c
17%'7 cc()c&87' c*c
()c' c*3c
/% ccc()c' c&8.c
()6c% cF&87'c
()c' %c
0-c&87'c
()6c% cF&87'c
()c/ c%c
()% c'c
4-,c% c/ -,c
%4#8c108c
-, c4c108c
()c&8. c' c
()c% c/c
()6cF&87' c%c
0-c&87'c
()c% c'c
()6cF&87' c%c

c
c
108ccccc c&4-5cc' /%c
&4-5c' c17%'7c
,-&c
ccccccccccccccccccccccccccccccccccccccccccccccccccccc

c
c
EXPERIMENT NO 8
~im:-!  c c $ c cc    cc c c

~pparatus cc
 c   cc c c  c

Theory: 7c c c    cc c c c c c c c
 cc
 c=<c= <c=<c0c c $ c
c
c  @c c%c c/c $  c

 cc!c
c c c c
c    cc cccc c%c c
$  c'c1  c c cc $  c/cc $  c'c!c
c c c
 cc%c
 c c cc/c  cc  cc  cc%c $  c
c/c $  c0  c'cc  c'cc  c'c c c c
 c c    cc .
Program cccccccccccccccccccccccccccccccccccccc()c'( c*c
()c% c*cc
()c/ c*c
()c' c/c
()c% c'c
#.c%/c
()c' c%c
()c/ c'c
()c% c/c
4-,c/ c*Bc c#8c
()c%c c'c
()c/ c' c
,-&c

c
c
Experiment No: 9c
~im:-To find the factorial of a number.

~pparatus c
 c   c c c  c

7,('G  c c c    cc cc c c c c c c c
c
 c =<= <=<Hc  c  $ c
c
c   @c c %c c /c $  cc

 c 
c
c  c c  c
c     c c c c c c c $  c c
' c   c c  c c $  c /c 'c
c  c c  c c %c
 c
 c/c c  cc  c  cc c $  c  c'cc  c
'ccc  c'cc c c c c c     c c 1  c c
 c
PROGR~M:

()c' c*ccc
()c% c*cc
()c/ c*ccc
()c' c*cc
()c' c/c
()c% c'c
#.c%/c
()c' c%c
()c' c/c
0-c'c
()c% c/c
4-,c/ c*Bc c#8c
()c% c'c
()c/ c' c
,-&c

c
c
Experiment No 10c
~im Program to control a stepper motor in direction, speed and number of
stepsc

~pparatus c
 c   c c c1  c  c

Theory:-

~)cMain program
1 cc c  @c  c cc cc c c  c

1 c I c  @c7c c c ; cc c

1 c c c  c c$ c   c

1 c+ c  @c  cccc c

1 c c
 cc c  cc c c

1 cB c cc c $  cc  @c ccc

1 cA cc cc cccccc c c c $c c  $c cc


 c c  c c $ c  c

1 cCJcc ccc cc ccc c $c c cc c  c c



c c

1 c3 ccc cc c cc ccc c $c c cc c  c c
 
c c

1 c c$c c cAc

c
è)cISR of serial interrupt

1 c cc   cc cc7c c c c7c c   c


1 c cc   cc ccc'0c cc c c c  c $  c
c $c c" cc"  c c c c9 c cc c c
 $ c c0c ccc cc  c c   c  c c
  c c c  "c

c
c
1 c c c'0c $c
c
3)cSubroutine for clockwise rotation.

c1 cJc$"c c c c c;cc


c c

1 c c$"c c c   c" c cc

'$  c" c

<c 0   c c $  c


7c c$ c c  c   c
c
&Ac cccccccc&Bc ccccc&cccccccccccc&+c ccccc&cccccccccc& c cccc&cccccccccc&c
,%c c c ,1c ,7c ,6c ,7c ,6c

c c Kc c c c c
c

c 3c c

<c  cc $  c

&Ac cccccccc&Bc ccccc&cccccccccccc&+c ccccc&cccccccccc& c cccc&cccccccccc&c


E c c:7c c c E c c:7c c c

c c c c c c c
c

c c c

7(&2L c

c
c
c

<1  c c $  c

c
&Ac cccccccc&Bc ccccc&cccccccccccc&+c ccccc&cccccccccc& c cccc&cccccccccc&c
1c 1c 1 c ',-c 7/Cc '/Cc 70c '0c

c c c c c c c
c

c c c c c

1(-c2Lc

c
+<c7 cc $  c c cc  @c cL>&cc  c cc cc3Bc cc
"c c c2cL>&c

PROGR~M:

('Ecc
.48c17%'7c
('Ec c
4-/c'0 c-67c
.'c'0c
()c% c1/#>c
4-,c% *DD %c
()c'0 *c
148c-67c
% c4-,c% c*D%D c% c
()c' c* c
148c-67c
% c4-,c% c*D D c%c
()c' c*c
148c-67c
c
c
% c4-,c% c*DD %+c
()c' c%c
()c% c'c
%&&c% c*c
()c' c%c
()c% c' c
4-c%c
0-c'+c
% c148c-67c
%+ c4-,c% *DD -67c
()c' c%c
()c% c'c
.'cc
1#//c% c*c
()c' c%c
()c% c' c
4-c-67c
&,c'+c
-67 c4-/c7 c-67c
.'c7c
-67 c',70c
('Eccc
.(!01, c()c' c*cc
17,8 c()c8 F'c
()cB c'c
()cA c'+c
%E%0c-c c()c+ c'Ac
%E%0- c&4-5c'+ c%E%0-c
&4-5c' c%E%0-cc
()c c'Bc
()c+ c'Ac
0-c'c
4-,c' c*+ c17,8c
',7c
('Ec c
c
c
%-70.(!01,c
()c' c*+c
17,8c c()c8 F'c
()cB c'c
()cA c'+c
%E%0-c c()c+ c'Ac
%E%0-c c&4-5c'+ c%E%0-c c
&4-5c' c%E%0-cc
()c c'Bc
()c+ c'Ac
0-c'c
4-,c' c*++c c17,8cc
',7c
('Ecc
17%'7 c()c' c*c
()c'+ c*c
()c' c*c
()cF' c*3cc
0-c'c
()cF' c*%cc
0-c'c
()cF' c*Bcc
0-c'c
()cF' c*cc
()c' c*+cc
()cF' c*cc
0-c'c
()cF' c*Bcc
0-c'c
()cF' c*%cc
0-c'c
()cF' c*3cc
()c1(- c*cc
()c7 c*>&cc
()c0, c*3c
c
c
()c7(& c* cc
1,7/c7'c
()c' c*c
,', c4-,c' c*c c/c
4-,c' c*c c/c
()c' c*c
/ c4-,c' c* c c/c
()c' c* cc
148c,',c
/ c4-,c' c* c/ c
4-,c' c*c c/+c
()c' c*cc
148c,',c
/+ c.%..c.(!01,c
148c,',c
/ c4-,c' c*  c,',c
4-,c' c*c c/c
()c' c*cc
148c,',c
/ c.%..c.(!01,c
148c,',c
,-&c
cc
c
c

c
c
Experiment no 11
c
~im:-Interfacing of D3 motor
~pparatus c
 c   c c c&c 

Theory:-
 c8 $  c
1 c c, c$ c c9   c   cc?cc
1 c c cc0-7c?c0-7c $ c cc c
1 c c, c  c c$ c   c
1 c+ c0c
c cc ; c c cc c
  c cc%cc c
. 3c cc c c %cc c!  c c c c  $c c cc
; c c c c  cc%c?c %cc c  $c  cc c c "c
cc c ccc c cc c "c8!c cc c  c
c
1 c c0c  
c cc ; c c cc c
  c cc %cc
c. 3c cc c c%cc c!  c c c c  $c c cc
; c c c c  cc%c?c %cc c  $c  cc c c "c
cc c ccc c cc c "c8!c cc c  c
c
1 cB cEc c c+c
è) ISR of INT 0.
1 c c!  c c c   cc c c c  cc c
 c
1 c c c   c $c
1 c c0  c c c c
c
c c  c
3)ISR of INT1
1 c c!  c c c   cc c c c  cc c
 c
1 c c c   c $c
1 c c0  c c c c
c
c c  c
'$  c) c
c
c
c
c

c
c
c
<c 0   c, c=0,<c'$  c
&Ac cccccccc&Bc ccccc&cccccccccccc&+c ccccc&cccccccccc& c cccc&cccccccccc&c
,%c c c ,1c ,7c ,6c ,7c ,6c

c c Kc c c c c
c

c
c Cc c
c cccccccccccccccccccccccccccc0,29Cc

PROGR~M:

('Ecc

.4#8c17%'7c

('Ecc

.4#8c#8c

('Ecc

.4#8c&(!-c

('Ecc

#8 c4-/c8 #8c

()c% 'Ac

%&&c% * cc

()c'A %c

.'c0,(c

',70c

('Ec c

&(!- c

c
c
4-/c8 &(!-c

()c% 'Ac

.'cc

1#//c% * cc

()c'A %c

.'c0,c

',7c0c

('Eccc

17%'7 c

()c&'A * Cc

()c0,c*Ccc

()c8 cc

,', c()c 8c

()c8 c

8.cc

()c8B c

()c'+ 'Ac

%E-%0-c c

&-45c'+ %E%0-cc

.'c8c

.'c8Bc

()c'+ 'Ac

()c% *>>cc
c
c
1#//c% '+c

()c'+ %c

%E%0-c c&4-5c'+ c%E%0- c

14#8c,',c

,-&c

c
c
c
c

c
c
c
c

c
c