Pages: [1]   Go Down
Author Topic: Intterrupts  (Read 979 times)
0 Members and 1 Guest are viewing this topic.
Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the difference between a pin-change interrupt and an external interrupt?

Thanks!
baum
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The external interrupts are associated with specific interrupt pins.  They can be set to signal on a LOW level, RISING edge, FALLING edge, or CHANGE (both rising and falling edge).

There is one "Pin Change" interrupt per port (8-bit group of I/O pins).  The pins within the group can be individually masked.  The pins are sampled periodically and the interrupt is signaled if any of the un-masked pins has changed.  If you have more than one pin in a port enabled you have to read the interrupt flag register to find out which pin(s) changed.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But on the attiny, every pin has a pcint (pin change interrupt)!!!!


http://www.atmel.com/dyn/resources/prod_documents/2535S.pdf (2ndPage)
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 197
Posts: 12741
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Pin-change...
• Applies to all pins
• Overloaded; all pins on a port are vectored through a single interrupt handler
• Fires only on CHANGE
• Processor clock does not need to be running

External...
• Applies to only specific pins
• One-to-one; each pin has a dedicated interrupt handler
• Can be configured to fire on RISING, FALLING, LOW, CHANGE
• Requires the processor clock to be running (except LOW)
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 197
Posts: 12741
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But on the attiny, every pin has a pcint (pin change interrupt)!!!!

Each pin on that processor is capable of generating a pin-change interrupt.  If any pin is configured to generate a pin-change interrupt, when the interrupt occurs, execution is vectored through a single interrupt service routine.
Logged

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I call the ISR and get the pin state?

Is it something like

PCINT << 4?
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 197
Posts: 12741
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How do I call the ISR

Are you asking how to enable pin-change interrupts?

Quote
and get the pin state?

digitalRead

Logged

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I can use digital read w/ your cores; how do i do pchange interrupts?
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 197
Posts: 12741
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


You're going to have a tough time using any core with an ATtiny13.  It really does not have much memory (64 bytes of SRAM; 4 bytes are used just getting into loop).  The processor was really meant to be programmed using assembly or possibly "raw" C.

There is an enormous amount of information available regarding pin-change interrupts.

http://www.google.com/search?q=arduino+pin+change
http://www.arduino.cc/playground/Main/PcInt
http://www.arduino.cc/playground/Main/PinChangeInt
http://arduino-tiny.googlecode.com/files/PinChangeInterrupt-0001.zip
http://arduino.cc/forum/index.php/topic,51838.msg369796.html#msg369796
Logged

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was talking about the '85... sorry!

So in summary, external interrupts execute certain code when triggered, pin change interrupts are a register that stores the inputs on that port?
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 197
Posts: 12741
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was talking about the '85... sorry!

In that case, just snag the Pin Change library from the Tiny Core website and play a bit.

So in summary, external interrupts execute certain code when triggered

Yes.

Quote
pin change interrupts are a register that stores the inputs on that port?

No.  "Pin change interrupts" also execute certain code when triggered.  The difference is that up to eight pins are tied to a single interrupt service routine and only CHANGE is supported.
Logged

Pages: [1]   Go Up
Jump to: