0
0
Embedded Cprogramming~10 mins

Watchdog reset recovery in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to clear the watchdog reset flag.

Embedded C
if (WDTIFG & [1]) {
    // Clear watchdog reset flag
    WDTIFG &= ~[1];
}
Drag options to blanks, or click blank then click option'
AWDTRST
BWDT_RESET
CWDTIFG
DWDT_FLAG
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong flag name that does not indicate watchdog reset.
Trying to clear the flag incorrectly.
2fill in blank
medium

Complete the code to reset the watchdog timer counter.

Embedded C
void reset_watchdog() {
    [1] = 0x5A;
    WDTCTL = WDTPW | WDTCNTCL;
}
Drag options to blanks, or click blank then click option'
AWDTCTL_RESET
BWDT_RESET
CWDT_COUNTER
DWDTCTL
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to reset the watchdog by writing to the wrong register.
Not including the password when writing to the watchdog control register.
3fill in blank
hard

Fix the error in the watchdog reset detection code.

Embedded C
if ([1] & WDTRST) {
    // Handle watchdog reset
}
Drag options to blanks, or click blank then click option'
AWDTIFG
BWDTCTL
CWDT_FLAG
DWDT_RESET
Attempts:
3 left
💡 Hint
Common Mistakes
Checking the flag in the wrong register.
Using an undefined flag name.
4fill in blank
hard

Fill both blanks to create a dictionary that maps reset causes to messages.

Embedded C
const char* reset_messages[] = {
    [[1]] = "Power On Reset",
    [[2]] = "Watchdog Reset"
};
Drag options to blanks, or click blank then click option'
APORRST
BWDTIFG
CWDTRST
DPWRONRST
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the constants for reset causes.
Using flags instead of reset cause constants.
5fill in blank
hard

Fill all three blanks to implement watchdog reset recovery logic.

Embedded C
void check_reset_cause() {
    if (WDTCTL & [1]) {
        clear_reset_flag([2]);
        log_event([3]);
    }
}
Drag options to blanks, or click blank then click option'
AWDTRST
C"Watchdog reset detected"
DWDTIFG
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the reset flag bit and the flag to clear.
Forgetting to log the reset event.