Tuesday, January 29, 2013

Know the System Interrupt Work in Microcontroller MCS-51

Robometricschool. - In this time we want to continue our lesson in section microcontroller, before we have discussed timer and counter in MCS-51, and now we want to continue discuss about system interrupt work in micro-controller MCS-51 family. 

Figure 1. Interrupt System Illustration



Before we continue tell about how interrupt system work, we must know about what is interruption that happen in microcontroller.

Interruption is condition where microcontroller stop while to do the main program and serve interruption program until this program finish to do and microcontroller do again main program. In Microcontroller with interrupts, the program flow can be stopped temporarily to run a subroutine, and then resume normal program flow like never no interruptions. This subroutine is called by the interrupt handler, and only run if there is a special event (event). This incident could be experiencing overflow timer, receiving character through serial port, send characters over the serial port, or one of the two external events.


There are six sources interruption in microcontroller MCS-51 like in AT89C51/52/55 and AT89S51/52/53. Six sources interruption like:

  1. Timer 0. This interruption came from timer 0 pin in microcontroller, it happen because overflow from timer 0.
  2. Timer 1. This interruption came from timer 1 pin in microcontroller, it happen because overflow from timer 1.
  3. serial data. This interruption came from serial data, it happen because received and transmitted in communication data serial.
  4. External 0. This interruption came from pin INT0 in microcontroller, it happen because is change condition in this pin.
  5. External 1. This interruption came from pin INT1 in microcontroller, it happen because is change condition in this pin.
  6. Timer 2 (specially in AT89S52). This interruption came from timer 2 pin in microcontroller specially in AT89S52, it happen because overflow from timer 2.

According source interruption in Microcontroller MCS-51, there are also any six interruption vector like in table 1, bellow:

Table 1. Interruption Vector in MCS-51
According table 1 above there are five Interrupt vector as follow: external interrupt INT0 is $ 0003, for the interrupt timer 0 is $ 000B, for external interrupt INT1 is $ 0013, for the first timer interrupt is $ 001B and to interrupt serial port is $ 0023. Specially for interrupt timer 2 in microcontroller AT89S52 is $002B.


According six source interruption in microcontroller MCS-51, we can set all interruption to active or not-active the interruption.  

When the beginning turned on (power on), all interrupts is disabled. Thus, although TF0 bit is set (timer 0 interrupt enabled), MCS-51 microcontroller will not execute the interrupt routine. A program should be developed and implemented to enable and specify where you want interruptions.

To set interrupt active or non-active, we can set configuration of register interrupt enable (IE register). To know arrange of IE register please see table 2 bellow:

Table 2. Interrupt Enable Register

To set IE register we must know more definition or function for all elements in IE register. To know all you can see table 3 that describe all function of these element in IE register like bellow:

Table 3. Function all elements in IE register

To activate a system interrupt, the interrupt control bit concerned that EA initiated and also set all interrupt sources. For example, the instructions used to activate external interrupt INT0 is SETB EA and then with SETB EX0 followed.


We can place the all source interruption to low and high priority to interrupt. Setting priorities tiers contents do with the bits in the IP register (Interrupt Priority). To know more IP register please see table 4 bellow:

Table 4. Interrupt Priority Register (IP Register)
And to know more function of these elements in Interrupt Priority register (IP register) please see table 5 bellow:

Table 5. Function of all elements in IP register
Note: 

The use of interrupt priority register (IP Register) above has some rules that are listed below:


  • No interruptions are to interrupt high priority interrupts.
  • High priority interrupts may interrupt a low priority interrupt.
  • Low priority interrupts may occur if no other interrupt is being executed.
  • If two interrupts occur at the same time, interrupt with a higher priority will be done first. If both have the same priority, then the interruption is on the order of the poll will be done first. 


References:

  1. Interrupt in 8051 family
  2. Tutorial interruption 


0 comments:

Post a Comment

Thank's for your visiting and reading this article, please share your idea with comment here