internal 1 MHz oscillator. Recall from last
month when I set up our Eclipse system and
tested the compiler I set the clock speed to
16 MHz — what I run my stuff at so that I can
use Arduino bootloaders. Your brand new part
won’t have that clock speed; it will be 1 MHz.
I suggest that you start another project for a
1 MHz clock if you don’t want to dive into
avrdude/AVR configuration bits voodoo at this
time. If you want a faster setup that has a
faster clock, then continue reading.
WARNING: If you make a mistake playing with
the AVR FUSE registers, you will “brick” your
micro — it won’t be broken or anything, but
you’ll need an STK500 or similar to reprogram
the part to get the clocks back. To use the In-circuit System Programming of the AVRISP or
AVRISP II, you need to have a working clock. Messing with
the oscillator options and getting it wrong will leave you
unable to program using the ISP programmers. (You have
Now, here is how to set up your FUSE registers on an
ATMEGA328. This process will differ in the details for each
AVR part; the essentials are the same, but the bits and/or
bit locations differ. If you have an ATMEGA328 on a board
that you got from someone selling the boards, it may already
be configured to work with the clock system on that board.
Find out from your supplier what you have before you
continue on; you may not need to do this next step.
You will need a terminal window for this step. Type in
the following command line exactly as it is written to
configure your ATMEGA328 to use an external crystal or
resonator for high speeds. In my case, I used a 16 MHz
Figure 4. Ta da! You have programmed your micro.
ready to program your ATMEGA328 micro. All you have to
do is press the tool button on the right side (with the down
arrow thing) and select the prog328 program. You’ll
program your part with the compiler/linker generated .hex
file you told it to use. For subsequent programmings, all
you will need to do is press the button — the last tool used
will be the default. I have several programmer scripts in my
toolbox. I select the one I want based on the project I’m
doing at the moment. When you press that button, you
should see something like Figure 4 printed out in your
Console window in Eclipse.
Conclusions: What you have learned.
avrdude –c avrisp –p m328p –P /dev/ttyUSB0 –U
efuse:w:0x00:m –U hfuse:w:0xdf:m –U
A whole lot of stuff is going to be printed in your
terminal window as this command does its thing. If
everything wrote and verified properly, you’re done. If not,
check your connections, your typing, and your assumptions;
one of them is incorrect.
You’re now set for higher clock rates. As soon as this
command is complete, you will be in the new mode. I
strongly suggest that you have your AVR set up on your
protoboard with a resonator or crystal circuit before you run
this command. Remember, the above incantation requires
that your configuration is exactly as I’ve been describing in
this set of articles.
Running your new programmer tool.
Now that you have everything that you need
configured and your IDE setup and your compiler working
(remember, you got it working last month), now you are
This concludes my mini tutorial about how to install the
avr-gcc tools, Eclipse, avrdude, and all that you need to
develop and program AVR microcontrollers on Ubuntu
Linux. This very same environment can be installed and set
up on a Windows or Apple OS X system. The OS X and
Linux versions are nearly identical since they are both UNIX
variants. I started with a brand new installation of Linux on
my laptop and installed everything exactly as I described
here. It worked the first time.
SERVO 05.2010 15