8051 Interrupts
An interrupt is an external or internal event that interrupts the microcontroller to inform it that
adeviceneedsits service
A single microcontroller can serve several devices by two ways:
• Interrupt
• Polling
1. Interrupts
Whenever any device needs its service, the device notifies the microcontroller by sending
an interrupt signal.
Upon receiving an interrupt signal, the microcontroller interrupts whatever it is
doing and serves the device.
The program which is associated with the interrupt is called the interrupt service routine
(ISR) or interrupt handler.
2. Polling
The microcontroller continuously monitors the status of a given device.
When the conditions met, it performs the service.
After that, it moves onto monitor the next device until everyone is serviced.
The polling method is not efficient, since it wastes much of the microcontroller’s time by polling
devices that do not need service. The advantage of interrupts is that the microcontroller can serve
many devices (not all at the same time).
Each device can get the attention of the microcontroller based on the assigned priority. For the
polling method, it is not possible to assign priority since it checks all devices in a round-robin
fashion. The microcontroller can also ignore (mask) a device request for service in Interrupt.
SixInterruptsin 8051
Sixinterruptsareallocatedasfollows:
1. Reset–power-upreset.
2. Two interrupts are set aside for the timers.
– One for timer 0 and one for timer 1
3. Two interrupts are set aside for hardware externalinterrupts.
– P3.2 and P3.3 are for the external hardware interrupts. INT0 (orEX1), and
INT1 (orEX2).
4. Serial communication has a single interrupt belongs to both receive and transfer.
5. We can configure the 8051 so that any of the following events will cause an interrupt:
a. Timer 0 Overflow.
b. Timer 1 Overflow.
c. Reception/Transmission of Serial Character.
d. External Event 0.
e. External Event 1.
8051 Interrupt related Registers
• The various registers associated with the use of interrupts are:
• TCON-Edge and Type bits for External Interrupts 0/1
• SCON-RI and TI interrupt flags for RS232
• IE- Enable interrupt sources
• IP - Specify priority of interrupts Enabling and Disabling an Interrupt
InterruptPriority
• When the 8051 is powered up, the priorities are assigned according to the following.
• In reality, the priority scheme is nothing but an internal polling sequence in which the 8051
polls the interrupts in the sequence listed and responds accordingly.
• We can alter the sequence of interrupt priority by assigning a higher priority to anyone
of the interrupts by programming a register called IP (interrupt priority).
• To give a higher priority to any of the interrupts, we make the corresponding bit in the IP
register high.