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.

CCSTUDIO-C2000: Consultation on CCS software compiling and generating hex files

Part Number: CCSTUDIO-C2000

Hello everyone!

Ask about CCS compilation.

When I compiled and released the program, when addressing structural variables in the hex file, the address was shifted backward by two bytes. Under what circumstances will this compilation result be?

A similar example is shown in the following figure: the correct compilation result should be e2af0210, the abnormal compilation result is e2af0212, and the abnormal result is the result of my previous compilation, which is different from the result of the current compilation, and the source code compiled now is exactly the same as the previous code. The CCS version and compiler used are the same. There are no errors in the two compilations.

I want to confirm where the configuration difference will cause such a problem? Does the configuration difference in CCS engineering lead to this situation? The same code can't be compiled to reproduce the previous exception. CCS version: version, compiler version: v20.2.4.lts.

Looking forward to your reply!

  • I'm confused.  Are you saying that when you build your CCS project two times in a row, with no changes to the source code, build options, or any other configuration detail, the hex output file is different each time?  

    Thanks and regards,


  • Yes, I'm confused, too

    When compiling and publishing for the first time, a compressed package of CCS project file and program source code was backed up. The hex file generated by compilation was wrong (not found at that time). When I unzip the backup compressed package and import the project files into CCS software for recompilation, the generated hex file is different from the first compilation result, and the first compilation result cannot be reproduced. From the comparison of hex files, it seems that when the compiler addresses structural variables, the address is shifted by two bytes. The same shift occurs at two positions of hex, and is two variables adjacent to the same structure. In addition, some variables are defined in the middle section of this structure according to the bit field. Will this affect the addressing of the compiler?  Another exception and internal variables of the structure are shown in the screenshot below:

    Best Regards!

  • I'm not sure exactly what is included in ...

    a compressed package of CCS project file and program source code

    ... but I think it includes the linker map file.  Compare the linker map file from the two builds.  Focus on the part titled GLOBAL SYMBOLS: SORTED BY Symbol Address.  What is the first symbol that has a different address?  Try to work out how that happened.

    Thanks and regards,


  • Yes. The compressed package includes the linker map file too.

    Compare the linker map file from the two builds.Only the linked time information at the beginning is different, and it is the same in other places.

    It is also the same at  GLOBAL SYMBOLS: SORTED BY Symbol Address, and the corresponding structure position is also the same, as shown in the following figure:

  • I presume you know which function contains the code with the incorrect reference to a field in a structure.  For the source file which contains this function, please follow the directions in the article How to Submit a Compiler Test Case.  Indicate the name of the function.  If the problem structure field is not obvious, please add an obvious comment to point that out.  I presume you do not want to post the code to this public forum.  So please pay close attention to the directions in the article about how to send the test case by private message.

    Thanks and regards,