Interrupt Priorities

The 8051 offers two levels of interrupt priority: high and low. By using interrupt priorities it may assign higher priority to certain interrupt conditions.

For example, you may have enabled Timer 1 Interrupt which is automatically called every time Timer 1 overflows. Additionally, you may have enabled the Serial Interrupt which is called every time a character is received via the serial port. However, you may consider that receiving a character is much more important than the timer interrupt. In this case, if Timer 1 Interrupt is already executing then it may wish that the serial interrupt itself interrupts the Timer 1 Interrupt. When the serial interrupt is complete, control passes back to Timer 1 Interrupt and finally back to the main program. This may accomplish this by assigning a high priority to the Serial Interrupt and a low priority to the Timer 1 Interrupt.

When considering interrupt priorities, the following rules apply : -

1. Nothing can interrupt a high-priority interrupt--not even another high priority interrupt.
2. A high-priority interrupt may interrupt a low-priority interrupt.
3. A low-priority interrupt may only occur if no other interrupt is already executing.
4. If two interrupts occur at the same time, the interrupt with higher priority will execute first. If both interrupts are of the same priority the interrupt which is serviced first by polling sequence will be executed first.



Comments

Popular posts from this blog

General puprose registers in 8051.

TCON Special Function register.

TMOD Special Function Register.