Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The watchdog timer control register must be set with the password (WDTPW), clear counter (WDTCNTCL), and the interval select bits (WDT_MRST_32) to start the timer.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
Resetting the watchdog timer requires writing to WDTCTL with the password, clear counter bit, and interval bits to prevent a reset.
3fill in blank
hardFix 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'
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.
✗ Incorrect
To stop the watchdog timer, write WDTPW (password) combined with WDTHOLD to WDTCTL.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using WDTHOLD stops the timer instead of configuring it.
Choosing the wrong interval bits causes unexpected timer behavior.
✗ Incorrect
WDTCNTCL clears the timer counter, and WDT_MRST_64 sets the interval mode to 64 cycles.
5fill in blank
hardFill 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'
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.
✗ Incorrect
First, stop the watchdog with WDTHOLD. Then restart it by clearing the counter (WDTCNTCL) and setting the interval (WDT_MRST_32).