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
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
6.3 PMP POINTERS<br />
Additional C Pointer Types<br />
• auto_psv - the compiler will set the PSVPAG register to the correct value <strong>for</strong><br />
accessing the auto_psv space, ensuring that it is restored when exiting the ISR<br />
• no_auto_psv - the compiler will not set the PSVPAG register<br />
For example:<br />
void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) {<br />
IFS0bits.T1IF = 0;<br />
}<br />
Current code (that does not assert the auto_psv attribute) may not execute properly<br />
unless recompiled. When recompiled, if no indication is made, the compiler will generate<br />
a warning message <strong>and</strong> select the auto_psv model.<br />
The choice is provided so that, if you are especially conscious of interrupt latency, you<br />
may select the best option. Saving <strong>and</strong> setting the PSVPAG will consume approximately<br />
3 cycles at the entry to the function <strong>and</strong> one further cycle to restore the setting<br />
upon exit from the function.<br />
Note that boot or secure interrupt service routines will use a different setting of the<br />
PSVPAG register <strong>for</strong> their constant data.<br />
Some devices contain a Parallel Master Port (PMP) peripheral which allows the connection<br />
of various memory <strong>and</strong> non-memory devices directly to the device. Access to<br />
the peripheral is controlled via a selection of peripherals. More in<strong>for</strong>mation about this<br />
peripheral can be found in the Family Reference Manual or device-specific data sheets.<br />
PMP pointers are similar to managed PSV pointers as described in the previous section.<br />
These pointers make it easier to read or write data using the PMP.<br />
The peripheral can require a substantial amount of configuration, depending upon the<br />
type <strong>and</strong> br<strong>and</strong> of memory device that is connected. This configuration is not done<br />
automatically by the compiler.<br />
The extensions presented here allow the definition of a variable as PMP. This means<br />
that the compiler will communicate with the PMP peripheral in order to access the variable.<br />
To use this feature:<br />
• Initialize PMP - define the initialization function: void __init_PMP(void)<br />
• Declare a New Memory Space<br />
• Define Variables within PMP Space<br />
6.3.1 Initialize PMP<br />
The PMP peripheral requires initialization be<strong>for</strong>e any access can be properly processed.<br />
Consult the appropriate documentation <strong>for</strong> the device you are interfacing to<br />
<strong>and</strong> the data sheet <strong>for</strong> 16-bit device you are using.<br />
The toolsuite, if PMP is used, will call void __init_PMP(void) during normal C<br />
run-time initialization. If a customized initialization is being used, please ensure that this<br />
function is called.<br />
This function should make the necessary settings in the PMMODE <strong>and</strong> PMCON SFRs.<br />
In particular:<br />
• The peripheral should not be configured to generate interrupts:<br />
PMMODEbits.IRQM = 0<br />
• The peripheral should not be configured to generate increments:<br />
PMMODEbits.INCM = 0<br />
The compiler will modify this setting during run-time as needed.<br />
© 2008 <strong>Microchip</strong> Technology Inc. DS51284H-page 83