Author |
Message |
cappy2112

Joined: Dec 24, 2004 Posts: 2494 Location: San Jose, California
Audio files: 2
G2 patch files: 1
|
Posted: Wed Oct 10, 2012 9:12 pm Post subject:
Pin Change Interrupts library for Arduino |
 |
|
The Arduino has the ability to use almost every pin as a hardware interrupt, even though there are only 2 external interrupt pins on the ATMega 328.
The library is called Pin Change Interrupt library. I've only used it in a limited experiment, but it worked well enough.
Support has recently been added for the 2560.
This library identifies which pin was interrupted, your program can make decisions based on the pin #.
http://code.google.com/p/arduino-pinchangeint/ _________________ Free Tibet. Release the Panchen Lama from prison. Let the Dalai Lama return to his home. |
|
Back to top
|
|
 |
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Sat Oct 13, 2012 11:50 am Post subject:
|
 |
|
This sounds like it would save some time coding. I was looking at interrupts in the AVR reference and it would be handy to have some pre-written code to help identifying the source of an interrupt. Thanks for posting this.
Steve |
|
Back to top
|
|
 |
cappy2112

Joined: Dec 24, 2004 Posts: 2494 Location: San Jose, California
Audio files: 2
G2 patch files: 1
|
Posted: Sat Oct 13, 2012 12:04 pm Post subject:
|
 |
|
MusicMan11712 wrote: | This sounds like it would save some time coding. I was looking at interrupts in the AVR reference and it would be handy to have some pre-written code to help identifying the source of an interrupt. Thanks for posting this.
Steve |
When you don't use this library, it's not a problem
identifying which pin was interrupted.
When the interrupt occurs, the ISR for that pin is called.
You register the ISR to be called for each pin, so you know which pin was interrupted, and there are only 2 external interrupt pins on the 328. I think there are 4 or 6 on the 2560, but again, each pin usually has it's own ISR.
The only time you need this library is if you want to use >2 external interrupt pins (for the 328), or 4 (or 6??) for the 2560.
I believe there is some speed penalty for using Pin Change interrupts, but
this may not be an issue for many applications. _________________ Free Tibet. Release the Panchen Lama from prison. Let the Dalai Lama return to his home. |
|
Back to top
|
|
 |
|