DM164120-2 Microchip Technology, DM164120-2 Datasheet - Page 33

BOARD DEMO PICKIT 2 44PIN

DM164120-2

Manufacturer Part Number
DM164120-2
Description
BOARD DEMO PICKIT 2 44PIN
Manufacturer
Microchip Technology
Type
MCUr
Datasheets

Specifications of DM164120-2

Contents
3 Boards (1 Populated, 2 Bare)
Processor To Be Evaluated
PIC16F
Silicon Manufacturer
Microchip
Kit Contents
PIC16F Device, 2 PCB Boards
Features
Small Surface Mount Prototype Area, Two Bare PCB Boards
Development Tool Type
Hardware - Daughter Card
Rohs Compliant
Yes
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
PIC16F887
Lead Free Status / Rohs Status
Lead free / RoHS Compliant

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
DM164120-2
Manufacturer:
Microchip Technology
Quantity:
135
© 2007 Microchip Technology Inc.
When the master interrupt line is asserted, the PIC microcontroller finishes the current
instruction, stores the next address on the CALL stack then jumps to the Interrupt Ser-
vice Routine (ISR). It also clears the GIE bit, preventing another interrupt from occur-
ring while servicing the current one.
Save Current Context
The first thing the ISR must do is to save the current context of the processor so it can
be restored before returning to the main program. Certain SFRs that may be changed
in the ISR should be saved, such as the WREG and STATUS registers at the very least.
Make sure to save the WREG first, as moving other SFRs into it will destroy the value
needing to be saved. The last 16 bytes of each PIC16F887 file register page are
unbanked and are good places to save the context, as they may be accessed from any
register page without regard to the RP0 and RP1 bits in the STATUS register. The
location of unbanked registers may vary from part to part. Check the register map to
find the unbanked region for a specific part.
Identify Triggering Event
Next, the ISR has to figure out what triggered the interrupt. It has to check the interrupt
flags to determine what caused the interrupt. When it finds the source, it can then
service the peripheral.
Restore Context
Once the peripheral is serviced, it needs to restore the context and resume the main
program. The “context” is the state of the SFRs when the interrupt occurred. Restoring
the context is a little harder than it might seem at first. The obvious method doesn’t work
because the MOVF W_Temp,w may affect the Z flag, which was restored in the previ-
ous instruction. Instead, a pair of SWAPF instructions can restore WREG without affect-
ing the flags in the STATUS register. SWAPF exchanges the high and low nibbles. The
first SWAPF switches the nibbles in the file register and the second one switches them
back and puts the result in WREG.
EXAMPLE 3-9:
Finally, RETFIE transfers control back to the original program and sets the GIE bit,
re-enabling interrupts.
;incorrect context restore
MOVF
MOVWF STATUS
MOVF
;good context restore
MOVF
MOVWF STATUS
SWAPF W_Temp,f
SWAPF W_Temp,w
STATUS_Temp,w
W_Temp
STATUS_Temp,w
CONTEXT RESTORE
44-Pin Demo Board Lessons
;this may change the Z bit
;in the Status register
;swap in place
;swap with Wreg destination
DS41296B-page 29

Related parts for DM164120-2