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.
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.
(2) Open Keil uVision. Click Project and select New uVision Project
(3) Give your project some name and click Save
(4) Select your device in the next prompt ( i-e ATMEL > AT89C51 )
(5) Select Yes, when prompted to add startup file.
(6) Click New file, and start writing your code in the editor (Assembly or C language)
(7) Save the file with proper extension ( *.c for C Language and *.asm for Assembly Language )
(8) If saved correctly, the code gets highlighted according to syntax. Re-check file-name and extension otherwise.
(9) Right-click Source Group 1 folder and select Add Files to Group
(10) Add the code (saved previously) into the project work-space as it’s not added by default
(11) Select Target 1, click Project, and then select Options as shown.
(12) In the Output tab, check Create HEX File as it’s disabled by default. Remember to repeat this step for every new project.
(13) Click Project and select Build Target to compile and build the project.
(14) Keil will notify you of errors. Notice successful build in this case. You can ignore the warnings.
(15) You can see the HEX file generated. Use this file to program your micro-controller.
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!