Pages: [1]   Go Down
Author Topic: ATtiny84 & <avr/fuse.h>, fuses automatically programmed?  (Read 587 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
Karma: 15
Posts: 508
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am programming a set of ATtiny84Vs using WinAVR. I am using the makefile from the WinAVR Makefile generator, which is attached below since it is too big to post.

I wish to use the macros in the <avr/fuse.h> header file to set the fuses in code for my set of ATtinys, rather than program them individually using avrdude. For example:
// Fuse settings
.high = (FUSE_SPIEN),
.extended = (EFUSE_DEFAULT),
In particular, I am changing the SUT (Start Up Time) fuse bits to a shorter startup than the default (4 ms instead of 64 ms).

If I have this in my code and compile it with "make all", then use "make program" to upload it to my uC, will the fuses be appropriately programmed? Do I need to add something to my makefile in order to program the fuse bits? Or do I just have to do it manually with the AVRdude terminal?

Relavent section from the makefile:
#---------------- Programming Options (avrdude) ----------------

# Programming hardware
# Type: avrdude -c ?
# to get a full listing.

# com1 = serial port. Use lpt1 to connect to parallel port.


# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.

# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.

# Increase verbosity level.  Please use this when submitting bug
# reports about avrdude. See <>
# to submit bug reports.

AVRDUDE_FLAGS +=-b 19200
# Program the device. 
program: $(TARGET).hex $(TARGET).eep
In particular, I see -U flags for the flash and eeprom, but not any of the fuse bits. Do I need to add these flags myself in order to program the fuse bits?

The documentation at the avr-libc page ( says:
Programming tools can take advantage of the fuse information embedded in the ELF file, by extracting this information and determining if the fuses need to be programmed before programming the Flash and EEPROM memories. This also allows a single ELF file to contain all the information needed to program an AVR.
This seems to say that you can set the programmer up to automatically program the fuses, but it doesn't tell how. Does anyone ave any experience in this area?

* Makefile (17.11 KB - downloaded 5 times.)

Leeds, UK
Offline Offline
Edison Member
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only way to program the fuses is by ISP or HVSP. It is not possible to do it from code running on the microcontroller.

You can however do it in the makefile:
#How to program the fuses
AVRDUDE_WRITE_FUSES = -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
#Set up your fuse values:
HFUSE = ...
LFUSE = ...
EFUSE = ...

# Program the device.  
program: $(TARGET).hex $(TARGET).eep
« Last Edit: July 07, 2014, 02:48:51 am by Tom Carpenter » Logged


Offline Offline
God Member
Karma: 15
Posts: 508
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found something in the last post of this thread here on AVR Freaks:

It seems to work well. Thanks anyway, Tom.

Pages: [1]   Go Up
Jump to: