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.

TMS570LC4357: HALCoGen (04.07.01) how to write code outside pre-defined "user code blocks"

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Dear TI Experts,

I'm using HALCoGen to generate source code files for the TMS570LC435 (and using the FreeRTOS variant). I would like to write some personal/customized code to be executed at the beginning and at the end of the gioSetBit() function. I am aware that I need to place my code inside the "USER CODE BEGIN" comment block so that my code does not get overwritten by HALCoGen. The function gioSetBit() has a user code block defined at the beginning of the function but not at the end of the function. Is there a way for me to manually insert a new user code block outside of those that were provided by HALCoGen?

Here's a screenshot depicting the issue that I'm running into:

I tried to add my own comment block similar to "USER BLOCK BEGIN (X)" and it didn't work; I tried several variations and different numbers without any luck. So my question is what can I do to add custom code where there isn't a pre-defined USER BLOCK" section?

Thank you,

Aamer

p.s. the reason I'm trying to do this is to be able to temporarily change CPU mode from 'user' to 'privileged' because RTP/DMM GIO's can not be controlled when CPU is in 'user mode'. If you have a different solution for me to try, I would be very grateful

  • Looking at a HALCoGen installation there are driver files which look to contain @@USERCODE which get expanded to the USER BLOCK sections.

    E.g. C:\ti\Hercules\HALCoGen\v04.07.01\drivers\TMS570LC4357ZWT\GIO570v000\gio.c has the following for gioSetBit with @@USERCODE only at the beginning:

    void gioSetBit(gioPORT_t *port, uint32 bit, uint32 value)
    {
    @@USERCODE
    
        if (value != 0U)
        {
            port->DSET = (uint32)1U << bit;
        }
        else
        {
            port->DCLR = (uint32)1U << bit;
        }
    }

    Whereas gioSetPort has a @@USERCODE at the beginning and end:

    void gioSetPort(gioPORT_t *port, uint32 value)
    {
    @@USERCODE
    
        port->DOUT = value;
    
    @@USERCODE
    
    }

    I haven't tried it, but think if the driver files were modified in the HALCoGen installation to add additional @@USERCODE entries that would result in USER BLOCK sections in the generated source files in the project.

  • Thanks for the suggestion, this does seem promising. My only issue with this approach is that it requires modification of HALCoGen installation files. I'm ok doing that on my local machine, but it would mean that everybody else on my department using this codebase would need to make that modification and that's something difficult to enforce/maintain. I wish HALCoGen allowed for user code to be added "on the fly" without being limited to the provided user block sections.

  • My only issue with this approach is that it requires modification of HALCoGen installation files. I'm ok doing that on my local machine, but it would mean that everybody else on my department using this codebase would need to make that modification and that's something difficult to enforce/maintain.

    Agree this is not ideal.

    I was hoping someone from TI would be able to offer a more maintainable suggestion which doesn't require modifying the HALoGen installation files.