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.

MSPM0L1305-Q1: program runaway when select optimization paradigm/Levle (-O) as 1 In CCS12.5.0

Part Number: MSPM0L1305-Q1
Other Parts Discussed in Thread: MSPM0L1305

Tool/software:

Hello,

    When I deubg MSPM0L1305, I find the program runaway when "select optimization paradigm/Levle (-O) " as 1 In CCS12.5.0. But when I set "select optimization paradigm/Levle (-O) " as null, It can runs normal.

    I open debug window to see memroy browser, I find stack ram data is unexcepet in "select optimization paradigm/Levle (-O) " = 1, and stack ram data is right in  "select optimization paradigm/Levle (-O) " = null.

    I adjust the size of stack_size from 256 to 512, it runaway also. and i adjust the size of stack_size from 512 to 1024, it runs OK. But the real size of stack used about 200 bytes.

    So I want to know why the program will runaway when "select optimization paradigm/Levle (-O)" = 1?

  • Hello Lihang,

    Different levels of optimization will result in varying degrees and types of optimizations to the code during compilation. It seems that the level 1 does a wrong optimization to your code. I think this can help you know the difference of different optimization level and help you check whether it will let your running error. Please learn about this resource and check whether you need to do some modification to your code. 

    Best Regards,

    Janz Bai

  • Or it is not unheard of for there to be a bug in the optimizer.

    If you can, pare down your code to a small example that shows this behaviour, and post it here. Often in the process of paring it down, you find the bug that you put there.

  • Hello Keith,

    I am sorry that I forget sending you the resource about the optimization level of CCS, you can refer to this.

    https://software-dl.ti.com/codegen/docs/tiarmclang/rel2_1_0_LTS/compiler_manual/using_compiler/compiler_options/optimization_options.html

    In fact, for a program, not all compiler optimization methods may be suitable for it, especially for some very simple programs. You can check the difference of different optimization level and choose the optimization level which is suitable for you. In fact, your program is not running correctly, it may not be due to a compiler bug, it is highly likely that the optimization method you have chosen is not suitable for your simple program.

    Best Regards,

    Janz Bai