INTERRUPTS IN 8051
WHAT IS INTERRUPT?
The interrupts refer to a notification, communicated to the controller, by a hardware device or software, on receipt of which controller momentarily stops and responds to the interrupt.It is an Occurrence of a condition –an event –which interrupts the normal program flow
WHY NEED INTERRUPTS?
An application built around microcontrollers generally has the following structure. It takes input from devices like keypad, ADC etc; processes the input using certain algorithm; and generates an output which is either displayed using devices like seven segment, LCD or used further to operate other devices like motors etc. In such designs, controllers interact with the inbuilt devices like timers and other interfaced peripherals like sensors, serial port etc. The programmer needs to monitor their status regularly like whether the sensor is giving output, whether a signal has been received or transmitted, whether timer has finished counting, or if an interfaced device needs service from the controller, and so on. This state of continuous monitoring is known as polling. INTERRUPTS VS POLLING:
* the device notifies by sending an interrupt signal
* Priority is assigned if many interrupts are met
* Microcontroller can also ignore(mask) a request for service * Less time when compared to polling
* Microcontroller continuously monitors the status
* Priority cannot be assigned since it checks in round-robin fashion * Not possible
* Waste of time
* In polling, the microcontroller keeps checking the status of other devices; and while doing so it does no other operation and consumes all its processing time for monitoring. This problem can be addressed by using interrupts. In interrupt method, the controller responds to only when an interruption occurs. Thus in interrupt method, controller is not required to regularly monitor the status (flags, signals etc.) of interfaced and inbuilt devices. . To understand the difference better, consider the following. The polling method is very much similar to a salesperson. The salesman goes door-to-door requesting to buy its product or service. Like controller keeps monitoring the flags or signals one by one for all devices and caters to whichever needs its service. Interrupt, on the other hand, is very similar to a shopkeeper. Whosoever needs a service or product goes to him and apprises him of his/her needs. In our case, when the flags or signals are received, they notify the controller that they need its service. * Hardware and Software interrupt
* The interrupts in a controller can be either hardware or software. If the interrupts are generated by the controller’s inbuilt devices, like timer interrupts; or by the interfaced devices, they are called the hardware interrupts. If the interrupts are generated by a piece of code, they are termed as software interrupts. * Interrupt service routine
It is also called as Interrupt handler.A routine that deals with a specific interrupt.For every interrupt there is a fixed location in the memory that holds the address of ISR.Interrupt vector table-group of memory locations that holds the address of ISR for various interrupts
The 8051 controller has six hardware interrupts of which five are available to the programmer. These are as follows:
1. RESET interrupts - This is also known as Power on Reset (POR). When the RESET interrupt is received, the controller restarts executing code from 0000H location. This is an interrupt which is not available to or, better to say, need not be available to the programmer.
2. Timer interrupts - Each Timer is associated with a Timer interrupt. A timer interrupt notifies the microcontroller that the corresponding Timer has finished counting.
3. External interrupts - There are two external interrupts EX0 and EX1 to serve external devices. Both these interrupts are active low....
Please join StudyMode to read the full document