A watchdog timer is a hardware timer that resets the system if the software becomes unresponsive or stuck, helping to recover from errors automatically.
Click to reveal answer
beginner
Why do we configure the watchdog timeout period?
We configure the watchdog timeout period to set how long the system can run without resetting the watchdog before it triggers a system reset, balancing safety and normal operation.
Click to reveal answer
beginner
Which unit is commonly used to set the watchdog timeout?
The watchdog timeout is commonly set in milliseconds or seconds, depending on the hardware timer's clock and prescaler settings.
Click to reveal answer
intermediate
How do you typically change the watchdog timeout in embedded C code?
You change the watchdog timeout by configuring specific registers related to the watchdog timer, often by setting prescaler and reload values according to the desired timeout period.
Click to reveal answer
beginner
What happens if the watchdog timer is not reset before the timeout?
If the watchdog timer is not reset (or 'kicked') before the timeout expires, it triggers a system reset to recover from a possible software fault.
Click to reveal answer
What is the main purpose of configuring a watchdog timeout?
ATo configure the display brightness
BTo set how long the system waits before resetting if unresponsive
CTo save power during sleep mode
DTo increase the CPU clock speed
✗ Incorrect
The watchdog timeout defines how long the system can run without resetting the watchdog before it triggers a reset.
Which action resets the watchdog timer to prevent a system reset?
AIncreasing the clock frequency
BTurning off the power supply
CWriting a specific value to the watchdog register
DDisabling interrupts
✗ Incorrect
Resetting the watchdog timer usually involves writing a specific value to its control register to prevent timeout.
If the watchdog timeout is set too short, what might happen?
AThe system may reset too often, even during normal operation
BThe system will never reset
CThe CPU speed will increase
DThe memory size will increase
✗ Incorrect
A very short timeout can cause unwanted resets because the system may not reset the watchdog in time during normal tasks.
What is a common unit for watchdog timeout configuration?
AMilliseconds
BBytes
CVolts
DDegrees Celsius
✗ Incorrect
Timeouts are usually set in time units like milliseconds or seconds.
Which register setting is often involved in configuring watchdog timeout?
AData direction register
BAnalog-to-digital converter register
CInterrupt mask register
DPrescaler and reload value
✗ Incorrect
Prescaler and reload values control the timing interval of the watchdog timer.
Explain how to configure a watchdog timer timeout in embedded C.
Think about how hardware timers use clock division and reload values to set time intervals.
You got /4 concepts.
Describe what happens if the watchdog timer is not reset before the timeout expires.
Consider why watchdog timers exist in embedded systems.
You got /4 concepts.
Practice
(1/5)
1.
What is the main purpose of configuring a watchdog timer's timeout in embedded C?
easy
A. To enable debugging messages
B. To increase the CPU clock speed
C. To set how long the system waits before resetting if it hangs
D. To allocate memory for variables
Solution
Step 1: Understand watchdog timer role
The watchdog timer resets the system if it stops responding.
Step 2: Identify timeout configuration purpose
Timeout sets the wait time before reset triggers.
Final Answer:
To set how long the system waits before resetting if it hangs -> Option C
Quick Check:
Watchdog timeout = reset delay [OK]
Hint: Timeout controls reset delay after hang [OK]
Common Mistakes:
Confusing timeout with CPU speed
Thinking timeout allocates memory
Assuming timeout enables debugging
2.
Which of the following is the correct syntax to set a watchdog timeout to 5000 milliseconds in embedded C?
void setup_watchdog() {
// Set timeout here
}
easy
A. WDT_SetTimeout(5000);
B. WDT_SetTimeoutMs(5000);
C. watchdog.timeout = 5000;
D. set_watchdog(5000);
Solution
Step 1: Identify common watchdog API
Many embedded C libraries use WDT_SetTimeoutMs() to set timeout in ms.
Step 2: Check syntax correctness
WDT_SetTimeoutMs(5000); correctly sets 5000 ms timeout.
Final Answer:
WDT_SetTimeoutMs(5000); -> Option B
Quick Check:
Correct function name with ms unit [OK]
Hint: Look for function with 'TimeoutMs' for milliseconds [OK]
Common Mistakes:
Using incorrect function names
Assigning timeout to struct without function
Using generic function names not in API
3.
Given the code below, what will be the watchdog timeout value after execution?
typedef struct {
unsigned int timeout_ms;
} Watchdog;
Watchdog wdt;
void configure_watchdog(unsigned int t) {
wdt.timeout_ms = t;
}
int main() {
configure_watchdog(3000);
configure_watchdog(7000);
return wdt.timeout_ms;
}
medium
A. 7000
B. 3000
C. 0
D. Compilation error
Solution
Step 1: Trace function calls
First call sets timeout_ms to 3000, second call overwrites it to 7000.
Step 2: Check return value
Main returns wdt.timeout_ms, which is 7000 after second call.
Final Answer:
7000 -> Option A
Quick Check:
Last set timeout = 7000 [OK]
Hint: Last assignment overwrites previous timeout [OK]
Common Mistakes:
Assuming first call value remains
Confusing return value with function return
Thinking timeout resets automatically
4.
Identify the error in the following watchdog timeout configuration code:
You want to configure a watchdog timer that resets the system if it hangs for more than 10 seconds, but also want to avoid false resets during long processing tasks. Which approach is best?
hard
A. Set timeout to 20 seconds and never reset watchdog
B. Set timeout to 1 second to catch hangs quickly
C. Disable watchdog during long tasks
D. Set timeout to 10 seconds and reset watchdog regularly during long tasks
Solution
Step 1: Understand watchdog timeout role
Timeout defines max hang time before reset; too short causes false resets.
Step 2: Balance timeout and reset calls
Setting 10 seconds timeout and resetting watchdog during long tasks avoids false resets.
Final Answer:
Set timeout to 10 seconds and reset watchdog regularly during long tasks -> Option D