- 8051

8051 Interrupts: Basics | Types | Programs |Timer interrupts | AT89C51

8051 Interrupts

An Interrupt is an external or internal event that halts or interrupts Microcontroller to inform it that a device needs its service.
  


1. Basics :
        A microcontroller is able to give service to many Input and Output devices connected to it. It is able to do it in two ways Interrupts and Polling

1.1 Polling: 
            In this method, the microcontroller will be continuously monitoring the status of a device, until some pre-determined condition is met, and then serves the device.In this method, multitasking is not possible.For example:


Fig 1 Polling Example 

In above example until the TF0 flag is set.The microcontroller checks the status and will not serve any other service.It’s not feasible.


1.2 Interrupts:
            In this method whenever a device needs the service, the device requests the microcontroller by sending it an interrupt signal.Upon reception of the interrupt signal, the microcontroller halts whatever it is doing and serves the device.

1.2.1 Interrupt Service Routine: The program related to interrupt is called Interrupt Service Routine(ISR) or Interrupt Handler.

1.2.2 Interrupt Vector Table: For every interrupt there is a fixed memory location that holds the address of its ISR. The group of memory locations set aside to hold the addresses of ISR’s is called the Interrupt Vector Table(IVT).


Fig 2 Interrupts with their Rom location


2.Steps taken when Interrupt occurs:
         
           When an interrupt occurs, the Microcontroller follows these steps:


Fig 3 Steps followed when an Interrupt occurs



  • 8051 Microcontroller finishes the instruction it is currently executing, and saves the contents of Program Counter(PC) on the stack (address of next instruction).
  •  It jumps to the interrupt vector location corresponding to the interrupt source.
  • Executes the interrupt service routine, until it encounters RETI instruction.
  • Returns back to the place where it was interrupted by popping the contents of stack on PC, and starts execution at that address.  



More concepts in posts. Stay tuned…..!         

Leave a Reply