How can I reserve memory and prevent it being used by the compiler?

When you compile with MPLAB® XC8 for a particular device, all the on-chip memory ranges are known by the compiler. If required, you can reduce these memory ranges, and providing the device allows it, specify additional memory to these ranges.

These adjustments can be made using the --RAM and --ROM driver options. If you are using MPLAB X IDE, these options can be accessed from the MPLAB X IDE Build Options > XC8 Linker > Memory Model > RAM Ranges and ROM Ranges.

Please refer to the compiler manual for more details about these arguments.

Example: To remove a particular ROM range of memory from the build process, add the option as:
default,-1000-11ff into the ROM ranges field. Doing this will remove the ROM range 1000h-11ffh from the on-chip memory.

This option is useful while writing Bootloader applications, where the Boot Code has to reserve space for the main application, and vice versa.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.