AN720
6.5. Toolchain Optimization Settings
In addition to the library types, each toolchain has multiple optimization settings that can affect the resulting code
size. In Keil µVision, the optimization settings are set using the following steps:
1. Right-click on the project_name in the Project window and select Options for Target ‘project_name’ or
go to ProjectOptions for Target ‘project_name’.
2. Select the C/C++ tab.
3. Use the Optimization drop-down menu to set the project optimization setting.
Figure 11 shows the optimization settings in the IDE.
The available options are:
Level 0: minimum optimization
Level 1: restricted optimization, removing inline functions and unused static functions
Level 2: high optimization
Level 3: maximum optimization with aims to produce faster code or smaller code size than Level 2,
depending on the options used
In addition to the levels, µVision also has an Optimize for Time selection available below the Optimization drop-
down menu. Declaring a variable as volatile will prevent the compiler from optimizing out the variable.
More information on these optimization levels can be found on the Keil website (http://www.keil.com/support/man/
docs/uv4/uv4_dg_adscc.htm).
Figure 11. Setting the Project Optimization in the µVision IDE
Using the sim3u1xx_Blinky and demo_si32UsbAudio default examples in the si32HAL 1.0.1 software package,
Table 21 and Table 22 show the relative Debug build sizes with the different optimization level settings. Table 23
shows the CoreMark Debug build sizes, and Table 24 lists the CoreMark speed scores for these optimization
levels.
22
Rev. 0.1