Yahia
How to use WinAVR with AVR Studio 4, Visual C++ 2008 Express and Eclipse to program your AVR controller in C
OVERVIEW
This is a guide for setting-up the programming environment required to create, compile and upload your C code to your AVR controller boards. Both Supermodified and Arduino controller boards are built around ATMEL’s ATMEGA 48p/88p/168p/328p family which is an AVR – based μC. Once these simple instructions are followed you will be able to compile and upload your code to any AVR – based controller, so this document can come really handy. Before we make a start it is necessary for you to download the following open – source programs: • • • • WinAVR AVR Studio Microsoft Visual C++ Express 2008 Eclipse
Let’s have a closer look at these tools so their functionality becomes clear to those who are not awfully familiar with them.
WinAVR
WinAVR is ATMEL’s native compiler comes with a suite of executable, open source software development tools for the Atmel AVR series of RISC microprocessors hosted on the Windows platform. It includes the GNU GCC compiler for C and C++. Download WinAVR from: http://winavr.sourceforge.net/ and run WinAVR_install.exe on your computer. Following a successful installation, go to: Start Programs WinAVR MFile
This is a Makefile generation utility. It allows you to configure your compiler according to your project needs and produce the hex files that will be later uploaded to your μC. Here is where you instruct your compiler what device you are using so it can load the appropriate register map, what is the oscillator speed the device will run at, the target file name, compiler optimisation options etc. You have to make sure the following settings are chosen from the Makefile drop-down menu: Main File Name: MCU Type: Output Format: Optimisation level: Debug level: C Standard Level: your_main_filename.c ATMEGA328P (your controller here) ihex 2 ELF/DWARF-2 gnu99
Once you are happy with the