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: TMS570LS3137: Using SYSESR and RTIWDSTATUS after startup

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN
Hello,
I have a question about SYSESR register and WDRST bit.
I need information in application code when microcontroller is reseted by DWWD time out. I am using bootloader and startup code generated by Halcogen. Part of the function _c_int00() is below.
Information if reset is caused by DWWD is cleared in startup procedure (line 16) so I can't use this information in application code. But the EXTRST bit which is also set in case of DWWD timeout is not cleared. Also RTIWDSTATUS is not changed in startup routine, so using these two information I can determine if reset is caused by DWWD.
Is this safe way to handle DWWD resets?
Second question is can I check watchdog violation by examining WDRST bit elsewhere in the code, after all tests are performed?
If I comment out code where WDRST is cleared (line 16) then my application never starts (even bootloader is not starting) and it seems function afterSTC() (line 53) never execute.
void _c_int00(void)
{
    // Enable EventBusExport, FlashEcc and some errata here ...

    if ((SYS_EXCEPTION & POWERON_RESET) != 0U)      /* SYSESR */
    {
        SYS_EXCEPTION = 0xFFFFU;/* clear all reset status flags */
    }
    else if ((SYS_EXCEPTION & OSC_FAILURE_RESET) != 0U)
    {
    }
    else if ((SYS_EXCEPTION & WATCHDOG_RESET) !=0U)
    {
        if(WATCHDOG_STATUS != 0U)
        {
            SYS_EXCEPTION = WATCHDOG_RESET;
        }
        else
        {
            SYS_EXCEPTION = ICEPICK_RESET;
        }
    }
    else if ((SYS_EXCEPTION & CPU_RESET) !=0U)
    {
        SYS_EXCEPTION = CPU_RESET;
        
        /* check if this was an stcSelfCheck run */
        if ((stcREG->STCSCSCR & 0xFU) == 0xAU)              /* Signature compare logic self-check enable key */
        {
            if ((stcREG->STCGSTAT & 0x3U) != 0x3U)
            {
                stcSelfCheckFail();             /* STC self-check has failed */           
            }
            else                                /* STC self-check has passed */          
            {
                stcREG->STCSCSCR = 0x05U;       /* clear self-check mode */            
                stcREG->STCGSTAT = 0x3U;        /* clear STC global status flags */           
                esmREG->SR1[0U] = 0x08000000U;  /* clear ESM group1 channel 27 status flag */       
                
                cpuSelfTest(STC_INTERVAL, STC_MAX_TIMEOUT, TRUE);                            
            }
        }
        else if ((stcREG->STCGSTAT & 0x1U) == 0x1U)         /* Self-test run completed. */
        {
            if ((stcREG->STCGSTAT & 0x2U) == 0x2U)        /* Test Fail */
            {
                cpuSelfTestFail();                    
            }
            else         /* CPU self-test completed successfully */                               
            {
                stcREG->STCGSTAT = 0x1U;  
                
                afterSTC();                                
            }
        }
        else                                        /* CPU reset caused by software writing to CPU RESET bit */
        {
        }
    }
    else if ((SYS_EXCEPTION & SW_RESET) != 0U)      /* Reset caused due to software reset.*/
    {
    }
    else                                            /* Reset caused by nRST being driven low externally.*/
    {
    }


    // Check for ESM group 3 errors, initialize System - Clock, Flash settings with Efuse self check, 
    // run a diagnostic check on the memory self-test controller, 
    // run and check PBIST on STC ROM, 
    // run and check PBIST on PBIST ROM, run stcSelfCheck

    // ....
}

  • Hello,

    The  EXTRST bit should be cleared in startup code. It is not cleared by the code generated through HALCoGen, please add code to clear it. You can use a global flag to record the reset source. 

    We recommend to check watchdog violation in startup when checking the reset source. But you can check it after startup using the information in RTIWDSTATUS register and the global flag.

  • Thank you for answer,

    Can you please explain using global flag?

    If you think global variable, I think it is not possible as it would be blown away after memory test is performed and subsequent resets during tests.

    Regards

    Refik

  • Hello Refik,

    Previous reset source status bits in SYSESR register are not automatically cleared if new resets occur. After reading this register, the software should clear any flags that are set so that the source of future resets can be determined. 

    The EXTRST bit get set for all the reset condition. The watchdog status can only be cleared by nPORRST. So using EXTRST+Wchdog status is not reliable way.

    You are right, the global flag doesn't work too. Another way is to program this flag to build-in EEPROM (Bank 7) after systemInit() was executed.

  • Hello,
    Sorry for late answer. 

    >> Another way is to program this flag to build-in EEPROM (Bank 7) after systemInit() was executed.


    This also is not possible. I described in first post if I do not clear SYS_EXCEPTION register then bootloader never exits and my application does not start. Code is blocked at some point during self tests and afterSTC() function is never reached (as wall as systemInit()).
    One way that is working currently is if I call:

    __iar_data_init3(); 

    TI_Fee_Init();

    Write_status_of_SYS_EXCEPTION_and_WATCHDOG_STATUS_to_eeprom();

    BEFORE clearing  SYS_EXCEPTION.

    Question is is this safe way because this code is executed before actual RAM and FLASH tests are executed.


    I am also considering to redirect DWWD timeout from reset to NMI and write relevant information to eeprom from interrupt routine.

    Regards,

    Refik