HW interrupt problem

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Anonymous2

HW interrupt problem

Post by Anonymous2 » Tue Dec 07, 2010 12:03 am

Hello all,

I try to use v-usb in a project where I need HW interrupts for the ATMega. I use a modified 'custom-class' project. The USB is connected to INT0 and it works nicely.

In INT1 I have a peripheral system that can cause an interrupt. As an interrupt service I have (it is dummy for now)

Code: Select all

ISR( INT1_vect, ISR_NOBLOCK )
{
        toggleGreen();
        _delay_ms(250);
}

And yes, I can toggle the green led with the external interrupt.

Now, if I cause INT1-interrupts then occasionally my PC's host program won't find the USB device.
    Could not find USB device "LEDControl" with vid=0x16c0 pid=0x5dc
I run the 'set-led' program in a tight loop in the PC.

So it seems that the INT0 (USB) cannot override the INT1(external). Despite the ATMega docs saying it should. AVR-libc docs say passing ISR_NOBLOCK to the ISR function should not disable interrupts. Am I doing something wrong, or is this as specified?

thanks

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: HW interrupt problem

Post by maxi » Tue Dec 07, 2010 9:47 pm

Anonymous2 wrote: Am I doing something wrong, or is this as specified?

Yes, the 250 ms delay in an interrupt service routine is a BIG no no, regardless of the fact that the you must call usbPoll() at least once every 50 ms. Better increment a (volatile)global counter and toggleGreen every so many iterations.

Hope it helps

Anonymous2

Re: HW interrupt problem

Post by Anonymous2 » Tue Dec 07, 2010 9:53 pm

maxi wrote: you must call usbPoll() at least once every 50 ms.


How silly of me. Thanks for pointing out the obvious :oops:
Back to the drawing board for my FW design.

Post Reply