Page 1 of 1

First project

Posted: Mon Dec 03, 2012 1:40 pm
by fma
Hi,

I'm new to V-USB, and I'm trying to build a LCD controller. My project is based on this one:

http://dicks.home.xs4all.nl/avr/usbtiny

I made a simple project which does nothing, except registering to USB driver. But it does not work.

First, my device is not detected on all computers. And when it is detected, I only get:
usb 2-1.6.3: new low-speed USB device number 21 using ehci_hcd

and I can't see it in the usb devices...

I don't know where to search to find the problem. Any advice welcome.

Thanks!

Re: First project

Posted: Tue Dec 04, 2012 8:54 pm
by winelight
Is your circuit the same as the one shown in that example?

The problems I had initially were the usual stupid ones:

* Forgetting to set the fuses
* Not fitting Zener diodes

And generally getting the software in a mess.

Re: First project

Posted: Wed Dec 05, 2012 9:24 am
by fma
Yes, same circuit. I have the diode, and I think my fuses are OK, as they are set according to the Makefile example:

################################ ATTiny2313 #################################
# ATTiny2313 FUSE_L (Fuse low byte):
# 0xef = 1 1 1 0 1 1 1 1
# ^ ^ \+/ \--+--/
# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
# | | +--------------- SUT 1..0 (BOD enabled, fast rising power)
# | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
# +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
# ATTiny2313 FUSE_H (Fuse high byte):
# 0xdb = 1 1 0 1 1 0 1 1
# ^ ^ ^ ^ \-+-/ ^
# | | | | | +---- RSTDISBL (disable external reset -> enabled)
# | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V)
# | | | +-------------- WDTON (watchdog timer always on -> disable)
# | | +---------------- SPIEN (enable serial programming -> enabled)
# | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved)
# +-------------------- DWEN (debug wire enable)


Are they OK ?

And as said, on some computers, I don't even get the above message. Why?

What are the steps during usb initial dialogue when a new device is inserted? Why do I get only that message? Where does it stop in the firmware?

Re: First project

Posted: Wed Dec 05, 2012 10:05 am
by winelight
Do you have a debug LED on one of the output pins? This is really useful. You can flash it in the initialisation routines (and anywhere else) just to know that your device is running and has been recognised and is being initialised.

Re: First project

Posted: Thu Dec 06, 2012 10:10 am
by fma
Yes, I have a led: it is turned on before usb init, and turned off after usb init:

Code: Select all

int main() {
    uchar i;

    DDRD = 32; // PD5 as output

    PORTD |= 32; // turn LED on

    wdt_enable(WDTO_1S); // enable 1s watchdog timer

    usbInit();

    usbDeviceDisconnect(); // enforce re-enumeration
    for(i = 0; i<250; i++) { // wait 500 ms
        wdt_reset(); // keep the watchdog happy
        _delay_ms(2);
    }
    usbDeviceConnect();

    sei(); // Enable interrupts after re-enumeration

    PORTD &= ~32; // turn LED off

    while(1) {
        wdt_reset(); // keep the watchdog happy
        usbPoll();
    }

    return 0;
}

Re: First project

Posted: Thu Dec 06, 2012 12:35 pm
by winelight
Yes, but does it actually come on?

Re: First project

Posted: Thu Dec 06, 2012 6:52 pm
by fma
Yes, sure, I can see it turned on at startup, and turned off ~0,5s later...

What should I see on the kernel messages? And what parts of the code are involved in the initializing com with the kerlen driver?

Re: First project

Posted: Sat Dec 08, 2012 10:08 am
by winelight
I don't know Linux so I don't know what kernel message you should see.

Are the basics correct? You're using a 12 MHz crystal and 5V supply? Is your device powered from the USB?

Have you gone through all the settings in the config file?

Re: First project

Posted: Sat Dec 08, 2012 10:15 am
by fma
Yes for all questions. I double checked it. I also tried on a windows machine, and nothing is detected...

What are the tricky points? What should I check on the hardware side? What levels should I see on the D+/D- lines? I can use an oscilloscope, so can you tell me what is the shape I should see there?

Re: First project

Posted: Sat Dec 08, 2012 12:52 pm
by winelight
Ah OK. Even on a Windows machine it should detect you plugging it in, that is just a question of the voltage levels, or something. It should come up with an error message, about a device that has malfunctioned, even if nothing works on your board.

The D- and D+ should have square waves (or rather, square pulses) of 3.3V approximately.

There's a picture here:

http://people.ece.cornell.edu/land/cour ... lowres.jpg

Re: First project

Posted: Sat Dec 08, 2012 2:02 pm
by fma
Ok, I'll check that...

Re: First project

Posted: Sat Dec 08, 2012 2:36 pm
by winelight
I believe it's simply the pull-up resistor on the D- line that causes Windows to detect you have plugged something in.

Check you have the D+ and D- lines the right way round - the correct colour coding is in Wikipedia, but the first Google hit for the image search has the green and white reversed (or it did when I looked).

Re: First project

Posted: Sat Dec 08, 2012 4:25 pm
by fma
I'll check that. Thanks!