Using ATTiny45 with an External 16Mhz crystal

Hello forum!

I'm pretty new to the whole Arduino thing, but I've been having a lot of fun so far!

I'm trying to use an ATTiny45 as an IR remote control, and I'm just using the internal 8MHz clock. It's been intermittent at best.

Searching around, I see people are using 20MHz crystals with these chips, but all I have on hand are the 16MHz ones.. which is really fast enough for what I'm doing.

I know I need to set fuse bits for it, but I don't know how to do that and I don't see any options for it in the Arduino IDE.

I'd just use the ATMega328, but since I'm only using 2 digital IO pins, this seems like crazy overkill.

The ATtinyX5 family will run at 16 MHz from the internal oscillator.

Tuning the oscillator will probably get you much better results without having to use an external crystal.

Board entry for using an external crystal with an ATtiny85. The fuses should be identical for an ATtiny45…
http://code.google.com/p/arduino-tiny/source/browse/Prospective+Boards.txt#194

So just burn the ATTiny85 bootloader to it?

Speed isn't the question (since 1MHz is plenty fast enough for what I'm doing), just simpler to do this than to try to rely on the internal oscillator.

edit:

avrdude: Expected signature for ATtiny85 is 1E 93 0B
         Double check chip, or use -F to override this check.

I find it hard to imagine anything simpler than an Attiny at 1MHz ???

...R

Huh?

Can't they run at 128KHz or something?

Anyway, I just want to run with the external 16MHz crystal so I can get reliable timings without messing with it too much.

danrulz98: I know I need to set fuse bits for it, but I don't know how to do that and I don't see any options for it in the Arduino IDE.

The Arduino IDE sets the fuse bits when you do "Burn bootloader" (even when there's no bootloader to burn).

The easiest way to edit them is in your "boards.txt". Make a copy of the ATTiny45 section with a different name and change the fuses in there. Now select your custom entry and do "burn bootloader".

###########################################################################
attiny45at16e.name=ATtiny45 @ 16 MHz  (external crystal; 4.3 V BOD)

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

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

attiny45at16e.upload.maximum_size=4096

# 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 level at VCC=4.3 V; [BODLEVEL=100]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]

attiny45at16e.bootloader.low_fuses=0xFF
attiny45at16e.bootloader.high_fuses=0xD4
attiny45at16e.bootloader.extended_fuses=0xFF
attiny45at16e.bootloader.path=empty

attiny45at16e.bootloader.file=empty85at16.hex

attiny45at16e.build.mcu=attiny45
attiny45at16e.build.f_cpu=16000000L
attiny45at16e.build.core=tiny
 
###########################################################################

For anyone doing this in the future…

Thankya

danrulz98: Anyway, I just want to run with the external 16MHz crystal so I can get reliable timings without messing with it too much.

You appear to be under a substantial misunderstanding here. You clearly have not looked inside a standard remote control unit.

I'll wager you will not find a crystal inside. More likely a ceramic resonator at 455kHz (cheapest sort), but quite possibly not even that.

If you are having trouble getting your circuit to operate reliably, look for anything other than the frequency stability. More likely, you are simply not getting the frequency generation correct due to code faults.

Have you seen this project?

http://nathan.chantrell.net/20121014/tinypcremote-an-attiny85-based-infrared-pc-remote-control/

Ok, it's an ATTiny85 but it is an IR Remote, no crystals...

dannable: http://nathan.chantrell.net/20121014/tinypcremote-an-attiny85-based-infrared-pc-remote-control/ Ok, it's an ATTiny85 but it is an IR Remote, no crystals...

It's actually the receiver, but a couple of points are notable. One is that the 38 kHz is handled by the IR sensor and accuracy for that is minimal - a kilohertz either way is not generally a problem.

The other is that the oscillator calibration is significant not for the decoding of the IR codes, but for the USB interface.

Yeah, I've seen the USB receiver, that's pretty neat. Well, since burning that bootloader with those fuses and using it with the 16MHz crystal, it works perfectly. I was using the ATMEGA328 to test my code and that worked totally fine, and now that the ATTiny is running with a crystal, it's working 100%.

If you look at something like the TV-B-Gone, it uses one of those cheap little resonators too. But, the 16MHz crystals is just what I have on hand. I don't see much of a point in ordering resonators when I have the overkill-accurate crystals in my parts bin.