Skip to main content
Keil1

How to Use Keil

I can safely assume that you’re a beginner (that’s why you’re here) and recently got introduced to Keil uVision. You want to compile your own code (or worse, you’re compelled to do so) and have no idea how it works. It doesn’t matter if you have chosen Assembly or C Language for yourself but what’s important now is that you need an environment specially designed for the 8051 micro-controller. Basically you’re looking for an IDE (Integrated Development Environment) that can help you build and compile programs. Keil uVision is one of them and this is a step-by-step tutorial on how to use it. 

 

Keil1

 

KEIL uVision works both as an assembler and a compiler. Simply put, you can write code in Assembly or C Language and Keil will take care of the rest. It also supports all the popular variants of the 8051 micro-controller.

You can download KEIL from their official website. You’ll have to fill out a simple form to download it.

After installation, you might find it confusing at first glance. Too many options and you have no idea where to start from. Well, I’ll try to make it easy for you. Follow this graphical tutorial and hopefully by the end of the day, you’ll be able to write your program in Keil, compile it, and generate HEX file – which is the ultimate aim.

 

(1) Create a New Folder for your project to stay organized and avoid getting mixed up with other files. It’s always a good practice when starting a new project.

Keil2

 

(2) Open Keil uVision. Click Project and select New uVision Project

Keil3

 

(3) Give your project some name and click Save

Keil4

 

(4) Select your device in the next prompt ( i-e ATMEL > AT89C51 )

Keil5

 

(5) Select Yes, when prompted to add startup file.

Keil6

 

(6) Click New file, and start writing your code in the editor (Assembly or C language)

Keil7

 

(7) Save the file with proper extension ( *.c for C Language and *.asm for Assembly Language )

Keil8

 

(8) If saved correctly, the code gets highlighted according to syntax. Re-check file-name and extension otherwise.

Keil9

 

(9) Right-click Source Group 1 folder and select Add Files to Group

Keil10

 

(10) Add the code (saved previously) into the project work-space as it’s not added by default

Keil11

 

(11) Select Target 1, click Project, and then select Options as shown.

Keil12

 

(12) In the Output tab, check Create HEX File as it’s disabled by default. Remember to repeat this step for every new project.

Keil13

 

(13) Click Project and select Build Target to compile and build the project.

Keil14

 

(14) Keil will notify you of errors. Notice successful build in this case. You can ignore the warnings.

Keil15

 

(15) You can see the HEX file generated. Use this file to program your micro-controller.

Keil16

 

And you’re done!

Hopefully, you’re now able to compile and build your code in Keil uVision and also generate HEX file out of it. The most important part is the HEX file generation because that’s the only file you will ever need to program your micro-controller. Happy building!

Faizan

Muhammad Faizan Khan is an Electrical Engineer and a Computer Geek. He is a technical guy and has more than 3 years of experience in Embedded Systems, Digital Logic Design, Computer Programming and everything else that’s logical. He mostly writes tutorials related to microcontrollers for beginners in his blog, PhaseWire.

2 thoughts on “How to Use Keil

Leave a Reply

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