Wednesday, April 27, 2011

Starting WinAVR

Setup of WinAVR can be downloaded from this link.

Once you are done installing, open the start menu and search for Programmer's Notepad. Click on it to open.
It should look something like this.


The bar on the left side may or may not be there.
The program is written in the large white area ( 'notepad' ).
The window at the bottom is called the output window.
The language in which the program is being written can be selected as shown.


Once the language has been selected, the program should be written in the notepad.


Once the program is written. Make a new folder and save this program with the extension .c. for example, main.c

For every program you write create a separate folder for it.

Once this is done, an mfile has to be created.

Search for 'mfile' in the start menu.
It'll look something like this.



After that, click on 'Makefile' and select 'Main File Name'.

A small window will open up. Write the name of the file you have saved. Don't write the extension of the file. For example, if the name of your file is main.c, write main in that window.


After that, in 'Makefile' select 'MCU type' and select the microcontroller you are using.


Then in 'Makefile' go to 'port' and select the port that is being used for programming. This depends on whether the programmer you are using. It may use a USB programmer or COM port or others. If you are not sure, contact the person you bought it from. If it is still not clear, please contact us at blogger.engg@gmail.com, or post your doubt as a comment below and we'll contact you.


After that select the programmer you are using.


Some programmer like USBASP are not mentioned in this. To select those programmers, select any programmer you want, then click on enable editing of makefile in 'Makefile' and in place of the text highlighted in yellow write the programmer you are using, in small letters (e.g usbasp)


Once you have selected enable editing of makefile, scroll up to find the text as shown in the picture below, and change the entry encircled below to the frequency of the crystal you are using.


After this go to 'File' in the mfile box only, and click 'Save As'. This file should be saved in the same folder that your .c file has been saved with the name 'Makefile'. If this name is already displayed, don't change it. This file should not be saved with any other name. 

Go back to programmer's notepad, go to 'Tools', select  'Make All'. This creates the hex file ( this file will be present in the folder) which is required to program your microcontroller. Syntax or mfile related errors, if any, are shown in this step in the the output window.
Make sure that your programmer is connected, and then go to 'Tools' and select 'Program'. 
That's it. Your microcontroller is programmed!

If you are not sure how to use your programmer, contact the person you bought it from. If it is still not clear, or you have any doubts in the above steps please contact us at blogger.engg@gmail.com, or post your doubt as a comment below and we'll contact you.

No comments:

Post a Comment