Feed on
Posts
Comments

In this video I show how you can use a 32KHz watch crystal on an ATtiny85 for precise timing.

We use the timers overflow to indicate when 1 second has passed which wakes up the ATtiny85 and turns an LED on or off and then goes back to sleep (which when in sleep mode with the LED off, it consumes about 60-70uA of current).

This can be used for applications such as clocks, data loggers, etc. If you are looking to minimise the current consumption when sleeping you’ll need to find a AVR with an independent timer clock like the ATmega328 so you can put the AVR on power-down whilst the timer is still running.

Fuse Calculator – http://www.engbedded.com/fusecalc
AVR Timing Calculator – http://frank.circleofcurrent.com/cache/avrtimercalc.htm
Download source: ATtiny25-45-85_Blink_32KHz_v1.0

3 Responses to “How to use a 32KHz watch crystal on an ATtiny85”

  1. Nick Sayer says:

    I’ve been trying to duplicate your success, but it’s not working out so well. If I use a scope, I can see 32 kHz on the two crystal lines of my Tiny85, so I rather suspect the clock is running, but I can’t talk to it after setting the fuses as you did. I knew that I’d be needing to use -B with my usbtiny. As you, I tried using 250, but no dice. I’ve also tried about 6 different versions of the AVR-as-ISP-sketch-slowed-down with an uno, but none of them work.

    What’s the magic?

    • Alex says:

      Hi Nick,

      It sounds like you are doing things right, can you try a bit of a higher bitclock -B, say 1000?
      Also try bypassing the usbtiny’s reset pin and pull it low yourself.

  2. Adam says:

    I had the same issue as Nick above. The problem is that entering any delay > 250 into avrdude’s -B switch gets converted back down to 250:

    >avrdude -p attiny45 -c usbtiny -B 500

    avrdude: Setting SCK period to 250 usec
    avrdude: initialization failed, rc=-1
    Double check connections and try again, or use -F to override
    this check.

Leave a Reply to Nick Sayer