Programming-
You know that Your hardware is nothing without the Software i.e. Program. So also writing a program in machine level language is also very difficult task. So to solve this problem, We use keil Compiler.
What are Keil Compilers?
Telling in one line, Compilers are nothing but programs used to convert a High Level Language to object code
Keil compiler is a software used
where the machine language code is written and compiled. After compilation, the
machine source code is converted into hex code which is to be dumped into the
microcontroller for further processing. Keil compiler also supports C language
code.
STEPS TO WRITE AN ASSEMBLY / C LANGUAGE PROGRAM IN KEIL AND HOW TO COMPILE IT:
- Install
the Keil Software in the PC in any of the drives.
- After
installation, an icon will be created with the name “Keil uVision3”. Just
drag this icon onto the desktop so that it becomes easy whenever you try
to write programs in keil.
- Double
click on this icon to start the keil compiler.
- A
page opens with different options in it showing the project workspace at
the leftmost corner side, output window in the bottom and an ash coloured
space for the program to be written.
- Now
to start using the keil, click on the option “project”.
- A
small window opens showing the options like new project, import project,
open project etc. Click on “New project”.
- A
small window with the title bar “Create new project” opens. The window
asks the user to give the project name with which it should be created and
the destination location. The project can be created in any of the drives
available. You can create a new folder and then a new file or can create directly
a new file.
- After
the file is saved in the given destination location, a window opens where
a list of vendors will be displayed and you have to select the device for
the target you have created.
- The
most widely used vendor is Atmel. So click on Atmel and now the family of
microcontrollers manufactured by Atmel opens. You can select any one of
the microcontrollers according to the requirement.
- When
you click on any one of the microcontrollers, the features of that
particular microcontroller will be displayed on the right side of the
page. The most appropriate microcontroller with which most of the projects
can be implemented is the AT89C51. Click on this microcontroller and have
a look at its features. Now click on “OK” to select this microcontroller.
- A
small window opens asking whether to copy the startup code into the file
you have created just now. Just click on “No” to proceed further.
- Now
you can see the TARGET and SOURCE GROUP created in the project workspace.
- Now
click on “File” and in that “New”. A new page opens and you can start
writing program in it.
- After
the program is completed, save it with any name but with the .asm or .c extension.
Save the program in the file you have created earlier.
- You
can notice that after you save the program, the predefined keywords will
be highlighted in bold letters.
- Now
add this file to the target by giving a right click on the source group. A
list of options open and in that select “Add files to the source group”.
Check for this file where you have saved and add it.
- Right
click on the target and select the first option “Options for target”. A
window opens with different options like device, target, output etc. First
click on “target”.
- Since
the set frequency of the microcontroller is 11.0592 MHz to interface with
the PC, just enter this frequency value in the Xtal (MHz) text area and
put a tick on the Use on-chip ROM. This is because the program what we
write here in the keil will later be dumped into the microcontroller and
will be stored in the inbuilt ROM in the microcontroller.
- Now
click the option “Output” and give any name to the hex file to be created
in the “Name of executable” text area and put a tick to the “Create HEX
file” option present in the same window. The hex file can be created in
any of the drives. You can change the folder by clicking on “Select folder
for Objects”.
- Now
to check whether the program you have written is errorless or not, click
on the icon exactly below the “Open file” icon which is nothing but Build
Target icon. You can even use the shortcut key F7 to compile the program
written.
- To
check for the output, there are several windows like serial window, memory
window, project window etc. Depending on the program you have written,
select the appropriate window to see the output by entering into debug
mode.
- The
icon with the letter “d” indicates the debug mode.
- Click
on this icon and now click on the option “View” and select the appropriate
window to check for the output.
- After
this is done, click the icon “debug” again to come out of the debug mode.
- The
hex file created as shown earlier will be dumped into the microcontroller
with the help of another software called Proload.
PROLOAD:
Proload is a software which accepts
only hex files. Once the machine code is converted into hex code, that hex code
has to be dumped into the microcontroller placed in the programmer kit and this
is done by the Proload. Programmer kit contains a microcontroller on it other
than the one which is to be programmed. This microcontroller has a program in it
written in such a way that it accepts the hex file from the keil compiler and
dumps this hex file into the microcontroller which is to be programmed. As this
programmer kit requires power supply to be operated, this power supply is given
from the power supply circuit designed above. It should be noted that this
programmer kit contains a power supply section in the board itself but in order
to switch on that power supply, a source is required. Thus this is accomplished
from the power supply board with an output of 12volts or from an adapter
connected to 230 V AC.
1. Install the Proload Software in the
PC.
2. Now connect the Programmer kit to
the PC (CPU) through serial cable.
3. Power up the programmer kit from the
ac supply through adapter.
4. Now place the microcontroller in the
GIF socket provided in the programmer kit.
5. Click on the Proload icon in the PC.
A window appears providing the information like Hardware model, com port,
device type, Flash size etc. Click on browse option to select the hex file to
be dumped into the microcontroller and then click on “Auto program” to program
the microcontroller with that particular hex file.
6. The status of the microcontroller
can be seen in the small status window in the bottom of the page.After this
process is completed, remove the microcontroller from the programmer kit and
place it in your system board. Now the system board behaves according to the
program written in the microcontroller.
No comments:
Post a Comment