Wednesday, November 28, 2012

EMBEDDED SYSTEMS TUTORIAL3- MAKING OUR FIRST PROJECT -PART1



Hii guys again I am here with my 3rd tutorial on embedded systems. I hope you have arranged all the required hardware and softwares. So today we are going to compile our first code using AVT STUDIO 4 and then we will burn the hex file to MCU with the help of USBASP programmer using PROGISP. Here  I have inlisted complete stepwise process to work on AVR STUDIO4 and programming the MCU. First of all install AVR STUDIO 4, WIN AVR and PROGISP with normal installation processes. Also install drivers provided with USBASP programmer as directed in documentation of product.





1.       COMPILING THE CODE


              Lets start our AVR STUDIO4 when it will start it will look something like this.

           



         To create a new project Choose NEW PROJECT. Now after choosing new project window will look like this

 



         



Now click on AVR GCC , give project a suitable PROJECT NAME and  SAVE it in desired location click NEXT, and window will turn to something like this.










Now Select Device here we are going to work with ATMEGA8, if you have ATMEGA16 or ATMEGA32 no problem same process will work fine just choose your device ,click finish, a new will open now.









Now there are three sections
 
PROJECTS SECTION- here the files used  in project are shown you can add additional file in this section.

CODE SECTION- in this section the source code is written and edited accordingly.

MESSAGE SECTION- this section shows suitable messages after compiling . Errors and warnings are displayed in this section.
 



Now copy this code from here and paste it in the code section. If you do not understand the code don’t worry I will teach about various programming aspects in next tutorials.


#include<avr/io.h>
#include<util/delay.h>

int main(void)


{

    DDRB=0b00000010;  // PB1 of PORT B is set as output connected with LED
    while(1)
    {
        PORTB=0b00000010;  //LED at PB1 set ON
        _delay_ms(200);

        PORTB=0b00000000; //LED at PB1 set OFF
        _delay_ms(200);
    }
}
 





Now click on build button or click   fn+f7   ………..and compiling started…J


If everything is correct build will succeed with 0 errors and may be with some warning do not worry about warnings build one more time and warnings will be eliminated.

Now after this much process your compilation is complete and u can see now hex file is generated in project folder . this is the file which will be fed or burnt in the microcontroller because microcontroller understand instructions given by hex file only.This was the compilation part now in next part we will burn this  generated hex file in our microcontroller. I hope this tutorial was beneficial for u all ,if u have any doubts , questions or critical view just leave your comment.............cntd. to  EMBEDDED SYSTEMS TUTORIAL3- MAKING OUR FIRST PROJECT PART2




                        THNX...:)




No comments:

Post a Comment