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


Post by Peter » Wed Feb 27, 2008 11:34 am


I want to use the Interupt1 to measure a fequency.
If there is a falling edge the timer has to start. At a rising edge the timer should stop.

So my question is how to initialize the interupt. In the usbInit() the Interup0 is initialized.
But my interupt should only be acitve if it will be used. So I want to activate and disable it on some points in the programm.

My other question is, how and where I have to write the ISR?
Can I write it like this:

Code: Select all


I hope you can help me.

One last question I have:
Is there anywhere a tutorial or a documentation how AVR-USB is used?


Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Feb 28, 2008 11:01 pm

Regarding how to enable/disable interrupts: You have to set the interrupt-enable bit for your interrupt in the appropriate register. That's similar to the code in usbInit().

The interrupt handler should not be declared with ISR if you use AVR-USB since it must allow other interrupts. Use UTIL_INTERRUPT instead where UTIL_INTERRUPT is declared as

Code: Select all

#define UTIL_INTERRUPT(signame)                         \
    void signame (void) __attribute__ ((interrupt));    \
    void signame (void)

There's currently no tutorial, only examples, see our reference implementations.

Post Reply