Changing fuse settings in ATtiny24A with ArduinoISP

I got my hands on a few ATtiny24A's and I'm trying to configure one of them to use an external 16MHz crystal. Using ArduinoISP I have already successfully uploaded a sketch that runs properly at the default 1MHz internally generated clock frequency. But I can't figure out how to change the fuse settings. I've tried using avrdude in a terminal window (I'm running Ubuntu Linux) with the command:

avrdude -t -c arduino -p t24 -P /dev/ttyUSB0 -B 2400

and tried a bunch of different speeds ranging from 19200 down to 600. I get one of 2 responses every time:

avrdude: stk500_getsync(): not in sync: resp=0xe0
or
avrdude: stk500_recv(): programmer is not responding

The setup works fine to upload a sketch using Arduino0022 and the "upload.using=arduinoisp" line in the programmers.txt file.

The serial buffer in Arduino 1.0 is too small to work with the ArduinoISP sketch. To work around it you can reduce the baud rate in the sketch and in programmers.txt.

I'm not using Arduino 1.0 yet, but rather Arduino 22 (with Arduino Tiny installed and ATtiny24A details added as well). This has been working fine with ArduinoISP to upload sketches to the ATtiny24A. I just can't figure out how to change the fuse settings with it.

I suppose I should install Arduino 1.0 in the meantime and make the baud rate changes to ArduinoISP and programmers.txt and see what happens.

Ok, I installed Arduino 1.0, added the Arduino Tiny files, made the baud rate changes, and can now use ArduinoISP to upload to the ATtiny24A with the new IDE. Trying to use Avrdude in a terminal window to access the ATtiny24A through the ArduinoISP is not working any better than before. The only differences I've noticed is that I the old error message:

avrdude: stk500_getsync(): not in sync: resp=0xe0
is now reading
avrdude: stk500_getsync(): not in sync: resp=0x00

If I just type in "avrdude" without any parameters it reports that it's version 5.10 if that's of any significance.

ElectricWater:
Ok, I installed Arduino 1.0, added the Arduino Tiny files, made the baud rate changes, and can now use ArduinoISP to upload to the ATtiny24A with the new IDE.

Excellent.

Trying to use Avrdude in a terminal window to access the ATtiny24A through the ArduinoISP is not working any better than before.

Do you still need to use avrdude from a terminal window?

I haven't used Avrdude much at all, actually, so if there's a way to use it in Linux other than in a terminal window I'm not aware of it.

Let's set that aside for the moment.

There are no board entries for an ATtiny24. When you uploaded from the IDE, did you first create an entry?

Yes, I duplicated the ATtiny84 section in boards.txt and changed some of the parameters to match the ATtiny24A. I also copied and renamed the "empty" bootloader hex file the same way. I wasn't sure if this would work, but the Arduino IDE seems happy with wthe changes I made.

Post the entry you created and I'll walk you through the last steps to get the processor running from a 16 MHz crystal.

###########################################################################

attiny24at1.name=ATtiny24 @ 1 MHz  (internal oscillator; BOD disabled)

# The following do NOT work...
# attiny24at1.upload.using=avrispv2
# attiny24at1.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
attiny24at1.upload.using=arduino:arduinoisp
# attiny24at1.upload.protocol=avrispv2
# attiny24at1.upload.using=pololu

attiny24at1.upload.maximum_size=2048

# Default clock (slowly rising power; long delay to clock; 8 MHz internal; divide clock by 8))
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Divide clock by 8 internally; [CKDIV8=0]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny24at1.bootloader.low_fuses=0x62
attiny24at1.bootloader.high_fuses=0xD7
attiny24at1.bootloader.extended_fuses=0xFF
attiny24at1.bootloader.path=empty
attiny24at1.bootloader.file=empty24at1.hex

attiny24at1.build.mcu=attiny24
attiny24at1.build.f_cpu=1000000L
attiny24at1.build.core=tiny
 
###########################################################################

Moderator edit: changed to
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags.

A few more questions...

• Should the Brown Out Detector (BOD) be enabled?
• At what voltage will you be running the ATtiny24?
• Do you prefer to have the EEPROM preserved when programming or cleared?

The BOD can be left disabled.
I'm running the device at 5V.
I would prefer EEPROM preservation during chip erase.

Thanks.

Excellent. Let's get to work...

I will be using this fuse calculator... http://www.engbedded.com/fusecalc/

We'll change the key and name to something that more accurately reflects the board...

attiny24at16.name=ATtiny24 @ 16 MHz (external crystal; BOD disabled)
attiny24at16.upload.using=arduino:arduinoisp
attiny24at16.upload.maximum_size=2048

I went with these fuse settings...

Ext. Crystal Osc.; Frequency 8.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms; [CKSEL=1111 SUT=11]

Brown-out detection disabled; [BODLEVEL=111]

Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

Serial program downloading (SPI) enabled; [SPIEN=0]

Which gives us these...

attiny24at16.bootloader.low_fuses=0xFF
attiny24at16.bootloader.high_fuses=0xD7
attiny24at16.bootloader.extended_fuses=0xFF
attiny24at16.bootloader.path=empty
attiny24at16.bootloader.file=empty24at16.hex

A few more small changes...

attiny24at16.build.mcu=attiny24
attiny24at16.build.f_cpu=16000000L
attiny24at16.build.core=tiny

And that should do it for the boards.txt entry.

The "bootloader" is really an empty stub. It's purpose is to satisfy the IDE so we can change the fuse settings without having to leave the comfort of the IDE. To create a stub for the ATtiny24, we...

• Ensure the Arduino IDE is not running
• Temporarily switch to the "empty" core by making this change to the boards.txt file...
attiny24at16.build.core=empty
• Start the Arduino IDE
• Ensure our board is selected
• Click Verify
• Navigate to the %TEMP% directory
• Locate the dot-HEX file
• Copy it to the hardware/tiny/bootloaders/empty directory
• Rename it to empty24at16.hex
• Close the Arduino IDE
• Restore the boards.txt file...
attiny24at16.build.core=tiny

At this point, we should be able to...

• Start the Arduino IDE
• Ensure our board is selected
• Execute Tools / Burn Bootloader / Arduino ISP

The fuses should now be set so the target runs from an external high frequency crystal.

This is the boards.txt entry I used...

###########################################################################

attiny24at16.name=ATtiny24 @ 16 MHz  (external crystal; BOD disabled)

# The following do NOT work...
# attiny24at16.upload.using=avrispv2
# attiny24at16.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
attiny24at16.upload.using=arduino:arduinoisp
# attiny24at16.upload.protocol=avrispv2
# attiny24at16.upload.using=pololu

attiny24at16.upload.maximum_size=2048

# Ext. Crystal Osc.; Frequency 8.0-    MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms;  [CKSEL=1111 SUT=11]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]

attiny24at16.bootloader.low_fuses=0xFF
attiny24at16.bootloader.high_fuses=0xD7
attiny24at16.bootloader.extended_fuses=0xFF
attiny24at16.bootloader.path=empty
attiny24at16.bootloader.file=empty24at16.hex

attiny24at16.build.mcu=attiny24
attiny24at16.build.f_cpu=16000000L
attiny24at16.build.core=tiny
 
###########################################################################

I've attached empty24at16.hex to this post.

I do not have an ATtiny24 so I cannot test my work. You should carefully review what I've done before executing Burn Bootloader. If you find any mistakes, please reply so others can avoid the mistakes.

empty24at16.hex (173 Bytes)

I followed all of your instructions right up to the step where the empty bootloader hex file is to be created by clicking "Verify". At this point I got the error"

sketch_apr13a.cpp:3:21: error: Arduino.h: No such file or directory

I navigated to the %TEMP% directory, which contains a new directory called "build9050422041432852183.tmp"
Inside this directory is a single file called "sketch_apr13a.cpp"
No .hex file to be found.

I went ahead and used the empty24at16.hex file you attached and continued following your instructions. The rest went without any trouble, and the ATtiny24A is now running with the 16 MHz crystal.
Thank you for your help with this, and the explanations as well!

I'm very interested to find out what went wrong. I tried the same steps up to the "Verify" point in both Linux and Windows XP installations of Arduino 1.0 and got the same results with both. Did I miss a stop, or do I possibly have some important files missing or just stuck in the wrong place?

ElectricWater:
I followed all of your instructions right up to the step where the empty bootloader hex file is to be created by clicking "Verify". At this point I got the error"

sketch_apr13a.cpp:3:21: error: Arduino.h: No such file or directory

Looks like I did not include the "empty" core when I published...
http://code.google.com/p/arduino-tiny/source/browse/#svn%2Ftrunk%2Fhardware%2Ftiny%2Fcores

Sorry about that. I'll try to get it added over the weekend. In the meantime, I've attached the files. Assuming you installed the Tiny Core in the {Arduino Sketch Root} directory, the attached files belong in... {Arduino Sketch Root}\hardware\tiny\cores\empty\

I went ahead and used the empty24at16.hex file you attached and continued following your instructions. The rest went without any trouble, and the ATtiny24A is now running with the 16 MHz crystal.

Excellent!

Thank you for your help with this, and the explanations as well!

You are welcome.

empty.7z (508 Bytes)

Ok, I added the "empty" core and was then able to create the empty bootloader file, which upon comparison was seen to be identical to the one you attached earlier (good thing!).

I tried making a few more empty bootloader files with different fuse settings and after they were burned to the ATtiny24A's the uC's worked just as expected for each set of options I selected. So it's all good now!

Thanks again Coding Badly!

So now I get to work on coming up with ways to build sketches that will fit it the 2048 bytes in these TINY things, but still be capable of doing something useful. I know I could get some ATtiny84's, but where's the challenge in that? :grin: