Firewing version introduced full GCC optimisation support for PIC24 and PIC32 devices. You can set the optimisation level in your program using the #option directive at the top of your program (and below any device or clock statements). For example,

device = 24HJ128GP502
clock = 80
#option _gccOptimise = O1

The following optimisation switches are supported

  • O0 - Do not optimise. This should be used during development and and also if debugging.
  • O1 - The compiler attempts to reduce code size and execution time.
  • O2 - Optimise more for speed. Can increase code size when compared to O1.
  • O3 - Apply additional speed optimisations. Will significantly increase code size when compare to O2.
  • Os - Optimize for size. Turns on all O2 optimisations that will not increase code size.

Previous versions of Firewing will produce smaller code when compared to the O0 option. However, very significant improvements in speed can be obtained when using one of the new optimisation levels. The Os option will produce code that is smaller and runs much faster than previous versions of Firewing.

All of the above optimisations will work with native Firewing PIC24 and PIC32 compilers. However, if using the Microchip XC16 or XC32 toolsuites, only licensed optimisations will work. If using free versions of the XC range of compilers, only O0 and O1 are supported. However, it should be noted that 01 will give surprisingly good optimisation results.

Important Note

Please note that is some very rare circumstances, applying optimsation may prevent code from working properly or it may produce unexpected results. It is therefore important to develop your code with O0 (no optimisation). This ensures that any anomalies observed will be more than likely code logic rather than a failure of the optimisation process.