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
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
16-Bit C <strong>Compiler</strong> User’s Guide<br />
4.13 BIT REVERSED AND MODULO ADDRESSING<br />
The compiler does not directly support the use of bit reversed <strong>and</strong> modulo addressing.<br />
If either of these addressing modes is enabled <strong>for</strong> a register, then it is the programmer’s<br />
responsibility to ensure that the compiler does not use that register as a pointer.<br />
Particular care must be exercised if interrupts can occur while one of these addressing<br />
modes is enabled.<br />
It is possible to define arrays in C that will be suitably aligned in memory <strong>for</strong> modulo<br />
addressing by assembly language functions. The aligned attribute may be used to<br />
define arrays that are positioned <strong>for</strong> use as incrementing modulo buffers. The reverse<br />
attribute may be used to define arrays that are positioned <strong>for</strong> use as decrementing<br />
modulo buffers. For more in<strong>for</strong>mation on these attributes, see Section 2.3 “Keyword<br />
Differences”. For more in<strong>for</strong>mation on modulo addressing, see chapter 3 of the<br />
“<strong>dsPIC</strong>30F Family Reference Manual” (DS70046).<br />
4.14 PROGRAM SPACE VISIBILITY (PSV) USAGE<br />
By default, the compiler will automatically arrange <strong>for</strong> strings <strong>and</strong> const-qualified<br />
initialized variables to be allocated in the .const section, which is mapped into the<br />
PSV window. Then PSV management is left up to compiler management, which does<br />
not move it, limiting the size of accessible program memory to the size of the PSV<br />
window itself.<br />
Alternatively, an application may take control of the PSV window <strong>for</strong> its own purposes.<br />
The advantage of directly controlling the PSV usage in an application is that it af<strong>for</strong>ds<br />
greater flexibility than having a single .const section permanently mapped into the<br />
PSV window. The disadvantage is that the application must manage the PSV control<br />
registers <strong>and</strong> bits. Specify the -mconst-in-data option to direct the compiler not to<br />
use the PSV window.<br />
The space attribute can be used to define variables that are positioned <strong>for</strong> use in the<br />
PSV window. To specify certain variables <strong>for</strong> allocation in the compiler-managed<br />
section .const, use attribute space(auto_psv). To allocate variables <strong>for</strong> PSV<br />
access in a section not managed by the compiler, use attribute space(psv). For more<br />
in<strong>for</strong>mation on these attributes, see Section 2.3 “Keyword Differences”.<br />
For more on PSV usage, see the “<strong>MPLAB</strong> ® Assembler, Linker <strong>and</strong> Utilities <strong>for</strong> <strong>PIC24</strong><br />
<strong>MCUs</strong> <strong>and</strong> <strong>dsPIC</strong> ® <strong>DSCs</strong> User’s Guide” (DS51317).<br />
4.14.1 Boot <strong>and</strong> Secure Constants<br />
Two new psv constant sections will be defined: .boot_const <strong>and</strong> .secure_const.<br />
These sections are analogous to the generic section .const, except that the compiler<br />
uses them independently of the user-selectable constants memory model.<br />
Regardless of whether you have selected the constants-in-code or constants-in-data<br />
memory model, the compiler will create <strong>and</strong> manage psv constant sections as needed<br />
<strong>for</strong> secure segments. Consequently, PSVPAG <strong>and</strong> CORCONbits.PSV must become<br />
compiler managed resources. Support <strong>for</strong> user-managed PSV sections is maintained<br />
through an object compatibility model explained below.<br />
Upon entrance to a boot or secure function, PSVPAG will be set to the correct value.<br />
This value will be restored after any external function call.<br />
DS51284H-page 76 © 2008 <strong>Microchip</strong> Technology Inc.