Installation

WinAVR (pronounced “whenever”) is a suite of executable, open source software development tools for the Atmel AVR series of RISC microprocessors hosted on the Windows platform. It includes the GNU GCC compiler for C and C++.

Note: This guide was tested by using “WinAVR-20100110-install.exe” file downloaded from sf.net website.

Run the “exe” file.

Note: The OS may ask you to grant permissions to execute the file, answer “yes”.

Choose language: English.

Agree with the terms.

Choose where to install. The default is probably “C:\WinAVR-20100110” which should OK.

Choose to install all components.

This will:

Install all files that are need for WinAVR to work properly.

Add WinAVR to PATH environment variables.

Install Programmers Notepad text editor.

This will add to the PATH:

“C:\WinAVR-20100110\bin”

“C:\WinAVR-20100110\utils\bin”

There is “WinAVR-user-manual.html” file in the “C:/WinAVR-20100110/” folder that describes WinAVR components.

Testing WinAVR

All command will be executed from a text console (similar to commend prompt and DOS prompt) that is called “shell”. The shell is part of WinAVR and is located under the “C:\WinAVR-20100110\utils\bin” folder.

IMPORTANT: Under the shell all texts are case sensitive – that means “hello” is completely different from “Hello”.

Note: Under certain versions of Windows (Ex.: 8.1) this may cause error messages to be printed out. One solution that was found is to run the “sh” command as an Administrator. This could be done like this …

Open Windows Explorer and go to the “C:\WinAVR-20100110\utils\bin” folder.

Locate “sh” (or “sh.exe”), do a “right click” and choose to “Run as administrator”.

For convenience you could create a short-cut of the “sh” to the desktop and then change the short-cut to run as an administrator:

Right-click on the sort-cut, then choose Properties.

under the “Compatibility” tab check the box “Run as administrator”

Run the shell.

First we need folder where all our projects will reside, so let’s go the our home folder and create one such folder …

$ cd /c/Users/MY_USER_NAME/
$ mkdir AVR_Projects
$ cd AVR_Projects

To test the WinAVR we need to create a new project and that project requires its own folder.

Go to a folder where all other projects will reside (if you are not already there):

$ cd /c/Users/MY_USER_NAME/AVR_Projects/

Create project folded and go into it:

$ mkdir test_winavr
$ cd test_winavr

Create new file in that folder:

$ touch test_winavr.c

Open the file:
(or from Windows Explorer with your favorite text editor)

$ notepad test_winavr.c

Write an “empty” program:
(it does not do anything)

int main(void)
{
return 0;
}

Close the file.

Now we need what is called a “Makefile” file.

There is MFile tool that is part of WinAVR and helps creating “Makefile” file – a file that is needed to build our programs. Start the MFile program – it creates new Makefile from a template.

Open menu “Makefile / main file name” and choose “test_winavr”.

Open menu “Makefile / MCU type” and choose “attiny85”.

In the text find the F_CPU and make sure it is 1000000 which corresponds to 1MHz CPU clock. Before that you will need to “Enable editing …” from the “Makefile” menu.

Open menu “File / Save as” and save file as “Makefile” in the folder where “test_winavr.c” is – i.e. in the “project folder”.

Close the MFile program.

Building the program …

From the shell go to the project folder (if not already there).

Build the project:

$ make

If this completes without any error messages that means the WinAVR was succressfully installed.

The “test_winavr.hex” contains the compiled program that should be programmed to the micro-controller. Please note that this is an empty program and does not do anything.

Before programming the micro-controller with the testing program and the USBasp programmer some driver maybe needed.

USBasp Driver Installation

USBasp is a USB in-circuit programmer for Atmel AVR controllers. It simply consists of an ATMega88 or an ATMega8 and a couple of passive components. The programmer uses a firmware-only USB driver, no special USB controller is needed.

Under MS Windows operating systems drivers are required for the USBasp to work. No such driver are required under Linux and OS X.

The Windows drivers are available at http://www.fischl.de/usbasp/. On the website look for the Drivers section – the ZIP file name should be something like “usbasp-windriver.2011-05-28.zip” or similar. Unzip the ZIP file and follow the instruction on the website.

Note: This guide was tested using “usbasp-windriver.2011-05-28.zip” file.

Windows Vista/7/8 Issues

Under MS Windows Vista/7/8 there are some issues while installing the USBasp drivers. You may need to temporary disable the “Driver Signature Enforcement”. Detailed guide is available at this location: http://letsmakerobots.com/node/36841

Checking Device Manager

Connect the USBasp programmer to the computer.

Open the Device Manager and see if the “USBasp” is present under the “libusb-win32 devices” section. In most cases that means the driver function properly.

Testing the USBasp Programmer

The USBasp programmer could be tested by writing very simple program that makes a LED to blink.

Portable WinAVR

Portable WinAVR is based on the regular WinAVR suite of software development tools for the Atmel AVR microprocessor series and is preconfigured to run directly from any removable medium (e.g. USB memory stick) without prior installation.

Share this:

7 thoughts on “WinAVR – Setup Guide”

Please make the following correction:
The instruction was to create “test_winavr.c” but while creating the makefile, the main file name was instructed to be given as “main” which does not match with “test_winavr.c” so it throws an error.
kindly correct it.