SW006012 Microchip Technology, SW006012 Datasheet - Page 115

C COMPILER FOR DSPIC30F FAMILY

SW006012

Manufacturer Part Number
SW006012
Description
C COMPILER FOR DSPIC30F FAMILY
Manufacturer
Microchip Technology
Type
MPLAB® C30 Compilerr
Series
PIC24 & DsPICr
Datasheets

Specifications of SW006012

Supported Families
PIC24, DsPIC30F And DsPIC33F
Core Architecture
PIC, DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Tool Type
Compiler
Processor Series
PIC24, dsPIC
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
dsPIC30F
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
7.10
© 2007 Microchip Technology Inc.
PSV USAGE WITH INTERRUPT SERVICE ROUTINES
}
A statement can be protected from interrupt using the INTERRUPT_PROTECT macro
provided above. For this example:
INTERRUPT_PROTECT(LATGbits.LATG15 ^= 1); /* Not interruptible by
The introduction of managed psv pointers and CodeGuard Security psv constant sec-
tions in MPLAB C30 v3.0 means that Interrupt Service Routines (ISRs) cannot make
any assumptions about the setting of PSVPAG. This is a migration issue for existing
applications with ISRs that reference the auto_psv constants section. In previous ver-
sions of MPLAB C30, the ISR could assume that the correct value of PSVPAG was set
during program startup (unless the programmer had explicitly changed it.)
To help mitigate this problem, two new function attributes will be introduced: auto_psv
and no_auto_psv. If an ISR references const variables or string literals using the
constants-in-code memory model, the auto_psv attribute should be added to the
function definition. This attribute will cause the compiler to preserve the previous con-
tents of PSVPAG and set it to section .const. Upon exit, the previous value of
PSVPAG will be restored. For example:
void __attribute__((interrupt, auto_psv)) myISR()
{
}
The no_auto_psv attribute is used to indicate that an ISR does not reference the
auto_psv constants section. If neither attribute is specified, the compiler will assume
auto_psv and will insert the necessary instructions to ensure correct operation at runt-
ime. A warning diagnostic message will also be issued. The warning will help alert cus-
tomers to the migration issue, and to the possibility of reducing interrupt latency by
specifying the no_auto_psv attribute.
/* This function can reference const variables and
string literals with the constants-in-code memory model. */
LATGbits.LATG2 = 0;
LATG += 0x0001;
IPC0bits.T1IP = 5;
/* No problem likely,
/* Potential HAZARD -
/* HAZARD -
single instruction bit clear
operation probably used */
First reads LATG into a W reg,
implements add operation,
then writes result to LATG */
Assigning a multiple bitfield
can generate a multiple
instruction sequence */
level 1-7 interrupt
requests and safe
at any optimization
level */
Interrupts
DS51284F-page 109

Related parts for SW006012