![](http://datasheet.mmic.net.cn/260000/PIC16LC72_datasheet_15942878/PIC16LC72_136.png)
PIC16C7X
DS30390B-page 136
1995 Microchip Technology Inc.
14.5.1
INT INTERRUPT
External interrupt on RB0/INT pin is edge triggered:
either rising if bit INTEDG (OPTION<6>) is set, or fall-
ing, if the INTEDG bit is clear. When a valid edge
appears on the RB0/INT pin, flag bit INTF
(INTCON<1>) is set. This interrupt can be disabled by
clearing enable bit INTE (INTCON<4>). Flag bit INTF
must be cleared in software in the interrupt service rou-
tine before re-enabling this interrupt. The INT interrupt
can wake-up the processor from SLEEP, if bit INTE
was set prior to going into SLEEP. The status of global
interrupt enable bit GIE decides whether or not the pro-
cessor branches to the interrupt vector following wake-
up. See Section 14.8 for details on SLEEP mode.
14.5.2
TMR0 INTERRUPT
An overflow (FFh
→
00h) in the TMR0 register will set
flag bit T0IF (INTCON<2>). The interrupt can be
enabled/disabled by setting/clearing enable bit T0IE
(INTCON<5>). (Section 7.0)
14.5.3
PORTB INTCON CHANGE
An input change on PORTB <7:4> sets flag bit RBIF
(INTCON<0>). The interrupt can be enabled/disabled
by setting/clearing enable bit RBIE (INTCON<4>).
(Section 5.2)
14.6
Context Saving During Interrupts
Applicable Devices
70 71 71A 72 73 73A 74 74A
During an interrupt, only the return PC value is saved
on the stack. Typically, users may wish to save key reg-
isters during an interrupt i.e., W register and STATUS
register. This will have to be implemented in software.
Example 14-1 and Example 14-2 store and restore the
STATUS and W registers. For PIC16C72/73/73A/74/
74A, the register, W_TEMP, must be defined in both
banks and must be defined at the same offset from the
bank base address (i.e., if W_TEMP is defined at 0x20
in bank 0, it must also be defined at 0xA0 in bank 1).
For
PIC16C70/71/71A,
STATUS_TEMP, must be defined in bank 0.
The example:
a)
Stores the W register.
b)
Stores the STATUS register in bank 0.
c)
Executes the ISR code.
d)
Restores the STATUS register (and bank select
bit).
e)
Restores the W register.
the
user
register,
Note:
For the PIC16C71/73/74 only,
if a change on the I/O pin should occur
when the read operation is being executed
(start of the Q2 cycle), then the RBIF inter-
rupt flag may not get set.
EXAMPLE 14-1: SAVING STATUS AND W REGISTERS IN RAM (PIC16C70/71/71A)
MOVWF W_TEMP ;Copy W to TEMP register, could be bank one or zero
SWAPF STATUS,W ;Swap status to be saved into W
MOVWF STATUS_TEMP ;Save status to bank zero STATUS_TEMP register
:
:(ISR)
:
SWAPF STATUS_TEMP,W ;Swap STATUS_TEMP register into W
;(sets bank to original state)
MOVWF STATUS ;Move W into STATUS register
SWAPF W_TEMP,F ;Swap W_TEMP
SWAPF W_TEMP,W ;Swap W_TEMP into W
EXAMPLE 14-2: SAVING STATUS AND W REGISTERS IN RAM (PIC16C72/73/73A/74/74A)
MOVWF W_TEMP ;Copy W to TEMP register, could be bank one or zero
SWAPF STATUS,W ;Swap status to be saved into W
BCF STATUS,RP0 ;Change to bank zero, regardless of current bank
MOVWF STATUS_TEMP ;Save status to bank zero STATUS_TEMP register
:
:(ISR)
:
SWAPF STATUS_TEMP,W ;Swap STATUS_TEMP register into W
;(sets bank to original state)
MOVWF STATUS ;Move W into STATUS register
SWAPF W_TEMP,F ;Swap W_TEMP
SWAPF W_TEMP,W ;Swap W_TEMP into W