Procedure of Creating .hex file in KEIL uVISION 4, for 8051 Microcontroller
Firstly your Computer system must have Keil uVISION 4, installed! The following steps are also very much applicable to Keil uVISION 3 [A later version of it].
If you haven't installed it yet, go and download it from the following link http://keil.com/downloads. There you can select the various options available, such as code limited version, trial will full lenght codes, etc. So go to the program location & double click on the Uv4.exe, that is the main executable of it. Or if you are a windows 7 user, them simply go on start menu, them search as "keil" without quotes, if you have installed it correctly, then you will find this on the top of results.
Kiel as seen in Windows 7 program search |
Once it is opened, your workspace will something like this.
Keil uVision 4 Workspace Startup look |
Now you have to create the Keil uVision project in order to proceed further. For that
Click on "Project" & select "New uVision Project".
Keil uVision 4 Project Menu Option |
Give a name to your project, the project name can be anything but, should not be starting with a digit.
Project Save Option in Keil uVision 4 |
Once named the project. Click on "Save".
Now a new window will open, which will tell you to select the device, so it will depend on your vendor, like nxp, atmel, intel, who manufacture the 8051 IC, & you have purchased one of them. Select the exact configuration to get go, on the next step. To find the exact version of 8051 IC you are having, look deeply on your 8051 IC. Then match exact codes for vendors & version. Here the vendor is Atmel & device is AT89C51.
After selecting your device click on "OK"
Selecting a Vendor & Version/Type of 8051 IC, From the list proided |
Now, one dialog box will appear stating, to copy 'STARTUP.A51' to project folder & add file to Project, Select Yes.
Dialog Box in Keil, to copy STATUP.A51 to project folder & add the file to the project |
Now after creating the project you need to create the source, which Keil will later on Compile(on your command). For that go to the "File" menu, and select "New".
Creating New File in Keil uVision 4 |
A text window will open, where you are going to write a code to compile & create the .hex file. Write down your code & save. For Assembly language file please save the file with ".asm" extension, if instead writing a code in C save it with a ".c" extension.
Writing the source code to be compiled in KEIL uVISION 4 |
After Finishing the code, save the file, for that go to the File menu and click on Save or Save As. As this is the file creation step both will result in the same.
Saving a file in KEIL uVISION 4 |
Save the file as any name, you want, but don't forget to give the file an extension .asm or .c, depending on what you are writing.
Saving a file in KEIL uVISION 4 |
Ne just to compile the code, by selecting, "Build the Target" option from "Project" menu. But before that, we need to go to the Project menu and select Options for Target 'Target 1'
Keil uVISION 4 Project Option |
A dialog box will open. Select the Output menu & put a tick on Create HEX file option.
NOTE: If you havn't selected this option you will not be able to create .hex file to burn it into the 8051 development board.
Selecting Create HEX File Option |
Now click on the "Project" Menu, & select "Build Target".
Building Target or Compiling code in KEIL uVISION 4 |
After A successful build your HEX file will be created & can be found in the project folder, where your source file is. It will be with the extension .hex & with the same name as the Project.
Browse it through, & with software like "flash burner", load it to the Micro-controller 8051, to work as desired.