You are on page 1of 7

EENG 481 LAB -2 NOTES

Gkhan Demirkran

How to use Keil for creating hex files.


1-Press the button Project>> new uVision project.

Name your project as Project1.

2-Then a window will appear, choose AT89C51 please.

EENG 481 LAB -2 NOTES

Gkhan Demirkran

3-Now you can press file>>new to open a blank page to write our c codes.

Copy the C code below from Mazidi, 8051 microcontroller and embedded systems: #include <reg51.h> void T0M1Delay(void); sbit mybit=P1^5; void main(void){ while (1) { mybit=~mybit; T0M1Delay(); } } void T0M1Delay(void){ TMOD=0x01; TL0=0xFD; TH0=0x4B; TR0=1; while (TF0==0); TR0=0; TF0=0; }

EENG 481 LAB -2 NOTES

Gkhan Demirkran

4-now, save this file as Ccode1

EENG 481 LAB -2 NOTES

Gkhan Demirkran

5- In order to add our C code Ccode1 into our project project1. We must add it into our project. Right click on the source group 1. And then press add files to group the source group 1..

Now choose your c code file Ccode1

EENG 481 LAB -2 NOTES

Gkhan Demirkran

Now it is added as you see below.

6-In order to get a hexadecimal file, a few changes must be done. Right click on Target1, press options for Target target1.

EENG 481 LAB -2 NOTES

Gkhan Demirkran

Change XTAL mhz as 12. And put a tick on create hex file

7- Now, we can create our hex file. Press the button build

EENG 481 LAB -2 NOTES

Gkhan Demirkran

A hex file, named project1.hex (not Ccode1.hex), is created. You can open it with notepad to see machine codes. This is an intel format hexadecimal file.

You might also like