Академический Документы
Профессиональный Документы
Культура Документы
Introduction 8051 Interrupt organization Processing Interrupts Program Design Using Interrupts Interrupt Timings
An interrupt is the occurrence of a condition--an event -- that cause a temporary suspension of a program while the event is serviced by another program (Interrupt Service Routine ISR or Interrupt Handler). Interrupt-Driven System-- gives the illusion of doing many things simultaneously, quick response to events, suitable for real-time control application.
Program
Interrupt
Program
Interrupt
Program
time t
fahr= (cent *
9 ) +32 5
Interrupt
Program
mov R1, cent mul R1, 9 div R1, 5 add R1, 32 mov fahr, R1
time t
Interrupt
Program
mov R1, cent
Program
mul R1, 9
time t
Interrupt
Program
mov R1, cent
time t
Interrupt
Program
mov R1, cent
Restore Context
eg pop R1
mul R1, 9
time t
Interrupt arrives Complete current instruction Save essential register information Vector to ISR Save additional register information Execute body of ISR
Restore other register information Return from interrupt and restore essential registers
Interrupt Latency
Interrupt Termination
Resume task
11
Interrupt Latency
12
` ` ` `
5 interrupt sources: 2 external, 2 timer, a serial port 2 programmable interrupt priority levels fixed interrupt polling sequence can be enabled or disabled IE (A8H), IP (B8H) for controlling interrupts
` ` ` ` ` ` ` ` `
Symbol Bit Address EA AFH AEH ET2 ADH ES ACH ET1 ABH EX1 AAH ET0 A9H EX0 A8H
Description (1=enable, 0=disable) Global enable/disable Undefined Enable timer 2 interrupt (8052) Enable serial port interrupt Enable timer 1 interrupt Enable external 1 interrupt Enable timer 0 interrupt Enable external 0 interrupt
Two bits must be set to enable any interrupt: the individual enable bit and global enable bit SETB ET1 SETB EA MOV IE,#10001000B
` ` ` ` ` ` ` ` `
Symbol Bit Address PT2 BDH PS BCH PT1 BBH PX1 BAH PT0 B9H PX0 B8H
Description (1=high, 0=low priority) Undefined Undefined Priority for timer 2 interrupt (8052) Priority for serial port interrupt Priority for timer 1 interrupt Priority for external 1 interrupt Priority for timer 0 interrupt Priority for external 0 interrupt
0= lower priority, 1= higher priority, reset IP=00H Lower priority ISR can be interrupted by a high priority interrupt. A high priority ISR can not be interrupted.
Interrupt Flag SFR Register & Bit Position -----------------------------------------------------------------------------External 0 IE0 TCON.1 External 1 IE1 TCON.3 Timer 1 TF1 TCON.7 Timer 0 TF0 TCON.5 Serial port TI SCON.1 Serial Port RI SCON.0 Timer 2 TF2 T2CON.7 (8052) Timer 2 EXF2 T2CON.6 (8052)
The state of all interrupt sources is available through the respective flag bits in the SFRs. If any interrupt is disabled, an interrupt does not occur, but software can still test the interrupt flag.
If two interrupts of the same priority occur simultaneously, a fixed polling sequence determines which is serviced first. The polling sequence is External 0 > Timer 0 >
External 1 > Timer 1 > Serial Port > Timer 2
Level- or edge-triggered
Level-triggered threshold
trigger point
t
Edge-triggered
` `
Interrupt vector = the address of the start of the ISR. When vectoring to an interrupt, the flag causing the interrupt is automatically cleared by hardware. The exception is RI/TI and TF2/EXF2 which should be determined and cleared by software.
Flag RST IE0 TF0 IE1 TF1 RI or TI TF2 or EXF2 Vector Address 0000H (LJMP 0030H) 0003H 000BH 0013H 001BH 0023H 002BH
Interrupt System Reset External 0 Timer 0 External 1 Timer 1 Serial Port Timer 2
MAIN: T0ISR:
`
MOV PUSH PUSH MOV POP MOVX INC POP MOVX SJMP RETI DPTR,#T2_ISR DPL DPH DPTR,#0FFF5H A @DPTR,A DPTR A @DPTR,A BACK
BACK: T2_ISR:
I request Electronics and communication ENGINEERING students to visit my blog for more abhishek1ek.blogspot.com awhengineering.blogspot.com
` `