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.

program can't end normally

My program can't end normally. There is a printf in the end. In stdout window, I see haha2. Then it halts at the second breakpoint. Can somebody help me?

  • wu wu said:
    My program can't end normally. There is a printf in the end. In stdout window, I see haha2. Then it halts at the second breakpoint.

    Is your problem that it actually gets to a break point placed after a return statement, or that something else is going wrong?

    For the break point often you end up with break points that do not align perfectly with the C code when you have optimization enabled in your build, so it is not uncommon to see breakpoints offset. What may help to make this make more sense would be to use the 'mixed mode' view in CCS (you should be able to select it from the right click menu) which will show both the C source and assembly, when you do this you will see that the break point is actually tied to a particular assembly instruction and not to a C statement. With the optimizer enabled the assembly can get pushed around and reorganized within the C so it may no longer be a 1:1 mapping which would cause this behavior.

  • I didn't add a breakpoint at the last row at first, but the program can't end. So I add a breakpoint at the last row to see where is wrong. I don't know Assembly Language. Below picture shows the Assembly Language in mixed model.

    Then I define the function is void type, and use exit (-1) instead of return 0. When optimize is closed, the program ends normally. Below picture shows the Assembly Language in mixed model.

    When optimize is used, the program can't end normally, too. Below picture shows the Assembly Language in mixed model.

  • wu wu said:
    I didn't add a breakpoint at the last row at first, but the program can't end.

    I am not sure what you mean by 'the program can't end', if you are at the end of the program it should simply spin indefinitely, or do you mean this is a function that is not returning?

    Looking at the assembly all of your examples show an ending branch statement (BNOP), so it should be leaving the program/function for somewhere, I may be able to comment better if I can better understand what the problem is.

  • I am sorry for that I didn't express myself clearly. This is a main function.  when a program ends, halt button of CCS will change to gray, run and animate buttons will be available, just like the follow picture:

    when my program realises the last printf, the three buttons don't like above picture: run and animate buttons are gray, halt button is available. It seems that the program is running.

  • Hi wu wu,

    the last BNOP is a branch to itself ... so basically an endless loop. This means the program is still running. You can stop the execution of the endless loop by pushing the halt button of CCS.

    Kind regards,

    one and zero

  • Hi one and zero,

    one and zero said:

    the last BNOP is a branch to itself ...

    Do you mean there is something wrong in my program?

    Thanks

     

  • Hi wu wu,

    no there's nothing wrong. This is normal. Let me try to explain this to you. The DSP will alwaysrun as long as you supply power and clock (simply spoken). If your program ends you basically need to keep the DSP executing defined instructions. That's why there's an endless loop which keeps the DSP spinning doing nothing.

    When CCS is connected to the DSP via JTAG typically will set an end of program breakpoint (at the label C$$EXIT, abort). But you can disable that as well - see screenshot.

    Kind regards,

    one and zero

  • Hi one and zero,

    one and zero said:

    When CCS is connected to the DSP via JTAG typically will set an end of program breakpoint (at the label C$EXIT, abort).

    I don't understand above very well. Do you mean when CCS is connected to the DSP via JTAG, there is an automatic breakpoint? And we can disable that? If there is an automatic breakpoint, the program shouldn't go to an endless loop.

    Do you upload three pictures? I just see the first one. My ccs has the same settings as the first picture.

    Thanks.

  • Hi wu wu,

    yes per default CCS sets an end of program breakpoint (at the label C$EXIT, abort) - and you can unselect the option if you wish.

    At the label C$EXIT, abort you'll find an infinite loop.

    Kind regards,

    one and zero

  • Hi one and zero,

                 Is it the option that don't set an end of program breakpoint?

               Since my ccs don't select the option, my program shouldn't halt because of a breakpoint at end of program?

               Sometimes, I write other program. When running, it don't halt. What's the reason?

               If the program halts when ccs is connected to DSP via JTAG, Then what will happen when burning program into flash?

    Thanks