Page 1 of 1

Using Pin Change Interrupt

Posted: Mon Mar 22, 2010 11:59 pm
by chrismerck
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