Other Parts Discussed in Thread: C2000WARE
Tool/software:
Hello,
I'm new to embedded programming and I'm attempting to track the reset reason.
I would appreciate your assistance with this.
When a soft reset happens and the application restarts, the reset reason is reported as multiple events by the API call `SysCtlResetCauseGet()`, which returns 24.
This value, 24, is a combination of `SYSCTL_CAUSE_SW` and `SYSCTL_CAUSE_WDOG`.
For a cold start, I receive `SYSCTL_CAUSE_WDOG`.
In both cases, `SYSCTL_CAUSE_WDOG` is consistently present.
I have not implemented watchdog in my code. but I still get the SYSCTL_CAUSE_WDOG.
What is the correct approach to know the reset cause.
Here is what the API says.
//*****************************************************************************
// The following are values that can be passed to the SysCtlResetCauseClear()
// API or returned by the SysCtlResetCauseGet() API.
//*****************************************************************************
#define SYSCTL_CAUSE_SW 0x00000010 // Software reset
#define SYSCTL_CAUSE_WDOG 0x00000008 // Watchdog reset
#define SYSCTL_CAUSE_POR 0x00000002 // Power on reset
Here is my function
void GetResetCause(void)
{
// Retrieve the current reset causes
uint32_t resetCauses = SysCtlResetCauseGet();
if (resetCauses > 0)
{
// Count the number of active causes (set bits)
int activeCauses = 0;
if (resetCauses & SYSCTL_CAUSE_EXT)
{
printf("External reset detected\n");
activeCauses++;
}
if (resetCauses & SYSCTL_CAUSE_WDOG)
{
printf("Watchdog reset detected\n");
activeCauses++;
}
if (resetCauses & SYSCTL_CAUSE_SW)
{
printf("Software reset detected\n");
activeCauses++;
}
if (resetCauses & SYSCTL_CAUSE_POR)
{
printf("Power-on reset detected\n");
activeCauses++;
}
// Determine if multiple causes are active
if (activeCauses > 1)
{
printf("Unknown or multiple reset causes detected\n");
}
printf("Reset causes %d\n", resetCauses);
// Clear the reset cause register after handling
SysCtlResetCauseClear(resetCauses);
}
}
Thanks,
Satish