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.
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.
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
Step 4: Change path to project folder (step 1). Enter File name , click save
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 AT89S52 under Atmel, click OK.
step 6: Another popup window will appear saying “ Copy Standard 8051 Startup ……..”. Click No
Step 7: Now go to File->New.
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
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’ .
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
Step 10: Now write the source code. Below I wrote an example 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.
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.
Step 13: It’s time to generate a HEX file. Click Project-> Options for Target “Target 1”
A popup window appears as shown below,
- Click Output (Highlighted).
- Then, Select [✓]Create HEX file. Change the HEX file name if you want.
Step 14: Now build the project (Step 10). You can also rebuild the entire KEIL uVision project by Clicking Project->Rebuild all target files.
You can find the hex file in the project folder.
You can flash HEX the file to 8051 microcontroller.
Share your feedback for further enhancements of the post.