Saturday, March 22, 2014

ATtiny85 and V-USB on a breadboard

Using an ATTiny85 chip, I programmed it to emulate a USB device and stuck it on a breadboard with a mini USB breakout board. It's not the nicest layout on a breadboard, but it gets the job done. Plugging the USB cable into the computer, it runs the code and a USB slave device shows up. I have a custom driver communicating with the chip over USB.

Thursday, March 6, 2014

Trinket with V-USB

A few months ago I stumbled upon Joonas Pihlajamaa's tutorial about AVR ATtiny USB Tutorial. His tutorial is very informative and got me interested in communicating with AVR chips via USB. In his tutorial, he used an ATtiny2313 chip on a breadboard with different components to demonstrate things. Since, I'm not an electrical engineer and don't know too much about putting all that together I didn't pursue his setup.

In came Adafruit's Trinket which is conveniently mounted on a PCB and has a USB interface with a ATtiny85 chip. I then set out to try to replicate his tutorial on this hardware. I didn't know much about avr-gcc so I got to learn about that in the process. In my prior post, I detailed out how to setup your environment, compile a simple program, and upload it to the trinket so refer to that if you are reading this first.

A lot of the magic happens in the V-USB library which does most of the heavy lifting for us. Since the ATtiny85 doesn't have a USB stack on that chip, we must use this library and software to emulate it. The configuration from Joonas' tutorial was a bit different as port's and pins differ between the ATtiny2313 and ATtiny85. 99% of the code is already listed in his tutorial so I am not going to re-invent the wheel here as you can refer to his tutorial for the code. Here is the hex file you will need to upload to the trinket. Using his usbtest binary, you can interface with your trinket over USB!