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.

Compiler/TMS570LS1224: HALCoGen 04.07.01 User Code Block does not allow for custom CPU reset routine to be implemented

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN,

Tool/software: TI C/C++ Compiler

Dear TI Experts,

I decided to post to this forum, as I could not find an appropriate forum for posting HALCoGen questions.

HALCoGen Version: 04.07.01

I have been analyzing the HALCoGen generated code for the TMS570LS1224, in particular the sys_startup file.

When checking the power-on reset condition, the last "else" statement is supposed to cover the case when the CPU reset was caused by software. One would expect a "User Code Begin" block there, however there is none. It is only after the squiggly bracket after closing the "else".

Here is the section of code  I am referring to:

        /* CPU reset caused by CPU self-test completion */
        else if ((stcREG->STCGSTAT & 0x1U) == 0x1U)        
        {
            /* Self-Test Fail flag is set */
            if ((stcREG->STCGSTAT & 0x2U) == 0x2U)        
            {
                /* Call CPU self-test failure handler */
                cpuSelfTestFail();                    
            }
            /* CPU self-test completed successfully */
            else                                        
            {
                /* clear STC global status flag */
                stcREG->STCGSTAT = 0x1U;  
                
                /* Continue start-up sequence after CPU STC completed */
                afterSTC();                                
            }
        }
        /* CPU reset caused by software writing to CPU RESET bit */
        else                                            
        {
            /* Add custom routine here to handle the case where software causes CPU reset */
        }
/* USER CODE BEGIN (21) */
/* USER CODE END */

    }
    /*SAFETYMCUSW 139 S MR:13.7 <APPROVED> "Hardware status bit read check" */
    else if ((SYS_EXCEPTION & SW_RESET) != 0U)
    {
        /* Reset caused due to software reset.
        Add user code to handle software reset. */

My presumption is that the "/*USER CODE BEGIN (21) */ should be inside that "else" statement above it, otherwise any user-written code would be deleted when generating code from HALCoGen.

Thank You for taking the time to look into this!

Kind regards,

Mihail