Page 1 of 1

Usb not Recognized: Malfunctioning

Posted: Mon Sep 21, 2009 9:16 pm
by Sartal
Hello all!
I'm trying to get vusb to work. I've dowloaded the following code onto an atmega8 . I've also set the frequency to 16mhz. However, when i plug the usb into the port, it gives me an error 'usb not recognized. Some device has malfunctioned...' I was under the impression that if it was working a message would pop up saying 'found new hardware. ' Not happening, though, its being recognized as an unknown device. I'm on windows vista.

My hardware setup is the one involving 3.6 zener diodes to the ground from the D+ and D-lines. However, i have 360 ohm resistors instead of 68 ohm resistors. This shouldn't make a difference though.

I've measured some voltages:
2.522 V on the D- line
0 V on D+ lines
5.01 V supplied
4.68V supplied to microcontroller.
1.478 K resistor from D- to VCC.

I cannot figure out what would be causing this. Any ideas? Thanks! D4 is the D- line and D2 is the D+ line. Everything else in usbconfig.h is default. I'm using
the winAVR eclipse plugin, so it generates Makefile automatically.

//One of the usb devices attached to this computer has malfunctioned and windows does not
//recognize it.

Code: Select all

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/wdt.h>

#define F_CPU 16000000
#include "usbdrv.h"
#include "oddebug.h"
#include <util/delay.h>

usbMsgLen_t usbFunctionSetup(uchar setupData[8])
{
return 0;
}

void setupUSB () {
   uchar   i;
   wdt_enable(WDTO_1S);
   odDebugInit();
   DDRD=~USBMASK;
   PORTD = 0;         //no pullups on usb pins

   /* We fake an USB disconnect by pulling D+ and D- to 0 during reset. This is
    * necessary if we had a watchdog reset or brownout reset to notify the host
    * that it should re-enumerate the device. Otherwise the host's and device's
    * concept of the device-ID would be out of sync.
    */
   usbDeviceDisconnect();  /* enforce re-enumeration, do this while interrupts are disabled! */
   i = 0;
   while(--i){             /* fake USB disconnect for > 500 ms */
      wdt_reset();
      _delay_ms(2);
   }
   usbDeviceConnect();
   usbInit();
   sei();
}

int main(void)
{
   setupUSB();
   for(;;) {                /* main event loop */
      wdt_reset();
      usbPoll();
   }
   return 0;
}

Re: Usb not Recognized: Malfunctioning

Posted: Tue Sep 22, 2009 6:36 am
by Guest
Any ideas on how to debug this? I've read elsewhere that this could be caused by a weak crystal signal? Are 27 pf caps fine for the crystal. Thanks :D

Re: Usb not Recognized: Malfunctioning

Posted: Tue Sep 22, 2009 11:07 am
by christian
2.5 V on D- is not enough. You need something around 3 V.

Re: Usb not Recognized: Malfunctioning

Posted: Tue Sep 22, 2009 5:53 pm
by Guest
You're right. I don't know how, but my zener diodes aren't working. So i'm switching to the 2 diode voltage drop to the microcontroller. Now i have 3.9V I'm guessing this is too much? What's the tolerance range for usb voltage?

Re: Usb not Recognized: Malfunctioning

Posted: Tue Sep 22, 2009 9:48 pm
by christian
3.9 should be OK for most hosts. The minimum voltage is defined by the USB spec (but you must take into account that the last couple of millivolts are reached slowly). The maximum is defined by the common mode voltage range of the host's input amplifier. This may be +5V (especially with older designs), but it's usually not far below 5V. The USB spec demands a minimum of 3.6 V for the maximum, as far as I remember.