Go Down

Topic: How to Configure ATtiny85 for 8 Mhz (Read 2126 times) previous topic - next topic

raschemmel

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.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

fungus


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.



No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

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:

Code: [Select]
' 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 ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

fungus


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:

Code: [Select]

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".

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

raschemmel

Thanks very much for your help!
I'll do it as soon as I get home.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

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.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

fungus

It means you didn't install this: http://code.google.com/p/arduino-tiny/
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

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
while (z--) { snoreEvenLouder(); }
www.smartshow.lighting - www.dmx512.lighting

fungus


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
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus

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

The boards.txt entry is:

Code: [Select]

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

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

dc42

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 http://miscsolutions.wordpress.com/2011/08/09/prototyping-small-embedded-projects-with-arduino/ and it is just the same for an attiny - skip to the "Set the fuses" section at the end.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

raschemmel

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

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

REDO
 
Quote
FUSE                                            TABLE                                          PAGE
EXTENDED                                      20.2                                             148
HIGH                                                20.4                                             148
LOW                                                 20.5                                             149
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

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 !
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up