reading, pay attention here. It’ll look the same a lot for you.
ones that you need to use:
Setting AVR fuses using avrdude
To actually get our AVR to do things the way we want at
the speed we want, we need to read the datasheets and program the fuses. The fuse bits set up various hardware options
that can’t be set with a program. Some AVRs have a single
fuse byte; some two and some even more. The ATTiny26 has
a high and low fuse byte. Tables 1 and 2 show what those are.
You have to study the fuse byte tables to understand them,
and experiment to see what they do sometimes because
defaults may be ‘ 1’ or ‘0’ and the word set doesn’t always
mean set to 1. Since this article is not a tutorial about the Atmel
AVR chips, I won’t go into detail here about the
meaning of these settings. We want our chip to run
on the internal RC oscillator which can be set to run
as high as 8 MHz. We want fast, so we will set the
ATTINY26 up for its maximum internal clock rate.
But how do you set the fuse bits? With
avrdude — which is an open source project whose
only purpose is to program Atmel microcontrollers.
If you are using the Pololu programmer that I
described, then you will have a certain device
driver file associated with it. In UNIX systems, all
hardware devices have a device file associated with
them and this file is located in /dev. You can’t see
this directory by using OS X Finder; you will need
a terminal window. At this point, you should have
the Developer files installed on your Mac. If you
don’t find the program Applications->Utilities->Terminal.app on your computer, then install the
Developer files right now before we go on. You
will need the Terminal application.
Start up a Terminal window, you’ll get a screen
that has a command line on it and it will — by
default — have you located in your home directory.
Make a directory/folder here by any name you like.
(I used “junk” in this case.) Type echo $PATH on
the command line. This will tell you if your AVR
programming binary directory is in your login path.
If you don’t see /usr/local/AVRMacPack/bin in
the returned string, then you will need to add it.
Figure 5 shows what you should be seeing.
When you have your PATH set up correctly, you
can use the AVR commands that I’m going to be
talking about. Connect your programmer to your
computer, your board to power, and your programmer
to your board. Now type ls /dev/cu* — you should
see the Pololu programmer appear as cu.Pololu.
This has worked for me with OS X 10. 4 (Tiger) and
10. 5 (Leopard) without having to go get more drivers.
If it doesn’t work for you, then check the Pololu
website to find out where to get drivers for your
OS. This device file is important because avrdude
needs to know how to talk to your programmer.
To find all of the options that avrdude can give
you, type avr-man avrdude and you’ll get a UNIX
man page display giving all of them. Here are the
avrdude –v –c avrispv2 –p T26 –P /dev/cu.Pololu –U
hfuse:r:high.txt:r –U lfuse:r:low.txt:r
A great deal of stuff will appear on the screen and at
the end it will tell you how the fuses are currently
programmed. It will also write the files high.txt and low.txt
in your current directory in binary format. This command
and options can be used to check your fuses. For our
ATTiny26, we want to program the high and low fuses to
0x17 and 0xE4, respectively. Since the default high fuse
setting is already 0x17, we only need to change the low
Fuse High Byte Bit No
Description
Default Value
7
—
1 (unprogrammed)
6
—
1 (unprogrammed)
5—
4 Select if PB7 is I/O pin or RESET pin
3 Enable Serial Program and Data Downloading
EEPROM memory is
2 preserved through the
Chip Erase
1 Brown out detector trigger level 1 (unprogrammed)
0 Brown out detector 1 (unprogrammed, enable BOD disabled)
1. The SPIEN Fuse is not accessible in serial programming mode.
2. When programming the RSTDISBL Fuse, Parallel Programming
has to be used to change fuses or perform further programming.
RSTDISBL( 2)
SPIEN( 1)
EESAVE
1 (unprogrammed)
1 (unprogrammed,
PB7 is RESET pin)
0 (unprogrammed, SPI
prog. enabled)
1 (unprogrammed,
EEPROM not
preserved)
BODLEVEL
BODEN
Notes:
Table 1. High Fuse Byte.
Fuse Low Byte Bit No
Description
Default Value
PLLCK
CKOPT( 3)
SUT1
SUT0
CKSEL3
CKSEL2
CKSEL1
CKSEL0
7
6
5
4
3
2
1
0
Use PLL for internal clock 1 (unprogrammed)
Oscillator options 1 (unprogrammed)
Select start-up time 1 (unprogrammed)( 1)
Select start-up time 0 (programmed)( 1)
Select Clock source 0 (programmed)( 2)
Select Clock source 0 (programmed)( 2)
Select Clock source 0 (programmed)( 2)
Select Clock source 1 (unprogrammed)( 2)
Notes:
1. The default value of SUT1..0 results in maximum start-up time.
See Table 12 on page 30 for details.
2. The default setting of CKSEL3..0 results in internal RC Oscillator
at 1 MHz. See Table 3 on page 26 for details.
3. The CKOPT Fuse functionality depends on the setting of the
CKSEL bits. See “System Clock and Clock Options” on page 24
for details.
The status of the Fuse bits is not affected by Chip Erase. Note that the
Fuse bits are locked if Lock bit1 (LB1) is programmed. Program the Fuse
bits before programming the Lock bits.
Table 2. Low Fuse Byte.
SERVO 09.2008 21