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.

CCS: How to modify Halcogen generated source?

Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hi,

we want to modify Halcogen generated files.   But it seems changes are only allowed within "USER CODE BEGIN" and "USER CODE END" when Halcogen placed those lines.   If we place modifications / fault corrections within our own "USER CODE" comments they are being removed.   Is there any way doing this?   If not: in which directory are the source files located that Halcogen is using?

Regards,

  • Hello,

    You must only insert your user code inside the predefined /* USER CODE BEGIN */ or otherwise your custom code will disappear after you regenerate HalCogen.

    Best regards,
    Miro

  • Hi Miro,

    thanks, that confirms what I feared already.   Is the source code somewhere inside the Halcogen software directory so that we can change it or is it hard coded inside the Halcogen executable?   Long term we will get rid of the Halcogen anyway (wrong approach to professional embedded software development) but short term we'd like to keep it alive.

    Regards,

  • Hello,

    You can not modify how HALCoGen is generating code.

    Best regards,
    Miro

  • Hello Hagen,

    If you search through other posts on this forum you can find descriptions of how people have handled cases where they want to modify HALCoGen-generated files in places where there are not currently "USER CODE BEGIN" sections, but where they still want to keep using HALCoGen to maintain and modify the majority of their HALCoGen-generated files.

    (If the latter were not true, they could just use HALCoGen to generate their initial files, and then "take ownership" of them thereafter and not run HALCoGen on them again.)

    Some of the options include:

    1)  If there are specific HALCoGen functions you want to replace, you can use the USER CODE BEGIN sections near the beginning of the file to insert a "#pragma WEAK" for that function.  This enables you to re-implement that function (using the same function name) in a separate file that you control, while still compiling the HALCoGen-generated file into your project.

    2) You can replace an entire HALCoGen-generated .c file by using CCS settings to exclude that file from being built into your project, and then re-implement the functionality you need from that file in a separate file that you control.

    3) In many cases you can "slice-and-dice" an existing HALCoGen-generated .c file by disabling almost abitrary portions of the file with a "#if 0" in an early USER CODE BEGIN section of the file, where the matching "#endif" is in a completely separate later portion of the file.

    You can find specific examples described in more detail in the forum of #3. My own recommendation would be to go with #1 or #2 as appropriate.  I find trying to peer review and maintain code where approach #3 has been taken to be tricky.

    Whichever option, I'd suggest making use of the existing USER CODE sections to place prominent comments making it clear to peer reviewers and future maintainers that the code in the HALCoGen-generated .c file is not "live" code.  In particular, if a future version of HALCoGen fixes or improves a file that has been all or partially replaced using any of these options, it is hard to realize that this fix hasn't actually been incorporated in your firmware.