You are on page 1of 21

VERSION 1.

Using AVR STUDIO 4/WINAVR to program AVR's


Tutorial 1 - Setting Up Your Programming Environment

Troy Boswell 11/30/2009

Introduction
These tutorials are designed to be balanced windows based tutorials, to introduce individuals to AVR C programming with AVR Studio 4 and WinAVR. Throughout these tutorials I will be using the ATMEL AVRISP MKII programmer and the STK 200 parallel programming cable. The ATMEL AVRISP MKII is a USB programmer which is available in Australia from Ocean controls or internationally from DIGI-KEY. I will be referring to the development board, OUSB which is a free source design and can be found at http://pjradcliffe.wordpress.com/open-usb-io/ and the schematic is here.

Aim
The aim of this tutorial it to give the reader the skills to program his/hers own code onto any AVR that is supported by AVR STUDIO 4. Note: Check current documentation for WinAVR to ensure the chip you wish to program is supported.

Parts List
OPEN USB Board Currently none are for sale online but students attending RMIT can purchase them from the design store or consult PJ Radcliffe. I think there is a future plan to make them available. For those who have the capability to make a PCB and add components the board schematics link is here. For those who aren t as capable may be able to contact PJ Radcliffe through his webpage and ask if he can source you one.

1|Page

Version 1.0

Programming Parts List


Part
WINAVR (FREE DOWNLOAD)

Supplier
http://sourceforge.net/pr ojects/winavr/files/

Part Number
- download the install file

Qty

AVR STUDIO 4 (FREE DOWNLOAD)

http://www.atmel.com/dy n/Products/tools_ card.asp?tool_id=2725

- scroll down page to software, download the first one that says register. Then registerand download and install for free. PRG-001 PRG-002 1 1

AVRISP MKII PROGRAMMER AVR Programming adaptor 40 Pin Double row headers IDC 10 PIN CABLE

Ocean controls Ocean controls Dick Smiths / Dick Smiths /

Jaycar Jaycar

Either Buy One Or Make One

STK 200 Programming Cable Parts List


Part
WINAVR (FREE DOWNLOAD)

Supplier
http://sourceforge.net/pr ojects/winavr/files/

Part Number
- download the install file

Qty

AVR STUDIO 4 (FREE DOWNLOAD)

http://www.atmel.com/dy n/Products/tools_ card.asp?tool_id=2725

- scroll down page to software, download the first one that says register. Then registerand download and install for free. 1 1 4 1

DB25 Male DB 25 Shell 470 ohm resistors IDC 10 PIN CABLE

Dick smiths/Jaycar Dick smiths/Jaycar Dick smiths/Jaycar Dick smiths/Jaycar

Either Buy One Or Make One

2|Page

Version 1.0

WINAVR and AVR Studio 4 Installation What is WINAVR and AVR Studio 4?
WinAVR is the engine for AVR STUDIO, it gives AVR STUDIO the capability to support C/C++ programming. AVR STUDIO is a free Integrated Development Environment (IDE) created by ATMEL and comes in Windows and Linux version, but since this tutorial is only for Windows users this tutorial will not give instructions for Linux. AVR STUDIO gives the programmer the ability to write, compile, debug and program code within one application.

What Is An AVR?
AVR is just the term used to describe any ATMEL microcontroller.

Downloading the needed file


Both of the following downloads are free!! Go to the following sites and save the following downloads to your system. WINAVR is located at, just download the .exe file http://sourceforge.net/projects/winavr/files/ AVR Studio 4 http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=2725 Scroll down the screen to software, then select the most current version. Then you will have to register and to download the software. ( When writing this the most current version was 4.17)

3|Page

Version 1.0

Installation of WinAVR and AVR STUDIO


After completing the downloads, installation may begin. 1. WinAVR has to be installed first to ensure that AVR STUDIO recognizes the GNU C-compiler as a plug-in. Ensure you use default install locations so that AVR studio can find WINAVR. 2. Open the downloaded WinAVR folder (extract if zipped) and double click on the WinAVR install icon, select your language and click 'OK'.

3. WinAVR Setup Wizard will now appear, click 'NEXT'.

4|Page

Version 1.0

4. Next the Licensing Agreement will apear, if you agree click 'I AGREE'.

5. Setup Wizard will now ask you where you would like to install WinAVR. It is important that you use this default setting so that AVR STUDIO can locate WinAVR during the AVR STUDIO installation. If you change this you risk not being able to program in C/C++ in AVR STUDIO.

5|Page

Version 1.0

6. Setup Wizard will now request for you to select the components to install. Ensure all 3 boxes are ticked, click 'INSTALL'.

7. WinAVR will now install.

6|Page

Version 1.0

8. Once the install is complete, click 'FINISH'.

9. Now that WinAVR is installed we can now install AVR STUDIO, the version I am installing is AVR STUDIO 4.17. 10. Open the downloaded AVR STUDIO folder (extract if zipped) and double click on the AVR STUDIO install icon, the InstallShield Wizard for AVR STUDIO4 will now appear, click 'NEXT'.

7|Page

Version 1.0

11. If you accept the Licensing Agreement, select the I accept statement and click 'NEXT'.

12. Install Shield will now ask you where you would like to install AVR STUDIO, as per point 5. It is important that you use default settings to ensure the WinAVR GNU C-compiler plug-in is found by AVR STUDIO. Do this by simply clicking 'NEXT'.

8|Page

Version 1.0

13. This next step is very important if you are going to be using the AVRISP MKII programmer. The Jungo Driver is the driver for the programmer, I recommend everyone install it as the file is only small. So ensure that Jungo USB Driver is selected and click 'NEXT'.

14. Install Shield will now ask you if you would like to install, click 'INSTALL'.

15. AVR STUDIO will now install.

9|Page

Version 1.0

16. Once the installation has completed, simply click 'FINISH'.

If you are using AVRISP MKII programmer in a 32 bit environment, continue through steps 17 - 22. If you are using AVRISP MKII programmer in a 64 bit environment skip to step 23 and continue through to step 37. If you are using the STK 200 parallel programming cable skip to tutorial 3.
17. The following screen shots are taken from an XP 32 bit machine and will differ if you are using a Windows 7 or Vista 32 bit machine. But in concept you will be doing the same thing as I am here, except for the fact you will have to click next and allow more times than in this tutorial. 18. Connect the AVRISP MKII programmer to a USB port on your PC, the New Hardware Found Wizard should appear. Select 'No, Not This Time' and click 'NEXT'.

10 | P a g e

Version 1.0

19. Select 'Install From a List or Specific Location (advanced)' , click 'NEXT'.

20. Click 'BROWSE', and find the director C:\Program Files\Atmel\AVR Tools\usb to direct the New Hardware Wizard to scan the 'usb' folder. Click 'NEXT'.

21. Now you should get a window saying that the hardware is installed. Click 'Finish'.

Now a Green light should appear next to the USB socket of the AVRISP MKII and a red light on top. If you have no Green light you have not installed the driver properly.

11 | P a g e

Version 1.0

22. Now open Device Manager. XP this is located at, start>control panel>performance and maintenance> hardware tab > DEVICE MANAGER Windows 7, this is located start>control panel> device and printers > DEVICE MANAGER Once you have opened device manager, scroll down your device list until you get to Jungo, click on the plus to expand the Jungo list, ensure that there are two devices in the Jungo list. AVRISP MKII and WinDriver.

You have now install WinAVR, AVR STUDIO 4 and the AVRISP MKII programmer and you are now ready to program. Continue onto the next tutorial, AVR STUDIO Introduction.

12 | P a g e

Version 1.0

23. The following Screen shots for a 64 bit install are taken from a Windows 7 64 bit machine. Vista 64 bit may vary slightly but most of the tutorial should be very similar. 24. Connect the AVRISP MKII programmer to a USB port on your PC, select start > control panel as shown below.

23. Now select 'Hardware and Sound'.

13 | P a g e

Version 1.0

24. Now select 'Device Manager'.

25. Now that you are in device manager, at the top of your PC's device list should be your computer name. Right click on your computer name, a box should appear which contains an option to 'Add legacy hardware', select this option.

14 | P a g e

Version 1.0

26. Add Hardware Wizard will now start, click 'NEXT'.

27. From the Wizard select the option 'Install the hardware that I manually select from a list (advanced)', click 'NEXT'.

15 | P a g e

Version 1.0

28. Select Jungo from the list, click 'NEXT'.

29. click 'Have Disk...'.

16 | P a g e

Version 1.0

30. Click 'Browse'.

31. The following shows the director needed to find the 64 bit driver. The directory is C:\Program Files (x86)\Atmel\AVR Tools\ usb64. Select the folder 'usb64'.

17 | P a g e

Version 1.0

32. Select the file 'windrvr6.inf', click 'OPEN'.

33. Ensure the directory, C:\Program Files (x86)\ATMEL\AVR Tools\usb64 is in the box as displayed below. Click 'OK'.

18 | P a g e

Version 1.0

34. Click 'NEXT'.

35. Click 'NEXT'.

19 | P a g e

Version 1.0

36. Once the driver is installed a Green Light next to the USB socket should appear, and a red light should be on top (if you have no green light then the AVRISP MKII programmer is not installed properly). Click 'FINSH'.

37. Now go back into Device Manager, expand the Jungo list as displayed below and ensure that devices AVRISP MKII and WinDriver are in your list. If they are then you are ready to move onto the next tutorial, AVR STUDIO Introduction.

20 | P a g e

Version 1.0

You might also like