Disponible uniquement sur Etudier
  • Pages : 10 (2295 mots )
  • Téléchargement(s) : 0
  • Publié le : 30 mars 2011
Lire le document complet
Aperçu du document
How to use WinAVR with AVR Studio 4, Visual C++ 2008 Express and Eclipse to program your AVR controller in C

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 anAVR – 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 theirfunctionality becomes clear to those who are not awfully familiar with them.

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.exeon 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 theoscillator 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 theconfiguration settings, go to: File -> Save As… and save the Makefile in your computer, later to be placed inside your project wannabe directory. You can also edit the Makefile by hand using WinAVR’s native text editor or any other standard text editor like notepad (or notepad++, SciTe etc). Experienced users tend to prefer this option, but novice users are advised to stick to this guide in order to avoidsilly downfalls. If you wish to compile your code manually the following steps can be followed: 1. Create a project directory. 2. Use a text editor to write your C code and save it using a .c extension. If header files are required they should be placed inside the project directory as well. 3. Use Mfile as instructed above to create the required Makefile. 4. Open a Command Prompt window and navigateto the project directory. 5. Type in make your_filename.c and press Enter

The output of the compilation is going to be your_filename.hex file which you can then directly flash to your controller using an appropriate programmer. In conjunction with a text editor, WinAVR offers all the necessary functionality to fully implement your AVR projects. Even though this true, there are much moreadvanced tools available that allow maximisation of your work output and minimisation of development times. Of course programming is all about logic behind processes, and this you have to learn and get accustomed to yourself. Nonetheless there are tools available that can make your life a bit easier.

Please read carefully…..
AVR controllers come with truly amazing support libraries which have beenbuilt from guru users over the years for the community. For references one needs to look no further than the AVR LibC documentation: http://www.nongnu.org/avr-libc/ This place is full of useful info and really helps to understand generic principles behind the functionality of the libraries that support the AVR. Last but not least, the Procyon AVR Library written by Pascal Stang offers an enormous...
tracking img