This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280039C-Q1: Global variable changed unexpectedly when we set the optimization level is 3

Part Number: TMS320F280039C-Q1

Tool/software:

Hi team, 

I ask this for my customer.

My customer call a function in their application, this function will receive the command from the master computer through CAN, and then they will assign this value (ulVal get from CAN) to a global variable (PfcCtrlOnOff) to determine whether their device boots up or not, if the PfcCtrlOnOff is 1, device will power off. The variable PfcCtrlOnOff will be assigned only in this code.

But now, after the device running about 30min, the device will power off automatically even they don't send the power off command through the CAN.

They find:

1. If they close the optimize level, this phenomena will not happen, that means device won't power off itself;

In this situation, the assemble is show in below:

2. But if they set the level is O-3, this phenomena will happen; then they connect the debug and find the variable becomes 1 but the ulVal is 0; 

in this situation, the assemble is show in below:

3. They set the level is O-3, add another global variable PfcOnoffTest and also assign the value ulVal to this variable, the value of PfcOnoffTest will not change unexpectedly, that means although the value of PfcOnoffTest change to q, but the PfcOnoffTest is 0 same as the ulVal;

I compare the assemble above, and find:

1. Between optimize level is off and 3, the position of DP change is not same, and the register to restore the ulVal is also not same; I'm not sure if it has anything to do with the phenomenon;

optimize level is off

optimize level is 3

       

2. in optimize level is 3, it will appear the code: return ulRet, that don't appear in optimize level is off

1. Could you give your opinion about the above difference when the optimize is difference?

2. Could you give your suggest how to find the root cause?

BRs

Shuqing

  • Behavior such as ...

    after the device running about 30min, the device will power off automatically even they don't send the power off command through the CAN.

    ... is rarely due to a problem in the compiler.  It is more likely that the problem is present all along, and building with optimization only exposes it.

    But I can investigate a few things related to the compiler.  For the source file that contains the assignment to PfcCtrlOnOff, please follow the directions in the article How to Submit a Compiler Test Case.  In addition, please submit the linker map file.

    Thanks and regards,

    -George