SW006015 Microchip Technology, SW006015 Datasheet - Page 51

C COMPILER MPLAB C32

SW006015

Manufacturer Part Number
SW006015
Description
C COMPILER MPLAB C32
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC32r
Datasheets

Specifications of SW006015

Supported Families
PIC32MX5, MX6, And MX7
Core Architecture
PIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC32 MCUs
Tool Function
Compiler
Supported Devices
PIC32 MCUs
Tool Type
Compiler
Processor Series
PIC32
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC32
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
3.1
3.2
3.3
© 2007 Microchip Technology Inc.
INTRODUCTION
HIGHLIGHTS
SPECIFYING AN INTERRUPT HANDLER FUNCTION
Interrupt processing is an important aspect of most microcontroller applications.
Interrupts may be used to synchronize software operations with events that occur in
real time. When interrupts occur, the normal flow of software execution is suspended
and special functions are invoked to process the event. At the completion of interrupt
processing, previous context information is restored and normal execution resumes.
PIC32MX devices support multiple interrupts, from both internal and external sources.
The devices allow high-priority interrupts to override any lower priority interrupts that
may be in progress.
The MPLAB C32 C compiler provides full support for interrupt processing in C or inline
assembly code. This chapter presents an overview of interrupt processing.
Items discussed in this chapter are:
• Specifying an Interrupt Handler Function
• Associating a Handler Function with an Exception Vector
• Exception Handlers
An interrupt handler function handles the context save and restore to ensure that upon
return from interrupt, the program context is maintained.
3.3.1
The standard calling convention for C functions will already preserve zero, s0-s7, gp,
sp, and fp. k0 and k1 are used by the compiler to access and preserve non-GPR
context, but are always accessed atomically (i.e., in sequences with global interrupts
disabled), so they need not be preserved actively. In addition to the standard registers,
a handler function will actively preserve the a0-a3, t0-t9, v0, v1 and ra registers.
An interrupt handler function will also actively save and restore processor status
registers that are utilized by the handler function. Specifically, the EPC, SR, hi and lo
registers are preserved as context.
Handler functions specified as priority level 7 (highest priority) will use a shadow
register set to preserve the general purpose registers, enabling lower latency entry into
the application code of the handler function.
3.3.2
A function is marked as a handler function via either the interrupt attribute or the
interrupt pragma
specified as handling interrupts of a specific priority level or for operating in single
vector mode.
1. Note that pre-processor macros are not expanded in pragma directives.
Handler Function Context Saving
Marking a Function as an Interrupt Handler
Chapter 3. Interrupts
1
. Each method is functionally equivalent to the other. The interrupt is
MPLAB
®
C32 C COMPILER
USER’S GUIDE
DS51686A-page 47

Related parts for SW006015