Improve ATtiny Timing Accuracy With This Clock Calibrator

The smaller ATtiny microcontrollers have a limited number of pins, and therefore rely on an internal 9.6 MHz oscillator rather than an external crystal. This oscillator lacks the accuracy of a crystal so individual chips can vary over a significant tolerance from the nominal figure. Happily the resulting timing inaccuracies can be mitigated through a calibration process, and [Stefan Wagner] has incorporated this into his Tiny Calibrator. In addition, it also has the required charge pump circuitry to reset the internal fuses to rescue “bricked” ATtinys, thus allowing those little mistakes to be salvaged.

The board has its own larger ATtiny with a crystal oscillator and an OLED screen, allowing it to measure that of the test ATtiny and generate a correction factor which it applies to the chip. This process is repeated until there is the smallest possible difference from the standard. You can find the files for the hardware on EasyEDA, and the software in a GitHub repository.

It’s important to state that the result will never be as stable as a crystal so you’d be well advised not to put too much trust in those timers, but at least they won’t be as far off the mark as when shipped. All in all this is a handy board to have at hand should you be developing for the smaller ATtiny chips.

Be careful when chasing clock accuracy — it can lead you down a rabbit hole.

13 thoughts on “Improve ATtiny Timing Accuracy With This Clock Calibrator

    1. Yep. For microcontrollers not fabricated on SKBS processes (stone knives and bear skins, of course), at the very least this happens at the factory and the calibration is burned into ROM. I always wonder how AVRs manage to maintain such a following among hobbyists despite the extreme levels of suck they heap upon the programmer.

      1. Perhaps it’s because they’re so well documented with numerous of “same level” examples by other hobbyists that even a caveman can understand them?

        Considering most people treat MCU’s as a means to an end, and not “not about the destination but the journey” and don’t want nor need to chase the bleeding edge, but want known stability, expected predictability, all flaws and bugs known with common workarounds documented and no surprises whatsoever.

        It’s much the same with the medical and military equipment sector, where once something has finally been approved, you can bet they’ll be getting their mileage out of it.

        No need to treat it like the smartphone, tablet or laptop market.

        1. +1

          some people around here just can’t get over others using parts not officially marked “ok to use” by them… it’s always the same rambling in the comments. Just use some trigger words like Arduino, Atmega, Attiny, breakout, …

      2. It is more like they don’t know anything better than a hammer and just treat anything as a nail.

        They are not the type that do their own part selection. If it is not in their favorate over priced reseller “store” or youtube video, then the appropriate parts do not exist.

        1. Ever thought of people who are ready to go by buying a cheap 5USD breakout board with their favourite lame old micro on it, upload their program by USB and are DONE with their project?

          That’s quicker than using a fancy new uC you never worked with beforr and maybe even need to buy a new programmer for.

          Come on guys, don’t be so narrow-minded. Jeez…

      3. Price. Worldwide availability. Simplicity. Good documentation. Free as in Freedom tools and libraries.

        Surprisingly few platforms deliever all of these things. Most don’t check a single one and however flashy and modern they may be, they will remain out of reach (and desire) for mortals.

  1. The V-USB project calibrates the ATtiny’s PLL using the USB bus SOF signal. The end result is that the ATtiny’s clock is accurate enough for low speed USB communication. I think this works nearly the same way.

  2. There is of course an appnote for calibration with the standard Atmel tools: AVR053 – Internal RC Oscillator Calibration
    But I appreciate the standalone quality of this device and neatly looking design (y)

Leave a Reply to RetiredHobgoblinCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.