Friday 27 September 2013

HOW TO CREATE A MAKEFILE

We assume that you already installed WinAvr latest version.

Note :- Install notepad++.
We recommended that you use a external make file in AVR STUDIO 4 for commanding all the process.

Follow all the steps for creating a make file.


1. After installing WinAvr. Search a file in your search option type "Mfile". see in below figure. If you can not search this file search it in WinAvr folder in 'C' drive where it is installed.



2. Open the file and click on the makefile option.




3. Click on the make file name option and type project file name. The name should be same as the project file name.


4. select Mcu type.


5. Select output format as ihex.


6. Select optimization level to 's' always.


7. Select debug format.


8. Select C standard level to gnu99 always.



9. If you want to use external header file or c source files in your code then you must select those files in your makefile from below option. Those file must be in the same folder where your project is saved.



10. Select your programmer. If do not want to burn your code no need to select this option.


11. Select your programer com port here for burning the program.


12. save the file in the same folder where your project is saved.


13. Now you have to insert this make file in avrstudio 4. Open studio 4.

     create your project see.....(AVR STUDIO 4 TUTORIAL...).

     Goto project option in main menu bar Project>configuration.

     Check the box "use external makefile".

    browse your make file from your project folder and click ok.

    now you can compile and build your program.


AVR STUDIO 4 TUTORIAL

The following assumes that you have already installed WinAVR and AVR Studio 4.

 Procedure
1.  Open Studio 4. If you don’t see the Project Wizard screen     as shown below, click on ‘Project’ from the main menu         bar, and select, ‘Project Wizard’.


2.  In the ‘Project Wizard’, click on ‘New Project’.
3.  Under Project Type, select AVR GCC.


4.  Enter the name you want to call the project
5.  If you want to have Studio automatically open a new file for        you to begin typing your code, check the box labeled, ‘Create      initial file’. Similarly, if you would like to create a folder in            which to put the project files, check the box labeled, ‘Create        folder’.
6.  In the box labeled, ‘Location’, either enter the location you          wish the new file and folder to be put, or click the browse             button (with three dots) to browse to the location.
7.  Click on Next to go to the next screen.
8.  Select AVR Simulator in the left column labeled, ‘Select debug      platform and device’, and select ATmega128 from the list of            devices in the right column. Then click ‘Finish’.


9.  The Wizard will set up the project file structure, which will            appear on the left window pane, and if you checked ‘Create          initial file’, it will open a window to the right in which you can        start typing or paste your C code. 
10. Press F7 or select, ‘Build’ from the Build pull-down            menu to start the compilation process.
11. Once you have successfully built your program, connect a             serial cable to the STK500 RS-232 connector. Turn on the           STK500, then click on ‘Tools’ from the main menu                     bar, select ‘Program AVR’ from the drop-down menu, then          select, ‘Connect’ (or just click on the ‘Connect’ icon on the          toolbar. You should then see the ‘Select AVR                              Programmer’ dialog box as shown in Figure 4. The selection          on the left side should be STK500 or AVRISP and that on the      right should be Auto (to auto-detect for an available COM            port on your PC). Make sure these selections have been made,      and click on ‘Connect’. 

Select AVR Programmer dialog box. This window allows you to choose the platform and COM port with which to program the avr. The selection on the left side should be STK500 or AVRISP and that on the right should be Auto (to autodetect for an available COM port on your PC).

                         12. You should then see the dialog box shown in Figure 5, which shows the fuse                                  settings. In the pane at the bottom of the window, you should see that AVR                                  Studio was successful in communicating with the avr.  
                          Fuse dialog box. This window allows you to select the fuses on the ATmega 


                    13. Once you have verified that the fuse settings are correct, click on the ‘Program’                             tab, and you should see the dialog box shown in Figure 6. In the section titled,                              ‘Flash’, the ‘Input Hex File’ radio button should be checked and a path to the hex                          file corresponding to target filename should be in the path box. You can also                                  navigate to another folder to download an alternate hex file if desired.
                   
                   14. Click on the button labeled, ‘Program’ to download the hex file to the                                            microcontroller. You should see the following lines appear at the bottom of the                              window:
Reading FLASH input file.. OK
Setting mode and device parameters.. OK!
Entering programming mode.. OK!
Erasing device.. OK!
Programming FLASH ..         OK!
Reading FLASH ..         OK!
FLASH contents is equal to file.. OK
Leaving programming mode.. OK! 



                           Program dialog box. This window allows you to navigate to the hex file to be                                  downloaded to the microcontroller.
 
                          15. Press the Reset button on the STK500, and your program is now                                                   running on the ATmega.