Megaprg Tutorial

8
MEGAPRG_TUTORIAL.PDF Page 1 of 8 The MEGAPRG A VR Progr amme r consis ts of three part s in addition to the soft ware 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 I DC he ader s oldered in the programmer has the foll owing pin de finitions: • Before connect ing the hardware, y ou should fir st install the MEGAPRG softwa re from the accompanying CDROM. Choose either Windows 98 or Windows XP version.

Transcript of Megaprg Tutorial

Page 1: Megaprg Tutorial

8/14/2019 Megaprg Tutorial

http://slidepdf.com/reader/full/megaprg-tutorial 1/8

Page 2: Megaprg Tutorial

8/14/2019 Megaprg Tutorial

http://slidepdf.com/reader/full/megaprg-tutorial 2/8

MEGAPRG_TUTORIAL.PDF

Page 2 of 8

• 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 3: Megaprg Tutorial

8/14/2019 Megaprg Tutorial

http://slidepdf.com/reader/full/megaprg-tutorial 3/8

MEGAPRG_TUTORIAL.PDF

Page 3 of 8

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

Page 4: Megaprg Tutorial

8/14/2019 Megaprg Tutorial

http://slidepdf.com/reader/full/megaprg-tutorial 4/8

MEGAPRG_TUTORIAL.PDF

Page 4 of 8

2-  prepare the components and connect the previous schematic on a bread board asshown. 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 5: Megaprg Tutorial

8/14/2019 Megaprg Tutorial

http://slidepdf.com/reader/full/megaprg-tutorial 5/8

MEGAPRG_TUTORIAL.PDF

Page 5 of 8

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

Page 6: Megaprg Tutorial

8/14/2019 Megaprg Tutorial

http://slidepdf.com/reader/full/megaprg-tutorial 6/8

MEGAPRG_TUTORIAL.PDF

Page 6 of 8

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 willshould write your own C or assembly codes and compile them to hex files.

Page 7: Megaprg Tutorial

8/14/2019 Megaprg Tutorial

http://slidepdf.com/reader/full/megaprg-tutorial 7/8

MEGAPRG_TUTORIAL.PDF

Page 7 of 8

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 8: Megaprg Tutorial

8/14/2019 Megaprg Tutorial

http://slidepdf.com/reader/full/megaprg-tutorial 8/8

MEGAPRG_TUTORIAL.PDF

Page 8 of 8

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 breadboardadapter 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.