Kit - C Programmers Guide to Building Hardware - Part 1
To get everything you
need for these projects in C, get the
Microcontroller Beginner Kit, the ADT87 adapter,
and the 8951Kit. The software CD that comes with
the MB Kit includes an evaluation version of the
Keil C compiler for 8051s. We will use this
evaluation Keil software in our examples. (Yes
that is only $181.50 for all the hardware and
all the software including the professional
PG302 device programmer!)
Start by installing the
Keil software. Look for keil.exe in the Tools
-> C compilers folder on the CD.
Next close the default
project that opens up in the compiler by
clicking on Project -> Close Project.
Then start a new
project by clicking on Project -> New Project.
Call it blink1. (You can create a new folder for
the project if you would like to keep the new
files together in their own folder.)
microcontroller by clicking on Atmel and
AT89C51. Click Ok and then click No when it asks
you if you would like to copy the startup code.
Click on the little
button just to the left of where it says Target
1 in the third row of the toolbar at the top of
the screen. (They could make this a little
easier to find.) This should bring up a window
that says Options for Target 'Target 1'.
Click on the Output
Click the box beside
Create Hex File so that it has a checkmark. Then
click Ok to save the settings.
The C Program
Click the small + sign
beside Target 1 in the Project Workspace window
on the left. Add the first example program to
the project by right clicking on Source Group 1
-> Add Files To Group. Find ledtest.c.
Compile and Build the Hex File
Click on Project ->Rebuild all target files
This should create a file called blink1.hex in the project folder.
Downloading the Hex File
Put the ADT87 adapter
on the PG302 as shown below and push down the
green handle to hold the adapter in place.
Connect the serial
cable and the power supply to the PG302
Put the 89C51 into the
ADT87 adapter and close the handle as shown in
the picture above.
If you have not
installed the PG302 software you need to do that
Start the PG302
From the Setup Menu,
select the Atmel 89C51.
From the Setup Menu,
select the Comm port you are using.
Press PROGRAM DEVICE.
Find blink1.hex and
click on it (single click).
Press OK to select the
Press OK to program the
file into the microcontroller.
The status bar should
say 'Device Equals File'. The program is now
loaded into the microcontroller.
We will start with the
basic setup as shown below.
Make sure you connect pin 40 to 5 Volts and
pin 20 to ground.
Make sure the power is
off for the circuit when inserting or removing
Turn on the power to
the circuit. If the LED starts blinking, then it
is time to celebrate!