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
Hi Satish,
Yes just reading RESC register can tell you the reset cause. Please refer to the register description in the manual.
I have not implemented watchdog in my code. but I still get the SYSCTL_CAUSE_WDOG.
Is watchdog enabled ? Also what do you mean by cold start ?
Thanks
Hi Prarthan,
Thanks for your response.
In my case the Watch dog is not enabled.
While the device is running, cut down the power and start again.
When the power is turned on, the bootloader loads the application and I seeSYSCTL_CAUSE_WDOG.
For a soft reset what is the reason for getting multiple events ? I was expecting SYSCTL_CAUSE_SW.
but i see`the reason SYSCTL_CAUSE_SW` and `SYSCTL_CAUSE_WDOG`.
Thanks
Hi Satish,
If you see that the Watchdog bit is set in RESC register, then indeed watchdog triggered a reset after timer expiry.
You are saying above that you are cutting power, that's not soft reset that's power cycle scenario or maybe you are trying to explain twwo different scenarios here.
But anyways when ROM code sees exception like below it can set the WDT and trigger reset for handling it, you may need to check the Bootrom execution status bits if this is case like below :
Can you also try just powerup boot to flash with a simple gpio toggle example from c2000ware, maybe and check the RESC register.
Thanks
Hello Prarthan,
In the MBOOT description provided, the only reason the MBOOT would trigger a Watchdog reset would be in the event of a FUSE error. I don't think this is happening in my case, because I am just power cycling.
I just want to know the reboot reason.
Given that the MBOOT code clears the POR and XRS bits but not the Watchdog, How do I differentiate between an actual watchdog trip (once I enable it) and an external or power on reset.
How would you recommend to differentiate between a POR (or XRS) and a watchdog given the MBOOT interference. Are there other registers available that provide additional useful information?
Thank you,
Satish
Hi Satish,
No RESC register is the only way to know the reset cause.
Given that the MBOOT code clears the POR and XRS bits but not the Watchdog, How do I differentiate between an actual watchdog trip (once I enable it) and an external or power on reset.
Boot code clears POR bit on POR and XRSn only on XRSn type reset. Other sources stay intact in the register for user to debug
Can you also try just powerup boot to flash with a simple gpio toggle example from c2000ware, maybe and check the RESC register.
Were you able to try above?
Thanks