Making An AVR Project In Eclipse

From WPI Automation and Interventional Medicine (AIM) Robotics Laboratory

Jump to: navigation, search


Contents

Making a New Project

Right click on your workspace and select

New>Project

You can also check out a new project from svn here: Set Up SVN For RBE Classes

Checkout.jpg


Also note that you want the AVR Application, not the static library option.

Project Name.jpg

Check off Release, and un-check Debug, then hit next. When you see the AVR configuration screen set up the fields with what the hardware in class will be using.

AVR Config.jpg

Making the Code Compile

To make the code compile you need a bare minimum of code. Make a new source folder called "src" by right clicking on your project and:

New>Source Folder

In the folder you want a new source file. Right click on "src" and:

New>Source File

Call the new file main.c and in it you will need a few lines of code to make it compile:


#include <avr/io.h>

int main(void){
	return 0;
}


In the console window you will see something like this:

Building target: LAB1_sample.elf
Invoking: AVR C Linker
avr-gcc -Wl,-Map,LAB1_sample.map -L"/home/hephaestus/workspace/RBELib/Release" -mmcu=atmega644p -o"LAB1_sample.elf"  ./src/main.o  ./src/driver/USARTDebug.o   -lRBELib
Finished building target: LAB1_sample.elf
 
Invoking: AVR Create Extended Listing
avr-objdump -h -S LAB1_sample.elf  >"LAB1_sample.lss"
Finished building: LAB1_sample.lss
 
Create Flash image (ihex format)
avr-objcopy -R .eeprom -O ihex LAB1_sample.elf  "LAB1_sample.hex"
Finished building: LAB1_sample.hex
 
Create eeprom image (ihex format)
avr-objcopy -j .eeprom --no-change-warnings --change-section-lma .eeprom=0 -O ihex LAB1_sample.elf  "LAB1_sample.eep"
Finished building: LAB1_sample.eep
 
Invoking: Print Size
avr-size --format=berkeley -t LAB1_sample.elf
   text	   data	    bss	    dec	    hex	filename
   2202	     50	      0	   2252	    8cc	LAB1_sample.elf
   2202	     50	      0	   2252	    8cc	(TOTALS)
Finished building: sizedummy

You are specifically looking for the line:

Finished building:

If this step finishes OK you will need to move on to the next step.

Setting Up the Programmer

Right click on your project and select "Properties". In the properties window select "AVR>AVRDude"

ProgrammerSetup.jpg

In the "Programmer configuration" section select "New...". In the Hardware section select "Atmel AVR ISP V2" and in th "Override default port (-P)" field select the serial port the OS selected for the programmer (for me it was COM6).


Pololu.jpg

Hit OK and select the new programmer you just selected. Hit apply and move on to the "Fuses" tab. Enter in the direct hex values of:

CF D1 FF

This will enable the external crystal, disable JTAG (Uses a lot of IO pins) and sets the start-up time. If you want to tweak these values to your application, hit the button with the pencil which is the fuse editor.

You can now move to the "Target Hardware" section on the left. Plug in your programmer, power up the chip, make sure the crystal is plugged in and enabled and verify that the "MCU Clock Frequency" is set to:

18432000

Now hit the "Load from MCU" button. This will read the chip ID from your target avr and load that into the selected field of the "MCU Type" drop-down. If yours says:

ATmega644P

Then everything is set up and your ready to program your MCU

Loading Code

Now you are ready to program you MCU. Select your project, not a file in your project. Save all files, as this is not automatic. Hit the hammer button to compile one last time. Then hit the button that has "AVR" and a green arrow on it. This will load the code to your MCU.

NOTE

Be sure to read the output. Just because the text streaming by is green, does not mean everything went ok. The debug output is very helpful, but only if you read it!

Personal tools