Electronic – Understanding difference between Interrupt Address and interrupt vector address

8051arminterruptsmicrocontroller

In my undergrads, I was taught 8051 and in interrupts my professor had said that on interrupt SP points to the address that is hardcoded and Program goes to excute those instructions. But in between two address space is only where I can write interrupt handling code and I wrote more than than byte available it will overwrite the next interrupt instructions.

Now when I look at Atmega or LPC2148 Datasheet it has interrupt vector address and I am assuming that it points to a address where instructions for interrupt handling instructions are written( not exactly on those addresses). Is my assumptions correct?

P.S Due to being on low bandwidth net, I am not able to provide links to Datasheet. Would do that when I get back.

Best Answer

The Interrupt Service Routine (ISR) is the program that's to be executed when an interrupt occurs.

Some CPU architectures have fixed addresses which the CPU will execute a subroutine call to. This is true of the MCS-51 (8051). The ISR must start at this address. It is not uncommon to just put a Jump instruction at this address that takes the CPU to the rest of the ISR elsewhere in memory.

Other CPU architectures use interrupt vectors. The vector is a memory location at which the address of the ISR can be found. The location of the vector is known to the CPU, either by being fixed or in conjunction with a special CPU/hardware register. When the CPU services the interrupt, it reads a vector value from memory and executes a subroutine call to the vector value. This is true of the ARM, 6502 and 68000 family. External hardware may have a hand in specifying the particular vector to use within a table of vectors but the principle still stands.

So the handling of interrupts in the 8051 CPU and in the ARM CPU seem different to you because they use fundamentally different schemes for finding the address of the ISR. But these two methods (hard-coded address versus vector in memory) are pretty-much the only schemes you'll come across in all the CPUs you'll see.

(There's the occassional oddity, like the Z80 in Interrupt Mode 0 where it expects to read an instruction from external hardware that'll take it to the ISR, but I wouldn't muddy your water with that stuff while you're getting the hang of it all.)