Search code examples
embeddedinterruptavravr-gcc

why the number of vector of INT0 is 1 not 2 as datasheet?


I am using an ATmega32 to do interrupt when i trying to do driver of external interrupt 0 , faced me a problem

Interrupt Vectors Table in ATmega32

Interrupt Vectors code in ISR(vector)

In iom32.h code , we see that ((INT0_vect " _VECTOR(1) ")) it's number 1 but in data sheet we see that the number is 2 , why ?


Solution

  • The datasheet starts numbering with the reset vector. But there is no need for an explicit define (like RESET_vect) for the reset vector, since it will not be used in conjunction with ISR(). So in the header/AVRGCC implementation it is omitted.

    If you compile this

    ISR(INT0_vect) {  }
    

    and look at the interrupt vector table

    00000000 <__vectors>:
    0:  0c 94 46 00     jmp 0x8c    ; 0x8c <__ctors_end>
    4:  0c 94 5f 00     jmp 0xbe    ; 0xbe <__vector_1>
    

    you can see that __vector_1 is placed at byte address 4, which corresponds to the word address 2 from the data sheet.