I'm building the simplest AVR-USB circuit I can, using the atmega324p and based off of the powerSwitch demo, running completely on external 5v power. When I connect it to linux, I get
Feb 20 17:25:02 foo kernel: [66496.580000] usb 1-5: new low speed USB device using ohci_hcd and address 29
Feb 20 17:25:02 foo kernel: [66496.760000] usb 1-5: device descriptor read/64, error -62
Feb 20 17:25:02 foo kernel: [66497.044000] usb 1-5: device descriptor read/64, error -62
Feb 20 17:25:02 foo kernel: [66497.324000] usb 1-5: new low speed USB device using ohci_hcd and address 30
Feb 20 17:25:03 foo kernel: [66497.504000] usb 1-5: device descriptor read/64, error -62
Feb 20 17:25:03 foo kernel: [66497.788000] usb 1-5: device descriptor read/64, error -62
Feb 20 17:25:03 foo kernel: [66498.068000] usb 1-5: new low speed USB device using ohci_hcd and address 31
Feb 20 17:25:04 foo kernel: [66498.476000] usb 1-5: device not accepting address 31, error -62
Feb 20 17:25:04 foo kernel: [66498.652000] usb 1-5: new low speed USB device using ohci_hcd and address 32
Feb 20 17:25:04 foo kernel: [66499.060000] usb 1-5: device not accepting address 32, error -62
My schematic is here: http://i248.photobucket.com/albums/gg19 ... 0109_2.jpg - the actual circuit has a connection from the D+ line to PD2/INT0, I just forgot to draw it here. Also in this schematic is what I believe is the USB "B" type socket pinout. The diodes are 1N5226B 3v6 zeners, the caps 22p ceramic, and the crystal is a 12Mhz (FOX120-20)
Here are two pictures of the circuit: an overview and a detail of the USB section. http://i248.photobucket.com/albums/gg19 ... G_0107.jpg and http://i248.photobucket.com/albums/gg19 ... G_0108.jpg
The software is the stock powerswitch software, with USB_CFG_IOPORTNAME B, USB_CFG_DMINUS_BIT 0, and USB_CFG_DPLUS_BIT 1, makefile has DEVICE set to atmega324p, uploaded via AVRDUDE. The 12 Mhz crystal has been fused and confirmed to be working through LED timing tests.
I think I did everything right - did I miss something?
device descriptor read/64, error -62
Since the device shows up with different addresses in the log file within a period of 2 seconds, I suppose that enumeration fails.
Since you have made sure that the AVR runs on 12 MHz, the most likely causes are missing zener diodes in 5 V designs or an incorrect initialization of the pins involved for USB. All pins must be configured as inputs without internal pull-up resistor.
As far as I remember, the "new device" message occurs even for a single pull-up resistor on D-.
Since you have made sure that the AVR runs on 12 MHz, the most likely causes are missing zener diodes in 5 V designs or an incorrect initialization of the pins involved for USB. All pins must be configured as inputs without internal pull-up resistor.
As far as I remember, the "new device" message occurs even for a single pull-up resistor on D-.
christian wrote:Since you have made sure that the AVR runs on 12 MHz, the most likely causes are missing zener diodes in 5 V designs or
I've got the zeners in the circuit and in the linked schematic, I think - am I missing something?
christian wrote:an incorrect initialization of the pins involved for USB. All pins must be configured as inputs without internal pull-up resistor.
The PowerSwitch code handles this, doesn't it?
#define USBMASK ((1<<USB_CFG_DPLUS_BIT) | (1<<USB_CFG_DMINUS_BIT)) /* mask for USB I/O bits */
DDRD = ~(1 << 2); /* all outputs except PD2 = INT0 */
PORTD = 0;
PORTB = 0; /* no pullups on USB pins */
DDRB = ~USBMASK; /* all outputs except USB data */
Even wierder, the circuit works fine - as long as i work from bus power and my AVR ISP Mkii programmer is also attached - to the same computer.
If the programmer and device are plugged into different computers' USB ports, it doesn't work. Ground has good continuity from avr-usb plug... Why would it care about the programmer?
If the programmer and device are plugged into different computers' USB ports, it doesn't work. Ground has good continuity from avr-usb plug... Why would it care about the programmer?
It works!
Mystery solved! I need to remember: anytime you see random behavior, first look for open grounds, then look for noise.
At the suggestion of eric_j in #avr on freenode, I added a pair of caps, a 47 uf electrolytic and a 0.1 uf across the power near the avr. Suddenly, it all works - both on and off bus power, with and without the programmer attached.
The programmer must have had enough capacitance to clean up the noise - once I added my own, the circuit works! Here is the final version, for anyone else that might be having a similar problem.
http://i248.photobucket.com/albums/gg19 ... switch.png
At the suggestion of eric_j in #avr on freenode, I added a pair of caps, a 47 uf electrolytic and a 0.1 uf across the power near the avr. Suddenly, it all works - both on and off bus power, with and without the programmer attached.
The programmer must have had enough capacitance to clean up the noise - once I added my own, the circuit works! Here is the final version, for anyone else that might be having a similar problem.
http://i248.photobucket.com/albums/gg19 ... switch.png