You Are Here: Home » AVR ATmega Projects » Interfacing(USB - RS232 - I2c -ISP) Projects » AVR ATtiny USB Tutorial Part 2

AVR ATtiny USB Tutorial Part 2

This is the second part of my USB tutorial for ATtiny2313 and V-USB library. In the first part we learned how to get 3.3V from USB to power our circuits. In this part, we will expand our setup with following parts:

  • Larger breadboard and additional jumper wires
  • ATtiny2313
  • 12 MHz crystal oscillator
  • Two 27 pF ceramic capacitors to stabilize the crystal
  • Two 68 Ω resistors between USB data lines and the microcontroller pins
  • 1 MΩ pullup resistor for D+ and 1.5 kΩ pullup for D-
  • 6-pin header for programming the ATtiny and 4.7 kΩ pullup for reset pinAVR ATtiny USB Tutorial Part 2

Update: Some people have noted that the setup I’m using here runs ATtiny2313 at 12 MHz with only 3.3V VCC, which is outside the specified range (frequencies over 10 Mhz require 4.5V or more). I’ve never had any problems, and many others have succeeded with this setup, but if you encounter persistent problems, I suggest you to power the ATtiny2313 straight from 5V of the USB line and use zener diodes on D+ and D- lines to drop their voltage, as is done in my later tutorial with the ATtiny85 microcontroller.

Breadboard setup

This time I will not walk you through every connection. Instead, I’ll just outline the steps needed and show the pictures of end result. Here is the schematic we’re building:Schematic AVR ATtiny USB Tutorial Part 2

Basically it’s the regulator circuit we just built, pullups and line resistors for D+ and D- in the USB bus going to PD2 and PD3, and the ATtiny2313 with RESET pullup and MISO, MOSI, SCK and RESET connected to the 6-pin programming header, and a 12 MHz crystal. An easy order to make these connections is to:

  1. Reconstruct the power circuit from part 1 in one corner of the breadboard. Instead of connecting 5V from USB to the positive power rail, connect it straight to the input pin of the regulator – we won’t be needing 5V anywhere else
  2. Use jumper wires to connect regulator output and shared ground from USB to breadboard power rail
  3. If you have multiple power rails, you can use jumper wires to provide current to all of them
  4. Double-check the regulator pin connections and that capacitors are connected the right way
  5. Plug in the USB and use a multimeter to check you have 3.3V in power rails
  6. Insert the ATtiny and do standard wiring for power, reset pullup and 6-pin programming header
  7. If your programmer has a mode where it provides power to the chip – disable it
  8. Use programmer to check that the chip responds OK (i.e. gets power and acts in a stable manner)
  9. Connect the LED to PB0 and do a “test run” – flash a program that blinks the LED to see that it works
  10. Connect pullup resistors to D+ and D- (1M and 1k5)
  11. Connect D+ and D- to PD2 and PD3, respectively – use 68 ohm resistors in series here!
  12. Connect the 12 MHz crystal to PA1 and PA0, and ceramic capacitors between crystal pins and ground

For more detail: AVR ATtiny USB Tutorial Part 2

Leave a Comment

You must be logged in to post a comment.

Read previous post:
atmega audio input to visual ouput
AVR Atmega audio input root mean square (RMS)

audiogetavarage is a simple library you can use to interface with an audio input. It reads data from an ADC...

Scroll to top