Page 1 of 1

Anybody using PCINT instead of INT0?

Posted: Tue Jan 03, 2012 4:14 am
by tman_r
Can't use INT0 pin on D- due to basically other needs for the pins on an ATtiny84 (or similar).

Has anyone successfully used PCINT instead of INT0? It seems pretty clear what needs to be changed at the bottom of usbconfig.h [*], but I notice that:
- INT0 is set to interrupt only on the rising edge (via ISC0x on MCUCR).
- PCINT's are necessarily going to interrupt on both edges, i.e. toggles. (I guess by definition of "pin _change_", and lack of any clear way to alter this).

Have any others dealt with this?

[*] -- I also see a need to insert a few lines of code in order to set the PCMSK0 on teh ATtiny84.

Thanks,
Tman.

Re: Anybody using PCINT instead of INT0?

Posted: Sun Jan 08, 2012 9:00 pm
by tman_r
Here I am replying to myself, just to document for the group how to get it to work. It's a piece of cake.
No sweat that the INT will trigger on both rising and falling edges, as the interrupt handler does cli() anyways.

/* Use PCINT0 instead of INT0 */
#define USB_INTR_CFG PCMSK0
#define USB_INTR_CFG_SET (1 << PCINT0)
#define USB_INTR_CFG_CLR 0
#define USB_INTR_ENABLE GIMSK
#define USB_INTR_ENABLE_BIT PCIE0
#define USB_INTR_PENDING GIFR
#define USB_INTR_PENDING_BIT PCIF0
#define USB_INTR_VECTOR PCINT0_vect

Re: Anybody using PCINT instead of INT0?

Posted: Mon Jan 09, 2012 12:13 pm
by Daid
For documentation not to get lost, you might want to put it on the wiki? http://vusb.wikidot.com/

Re: Anybody using PCINT instead of INT0?

Posted: Mon Jan 09, 2012 12:51 pm
by Peter Chaffe
I never answered because I couldn't find the reference, but there is a mention somewhere that any interrupt pin can be used successfully but the big drawback is that it severely limits the use of any higher interrupt pins for other purposes. so in effect it would probably be self defeating.

Re: Anybody using PCINT instead of INT0?

Posted: Mon Jan 16, 2012 7:21 pm
by Harwestor
Peter Chaffe wrote: so in effect it would probably be self defeating.

So then there's no sense in it or what?
______________________
making an iphone app

Re: Anybody using PCINT instead of INT0?

Posted: Mon Jan 16, 2012 10:03 pm
by Peter Chaffe
Self defeating was probably a bad choice of words, and I still can't find the reference I mentioned...

What I meant to say was that it wouldn't be a preferred option to use another pin than INT0. as any higher interrupt pins would then need to be used with great care to avoid any possible unexpected results...

Yes I still think it's not a good idea, but that is only an opinion...