0
0
Embedded Cprogramming~20 mins

Why watchdog timer is needed in Embedded C - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Watchdog Timer Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of a Watchdog Timer
Why is a watchdog timer important in embedded systems?
AIt increases the processing speed of the microcontroller.
BIt resets the system if the software stops responding to prevent system hang.
CIt stores data permanently in case of power failure.
DIt manages power consumption by turning off unused peripherals.
Attempts:
2 left
💡 Hint
Think about what happens if the program gets stuck or crashes.
Predict Output
intermediate
2:00remaining
Watchdog Timer Reset Behavior
What will be the output of this embedded C code snippet simulating a watchdog reset?
Embedded C
#include <stdio.h>
int main() {
    static int watchdog_counter = 0;
    int system_hang = 1; // 1 means system is stuck
    if(system_hang) {
        watchdog_counter++;
        if(watchdog_counter > 3) {
            printf("System Reset Triggered\n");
        } else {
            printf("System Running\n");
        }
    } else {
        printf("System Running Normally\n");
    }
    return 0;
}
ASystem Running
BSystem Reset Triggered
CSystem Running Normally
DNo output
Attempts:
2 left
💡 Hint
Check how many times the watchdog_counter is incremented and compared.
🔧 Debug
advanced
2:00remaining
Identify the Watchdog Timer Bug
What error will this embedded C code cause related to the watchdog timer?
Embedded C
void watchdog_reset() {
    int timer = 0;
    if(timer == 0) {
        // supposed to reset watchdog timer
        timer = 5;
    }
}

int main() {
    watchdog_reset();
    if(timer == 0) {
        // check if timer reset
        printf("Watchdog not reset\n");
    } else {
        printf("Watchdog reset\n");
    }
    return 0;
}
AOutput: Watchdog reset
BRuntime error: division by zero
CCompilation error: 'timer' undeclared in main
DOutput: Watchdog not reset
Attempts:
2 left
💡 Hint
Check variable scope of 'timer' in main function.
📝 Syntax
advanced
2:00remaining
Syntax Error in Watchdog Timer Code
Which option contains the correct syntax to initialize and start a watchdog timer in embedded C?
AWDTCTL := WDTPW | WDTHOLD; // Stop watchdog timer
BWDTCTL == WDTPW | WDTHOLD; // Stop watchdog timer
CWDTCTL = WDTPW & WDTHOLD; // Stop watchdog timer
DWDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
Attempts:
2 left
💡 Hint
Assignment uses a single equal sign in C.
🚀 Application
expert
3:00remaining
Watchdog Timer Use Case Scenario
In which scenario is a watchdog timer most critical to ensure system reliability?
AA spacecraft control system running unattended for months in space.
BA home thermostat controlling temperature with occasional user input.
CA simple calculator app on a smartphone.
DA desktop word processor application.
Attempts:
2 left
💡 Hint
Think about systems that cannot be manually reset easily.