Getting started with Eclipse and Arduino Nano (ATMega 328p) on Windows 10

Suhirthan
6 min readMar 28, 2016

During the weekend I decided to test out the possibility of programming an Arduino Nano (probably fake) which I ordered from eBay a while back, using Eclipse and the standard AVR libraries. It turned out quite successful so decided to share it with you guys.

Keep in mind the set-up is a bit complex than running an Arduino IDE, but its a better way (according to me) to understand the inner working of AVR micro-controllers. I’ll try to make it simple by dividing the set up into steps. So lets dive in.

Step 1 : Downloading the IDE

Go to http://www.eclipse.org/downloads/ and download the “Eclipse IDE for C/C++ Developers” variant, pick the 32 or 64 bit based on your operating system.

Eclipse Downloads page

Once the files are downloaded, extract it and paste in your local disk. I am extracting it to a folder called eclipseC in my C:\ drive.

Extracted files in eclipseC

Once its extracted open the folder and run the eclipse.exe file. Assign the work-space press OK, this will open the Eclipse IDE with the welcome screen. For ease of use its better to add a shortcut to the desktop for the eclipse.exe file. Now we have completed the IDE installation lets move on to the next step.

Step 2: Installing AVR GCC compiler and AVR Dude

The AVR GCC and AVR Dude can be found on the WinAVR downloads page. Just download it and run the installation. Its a pretty straight forward installation. Once the installation is complete, check it via CMD by typing in

avr-gcc -v

for which you should get the following response.

Using built-in specs.
Target: avr
Configured with: ../gcc-4.3.3/configure — enable-win32-registry=WinAVR-20100110 — with-gmp=/usr/local — with-mpfr=/usr/local — prefix=/c/WinAVR — target=avr — enable-languages=c,c++,objc — with-dwarf2 — enable-doc — disable-shared — disable-libada — disable-libssp — disable-nls — with-pkgversion=’WinAVR 20100110' — with-bugurl=’URL:http://sourceforge.net/tracker/?atid=520074&group_id=68108&func=browse'
Thread model: single
gcc version 4.3.3 (WinAVR 20100110)

The last thing to do is, download the DLL using the link and replace it with the existing DLL in {location}\WinAVR-20100110\utils\bin\ . Which will reduce the compile time errors that will popup during builds.

Step 3: Installing the Eclipse CDT plugin

Once the AVR tool chain is installed its time to install the CDT plugin. To do that Open Eclipse and navigate to the menu bar select Help > Install New Software . A window will pop up on that, fill in the Work with field with the following URL and press the Add button.

http://avr-eclipse.sourceforge.net/updatesite/

On the window that pops up give a name for the plugin, AVR Eclipse Plugin would be ideal, and click Ok. After a brief period of time the window below will be displayed, select the AVR Eclipse Plugin and click next and continue to finish the plugin install.

CDT Plugin install Window

A popup will show you the download progress. During the download or install process if the popup asks to allow the use of unsigned software please press Ok. Once it’s installed it will ask for eclipse to be restarted please press Yes, after the restart Eclipse is ready for our first application.

Step 4: Connecting the Arduino Nano and Driver Install

Sometimes installing the Arduino driver can be an difficult, hopefully this will be simple and straight forward. Download the file from this link and run the installer based on your operating system version. Once the driver is installed the device manager will show the Arduino as USB-Serial CH340, once its connected to the PC.

After Driver Installation

Step 5: Creating and Configuring a new application

New Project Window

To create a new application go to File > New > C Project. Fill in a project name, and select the project type as Empty Project under AVR Cross Target Application. Finally click Finish to create the project.

I am calling my project LED, as per the image displayed on the left.

Once the application is created we can move on to configuring the build options. To start off Right Click the Project Name on the Project Explorer Tab, and click on properties which will bring out the project properties window.

From the list on the right side expand the C/C++ Build option and click Settings. Make sure the Generate Hex File for Flash Memory, Print Size, and AVR Dude options are checked as shown in the image.

Build Settings

The last part of the project set up is to instruct Eclipse on the AVR controller we are going to program. The one we are using is the ATmega328P micro-controller. In order to do that, explan the AVR option on the roperties window and click on AVRDude. Since this is the first time creating a new project there are no programmer configurations, to add one click on the New button on the right of the window. Which will bring up the Programmer configuration window. Type the Configuration name as Arduino 328p, Select Arduino as the Programmer Hardware, fill in the correct COM Port (mine is connected to COM3) and select the baud rate as 57600.

Programmer configuration window

Now that all the required configurations are done its time to create the source file, build and run the project.

Project Explorer Tab

On the main menu select File > New > Source Folder and call it src . This will be the project source folder all code related to the project will be added here. Now right click on the newly created src folder and select New > Source File , and call it main.c We are done with the files. Now the project explorer will look like the the image on the left.

Add the following code given in this link. Let’s change the delays to 500ms each, and click Build All (Ctrl + B) or the file icon with binary numbers. Once the build is successful, we can proceed to upload the code by clicking on the the AVR Button.

Now that everything is done, all we have to do now is to connect an LED and check if the program works. As the program is written to blink the LED connected to PORTB0, we connect it to Pin D8 (Pinout Diagram) on the Arduino Nano.

LED Blinking

That’s it folks, you can create more projects and explore. I will make more programs available in the coming weeks. Don’t be shy to post your question and feedback below.

--

--