0
0
Embedded Cprogramming~10 mins

Why power management matters in Embedded C - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the microcontroller to sleep mode.

Embedded C
MCUCR = (1 << [1]);
Drag options to blanks, or click blank then click option'
ASM1
BSE
CSM0
DSM2
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong bit like SE instead of SM1.
Confusing SM bits with SE bit.
2fill in blank
medium

Complete the code to enable sleep mode by setting the sleep enable bit.

Embedded C
MCUCR |= (1 << [1]);
Drag options to blanks, or click blank then click option'
ASM0
BSM1
CSE
DSM2
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the wrong bit like SM0 instead of SE.
Not using bitwise OR to set the bit.
3fill in blank
hard

Fix the error in the code to correctly put the MCU to sleep.

Embedded C
sleep_cpu();
MCUCR &= ~(1 << [1]);
Drag options to blanks, or click blank then click option'
ASM1
BSM0
CSM2
DSE
Attempts:
3 left
💡 Hint
Common Mistakes
Clearing the wrong bit like SM0 instead of SE.
Not clearing the bit after waking up.
4fill in blank
hard

Fill both blanks to create a dictionary of power modes and their descriptions.

Embedded C
const char* power_modes[] = {"Idle", "Power-down", "Power-save", "Standby"};
const char* descriptions[] = {"CPU stopped", "Most devices off", "Timer running", [1];

const char* mode = power_modes[2];
const char* desc = descriptions[[2]];
Drag options to blanks, or click blank then click option'
A"Lowest power mode"
B"Timer running"
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong index for descriptions array.
Mixing descriptions for different power modes.
5fill in blank
hard

Fill all three blanks to complete the function that configures and enters sleep mode.

Embedded C
void enter_sleep_mode() {
    MCUCR = (1 << [1]); // Set sleep mode
    MCUCR |= (1 << [2]); // Enable sleep
    [3](); // Enter sleep
    MCUCR &= ~(1 << [2]); // Disable sleep after wakeup
}
Drag options to blanks, or click blank then click option'
ASM1
BSE
Csleep_cpu
DSM0
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong bits for sleep mode selection.
Forgetting to disable sleep after waking.
Not calling the correct function to enter sleep.