What happens when an interrupt occurs?

When an interrupt is triggered, the following actions are taken automatically by the microcontroller :-

1.  The current Program Counter is saved on the stack, low-byte first.
2.  Interrupts of the same and lower priority are blocked.
3.  In the case of Timer and External interrupts, the corresponding interrupt flag is cleared.
4.  Program execution transfers to the corresponding interrupt handler vector address.
5.  The Interrupt Handler Routine executes.

Take special note of the third step: If the interrupt being handled is a Timer or External interrupt, the microcontroller automatically clears the interrupt flag before passing control to interrupt handler routine. This means it is not necessary that bit is cleared in the code.

Comments

Popular posts from this blog

General puprose registers in 8051.

TCON Special Function register.

TMOD Special Function Register.