Page 1 of 1

v-usb + interrupts?

Posted: Tue Mar 06, 2012 10:43 pm
by mrzephy
Is there a way to use interrupts when using v-usb? For example if I wanted a 1KHz timer. Because right now as soon as I enable some interrupt other than v-usb, USB will stop working.

Re: v-usb + interrupts?

Posted: Wed Mar 07, 2012 12:05 pm
by Daid
This is possible, however, you need to make sure the USB interrupt is the highest you use. And you need to make sure your other interrupt doesn't take too long (or enable interrupts inside the interrupt routine)

Re: v-usb + interrupts?

Posted: Fri Mar 09, 2012 4:59 pm
by mrzephy
Can you give more details on how to achieve this?
My ISR is pretty short, but I would rather let the V-USB ISR interrupt my ISR, just in case. If you can list the most important things/flags/functions to use, I would appreaciate it!

Btw have you used this kind of approach and did it work reliably (i.e. no USB connection interruptions).

Thanks.

Re: v-usb + interrupts?

Posted: Mon Mar 12, 2012 7:18 pm
by Daid
I've used timer interrupts to control step motors without an issue for the V-USB connection. Without enabling interrupts in the timer.

If you want to enable interrupts inside the interrupt you need to do an "sei();" call inside the interrupt.

Re: v-usb + interrupts?

Posted: Thu Mar 15, 2012 10:21 pm
by xiangrui
"sei();" is simply to enable global interrupt, right? It is already enabled in V-USB. Why do we need to do it again inside interrupt? Thanks.

-Xiangrui

Daid wrote:I've used timer interrupts to control step motors without an issue for the V-USB connection. Without enabling interrupts in the timer.

If you want to enable interrupts inside the interrupt you need to do an "sei();" call inside the interrupt.

Re: v-usb + interrupts?

Posted: Fri Mar 16, 2012 2:16 pm
by Daid
Because entering an interrupt routine disables global interrupts, and exiting the interrupt routine enables them again.