Sei sulla pagina 1di 4

Following is a short tutorial on how to set up and run the GCC plug-in from within AVR Studio.

It was created using WinAVR 20060125 and AVR Studio Version 4.12, Service Pack 2. Please verify you have Service Pack 2 installed as it was specifically created to eliminate a lockup problem in AVR Studio when using GCC. See this thread for more details: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=35216 This example uses the Blinky code and hardware example for the AVR Butterfly as described in Joe Pardues tutorial here: http://www.smileymicros.com/QuickStartGuide.pdf. Joe has also written an excellent book entitled C Programming for Microcontrollers which features the Butterfly and WinAVR. Visit http://www.smileymicros.com/ for more details. 1. Open AVR Studio. Select Project Menu Project Wizard New Project. 2. Select AVR GCC and enter Blinky for the project name.

3. Select AVR Simulator for the debug platform and ATmega 169 for the device.

4. Enter the following code: // Blinky.c #include <avr/io.h> #include <util/delay.h> void wait(void); int main (void) { // set PORTD for output DDRD = 0xFF; while(1) { for(int i = 1; i <= 128; i = i*2) { PORTD = i; _delay_loop_2(30000); } for(int i = 128; i > 1; i -= i/2) { PORTD = i; _delay_loop_2(30000); } } }

5. Select Project Menu Configuration Options. 6. Configure the General tab.

7. On the Custom Options tab, use [ADD] to add "-std=gnu99" to the list of project options.

8. Save everything. 9. Click the Clean Current Configuration button on the toolbar. (F12) 10. Click the Build Active Configuration button on the toolbar. (F7)

11. When you are editing a GCC project, help for the GCC plug-in can be obtained by Help AVR GCC Plug-in Help. When not editing a GCC project you may reach the GCC plug-in help by Help AVR Tools User Guide AVR Studio Project AVR GCC Project. Aaron Garber Last Revised on March 21, 2006 email: aaron.groups@gmail.com

Potrebbero piacerti anche