v-usb + interrupts?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
mrzephy
Posts: 5
Joined: Fri Sep 23, 2011 3:32 am

v-usb + interrupts?

Post by mrzephy » Tue Mar 06, 2012 10:43 pm

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.

Daid
Rank 2
Rank 2
Posts: 55
Joined: Mon Apr 18, 2011 12:19 pm

Re: v-usb + interrupts?

Post by Daid » Wed Mar 07, 2012 12:05 pm

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)

mrzephy
Posts: 5
Joined: Fri Sep 23, 2011 3:32 am

Re: v-usb + interrupts?

Post by mrzephy » Fri Mar 09, 2012 4:59 pm

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.

Daid
Rank 2
Rank 2
Posts: 55
Joined: Mon Apr 18, 2011 12:19 pm

Re: v-usb + interrupts?

Post by Daid » Mon Mar 12, 2012 7:18 pm

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.

xiangrui
Rank 1
Rank 1
Posts: 30
Joined: Sun Jan 01, 2012 5:19 am

Re: v-usb + interrupts?

Post by xiangrui » Thu Mar 15, 2012 10:21 pm

"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.

Daid
Rank 2
Rank 2
Posts: 55
Joined: Mon Apr 18, 2011 12:19 pm

Re: v-usb + interrupts?

Post by Daid » Fri Mar 16, 2012 2:16 pm

Because entering an interrupt routine disables global interrupts, and exiting the interrupt routine enables them again.

Post Reply