Getting an ATtiny85 to work with an external clock

I'm new to the ATtiny line, and have been trying for some time to get my ATtiny85 to work with an external 20 MHZ crystal. I've been programming it with an Arduino Uno as an ISP, and downloaded a program that I thought I could modify (with the help of this site) to set the fuse values to get it to work with an external 20 MHZ clock, but with no success. I know all my circuitry is right, as I was able to upload the program successfully with the default fuse configurations, I just can't figure out how to modify the sketch to program the fuse values I want, or what those fuse values might be. Now I'm wondering whether I can set the correct fuse values with the program, and if so how, or whether there's an easier way to go about this.

Any input or pointers would help. Thanks!

Here is the program I'm using

The program you have linked is for high-voltage serial programming, not ISP programming.

The two are not the same - ISP is easy in terms of hardware, and can often be done with everything still connected (hence "in-system programming"). HV serial programming is much more awkward, requiring more pins, and applying 12v to reset - but it lets you do things you can't do normally: You can reset the flags even if RST_DISABLE fuse is set, you can fix the fuse bits when you set the clock bits wrong and it's expecting an external oscillator that isn't there, reset the fuse that blocks ISP programming, and you can revive chips that you somehow scribbled over the device identifier on (though the one you linked doesn't have that feature). Like most of the HV serial code on the internet, the one you linked is hard-coded to just reset the fuses to default, so you can get into it with ISP to do whatever.

But the point is, you can't use HV serial programming code to change fuses via ISP.

If you examine the code for the ArduinoISP sketch, you can see that it accepts commands over serial, and this is what the IDE does when you, say, burn a bootloader. So, you can send those commands down the serial monitor, and have it tell the sketch to write the fuses appropriately. There may be an easier way to do this in the IDE - but I don't know it.

I use the USBASP ($7 shipped on ebay) and Extreme Burner AVR to set fuses on my ATtiny's. I've had no problems with it.

Thanks Azzy for the response! :wink:
I think I may have caused some confusion when I was talking about the programs I was using: I am using both the Arduino ISP example program that comes pre-installed with the Arduino Software as well as the program I linked. I was simply using the second program as a means to try to set the ATtiny's fuse values to what I desired; all my programming of the ATtiny was done with the ISP program.

Yeah - that's how I interpreted what you were saying.

The program you linked to, for HV Serial programming, is not readily modifyible to use In System Programming instead. You would need to build an HV serial programmer (which entails a 12v supply to apply to reset, and connecting to different pins than ISP), in addition to changing the code to set the fuses differently; I don't think this makes much sense to do, because all you're doing is trying to set the fuse bits on a working chip. This can be done using in-system programming.

If you were thinking you'd modify it to set the fuses via ISP instead of HVSP, the Arduino ISP sketch is much closer to what you want.

Imo, you should either reverse engineer the correct command to send to it over serial monitor to write the fuses using the stock Arduino ISP sketch (it's just a matter of sending the right characters down the line - the Arduino as ISP sketch takes its commands over serial), start from the Arduino ISP sketch instead of the HV serial one, (or buy a standalone ISP).

After playing around for a while I was able to change the board from using the internal 1 MHZ clock, to using the internal 8 MHZ clock, by burning the boot-loader while the ATtiny85 is hooked up to the Arduino running the ISP sketch. I tried connecting the 20 MHZ crystal to the ATtiny (with the recommended capacitors as well) and then burning the boot-loader again, but this time it didn't work. I think I probably either have the circuitry wrong, or there's something more I need to do to get it to work.

If yourcArduinoISP is working correctly, everything you want to do for fuses can be done from the command line. You need to read up on AVRDUDE command line.
Here are some examples from my article:
avr-firmware-duplicator

Ray

Sorry I left the thread for so long, I hope I didn't leave anyone hanging. I finally figured out my problem: I didn't realize I needed a crystal with the clock circuitry already built in, I was just using a basic 20 MHZ crystal. I managed to fix the problem by using a low frequency crystal from an old watch I had laying around. For anyone wondering how to do it, I found this video here quite helpful.

XepheraGeeb:
Sorry I left the thread for so long, I hope I didn't leave anyone hanging. I finally figured out my problem: I didn't realize I needed a crystal with the clock circuitry already built in, I was just using a basic 20 MHZ crystal. I managed to fix the problem by using a low frequency crystal from an old watch I had laying around. For anyone wondering how to do it, I found this video here quite helpful.

Hi, i am also trying to get my Attiny45 to work with external 32768kHz external oscilator. I also watched the video but i didn't managed to get it work.

Would you mind to mention step by step, what to do and which software and hardware you used for it?

On the Video it seems that you don't need any capacitors for the oscilator. I have downloaded the code but i don't know which software can handle or open it to transfer it to the Attiny.

Do i need the tinyisp or is it possible to do it with arduino uno as isp?

I tryed to burn the fuses with AVRDUDESS and i think it worked, but since then i cannot do anything with the Attiny, i think maybe i have to put the external oscilator to it ? but how do i now upload the code to it?

I hope you guys can give me any helpfull hints, i try to do this since some months but the are no good explanations about using the 32768kHZ external Oscillator.

I think there is also another way without using the external oscillator by sunchronizing the internal oscilator but there is also no good how to.

Thank you in advance for the support.

Greets