How to setup KEIL uVision IDE for 8051 microcontroller

By | June 3, 2015

I think, you have decided to develop an 8051 project using KEIL uVision IDE (Integrated Development Environment). Are you searching for a beginners guide to setup KEIL for 8051? Then you are in right place. In this post, I am going to  show the detailed procedure to setup KEIL for 8051 derivatives, compilation and HEX file generation.

KEIL uVision4

What is KEIL IDE?

KEIL is a software application that provides extensive facilities for embedded application developers. It contains a source code editor, software debugger, assembler, cross compiler, simulator. It supports Embedded C and assembly programming for different microcontrollers such as 8051, ARM. On successful compilation of software, KEIL generates a HEX file that can be flashed to 8051 microcontrollers.

The Official link to Download KEIL uVision IDE for 8051 microcontroller

You can download KEIL from the above link or alternative download links are available in Google.  I’m using KEIL uVision 4 portable version.

Let’s create an 8051 project using KEIL uVision

Step 1: Create a project folder on your PC.  Later, You are going to store all your project files in this folder.

Step 2: Open KEIL uVision IDE

Step 3: Click  Project –> New uVision Project

Create new Keil uVision project

Step 4: Change path to project folder (step 1). Enter File name , click save

save the project

Step 5: A new popup window appears as shown below. Here you need to select your microcontroller. If you are using an ATMEL AT89S52 microcontroller, then find Atmel  in Data base and double click on it. You will see a list of Atmel controllers supported by KEIL.

select Atmel

Select AT89S52 under Atmel, click OK.

select AT89S52

step 6: Another popup window will appear saying “ Copy Standard 8051 Startup ……..”. Click No

Copy Standard 8051 Startup .. Click No

Step 7: Now go to File->New.

Create new source editor

Step 8: This is an important step. Here you need to save the file.

      • For Embedded C, file should save with extension ‘.c’.  Ex: test.c
      • For assembly code, file should be saved with extension ‘.asm’. Ex: test.asm

Save source file

Step 9: In this step you are going to  Add source files( .c or .asm ) to the project.

  • Locate project window on the right side of the KEIL IDE.
  • Then click  [+] symbol next to the Target 1.
  • Now right click on Source  Group 1, click Add Files to Group ‘Source Group 1’ .

add files to source group

New pop window appears as shown below.

  • Select ‘.c’ or ‘.asm’ project files (already created in step8)
  • Click Add  to add the source file and close the window

add files to 8051 KEIL project

Step 10: Now write the source code. Below I  wrote an example code.

8051 test code

Step 11: Once coding part is over, press F7 to build the project. You can also click Project->Buid target to build the project.  

Build the project

Step 12:  You can verify build log at the bottom of the KEIL IDE. In case of Errors and warnings modify the code and re-compile.

KEIL uVision buid log

Step 13: It’s time to generate a HEX file. Click Project-> Options for Target “Target 1” 

Options for target

A popup window appears as shown below,

  • Click Output (Highlighted).
  • Then, Select [✓]Create HEX file. Change the HEX file name if you want.

Hex File Generation

Step 14: Now build the project (Step 10). You can also rebuild the entire KEIL uVision project by  Clicking Project->Rebuild all target files.

Rebild KEIL project

You can find the hex file in the project folder.

KEIL project folder

You can flash HEX the file to 8051 microcontroller.

Share your feedback for further enhancements of the post.

Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *