Complete the code to clear the watchdog reset flag.
if (WDTIFG & [1]) { // Clear watchdog reset flag WDTIFG &= ~[1]; }
The watchdog reset flag is typically named WDTRST in embedded C for MSP430. Checking this flag helps detect if a watchdog reset occurred.
Complete the code to reset the watchdog timer counter.
void reset_watchdog() {
[1] = 0x5A;
WDTCTL = WDTPW | WDTCNTCL;
}Writing the password and the clear bit to WDTCTL resets the watchdog timer counter.
Fix the error in the watchdog reset detection code.
if ([1] & WDTRST) { // Handle watchdog reset }
The watchdog reset flag WDTRST is a bit in the WDTCTL register, so you must check WDTCTL & WDTRST.
Fill both blanks to create a dictionary that maps reset causes to messages.
const char* reset_messages[] = {
[[1]] = "Power On Reset",
[[2]] = "Watchdog Reset"
};PWRONRST is the power-on reset cause, and WDTRST is the watchdog reset cause.
Fill all three blanks to implement watchdog reset recovery logic.
void check_reset_cause() {
if (WDTCTL & [1]) {
clear_reset_flag([2]);
log_event([3]);
}
}Check the WDTRST bit in WDTCTL, clear the watchdog reset flag, and log a message.