How to write a program for 8051 using Keil Compiler


Summary

Keil uVision is the IDE for the 8051, ARM and Cortex family controllers. In this tutorial, we will guide how to compile a program for 8051 using Keil.

Let’s Code with Keil

Step-1:

For demo we will compile the program of LED Blinking.

Create a folder “LED_BLINK”. Create two sub-folders as shown in below image. One folder will be used for Program and another one will be used for Schematic.

Step-2:

To write a program, we will use Keil uVision3 (Other versions also have similar procedure with minor or no changes). Open the software from the installed directory.

Step-3:

Click on Project > Close Project to close previously created project (if any).

Step-4:

Create a new project from the option Project > New uVision Project

Step-5:

Provide a name of the project and path of the location where you want to create it.

Step-6:

Select your micro-controller. You can select Intel > 8051AH for all basic applications. Select controller and click on OK.

Step-7:

Keil will ask whether to add STARTUP.A51 file or not. This file is required for “C” programming. So click on YES to add the file to the Source Group.

Step-8:

Create a file to write our program from File > New Menu or use Ctrl+N Shortcut.

Step-9:

Save the file name with .c extension. For e.g. LED_BLINK.c

Step-10:

Write the program and save the file. (Program is available in code section).

Step-11:

Add the .c file to group source. For that Right click on Source Group1 > Add Files to Group ‘Source Group 1’

Step-12:

Browse the required .c file and click on ADD.

Step-13:

Click on Build target from Toolbar or Press F7 Key.

Step-14:

At bottom of the screen, check the result of build operations. Corrects the errors if any.

Step-15:

Go to Options For Target1 > Output.

Step-16:

Go to output TAB. Tick the checkbox marked as Create Hex File.

Click on OK.

Step-17:

Rebuild target to create hex file. This will create the hex file in the folder where we have created the project.

Bingo..!!

Now we can use the hex file for simulation on Proteus or else we can load it to a controller and test it…!!

 

Hope you have enjoyed the first step towards learning 8051…!!

Keep learning ...  Keep Creating...

If you face any issues, we are just a click away to help you…!! Post your query on ASK US section.

Please log in to view code.

You may also like...

Leave a Reply

Specify Facebook App ID and Secret in Super Socializer > Social Login section in admin panel for Facebook Login to work

Specify LinkedIn Client ID and Secret in Super Socializer > Social Login section in admin panel for LinkedIn Login to work

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