Вы находитесь на странице: 1из 6

WINAVR:

WinAVR is not just one tool, like many other software names. WinAVR is instead a set
of tools, these tools include avr-gcc (the command line compiler), avr-libc (the compiler
library that is essential for avrgcc), avr-as (the assembler), avrdude (the programming
interface), avarice (JTAG ICE interface), avr-gdb (the de-bugger), programmers
notepad (editor) and a few others. These tools are all compiled for Microsoft Windows
and put together with a nice installer program.

When referring to the version, you are most of the time referring to the version of the
compiler, avr-gcc. For example currently WinAVR includes version 3.3 of avr-gcc.
However, it is not WinAVR 3.3 as some people call it, to refer to which release you are
using that is done by date. For example WinAVR 20030424. The 20030424 is a date
code, which is discussed later..

Getting WinAVR:
The WinAVR website is located at: http://winavr.sourceforge.net/ This site contains
information on WinAVR, including some very useful links, notes, and news. You
should first go to this site to see if there is any important information you should know
about WinAVR before downloading (different releases, etc).

You should now go to the SourceForge.net project site for WinAVR, the exact address
being: https://sourceforge.net/projects/winavr/
Installing WinAVR
Creating First Project
Here I'll be illustrating the simplest way to get through the WinAVR. The installation
of WinAVR installs following program which we will be using to write/compile the
code

1. Programmer's Notepad - it's generic notepad with the additional capability of syntax

highlighting.

2. Mfile - it's the utility to create the Makefile. It's very important in-case of compiling

and programming.

 The programmer notepad is the environment where you will be writing the

code. You are free to choose your own language to write the code but

compiling process or method will change. So, now let's start, the first thing first

is you have to create your own folder where you can host your project. I have

chosen to use keep it under a folder named AVR located at user home folder.

Creating your first project:

Now name the project whatever you like and hit "Save" to safeguard your project.
Now, we have the folder and project both the things, it's time to add the code to it. To
do so, go ahead and click on the file create a new file and then select the type of the
language you will be using for the project in my case it is C/C++. The selection of the
language helps editor to highlight the syntax.

Adding new file:

As the project is saved and ready to use now you can add the files to the project. You
can create new file and dave it via "File menu". These are known as source files. The
source files must include the "main.c" which is the file will get compiled. In addition,
you can also include/create your own header files. Header files are the supportive to
the main.c which fetches following advantages,

 It helps to organize your code/project.

 It helps to make the code readable and concise. So, do not end up writing huge codes.

 Also, it allows you to include the files from multiple projects. And these files can be

portable.
Also, remember if you create a new file it won't get added to the project. You have to
do it manually. By right clicking on the project and selecting add file option, locate
the file and click open. Shown in the images.

Writing the code:

As this is the tutorial to setup AVR toolchain. I'll be not focusing on the how to write
the code. You can download te whole project or just download the main.c from the
attached files.

Creating Makefile

Make file is the file which assists the editor, compiler, and linker. It consists of the file
name which is the source file, in this case, it's "main.c". Also, it holds the information
of your microcontroller and programmer you are using and the commands and ports
via it is connected to the computer. Precisely it contains the rules for your project to
compile. Open the program Mfile located in the start menu under WinAVR folder.

After opening, you will see the window in which you can select the parameters from
the drop down menu. For example, I'll be compiling my project for
the atmega16a microcontroller. Here in the Makefile only you can select your source
file e.g. "main.c". Once do the necessary changes you can then "Save As" the
modified Makefile into the directory where the main source file is located.

Once you have the files ready you can go ahead and compile the program. To do so
you can go to "Tools" option and choose following commands,
 Make All: Command to compile the code

 Make Clean: It's the command to delete all files created during the compiling and

linking process

 Make Program: This is used to burn the program to the microcontroller target.

Happy programming!! That's all you need to get started with compiling the code for
AVR controllers. `

Вам также может понравиться