change internal clock of attiny85

Hi , i used arduino uno to program attiny85 but i want to run attiny at 1MHz clock .
so how can be it done to change the internal clock of attiny85 with arduino?
Thanks!

It wil run @ 1 MHz if you haven't changed it (it is preprogrammed from the factory)
If you want to run 8MHz:

Select Board -> Attiny85@8MHZ
select Programmer -> Arduino as ISP
Select ->Burn bootloader, this will set the fuses but not burn any bootloader

New Tiny85's are produced with a default of internal 1Mhz clock and if you have only programmed it using an UNO loaded with ArduinoISP and not burnt the bootloader (that change the fuse settings that alter the clock type/speed) then it will still be at 1MHz. The arduino core is not designed for this clock speed (only 8 & 16MHz) but a lot of code will still work okay as long as it does not have time critical sections.

I did want to burn a bootloader "attiny85 @ 16Mhz external crystal"

But it failed and now it tells me with everything I want to upload:

avrdude: Expected signature for ATtiny85 is 1E 93 0B
Double check chip, or use -F to override this check.
Fout tijdens het branden van de bootloader.

How can I force to upload a bootloader like is suggested?

I know the bootloader "attiny85 @ 8 Mhz internal crystal" works like a charm....

creamers:
I did want to burn a bootloader "attiny85 @ 16Mhz external crystal"
But it failed and now it tells me with everything I want to upload:

Now , avrdude want to see external crystal on tiny and if you dont have one , you got that error.
So to correct that , use external crystal ( doesn't have to be 16 MHz ) put it between ATTiny85 pin2 and pin3(PB3 and PB4) :

//                         +-\/-+
// PCINT5 Ain0 (D 5) PB5  1|    |8  Vcc
// PCINT3 Ain3 (D 3) PB3  2|    |7  PB2 (D 2) Ain1 PCINT2
// PCINT4 Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1 PCINT1
//                   GND  4|    |5  PB0 (D 0) pwm0 PCINT0
//                          +----+

and choose :

Tools-Board- attiny85 @ 8 Mhz internal crystal

or 1MHz if you want that and then choose :

Tools-Burn bootloader

after that remove external crystal and use attiny as usual. ( 2 - 27pF capacitor from external crystal to ground is not necessary for correcting wrong bootloader but if you have problem use them too )

If you don't have a crystal/resonator to hand to allow you to burn bootloader/set fuses back to internal oscillator then there is a version of ArduinoISP that has a pin set to 8MHz that can work as a clock source.

common_ground & Riva, THx for the help. begin to understand more and more :wink:

Will let you know if it worked out as soon as I'm home :wink:

Great it worked! Both methods worked by the way.

I ripped a oscillator from a printboard saying : "D450C6" and tried the software Riva advised.

Question, as I don't have another crystal oscillator, any change you guys know what crystal "D450C6" is?

*EDIT: and...I ripped a ceramic E10.75 Cm , what frequency would that be ?

Next step is to burn fuses for those or other oscillators...any tips ?

I'm confused now, do you want to set the tiny85 back to internal 1MHz clock or are you now saying you want to use an external crystal/resonator to derive the clock?
If you want to set it back to internal clock then I would suggest setting it to 8MHz so it works nice with the arduino core. Once the fuses are set back to internal clock you can remove the external crystal/resonator.
The part numbers you give us are of little use, your better off looking for the speed on the package or tell us all the writing you see.
There is a fuse calculator here but take care as you can end up disabling the reset pin and preventing normal programming. You can recover from this though but it means buying/building a high voltage programmer to do it.

Riva:
I'm confused now, do you want to set the tiny85 back to internal 1MHz clock or are you now saying you want to use an external crystal/resonator to derive the clock?

No, I did calibrate the internal clock but it's not precise enough. So I wanted to test the external clock bootloader but it failed on me. You gave me the tip to get it going without a external crystal again.
So my original problem is solved :wink:

The part numbers you give us are of little use, your better off looking for the speed on the package or tell us all the writing you see.
There is a fuse calculator here but take care as you can end up disabling the reset pin and preventing normal programming. You can recover from this though but it means buying/building a high voltage programmer to do it.

Now I ripped some oscillators to play with, but don't know the frequency. That's why I asked you guys if you could figure out what they are....

but don't know the frequency. That's why I asked you guys if you could figure out what they are....

You can try a Google search with those part numbers and add "crystal" to the search... But, house numbers are notoriously difficult to track.

Ray

Oke found a crystal. Question, when I burn the bootloader with the caption 'external crystal' everything goes well and I can upload the blink sketch but......

Should my led blink when removing the crystal? Logical I should say no as there is no oscillation...right

Logical I should say no as there is no oscillation...right

Mr. Spock indicates affirmative!

But, why do you not really prove it to yourself?
listen-to-your-arduino

Ray

Thx, everytime I ask a question I need more time to fullfill my curiousity :wink:

I now found a watch crystal 32.768khz from an old computer. It's visual printed on this crystal: '32.768'

But,,,,as I go one step forward I need 8 hours of googling to go to the next level :wink:

I followed this video and did exactly that but the led is blinking more every 5 sec instead of every 1 second. I did upload the stuff with an alternative frequency as I cannot upload with arduino and this slow 32.768 frequency. After uploading I connect the 32.768 crystal instead. Does that matter ?

Any idea what could be my problem?

creamers:
Thx, everytime I ask a question I need more time to fullfill my curiousity :wink:

I now found a watch crystal 32.768khz from an old computer. It's visual printed on this crystal: '32.768'

But,,,,as I go one step forward I need 8 hours of googling to go to the next level :wink:

I followed this video and did exactly that but the led is blinking more every 5 sec instead of every 1 second. I did upload the stuff with an alternative frequency as I cannot upload with arduino and this slow 32.768 frequency. After uploading I connect the 32.768 crystal instead. Does that matter ?

Any idea what could be my problem?

Here is my take:
1-second-tiny85-timer

Original work/code:
insidegadgets
32khz-watch-crystal-on-an-attiny85/

Ray

That's exactly what I did, but two things arent working for me.
One, the led is blinking +/- every 5 sec instead 1sec
Two, howto use arduino after setting the fuses cause it doesn't 'talk' anymore.

Just wanted to let you guys know that I resolved my issue. I use pin9 with this arduinoISP: LINK So I burn my bootloader and code with the Nano pin9 connected to xtal of the attiny. (using a 32khz crystal gives me problems uploading with arduino)

After burning bootloader and uploading sketch I place my crystal watch oscillator 32khz.

But, what I missed was setting the prescaler correctly:

When I set all four values:

CS13 CS12 CS11 CS10

it overflows every second....

In this example LINK it only sets CS13. But also setting the others will make my attiny85 blink every second.!!

But, another question arrives :slight_smile:

#what is more precise when counting time: a small or larger prescaler? Or doesn't it really matter ?

ps, just for kicks to begin counting:

 if (interrupt) {
 
    /*TIME COUNTING*/   
    if (!settingRoutine) { //enables time counting only after the setting is completed     
      secdevs += 1; //increment clock cycle counter
      /*counting time in timenumbers[]*/
      if (secdevs == fullsec) { //number of cycles equal to a second have passed
        secdevs = 0; //reset cycle counter
        timenumbers[5] += 1; //increment seconds count
        if (timenumbers[5] >= 10) { //seconds'1
          timenumbers[5] = 0; //reset that number
          timenumbers[4] += 1; //increment next number
          if (timenumbers[4] >= 6) { //seconds'10
            timenumbers[4] = 0;
            timenumbers[3] += 1;
            if (timenumbers[3] >= 10) { //minutes'1
              timenumbers[3] = 0;
              timenumbers[2] += 1;
              if (timenumbers[2] >= 6) { //minutes'10
                timenumbers[2] = 0;
                timenumbers[1] += 1;
                if (timenumbers[1] >= 10) { //hours'1  - hour change at 10 and 20
                  timenumbers[1] = 0;
                  timenumbers[0] += 1;
                }
                if (timenumbers[0] == 2 && timenumbers[1] == 4) { //hour change at 24
                  timenumbers[1] = 0;
                  timenumbers[0] = 0; //set to 00:00:00
                }
              }
            }
          }
        }
      }
    }// /time counting

#what is more precise when counting time: a small or larger prescaler? Or doesn't it really matter ?

The better question I think is how best to minimize interrupt overhead (dead time.). The general rule is to make the interrupt routine as short as possible... The more work done in the interrupt routine the more cycles that are being removed from other interrupt routines and main().

Your prescaller selection should ensure that you can safely manage all of the previous interrupt and return the registers and stack pointer before the next interrupt fires... You still want to maximize time in main() too, so with timed interrupts you must optimize the resolution while minimizing the overhead.

In your example, you must complete all the array calcs for HH:MM:SS before the interrupt for the next second occurs. You would need to rethink your strategy if you needed tenths of a second or hundredths of a second!

Ray