Professional Documents
Culture Documents
(AUTONOMOUS)
INFORMATION TECHNOLOGY
NAME : __________________________
ROLL NO. : __________________________
LAB : __________________________
BRANCH : __________________________
LIST OF EXPERIMENT
1. AN 8051 ALP TO CLEAR A REGISTER AND ADD 3 TO IT TEN TIMES AND STORE
3. TOOGLE SWITCH
4. BLINKING LED’S
5. DANCING LED’S
6. LCD INTERFACING
7. SERIAL TRANSMISSION
8. SERIAL RECEPTION
9. TIMER 0 AS A COUNTER
USING RS232C
INDEX
3 TOOGLE SWITCH
4 BLINKING LED’S
5 DANCING LED’S
6
LCD INTERFACING
7
SERIAL TRANSMISSION
8 SERIAL RECEPTION
9
TIMER 0 AS A COUNTER
An 8051 ALP to clear a register and ADD 3 to it TEN times and store the result in memory
Aim: Write an 8051 ALP to a register and Add 3 to iy 10-times, and store the result in memory.
Procedure:
1. Write the assembly language for this task in the keil complier
3. Start the debug session by selecting the option from debug menu.
5. Observe the changes occur in registers after execution of each instruction by selecting the
6. We can see the contents of memory using memory window from view menu.
Program:
ORG 00H
CLR A
MOV 20H, #10
DEC @R0
MOV 30H, A
END
Output:
Result: The program for clearing a register and adding 3 to it 10 times is compiled and verified
Aim: To write a program to monitor door sensor and sound the buzzer when the signal is
Procedure:
1. Write the assembly language for this task in the keil complier and save it with “.C”
extension.
3. Start the debug session by selecting the option from debug menu.
7. Seeing the output reset the set the port1.1 and see the output
Program:
#include<reg51.h>
sbit dsensor=P1^1;
sbit buzzer=P1^7;
void main(void)
while(1)
if(dsensor==0)
buzzer=0;
delay(200);
else
buzzer=1;
delay(200);
{
int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++)
Output:
Result:
The program to monitor door sensor was successfully performed using keil software.
SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
DEPT. OF ECE
Experiment-3 DATE:
______________________________________________________________________________
TOOGLE SWITCH
Aim: To write a program in embedded to toggle all the bits of portB parts continuously with a
250ms delay.
Procedure:
1. Write the assembly language for this task in the keil complier and save it with “.C”
extension.
3. Start the debug session by selecting the option from debug menu.
7. Seeing the output reset the set the port1.1 and see the output
Program
#include<reg51.h>
void delay(void);
void main(void)
while(1)
P1=0x55;
delay();
P1=0xAA;
delay();
void delay(void)
int i,j;
for(i=0;i<10;i++)
for(j=0;j<1000;j++)
}
Output:
Result:
The program to toggle LED was successfully performed using keil software.
SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
DEPT. OF ECE
Experiment-4 DATE:
______________________________________________________________________________
BLINKING LED’S
Aim: To write a program in embedded to perform blinking LED’S using keil software
Procedure:
1. Write the assembly language for this task in the keil complier and save it with “.C”
extension.
3. Start the debug session by selecting the option from debug menu.
5. Connect the port p1. 1 to LED input (CN4) using 8 pin connector
7. Before seeing the output reset the device to communicate the peripherals
9. Reset the device to communicate with 8 pin connector to blink LED’s as per program.
10. Seeing the output reset the set the port1.1 and see the output
Program
#include<reg51.h>
sbit led=P1^0;
void delay(void);
void main(void)
while(1)
led=0;
delay();
led=1;
delay();
void delay(void)
int i,j;
for(i=0;i<10;i++)
for(j=0;j<1000;j++)
}
}
Output:
Result:
The blinking LED’s program was successfully performed using keil software.
SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
DEPT. OF ECE
Experiment-5 DATE:
______________________________________________________________________________
Dancing LED’S
Aim: To write a program in embedded to perform Dancing LED’S using keil software
Procedure:
1. Write the assembly language for this task in the keil complier and save it with “.C”
extension.
3. Start the debug session by selecting the option from debug menu.
5. Connect the port p1. 1 to LED input (CN4) using 8 pin connector
7. Before seeing the output reset the device to communicate the peripherals
9. Reset the device to communicate with 8 pin connector to blink LED’s as per program.
10. Seeing the output reset the set the port1.1 and see the output
Program
#include<stdio.h>
#include<reg51.h>
#include<math.h>
void main()
do
int i;
for(i=0;i<10000;i++)
P1=0x01;
for(i=0;i<10000;i++)
P1=0x02;
for(i=0;i<10000;i++)
P1=0x04;
for(i=0;i<10000;i++)
{
P1=0x08;
for(i=0;i<10000;i++)
P1=0x10;
for(i=0;i<10000;i++)
P1=0x20;
for(i=0;i<10000;i++)
P1=0x40;
for(i=0;i<10000;i++)
P1=0x80;
}
while(1);
Output:
Result:
The Dancing LED’S program was successfully performed using keil software.
SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
DEPT. OF ECE
Experiment-6 DATE:
______________________________________________________________________________
LCD INTERFACING
Aim: To write a program in embedded to write in LCD IN 8051 development kit using keil
software
Procedure:
1. Write the assembly language for this task in the keil complier and save it with “.C”
extension.
3. Start the debug session by selecting the option from debug menu.
6. Connect the pin p2.0, p2.1, p2.2 to the enable read/write and reset respectively in the
LCD module.
7. Before seeing the output reset the device to communicate with other peripheral.
Program
#include <reg51.h>
#include <string.h>
en = 1; // strob LCD
en = 0;
en = 1; // strob LCD
en = 0;
void busy()
en = 0; // disable display
while(b==1)
en=1;
en=0;
s++;
main()
P2=0x00;
writecmd(0x0E);
writestr("Program");
Output:
Result:
The message is displayed in the LCD was successfully performed using Keil µ vision and
SERIAL TRANSMISSION
Aim: To write a program for the 8051 to transfer the letter ‘A’ serially with a baud rate of 9600
Procedure:
1. Write the assembly language for this task in the keil complier and save it with “.C”
extension.
3. Start the debug session by selecting the option from debug menu.
5. Set the device 89V51RD2 using COM1 port with baud rate of 9600.
7. Browse the program hex file location and select the program to dump to µc.
8. If the option comes like “Reset the device into ISP mode” press the reset button in 8051
development board.
12. After pressing RESET key the device receives the character to hyper terminal using serial
port RS232.
PROGRAM
#include<reg51.h>
void main(void)
SCON=0x50;
TR1=1;
while(1)
sertx(‘Y’);
sertx(‘E’);
sertx(‘S’);
SBUF=x;
while(TI==0);
TI=0;
Output:
Result: Therefore, Sending a character serially was successfully performed using Keil µvision
SERIAL RECEPTION
Aim: To write a C language program to perform serial reception in development board using keil
µvision
Procedure:
1. Write the assembly language for this task in the keil complier and save it with “.C”
extension.
3. Start the debug session by selecting the option from debug menu.
5. Set the device 89V51RD2 using COM1 port with baud rate of 9600.
7. Browse the program hex file location and select the program to dump to µc.
8. If the option comes like “Reset the device into ISP mode” press the reset button in 8051
development board.
12. After pressing RESET key the device receives the character to hyper terminal using serial
port RS232.
SERIAL RECEPTION
PROGRAM
#include<reg51.h>
sfr lcddata=0x90;
sbit rs=P3^4;
sbit rw=P3^3;
sbit en=P3^2;
sbit s=P2^1;
for(i=0;i<=a;i++)
for(j=0;j<=125;j++)
{}
}
lcddata=dost;
rs=0;
rw=0;
en=1;
delay(5);
en=0;
lcddata=word;
rs=1;
rw=0;
en=1;
delay(5);
en=0;
void delete1()
command(0xc0+cnt1);
command(0x10);
lcddisplay(0x20);
cnt1--;
command(0x10);
void delete()
command(0x80+cnt);
command(0x10);
lcddisplay (0x20);
cnt--;
command(0x10);
void main()
command(0x38);
command(0x0e);
command(0x80);
while(1)
TMOD=0x20;
TH1=0xfd;
SCON=0x50;
TR1=1;
while(RI==0);
m=SBUF;
RI=0;
if(m==0x80)
if(cnt>0)
if(cnt!=0)
delete1();
else
f=0;
delete();
else
if(m==0x0d)
command(0xc0);
cnt++;
f=1;
else
if(cnt==-1)
command(0x80);
cnt++;
if(cnt==16&&f==0)
command(0xc0);
f=1;
command(0x60);
lcddisplay(m);
if(f==0)
cnt++;
else
{
cnt1++;
Output:
Result: Thus, the serial reception was performed successfully by using keil µvision and
hyperterminal.
SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
DEPT. OF ECE
Experiment-9 DATE:
______________________________________________________________________________
TIMER 0
Apparatus required:
Procedure:
4. Move the data for counting and giving the time to that data.
6. Finally the result is stored that is displayed on the Cathode Ray Oscilloscope.
Program:
MOV TMOD,#01H
CLR TR0(8C)
CLR TF0
MOV TH0,#0FFH
MOVTL0,#1AH
SETB TR0
BACK1:MOV C,TF0
JNC BACK1
CLR P1.6
CLR TR0
CLRTF0
MOV TH0,#0FDH
MOV TL0,#04DH
SETB TR0
BACK2:MOV C,TF0
JNC BACK2
SJMP NEXT
(SQUARE WAVE)
MOV TMOD,#03H
BACK1:CLR TR1
CLR TF1
MOV TH0,#04AH
SETB TR1
BACK2:MOV C,TF1
JNC BACK2
MOV C,P1.5
CPL C
MOV P1.5,C
SJMP BACK1
Output
Rectangular wave:
Amplitude=
Time period=
T=
Frequency=
Square wave:
Amplitude=
Time period=
T=
Frequency=
Result:
Thus, the program to use Timer `0` as counter has been verified successfully