Open In App

How to Create a Project in Keil Microvision Software?

Last Updated : 24 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

A Keil Microvision software is an IDE for executing assembly language programs and embedded c programs you can create a hex file in Keil Microvision software, that’s why it is the best software for creating projects that are related to hex files such as LCD Interfacing, Stepper motor interfacing, traffic light system and projects related with robotics because in all of these projects we need a hex file of programs, after loading this hex file in IC and by inserting this IC in hardware kit you can run your project. in this article, you are going to create a demo project step by step in Keil Microvision software. 

Creating a Project in Keil Microvision Software

Let’s create a traffic light system project step by step:

Step 1: Open your Keil Microvision software, click on project select new Microvision project.

Open-your-Keil-Microvision-software

Step 2: Give a proper name to your project and save it with extension .c  because in this demo project we are using embedded c language.

Give-a-proper-name-to-your-project

Step 3: Now select a microchip AT89S52 and click on ok.

Select-a-microchip-AT89S52

Step 4: A project window will get open on the right side you will see target 1 click on that and then double click on source group 1, then select your previously saved file and add it to the source group and close it. 

 Click-on-source-group

Step 5: Now double click on the file that is visible below the source group 1, a plain text area will get open.

Opening-plain-text-area

Step 6: Type your program in the plain text area and then click on build for checking errors then click on rebuild.

Enter-the-program

 

Here is the source code for the traffic light system. This source code is in embedded c language

C




// C program for traffic light system
#include<reg51.h>
void delay(int);
void delay(int itime);
void main()
{
    P0 = 0x00; //Clears content of port0
    P1 = 0x00; //Clears content of port1
    while(1)
    {
        P0 = 0xDB; //First route is open for traffic flow
        P1 = 0xDE; //First route is open for traffic flow
        delay(1000); // Long delay
          
        P0 = 0xDD; //First route switching for traffic flow
        P1 = 0xDE; //First route switching for traffic flow
        delay (100); // short delay
          
        P0 = 0xF6; // Second route is open for traffic flow
        P1 = 0xDE; // Second route is open for traffic flow
        delay(1000); // Long delay
          
        P0 = 0xEE; // Second route is open for traffic flow
        P1 = 0xDE; // Second route is open for traffic flow
        delay(100); // short delay
          
        P0 = 0xDE; // Third route is open for traffic flow
        P1 = 0xDB; // Third route is open for traffic flow
        delay(1000); //Long Delay
          
        P0 = 0xDE; // Third route is open for traffic flow
        P1 = 0xDD; // Third route is open for traffic flow
        delay(100); // Short Delay
        
        P0 = 0xDE; // Fourth route is open for traffic flow
        P1 = 0xF6; // Fourth route is open for traffic flow
        delay(1000); // Long Delay
          
        P0 = 0xDE; // Fourth route is open for traffic flow
        P1 = 0xEE; // Fourth route is open for traffic flow
        delay(100); // short delay
    }
}
void delay(int itime)
{
    int i,j;
    for(i = 0; i < itime; i++)
    for(j = 0; j < 2000; j++);
}


Step 7: Click on debug start debug section, for checking your code is running or not click on peripherals select input-output ports that you use in your program.

 Click-on-debug-start-debug-section

 

Step 8: Click on debug and run the program you will see some changes in the ports that you selected which means your code is correct and running perfectly.

Click-on-debug-and-run-the-program

Step 9: Now click on the project select option for targets, 

Click-on-the-project-select-option-for-targets

Step 10: Write the Xtal frequency as 11.0592 

Enter-Xtal-frequency-as-11.0592

Step 11: Now click on the output for selecting the folder for keeping your hex file, select folder, and then click on create HEX file and press ok.

Click-on-create-HEX-file

Step 12: Again build and rebuild your program, you will get a message creating a HEX file.

 Creating-a-HEX-file

Step 13: Check created hex file on the folder that you have selected previously you didn’t understand anything in created hex file for giving this traffic light system project live you need to transfer this hex file to the microprocessor (8051) then you need to attach this microprocessor chip to the hardware kit of traffic light system.

Here is the source code for traffic light system:

Note: This source code is in embedded c language

C




#include<reg51.h>
void delay(int);
void delay(int itime);
void main()
{
P0=0x00; //Clears content of port0
P1=0x00; //Clears content of port1
while(1)
{
 P0=0xDB; //First route is open for traffic flow
 P1=0xDE; //First route is open for traffic flow
 delay(1000); // Long delay
   
 P0=0xDD; //First route switching for traffic flow
 P1=0xDE; //First route switching for traffic flow
 delay (100); // short delay
 P0=0xF6; // Second route is open for traffic flow
 P1=0xDE; // Second route is open for traffic flow
 delay(1000); // Long delay
 P0=0xEE; // Second route is open for traffic flow
 P1=0xDE; // Second route is open for traffic flow
 delay(100); // short delay
 P0=0xDE; // Third route is open for traffic flow
 P1=0xDB; // Third route is open for traffic flow
 delay(1000); //Long Delay
   
 P0=0xDE; // Third route is open for traffic flow
 P1=0xDD; // Third route is open for traffic flow
 delay(100); // Short Delay
 P0=0xDE; // Fourth route is open for traffic flow
 P1=0xF6; // Fourth route is open for traffic flow
 delay(1000); // Long Delay
   
 P0=0xDE; // Fourth route is open for traffic flow
 P1=0xEE; // Fourth route is open for traffic flow
 delay(100); // short delay
}
}
void delay(int itime)
 {
 int i,j;
for(i=0;i<itime;i++)
for(j=0;j<2000;j++);
}




Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads