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.

optimization levels

Hi,

I am using CCS  Version: 4.2.4.00033. I am getting variable corruption in a function when I change the compiler optimization level from blank to "0". All of the variables in the function are declared volatile.   My stack size is at 1024 and should be large enough. This routine does use malloc. About 1/2 of the heap is used.

e.g. volatile UInt32 bytes, checksum, mask ,i;

Any suggestions? Are there in-line compiler optimization switches to override the global settings?

 

Regards

Paul

 

  • Based on what is here, I can only make a few vague comments.  Situations like this, where the code stops working when optimization is used, are often due to a bug in the source code, such as an uninitialized variable.  The bug is there all along, but is not exposed until optimization is applied.  Why declare all variables volatile?  Was that added just to see if it avoids the bug?  Which target?  What version of the compiler?  And we will almost certainly need a test case to say anything specific.

    Thanks and regards,

    -George

  • I am starting to narrow down the problem. Corruption of variables is occurring during the SysTick interrupt. If I have a for loop running during the SysTick interrupt I get corruption.

    I could not find a discussion of what IT folding is? Should I also disable interruption of Multiple Cycle instructions? What are the default preemption priorities?

    More later

    Paul