Upload
naveen-kumar-saganti
View
225
Download
0
Embed Size (px)
Citation preview
8/8/2019 Interrupts Handling
1/34
Chapter 5
Interrupt Handling Mechanism
8/8/2019 Interrupts Handling
2/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
InterruptFlag
InterruptInterrupt
StructureStructure
InterruptDisabling(masking)
InterruptServiceRoutine
InterruptSourceIdentification
InterruptEnabling
InterruptServicingPriority
8/8/2019 Interrupts Handling
3/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Lesson 1
Interrupt Identification, Service
Enabling and Allocating priorities
8/8/2019 Interrupts Handling
4/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Outline
Why are interrupts important?
Identification of interrupt source
Mask/ Enable interrupts
Priority of interrupts
8/8/2019 Interrupts Handling
5/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Phone ring Importance
We can continue our schedule andattend to phone on an interrupt-event(ringing).
Instance of a phone call event is not known.
8/8/2019 Interrupts Handling
6/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Instance of occurrence of an interrupt eventis not known.
Interrupt Structure Importance
Enables servicing of multiple sources ofinterrupt events.
Processor can execute foreground programtill an interrupt-event starts a service routine.
Interrupt handling when event occurs, saves
wait period of the processor for that event.
8/8/2019 Interrupts Handling
7/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Outline
Why interrupts important?
Identification of interrupt source Mask/ Enable interrupts
Priority of interrupts
8/8/2019 Interrupts Handling
8/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
An MCUInCap flagsetTimer
Device
Overflow
Rx flagset
Transmitted acharacterSerial
Device
Tx flag set
Inputcapture
Received - acharacter
OV flag
set
Interrupt Source Events
8/8/2019 Interrupts Handling
9/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Each interrupt source of each device can
be assigned a flag. Flag(s) shows thedevice status
Interrupt Source Event Identification
byflag bit
A device event sets the flag.A flag is reset at the start.
The flag, when sets, shows the need toservice the interrupt (need of executingthe service routine associated with that
interrupt occurrence).
8/8/2019 Interrupts Handling
10/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Some MCUs show a service need forexecuting a service routine for an interrupt
source of each device by a pending bit.
Interrupt Source Event Service Need
Identification bypending Bit
A device event sets the bit when serviceneed arises.
Service routine execution resets theinterrupt pending bit.
8/8/2019 Interrupts Handling
11/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Outline
Why interrupts important?
Identification of interrupt source Mask/ Enable interrupts
Priority of interrupts
8/8/2019 Interrupts Handling
12/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
MCU
MaskableMaskableinterruptsinterrupts
Non
Maskableinterrupts
8/8/2019 Interrupts Handling
13/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Examples- Maskable Interrupt Sources
Serial Transmitter buffer empty
Serial Receiver buffer full
ADC conversion over
Timer overflow
Serial Receiver FIFO half full
Real time clock ticks
8/8/2019 Interrupts Handling
14/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Examples- Nonmaskable Interrupt
Sources
Software interrupt
RAM parity check error
Clock failure
Illegal opcode
8/8/2019 Interrupts Handling
15/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Software can mask servicing of theMaskable interrupt event so that the
current routine continues when maskbit set or enable bit reset
8/8/2019 Interrupts Handling
16/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Software can enable all or disable all
services to all the Maskable interrupt
events by setting enable all bit (EA =0) or resetting EA bit, called primary
level mask bit.
Primary level mask
8/8/2019 Interrupts Handling
17/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Software can enable or disable a
service to a specific maskable
interrupt event by setting a specificenable bit or resetting bit, called
secondary level mask.
Secondary level Mask
8/8/2019 Interrupts Handling
18/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Primary mask bit disables servicesof all maskable interrupts
Secondary mask bit disablesservice for an individual maskable
interrupt event
8/8/2019 Interrupts Handling
19/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
IE.7
Interrupt masks
IE.6 IE.5 IE.4 IE.3 IE.2 IE.1 IE.0
IE
EA - ET2 ES ET1 EX1 ET0 EX0
Primary mask bit
Enable all
8051/52 Interrupt Enable Register
8/8/2019 Interrupts Handling
20/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
1
0
1
1
0
0
0
ET2
ESET1
EX1
ET0
EX0
Disable T2
Enable T1Enable SI
Disable INT1
DisableINT0
Disable T0
Interrupt
enable/disable bits
Enable when a bit
sets and when EA =1
Enable T2
Enable T1Enable SI
Enable INT1
Enable INT0
Enable T0
EA Enable AllPrimary mask bit
8/8/2019 Interrupts Handling
21/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
MCU
Check service need for executing aservice routine, if primary maskreset
Event(s) Identify
Check secondary mask, service if
mask reset
Execute Interrupt Service routine
8/8/2019 Interrupts Handling
22/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Outline
Why interrupts important?
Identification of interrupt source Mask/ Enable interrupts
Priority of interrupts
8/8/2019 Interrupts Handling
23/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
An MCU Interruptevent
User Assigned newUser Assigned newprioritypriority
MCU AssignedInternal Priority
8/8/2019 Interrupts Handling
24/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
MCU Internally Assigned Priorities
8/8/2019 Interrupts Handling
25/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
INT0 pin interrupt
INT0 pin interrupt
High
T0OVF interrupt
INT0
T0
T1OVF interrupt
INT1
T1
RI and then Txcomplete
RI and TI
8051 Interrupts Defaults Priorities
Low
T2EX pin-ve edge
capture/reload interrupt
T2
Synchronous Serial Device modeinterrupt
SI Synchmode
8/8/2019 Interrupts Handling
26/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
User Assigned Priorities
8/8/2019 Interrupts Handling
27/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
IP
interrupt Priority Register
IP.7 IP.6 IP.7 IP.6 IP.7 IP.6 IP.7 IP.6- - PT2 PS PT1 PX1 PT0 PX0
8051
8/8/2019 Interrupts Handling
28/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
= 0
1
0
1
0
0
PT2
PS
PT1
PX1
PT0
PX0
Low
LowHigh
High
Low
Low
User assigned IP
register bits
Priority Set/Reset
bits
Priority T2
Priority T1Priority SI
Priority INT1
Priority INT0
Priority T0
Assigning Serial Device and INT1 interrupts
Higher priority for service
8/8/2019 Interrupts Handling
29/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
MCUFirst Service an interruptevent whose software andhardware priorities highest
Check mask and service needs
Lastly service the one that has
lowest software and lowesthardware priority
8/8/2019 Interrupts Handling
30/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Software assigned priority overrides
the hardware priority
8/8/2019 Interrupts Handling
31/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Summary
8/8/2019 Interrupts Handling
32/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
Interrupts from Devices and eventsare important
Flag identifies an interrupt
Primary mask bits disables services ofall maskable interrupts Secondary mask bit disables service
for an individual maskable interruptevent
Hardware assigns default priorities Software priority override a hardwarepriority
8/8/2019 Interrupts Handling
33/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
End of Lesson 1
Interrupt Identification, Service
Enabling and Allocating priorities
8/8/2019 Interrupts Handling
34/34
Ch05L1-"Microcontrollers....", RajKamal, from Pearson Education,
THANK YOU