Go Down

Topic: ATtiny84 & <avr/fuse.h>, fuses automatically programmed? (Read 668 times) previous topic - next topic


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:
Code: [Select]
// 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:
Code: [Select]
#---------------- 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 <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.

AVRDUDE_FLAGS +=-b 19200

Code: [Select]
# 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 (http://www.nongnu.org/avr-libc/user-manual/group__avr__fuse.html) 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?

Tom Carpenter

Jul 07, 2014, 09:45 am Last Edit: Jul 07, 2014, 09:48 am by Tom Carpenter Reason: 1
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:
Code: [Select]

#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


I found something in the last post of this thread here on AVR Freaks: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=69013&postdays=0&postorder=asc&start=40

It seems to work well. Thanks anyway, Tom.

Go Up