How to Configure ATtiny85 for 8 Mhz

I have a working ATtiny85 that load sketches into using Board=ATtiny85 with Arduino as ISP
and Programmer = Arduino as ISP.
I want to be able to do serial communications so I read that the tiny needs to be configured for 8 Mhz.
I changed the clock frequency line in Boards.txt from XXXXXXX_1000000 to XXXXXXX_8000000 and
reloaded the IDE Blink Example sketch without problem. Now the LED-(0) is flashing for 8 times longer
(roughly, I didn't time it ...) with the delay(1000); statement . I assume that when you configure it
for a different clock speed the cpu automatically calculates the delays for that clock speed. Obviously
the sketch is running but apparently still at 1 Mhz but the delay has been recalculated for the 8 Mhz
clock speed. I did not use the BURN BOOTLOADER option because I read that is for setting fuses for
external xtals (like 20 Mhz and if you do that you better have the right xtal and caps handy .
So what am I doing wrong ?
Any help would be greatly appreciated.

raschemmel:
I did not use the BURN BOOTLOADER option because I read that is for setting fuses for
external xtals (like 20 Mhz and if you do that you better have the right xtal and caps handy .

...and also for all the other clocking options, eg. 8MHz.

OOPS !
Thanks for the heads up.

I found a reference online here:
http://avrhelp.mcselec.com/index.html?using_usi_universal_serial_int.htm

to an 8 Mhz "INTERNAL" xtal in the ATtiny85 in a USI-SPI program for the ATtiny85 from
which this exert was taken:

' Using USI as an SPI slave with Attiny85
' The ATTINY85 work with 3.3 V so we can direct connect it to an ATXMEGA
' Following you find also a SPI configuration with an XMEGA as SPI Master which I have tested with this SPI Slave
 
'(
Config Spid = Hard , Master = Yes , Mode = 0 , Clockdiv = Clk128 , Data_order = Msb , Ss = Auto
'SS = Auto set the Slave Select (SS) automatically before a print #X or input #X command  (including initialization of the pin)
'Master SPI clock = 32MHz/Clk128 = 250KHz
Open "SPID" For Binary As #12
')
 
$regfile = "ATtiny85.DAT"                                   
$crystal = 8000000                                     'internal crystal'
$hwstack = 32                                               
$swstack = 10                                               
$framesize = 30

How does that work ?
How can I configure my ATtiny85 to do that ?

raschemmel:
How does that work ?
How can I configure my ATtiny85 to do that ?

Find the file "boards.txt" in your projects folder.

Put this in it:

attiny85-8.name=ATtiny85 (internal 8 MHz clock)
attiny85-8.bootloader.low_fuses=0xe2
attiny85-8.bootloader.high_fuses=0xd7
attiny85-8.bootloader.extended_fuses=0xff
attiny85-8.upload.maximum_size=8192
attiny85-8.build.mcu=attiny85
attiny85-8.build.f_cpu=8000000L
attiny85-8.build.core=arduino:arduino
attiny85-8.build.variant=tiny8

Restart the IDE and select "ATtiny85 (internal 8 MHz clock)" as your board. Do "burn bootloader".

Thanks very much for your help!
I'll do it as soon as I get home.

I got a compile error .
I don't understand what it means.
I highlighted the verbose output but when I right-clicked the menu to copy didn't come up
so I had to take a screenshot and paste it into PAINT.
see attached.

It means you didn't install this: Google Code Archive - Long-term storage for Google Code Project Hosting.

I really want to use ATtiny85 with a 20mhz crystal... I bought some, but just confused about what to do to make it work at 20mhz

Any help welcome

mcnobby:
I really want to use ATtiny85 with a 20mhz crystal... I bought some, but just confused about what to do to make it work at 20mhz

Any help welcome

a) Copy/paste the "16Mhz external clock" option in your boards.txt under a different name.
b) Edit the clock speed ("f_cpu") in that newly created option, change it to 20000000

PS: Do you know the Tiny85 has an internal 16MHz clock?

The boards.txt entry is:

attiny85-16.name=ATtiny85 (internal 16 MHz PLL)
attiny85-16.bootloader.low_fuses=0xe1
attiny85-16.bootloader.high_fuses=0xd7
attiny85-16.bootloader.extended_fuses=0xff
attiny85-16.upload.maximum_size=8192
attiny85-16.build.mcu=attiny85
attiny85-16.build.f_cpu=16000000L
attiny85-16.build.core=arduino:arduino
attiny85-16.build.variant=tiny8

All you actually need to do is to get your attiny running at 8MHz instead of 1MHz is change the CLKDIV8 fuse in the attiny. You can do this using avrdude to program the fuses via your ArdunoISP setup. I describe the process for at atmega328p here Prototyping small embedded projects with Arduino | David Crocker's Solutions blog and it is just the same for an attiny - skip to the "Set the fuses" section at the end.

mcNobby:

If you want read up on the Fuse settings for the ATtiny85 see the following sections of attached datasheet:

FUSE TABLE PAGE
EXTENDED 20.2 148
HIGH 20.4 148
LOW 20.5 149

====================================================
Look at the following settings for 8Mhz & 16 Mhz and then compare them to the above sections in the datasheet.
attiny85-8.name=ATtiny85 (internal 8 MHz clock)
attiny85-8.bootloader.low_fuses=0xe2 // (11100010)
attiny85-8.bootloader.high_fuses=0xd7
attiny85-8.bootloader.extended_fuses=0xff

attiny85-16.name=ATtiny85 (internal 16 MHz PLL)
attiny85-16.bootloader.low_fuses=0xe1
attiny85-16.bootloader.high_fuses=0xd7
attiny85-16.bootloader.extended_fuses=0xff

You can use the following online HEX to BINARY converter to obtain the bit values:
http://easycalculation.com/hex-converter.php

atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf (3.67 MB)

REDO

FUSE TABLE PAGE
EXTENDED 20.2 148
HIGH 20.4 148
LOW 20.5 149

Thanks fungas for the info on the Lib !
And thanks dc42 for the very informative link that takes alot of the mystery out of fuse programming !

fungus,
I had already downloaded a zip file with the exact same name as the one on the link you provided but
I don't remember where I got it. When I unzipped it into the Hardware folder it was missing:
Prospective boards.txt
license.txt
\Bootloaders (folder)
so I downloaded the one at the link you recommended and it had all the missing files/folders but the
exact same filename and approx file size. I deleted the first one I had installed and installed the one
from the link you gave me and then did only "UPLOAD" to see if it changed the LED delay time and
it did. The delay was 8 times longer. Indicating that it reconfigured the IDE to run code for a device
with an 8Mhz clock. Once I confirmed this, went ahead and did BURN BOOTLOADER and the led
stopped flashing. Assuming this was normal and all it needed was a reset I just loaded the Blink
example using UPLOAD, the led came on flashing the correct 1000ms interval , indicating that the
internal 8Mhz clock was activated and running.
Thank you for all your help. I am now going to see if I can get TinyWire or ArduinoDebugInputKnockBang
to work, or any other communication or serial programs I can find for the ATtiny85.

fungus,
I followed the instructions here:

and IT WORKED !
See attached screenshot of my terminal program reading the tiny output to a TTL-RS232 adaptor module
(simple MAX232 circuit I got for $5 on eBay). I have an RS232 to USB cable from RadioShack plugged
into the adaptor module which uses a different comm port (in Device Manager) than my Arduino UNO
USB used to upload programs to the tiny85. tiny pin -3 (chip pin-2) is rx, and tiny pin-4 (chip pin-3)
is tx. I still need to test serial input to the tiny but at least I have debug serial out , thanks to you.
I'm on my way now...

Thanks Fungus, just off to try the 20mhz now !