I'm trying to design a low-speed USB device based on ATmega16a. That chip doesn't have any USB interface, but it is possible to use bit-banging and there are even ready-made libraries to do so, like V-USB. So the programming part is quite clear.

What is unclear, it is how to physically interface AVR to USB. The problem is, USB gives +5V, but uses 3.3V levels on data lines D+ and D- (which aren't always differential). The V-USB suggests two solutions: running a whole AVR at 3.3v (with two clamp diodes on 3V line) or making a lousy level converter by attaching two 3.6V zener diodes, to clamp voltage from AVR.

Low speed USB runs at 1.5MHz, so ATmega16A should run at 12 MHz. According to datasheet, it is not rated to work reliably at that frequency when powering from 3.3V, so I required to run it directly from 5V and the first option (with clamp diodes) is not available for me.

I've implemented this on a breadboard with zeners, so test circuit works. But I think this is not very robust solution, because data from USB to AVR could be on AVR 1-level margin. I think about using a bi-directional level converter, like txb0104.

This is my question: will level converter work for USB data lines? I want to figure out the way how to analyze timing parameters in the datasheet to ensure it will not screw USB signal timing too much.

  • \$\begingroup\$ The TXB0104 probably wouldn't work - it has a 4kOhm series resistor in its output drivers which means over long USB cables it may not be able to deliver the required speed. Any buffer may also prevent the 1.5kOhm pull up resistor on the data line being detected during a reset condition - that could be adjusted by putting the resistor on the host side of any level shifter, but I'm not sure it would work. \$\endgroup\$ – Tom Carpenter Mar 13 '16 at 6:03
  • \$\begingroup\$ Is there any reason you can't run the AVR at 3.3V? Unless my calculations are incorrect, the ATMega16A is rated to run at 12MHz with a Vdd of 3.6V - if you run it at 3.3V you are not that far out from being in spec. If you need other peripherals at 5V, then you can put a level shifter between those and the AVR. In fact you could probably happily run it at 3.6V if need be as that is also within the USB Voh requirements (2.8-3.6V). \$\endgroup\$ – Tom Carpenter Mar 13 '16 at 6:09
  • \$\begingroup\$ Yes, according to datasheet 3.6v is exactly minimum voltage to run 12 MHz. But then there is no safety margin left. \$\endgroup\$ – Nikita Kipriyanov Mar 13 '16 at 7:47
  • 1
    \$\begingroup\$ TBH if you are that worried about it being reliable (not a bad thing, don't get me wrong), then using V-USB is not a sensible option. Not only for the signalling issues, but also from a software reliability standpoint. Your best bet would be to go for something like a 32U4 which has a USB slave interface. \$\endgroup\$ – Tom Carpenter Mar 13 '16 at 14:19

How about using an isolator? I've used Analog Devices ADuM3160 for interfacing a 3.3V MCU board to a PC host. Works well if you don't need High Speed. Read through the "Power supply option" section, I think it is possible to drive this from a 5V MCU also.

enter image description here

| improve this answer | |
  • \$\begingroup\$ That's an option, thank you. I don't need anything faster than Low Speed, because I will not achieve anything better with software implementation on 12 MHz MCU. \$\endgroup\$ – Nikita Kipriyanov Mar 15 '16 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.