,

How to use keil software for 8051

1) As you will open Keil software , you will see following screen:

keil1

 

2) Create new project as shown below:

keil2

 

3) Name it. Make sure that you already have made the separate folder to minimize confusion of new project files with old ones. New folder will keep all files related to only to one project hence making it easy to locate files you need afterwards.

keil3

 

4) Select chip manufacturer, in our case Atmel then select chip model i-e AT89c51

keil4

 

keil5

 

5) Software will ask you whether to include 8051 start up code, select YES.

keil6

 

6) This is how you working environment should look like till now:

keil7

 

6) As new project folders are created, now it is time to create a text file which will include your assembly code. Go to file drop down menu and select “New” or simply click blank paper icon in file toolbar.

keil8

 

keil9

 

7) Write your code in the new white work space that just has been created.

keil10

 

keil11

8) It’s time to save your C code file now.
Go to file drop down menu and select save. Save the file into your main project folder.

keil12

 

NOTE: SAVE FILE WITH .C EXTENSION AS OUR CODE IS IN C LANGUAGE.

 

As you will save the file, the software will detect the .C language keywords and they become colorful to make them prominent from rest of code.

keil12

 

 

9) Now you have to add .C code file to your project. Right click on the source group folder (sub-folder of main target1 folder) and select “Add files to group (source group)”

keil13

 

10) A small window will appear asking you for location of your .C code file. Give it the path of wherever you have saved your file, it should be in your project folder. Select the file click “Add”.

keil14

keil15

 

11) You may check the .C file by clicking on the little plus sign at the left of source group.

keil16

12) There are some configuration changes that you have to make before you build the final .HEX file.

keil17

 

-In target tab set the frequency that you are using with 8051, in our case 12MHz. So change default value 24.0MHz to 12Mhz

keil18

 

-In output tab check the “Create HEX file” box otherwise HEX file will not be created.

After all these settings click OK.

keil19

 

13) It’s now time to get final output that HEX file.

Right click on .C file which is in source group folder and select “Build target”.

keil20

 

14) If there are no errors in code your code will be compiled in couple of seconds showing progress in window at the bottom.

If there are errors in code then they will also be mentioned in same bottom window with number of line that contains error. You may recheck that line rectifying the mistake(s).

keil21

 

15) After successful compilation of code you can find final HEX file in same project folder that contains main project file/.C file/other files.

keil22