Trouble with ATmega328P + V-USB

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
GarrettVD
Posts: 1
Joined: Fri Jun 05, 2015 9:47 pm

Trouble with ATmega328P + V-USB

Postby GarrettVD » Sat Jun 06, 2015 8:08 am

Hi all,

I'll preface this thread by stating that I'm relatively new to embedded development in general, so please forgive me if I've gleened over something completely obvious to a more experienced dev out there!

So, I'm having some trouble getting my ATmega328P to successfully be recognized as a low-speed USB device when connected to a Linux (Ubuntu 14.10) or Windows 8.1 host.

  • I'm using the V-USB library (release version 20121206).
  • I'm using an STK500 V2 programmer, connected to my Windows 8.1 host via a Prolific USB-to-RS232 adapter on port COM2.
  • I've created a GCC C Executable Project in Atmel Studio 6.2 and I'm compiling using avr-gcc in a Windows 8.1 environment.
    Flashing and setting fuses using avrdude.
  • I'm using a 16MHz external crystal oscillator.
  • I've set the HIGH fuse to 0xD1 and LOW fuse to 0xFF, which appear to be the correct settings for use of an external 16MHz clock with a slow startup.

I've read a few threads on this forum and an article within the V-USB Wiki that suggested some wonky behaviour with P-suffixed devices, and specifically mentioned that building for the ATmega168 instead of the ATMega328P may resolve the problem. But after much fiddling about with the Makefile, I've yet to get the device to be recognized!
Schematic-wise, I'm basing this off of one I found on these forums (http://img607.imageshack.us/img607/7831/ai00.png) with the addition of an LED + 680R from PC3 to GND.

I'd had a hunch that perhaps it was something to do with the zeners; I'm using 0.5W 3v6 Zener diodes (1N5227B), which when testing voltage on the D- line, only appears to be providing 2.6V instead of the 3.3V as expected. Because of this, I temporary removed the zeners and used a combination of an LM317 variable voltage regulator and two BC517 NPNs to get the voltage into a reasonable 3.3V range. Still, no luck.
Any help would be greatly appreciated.

You can download / check out my code on my BitBucket repo, some error messages when performing "make program", as well as some logged errors from dmesg on Ubuntu.

Code: Select all

[103420.573274] usb 2-1.3: new full-speed USB device number 87 using ehci-pci
[103420.661214] usb 2-1.3: device descriptor read/64, error -32
[103420.853549] usb 2-1.3: device descriptor read/64, error -32
[103421.029716] usb 2-1.3: new full-speed USB device number 88 using ehci-pci
[103421.437722] usb 2-1.3: device not accepting address 88, error -32
[103421.509886] usb 2-1.3: new full-speed USB device number 89 using ehci-pci
[103421.918192] usb 2-1.3: device not accepting address 89, error -32
[103421.918412] hub 2-1:1.0: unable to enumerate USB device on port 3


Code: Select all

C:\Users\Garrett\Documents\Atmel Studio\6.2\GccApplication1\GccApplication1> make program
avrdude -c stk500v2 -p atmega328p -P com2  -U flash:w:main.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "main.hex"
avrdude: writing flash (1510 bytes):

Writing | ################################################## | 100% 0.84s

avrdude: 1510 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex contains 1510 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.56s

avrdude: verifying ...
avrdude: 1510 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

avrdude -c stk500v2 -p atmega328p -P com2  -U hfuse:w:0xd1:m -U lfuse:w:0xff:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "0xd1"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd1:
avrdude: load data hfuse data from input file 0xd1:
avrdude: input file 0xd1 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


Thanks,

blargg
Rank 3
Rank 3
Posts: 102
Joined: Thu Nov 14, 2013 10:01 pm

Re: Trouble with ATmega328P + V-USB

Postby blargg » Sun Jun 07, 2015 10:21 pm

The 1M pulldown resistor isn't something I see in V-USB designs. Also, I couldn't find a pinout for your USB connector to verify that you have D+ and D- connected as listed in the schematic. If these don't yield anything, I'd put a very basic USB project on it first. Even an LED blink to be sure that the clock is working.


Return to “V-USB”

Who is online

Users browsing this forum: No registered users and 1 guest

cron