Sie sind auf Seite 1von 8

MEGAPRG_TUTORIAL.

PDF

• The MEGAPRG AVR Programmer consists of three parts in addition to the software
CDROM. The programmer module which will be connected to the PC parallel port, the
10 way flat cable, and the adapter which facilitates using MEGAPRG with breadboard.

• The 10 pins IDC header soldered in the programmer has the following pin definitions:

• Before connecting the hardware, you should first install the MEGAPRG software from
the accompanying CDROM. Choose either Windows 98 or Windows XP version.

Page 1 of 8
MEGAPRG_TUTORIAL.PDF

• After installing the software (found in the megaprg directory), you should prepare the
microcontroller hardware circuit. Almost 95% of ATMEL AVR microcontrollers are in
circuit programmable and only 4 pins need to be connected between the microcontroller
and the MRGAPRG. Those pins are MOSI, MISO, SCK, and RST.

• So as a start, select a certain AVR microcontroller (for example ATMEGA8515) and


from its datasheet (found in the "datasheet" directory) define those 4 programming pins.

• You can follow the following complete example to understand how to use MEGAPRG.
Suppose you want to program ATMEGA8515 microcontroller so that it flashes a LED
connected to PA0 every second.

Page 2 of 8
MEGAPRG_TUTORIAL.PDF

1- Prepare a proper schematic for the circuit as shown below.

Page 3 of 8
MEGAPRG_TUTORIAL.PDF

2- prepare the components and connect the previous schematic on a bread board as
shown. Note that it is highly recommended to separate the 4 programming pins as
well as the GND and VCC so that they will be easily connected to the programming
adapter.

Page 4 of 8
MEGAPRG_TUTORIAL.PDF

3- Connect the programming adapter to the bread board as shown.

Page 5 of 8
MEGAPRG_TUTORIAL.PDF

4- Connect the 10 way flat cable to the programming adapter from one side and to the
MEGAPRG programmer (which is connected to the PC Parallel port) from the other
side.

5- Finally supply the microcontroller circuit with a regulated 5v supply (you can use
SUPMOD module). Now the hardware is ready.

6- Download the ZIP file “megaprg_test.zip” which contains a CodeVision compiled


project that will achieve the flasher job.

7- unzip the file and make sure that the file “megaprg_test.hex” is there. Later you will
should write your own C or assembly codes and compile them to hex files.

Page 6 of 8
MEGAPRG_TUTORIAL.PDF

8- Power ON your board and start MegaPrg software. You should notice that the software
is initialized successfully and the LED on the bread board adapter should be ON. Now
follow the following sequence

a- select the specific AVR chip you are using (ATMEGA8515 in this case)
b- load the hex file (File-> Load-> Flash)
c- erase the chip (Device -> Erase)
d- program the chip (Device -> Program -> Flash)
e- verify the chip (Device -> Verify -> Flash). If everything is OK, the data in the
program window will be in green. If there is something wrong, the data will be
in red.

Page 7 of 8
MEGAPRG_TUTORIAL.PDF

9- since ATMEGA devices comes with a built in 1MHz RC oscillator, the microcontroller
will not operate from the external 4 MHz oscillator. To let the controller execute the
program with the speed of the external source, you should program the fuses using the
following steps.
a) Display the fuses (View->Fuse & Lockbits)
b) Change to external clock source by Un-checking CKSEL0, CKSEL1,
CKSEL2, and CKSEL3.
c) Program the fuses (Device -> Program -> Fuses)

10- Run your microcontroller program (Device -> Run). The LED on the breadboard
adapter should be OFF and The Green LED connected to PA0 will flash every sec-
ond.

11- You can now push the reset button in the program and repeat the programming cycle
after modifying your code (the programming adapter LED should be ON again).

12- Finally, if you remove the programming adapter from the breadboard, you will find
the green LED flashing and now you have your first stand-alone embedded applica-
tion.

Page 8 of 8

Das könnte Ihnen auch gefallen