Entirely polled V-USB? [yes, it works!]

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
cpldcpu
Rank 2
Rank 2
Posts: 44
Joined: Sun Nov 10, 2013 11:26 am

Re: Entirely polled V-USB? [yes, it works!]

Post by cpldcpu » Sun Dec 01, 2013 1:53 am

I made a version of micronucleus only using polling, based on your work above. You can find the branch here:

https://github.com/micronucleus/micronu ... g/firmware

Getting the polling to work with larger datatransfers as well was not easy. Finding the right timing to call usbPoll() in between transmissions was quite difficult. I had no luck with a blocking wait, so in the end i settled with a 100µs loop and calls to the housekeeping functions in between. The current state seems to work pretty reliably on my machine, even when routed through two cascaded hubs. But even slight changes in the loop timing will cause errors during data transfer.

cpldcpu
Rank 2
Rank 2
Posts: 44
Joined: Sun Nov 10, 2013 11:26 am

Re: Entirely polled V-USB? [yes, it works!]

Post by cpldcpu » Sun Dec 01, 2013 2:09 am

meh... just tried it on another machine and it failed all the time. Looks like the only solution is to introduce a more sophisticated algorithm that decides when to do the housekeeping.

blargg
Rank 3
Rank 3
Posts: 102
Joined: Thu Nov 14, 2013 10:01 pm

Re: Entirely polled V-USB? [yes, it works!]

Post by blargg » Sun Dec 01, 2013 3:58 am

I noticed that you don't clear the interrupt flag before PCINT0_vect(). Did you determine that leaving the flag set won't bother usbdrv? I ask because I have seen places in the interrupt code where it checks the flag and acts on whether it's set.

cpldcpu
Rank 2
Rank 2
Posts: 44
Joined: Sun Nov 10, 2013 11:26 am

Re: Entirely polled V-USB? [yes, it works!]

Post by cpldcpu » Sun Dec 01, 2013 9:11 am

I moved that to the beginning of the interrupt routine to ensure that YL is initialized as well.

Post Reply