How to read last Reset Reason for Teensy 4.1

Status
Not open for further replies.

RoSchmi

Member
Hello,
I would like to explore and log unexpected resets of the Teensy 4.1 board but could only find solutions for other Teensy boards, not the Teensy 4.1.
Is this already published anywhere for the Teensy 4.1.
Thanks in advance
RoSchmi
 
Thanks for showing the place.
I played around a little bit with the Reset Status Register.
The most important bits for me seem to be:
SRC_SRSR_IPP_RESET_B // After power reset
SRC_SRSR_LOCKUP_SYSRESETREQ // After software induced reset (SCB_AIRCR = 0x05FA0004;)
SRC_SRSR_WDOG_RST_B // After Watchdog WDT1 induced reset

If someone is interested in my "playing" code:
-https://github.com/RoSchmi/Teensy/tree/master/Proj/Teensy41_Watchdog_ResetCause_1
 
Following up on this, I've added code for other documented causes. I'm not so sure about the description of IPP_USER_RESET_B or IPP_RESET_B. I can't find what "IPP" means. If anyone has better description of these let me know. I did not put in the effort to distinguish between CPU lockup and software reset.

Code:
/* ==================================================================== */
// i.MX RT1060 Processor Reference Manual, 21.8.3 SRC Reset Status Register
void resetCause(uint32_t resetStatusReg) {
    bool info = false;

    if (resetStatusReg & SRC_SRSR_TEMPSENSE_RST_B) {
        Serial.println("Temperature Sensor Software Reset");
        info = true;
    }
    if (resetStatusReg & SRC_SRSR_WDOG3_RST_B) {
        Serial.println("IC Watchdog3 Timeout Reset");
        info = true;
    }
    if (resetStatusReg & SRC_SRSR_JTAG_SW_RST) {
        Serial.println("JTAG Software Reset");
        info = true;
    }
    if (resetStatusReg & SRC_SRSR_JTAG_RST_B) {
        Serial.println("High-Z JTAG Reset");
        info = true;
    }
    if (resetStatusReg & SRC_SRSR_WDOG_RST_B) {
        Serial.println("IC Watchdog Timeout Reset");
        info = true;
    }
    if (resetStatusReg & SRC_SRSR_IPP_USER_RESET_B) {
        Serial.println("Power-up Sequence (Cold Reset Event)");
        info = true;
    }
    if (resetStatusReg & SRC_SRSR_CSU_RESET_B) {
        Serial.println("Central Security Unit Reset");
        info = true;
    }
    if (resetStatusReg & SRC_SRSR_LOCKUP_SYSRESETREQ) {
        Serial.println("CPU Lockup or Software Reset");
        info = true;
        /* Per datasheet: "SW needs to write a value to SRC_GPR5
         * before writing the SYSRESETREQ bit and use the SRC_GPR5
         * value to distinguish if the reset is caused by SYSRESETREQ
         * or CPU lockup."
         */
    }
    if (resetStatusReg & SRC_SRSR_IPP_RESET_B) {
        Serial.println("Power-up Sequence");
        info = true;
    }
    if (!info) {
        Serial.println("No status bits set in SRC Reset Status Register");
    }
}

Usage is:

Code:
    uint32_t lastResetCause;

    // ... do this first in setup() ...
    // Save copy of Reset Status Register
    lastResetCause = SRC_SRSR;
    // Clear all Reset Status Register bits
    SRC_SRSR = (uint32_t)0x1FF;

    // ... more setup steps, get USB ready ...
    resetCause(lastResetCause);
 
@jrw Thanks for pointing out the additional cases. In my application I only tested for SRC_SRSR_IPP_RESET_B (Power Reset), SRC_SRSR_LOCKUP_SYSRESETREQ (Software Reset) and
SRC_SRSR_WDOG_RST_B (Watchdog Reset).
Roschmi
 
Status
Not open for further replies.
Back
Top