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.
Anybody using PCINT instead of INT0?
Re: Anybody using PCINT instead of INT0?
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
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?
For documentation not to get lost, you might want to put it on the wiki? http://vusb.wikidot.com/
-
- Rank 1
- Posts: 20
- Joined: Fri Dec 02, 2011 12:25 pm
Re: Anybody using PCINT instead of INT0?
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?
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
Last edited by Harwestor on Wed Jan 25, 2012 10:20 pm, edited 1 time in total.
-
- Rank 1
- Posts: 20
- Joined: Fri Dec 02, 2011 12:25 pm
Re: Anybody using PCINT instead of INT0?
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...
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...