A wake-up source is a hardware or software event that brings the microcontroller out of a low-power or sleep mode to resume normal operation.
Click to reveal answer
beginner
Name three common wake-up sources in microcontrollers.
Common wake-up sources include external interrupts (like a button press), timers (RTC alarms), and communication peripherals (UART, I2C activity).
Click to reveal answer
intermediate
How do you typically configure an external interrupt as a wake-up source in embedded C?
You enable the interrupt line, configure its trigger condition (rising/falling edge), and enable the microcontroller's wake-up capability on that interrupt line.
Click to reveal answer
beginner
Why is it important to configure wake-up sources correctly?
Correct configuration ensures the device wakes up only on intended events, saving power and avoiding unwanted wake-ups that drain battery.
Click to reveal answer
intermediate
Show a simple embedded C code snippet to enable a timer as a wake-up source.
// Enable timer interrupt as wake-up source
Timer_EnableInterrupt();
Power_EnableWakeupSource(TIMER_INTERRUPT);
Power_EnterSleepMode();
Click to reveal answer
Which of the following can be a wake-up source in embedded systems?
AExternal interrupt
BRandom number generator
CDisplay refresh
DInternal temperature sensor reading
✗ Incorrect
External interrupts are common wake-up sources because they signal an event from outside the microcontroller.
What is the main purpose of configuring wake-up sources?
ATo save power by waking up only on specific events
BTo increase CPU speed
CTo disable interrupts
DTo reset the microcontroller
✗ Incorrect
Wake-up sources help the device save power by waking only when needed.
Which trigger condition is commonly used for an external interrupt wake-up?
AConstant high level
BRising edge
CNo trigger
DTimer overflow
✗ Incorrect
Rising edge triggers when the signal changes from low to high, commonly used for interrupts.
What happens if no wake-up source is configured before entering sleep mode?
AThe device speeds up
BThe device wakes up immediately
CThe device resets
DThe device may never wake up automatically
✗ Incorrect
Without a wake-up source, the device stays in sleep mode indefinitely.
Which function might you call to enable a wake-up source in embedded C?
AUART_Close()
BTimer_Disable()
CPower_EnableWakeupSource()
DGPIO_SetLow()
✗ Incorrect
Power_EnableWakeupSource() is typically used to enable a specific wake-up source.
Explain what a wake-up source is and why it is important in embedded systems.
Think about how devices save battery by sleeping and waking only when needed.
You got /3 concepts.
Describe the steps to configure an external interrupt as a wake-up source in embedded C.
Consider how you prepare the microcontroller to listen for an event before sleeping.
You got /4 concepts.
Practice
(1/5)
1. Which of the following is a common wake-up source in embedded C devices?
easy
A. GPIO pin interrupt
B. Floating point calculation
C. String concatenation
D. File system read
Solution
Step 1: Understand wake-up sources
Wake-up sources are hardware events that can wake a device from sleep mode, such as GPIO interrupts or timers.
Step 2: Identify valid wake-up sources
GPIO pin interrupts are commonly used as wake-up sources because they detect external signals.
Final Answer:
GPIO pin interrupt -> Option A
Quick Check:
Wake-up source = GPIO pin interrupt [OK]
Hint: Wake-up sources are hardware events like GPIO or timers [OK]
Common Mistakes:
Confusing software operations with hardware wake-up sources
Thinking file operations can wake embedded devices
Assuming calculations can trigger wake-up
2. Which syntax correctly enables a GPIO pin as a wake-up source in embedded C?
easy
A. enable_wakeup(GPIO_PIN_5);
B. GPIO_WAKEUP_ENABLE(5);
C. wakeup_enable(GPIO5);
D. set_wakeup_pin(5);
Solution
Step 1: Recognize common embedded C macros
Macros often use uppercase and underscores, like GPIO_WAKEUP_ENABLE(pin).
Step 2: Match syntax style
GPIO_WAKEUP_ENABLE(5); matches typical embedded C macro style for enabling wake-up on GPIO pin 5.
Final Answer:
GPIO_WAKEUP_ENABLE(5); -> Option B
Quick Check:
Macro style = GPIO_WAKEUP_ENABLE(5) [OK]
Hint: Look for uppercase macro style for hardware config [OK]
Common Mistakes:
Using lowercase function names not defined in embedded C
Confusing parameter formats
Missing parentheses or semicolons
3. What will be the output of the following code snippet?
void configure_wakeup() {
WAKEUP_ENABLE_TIMER(1000); // 1000 ms
WAKEUP_ENABLE_GPIO(3);
}
int main() {
configure_wakeup();
if (is_wakeup_source(GPIO_3)) {
printf("Wakeup by GPIO 3\n");
} else if (is_wakeup_source(TIMER)) {
printf("Wakeup by Timer\n");
} else {
printf("No wakeup source\n");
}
return 0;
}
medium
A. Wakeup by GPIO 3
B. Wakeup by Timer
C. No wakeup source
D. Compilation error
Solution
Step 1: Analyze function and macros usage
The code uses WAKEUP_ENABLE_TIMER and WAKEUP_ENABLE_GPIO macros but does not define or include them, causing compilation errors.
Step 2: Check function calls and conditions
Functions like is_wakeup_source and constants GPIO_3, TIMER are undefined, leading to compilation failure.
Final Answer:
Compilation error -> Option D
Quick Check:
Undefined macros/functions cause compilation error [OK]
Hint: Undefined macros or functions cause compile errors [OK]
Common Mistakes:
Assuming macros are predefined without headers
Ignoring missing function definitions
Confusing runtime output with compile errors
4. Identify the error in this wake-up source configuration code:
The code enables GPIO pin 2 twice, which can cause conflicts or redundant configuration.
Step 2: Check timer configuration and function structure
Timer value 500 ms is valid; no return needed for void function.
Final Answer:
Duplicate GPIO wake-up enable causes conflict -> Option A
Quick Check:
Duplicate GPIO enable = conflict [OK]
Hint: Avoid enabling same GPIO wake-up twice [OK]
Common Mistakes:
Thinking timer value is invalid
Expecting return in void function
Ignoring duplicate hardware config issues
5. You want to configure a device to wake up either by GPIO pin 4 or after 2 seconds using a timer. Which code snippet correctly sets both wake-up sources?
hard
A. WAKEUP_CONFIG(GPIO4 | TIMER_2S);
B. WAKEUP_ENABLE_TIMER(2);
WAKEUP_ENABLE_GPIO(4);
C. WAKEUP_ENABLE_GPIO(4);
WAKEUP_ENABLE_TIMER(2000);
D. WAKEUP_ENABLE_GPIO(4, 2000);
Solution
Step 1: Understand separate wake-up source configuration
GPIO and timer wake-up sources are usually enabled with separate calls specifying pin and time in milliseconds.
Step 2: Evaluate options for correctness
WAKEUP_ENABLE_GPIO(4);
WAKEUP_ENABLE_TIMER(2000); correctly enables GPIO pin 4 and timer with 2000 ms (2 seconds). WAKEUP_ENABLE_TIMER(2);
WAKEUP_ENABLE_GPIO(4); uses 2 (seconds) instead of milliseconds. WAKEUP_ENABLE_GPIO(4, 2000); incorrectly combines parameters. WAKEUP_CONFIG(GPIO4 | TIMER_2S); uses an undefined macro.
Final Answer:
WAKEUP_ENABLE_GPIO(4);
WAKEUP_ENABLE_TIMER(2000); -> Option C
Quick Check:
Separate calls with correct units = WAKEUP_ENABLE_GPIO(4);
WAKEUP_ENABLE_TIMER(2000); [OK]
Hint: Enable GPIO and timer separately with correct units [OK]
Common Mistakes:
Using seconds instead of milliseconds for timer
Combining GPIO and timer in one call
Using undefined macros
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.