Entirely polled V-USB? [yes, it works!]
Posted: Tue Nov 19, 2013 9:49 pm
Any reasons an entirely polled V-USB wouldn't work? I gave it a try but got host errors (polling the interrupt flag between usbPoll() calls).
Fundamentally, you've got the loop that calls usbPoll(), and periodic interrupts to run code that handles the timing-critical I/O. The I/O interrupts come at regular intervals. If you could arrange so that between the I/O you do at most slightly less work than until the next one, you could then poll the interrupt flag.
Polling shouldn't be a timing problem since the comments say that you have many tens of cycles before the ISR needs to actually fire (a polling loop maybe adds 7 cycles).
The question is how much work you need to do between the USB interrupts. Apparently it's not just a little bit, or my test would have worked. And also the I/O handling eats into some of the time, depending on how much data is being exchanged. I wonder whether the CRC routines eat a lot during initial configuration when several packets are being sent back to the host.
I became interested in this after reading that someone had implemented USBaspLoader on a attiny chip that lacked a separate set of vectors for the bootloader, and thus had to share the vectors with the application. If V-USB could be made to work with polling, the bootloader would only need to share the reset vector, a far easier one to do that with.
Fundamentally, you've got the loop that calls usbPoll(), and periodic interrupts to run code that handles the timing-critical I/O. The I/O interrupts come at regular intervals. If you could arrange so that between the I/O you do at most slightly less work than until the next one, you could then poll the interrupt flag.
Polling shouldn't be a timing problem since the comments say that you have many tens of cycles before the ISR needs to actually fire (a polling loop maybe adds 7 cycles).
The question is how much work you need to do between the USB interrupts. Apparently it's not just a little bit, or my test would have worked. And also the I/O handling eats into some of the time, depending on how much data is being exchanged. I wonder whether the CRC routines eat a lot during initial configuration when several packets are being sent back to the host.
I became interested in this after reading that someone had implemented USBaspLoader on a attiny chip that lacked a separate set of vectors for the bootloader, and thus had to share the vectors with the application. If V-USB could be made to work with polling, the bootloader would only need to share the reset vector, a far easier one to do that with.