USB On The ATtiny10

Atmel’s ATtiny10 is their smallest microcontroller in terms of physical size – it’s an SOT-23-6 package, or about the same size as surface mount transistors. The hardware inside this extremely bare-bones; three I/O lines, 1kB of Flash, 32 bytes of RAM, and a reduced AVR core with 16 registers instead of 32. With such a minimal feature set, you would think the only thing this micro would be good for is blinking a LED. You’d be right, but [cpldcpu] can blink a LED with the ‘tiny10 over USB.

The V-USB interface usually requires about 1.5kB of Flash in its most minimal implementation, and uses 50 bytes of RAM. This just wouldn’t do for the ‘tiny10, and although [cpldcpu] is working on a smaller, interrupt-free V-USB, there were still some hurdles to overcome.

The biggest issue with putting code on the ‘tiny10 is its reduced AVR core – on the ‘big’ 32-register core, direct memory access is two words. On the ’10, it’s only one word. AVR-GCC doesn’t know this, and no one at Atmel seems to care. [cpldcpu] worked around this problem using defines, and further reduced the code size by completely gutting V-USB and putting it in the main loop.

It’s not much, but now [cpldcpu] can blink an LED with a ‘tiny10 over USB. If you’re wondering, 96.4% of the Flash and 93.8% of the SRAM was used for this project.

26 thoughts on “USB On The ATtiny10

    1. There are many applications where you just have to control signals on one or two lines. No need to go for a bulky device with complex firmware. Obviously they did not create the device with anything like USB in mind.

      I think Microchip was first with their SOT23 PICs, but Atmel response (ATtiny 4/5/9/10) is much more powerful.

      1. @cpldcpu,
        “I think Microchip was first with their SOT23 PICs, but Atmel response (ATtiny 4/5/9/10) is much more powerful.”
        True concerning PIC10F2xxx but not for the PIC10F322 which is quite powerfull.

        1. Sometimes it’s worth it to spend a few months of developer time to use a cheaper chip. 10 cents saved on a chip, on a product with a volume of 100.000 a year. That’s 10k right there. You can put a developer on that for a month easy.

    2. I remember seeing my first PIC “in the wild”, it was in a paper shredder. It basically told the motor to run for a second or two after the “paper present” switch re-opened to allow the motor to clean the remaining paper from the shear rollers. No need for a USB, and yes, the next comment will probably say, “I can to that with a 555, a resistor and a capacitor”.

    1. I was wondering about this when I edited it. I had read your original post when you first published it.

      I have it in the back of my mind that I need to look at your code but I can’t figure out how you managed to fit in the timing necessary to drive WS28xx LEDs with what you have leftover in code space. Amazing!

  1. I’ve used these types of microcontrollers to make LFSR digital noise sources for prototyping/breadboarding circuits. It was actually easier than wiring up an analog circuit in terms of development time

  2. Working with attiny10 is hard enough already without these memory issues. Although the AVR toolchain shipped with Atmel Studio can handle this target just fine, the support for the attiny10 architecture has not been merged into mainline gcc. Therefore, the avr-gcc packages in many Linux distributions do not support this microcontroller at all.

    The modified sources for the toolchain are available from Atmel as large tarballs, unfortunately not as separate patches for integration:

Leave a 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.