Eclipse Setup

Install the Eclipse development environment for AVR

I use Eclipse Indigo 3.7 (last time I tried, the new Eclipse 4.2 Juno still had stability issues, which are probably fixed by now). Eclipse 3.7 works equally well on Linux, Mac and Windows, and has more features than I can possibly use.

You will need to install Eclipse C/C++ version for your platform, then install the AVR plugin from within Eclipse. But before you do so, install the AVR cross compile tools and libraries for you platform:

On Windows, download and install  WinAVR 2010-01-20
On Mac, download and install Crosspack AVR

Download and install Eclipse IDE for C/C++ (3.7 Indigo) for your platform

From within Eclipse, install the AVR plugin.
AVR plugin installation instructions

Note: Eclipse AVR used to require the "PartsDescriptionFiles" folder which is part of Atmel AVR Studio 5 download, which you can still get here:
http://www.atmel.com/Images/as5installer-stable-5.1.208-full.exe
It would find that folder automatically if Atmel Studio 5 was installed on your computer.
The current version is now Atmel Studio 6, and this folder has been renamed "devices". I have Studio 5 installed on my machine, and it works great. I have not tested whether you need install Studio 6 or anything else with the new Eclipse AVR version.

Setup a new MarcDuino project

Launch Eclipse, and designate a folder as your workspace.
Go to File->New->C Project.
In the dialog window that opens, select AVR Cross Target Application, empty project,
Give it a proejct name. Beware, the project name should have NO SPACES in it, or you'll get a weird error at compile time.


Configure the project hardware properties for the MarcDuino board

Go to Project -> Properties
In the dialog window that opens, select AVR, then Target Hardware
Set the MCU Type to ATMega328p, and MCU Clock to 16000000 (our 16 MHz clock)


Configure AVRdude  and Fuse values

This assumes you will be using SparkFun's AVR Pocket Programmer as described here.

In the dialog box above, click on the right on AVRDude. Then go to the Programmer tab. Click New..., select USBTiny from the list, leave everything as default, name the scheme "AVR Pocket Programmer".


Next you should go to the Fuse tab. This is an important step. Setting the fuses will determine among others the clocking source for the ATmega328 chip, memory protection and programming methods. If you set it wrong, there is a good chance you will brick your chip forever. Double check the fuse values twice. You only have to set the fuses once at the first upload. You can disable downloading fuses afterwards.

Click direct HEX values -> click convert -> fill values with FF DF 07


Click OK to dismiss the dialog.

Import source files into the project

Source files are at the bottom of this page. Select the zip file for the board you want to build, download it and unzip it.

Go to File -> Import
In the dialog that appears, choose File System.


Click Next, and Browse... to select the folder where you expanded the source files. Put a checkmark next to it to select all the files.


Click Finish. All your project files should now appear into your project folder (and don't do like me and use spaces in your project name!). If you double click on main.c for example, the main program source file will open in the editor tab. You can now explore and edit the source code as desired.


Compile and upload the code

Make sure your project folder is selected. Click on the little arrow next to the Hammer Icon, and select Release. The source code will compile, takes just a few seconds.


The console window should appear at the bottom with some kind of good news like this:


Once that is done, you can simply upload the code and set the board fuses with one click on the AVR* icon.


On occasion, I get an error "Could not find USBTiny device", just unplugging and replugging the Pocket Programmer fixes it.

Your program should upload and the telltale red LED light should begin to flash after it's done, indicating the program is running.






Comments