Search code examples
microcontrollerinterrupt-handlingisr

How is ISR a callback function


The wikipedia entry states:

In computer system programming, an interrupt handler, also known as an interrupt service routine or ISR, is a callback function in microcontroller firmware, an operating system or a device driver, whose execution is triggered by the reception of an interrupt.

How is ISR a callback. Is it the PC value stored on stack itself is the callback function?

I.e., the ISR calls the interrupted function back. Hence the interrupted function is a callback.


Solution

  • A bit of setup code stores the address of the ISR function in the interrupt vector table to say "call me back at this address when the interrupt occurs".

    To be clear, the ISR itself is the function that is "called back". The interrupted code is not the callback; it is merely "interrupted" and later "resumed".