Nothing Special   »   [go: up one dir, main page]

Interrupt - MCS51

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 18

INTERRUPT

Setyawan Ajie Sukarno


Introduction
 Interrupt is an event that cause main program
temporary stopped to execute the other program
(interrupt service routine)
 2 ways to make a hardware interface
 polling/scanning, and
 interrupt
Polling vs Interrupt
 Polling :
 CPU check the device frequently, waiting for
“service flag”
 CPU always busy for doing polling request
 Interrupt :
 The device will sent an interrupt signal when it
ready or need to interrupt CPU
 CPU always “free” when interrupt service is off
Interrupt in Fields
 Keyboard on Desktop PC and Notebook
 Emergency Button
 Thermal Sensor in Chiller Machine
 Load Sensor in Elevator
 Cancel Button in ATM
Events associated to interrupts

 External port lines


 Level and edge triggered
 Peripherals
 Serial I/O
 Asynchronous
 I2C, SPI
 Timers time-out
 A/D end of conversion
 Software instruction
Interrupt’s SFR
 Interrupt Enable (IE)

EA - ET2 ES ET1 EX1 ET0 EX0


Interrupt’s SFR
 Interrupt Priority (IP)

- - PT2 PS PT1 PX1 PT0 PX0


Types of Interrupt
 There are 3 types of interrupt in MCS-51 family :
 External Interrupt
 Timer Interrupt
 Serial Interrupt
External Interrupt
 There are 2 types of external interrupt in MCS-51
family :
 EXT0
 EXT1
External Interrupt
 External Interrupt 0 (EXT0)
 Pin 12 (P3.2)
 Active Low
 External Interrupt 1 (EXT1)
 Pin 13 (P3.3)
 Active Low
External Interrupt
 Initialization
 IE (Interrupt Enable)
 Pin 7 : EA (Enable All)
 Pin 0 : EX0 (Enable External Int 0)
 Pin 2 : EX1 (Enable Ext Int 1)

setb ea
setb exo
setb ex1
External Interrupt
 Initialization
 IP (Interrupt Priority)
 Pin 0 : PX0 (Priority on Ext Int 0)
 Pin 2 : PX1 (Priority on Ext Int 1)

setb px0
setb px1
External Interrupt
 Interrupt Vector
 When the interrupt signal detected, microcontroller
will stop the program that is running, and execute
the program in the interrupt vector
 Place (memory) where the Interrupt Service
Routine are stored
External Interrupt
 Interrupt Vector
 EXT0 03h
 EXT1 13h
 ET0 0bh
 ET1 1bh
 ES 23h

org 03h
……… // write your program here
reti
External Interrupt
 Interrupt Vector

org 03h
lcall isr_ext0
reti
...
org 100h
isr_ext0:
……… // write your program here
ret
External Interrupt

ANY QUESTION ???


Assignments #1
Make an interrupt programm, when:
1. Interrupt signal is not detected, the
microcontroller will execute an up-counter from
00-99 which will be displayed in 7 segments.
2. Interrupt signal detected, the microcontroller will
display “intd” in 7 segments.
Assignments #2
Make an interrupt programm, when:
1. Interrupt signal is not detected, the
microcontroller will execute an up-counter from
00-99 which will be displayed in LCD.
2. Interrupt signal detected, the microcontroller will
display “programm interrupted” in LCD screen.

You might also like