µ[micro]electronics info

A weblog focused on interesting circuits, ideas, schematics and other information about microelectronics and microcontrollers.

E-books

Google

Disclaimer

Because I have not tested all electronic circuits mentioned on this pages, I cannot attest to their accuracy; therefore, I do not provide a warranty of any kind and cannot be held responsible in any manner.

My e-mail

My website

Software-driven USB interface for AVR

How to connect an AVR microcontroller directly to USB without any converter chips?

The USB protocol isn't as simple as RS232 was and the easiest way is to use specialized chips like PIC18F2550 or FTDIs. But there is a possibility to connect an microcontroller directly to the USB just in the software way.

The first one I know is the implementation by Igor Cesko. He writes:

My solution is USB implementation into cheap microcontroller through the emulation of USB protocol in firmware of microcontroller. Problem during design was microcontroller speed. Speed of USB bus is too high: LowSpeed - 1.5Mbit/s, FullSpeed - 12Mbit/s, HighSpeed - 480Mbit/s. Normal microcontrollers are maximum performance cca: AT89C2051 - 2MIPS = 24MHz/(12cycl/inst.), PIC16F84 - 5MIPS = 20MHz/(4cycl/inst.), AT90S23x3 - 10MIPS = 10MHz/(1cycl/inst.). There exist microcontrollers with highest speeds too, but they are poorly available (price too) and are biggest (more pins - difficult construction). For all that I have decided for microcontrollers PIC16F84 or AT90S1200/AT90S23x3, which would be "enough" for LowSpeed USB. For highest USB speeds is this solution not good - for one bit from USB processing is need of several cycles of microprocessor: reading, comparison, storing, some operation, ...
Third try was successful: AT90S2313-10 (or AT90S2323-10, AT90S2343-10). This are RISC microcontrollers from Atmel production - AVR family. With comparison with PIC are slow crystal clock, but have 1 instruction per crystal clock (PIC16F84 has to 1 instruction per 4 crystal clock). In addition their instruction set and architecture is nearly to RISC. Again because of synchronization with USB clock I used overclocking to 12MHz (AT90S23x3-10 are initially to 10MHz only). In this manner I obtained more performance and 12MHz crystals are "easy to obtain" (with comparison to e.g. 10.5MHz - which is the multiple of LowSpeed USB clock 1.5Mbit/s too).

The second one I've found is the ObDev's AVR USB. They're using ATtiny2313 and their solution has following features:

* Fully USB 1.1 compliant low-speed device, except handling of communication errors and electrical specifications.
* Supports multiple endpoints: one control endpoint, two interrupt/bulk-in endpoints and up to 7 interrupt/bulk-out endpoints. (Bulk endpoints are forbidden for low speed devices by the USB standard.)
* Transfer sizes up to 254 bytes.
* Comes with freely usable USB identifiers (Vendor-ID and Product-ID pairs).
* Runs on any AVR microcontroller with at least 2 kB of Flash memory, 128 bytes RAM and a clock rate of at least 12 MHz.
* No UART, timer, input capture unit or other special hardware is required (except one edge triggered interrupt).
* Can be clocked with 12 Mhz, 15 MHz or 16 MHz crystal or from a 16.5 MHz internal RC oscillator.
* High level functionality is written in C and is well commented.
* Only about 1200 to 1400 bytes code size for basic functionality.
* You can choose the License: Open Source or commercial.

Powered by Drupal - Design by Artinet