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.

TMS570LS04 Cortex R4 CPU Selftest and STC CPU Test Problems

Other Parts Discussed in Thread: HALCOGEN

Hello, I'm using the TMS570LS04 with Halcogen and want to create a self test Program that runs multiple Selftests on the device. This is my "main" code.

    stcBASE_t stc_data; //stc Data Structure
    stcBASE_t *stc_data_ptr = &stc_data; //stc data ptr

    unsigned int NumberOfChars, value, counter=0, i=0; //Declare variables

    uint8 UARTreceivedData=0;


    sciInit();                 //Initializes the SCI (UART) module
    adcInit();                //Initializes the ADC module
    gioInit();                 //Initializes the gio ports
    hetInit();                 //Initializes the het
    esmInit();              //Configure ESM module to capture esm errors on Error Pin



    sciSend(scilinREG, 2, (unsigned char *)"\r\n");                                                     //Sends new line character
    sciSend(scilinREG, 44, (unsigned char *)"Welcome to the TMS570LS04 Self Test Program.");
    sciSend(scilinREG, 2, (unsigned char *)"\r\n");                                                     //Sends new line character
    
    sciSend(scilinREG, 67, (unsigned char *)"To continue with the CCM Selftest press 'c' and confirm with ENTER.");
  

    sciSend(scilinREG, 2, (unsigned char *)"\r\n");                                                     //Sends new line character

    while(UARTreceivedData!='c'){
    UARTreceivedData=(unsigned int)sciReceiveByte(scilinREG);
    }

    sciSend(scilinREG, 22, (unsigned char *)"CCM SelfCheck started.");
    sciSend(scilinREG, 2, (unsigned char *)"\r\n");                                                     //Sends new line character


    CCMKEYR = 0x00000006U;                                                                                //CPU in Selftest Status

    CCMKEYR = 0x00000000U;                                                                                //reset to Lockstep mode

    while ((CCMSR & 0x00000100U) != 0x00000100U){
    }                                                                                                    //wait for Selftest completition


    sciSend(scilinREG, 46, (unsigned char *)"CCM SelfCheck - complete. Test was successful.");
    sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

    




    sciSend(scilinREG, 67, (unsigned char *)"To continue with the STC Selftest press 'c' and confirm with ENTER.");
    sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

    while(UARTreceivedData!='c'){
    UARTreceivedData=(unsigned int)sciReceiveByte(scilinREG);
    }


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

        sciSend(scilinREG, 22, (unsigned char *)"STC SelfCheck started.");
        sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character
        stcSelfCheck();                                                                                                                      //Start STC SelfTest
    }


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


            sciSend(scilinREG, 39, (unsigned char *)"STC SelfCheck - complete. Test failed as expected.");


            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, 33, (unsigned char *)" CPU2 error Bit high as intended.");
            }

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

                sciSend(scilinREG, 33, (unsigned char *)" CPU1 error Bit high as intended.");
            }

            sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character
        }



        else if(((stcREG->STCGSTAT) & 0x00000002U) == 0x00000000U){            // STC SelfTest completed and succeeded (STCGSTAT Bit2 low)

            sciSend(scilinREG, 46, (unsigned char *)"STC SelfCheck - complete. Test was successful.");
            sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character
        }

    sciSend(scilinREG, 23, (unsigned char *)"Starting STC CPU Test.");
    sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

    while(((stcREG->STCGSTAT) & 0x00000002U) != 0x00000000U){
    cpuSelfTest(2, 0xFFFFFFFF, 1); //start STC CPU Selftest
    }


    if(((stcREG->STCGSTAT) & 0x00000002U) == 0x00000000U){

        sciSend(scilinREG, 44, (unsigned char *)"STC CPUTest - complete. Test was successful.");
        sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

    }


    sciSend(scilinREG, 52, (unsigned char *)"Please Press 'c' and confirm with Enter to continue.");
    sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

    while(UARTreceivedData!='c'){
    UARTreceivedData=(unsigned int)sciReceiveByte(scilinREG);
    }


    sciSend(scilinREG, 26, (unsigned char *)"PBIST SelfCheck started.");
    sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

    pbistSelfCheck();

    sciSend(scilinREG, 42, (unsigned char *)"Memory (RAM) self test (PBIST) - complete.");
    sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

 


following problems occur:

The CCM Selftest catches the program in the following loop. The ending condition for the loop: which is the selftest finished bit doesnt get set.

After the first run of the STC Selfcheck the program resets and it needs a second run to complete. I set the Interval number to two, but why cant I just continue the program?

the STC CPU test always resets the entire program, no matter what. I also chose two as no_of_intervals but here I can run the program multiple times and it doesn't help. I'd like to continue after the run.

  • Hi user4351415 ,

    Did you look at the 'demo app' that comes with the safety library code?
    This should be a good starting point for what you are trying to do.
  • I took a look to it, I'm pretty new to microcontrolers so I couldn't extract the information from it I needed. I can try just to copy the code from the demo but then I will be caught with some other things I dont understand completely yet. I can say from the code that I probably have to use the _coreBackupStackPointer_(); and _coreRestoreStackPointer_(); functions to continue as I wish after the reset in the STC usage.
    I think I'm also going to have problems because the demo hast a different HAL because I use a later version of HALCOGEN.
    U think I should just copy and adjust the code from the demo? I can do that. Only the ccm test isn't a part of the demo, so the problem with the loop I will have anyway.
    thanks for your help,
    Jonathan
  • Hi,

    If you're new then I would definitely start by working through the safety lib demo.

    You're also picking one of the more difficult areas to start if you are new to Microcontrollers :)!

    Because the self tests change the CPU state and memory state (PBIST) 'behind the scenes' i.e. in ways not understood by the C Compiler. So you really need to be careful ... the compiler can't be relied on too heavily when it's assumptions about the environment are not true.

    I though the self test wasn't part of the demo app myself - until someone pointed out to me that it's there. It's just buried in the startup code rather than the app.. it's more common to only execute the STC at every startup - before your whole C environment is setup - for the reasons above.

    Best Regards,
    Anthony
  • Thanks Anthony, so I will go through the demo app and will ask questions about it if I can't understand. I know its a more difficult area, but the company I work for needs the selftest execution for their device so i gotta do it.