Interrupt vector tables
published: 21 April 2020 / updated 8 June 2020
Using interrupt vectors
Specific Flash Forth
To assign the execution of a word written in FORTH language to an interruption, two things are needed:
- retrieve the execution address cfa with the word
'
or[']
- assign this execution address cfa to the vector
of interruption corresponding with the word
int!
Retrieving the execution address
The execution address of a FORTH word, abbreviated cfa, can be obtained by simply typing:
#2 constant INT0
variable COUNTER
: count.inc ( ---)
COUNTER 1+!
;i
' count.inc INTO int!
The sequence VERY IMPORTANT Any FORTH word used in an interrupt vector must complete its definition with
the word ' count.inc
retrieves the address cfa
of the word count.inc
.
;i
and not the word ;
Assignment of the interrupt vector
In the example above, the sequence INTO int!
affects the cfa
from the word count.inc
to the interrupt vector corresponding to INT0 (value 2).
The word int!
accepts a vector number. A vector is not a memory address!
In the example, this assignment is made in interpreted mode. Extract:
' count.inc INTO int!
If we had wanted to use the INT1 interrupt, we would have written:
#3 constant INT1 ' count.inc INT1 int!
To initialize an interrupt vector in the definition of a FORTH word, we will use
the word [']
like this:
: int.init ( ---)
['] count.inc INT1 int!
;
ATmega328P Interrupt Vector Table
The Atmega328 processor equips all of the following ARDUINO cards:
- NANO
- UNO
Vector No | Program Address | Source | Interrupt Definition |
---|---|---|---|
1 | $0000 | RESET | |
2 | $0002 | INT0 | External Interrupt Request 0 |
3 | $0004 | INT1 | External Interrupt Request 1 |
4 | $0006 | PCINT0 | Pin Change Interrupt Request 0 |
5 | $0008 | PCINT1 | Pin Change Interrupt Request 1 |
6 | $000A | PCINT2 | Pin Change Interrupt Request 2 |
7 | $000C | WDT | Watchdog Time-out Interrupt |
8 | $000E | TIMER2 COMPA | Timer/Counter2 Compare Match A |
9 | $0010 | TIMER2 COMPB | Timer/Counter2 Compare Match B |
10 | $0012 | TIMER2 OVF | Timer/Counter2 Overflow |
11 | $0014 | TIMER1 CAPT | Timer/Counter1 Capture Event |
12 | $0016 | TIMER1 COMPA | Timer/Counter1 Compare Match A |
13 | $0018 | TIMER1 COMPB | Timer/Counter1 Compare Match B |
14 | $001A | TIMER1 OVF | Timer/Counter1 Overflow |
15 | $001C | TIMER0 COMPA | Timer/Counter0 Compare Match A |
16 | $001E | TIMER0 COMPB | Timer/Counter0 Compare Match B |
17 | $0020 | TIMER0 OVF | Timer/Counter0 Overflow |
18 | $0022 | SPI, STC | SPI Serial Transfer Complete |
19 | $0024 | USART | RX USART Rx Complete |
20 | $0026 | USART, UDRE | USART Data Register Empty |
21 | $0028 | USART | TX USART |
22 | $002A | ADC | ADC Conversion Complete |
23 | $002C | EE READY | EEPROM Ready |
24 | $002E | ANALOG COMP | Analog Comparator |
25 | $0030 | TWI | 2-wire Serial Interface (I2C) |
26 | $0032 | SPM READY | Store Program Memory Ready |
ATmega2560 Interrupt Vector Table
The Atmega2560 processor equips all of the following ARDUINO cards:
- MEGA
Vector No | Program Address | Source | Interrupt Definition |
---|---|---|---|
1 | $0000 | RESET | External Pin, Power-on Reset, Brown-out Reset, Watchdog Reset and JTAG AVR Reset |
2 | $0002 | INT0 | External Interrupt Request 0 |
3 | $0004 | INT1 | External Interrupt Request 1 |
4 | $0006 | INT2 | External Interrupt Request 2 |
5 | $0008 | INT3 | External Interrupt Request 3 |
6 | $000A | INT4 | External Interrupt Request 4 |
7 | $000C | INT5 | External Interrupt Request 5 |
8 | $000E | INT6 | External Interrupt Request 6 |
9 | $0010 | INT7 | External Interrupt Request 7 |
10 | $0012 | PCINT0 | Pin Change Interrupt Request 0 |
11 | $0014 | PCINT1 | Pin Change Interrupt Request 1 |
12 | $0016 | PCINT2 | Pin Change Interrupt Request 2 |
13 | $0018 | WDT | Watchdog Time-out Interrupt |
14 | $001A | TIMER2 COMPA | Timer/Counter2 Compare Match A |
15 | $001C | TIMER2 COMPB | Timer/Counter2 Compare Match B |
16 | $001E | TIMER2 OVF | Timer/Counter2 Overflow |
17 | $0020 | TIMER1 CAPT | Timer/Counter1 Capture Event |
18 | $0022 | TIMER1 COMPA | Timer/Counter1 Compare Match A |
19 | $0024 | TIMER1 COMPB | Timer/Counter1 Compare Match B |
20 | $0026 | TIMER1 COMPC | Timer/Counter1 Compare Match C |
21 | $0028 | TIMER1 OVF | Timer/Counter1 Overflow |
22 | $002A | TIMER0 COMPA | Timer/Counter0 Compare Match A |
23 | $002C | TIMER0 COMPB | Timer/Counter0 Compare match B |
24 | $002E | TIMER0 OVF | Timer/Counter0 Overflow |
25 | $0030 | SPI, STC | SPI Serial Transfer Complete |
26 | $0032 | USART0 RX | USART0 Rx Complete |
27 | $0034 | USART0 UDRE | USART0 Data Register Empty |
28 | $0036 | USART0 TX | USART0 Tx Complete |
29 | $0038 | ANALOG COMP | Analog Comparator |
30 | $003A | ADC | ADC Conversion Complete |
31 | $003C | EE READY | EEPROM Ready |
32 | $003E | TIMER3 CAPT | Timer/Counter3 Capture Event |
33 | $0040 | TIMER3 COMPA | Timer/Counter3 Compare Match A |
34 | $0042 | TIMER3 COMPB | Timer/Counter3 Compare Match B |
35 | $0044 | TIMER3 COMPC | Timer/Counter3 Compare Match C |
36 | $0046 | TIMER3 OVF | Timer/Counter3 Overflow |
37 | $0048 | USART1 RX | USART1 Rx Complete |
38 | $004A | USART1 UDRE | USART1 Data Register Empty |
39 | $004C | USART1 TX | USART1 Tx Complete |
40 | $004E | TWI | 2-wire Serial Interface |
41 | $0050 | SPM READY | Store Program Memory Ready |
42 | $0052 | TIMER4 CAPT | Timer/Counter4 Capture Event |
43 | $0054 | TIMER4 COMPA | Timer/Counter4 Compare Match A |
44 | $0056 | TIMER4 COMPB | Timer/Counter4 Compare Match B |
45 | $0058 | TIMER4 COMPC | Timer/Counter4 Compare Match C |
46 | $005A | TIMER4 OVF | Timer/Counter4 Overflow |
47 | $005C | TIMER5 CAPT | Timer/Counter5 Capture Event |
48 | $005E | TIMER5 COMPA | Timer/Counter5 Compare Match A |
49 | $0060 | TIMER5 COMPB | Timer/Counter5 Compare Match B |
50 | $0062 | TIMER5 COMPC | Timer/Counter5 Compare Match C |
51 | $0064 | TIMER5 OVF | Timer/Counter5 Overflow |
52 | $0066 | USART2 RX | USART2 Rx Complete |
53 | $0068 | USART2 UDRE | USART2 Data Register Empty |
54 | $006A | USART2 TX | USART2 Tx Complete |
55 | $006C | USART3 RX | Rx Complete |
56 | $006E | USART3 UDRE | USART3 Data Register Empty |
57 | $0070 | USART3 TX | USART3 Tx Complete |