Arduino Part 3

In embedded software on February 19, 2011 at 8:10 pm

Learning More–getting ready for the class

I’ve learned a bit more about the Arduino in the last couple of weeks, since my last Arduino post. Most of the information has been about using Eclipse and the Arduino Uno. The basic project I completed last time was the simple blinking example on the Decimilia board. This is an ATmega168 processor and runs just fine. However, when you go to Eclipse, you need to make sure that you set the clock frequency to 16000000 and not 1000000 as in some of the documents. Other than that, everything works just great.

Enter the Uno

The Arduino Uno is the latest version of the Arduino. I ordered a starter kit from Amazon. It was a duemilanove kit, but shipped with the Uno. It has the ATmega328p processor. It worked just fine with the Arduino IDE, but when I tried to duplicate the steps to get it working with Eclipse, I failed miserably. It’s taken a while to track things down, but I think I’ve got it pretty much sorted out now.Here are some of the things that I’ve found helpful.

  1. When you set up the AVRDude configuration for the Uno, the baudrate should be 115200 instead of 57600 as some of the documents indicate. This will get rid of the annoying “stk500_recv(): programmer is not responding” message when AVRDude runs.
  2. In order to see what’s going on with the Arduino IDE, you can modify the preferences.txt file to add some verbose options. The file is in the Library/Arduino directory under my home directory on the Mac. A couple of the useful things I’ve found are adding the following lines:
    • upload.verbose displays the command line used for invoking AVRDude.
    • build.verbose=true displays the output of the build process.
  3. I’ve copied the Uno core.a library created by the Arduino IDE and am going to just use it rather than trying to create an Eclipse project for building such a library like I did for the Diecimilia. This will reduce the number of things I have to work with and it is the preferred way of getting the library according to the installation. One of the problems is finding the library on the system on the Mac. The location of the libraries is specified for other platforms in the Eclipse installation instructions from the Arduino playground. It took a little while, but after putting in the “build.verbose” file in the Arduino IDE’s preferences.txt file, I found the directory. It was in /var/folders/7A/… . Not the most obvious place. I moved this into my a lib/arduino directory in my home directory.

After all of this, I still am not getting the program to execute. It compiles, loads, but does not run on the Uno.

Finally: Success

So, it was back to the drawing board. I went back and recreated a separate project for the Uno core library. Then I compiled that and created a new project for the Uno blink program, and it worked. It’s still not the easiest thing to make sure you get all of the settings correct, but it is nice to see the light blink.

Next, I think I’ll work on building the project in a more simple environment, like a text editor, command line compilation, and make.

First, it’s probably worth recording the settings I’ve got on the two projects.

Uno Core Library Project

I simply copied all of the sources from the …/cores/arduino directory to the top level of this project. I deleted the main.cpp as the Eclipse installation directions said. Next, I followed the directions from the Eclipse installation page exactly. The relevant preferences settings for the project are:

  • AVR>Target Hardware: ATmega328p, 16000000 MHz.
  • C/C++ Build>Seettings: no debugging information, and optimize for size on both compilers (C and C++). Also, the other optimization flags for the C++ compiler are”-ffunction-sections -fdata-sections -Wl,–gc-sections”.

I have both the debugging and release configurations set for this, but it only needs release. We’re not really worrying about debug configurations at all here.

The Uno Blink Project

Again I followed the instructions in the Eclipse installation directions. There was one thing not covered which got the library included in the linking. Here are my settings:

  • AVR>AVRDude: Uno programmer configuration. No switches set under Advanced tab.
  • AVR>Target Hardware: same as above.
  • C/C++ Build>Settings
    • Additional Tools in Toolchain: Generate Hex Files for Flash Memory and Print Size are checked.
    • AVR Compiler>Directories: “${workspace_loc:/UnoCore}”, where UnoCore is the name of my Uno core library project.
    • For both compilers (C and C++), no debugging and size optimizations.
    • AVR C++ Compiler>Directories: same as for the AVR Compiler.
    • AVR C++ Compiler>Optimization: -ffunction-sections -fdata-sections -Wl,–gc-sections
    • AVR C++ Linker>Libraries: Libraries (top): UnoCore, which is the name of my library for the Uno core. Libraries Path (bottom): “${workspace_loc:/UnoCore/Release}”.
  1. Hi

    i’m happy to find a post like this.
    just in time before moving my arduino dumeilanove with atmega320 in trash bin.

    How do you override baud rate?
    I catch the same error:
    “Binary sketch size: 1018 bytes (of a 14336 byte maximum)
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_recv(): programmer is not responding


    • You set the baud rate in the AVRDude Programmer preference. Bring up your Eclipse preferences and go to AVR>AVRDude pane and edit the programmer you use for the Uno.

  2. Nothing to do.
    Using Arudino UNO config, it says:

    avrdude: Version 5.4-arduino, compiled on Oct 9 2007 at 11:20:31
    Copyright (c) 2000-2005 Brian Dean,

    System wide configuration file is “/Applications/”
    User configuration file is “/Users/emaaaa/.avrduderc”
    User configuration file does not exist or is not a regular file, skipping

    Using Port : /dev/tty.usbserial-A9007MIy
    Using Programmer : stk500v1
    Overriding Baud Rate : 115200
    avrdude: Send: 0 [30] [20]
    avrdude: Send: 0 [30] [20]
    avrdude: Send: 0 [30] [20]
    avrdude: ser_recv(): programmer is not responding
    avrdude: stk500_recv(): programmer is not responding
    avrdude: Send: Q [51] [20]
    avrdude: ser_recv(): programmer is not responding
    avrdude: stk500_recv(): programmer is not responding

    • It’s got the right baud rate. It looks like something may be wrong with the Arduino or you have the wrong port selected.

  3. I have been working to get the arduino core library working for the UNO, in eclipse, with a C project (not C++). I can successfully compile a project in C and create the blink program without using arduino library functions (e.g, pinMode()). However, when I try to use eclipse to compile the arduino core and include it in my project the code hangs. It appears the code and library compile properly and load using AVRdude, but the code doesn’t loop. Any ideas?

  4. 57600 baudrate fixed my problem! Thanks!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: