Interrupts in 8051
Microcontroller
Presented by: GAURAV BHAISARE
Scholar Number: 2311401162
What is an Interrupt?
Interrupt Concept Real-Time Use ISR Execution
An interrupt temporarily halts Enables immediate responses After ISR, program resumes from
normal execution for special without polling, e.g., button press where it paused.
processing. detection.
8051 Interrupt System Overview
Interrupt Sources More Interrupts
INT0 (External Interrupt 0) - P3.2 Timer 1 Overflow
Timer 0 Overflow Serial Communication (RI/TI)
INT1 (External Interrupt 1) - P3.3 Fixed vector addresses and priorities
IE Register 3 Enabling Interrupts
Master Control (EA) Individual Bits Example Setting
Bit 7 enables or disables all interrupts Bits enable serial, timer, and external MOV IE, #10000011B enables serial,
globally. interrupts selectively. INT0, and global interrupt.
IP Register 3 Interrupt Priority
Priority Bits More Priority Bits Priority Rules
PS: Serial Port Interrupt PT0: Timer 0 Interrupt High priority interrupts preempt low
PT1: Timer 1 Interrupt PX0: External Interrupt 0 priority ISRs.
PX1: External Interrupt 1
Interrupt Vector Table
Interrupt Vector Address (Hex)
Reset 0000H
INT0 0003H
Timer0 Overflow 000BH
INT1 0013H
Timer1 Overflow 001BH
Serial 0023H
Example 3 External Interrupt (INT0)
Toggle LED on interrupt using INT0 (P3.2)
ORG 0000H
AJMP MAIN
ORG 0003H ; INT0 vector
CLR P1.0 ; Turn off LED
RET
MAIN: MOV IE, #10000001B ; Enable INT0 and EA
SETB P1.0 ; LED ON initially
HERE: SJMP HERE ; Infinite loop
Explanation:
When INT0 pin goes LOW (edge-triggered), ISR at 0003H is executed.
LED is turned OFF.
Program returns to main loop.
Assembly Example 3 INT0 LED Control
Set Vector
1
ORG 0003H; ISR jumps here on INT0
Turn Off LED
2
CLR P1.0; LED off on interrupt
Enable Interrupt
3
MOV IE, #10000001B; Enable INT0 & global
Main Loop
4 Loop infinitely while ISR handles button press
Edge vs. Level Triggering (TCON Register)
Level Triggered Edge Triggered TCON Bits
Interrupt active as long as input stays Interrupt occurs only on falling edge IT0 controls INT0 trigger mode
LOW. transition. IT1 controls INT1 trigger mode
MOV TCON, #05H sets INT0 edge-
triggered.
Applications of Interrupts in 8051
Timer Interrupts Serial Interrupts External Interrupts Power Saving
Used for precise timing and Manage UART communication Detect switches, sensors, and Wake microcontroller from low
pulse generation. efficiently. alarms. power modes.
THANKYOU
DATE : 25 / 04 / 2025