Page 1 of 1

AVR-USB on ATmega128

Posted: Thu May 15, 2008 12:01 am
by alanp
Hi Guys,

New to the forum and new to AVRs, but have programmed other microcontrollers.

I'm just laying out a board with an ATmega128 on it. I have a question about the interrupts that are used with AVR-USB.

On the ATmega128 there are 8 interrupts, INT0-3 are asynchronous, INT4-7 are synchronous. With the latest AVR-USB software you can change which interrupt is used. I understand that the interrupt used for the USB must be the highest priority, but does the interrupt need to be one of INT0-3 or can I used INT4-7???

I'm guessing this might change with clock frequency?

Thanks in advance.

Alan

Posted: Thu May 15, 2008 2:59 pm
by christian
It depends on whether you implement USB suspend or not. If you implement suspend, you need to wake up your CPU from sleep mode with the interrupt. This works only with INT0 - 3. Otherwise the additional synchronization with the I/O clock should not matter.

Posted: Fri May 30, 2008 4:42 am
by alanp
Just an update.

AVR-USB will work with INT4-7. My setup for INT5 is:

Code: Select all

#define USB_INTR_CFG            EICRB
#define USB_INTR_CFG_SET        ((1 << ISC50) | (1 << ISC51))
#define USB_INTR_CFG_CLR        0
#define USB_INTR_ENABLE         EIMSK
#define USB_INTR_ENABLE_BIT     INT5
#define USB_INTR_PENDING        EIFR
#define USB_INTR_PENDING_BIT    INTF5
#define USB_INTR_VECTOR         SIG_INTERRUPT5

It worked with no problems at all.