General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
-
fma
- Posts: 7
- Joined: Mon Dec 03, 2012 1:23 pm
Post
by fma » Mon Dec 03, 2012 1:40 pm
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/usbtinyI 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!
-
winelight
- Rank 1
- Posts: 21
- Joined: Tue Nov 27, 2012 11:36 pm
Post
by winelight » Tue Dec 04, 2012 8:54 pm
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.
-
fma
- Posts: 7
- Joined: Mon Dec 03, 2012 1:23 pm
Post
by fma » Wed Dec 05, 2012 9:24 am
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?
Last edited by
fma on Thu Dec 06, 2012 10:04 am, edited 1 time in total.
-
winelight
- Rank 1
- Posts: 21
- Joined: Tue Nov 27, 2012 11:36 pm
Post
by winelight » Wed Dec 05, 2012 10:05 am
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.
-
fma
- Posts: 7
- Joined: Mon Dec 03, 2012 1:23 pm
Post
by fma » Thu Dec 06, 2012 10:10 am
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;
}
-
winelight
- Rank 1
- Posts: 21
- Joined: Tue Nov 27, 2012 11:36 pm
Post
by winelight » Thu Dec 06, 2012 12:35 pm
Yes, but does it actually come on?
-
fma
- Posts: 7
- Joined: Mon Dec 03, 2012 1:23 pm
Post
by fma » Thu Dec 06, 2012 6:52 pm
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?
-
winelight
- Rank 1
- Posts: 21
- Joined: Tue Nov 27, 2012 11:36 pm
Post
by winelight » Sat Dec 08, 2012 10:08 am
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?
-
fma
- Posts: 7
- Joined: Mon Dec 03, 2012 1:23 pm
Post
by fma » Sat Dec 08, 2012 10:15 am
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?
-
winelight
- Rank 1
- Posts: 21
- Joined: Tue Nov 27, 2012 11:36 pm
Post
by winelight » Sat Dec 08, 2012 12:52 pm
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
-
fma
- Posts: 7
- Joined: Mon Dec 03, 2012 1:23 pm
Post
by fma » Sat Dec 08, 2012 2:02 pm
Ok, I'll check that...
-
winelight
- Rank 1
- Posts: 21
- Joined: Tue Nov 27, 2012 11:36 pm
Post
by winelight » Sat Dec 08, 2012 2:36 pm
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).
-
fma
- Posts: 7
- Joined: Mon Dec 03, 2012 1:23 pm
Post
by fma » Sat Dec 08, 2012 4:25 pm
I'll check that. Thanks!