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.

TMS570LS12x Launchpad SafeTI Integration

Other Parts Discussed in Thread: TMS570LS1115, HALCOGEN

Hello All,

I am trying to Integrate the SafeTI API to the TMS570LS1115 processor. But I have a TMS570LS12x Launchpad and I am performing initial development on it. 

Currently. the SafeTI API source is integrated to the CCS project and I have enabled all the safety tests in HALCoGen. I can run the project and it executes perfectly.

My intention is to initially run all the tests on the processor to verify full processor operation and later will schedule tests to run periodically. 

I would like to know a few things regarding the SafeTI usage and HALCoGen generated source.

  1. When I check the sys_startup.c file I can see many self-test functions are called by the HALCoGen generated code. I guess these are the Self Tests that I selected in HALCoGen and it has nothing to do with the SafeTI API. Am I correct?

  2. When I checked the sl_api.h I can see many functions which can perform similar self tests on the peripherals. Do I need to change the sys_startup.c file and include SafeTI API calls? Or do SafeTI self tests perform the same operation which is done by the HALCoGen generated SelfTests?

  3. During the reset stage, if any self test failed in the middle, how can I get which test actually failed? I think I will not be able to print it to console because we have not even reached the main function yet.

  4. When I checked sl_log.h file, I could find a "SL_Log_Error" function which obviously is designed to Log errors occurring during the Self Tests. For this API to work separate SECTION called LOG_DATA should be dedicated for Error Logs. How to do this? Is there any example for this?

  5. Is this LOG_DATA section in the RAM or in the FLASH? If it is in the RAM still how to retrieve the ErrorLog which is in that location? 

  6. Apart from tests scheduled at the reset, we can configure tests to run in a periodic manner. In this case, what are the non-destructive APIs in the SafeTI library? 

I hope that my questions are clear.

Thank yo

  • Hi Pradeepa,

      The diagnostic functions that comes with the HalCogen are developed earlier than the SafeTI Safety Diagnostic library. For legacy reason they are still included in the HalCoGen. Many of your questions can be found in the wiki at 

    The SafeTI diagnostic library contains suite of diagnostic functions that have a direct mapping to the safety mechanism called out in the respective device safety manual. Here is a link to the SafeTI diagnostic library userguide. 

  • Hi Pradeepa,

    For detailed information, you can refer the PDF provided by Charles. Here are brief answers to your questions:

    1. Yes. The Selftests that you see in sys_startup.c file are called by HalCoGen generated code and have nothing to do with SafeTI API. These selftests are however just some demo diagnostics. HalCoGen generated code is primarily a demo startup code provided to give an idea to the user of how the startup code should look like, how the device initializations should be carried out and how some boot time diagnostics can be called. It’s the selftests in the SafeTI API that you would want to call to perform the diagnostics on your MCU.

    2. The functions that you see in sl_api.h belong to the SafeTI API (all file names of the type “sl_xx” belong to the Safety Library). These are the functions you should call to perform selftests instead of the ones generated by HalCoGen as stated above. You can call these functions in the sl_startup.c file in order to perform boot time tests (but only after the device initialization is complete. This is where HalCoGen generated code will guide); or you can call them in main() as periodic tests inside some loop.

    3. (and 4,5) I am not sure about the answers to these questions. You can refer the PDF for these. In time, I or someone else can get back to you on these.

    6. All of the API in SafeTI Library are non-destructive if handled properly by the application. Some diagnostics are deliberate fault injections and should handled by application in the ESM app callback function. Some diagnostics cause aborts and can be handled in the abort handler functions. Some diagnostics cause reset and can be handled in the reset (c_init) code. Some diagnostics cause disruption of RAM or conflicts with application settings and should be called in a correct sequence during device initialization (boot time only). You can refer the Safety Manual to make out which diagnostics fall under which of the above specified categories and which ones can be called periodically.

    Thanks,
    Vivs
  • Vivs,
    Thanks for your further answers.
  • Hello,

    Thank you very much for all the answers.

    I have another question related to the change from HALCoGen code to SafeTiCode.

    I have generated the HAL code using HALCoGen.

    But if I change the sys_startup.c file's

    _coreInitRegisters_();

    function to 

    SL_Init_R4Registers();

    The ERR LED in Launchpad becomes ON.

    Why is this happening? What are the limitations? Are these limitations documented somewhere. 

    When I checked the HALCoGen examples. It is also not changing _coreInitRegisters_() function. 

    But it does not explain any reason.

  • I don't know why - if this is the only change. You should make sure you have _VFP_SUPPORT_ defined as 1 if you are using the floating point registers.

    What do the ESM status registers say is the issue ?
  • I get 0x08 in the ESMSR3. I cannot find that bit definition in the data sheet. What is the error reported there?

    In the sys_startup.c code, do we need to call _coreInitRegisters_()? Can't we just replace it with SL_Init_R4Registers()?

  • Pradeepa,

    0x08 in ESMSR3 is documented:

    I bet you were just looking at bit 8 instead, because bit 8 is reserved.   The value 0x08 means bit 3 is set.  Easy mistake to make.

    Regarding your 2nd question - Yes I think you can but I would say that you need to make sure that you have defined the default initialization value that

    SL_Init_R4Registers() uses.   I believe the other init routine just uses 0.

    Now in my personal opinion - and I am filing a ticket on this - there is an issue in the startup code in that it tests the reset source before calling the core init registers function.   It may be 'ok' but it's pretty fragile as calling functions before the stack pointers are initialized isn't a good practice IMO.    It may work on a particular compiler version / set of switches but anyway... 

    Point is if I were you for now I would put a call to _coreInitRegisters_ in the /* User Code */ right before the switch/case section that checks the reset state.
    It may initialize the registers twice this way but it shouldn't hurt anything.

  • Anthony,

    Yes I have missed the definition of the error.

    I believe SL_Init_R4Registers() function uses the assembly code available in "sl_asm_api.asm". That assembly code uses SL_REG_INIT_VAL #define internally to initialize all the registers to zero. SL_REG_INIT_VAL is defined in sl_config.h.

    All the above are verified in my code.

    Also, following definitions are added to the project.

    _VFP_SUPPORT_=1

    _TMS570LS12x_

    EXTERNAL_SP_INIT

    Now I am using the example code available in "C:\ti\Hercules\HALCoGen\v04.05.01\examples\TMS570LS12x_11x\example_SafetyLib.c"

    Example code as it is works perfectly. But I want to have a better understanding of the behavior of the library before using it in the project. Otherwise I am responsible for any failures.

    I did very minor change to the code in _c_int00() function declared in sys_startup.c file.

    The change is,

    void _c_int00(void)
    {
    	/* NOTE: DO NOT INITIALIZE ANY VARIABLES !! (will cause DABORT because of un-initialized SP) */
    	volatile boolean 			retVal;             /* For function return values */
        SL_STC_Config 				stcSelfTestConfig;  /* STC Configuration */
    
        _coreInitRegisters_();
    
        SL_Init_R4Registers();   // !!!! ****THIS IS THE ONLY CHANGE**** !!!!
    
        _coreInitStackPointer_();

    Now I connected my TMS570LS12x launchpad and used the CCS debug feature to download the code to the internal flash.

    Now I can see the ERROR RED LED is on. I paused the debugger and checked the ESM registers. I can see 0x08 in ESMSR3.

    Then I changed the code like below,

    void _c_int00(void)
    {
    	/* NOTE: DO NOT INITIALIZE ANY VARIABLES !! (will cause DABORT because of un-initialized SP) */
    	volatile boolean 			retVal;             /* For function return values */
        SL_STC_Config 				stcSelfTestConfig;  /* STC Configuration */
    
        SL_Init_R4Registers();
    
        _coreInitRegisters_();
        
        _coreInitStackPointer_();

    Now it is working. So it is evident that some issue is there in SL_Init_R4Registers function. 

    Please check into this.

    Thanks for the help so far.

    PS: I tried to be as descriptive as possible to allow you to debug the issue quickly.

  • Pradeepa,

    You are right about SL_Init_R4Registers() that this function uses the assembly code available in "sl_asm_api.asm". That assembly code uses SL_REG_INIT_VAL #define internally to initialize all the registers to zero. Moreover, the function _coreInitRegisters_() does almost the same (its the HalCoGen counterpart of SL_Init_R4Registers() function). Thus calling one of the two functions does the job. I guess calling SL_Init_R4Registers() after _coreInitRegisters_() is breaking the system for some reason. It will work fine if you call SL_Init_R4Registers() only.

    I'll debug and come back to you on why calling both the functions (_coreInitRegisters_() followed by SL_Init_R4Registers()) is causing an issue.

    Thanks,
    Vivs
  • Hello Vivs,

    Vivs Shitole said:

     I guess calling SL_Init_R4Registers() after _coreInitRegisters_() is breaking the system for some reason. It will work fine if you call SL_Init_R4Registers() only.

    I can confirm that calling the function SL_Init_R4Registers() alone will still break the system. 

    I have tried this several times. I will check this again today and let you know.

    Thanks.

  • Pradeepa,

    Could you please try the following :

    1. Call SL_Init_R4Registers() in place of _coreInitRegisters_()
    2. Call SL_Init_StackPointers() in place of _coreInitStackPointer_()

    and tell me if you still see the ERROR RED LED on?

    Thanks a lot,
    Vivs
  • Case 1:

    SL_Init_R4Registers();
    /* USER CODE END */
    
    /* Initialize Core Registers to avoid CCM Error */
    _coreInitRegisters_();
    
    /* USER CODE BEGIN (6) */
    /* USER CODE END */
    
    /* Initialize Stack Pointers */
    _coreInitStackPointer_();
    
    /* USER CODE BEGIN (7) */

    No issue.


    Case 2:

    /* USER CODE END */
    
    /* Initialize Core Registers to avoid CCM Error */
    _coreInitRegisters_();
    
    /* USER CODE BEGIN (6) */
    SL_Init_R4Registers();
    /* USER CODE END */
    
    /* Initialize Stack Pointers */
    _coreInitStackPointer_();
    
    /* USER CODE BEGIN (7) */

    Error LED is on

    Case 3:

    /* USER CODE END */
    
    /* Initialize Core Registers to avoid CCM Error */
    //_coreInitRegisters_();
    
    /* USER CODE BEGIN (6) */
    SL_Init_R4Registers();
    /* USER CODE END */
    
    /* Initialize Stack Pointers */
    _coreInitStackPointer_();
    
    /* USER CODE BEGIN (7) */

    Error LED is on

    Case 4:

    /* USER CODE END */
    
    /* Initialize Core Registers to avoid CCM Error */
    _coreInitRegisters_();
    
    /* USER CODE BEGIN (6) */
    /* USER CODE END */
    
    /* Initialize Stack Pointers */
    _coreInitStackPointer_();
    
    /* USER CODE BEGIN (7) */
    SL_Init_R4Registers();

    No Error LED. But the execution is going through a boot loop.

    Hope this will help you.

  • There are definitely issues in this startup code example.
    Waiting to see how many are resolved in the next release of the library.
  • Hello,

    When will the next release be available?

    Is there any document which contains the current bugs and workarounds?

  • Pradeepa,

    Not on the example code - that is not really part of the library and was only intended to be an example of how to call the APIs
    but there are a lot of problems in the switch case that checks for the reset source.

    Also this switch statement is a problem in 'C' because depending on the compiler and switches used it may be using the stack before the stack pointer is initialized. It needs to be written in assembly if it's going to do this sort of tricky stuff.

    I would just simplify that out for now if you do not need to know what caused reset.

    There is a device startup application note that can be used as a reference for what this particular code needs to do:
    www.ti.com/.../getliterature.tsp

    Not sure about the safety lib release but was already expecting it was out. So should be soon.