Embedded Controller 8051 C Lab Manual
Embedded Controller 8051 C Lab Manual
B. Sc Vth Semester
Keil provides a code limited (2K bytes) evaluation version for 8051
architecture (C51) which is sufficient for learning purposes.
Keil uVision IDE (Evaluation Version) can be downloaded using this link.
On Clicking the above link you will be redirected to Keil Website Download
section.
After you have installed the Keil uVision tools for 8051, Double click on the
Keil icon on your Windows Desktop to launch the IDE.
To create a new 8051 project using Keil IDE, Click on the ' Project ' item on
the IDE Menu bar and select ' New uVision Project... 'as shown in the above
image.
Now create a Folder to store your project and give a name to your Project
files (*.uvproj), for eg Test (Test.uvproj).
Keil has support for a wide variety of 8051 derivatives on its IDE.The 8051
derivatives are organised according to their manufacturer's.
On selecting the particular microcontroller the Keil IDE also displays the
features of the selected microcontroller on its left pane .You can Click OK to
confirm your choice.
Step 4:
Now your Project pane on the Kiel IDE would look something like this
(above image)
Right Click on the Source Group 1 folder on your Project pane and
select Add New Item to Group 'Source Group1'...
Step 7:
Now you can select the type to add to your project. Select C File(.c) and
give it a name (here main.c) and Click Add.
After you have typed out the above c program to your main.c file,You can
compile the C file by pressing F7 key or by going to ' Project -> Build
Target ' on the IDE menu bar.
Step 9: If there are no errors the code will compile and you can view the output
on the Build Output panel.
# include<reg51.h>
void main(void)
Acc = 0x25;
#include<reg51.h>
void main(void)
unsigned char z;
P1=z;
#include<reg51.h>
void main ( )
for ( ; ; )
P1=0x55;
P1=0xAA;
4. Write a program to load three numbers into Accumulator and send them to port
# include <reg51.h>
void main( )
ACC = 0x25;
P1 = ACC;
ACC = 0x46;
P1 = ACC;
ACC = 0x92;
P1 = ACC;
}
GFGC Shikaripura Department of Electronics
5. Write a 8051 c program to add array of 16bit numbers and store the 16bit result in the
internal RAM
#include <reg51.h>
#include<stdio.h>
void main(void)
for(i=0;i<=5;i++)
sum=sum+array[i];
P1 = sum;
#include <reg51.h>
#include<stdio.h>
void main(void)
for(i=0;i<=5;i++)
P0=array[i];
#include <reg51.h>
void main(void)
for(num=0;num<=10;num++)
P0=square;
while(1);
#include <reg51.h>
#include <stdio.h>
void main(void)
SCON = 0x50;
TMOD = 0x20;
TH1 = 0xFD;
TR1 = 1;
TI = 1;
while(1)
printf("Hi Microcontroller");
#include <reg51.h>
void main(void)
hexa = hexa/10;
P0 = B;
units = B;
hexa = hexa/10;
hundreds = ACC;
tens = B;
P1 = B;
P2 = ACC;
while(1);
LED = 0; // LED ON
Delay();
Delay();
void Delay(void)
int j;
int i;
for(i=0;i<10;i++)
{
for(j=0;j<10000;j++)
}
}
GFGC Shikaripura Department of Electronics
GFGC Shikaripura Department of Electronics