What's the relationship between ISR() and AttachIntterupt( )? why both or either

Sometimes, I see one of the functions inside the code, but sometimes I see both of the functions inside the code

  1. is ISR a user defined function that associated with a vector
    ISR( vector )

  2. AttachInterrupt(interrupt pin, isr, ..) sometimes I see onky attachinterrupt function without the ISR(vector) function,
    It's associated a pin change with a certain isr but this isr doesn't have the format of ISR(vector) . Instead it just any defined function such as wake(). In this case, is there a certain interrupt vector from the table associated with AttachInterrupt?

  3. Sometimes I see both AttachInterrupt and ISR(vector) functions in the code.

Why there are 3 different scenarios with Interrupts?

Nick has a good discussion on this:

attachInterrupt() is used with the external interrupts - it is just a convenience because this is the most common Arduino usage.

ISR.... is used with other interrupts

...R

Robin2:
attachInterrupt() is used with the external interrupts - it is just a convenience because this is the most common Arduino usage.

ISR.... is used with other interrupts

...R

How come AttachInterrupt doesn't have a vector (from vector table) associated with it?

The vectors from vector table has both internal and external interrupts.

How come AttachInterrupt doesn't have a vector (from vector table) associated with it?

You have the source code of attachInterupt.

It may be instructive for you to study it.

AWOL:
You have the source code of attachInterupt.

It may be instructive for you to study it.

I have an example in front me right now

int pin = 13;
volatile int state = LOW;

void setup() {
    pinMode(pin, OUTPUT);
    attachInterrupt(digitalPinToInterrupt(pin), blink, CHANGE);
}

void loop() {
    digitalWrite(pin, state);
}

void blink() {
    state = !state;
}[/code}

So base on the table pin 13 belongs vector 4 or PCINT0_vect, right?
Since in this example, I defined a custom ISR therefore the macro
ISR(PCINT0_vect) {  }   would be empty inside?



 1  Reset 
 2  External Interrupt Request 0  (pin D2)          (INT0_vect)
 3  External Interrupt Request 1  (pin D3)          (INT1_vect)
 4  Pin Change Interrupt Request 0 (pins D8 to D13) (PCINT0_vect)
 5  Pin Change Interrupt Request 1 (pins A0 to A5)  (PCINT1_vect)
 6  Pin Change Interrupt Request 2 (pins D0 to D7)  (PCINT2_vect)
 7  Watchdog Time-out Interrupt                     (WDT_vect)
 8  Timer/Counter2 Compare Match A                  (TIMER2_COMPA_vect)
 9  Timer/Counter2 Compare Match B                  (TIMER2_COMPB_vect)
10  Timer/Counter2 Overflow                         (TIMER2_OVF_vect)
11  Timer/Counter1 Capture Event                    (TIMER1_CAPT_vect)
12  Timer/Counter1 Compare Match A                  (TIMER1_COMPA_vect)
13  Timer/Counter1 Compare Match B                  (TIMER1_COMPB_vect)
14  Timer/Counter1 Overflow                         (TIMER1_OVF_vect)
15  Timer/Counter0 Compare Match A                  (TIMER0_COMPA_vect)
16  Timer/Counter0 Compare Match B                  (TIMER0_COMPB_vect)
17  Timer/Counter0 Overflow                         (TIMER0_OVF_vect)
18  SPI Serial Transfer Complete                    (SPI_STC_vect)
19  USART Rx Complete                               (USART_RX_vect)
20  USART, Data Register Empty                      (USART_UDRE_vect)
21  USART, Tx Complete                              (USART_TX_vect)
22  ADC Conversion Complete                         (ADC_vect)
23  EEPROM Ready                                    (EE_READY_vect)
24  Analog Comparator                               (ANALOG_COMP_vect)
25  2-wire Serial Interface  (I2C)                  (TWI_vect)
26  Store Program Memory Ready                      (SPM_READY_vect)

Above example,
So base on the table pin 13 belongs vector 4 or PCINT0_vect, right?
Since in this example, I defined a custom ISR therefore the macro
ISR(PCINT0_vect) { } would be empty inside?

1 Reset
2 External Interrupt Request 0 (pin D2) (INT0_vect)
3 External Interrupt Request 1 (pin D3) (INT1_vect)
4 Pin Change Interrupt Request 0 (pins D8 to D13) (PCINT0_vect)
5 Pin Change Interrupt Request 1 (pins A0 to A5) (PCINT1_vect)
6 Pin Change Interrupt Request 2 (pins D0 to D7) (PCINT2_vect)
7 Watchdog Time-out Interrupt (WDT_vect)
8 Timer/Counter2 Compare Match A (TIMER2_COMPA_vect)
9 Timer/Counter2 Compare Match B (TIMER2_COMPB_vect)
10 Timer/Counter2 Overflow (TIMER2_OVF_vect)
11 Timer/Counter1 Capture Event (TIMER1_CAPT_vect)
12 Timer/Counter1 Compare Match A (TIMER1_COMPA_vect)
13 Timer/Counter1 Compare Match B (TIMER1_COMPB_vect)
14 Timer/Counter1 Overflow (TIMER1_OVF_vect)
15 Timer/Counter0 Compare Match A (TIMER0_COMPA_vect)
16 Timer/Counter0 Compare Match B (TIMER0_COMPB_vect)
17 Timer/Counter0 Overflow (TIMER0_OVF_vect)
18 SPI Serial Transfer Complete (SPI_STC_vect)
19 USART Rx Complete (USART_RX_vect)
20 USART, Data Register Empty (USART_UDRE_vect)
21 USART, Tx Complete (USART_TX_vect)
22 ADC Conversion Complete (ADC_vect)
23 EEPROM Ready (EE_READY_vect)
24 Analog Comparator (ANALOG_COMP_vect)
25 2-wire Serial Interface (I2C) (TWI_vect)
26 Store Program Memory Ready (SPM_READY_vect)

You could use ISR (INT0_vect) as an alternative to attachInterrupt()

What you have in Reply #5 is not the source code for the attachInterrupt() function

...R

Go to /hardware/arduino/avr/cores/arduino/WInterrupts.c.

All will be revealed.