Anda di halaman 1dari 9

SIEP WORKSHOP

Presentation by: Osama Tahir 09-EE-88

Starting AVR Studio


Open AVR Studio 4 Click on New Project Select AVR GCC and write project name SIEP and click Next.

Starting AVR Studio


Select Proteus VSM Viewer as your Debug platform. Select Atmega16 and click Finish.

Settings
Go to Project in the Menu bar and click on configuration settings. Set frequency to 8000000 and optimization to --O0. Click OK.

Starting PROGRAM
To program any AVR microcontroller include avr/io.h to your program by writing #include<avr/io.h> This header file includes the appropriate IO definitions for the device.

Writing Main Function


Void main() { } First line tells the compiler that there is a function named main . The "curly braces" ({ and }) signal the beginning and end of functions and other code blocks. Any thing written between these curly braces will get executed line by line.

The same way as you code in C or C++

Defining and using Functions


Similarly we can define other functions in similar manner. 1.Defining Prototype before main function e.g. void Initialize_ports(); 2.Defining function after Main function and writing code in it. Void initialize_ports(); { DDRA=0b11111111; }

Defining and using Functions


3. Call this function in main program. Void main() { initialize_ports(); } Now that command which we wrote DDRA=0b11111111 will get executed.

Anda mungkin juga menyukai