PIC16C662-10I/SP Microchip Technology, PIC16C662-10I/SP Datasheet - Page 68

no-image

PIC16C662-10I/SP

Manufacturer Part Number
PIC16C662-10I/SP
Description
8-Bit EPROM Microcontrollers with Analog Comparators
Manufacturer
Microchip Technology
Datasheet
PIC16C64X & PIC16C66X
9.6
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 e.g. W register and STATUS
register. This will have to be implemented in software.
Example 9-1 stores and restores the STATUS and W
registers. The user register, W_TEMP, must be defined
in both banks and must be defined at the same offset
from the bank base address (i.e., W_TEMP is defined
at 0x70 - 0x7F in Bank 0). The user register,
STATUS_TEMP, must be defined in Bank 0.
EXAMPLE 9-1:
MOVWF
SWAPF
BCF
MOVWF
SWAPF
MOVWF
SWAPF
SWAPF
DS30559A-page 68
:
: (Interrupt Service Routine)
:
Context Saving During Interrupts
W_TEMP
STATUS,W
STATUS,RP0
STATUS_TEMP
STATUS_TEMP,W
STATUS
W_TEMP,F
W_TEMP,W
SAVING THE STATUS AND W REGISTERS IN RAM
; Copy W to a Temporary Register regardless of current bank
; Swap STATUS nibbles and place into W register
; Change to Bank 0 regardless of current bank
; Save STATUS to a Temporary register in Bank 0
; Swap original STATUS register value into W (restores original bank)
; Restore STATUS register from W register
; Swap W_Temp nibbles and return value to W_Temp
; Swap W_Temp to W to restore original W value without affecting STATUS
Preliminary
Example 9-1:
• Stores the W register regardless of current bank
• Stores the STATUS register in Bank 0
• Executes the ISR code
• Restores the STATUS (and bank select bit
• Restores the W register
register)
1996 Microchip Technology Inc.

Related parts for PIC16C662-10I/SP