Tutorial Microcontroller MCS-51 ATMEL ISP

Microcontroller Kits
Programmer and Target 89s51

Simple Mikrokontroller 89s51 Trainer


Standart
Mikrokontroller 89s51 Trainer


Super Mikrokontroller Trainer 89s51

+

All Item Include

Programmer
Via USB

 

 

NEXT

5.1. Interrupt

 

The 80C51 provides 5 interrupt sources. These are shown in Figure 17. The External Interrupts INT0 and INT1 can each be either level-activated or transition-activated, depending on bits IT0 and IT1 in Register TCON. The flags that actually generate these interrupts are bits IE0 and IE1 in TCON. When an external interrupt is generated, the flag that generated it is cleared by the hardware when the service routine is vectored to only if the interrupt was transition-activated. If the interrupt was level-activated, then the external requesting source is what controls the request flag, rather than the on-chip hardware.

The Timer 0 and Timer 1 Interrupts are generated by TF0 and TF1, which are set by a rollover in their respective Timer/Counter registers (except see Timer 0 in Mode 3). When a timer interrupt is generated, the flag that generated it is cleared by the on-chip hardware when the service routine is vectored to.

The Serial Port Interrupt is generated by the logical OR of RI and TI. Neither of these flags is cleared by hardware when the service routine is vectored to. In fact, the service routine will normally have to determine whether it was RI or TI that generated the interrupt, and the bit will have to be cleared in software.

All of the bits that generate interrupts can be set or cleared by software, with the same result as though it had been set or cleared by hardware. That is, interrupts can be generated or pending interrupts can be canceled in software.

Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in Special Function Register IE (Figure 18). IE also contains a global disable bit, EA, which disables all interrupts at once.

Priority Level Structure
Each interrupt source can also be individually programmed to one of two priority levels by setting or clearing a bit in Special Function

Register IP (Figure 19). A low-priority interrupt can itself be interrupted by a high-priority interrupt, but not by another low-priority interrupt. A high-priority interrupt can’t be interrupted by any other interrupt source.

If two request of different priority levels are received simultaneously, the request of higher priority level is serviced. If requests of the same priority level are received simultaneously, an internal polling sequence determines which request is serviced. Thus within each priority level there is a second priority structure determined by the polling sequence as follows:

Source Priority Within Level
1. IE0 (highest)
2. TF0
3. IE1
4. TF1
5. RI+TI (lowest)

Note that the “priority within level” structure is only used to resolve simultaneous requests of the same priority level. The IP register contains a number of unimplemented bits. IP.7, IP.6, and IP.5 are reserved in the 80C51. User software should not write 1s to these positions, since they may be used in other 8051 Family products.



Interrupt Enable Registe ( IE )

MSB
LSB
EA
X
X
ES
ET1
EX1
ET0
EX0

BIT
SYMBOL
FUNCTION
IE.7 EA
Disables all interrupts. If EA=0, no interrupt will be acknowledged. If EA=1, each interrupt source is individually enabled or disabled by setting or clearing its enable bit.
IE.6 - -
IE.5 - -
IE.4 ES
Enables or disables the Serial Port interrupt. If ES=0, the Serial Port interrupt is disabled.
IE.3 ET1
Enables or disables the Timer 1 Overflow interrupt. If ET1=0, the Timer 1 interrupt is disabled.
IE.2 EX1
Enables or disables External Interrupt 1. If EX1=0, External interrupt 1 is disabled.
IE.1 ET0
Enables or disables the Timer 0 Overflow interrupt. If ET0=0, the Timer 0 interrupt is disabled.
IE.0 EX0
Enables or disables External interrupt 0. If EX0=0, External interrupt 0 is disabled.

Interrupt Priority Register ( IP )

MSB   LSB
X
X
X
PS
PT1
PX1
PT0
PX0

Note:
BIT
SYMBOL
FUNCTION
IP.7
-
-
IP.6
-
-
IP.5
-
-
IP.4
PS
Defines the Serial Port interrupt priority level. PS=1 programs it to the higher priority level.
IP.3
PT1
Defines the Timer 1 interrupt priority level. PT1=1 programs it to the higher priority level.
IP.2
PX1
Defines the External Interrupt 1 priority level. PX1=1 programs it to the higher priority level.
IP.1
PT0
Enables or disables the Timer 0 interrupt priority level. PT0=1 programs it to the higher priority level.
IP.0
PX0
Defines the External Interrupt 0 priority level. PX0=1 programs it to the higher priority level.

 

Source
Vector Address
IE0
0003H
TF0
000BH
IE1
0013H
TF1
001BH
RI + TI
0023H

Comments, questions and discussion about this topic

NEXT