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.

CCS/TMS570LS3137: Using SYSESR after startup

Part Number: TMS570LS3137


Tool/software: Code Composer Studio

I need to use the value of the System Exception Status Register (SYSESR) in my application to help diagnose spurious system failures. For instance, it would be very useful to know if a reset occurred because of a watchdog timer timeout or a power-on reset. Unfortunately, the very bits in this register that could provide this information are cleared in the HalCoGen-generated _c_int00(). For instance,

if ((SYS_EXCEPTION & POWERON_RESET) != 0U)
{
/* USER CODE BEGIN (12) */
/* USER CODE END */

/* clear all reset status flags */
SYS_EXCEPTION = 0xFFFFU;

/* USER CODE BEGIN (13) */
/* USER CODE END */
/* USER CODE BEGIN (14) */
/* USER CODE END */
/* USER CODE BEGIN (15) */
/* USER CODE END */
/* continue with normal start-up sequence */
}

I could disable this code with the appropriate USER CODE blocks, but I'm wondering if it would be safe to do so. Or is there some other way I can store the startup value of SYSESR for later use in main()? I tried simply writing it to a global variable but this gets blown away by subsequent memory tests, of course.

  • Hello,

    The application's response to each reset condition is up to the application. HALCoGen only provides a way to sort through the SYSESR register to identify which reset condition occurred. You can have your own reset handler that does not clear the PORST bit in SYSESR. Then you should be able to see this bit set on each power-up.

    You can disable the clearing of the exception status register for the watchdog and you can read the system exception status register in main. Be sure to clear the watchdog flag after you read it, or it will still be set on other resets (except power-on).