Interrupt Service Routine (Isr) : The Operation of An Interrupt Sequence
Interrupt Service Routine (Isr) : The Operation of An Interrupt Sequence
INTERRUPTISR
INTERRUPTSERVICEROUTINE(ISR)
Ifmorethanonedeviceisconnectedtotheinterruptline,theprocessorneedstoknowtowhichdevice
service routine it should branch to. The identification of the device requesting service can be done in
eitherhardwareorsoftware,oracombinationofboth.Thethreemainmethodsare:
1. SoftwarePolling,
2. HardwarePolling,(DaisyChain),
3. HardwareIdentification(VectoredInterrupts).
4.
TheOperationofanInterruptsequence:
1.TheCPUfinishesthepresentinstruction.
2.ThereturnaddressHighByteisPushedontotheStack.
3.TheStackPointer(SP)isdecremented
4.ThereturnaddressLowByteisPushedontotheStack
5.TheStackPointer(SP)isdecremented
6.ThemicroprocessorservicestheInterruptServiceRoutine(ISR).
7.Whilereturningfromtheinterruptserviceroutinebytheinstruction(RTI)thereturnaddressLowand
HighbytesarePulledfromthestackandplacedintotheProgrammeCounter(PC).
8.Mainprogrammecontinues.
SoftwarePollingDeterminationoftheRequestingDevice
Asoftwareroutineisusedtoidentifythedevicerequestingservice.Asimplepollingtechniqueisused,
eachdeviceischeckedtoseeifitwastheoneneedingservice.
http://www.electronics.dit.ie/staff/tscarff/16F84/interrupt_ISR.htm
1/4
7/7/2015
INTERRUPTISR
Having identified the device, the processor then branches to the appropriate interrupthandlingroutine
addressforthegivendevice.Theorderinwhichthedevicesappearinthepollingsequencedetermines
theirpriority.
Thefollowingexampleshowsatypicalwayofhandlinginterrupts.PIC16F84hasgotasinglelocation
forstoringtheaddressofaninterruptsubroutine.Thismeansthatfirstweneedtodetectwhichinterrupt
isathand(ifmorethanoneinterruptsourceisavailable),andthenwecanexecutethatpartofa
programmewhichreferstothatinterrupt.
TIMER0INTERRUPT
http://www.electronics.dit.ie/staff/tscarff/16F84/interrupt_ISR.htm
2/4
7/7/2015
INTERRUPTISR
FOR16F84RUNNINGAT4MHz
***************************************************
Thiscodewillgenerateatimer0interruptevery1/15ofasecondandincrementportboneveryinterrupt
***************************************************
theLISTcommandisanassemblerdirectiveandtellstheassemblerwhichcontrollerithastoassemblethecodeforandinwhatformatthecodeshouldbe
generated.
LISTP=16F84,F=INHX8M
whenwritingcodeitiseasiertoputnamestoregistersorfixednumberstodothisweusetheEQUcommand,thisisanotherassemblerdirectiveanditinstructs
theassemblertosubstitutethevalueaftertheEQUcommandtothelabelbeforetheEQUcommand.
INADDEQU00H
TMR0EQU01H
PCEQU02H
STATUSEQU03H
FSREQU04H
PORTAEQU05H
PORTBEQU06H
INTCONEQU0BH
EECON1EQU88H
TRISAEQU85H
TRISBEQU86H
OPTEQU81H
W_STOREEQU20H
STATUS_STOREEQU21H
BITEQUATES
CEQU00
ZEQU02
RP0EQU05
GIEEQU07
EEIEEQU06
T0IEEQU05
INTEEQU04
http://www.electronics.dit.ie/staff/tscarff/16F84/interrupt_ISR.htm
3/4
7/7/2015
INTERRUPTISR
RBIE
http://www.electronics.dit.ie/staff/tscarff/16F84/interrupt_ISR.htm
4/4