General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
-
Adam
Post
by Adam » Fri Nov 20, 2009 2:30 pm
Hello,
I have made the HIDkeys project and the power switch project. It works.
Thanks to Development Software GmbH.
No my idea and question:
Is it possible to drive an atmega8 with 2 stand alone USB connectors?
The USBs are switch in 2 different PCs.
I will use Int0 for USB connector 1 and Int1 for USB connector 2.
USB1 works as an HDI device and USB2 works as a power switch.
I will copy and rename the files and functions und compile it.
eg in main.C
Code: Select all
sei();
for(;;){ /* main event loop */
wdt_reset();
usbPoll(); // Polling USB0
usbPoll_USB2();// Polling USB1
Will this works?
Are there troubles with the timing from usbPoll() und usbPoll_USB2()?
Thanks for anwer
-
toface
- Posts: 4
- Joined: Fri Nov 20, 2009 5:06 pm
Post
by toface » Fri Nov 20, 2009 5:57 pm
I'd say "no", as you might be unlucky and the interrupt (start of frame) comes in at the approximately same time from the two computers.
According to usbdrv.h you have at most 25 cycles (@12MHz) that you can ignore the start of frame interrupt, (coming in every 1ms) and each interrupt may last up to 100usec, ie ~90% of the time it will work. In the rest of the cases probably fail after a while. Either way, I wouldn't do it. If the usb frequencies aren't exactly the same, it will never work for an extended time.
Maybe you can somehow force some "unsynchronization" of the USB clocks between the computers, I know too little about USB to answer that, but I wouldn't count on it.
I would recommend you hook up two different avr's and use for example spi or serial to talk between them. Preferably something with flow control, as 100usec is a lot of time when you're sending data quickly back and forth.