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.