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.

TMS570LS04x STC SelfCheck Error

Other Parts Discussed in Thread: HALCOGEN

Hello,


I'm stuck with a problem occuring while trying to run the SelfTestControler SelfCheck on the TMS570LS04x Eval Board. I'm using HalcoGen and want to do the STCSelfCheck like described in the technical reference.
The following things I'm doing in the HalcoGen generated Code:

1. I choose the Selftest frequency

2. I select the amount of intervals

3. I choose the timeout frequency

4. I wait 16 VBUS clock cycles

5. I'm enabling the STC SelfCheck

6. I'm sending the CPU to Idle Mode in order to start the Check


thats this code:

void stcSelfCheck(void)
{
/* USER CODE BEGIN (8) */
/* USER CODE END */
    volatile uint32 i = 0U;

    /* Run a diagnostic check on the CPU self-test controller */
    /* First set up the STC clock divider as STC is only supported up to 90MHz */

    /* STC clock is now normal mode CPU clock frequency/2 = 180MHz/2 */
    systemREG2->STCCLKDIV = 0x01000000U;

    /* Select one test interval, restart self-test next time, 0x00010001 */
    stcREG->STCGCR0 = 0x00010001U;

    /* Enable comparator self-check and stuck-at-0 fault insertion in CPU, 0x1A */
    stcREG->STCSCSCR = 0x1AU;                                                                                              <---------- I dont understand why this step is necessary

    /* Maximum time-out period */
    stcREG->STCTPR = 0xFFFFFFFFU;

    /* wait for 16 VBUS clock cycles at least, based on HCLK to VCLK ratio */
    /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "Wait for few clock cycles (Value of i not used)" */
    /*SAFETYMCUSW 134 S MR:12.2 <APPROVED> "Wait for few clock cycles (Value of i not used)" */
    for (i=0U; i<(16U + (16U * 0U)); i++){ /* Wait */ }

    /* Enable self-test */
    stcREG->STCGCR1 = 0xAU;

/* USER CODE BEGIN (9) */
/* USER CODE END */

    /* Idle the CPU so that the self-test can start */
    _gotoCPUIdle_();

What should happen now is that "at the end of each interval, the 128 bit MISR value (reflected in registers CPUx_CURMISR[3:0])" gets shifted into the SelfTestControler and is then compared with a "golden" (whatever that means) value in the ROM. After that the Controler resets and starts the program from beginning.

Sadly the MISR Register Value is complete zeros in my case and in the end I'm always ending up having errors diagnosed from both CPUs in my control registers. My main code looks like this:

if((stcREG->STCGSTAT & 0x00000001U) == 0x00000000U){                 //if STC SelfTest not completed (STCGSTAT Bit1 low)

 stcSelfCheck();        //Start STC SelfTest
    }


    else if(((stcREG->STCGSTAT) & 0x00000002U) == 0x00000002U){            // STC SelfTest completed and failed (STCGSTAT Bit2 high)


            if(((stcREG->STCFSTAT) & 0x00000004U) == 0x00000004U){                            //TimeOut Error happened

                sciSend(scilinREG, 25, (unsigned char *)"An TimoOut Error occured.");
            }

            if(((stcREG->STCFSTAT) & 0x00000002U) == 0x00000002U){                            //CPU2 Error happened

                sciSend(scilinREG, 23, (unsigned char *)" CPU2 created an error.");
            }

            if(((stcREG->STCFSTAT) & 0x00000001U) == 0x00000001U){                            //CPU1 Error happened

                sciSend(scilinREG, 23, (unsigned char *)" CPU1 created an error.");
            }


        }

I'm new to microcontroler coding and would appreciate your help.


thanks,

Jonathan

  • Jonathan,

    I am looking into this and will get back to you soon.
  • Jonathan,

    HALCoGen already generates the stcSelfCheck function for you, so you don't have to write your own. This function is defined in the sys_selftest.c file. The first run of the CPU STC causes an intentional fail in order to verify the failure signaling mechanism. This is followed by a "real" CPU STC run using the max number of intervals. You can modify this number of intervals as desired. The mechanisms to check whether STC has passed or failed are also defined in the sys_selftest.c file. The actual response to a CPU STC fail is not defined and is application-specific. You can add your code with sciSend in this empty function.

    Hope this helps.
  • Thank you Sunil,

    I'm using the HalcoGen generated funktion. I just modified it a little bit in order to change the intervalls.
    What you are saying is that the first run of "stcSelfCheck();" will create an intentional error and only the next call of "stcSelfCheck();" will start the real STC SelfCheck? Why is this not written anywhere in the documentation?
    Do I have to call "stcSelfCheck();" then as many times as I have Intervalls choosen?
    Is it wrong to just read the registers in order to detect the errors?
    This might be beginners questions and I hope you're not facepalming. I really appreciate your help.
  • Jonathan,

    That is correct. The stcSelfCheck() function is intended to cause the self-test to fail intentionally. At the end of this first self-test run with a single interval, the CPU gets reset and the reset handler (_c_int00 in sys_startup.c) makes sure that the CPU reset was caused by the STC and that the self-test has failed. Then it calls the function to run the actual CPU self-test. This function is called cpuSelfTest() and takes as arguments the number of intervals to be run. The default value is 26 for the LS04x. You can modify it as you want without actually modifying the code (find the #define in sys_selftest.h in the include folder).

    Once this second run of the self-test completes, the CPU will be reset again. This time the CPU reset handler (again, in _C_int00) will expect the CPU self-test to pass by checking the status register (this code exists already as part of sys_startup.c). If the CPU self-test has failed, then the cpuSelfTestFail function is called. You can write this function the way you want to in order to handle the case when the CPU self-test has failed for real. If the CPU self-test passed, then a function named afterSTC is called. This allows you to continue with the rest of the MCU initialization, as defined in sys_startup.c.
  • Thank you Sunil. I'll will check if everything works as intended and hope its answered.