07.04.2013 Views

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Differences Between 16-Bit Device C <strong>and</strong> ANSI C<br />

auto_psv, no_auto_psv<br />

The auto_psv attribute, when combined with the interrupt attribute, will cause the<br />

compiler to generate additional code in the function prologue to set the PSVPAG SFR<br />

to the correct value <strong>for</strong> accessing space(auto_psv) (or constants in the constants-in-code<br />

memory model) variables. Use this option when using 24-bit pointers<br />

<strong>and</strong> an interrupt may occur while the PSVPAG has been modified <strong>and</strong> the interrupt routine,<br />

or a function it calls, uses an auto_psv variable. Compare this with<br />

no_auto_psv. If neither auto_psv nor no_auto_psv option is specified <strong>for</strong> an<br />

interrupt routine, the compiler will issue a warning <strong>and</strong> select this option.<br />

The no_auto_psv attribute, when combined with the interrupt attribute, will cause the<br />

compiler to not generate additional code <strong>for</strong> accessing space(auto_psv) (or constants<br />

in the constants-in-code memory model) variables. Use this option if none of the<br />

conditions under auto_psv hold true. If neither auto_psv nor no_auto_psv option<br />

is specified <strong>for</strong> an interrupt routine, the compiler will issue a warning <strong>and</strong> assume<br />

auto_psv.<br />

boot<br />

This attribute directs the compiler to allocate a function in the boot segment of program<br />

Flash.<br />

For example, to declare a protected function:<br />

void __attribute__((boot)) func();<br />

An optional argument can be used to specify a protected access entry point within the<br />

boot segment. The argument may be a literal integer in the range 0 to 31 (except 16),<br />

or the word unused. Integer arguments correspond to 32 instruction slots in the segment<br />

access area, which occupies the lowest address range of each secure segment.<br />

The value 16 is excluded because access entry 16 is reserved <strong>for</strong> the secure segment<br />

interrupt vector. The value unused is used to specify a function <strong>for</strong> all of the unused<br />

slots in the access area.<br />

Access entry points facilitate the creation of application segments from different vendors<br />

that are combined at run time. They can be specified <strong>for</strong> external functions as well<br />

as locally defined functions. For example:<br />

/* an external function that we wish to call */<br />

extern void __attribute__((boot(3))) boot_service3();<br />

/* local function callable from other segments */<br />

void __attribute__((secure(4))) secure_service4()<br />

{<br />

boot_service3();<br />

}<br />

To specify a secure interrupt h<strong>and</strong>ler, use the boot attribute in combination with the<br />

interrupt attribute:<br />

void __attribute__((boot,interrupt)) boot_interrupts();<br />

When an access entry point is specified <strong>for</strong> an external secure function, that function<br />

need not be included in the project <strong>for</strong> a successful link. All references to that function<br />

will be resolved to a fixed location in Flash, depending on the security model selected<br />

at link time.<br />

When an access entry point is specified <strong>for</strong> a locally defined function, the linker will<br />

insert a branch instruction into the secure segment access area. The exception is <strong>for</strong><br />

access entry 16, which is represented as a vector (i.e, an instruction address) rather<br />

than an instruction. The actual function definition will be located beyond the access<br />

area; there<strong>for</strong>e the access area will contain a jump table through which control can be<br />

transferred from another security segment to functions with defined entry points.<br />

© 2008 <strong>Microchip</strong> Technology Inc. DS51284H-page 21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!