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.

TMS570LS3137: Query STCSCSCR[3:0] for STC test continuation after reset

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

hi, how the cpu comes back to where it left after stc executed?

in "C:\ti\Hercules\Hercules Safety MCU Demos\4.0.0\TMS570LS3x_target_sources\HALCoGen\source\sys_main.c"

//#######################################################################

_coreBackupStackPointer_();

/** - Enable the STC Self Test */
stcREG->STCGCR1 = 0xA;

/** - Enter ARM IDLE state to start the test */
asm(" WFI");
asm(" nop");
asm(" nop");
asm(" nop");
/** - When STC test completes a CPU reset occurs.
* - After checking whether the reset is caused by STC
* the code will brach here to continue the reset of the code */
asm("_Continue_after_STC: nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
//###############################################################

all i see you created a global label "_Continue_after_STC"
and cpu was take to idle to run the stc by asm(" WFI");
but after stc finished how it will come back to this label ?
after stc completed, a cpu reset will occur and in there i dont see any jmp instruction to this jump to this lebel.
can you explain please 

thanks 

  • Hi,

    There should be a function call from the reset handler to this routine. The reset handler is defined in the file sys_startup.c. The CPU gets reset once the CPU self-test (using the Self-Test Controller, STC) completes. This CPU reset is indicated with a flag in the system exception status register (SYSESR). The reset handler checks for this condition to identify whether the CPU reset was caused by an STC run. It then jumps to the function that resumes further configuration of the device after STC.

    Regards,
    Sunil
  • yes, i was expecting that, but in sys_startup.c , there is no calling to this lebel. or no function i see.

    all i found "C:\ti\Hercules\Hercules Safety MCU Demos\4.0.0\TMS570LS3x_target_sources\HALCoGen\source\sys_startup.c"
    ###################################################################
    else if ((SYS_EXCEPTION & CPU_RESET) !=0 )
    {
    /* Reset caused due to CPU reset.
    CPU reset can be caused by CPU self-test completion, or
    by toggling the "CPU RESET" bit of the CPU Reset Control Register. */

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

    /* clear all reset status flags */
    SYS_EXCEPTION = CPU_RESET;

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

    }
    #####################################################################
    can you attach a good file sys_startup.c.
    thanks

  • I would recommend starting with HALCoGen if you are working on a new project with the LS3137 MCU. I have verified the correct function call is present in the reset handler generated by HALCoGen.

    I will verify the implementation on the safety demos and get back to you.
  • hi, when i create sys_startup.c with HALCoGen, the reset handler calls afterSTC() and which calls main().

    but then after self test completed it will start from main.
    but i want to go, where it was called.
    idea is calling the stc self test from a function. and after the self test, program counter will return to the function.

    i found similar example in C:\ti\Hercules\Hercules Safety MCU Demos\4.0.0\TMS570LS3x_target_sources\"
    they created a global label "_Continue_after_STC" with assembly language.
    but after the self test completion i don't see any call back to that label.


    //#############################################
    /**
    - When STC test completes a CPU reset occurs,
    - After checking whether the reset is caused by STC,
    - the code will brach here to continue the reset of the code
    */
    asm("_Continue_after_STC: nop");
    //###################################

  • You can certainly write your own function for performing the STC. Note that the CPU does get reset at the end of the STC, so you need to manually manipulate the address it jumps to after the STC completes, just like how it is done in the example. The CPU reset causes all context information to be lost, so all the CPU initialization steps are required again after the STC completes.
  • Is your question answered? I will mark this post as resolved and close it. Please feel free to post any question you have.

    Regards,
    Sunil
  • hi, no it's not solved.

    i found Hercules Safety MCU Demos examples, but in sys_startup.c file has "void _c_int00(){}"

    after stc self test cpu will reset and program will go there, and you can see below the code.


    void _c_int00()
    {

    _coreInitRegisters_();/* Initialize Core Registers to avoid CCM Error */


    _coreInitStackPointer_();/* Initialize Stack Pointers */

    .......................

    }

    so i think after cpu reset it is not just just reloading the context but starting from beginning.


    do you have any working projects with stc self-test running  periodically for any micro-controller ?

  • Rana,

    Calling the function to enable CPU self-test only enables the CPU self-test. The CPU self-test executes the selected number of test intervals and then causes a CPU reset (not system reset). This is how the CPU self-test differs from a normal function call.

    The reset handler then identifies that the cause of CPU reset is a self-test execution. The CPU initialization is required again after each CPU reset, which is what you observe. The application then jumps to the MCU initialization step after the CPU self-test. Note that only the CPU initialization is performed in this case, the rest of the device is still functioning as configured before (clocks, peripherals, etc).