09212024

Last update2016/05/28 14:38

Back 現在地: Home パートナー SCIOPTA パートナー Atollic 3.エンプティーループがRELEASE-buildで走らない

3.エンプティーループがRELEASE-buildで走らない

3.エンプティーループがRELEASE-buildで走らない

One common support question is related to application behaviour using the two different default generated build configuration; DEBUG and RELEASE. The application typically behaves as expected in debug build configuration, but the behaviour may seem different when building with RELEASE build configuration. Experience tell us that this often is because the developer has written code constructions that are not 100% correct. Using the RELEASE build configuration with higher optimization level the toolchain will remove more code that is perceived as unnecessary. Let us take a look at the example below, two LEDs flashing with a for-loop delay dummy:

 int j;
 EVAL_LEDOn(LEDx);
 for(j = 0; j < 0x100000; j++); ;
 EVAL_LEDOff(LEDx);
 for(j = 0; j < 0x100000; j++);

For the DEBUG build configuration the behaviour will be in accordance with the C-code above. Using the RELEASE build configuration with a higher optimization level, these empty for-loops will be interpreted as unnecessary. In order for the toolchain not to remove them from the RELEASE output binary, the developer must be more accurate in his/her code writing. In this specific case the volatile modifier must proceed the integer declaration:

volatile int j;

 EVAL_LEDOn(LEDx);
 for(j = 0; j < 0x100000; j++); ;
 EVAL_LEDOff(LEDx);
 for(j = 0; j < 0x100000; j++);

This type of mistake is the root cause of most support cases stating that there are differences between DEBUG and RELEASE build configuration.