Anybody using PCINT instead of INT0?

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

Anybody using PCINT instead of INT0?

Post by tman_r » Tue Jan 03, 2012 4:14 am

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.

tman_r

Re: Anybody using PCINT instead of INT0?

Post by tman_r » Sun Jan 08, 2012 9:00 pm

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

Daid
Rank 2
Rank 2
Posts: 55
Joined: Mon Apr 18, 2011 12:19 pm

Re: Anybody using PCINT instead of INT0?

Post by Daid » Mon Jan 09, 2012 12:13 pm

For documentation not to get lost, you might want to put it on the wiki? http://vusb.wikidot.com/

Peter Chaffe
Rank 1
Rank 1
Posts: 20
Joined: Fri Dec 02, 2011 12:25 pm

Re: Anybody using PCINT instead of INT0?

Post by Peter Chaffe » Mon Jan 09, 2012 12:51 pm

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.

Harwestor
Posts: 1
Joined: Mon Jan 16, 2012 7:14 pm

Re: Anybody using PCINT instead of INT0?

Post by Harwestor » Mon Jan 16, 2012 7:21 pm

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.

Peter Chaffe
Rank 1
Rank 1
Posts: 20
Joined: Fri Dec 02, 2011 12:25 pm

Re: Anybody using PCINT instead of INT0?

Post by Peter Chaffe » Mon Jan 16, 2012 10:03 pm

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...

Post Reply