4.2 Software Setup

Most code examples releases contain two software configurations – free and pro. The pro configuration is setup to use the high-level optimizations of the MPLAB XC8 Compiler, which require a software license, while the free configuration is compiled with only basic optimizations. Both configurations function identically, except for code size and speed improvements from the higher-level optimizations, as shown in Table 4-1.

Note: This example used the standard XC8 compiler to make the example more accessible. In production, use the Functional Safety certified compiler.
Table 4-1. Code Size Comparison in MPLAB XC8 v2.46 and AVR-Ex_DFP v1.13.715
Software ConfigurationOptimization LevelData Memory (SRAM) UsageProgram Flash Memory Usage
Free1373B25,240B
ProS373B23,560B

However, two additional configurations were created for this example. The gas sensor on the Ammonia Click requires a 24-hour warmup time before reaching stable operation. The microcontroller alone can't differentiate a brief power glitch from a long power outage, so the 24-hour sensor warmup is enforced on start-up. However, this is unacceptable for development, so two alternate configurations, develop and develop_no_cksm, were created to accelerate start-up. These configurations also allow the system to start with self-test failures, which is important during development.

In develop_no_cksm, a dummy checksum value (0x87654321) is inserted into the firmware rather than using the Hexmate utility to add one to the output file, which is required since the inserted checksum causes issues when compiling for debugging. The table below shows a summary of the differences between the software configurations.

Table 4-2. Software Configuration Table
Software ConfigurationOptimization LevelHardware Debug24 Hour WarmupStart-up Self-Test Failure AllowedValid Flash Checksum
free1NoYesNoYes
proSNoYesNoYes
develop1NoNoYesYes
develop_no_cksm1YesNoYesNo
Tip:

MPLAB X v6.20 and later default to Build for Debug on the top menu bar for the non-programming options. Pressing the program button (arrow into the microcontroller) does not build for debugging. Standalone Build (and Clean) is available in the IDE by clicking the small arrow next to the build icons.