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.

Functions ignored on CCSv5.1

Other Parts Discussed in Thread: MSP430F47166

Hi,

I imported a project from CCSv4 and it seems the new CCSv5 compiler version are optimizing functions which are critical for my application. 

I tried to modify the optimization parameter from empty to 0 but the result is the same.
Do you have any idea to fix this problem.

Example, this simple delay function below are not executed anymore :

void Loop_Xms(UInt16 x){
UInt16 Loop_1ms;
UInt16 Tune_1ms;
for (Loop_1ms = 0;Loop_1ms < x; Loop_1ms++){
for (Tune_1ms = 0;Tune_1ms < 1700; Tune_1ms++);
}
}
Please consider lot of my CCSv4 project implement this quind of functions, so add a NOP(); instruction to force compiler to execute my function is not a good solution.  

Micro : MSP430F47166

Clock: External Quartz 32.768 Khz , OSC : 10MHz

  • Hello,

    Try disabling all high level optimizations.  You can do this under Project->Properties->Build->MSP430 Compiler->Advanced Options->Advanced Optimizations-> Disable all high level optimizations.

    Please keep us informed.

    Best Regards,

    Lisa

  • Hello Lisa,

    This configuration seems to fix the problem.

    I think this function should be disabled  by default when first use of CCS5 or importing project from older version. This problem made a big mess in our production !

    Thank you for your quick answer.

    Emilien

  • You may want to use the _delay_cycles() intrinsic instead of an empty for loop - it will delay even when there are optimizations enabled in the compiler, and it will also delay for a specific amount of cycles, and not just an unpredictable amount of cycles depending on how the compiler implements the for loop.

    Though seeing the posts recently popping up because of the new default optimizations, it would have probably been better not to turn that into a default - especially for debugging builds where it makes debugging code quite harder. 

  • Hello bernhard,

    I am sure your function _delay_cycles() is much better than my poor loop. Do you know  a doc or application note where I could find all these little function listed & explained because I think I waste my time in developping code which are already written in libraries.

    Thank you

  • The information on the intrinsics is in the code generation tools user guides. The one for the MSP430 is available here.

    It might be a bit of a hard read through that document, but it helped me a lot to understand the compiler better. And with the CCSv5.1 I learned that even if you know the old version, it's worthwhile to read the new documentation - as it contains for example the explanation that optimizations is now turned on by default (page 52 for document revision F).

    You can also find a list of the intrinsics (the useful little functions) in chapter 6.7 (page 122 and following).

    Reading chapter 3 might be especially useful as it handles optimizations, this will hopefully make you aware of possible bugs in your software due to optimization. 

  • HI Emilien,

    no problem at all ... glad we got you pointed to the right option and all the best with development/production!

     

    Best Regards,
    LIsa