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.

CODE OPTIMIZATION



Dear Ti:

       Now we have set the optimization level(--opt_level,-o) : as 2. but my code can't run to the end on my target cpu, if i change it back , it will ok, why this happen?

if i use some .lib which is under release status is it can cause the other code can't be optimized?

  • Hello,
    It is difficult to provide any good suggestions without more details. A reproducible test case would help immensely.

    I will also move this thread to the compiler forums, where the experts there can help you best.

    Thanks
    ki
  • thank you. Now my situation is that ,when i set the level at 1, it can run(my code can access to the interrupt isr function) . but when i set the level higher than 1,which is 2 or 3, it can't access. this really confused me.
  • There isn't enough here to act on.  I'll make a suggestion.  But there is good chance it won't help.

    One common user error in similar circumstances is the failure to use the volatile keyword.  The keyword volatile is a type qualifier like const.  It is applied to variables, like this ...

    volatile int changed_by_isr;

    As one example, any variable that is written by an interrupt must be marked volatile.  Please see this wiki article for more details about volatile.

    If this does not fix your problem, then please supply much more detail on the circumstances of what has gone wrong.

    Thanks and regards,

    -George

  • Sorry, you means is that :if i have changed some variable in the interrupt isr function, it should be volatile type? how about the functions i call in the isr function?

    Now i think i have changed a variable to the volatile , and make it ++ in the isr ,but when i download it to my board , it never do ++ operate(i view it in the express window of CCS). My code is under release mode, optimization level is 2. but when i set to 1 ,it works. I don't know why?

  • Yes, any variable that you write in an interrupt function should be declared volatile. The same applies to any variable written by any function called by the interrupt function.

    Are you absolutely sure that the interrupt is occurring? Set a breakpoint at the start of the interrupt function and see if it is reached.
  • Yes, thank you for your help. I have found it that the interrupt is never happen. if i have a very large array, it should be declare as volatile?

  • The size of the array is irrelevant. What matters is whether it can be written by something like an ISR.

    You need to find out why the ISR is never called. Are you sure you installed the ISR in the interrupt vector? Are you sure you have enabled interrupts in your program?