Make Your Code Small for Free

Last modified by Microchip on 2024/01/17 22:16

Microchip’s free optimizing compilers are great, but are you sure you’re getting all of the code size benefits that you can from them? For backward compatibility reasons, not all of the optimizations are turned on by default. All optimizations are easily controlled from the Project Properties window in MPLAB® X IDE. For MPLAB XC8, there are three important selections: choose Generated Assembler Code and Assembler Files, and deselect Speed. This will give you the tightest code generation.

Project properties selections for XC8

It’s even simpler for MPLAB XC16 and XC32. In the same Project Properties window, simply choose Optimization Level 1.

Project properties selections for XC16 and XC32

That’s all it takes to get the smallest possible code size for all of the free optimizing MPLAB XC compilers!