Arduino Eclipse Development environment

Source: Internet
Author: User

In summary, Eclipse Cdt,toolchain uses AVR Libc, as well: A, AVR Eclipse plugin plugin, b, make, RM and other shell command line tools, C, avrdude, to download the program to the microcontroller.

This essay is divided into 2 parts, the first part is the software installation and setup steps, the second part establishes a demo project, and compiles, downloads the program to the Development Board to determine the development environment to work properly.

1. Installation and Setup

First install Eclipse CDT, I use the new version neon. Install AVR Eclipse Plugin in Marketplace search.

There are 2 sources of toolchain. First, the microchip website can download AVR toolchain for Windows separately. Second, Atmel Studio can be installed with a shell command line tool in addition to the AVR libc. I used the latter to install Atmel Studio and then copy the things I needed.

The Arduino software is avrdude and can be copied directly.

Under the Atmel Studio installation directory, the path to Toolchain is Toolchain\avr8\avr8-gnu-toolchain, such as:

The path to the shell command-line tool is shellutils, such as:

Under the Arduino installation directory, the Avrdude path is hardware\tools\avr\bin\avrdude.exe and the configuration file path is hardware\tools\avr\etc\ avrdude.conf, copy them all and put them in the same directory. The Avrdude configuration file includes the current directory in the default search path, so you can put the configuration file and the executable program together. By the way, the Arduino installation directory also contains AVR LIBC, but has been modified by the Arduino project. There should be no problem with it, but I still use the official out.

In addition, the analysis of Avrdude.exe link relationship, found that it relies on LIBUSB0.DLL, so it needs to be copied together, placed in the same directory Avrdude.exe. Therefore, the Avrdude directory should contain 3 files: Avrdude.exe, avrdude.conf, Libusb0.dll.

When you are done, you need to set the PATH environment variable. I like to start eclipse with a bat batch so that you can set environment variables for eclipse alone, without modifying Windows system variables. The startup script is as follows:

Set Path=%windir%\system32set Java_home=c:\java\jdk_x64\jdk1.8.0_144set Toolchain_home=%cd%\avr8-gnu-toolchainset Shellutils_path=%cd%\shellutilsset Avrdude_path=%cd%\avrdudeset path=%java_home%\bin;%toolchain_home%\bin;% Shellutils_path%;%avrdude_path%;%path%start%cd%\eclipse\eclipse.exe

Well, I admit, these paths are really unnecessary. The AVR Eclipse plugin plug-in settings still require these paths to be set. However, one of the benefits of adding to path is that you can manually execute some command lines in Eclipse Terminal. Then set up AVR Eclipse Plugin, such as. You need to set these paths:

    • Avr-gcc:toolchain the bin in the installation directory
    • Make:shellutils Directory
    • AVR Header files:toolchain installation directory of Avr\include
    • Avrdude:

The configuration file path for the avrdude also needs to be specified, such as:

Next, add Avrdude's "Programmer Configuration". Simply put, the Programmer configuration is a template that invokes the commands and options of the Avrdude writing program. One way to determine avrdude commands and options is with the Arduino software. In the Arduino software, download a program to the Development Board and observe the command calls in the output area, for example:

  

This can be determined for Arudino UNO:

    • The protocol is Arduino (-c Arduino)
    • MCU for atmega328p (-P atmega328p)
    • Serial number COM4 (-P COM4)
    • Baud rate is 115200 (-b 115200)
    • -D option

In accordance with the above settings, add Arduino UNO programmer configuration, as follows. This is mainly the choice of protocol and serial port parameters, the remaining options will be automatically complete by AVR Eclipse plugin. You can view the command-line previews at the bottom of the interface:

2. Demo Project

Engage a Blink demo project. Create a new C Project, select the AVR GCC toolchain, and specify the MCU model and frequency. Arduino Uno is the Atmega328p,16mhz frequency:

Increase the source file main.c to achieve led flicker, the code is as follows. The LED on the Arduino UNO Development Board is connected to the PB5 port:

#include <avr/io.h> #include <util/delay.h>int main () {    DDRB = 0xFF;    for (;;) {        pinb = 1 << PINB5;        _delay_ms (+);        PINB = 0;        _delay_ms (+);    }}

  

You need to make some settings for the project properties. First specify the hex file to be generated:

Next, set the parameters for the avrdude. Programmer configurations Select the Arduino uno configuration created in the first section earlier. The-D option is enabled in the Advanced tab. Note that the previous Arduino software call Avrdude command line, you can see that it uses this option:

Now it's ready to compile. Select Menu Project->build Project, if compiled successfully, the Blink.hex file will be generated in the debug directory. Then select the menu avr->upload Project to Target Device and download the hex file to the Development Board. Note the output from the console view to confirm that the compilation and download were successful. If all goes well, when the program is downloaded to the Development Board, the LEDs blink at 1s frequency:

Arduino Eclipse Development environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.