SlideShare a Scribd company logo
Interrupts in 8051
Sudhanshu Janwadkar
5th-16th April 2018
Introduction
• A single microcontroller can serve several devices by two ways
 Interrupts
 Polling
• In Interrupts, Whenever any device needs its service, the device
notifies the microcontroller by sending it an interrupt signal
• Upon receiving an interrupt signal, the microcontroller interrupts
whatever it is doing and serves the device
• In Polling, The microcontroller continuously monitors the status of
all devices in Round-robin manner.
• When the conditions are for a given device are met, it performs the
service.
• After that, it moves on to monitor the next device until every one is
serviced
What is an Interrupt?
• An interrupt is an external or internal event that interrupts
the microcontroller to inform it that a device needs its service
• The program which is associated with the interrupt is called
the Interrupt Service Routine (ISR) or interrupt handler
Polling Vs Interrupts
Polling Interrupt
In Polling, The microcontroller
continuously monitors the status of all
devices in Round-robin manner.
When the conditions are for a given
device are met, it performs the service.
After that, it moves on to monitor the
next device until every one is serviced
In Interrupts, Whenever any device needs
its service, the device notifies the
microcontroller by sending it an interrupt
signal
Upon receiving an interrupt signal, the
microcontroller interrupts whatever it is
doing and serves the device
The polling method is not efficient, since
it wastes much of the microcontroller’s
time by polling devices that do not need
service
Interrupts serve only those devices which
need service and hence are efficient
It is not possible to assign priority since it
checks all devices ina round-robin fashion
Each devices can get the attention of the
microcontroller based on the assigned
priority
Ignoring a device request is not possible microcontroller can also ignore
(mask) a device request for service
Vectored vs Non Vectored Interrupts
Vectored Interrupts
• Devices that use vectored interrupts are assigned an interrupt
vector. This is a number that identifies a particular interrupt
handler. The ISR address of this interrupt is fixed and is known to
CPU.
• When the device interrupts, the CPU branches to the particular ISR.
• All 8051 interrupts are vectored interrupts
Non Vectored Interrupts
• Non Vectored Interrupt is an interrupt who has a common ISR,
which is common to all non-vectored interrupts in the system. The
address of this common ISR is known to the CPU.
• However, The CPU crucially does not know which device caused the
interrupt without polling each I/O interface in a loop.
• Once the interrupt occurs, the system must determine which
device, of all the devices associated actually interrupted.
Maskable vs Non-Maskable Interrupts
Maskable Interrupts
• A maskable interrupt is one that programmaer can ignore
by setting (or clearing) a bit in an interrupt control register.
• Typically, the microcontroller might allow multiple interrupt
sources, but application requires only few of them. The
programmer can mask off the unused interrupts
Non Maskable Interrupts
• Non-maskable interrupts are those interrupts which do not
get gated by the interrupt control register -- they ALWAYS
interrupt, no matter what state the microcontroller is in.
• Typically these are used for CRITICIAL or FATAL conditions,
or for system reset functions.
Interrupt Service Routine
• For every interrupt, there must be an interrupt service routine
(ISR), or interrupt handler
• When an interrupt is invoked, the microcontroller runs the
interrupt service routine
• For every interrupt, there is a fixed location in memory that
holds the address of its ISR
• The group of memory locations set aside to hold the
addresses of ISRs is called interrupt vector table
Steps in executing an interrupt
Upon activation of an interrupt, the microcontroller goes
through the following steps
1. It finishes the instruction it is executing and saves the
address of the next instruction (PC) on the stack
2. It also saves the current status of all the interrupts internally
(i.e: not on the stack)
3. It jumps to a fixed location in memory, called the interrupt
vector table, that holds the address of the ISR
Steps in executing an interrupt
4. The microcontroller gets the address of the ISR from the
interrupt vector table and jumps to it
 It starts to execute the interrupt service subroutine
until it reaches the last instruction of the subroutine
which is RETI (return from interrupt)
5. Upon executing the RETI instruction, the microcontroller
returns to the place where it was interrupted
 First, it gets the program counter (PC) address from
the stack by popping the top two bytes of the stack
into the PC
 Then it starts to execute from that address
Interrupts in 8051
There are SIX interrupts in 8051
• Reset – power-up reset
• Two interrupts are set aside for the timers:
 one for timer 0 and one for timer 1
• Two interrupts are set aside for hardware external interrupts
 P3.2 and P3.3 are for the external hardware interrupts
INT0 (or EX1), and INT1 (or EX2)
• Serial communication has a single interrupt that belongs to
both receive and transfer
Interrupt Vector Table of 8051
Enabling and Disabling of Interrupts
• Upon reset, all interrupts are disabled (masked),
meaning that none will be responded to by the
microcontroller, even if they are activated
• The interrupts must be enabled by software in
order for the microcontroller to respond to them
• There is a register called IE (interrupt enable) that
is responsible for enabling (unmasking) and
disabling (masking) the interrupts
IE Register (Interrupt Enable Register)
• Bit D7 of the IE register (EA) must be set to high to allow
the rest of register to take effect
• The value of EA
 If EA = 1, interrupts are enabled and will be responded
to if their corresponding bits in IE are high
 If EA = 0, no interrupt will be responded to, even if the
associated bit in the IE register is high
Timer Interrupt
• The timer flag (TF) is raised when the timer rolls over
• In polling TF, we have to wait until the TF is raised
• The problem with this method is that the microcontroller is
tied down while waiting for TF to be raised, and can not do
anything else
• If the timer interrupt in the IE register is enabled, whenever
the timer rolls over, TF is raised, and the microcontroller is
interrupted in whatever it is doing, and jumps to the
interrupt vector table to service the ISR.
• Hence, using interrupts, the problem of tying down the
microcontroller is solved.
• In this way, the microcontroller can do other tasks until it is
notified that the timer has rolled over
External Interrupts in 8051
• The 8051 has two external hardware interrupts
• Pin 12 (P3.2) and pin 13 (P3.3) of the 8051, designated as INT0
and INT1, are used as external hardware interrupts
• The interrupt vector table locations 0003H and 0013H are set
aside for INT0 and INT1
• There are two activation levels for the external hardware
interrupts
Level trigged
Edge trigged
External Interrupts in 8051
Level Triggered Interrupts
• In the level-triggered mode, INT0 and INT1 pins are
normally high
• If a low-level signal is applied to them, it triggers the
interrupt. Then the microcontroller stops whatever it is
doing and jumps to the interrupt vector table to service
that interrupt
• The low-level signal at the INT pin must be removed
before the execution of the last instruction of the ISR,
RETI; otherwise, another interrupt will be generated
• This is called a level-triggered interrupt and is the
default mode upon reset of the 8051
Level Triggered Interrupts
According to one manufacturer’s data sheet,
• The pin must be held in a low state until the start of the execution of ISR
 If the INTx pin is brought back to a logic high before the start of the
execution of ISR there will be no interrupt
 If INTx pin is left at a logic low after the RETI instruction of the ISR,
another interrupt will be activated after one instruction is executed
• To ensure the activation of the hardware interrupt at the INTx pin, make
sure that the duration of the low-level signal is around 4 machine cycles,
but no more
Edge Triggered Interrupts
• To make INT0 and INT1 edge-triggered interrupts, we must
program the bits of the TCON register
• The TCON register holds the IT0 and IT1 flag bits, that
determine level- or edge-triggered mode of the hardware
interrupt
• IT0 and IT1 are also referred to as TCON.0 and TCON.2 since
the TCON register is bit addressable
Edge Triggered Interrupts
Edge Triggered Interrupts
Edge Triggered Interrupts
• In edge-triggered interrupts, the external source must be held
high for at least one machine cycle, and then held low for at
least one machine cycle
• The falling edge of pins INT0 and INT1 are latched by the 8051
and are held by the TCON.1 and TCON.3 bits of TCON register
• It indicates that the interrupt is being serviced now and on
this INTx pin, and no new interrupt will be responded to until
this service is finished
Edge Triggered Interrupts
Please note that
• When the ISRs are finished (that is, upon execution of RETI),
these bits (TCON.1 and TCON.3) are cleared, indicating that
the interrupt is finished and the 8051 is ready to respond to
another interrupt on that pin
• During the time that the interrupt service routine is being
executed, the INTn pin is ignored, no matter how many times
it makes a high-to-low transition
 RETI clears the corresponding bit in TCON register (TCON.1
or TCON.3)
 There is no need for instruction CLR TCON.1 before RETI in
the ISR associated with INT0
Interrupts in 8051
Serial Interrupts in 8051
• TI (transfer interrupt) is raised when the last bit of the framed
data, the stop bit, is transferred, indicating that the SBUF
register is ready to transfer the next byte
• RI (received interrupt) is raised when the entire frame of data,
including the stop bit, is received
Serial Interrupts in 8051
• In the 8051 there is only one interrupt set aside for serial
communication
 This interrupt is used to both send and receive data
 If the interrupt bit in the IE register (IE.4)is enabled, when
RI or TI is raised the 8051 gets interrupted and jumps to
memory location 0023H to execute the ISR
 In that ISR we must examine the TI and RI flags to see
which one caused the interrupt and respond accordingly
Interrupt Priority
• When the 8051 is powered up, the priorities are assigned
according to the following
Priority of Interrupts
• We can alter the sequence of interrupt priority by assigning a
higher priority to any one of the interrupts by programming a
register called IP (interrupt priority)
• To give a higher priority to any of the interrupts, we make the
corresponding bit in the IP register high
• When two or more interrupt bits in the IP register are set to high,
they are serviced according to the default priority
 All the interrupts are latched and kept internally and till the
interrupt is being serviced, all other interrupts would be ignored.
 Upon RETI, No low-priority interrupt can get the immediate
attention of the CPU until the 8051 has finished servicing the
high-priority interrupts
IP Register
Support for Interrupts in Embedded C
• The 8051 compiler have extensive support for the interrupts
• They assign a unique number to each of the 8051 interrupts

More Related Content

PPT
Interrupt programming with 8051 microcontroller
PDF
8051 interfacing
PDF
Basic Electronics for diploma students as per technical education Kerala Syll...
PPTX
Microprocessor 8085 complete
PDF
RTOS for Embedded System Design
PPTX
Architecture of 8051
PPTX
How to Cancel your Subscription
PPTX
Air pollution final.ppt
Interrupt programming with 8051 microcontroller
8051 interfacing
Basic Electronics for diploma students as per technical education Kerala Syll...
Microprocessor 8085 complete
RTOS for Embedded System Design
Architecture of 8051
How to Cancel your Subscription
Air pollution final.ppt

What's hot (20)

PPTX
8051 timer counter
PPT
Memory organization of 8051
PPT
8051 ch9-950217
PPT
Architecture of 8086 Microprocessor
PPTX
Interfacing Stepper motor with 8051
PPTX
8051 Microcontroller ppt
PPT
Memory & I/O interfacing
PDF
Seven segment interfacing with 8051.pdf
PPTX
8051 Microcontroller PPT's By Er. Swapnil Kaware
PPTX
Architecture of 8085 microprocessor
PPTX
8257 DMA Controller
PPT
8051 instruction set
PPTX
R-2R Ladder DAC
PDF
8051 assembly programming
PPTX
Interrupts on 8086 microprocessor by vijay kumar.k
PPT
8051 Presentation
PDF
Keypad Interfacing with 8051 Microcontroller
PPTX
Timer counter in arm7(lpc2148)
PPTX
8255 PPI
PPTX
Serial Communication in 8051
8051 timer counter
Memory organization of 8051
8051 ch9-950217
Architecture of 8086 Microprocessor
Interfacing Stepper motor with 8051
8051 Microcontroller ppt
Memory & I/O interfacing
Seven segment interfacing with 8051.pdf
8051 Microcontroller PPT's By Er. Swapnil Kaware
Architecture of 8085 microprocessor
8257 DMA Controller
8051 instruction set
R-2R Ladder DAC
8051 assembly programming
Interrupts on 8086 microprocessor by vijay kumar.k
8051 Presentation
Keypad Interfacing with 8051 Microcontroller
Timer counter in arm7(lpc2148)
8255 PPI
Serial Communication in 8051
Ad

Similar to Interrupts in 8051 (20)

PPTX
Interrupts of 8051 microcontroller.newpp
PPTX
Embedded systems, lesson 16
PPTX
Interrupt in 8051
PPTX
Mc module5 ppt_msj
PPTX
Micro controller 8051 Interrupts
PPTX
Interrupt in 8051 microcontrollers .pptx
PPTX
hardware interrupts in 8051 microcontroller
PPTX
Interrupt programming
PPTX
Interrupt in ATMEGA328P.pptx
PPTX
Interrupts programming in embedded C using 8051
PPT
PPTX
Unit 3 timer and counter and there application .pptx
PPT
Interrupts for PIC18
PPTX
unit 3 a.pptxppppppppppppppppppppppppppp
PPTX
Interrupt 8085
PDF
Unit 5_interrupt programming_Part 1
PPTX
3.12_8086 microprocessor Interrupts.pptx
PPT
Interrupt
PDF
8085 interrupts
PDF
8085 interrupts
Interrupts of 8051 microcontroller.newpp
Embedded systems, lesson 16
Interrupt in 8051
Mc module5 ppt_msj
Micro controller 8051 Interrupts
Interrupt in 8051 microcontrollers .pptx
hardware interrupts in 8051 microcontroller
Interrupt programming
Interrupt in ATMEGA328P.pptx
Interrupts programming in embedded C using 8051
Unit 3 timer and counter and there application .pptx
Interrupts for PIC18
unit 3 a.pptxppppppppppppppppppppppppppp
Interrupt 8085
Unit 5_interrupt programming_Part 1
3.12_8086 microprocessor Interrupts.pptx
Interrupt
8085 interrupts
8085 interrupts
Ad

More from Sudhanshu Janwadkar (20)

PPTX
Presentation on Elementary Data Link Protocols
PPTX
Error Correcting and Error Detecting Codes.pptx
PPTX
DSP Processors versus ASICs
PPT
ASIC design Flow (Digital Design)
PPTX
Fpga architectures and applications
PPTX
LCD Interacing with 8051
PPT
SPI Bus Protocol
PPTX
I2C Protocol
PPTX
Introduction to 8051 Timer/Counter
PPTX
Intel 8051 Programming in C
PPTX
Hardware View of Intel 8051
PPTX
Architecture of the Intel 8051 Microcontroller
PPTX
Introduction to Embedded Systems
PPTX
PPTX
Interconnects in Reconfigurable Architectures
PPTX
Introduction to FPGAs
PDF
Design and Implementation of a GPS based Personal Tracking System
PDF
Embedded Logic Flip-Flops: A Conceptual Review
PPTX
Pass Transistor Logic
PPTX
Memory and Processor Testing
Presentation on Elementary Data Link Protocols
Error Correcting and Error Detecting Codes.pptx
DSP Processors versus ASICs
ASIC design Flow (Digital Design)
Fpga architectures and applications
LCD Interacing with 8051
SPI Bus Protocol
I2C Protocol
Introduction to 8051 Timer/Counter
Intel 8051 Programming in C
Hardware View of Intel 8051
Architecture of the Intel 8051 Microcontroller
Introduction to Embedded Systems
Interconnects in Reconfigurable Architectures
Introduction to FPGAs
Design and Implementation of a GPS based Personal Tracking System
Embedded Logic Flip-Flops: A Conceptual Review
Pass Transistor Logic
Memory and Processor Testing

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Structure & Organelles in detailed.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
master seminar digital applications in india
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Institutional Correction lecture only . . .
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Pharma ospi slides which help in ospi learning
Cell Structure & Organelles in detailed.
2.FourierTransform-ShortQuestionswithAnswers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Insiders guide to clinical Medicine.pdf
TR - Agricultural Crops Production NC III.pdf
Final Presentation General Medicine 03-08-2024.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Basic Mud Logging Guide for educational purpose
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
master seminar digital applications in india
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Institutional Correction lecture only . . .
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx

Interrupts in 8051

  • 1. Interrupts in 8051 Sudhanshu Janwadkar 5th-16th April 2018
  • 2. Introduction • A single microcontroller can serve several devices by two ways  Interrupts  Polling • In Interrupts, Whenever any device needs its service, the device notifies the microcontroller by sending it an interrupt signal • Upon receiving an interrupt signal, the microcontroller interrupts whatever it is doing and serves the device • In Polling, The microcontroller continuously monitors the status of all devices in Round-robin manner. • When the conditions are for a given device are met, it performs the service. • After that, it moves on to monitor the next device until every one is serviced
  • 3. What is an Interrupt? • An interrupt is an external or internal event that interrupts the microcontroller to inform it that a device needs its service • The program which is associated with the interrupt is called the Interrupt Service Routine (ISR) or interrupt handler
  • 4. Polling Vs Interrupts Polling Interrupt In Polling, The microcontroller continuously monitors the status of all devices in Round-robin manner. When the conditions are for a given device are met, it performs the service. After that, it moves on to monitor the next device until every one is serviced In Interrupts, Whenever any device needs its service, the device notifies the microcontroller by sending it an interrupt signal Upon receiving an interrupt signal, the microcontroller interrupts whatever it is doing and serves the device The polling method is not efficient, since it wastes much of the microcontroller’s time by polling devices that do not need service Interrupts serve only those devices which need service and hence are efficient It is not possible to assign priority since it checks all devices ina round-robin fashion Each devices can get the attention of the microcontroller based on the assigned priority Ignoring a device request is not possible microcontroller can also ignore (mask) a device request for service
  • 5. Vectored vs Non Vectored Interrupts Vectored Interrupts • Devices that use vectored interrupts are assigned an interrupt vector. This is a number that identifies a particular interrupt handler. The ISR address of this interrupt is fixed and is known to CPU. • When the device interrupts, the CPU branches to the particular ISR. • All 8051 interrupts are vectored interrupts Non Vectored Interrupts • Non Vectored Interrupt is an interrupt who has a common ISR, which is common to all non-vectored interrupts in the system. The address of this common ISR is known to the CPU. • However, The CPU crucially does not know which device caused the interrupt without polling each I/O interface in a loop. • Once the interrupt occurs, the system must determine which device, of all the devices associated actually interrupted.
  • 6. Maskable vs Non-Maskable Interrupts Maskable Interrupts • A maskable interrupt is one that programmaer can ignore by setting (or clearing) a bit in an interrupt control register. • Typically, the microcontroller might allow multiple interrupt sources, but application requires only few of them. The programmer can mask off the unused interrupts Non Maskable Interrupts • Non-maskable interrupts are those interrupts which do not get gated by the interrupt control register -- they ALWAYS interrupt, no matter what state the microcontroller is in. • Typically these are used for CRITICIAL or FATAL conditions, or for system reset functions.
  • 7. Interrupt Service Routine • For every interrupt, there must be an interrupt service routine (ISR), or interrupt handler • When an interrupt is invoked, the microcontroller runs the interrupt service routine • For every interrupt, there is a fixed location in memory that holds the address of its ISR • The group of memory locations set aside to hold the addresses of ISRs is called interrupt vector table
  • 8. Steps in executing an interrupt Upon activation of an interrupt, the microcontroller goes through the following steps 1. It finishes the instruction it is executing and saves the address of the next instruction (PC) on the stack 2. It also saves the current status of all the interrupts internally (i.e: not on the stack) 3. It jumps to a fixed location in memory, called the interrupt vector table, that holds the address of the ISR
  • 9. Steps in executing an interrupt 4. The microcontroller gets the address of the ISR from the interrupt vector table and jumps to it  It starts to execute the interrupt service subroutine until it reaches the last instruction of the subroutine which is RETI (return from interrupt) 5. Upon executing the RETI instruction, the microcontroller returns to the place where it was interrupted  First, it gets the program counter (PC) address from the stack by popping the top two bytes of the stack into the PC  Then it starts to execute from that address
  • 10. Interrupts in 8051 There are SIX interrupts in 8051 • Reset – power-up reset • Two interrupts are set aside for the timers:  one for timer 0 and one for timer 1 • Two interrupts are set aside for hardware external interrupts  P3.2 and P3.3 are for the external hardware interrupts INT0 (or EX1), and INT1 (or EX2) • Serial communication has a single interrupt that belongs to both receive and transfer
  • 12. Enabling and Disabling of Interrupts • Upon reset, all interrupts are disabled (masked), meaning that none will be responded to by the microcontroller, even if they are activated • The interrupts must be enabled by software in order for the microcontroller to respond to them • There is a register called IE (interrupt enable) that is responsible for enabling (unmasking) and disabling (masking) the interrupts
  • 13. IE Register (Interrupt Enable Register) • Bit D7 of the IE register (EA) must be set to high to allow the rest of register to take effect • The value of EA  If EA = 1, interrupts are enabled and will be responded to if their corresponding bits in IE are high  If EA = 0, no interrupt will be responded to, even if the associated bit in the IE register is high
  • 14. Timer Interrupt • The timer flag (TF) is raised when the timer rolls over • In polling TF, we have to wait until the TF is raised • The problem with this method is that the microcontroller is tied down while waiting for TF to be raised, and can not do anything else • If the timer interrupt in the IE register is enabled, whenever the timer rolls over, TF is raised, and the microcontroller is interrupted in whatever it is doing, and jumps to the interrupt vector table to service the ISR. • Hence, using interrupts, the problem of tying down the microcontroller is solved. • In this way, the microcontroller can do other tasks until it is notified that the timer has rolled over
  • 15. External Interrupts in 8051 • The 8051 has two external hardware interrupts • Pin 12 (P3.2) and pin 13 (P3.3) of the 8051, designated as INT0 and INT1, are used as external hardware interrupts • The interrupt vector table locations 0003H and 0013H are set aside for INT0 and INT1 • There are two activation levels for the external hardware interrupts Level trigged Edge trigged
  • 17. Level Triggered Interrupts • In the level-triggered mode, INT0 and INT1 pins are normally high • If a low-level signal is applied to them, it triggers the interrupt. Then the microcontroller stops whatever it is doing and jumps to the interrupt vector table to service that interrupt • The low-level signal at the INT pin must be removed before the execution of the last instruction of the ISR, RETI; otherwise, another interrupt will be generated • This is called a level-triggered interrupt and is the default mode upon reset of the 8051
  • 18. Level Triggered Interrupts According to one manufacturer’s data sheet, • The pin must be held in a low state until the start of the execution of ISR  If the INTx pin is brought back to a logic high before the start of the execution of ISR there will be no interrupt  If INTx pin is left at a logic low after the RETI instruction of the ISR, another interrupt will be activated after one instruction is executed • To ensure the activation of the hardware interrupt at the INTx pin, make sure that the duration of the low-level signal is around 4 machine cycles, but no more
  • 19. Edge Triggered Interrupts • To make INT0 and INT1 edge-triggered interrupts, we must program the bits of the TCON register • The TCON register holds the IT0 and IT1 flag bits, that determine level- or edge-triggered mode of the hardware interrupt • IT0 and IT1 are also referred to as TCON.0 and TCON.2 since the TCON register is bit addressable
  • 22. Edge Triggered Interrupts • In edge-triggered interrupts, the external source must be held high for at least one machine cycle, and then held low for at least one machine cycle • The falling edge of pins INT0 and INT1 are latched by the 8051 and are held by the TCON.1 and TCON.3 bits of TCON register • It indicates that the interrupt is being serviced now and on this INTx pin, and no new interrupt will be responded to until this service is finished
  • 23. Edge Triggered Interrupts Please note that • When the ISRs are finished (that is, upon execution of RETI), these bits (TCON.1 and TCON.3) are cleared, indicating that the interrupt is finished and the 8051 is ready to respond to another interrupt on that pin • During the time that the interrupt service routine is being executed, the INTn pin is ignored, no matter how many times it makes a high-to-low transition  RETI clears the corresponding bit in TCON register (TCON.1 or TCON.3)  There is no need for instruction CLR TCON.1 before RETI in the ISR associated with INT0
  • 25. Serial Interrupts in 8051 • TI (transfer interrupt) is raised when the last bit of the framed data, the stop bit, is transferred, indicating that the SBUF register is ready to transfer the next byte • RI (received interrupt) is raised when the entire frame of data, including the stop bit, is received
  • 26. Serial Interrupts in 8051 • In the 8051 there is only one interrupt set aside for serial communication  This interrupt is used to both send and receive data  If the interrupt bit in the IE register (IE.4)is enabled, when RI or TI is raised the 8051 gets interrupted and jumps to memory location 0023H to execute the ISR  In that ISR we must examine the TI and RI flags to see which one caused the interrupt and respond accordingly
  • 27. Interrupt Priority • When the 8051 is powered up, the priorities are assigned according to the following
  • 28. Priority of Interrupts • We can alter the sequence of interrupt priority by assigning a higher priority to any one of the interrupts by programming a register called IP (interrupt priority) • To give a higher priority to any of the interrupts, we make the corresponding bit in the IP register high • When two or more interrupt bits in the IP register are set to high, they are serviced according to the default priority  All the interrupts are latched and kept internally and till the interrupt is being serviced, all other interrupts would be ignored.  Upon RETI, No low-priority interrupt can get the immediate attention of the CPU until the 8051 has finished servicing the high-priority interrupts
  • 30. Support for Interrupts in Embedded C • The 8051 compiler have extensive support for the interrupts • They assign a unique number to each of the 8051 interrupts