Mistake on this page?
Report an issue in GitHub or email us

ResetReason

When the system restarts, the system registers contain the reason for the restart at boot time in a board specific manner. This API provides a generic method of fetching the reason for the restart.

You can use the ResetReason interface to determine the cause of the last system reset in a portable fashion.

ResetReason class reference

Static Public Member Functions
static reset_reason_t get ()
 Get the platform independent reason code for the last system reset. More...
static uint32_t get_raw ()
 Get the platform specific reason code for the last system reset. More...

ResetReason example

Check the cause of the last system reset:

#include "mbed.h"
#include "ResetReason.h"

#include <string>

std::string reset_reason_to_string(const reset_reason_t reason)
{
    switch (reason) {
        case RESET_REASON_POWER_ON:
            return "Power On";
        case RESET_REASON_PIN_RESET:
            return "Hardware Pin";
        case RESET_REASON_SOFTWARE:
            return "Software Reset";
        case RESET_REASON_WATCHDOG:
            return "Watchdog";
        default:
            return "Other Reason";
    }
}

int main()
{
    const reset_reason_t reason = ResetReason::get();

    printf("Last system reset reason: %s\r\n", reset_reason_to_string(reason).c_str());
}
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.