Académique Documents
Professionnel Documents
Culture Documents
TOGGLE 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.
2.Flashing a light by a software delay
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 flashing LED’s program was successfully performed using keil software.
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.
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;
}
void writestr(unsigned char *s)
for(i=1;i<l;i++)
s++;
main()
P2=0x00;
writecmd(0x0E);
writestr("Program");
Output:
Result: The message is displayed in the LCD was successfully performed using Keil µ vision
4.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.
10. Go to the hyper terminal, name the connection COM1 port with baud rate of 9600 with
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
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.
10. Go to the hyper terminal, name the connection COM1 port with baud rate of 9600 with
12. After pressing RESET key the device receives the character to hyper terminal using serial
port RS232.
SERIAL RECEPTION
PROGRAM
#include<reg51.h>
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.
5.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=
Output:
Result:
Thus, the program to use Timer `0` as counter has been verified successfully