Indian Institute of Information Technology Bhagalpur-813210: Microprocessor & Interfacings Lab
Indian Institute of Information Technology Bhagalpur-813210: Microprocessor & Interfacings Lab
TECHNOLOGY BHAGALPUR-813210
ss ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
CERTIFICATE
This is to certify that Mr. SHEELAJ BABU bearing Institute Roll No.
180101041 has satisfactorily completed the course in Microprocessor &
interfacings (EC216) during the academic year 2020-2021.
DATE :22/05/2020
PLACE:IIIT,BHAGALPUR
Dr. Suraj
Assistant Professor,(ECE)
IIIT, Bhagalpur-813210
contents:-
2
EXPERIMENT- 01
Toggle LEDs connected at Port P1. 9
1.1 AIM : 9
1.2 Program : 9
1.5 Conclusion 10
EXPERIMENT- 02
Toggle LEDs connected to the port P1, from right to left, keeping previous LEDs off. 11
2.1 AIM : 11
2.2 Program : 11
2.5 Conclusion 12
EXPERIMENT- 03
Toggle LEDs connected to the port P1, from left to right, keeping previous LEDs on. 13
3
3.1 AIM : 13
3.2 Program : 13
3.6 Conclusion 10
EXPERIMENT- 04
Toggle LED with delay of 500 ms connected at port P1.1: Use of Software delay 10
4.1 AIM : 10
4.2 Program : 10
4.5 Conclusion 12
EXPERIMENT- 05
5.2 Program : 18
5.5 Conclusion 19
EXPERIMENT- 06
6.1 AIM : 20
6.2 Program 20
6.5 Conclusion 21
EXPERIMENT- 07
Hardware delay using interrupt (use auto-reload mode) 22
7.1 AIM : 22
5
7.2 Program 22
7.6 Conclusion 24
EXPERIMENT- 08
8.1 AIM : 25
8.2 Program 25
8.6 Conclusion 26
EXPERIMENT- 09
Display 0 to 9 using seven segment display 15
6
9.1 AIM : 15
9.2 Program 15
9.6 Conclusion 17
EXPERIMENT- 10
10.1 AIM : 15
10.2Program 15
10.6 Conclusion 17
EXPERIMENT- 11
7
11.1 AIM : 15
11.2Program 15
11.6 Conclusion 17
8
1.1 AIM :
Toggle the LEDs connected at alternate pin of the port P1.
1.2 PROGRAM:
// Header:-Simple on-off blinking
// Author:SHEELAJ BABU
// Date:17-jan-2020
void main()
for(index=0;index<10000;index++);// delay
for(index=0;index<10000;index++);// delay
:0C082700787FE4F6D8FD75810702080018
:10080000758055E4FFFE0FBF00010EBE27F8BF1034
:10081000F57580AAE4FEFFC3EF9410EE942750E034
:070820000FBF00010E80F084
:00000001FF
9
1.4 SIMULATED OUTPUT:
1.5 CONCLUSION:
Thus We Have got Simple on off blinking is implemented using (01010101) 2=(55)16
and (10101010)2=(AA)16 .
2.1 AIM :
Right to left blink shifting with the use of shifting operator and previous LEDs off.
2.2 PROGRAM :
// Header: Right to left blink shifting
// Date: 03-Feb-2020
#include <reg51.h>
for(index2=0;index2<10000;index2++);
void main()
P1=0x01;
delay();//Calling Delay
delay();//Calling Delay
11
:0300000002083CB7
:0C083C00787FE4F6D8FD75810702080003
:10081F00E4FFFEE4FDFC0DBD00010CBC27F8BD108C
:0C082F00F50FBF00010EEF64C84E70E72B
:01083B00229A
:10080000759001E4FBFA12081FE59025E0F59012BF
:0F081000081F0BBB00010AEB64074A70E980E187
:00000001FF
2.5 CONCLUSION:
So in this experiment we have to (Right to left) blink shifting is implemented.The idea of using for loop is
clearly now .
12
-: Toggle LEDs connected to the port P1, from left to right,
keeping previous LEDs on.:-
3.1 AIM:
left to right blink shifting with the use of shifting operator and previous LEDs on.
3.2 PROGRAM:
// Header: Left to Right blink shifting with previous led on
// Date: 10-Feb-2020
#include <reg51.h>
for(index2=0;index2<10000;index2++);
void main()
P1=0x80;
delay();//Calling Delay
P1=(P1>>1)+0x80;//Shifting the Value one bit to right keeping previous led on.
delay();//Calling Delay
13
3.3 HEX CODE:
:0300000002083EB5
:0C083E00787FE4F6D8FD75810702080001
:10082100E4FFFEE4FDFC0DBD00010CBC27F8BD108A
:0C083100F50FBF00010EEF64C84E70E729
:01083D002298
:10080000759080E4FBFA120821E590C3132480F56B
:10081000901208210BBB00010AEB64074A70E780C5
:01082000DFF8
:00000001FF
14
3.5 HARDWARE INTERFACED OUTPUT:
3.6 CONCLUSION:
In this experiment we have implemented Left to Right blink shifting with previous led
on.
15
-:Toggle LED with delay of 500 ms connected at
port P1.1: Use of Software delay:-
4.1 AIM:
Toggle LED with delay of 500ms connected at p1.1:-using software delay.
4.2 PROGRAM :
// Header: Specified delay by software
// Date: 03-Feb-2020
void main()
for(index=0;index<3000;index++);// delay
for(index=0;index<1500;index++);// delay
16
4.4 SIMULATED OUTPUT:
4.5 CONCLUSION:
Port output confirms that led is toggling . Further delay is measured which is 500ms. So
required condition is successfully completed.
// Author:SHEELAJ BABU
// Date: 1-May-2020
//org0h
Suraj:
RET; Return
END;End of Program
18
5.5 CONCLUSION:-
In This experiment the Square wave is generated with 50% duty cycle using delay of timer 0
in mod 1.
// Author:SHEELAJ BABU
// Date: 01-May-2020
CLR TR0
CLR TF0
SJMP AGAIN
END
:10000000758902758CFFD28C308DFDC28CB2A3C273
:030010008D80F0F0
:00000001FF
20
Port output to check square bit is fluctuating or not for the confirmation of production of
square wave.
Timer out to check wether timer 0 in auto reload mode is set up or not.
6.5 CONCLUSION:-
Finally the Square wave is successfully generated with 50% duty cycle using delay of timer 0
in mod 2.
7.1 AIM :
Write an ALP that continuously read 8 bit data from Port 2 and send the data to Port 0.At the same time it
should generate square wave 0f 500 micro seconds period on pin P1.0.Assume crystal frequency is 11.0592
MHz.
Interrupt Vector Location
--------------------------------------------------------------------------
~INT0 0003H
TF0 000BH
INT1 0013H
// Author:SHEELAJ BABU
// Date: 01-May-2020
ORG0000H
END
22
7.3 HEX CODE:
:06000000759000020020D3
:10001B00B290C28F3275892075A0FF758D1A75A8A5
:09002B0088D28EE5A0F58080FA70
:00000001FF
Timer output:
23
Interupt peripheral output:
7.5 CONCLUSION:-
In this experiment the Square wave of specified time period 500 micro sec is generated with
50% duty cycle using timer 1 in auto reload mode.Also port 2 ad 0 data are same which
confirms that data from port2 is read and sended to port 0 succesfully.
Timer peripherals further confirms that timer 1 is used in auto reload mode(mode
2).Interupt peripheral shows that interrupt is enabled.
24
-:Generation of PWM wave of specified frequency and duty
cycle:-
8.1 AIM :Generate a PWM Wave of 14.68Hz and 70% duty cycle at P1.1 .
8.2 PROGRAM:
// Header: Pwm wave with specified duty cycle and frequency.
// Date: 06-May-2020
# include <reg51.h>
int index=0;
sbit x =P1^1;
void main()
TR0=1;//makes timer 0 on
x=1;//sets x
while(1)//infinite loop
x=0;
x=1;
index=0;
index++;//increments x
25
}
8.5 CONCLUSION:
In this experiment we have ,Pwm wave is successfully generated with 14.68Hz frequency and
70% duty cycle. Further fluctuating port1.1 output confirms the generation of pwm wave.
26
-: Display 0 to 9 using seven segment display:-
9.1 AIM :
Program to display 0 to 9 using seven segment display .
9.2 PROGRAM:
//AUTHOR-SHEELAJ BABU
//ROLL-180101041
//BRANCH-CSE
#include<reg51.h>
sbit x=P2^7;
sbit y=P2^6;
sbit z=P2^5;
void delay(void);
unsigned int i,j,seg=0;
void main()
{
unsigned char
disp[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
while(1)
{
k:
if(seg==0)
{
x=0;
y=0;
z=0;
}
if(seg==1)
{
x=0;
y=0;
z=1;
}
if(seg==2)
{
x=0;
y=1;
z=0;
}
if(seg==3)
{
x=0;
y=1;
z=1;
}
if(seg==4)
{
seg=0;
27
goto k;
}
for(i=0;i<10;i++)
{
P0=disp[i];
for(j=0;j<1000;j++)
{delay();}
}
seg++;
}
}
void delay(void)
{
TMOD=0x01;
TL0=0xFB;
TH0=0xF3;
TR0=1;
while(TF0==0);
TF0=0;
TR0=0;
}
28
9.3 HEX CODE:
:0308AE000108003E
:10088C0075890275A882758CE1D28CAF087E00EF59
:10089C0064467002C291EF64644E70EFD291F50819
:0208AC0080E9E1
:03000B000208B236
:0308B20005083204
:03000000020800F3
:0C080000787FE4F6D8FD758108020847F7
:10080C0002088CE493A3F8E493A34003F68001F26E
:10081C0008DFF48029E493A3F85407240CC8C333ED
:10082C00C4540F4420C8834004F456800146F6DFBC
:10083C00E4800B01020408102040809008AEE47E96
:10084C00019360BCA3FF543F30E509541FFEE493B1
:10085C00A360010ECF54C025E060A840B8E493A378
:10086C00FAE493A3F8E493A3C8C582C8CAC583CAA3
:10087C00F0A3C8C582C8CAC583CADFE9DEE780BE5B
:0108B1000046
:00000001FF
9.5 CONCLUSION:-
We used four 7 segment LED displays to continuously display series of
numbers from 0 to 9. We kept shifting this series from first segment to
last segment.
29
-:Design of digital voltmeter: Application of ADC:-
10.1 AIM :
Write a program to design of ADC.
10.2 PROGRAM:
// Header: Digital voltmeter.
// Date: 06-May-2020
#include <reg51.h>
#include <intrins.h>
#define display_port P0
sbit ALE=P3^1;
sbit EOC=P3^2;
sbit OE=P3^3;
sbit SOC=P3^4;
sbit CS_A=P3^5;
sbit CS_B=P3^6;
sbit CS_C=P3^7;
unsignedinta,b,c,d,e,f,g,h,i,j,k,V[5];
void ADC_INI(void);
sbit RS=P2^7;
sbit RW=P2^6;
sbit EN=P2^5;
voidlcd_ini(void);
voidlcd_cmd(unsignedchar command);
voidlcd_data(unsignedchardispdata);
void main()
30
ADC_INI();
while(1)
ADC_INI();
ADC_READ();
void ADC_INI()
P1=0xFF;
ALE=0;
SOC=0;
OE=0;
EOC=1;
delay(1);
//return;
CS_A=0;
CS_B=0;
CS_C=0;
ALE=1;
SOC=1;
ALE=0;
SOC=0;
delay(1);
while(EOC==1);
OE=1;
a=P1;
OE=0;
calculate(a);
//return;
31
}
void calculate(unsignedint u)
h=2500/255;
b=u*h;
V[0]=b/1000+0x30;
c=b%1000;
V[2]=c/100+0x30;
d=e%100;
V[3]=e/10+0x30;
f=e%10;
V[4]=f+0x30;
DISP_LCD();
//return;
lcd_ini();
lcd_cmd(0x80);
for(i=0;i<7;i++)
lcd_data(z[i]);
delay(500);
lcd_cmd(0xC0);
for(i=0;i<5;i++)
if(i==1)
lcd_data('.');
else
lcd_data(V[i]);
delay(500);
//return;
32
}
voidlcd_cmd(unsignedchar command)
P0=command;
RS=0;
RW=0;
EN=1;
EN=0;
voidlcd_data(unsignedchardispdata)
P0=dispdata;
RS=1;
RW=0;
EN=1;
EN=0;
voidlcd_ini(void)
lcd_cmd(0x38);
lcd_cmd(0x0F);
lcd_cmd(0x01);
for(j=0;j<t;j++)
for(k=0;k<1000;k++)
{}
33
10.3 HEX CODE:
:03000000020B11DF
:0C0B1100787FE4F6D8FD75812E020B1DE4
:070B2800564F4C54414745B4
:0B0B1D00120ACC120ACC120A6280F807
:100ACC007590FFC2B1C2B4C2B3D2B27F017E000234
:020ADC000A9E70
:100A6200C2B5C2B6C2B7D2B1120A9AD2B4120A9AA7
:100A7200C2B1120A9AC2B4120A9A20B2FD120A9A9A
:100A8200D2B3120A9AAF907512008F13120A9AC249
:080A9200B3AF13AE1202095DBF
:10095D00752000752109AC20AD211208F68E148F7B
:10096D00157C037DE8120908EF2430F509E43EF506
:10097D0008AE14AF157C037DE81209088C168D178F
:10098D00AE16AF177C007D64120908EF2430F50D0B
:10099D00E43EF50CAE1AAF1B7C007D641209088C89
:1009AD00188D19AE1AAF1B7C007D0A120908EF24B1
:1009BD0030F50FE43EF50EAE1AAF1B7C007D0A122A
:1009CD0009088C1C8D1DE51D2430F511E4351CF531
:0409DD00100209E11A
:1009E10078287C007D007BFF7A0B79287E007F07C9
:1009F1001208D0120B027F80120ADEE4F522F523E1
:100A010074282523F8E6FF120AF07FF47E01120A0A
:100A11009E0523E52370020522C39407E522940075
:100A210040DE7FC0120ADEE4F522F523E5236401EE
:100A3100452270077F2E120AF08014E52325E02459
:100A410008F808E6FF120AF07FF47E01120A9E05FB
:100A510023E52370020522C39405E522940040CCCE
:010A61002272
:100ADE008F80C2A7C2A6D2A57F0A7E00120A9EC22E
:020AEE00A5223F
:100AF0008F80D2A7C2A6D2A57F0A7E00120A9EC20C
:020B0000A5222C
:0F0B02007F38120ADE7F0F120ADE7F01020ADE41
:040A9A007F017E005A
:100A9E00E4F524F525C3E5259FE5249E501FE4F5D6
:100AAE0026F5270527E52770020526B4E8F5E52685
:0E0ABE00B403F00525E52570DC052480D82260
:10080000E709F608DFFA8046E709F208DFFA803EDA
:1008100088828C83E709F0A3DFFA8032E309F608C7
:10082000DFFA8078E309F208DFFA807088828C832F
:10083000E309F0A3DFFA806489828A83E0A3F608E3
:10084000DFFA805889828A83E0A3F208DFFA804CBD
:1008500080D280FA80C680D4806980F28033801094
:1008600080A680EA809A80A880DA80E280CA8033FD
:1008700089828A83ECFAE493A3C8C582C8CCC58375
:10088000CCF0A3C8C582C8CCC583CCDFE9DEE78045
:100890000D89828A83E493A3F608DFF9ECFAA9F0C4
:1008A000EDFB2289828A83ECFAE0A3C8C582C8CC1A
:1008B000C583CCF0A3C8C582C8CCC583CCDFEADE33
:1008C000E880DB89828A83E493A3F208DFF980CC95
:1008D00088F0EF60010E4E60C388F0ED2402B4048E
:1008E0000050B9F582EB2402B4040050AF23234535
:0608F00082239008507302
:1008F600EF8DF0A4A8F0CF8CF0A428CE8DF0A42E16
:02090600FE22CF
:10090800BC000BBE0029EF8DF084FFADF022E4CCD3
:10091800F875F008EF2FFFEE33FEEC33FCEE9DEC9C
:10092800984005FCEE9DFE0FD5F0E9E4CEFD22EDE2
:10093800F8F5F0EE8420D21CFEADF075F008EF2F2C
:10094800FFED33FD4007985006D5F0F222C398FD1D
:050958000FD5F0EA22BA
:00000001FF
34
10.4 HARDWARE INTERFACED OUTPUT:
10.5 CONCLUSION:
Finally We have successfully implemented Digital voltmeter.
35
-:Interfacing of servo motor:-
11.1 AIM :
Implement Interfacing of servo motor with 8051 microcontroller.
// Date: 29-May-2020
MAIN:
RET
36
CLR P2.0 ;Make P2.0 LOW
RET
RET
RET
LOOP3:DJNZ R2,LOOP3
DJNZ R3,LOOP2
DJNZ R4,LOOP1
37
RET
END
11.5 CONCLUSION:
Servo motor is interfaced with 8051 microcontroller successfully and works according to
instructions given by the 8051 microcontroller.
38
39
CERTIFICATE
40