17.3 Interrupt Vectors in ATmega168PB

Table 17-4. Reset and Interrupt Vectors in ATmega168PB
Vector No.Program Address(2)SourceInterrupt Definition
10x0000(1)RESETExternal Pin, Power-on Reset, Brown-out Reset and Watchdog System Reset
20x0002INT0External Interrupt Request 0
30x0004INT1External Interrupt Request 1
40x0006PCINT0Pin Change Interrupt Request 0
50x0008PCINT1Pin Change Interrupt Request 1
60x000APCINT2Pin Change Interrupt Request 2
70x000CWDTWatchdog Time-out Interrupt
80x000ETIMER2 COMPATimer/Counter2 Compare Match A
90x0010TIMER2 COMPBTimer/Counter2 Compare Match B
100x0012TIMER2 OVFTimer/Counter2 Overflow
110x0014TIMER1 CAPTTimer/Counter1 Capture Event
120x0016TIMER1 COMPATimer/Counter1 Compare Match A
130x0018TIMER1 COMPBTimer/Coutner1 Compare Match B
140x001ATIMER1 OVFTimer/Counter1 Overflow
150x001CTIMER0 COMPATimer/Counter0 Compare Match A
160x001ETIMER0 COMPBTimer/Counter0 Compare Match B
170x0020TIMER0 OVFTimer/Counter0 Overflow
180x0022SPI, STCSPI Serial Transfer Complete
190x0024USART, RXUSART Rx Complete
200x0026USART, UDREUSART, Data Register Empty
210x0028USART, TXUSART, Tx Complete
220x002AADCADC Conversion Complete
230x002CEE READYEEPROM Ready
240x002EANALOG COMPAnalog Comparator
250x0030TWI2-wire Serial Interface (I2C)
260x0032SPM READYStore Program Memory Ready
270x0034USART, STARTUSART Start Edge Interrupt
Note:
  1. When the BOOTRST Fuse is programmed, the device will jump to the Boot Loader address at reset, please refer to Boot Loader Support – Read-While-Write Self-Programming chapter.
  2. When the IVSEL bit in MCUCR (MCUCR.IVSEL) is set, Interrupt Vectors will be moved to the start of the Boot Flash Section. The address of each Interrupt Vector will then be the address in this table added to the start address of the Boot Flash Section.

The following table shows reset and Interrupt Vectors placement for the various combinations of BOOTRST and IVSEL settings. If the program never enables an interrupt source, the Interrupt Vectors are not used, and regular program code can be placed at these locations. This is also the case if the Reset Vector is in the Application section while the Interrupt Vectors are in the Boot section or vice versa.

Table 17-5. Reset and Interrupt Vectors Placement in ATmega168PB
BOOTRSTIVSELReset AddressInterrupt Vectors Start Address
100x0000x002
110x000Boot Reset Address + 0x0002
00Boot Reset Address0x002
01Boot Reset AddressBoot Reset Address + 0x0002
Note: The Boot Reset Address is shown in Table. Boot Size Configuration, ATmega168PB in ATmega168PB Boot Loader Parameters. For the BOOTRST Fuse “1” means unprogrammed while “0” means programmed.

The most typical and general program setup for the Reset and Interrupt Vector Addresses in ATmega168PB is:

AddressLabelsCode Comments
0x0000jmpRESET; Reset Handler
0x0002jmpEXT_INT0; IRQ0 Handler
0x0004jmpEXT_INT1; IRQ1 Handler
0x0006jmpPCINT0; PCINT0 Handler
0x0008jmpPCINT1; PCINT1 Handler
0x000AjmpPCINT2; PCINT2 Handler
0x000CjmpWDT; Watchdog Timer Handler
0x000EjmpTIM2_COMPA; Timer2 Compare A Handler
0x0010jmpTIM2_COMPB; Timer2 Compare B Handler
0x0012jmpTIM2_OVF; Timer2 Overflow Handler
0x0014jmpTIM1_CAPT; Timer1 Capture Handler
0x0016jmpTIM1_COMPA; Timer1 Compare A Handler
0x0018jmpTIM1_COMPB; Timer1 Compare B Handler
0x001AjmpTIM1_OVF; Timer1 Overflow Handler
0x001CjmpTIM0_COMPA; Timer0 Compare A Handler
0x001EjmpTIM0_COMPB; Timer0 Compare B Handler
0x0020jmpTIM0_OVF; Timer0 Overflow Handler
0x0022jmpSPI_STC; SPI Transfer Complete Handler
0x0024jmpUSART_RXC; USART, RX Complete Handler
0x0026jmpUSART_UDRE; USART, UDR Empty Handler
0x0028jmpUSART_TXC; USART, TX Complete Handler
0x002AjmpADC; ADC Conversion Complete Handler
0x002CjmpEE_RDY; EEPROM Ready Handler
0x002EjmpANA_COMP; Analog Comparator Handler
0x0030jmpTWI; 2-wire Serial Interface Handler
0x0032jmpSPM_RDY; Store Program Memory Ready Handler
;
0x0033RESET: ldir16, high(RAMEND); Main program start
0x0034out SPH,r16; Set Stack Pointer to top of RAM
0x0035ldi r16, low(RAMEND)
0x0036out SPL,r16
0x0037sei; Enable interrupts
0x0038<instr> xxx
.........

When the BOOTRST Fuse is unprogrammed, the Boot section size set to 2Kbytes and the IVSEL bit in the MCUCR Register is set before any interrupts are enabled, the most typical and general program setup for the Reset and Interrupt Vector Addresses in ATmega168PB is:

AddressLabelsCode Comments
0x0000RESET: ldir16,high(RAMEND); Main program start
0x0001outSPH,r16; Set Stack Pointer to top of RAM
0x0002ldir16,low(RAMEND)
0x0003outSPL,r16
0x0004sei; Enable interrupts
0x0005<instr> xxx
;
.org0x1C02
0x1C02jmpEXT_INT0; IRQ0 Handler
0x1C04jmpEXT_INT1; IRQ1 Handler
.........
;
0x1C32jmpSPM_RDY; Store Program Memory Ready Handler

When the BOOTRST Fuse is programmed and the Boot section size set to 2Kbytes, the most typical and general program setup for the Reset and Interrupt Vector Addresses in ATmega168PB is:

AddressLabelsCode Comments
.org0x0002
0x0002jmpEXT_INT0; IRQ0 Handler
0x0004jmpEXT_INT1; IRQ1 Handler
.........
;
0x0032jmpSPM_RDY; Store Program Memory Ready Handler
;
.org0x1C00
0x1C00RESET: ldir16,high(RAMEND); Main program start
0x1C01outSPH,r16; Set Stack Pointer to top of RAM
0x1C02ldir16,low(RAMEND)
0x1C03outSPL,r16
0x1C04sei; Enable interrupts
0x1C05<instr>xxx

When the BOOTRST Fuse is programmed, the Boot section size set to 2Kbytes and the IVSEL bit in the MCUCR Register is set before any interrupts are enabled, the most typical and general program setup for the Reset and Interrupt Vector Addresses in ATmega168PB is:

AddressLabelsCode Comments
;
.org0x1C00
0x1C00jmpRESET; Reset handler
0x1C02jmpEXT_INT0; IRQ0 Handler
0x1C04jmpEXT_INT1; IRQ1 Handler
.........
;
0x1C32jmpSPM_RDY; Store Program Memory Ready Handler
;
0x1C33RESET: ldir16,high(RAMEND); Main program start
0x1C34outSPH,r16; Set Stack Pointer to top of RAM
0x1C35ldir16,low(RAMEND)
0x1C36outSPL,r16
0x1C37sei; Enable interrupts
0x1C38<instr> xxx