DatasheetQ Logo
Electronic component search and free download site. Transistors,MosFET ,Diode,Integrated circuits

PIC16LC925T-I/CL 查看數據表(PDF) - Microchip Technology

零件编号
产品描述 (功能)
生产厂家
PIC16LC925T-I/CL
Microchip
Microchip Technology 
PIC16LC925T-I/CL Datasheet PDF : 182 Pages
First Prev 111 112 113 114 115 116 117 118 119 120 Next Last
PIC16C925/926
12.6 Context Saving During Interrupts
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., the W and STATUS reg-
isters. This will have to be implemented in software.
Example 12-1 stores and restores the STATUS, W, and
PCLATH registers. The register, W_TEMP, must be
defined in each bank 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).
The code in the example:
e) Stores the W register.
f) Stores the STATUS register in bank 0.
g) Stores the PCLATH register.
h) Executes the ISR code.
i) Restores the STATUS register (and bank select
bit).
j) Restores the W and PCLATH registers.
EXAMPLE 12-1: SAVING STATUS, W, AND PCLATH REGISTERS IN RAM
MOVWF W_TEMP
;Copy W to TEMP register, could be bank one or zero
SWAPF STATUS,W
;Swap status to be saved into W
CLRF
STATUS
;bank 0, regardless of current bank, Clears IRP,RP1,RP0
MOVWF STATUS_TEMP
;Save status to bank zero STATUS_TEMP register
MOVF
PCLATH, W
;Only required if using pages 1, 2 and/or 3
MOVWF PCLATH_TEMP
;Save PCLATH into W
CLRF
PCLATH
;Page zero, regardless of current page
BCF
STATUS, IRP
;Return to Bank 0
MOVF
FSR, W
;Copy FSR to W
MOVWF FSR_TEMP
;Copy FSR from W to FSR_TEMP
:
:(ISR)
;Insert user code here
:
MOVF
PCLATH_TEMP, W ;Restore PCLATH
MOVWF PCLATH
;Move W into PCLATH
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
2001 Microchip Technology Inc.
Preliminary
DS39544A-page 109

Share Link: 

datasheetq.com  [ Privacy Policy ]Request Datasheet ] [ Contact Us ]