Tool/software: TI C/C++ Compiler
Hi,
Customer is using F28034 for motor control. Now they faced one issue about compiler optimization. Because of the optimization, the sequence of codes is changed, not the same as the sequence in the *.c file. We'd like to know why, and how to avoid.
In details:
1) Compiler version: 4.1.3 and 6.2.x have the same issue;
2) Optimization level 2 and 3 have the same issue, as the code is in one function.
3) Below is the code's dis-assembly, gBeforeRunPhaseLose.CurComperCoff = Data1; the sequence is changed, with optimization 2 or 3. It's executed after about 11 lines codes.
4) Below is the dis-assembly without optimization. It's executed immediately. gBeforeRunPhaseLose.CurComperCoff will be set the right value without any delay.
5) In the function, gBeforeRunPhaseLose.CurComperCoff will be set other values in other TWO places. If these two places' codes are excluded from build, the result will be like point 4). CurComperCoff will be set the right value immediately. If these two places' codes are build, there will be the issue, like point 3). The optimization "combined" these codes and caused the new value setting delayed.
Thanks a lot.
Br, Jordan