Page 1 of 1

Using Pin change interrupt instead of INT0

Posted: Tue Oct 03, 2017 12:14 pm
by NewbeeV-USB
Can I use pin change interrupt available in ATmega328p to connect to vusb instead of INT0 to connect to D+.

Re: Using Pin change interrupt instead of INT0

Posted: Tue Oct 03, 2017 8:40 pm
by horo
Yes, you can do so. I did it for an ATtiny85, have a look at my project here in the forum.
You have to define it in the file usbconfig.h

Code: Select all

...
/* ----------------------- Optional MCU Description ------------------------ */

/* The following configurations have working defaults in usbdrv.h. You
 * usually don't need to set them explicitly. Only if you want to run
 * the driver on a device which is not yet supported or with a compiler
 * which is not fully supported (such as IAR C) or if you use a differnt
 * interrupt than INT0, you may have to define some of these.
 */
#define USB_INTR_CFG            PCMSK
#define USB_INTR_CFG_SET        (1 << USB_CFG_DPLUS_BIT)
#define USB_INTR_CFG_CLR        0
#define USB_INTR_ENABLE         GIMSK
#define USB_INTR_ENABLE_BIT     PCIE
#define USB_INTR_PENDING        GIFR
#define USB_INTR_PENDING_BIT    PCIF
#define USB_INTR_VECTOR         PCINT0_vect


Ciao, Martin

Re: Using Pin change interrupt instead of INT0

Posted: Sun Oct 08, 2017 7:10 pm
by ulao
I find this rather interesting, could anyone explain the advantages/disadvantages or reason for wanting to do so? I'm thinking it would allow the device to sync to the usb poll better but not sure I follow the intention.