0
0
Embedded Cprogramming~10 mins

Watchdog timer operation 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 start the watchdog timer.

Embedded C
WDTCTL = [1];  // Start watchdog timer with password and interval
Drag options to blanks, or click blank then click option'
AWDTPW | WDTCNTCL | WDT_MRST_32
BWDTPW | WDTHOLD | WDT_MRST_32
CWDTPW | WDTCNTCL | WDT_MRST_64
DWDTPW | WDTHOLD
Attempts:
3 left
💡 Hint
Common Mistakes
Using WDTHOLD stops the watchdog timer instead of starting it.
Forgetting to include the password WDTPW causes the write to fail.
2fill in blank
medium

Complete the code to reset (kick) the watchdog timer inside the main loop.

Embedded C
while(1) {
    // Your code here
    [1];  // Reset watchdog timer
}
Drag options to blanks, or click blank then click option'
AWDTCTL = WDTPW | WDTHOLD | WDT_MRST_32
BWDTCTL = WDTPW | WDTHOLD
CWDTCTL = WDTPW | WDTCNTCL | WDT_MRST_64
DWDTCTL = WDTPW | WDTCNTCL | WDT_MRST_32
Attempts:
3 left
💡 Hint
Common Mistakes
Using WDTHOLD stops the watchdog timer instead of resetting it.
Not including the password WDTPW causes the reset to fail.
3fill in blank
hard

Fix the error in the watchdog timer stop code.

Embedded C
void stop_watchdog() {
    WDTCTL = [1];  // Stop watchdog timer
}
Drag options to blanks, or click blank then click option'
AWDTPW | WDTCNTCL
BWDTPW | WDTHOLD
CWDTPW | WDT_MRST_32
DWDTHOLD | WDTCNTCL
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the password WDTPW causes the stop command to be ignored.
Using WDTCNTCL clears the counter but does not stop the timer.
4fill in blank
hard

Fill both blanks to configure the watchdog timer interval and mode.

Embedded C
WDTCTL = WDTPW | [1] | [2];  // Configure watchdog timer
Drag options to blanks, or click blank then click option'
AWDTCNTCL
BWDTHOLD
CWDT_MRST_64
DWDT_MRST_128
Attempts:
3 left
💡 Hint
Common Mistakes
Using WDTHOLD stops the timer instead of configuring it.
Choosing the wrong interval bits causes unexpected timer behavior.
5fill in blank
hard

Fill all three blanks to create a safe watchdog reset function with stop and start.

Embedded C
void reset_watchdog() {
    WDTCTL = WDTPW | [1];  // Stop watchdog
    // Some critical code here
    WDTCTL = WDTPW | [2] | [3];  // Restart watchdog
}
Drag options to blanks, or click blank then click option'
AWDTHOLD
BWDTCNTCL
CWDT_MRST_32
DWDT_MRST_128
Attempts:
3 left
💡 Hint
Common Mistakes
Not stopping the watchdog before critical code can cause unwanted resets.
Forgetting to clear the counter when restarting causes immediate reset.