Compiling for Debug Outside of MPLAB® X IDE

To compile code for debugging outside of MPLAB® X IDE, you must ensure you pass the correct parameters to the compiler and/or the linker to reserve the areas required. The parameter values depend on the debug tool being used and on the compiler being used. Furthermore, the version of the compiler might determine the specific mechanism used to reserve these areas.

MPLAB X IDE knows to determine what needs to be passed to the compiler/assembler/linker. So, the best way to find out how to reserve areas for debugging is to create a small project in the IDE using the desired device, debug tool, and compiler. Since the IDE can support multiple versions of the same compiler, make sure you select the compiler version you want for your project.

After you have created the small project, build the project for debugging. Save the text in the output window showing the build steps for debugging. Then build the project again (not for debugging) and save the text in the output window showing the build steps for production. Compare the two sets of instructions being passed to the compiler/assembler/linker.

BuildIconMenu.png
Figure: Build Icon Menu

Some examples of the differences in the output window are:

  • Compiler/assembler/linker being called with the __DEBUG macro.
  • Compiler/assembler/linker being called with the __MPLAB_DEBUG macro.
  • Linker being called with __ICD2_RAM or -mreserves. These two are mutually exclusive, i.e., the linker is called with one of them but not the other.
  • Compiler/assembler/linker is called with the name of the debug tool to be used.

This is not an exhaustive list.

© 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.