Using Pin Change Interrupt

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

Using Pin Change Interrupt

Post by chrismerck » Mon Mar 22, 2010 11:59 pm

Just a note on configuring V-USB for use with a pin change interrupt (PCINTx).

To use, for example, PCINT16 on an ATmega168, the following configuration needs to be set in usbconfig.h:

near the top:

Code: Select all

#define USB_CFG_DPLUS_BIT       0 // PD0 is PCINT16


at the end:

Code: Select all

#define USB_INTR_CFG            PCMSK2
#define USB_INTR_CFG_SET        (1 << PCINT16)
#define USB_INTR_CFG_CLR        0
#define USB_INTR_ENABLE         PCICR
#define USB_INTR_ENABLE_BIT     PCIE2
#define USB_INTR_PENDING        PCIFR
#define USB_INTR_PENDING_BIT    PCIF2
#define USB_INTR_VECTOR         SIG_PIN_CHANGE2


Cheers,
Chris

Post Reply