0
0
Embedded Cprogramming~10 mins

Why interrupts are needed 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 define an interrupt service routine (ISR) function.

Embedded C
void [1]() {
    // ISR code here
}
Drag options to blanks, or click blank then click option'
AISR_Handler
Bmain
Cloop
Dsetup
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'main' or 'loop' as ISR function name.
2fill in blank
medium

Complete the code to enable global interrupts in the microcontroller.

Embedded C
sei(); // [1] interrupts
Drag options to blanks, or click blank then click option'
Areset
Bdisable
Cignore
Denable
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing enable with disable or reset.
3fill in blank
hard

Fix the error in the code to correctly declare an ISR for timer overflow.

Embedded C
ISR([1]) {
    // Timer overflow code
}
Drag options to blanks, or click blank then click option'
Atimer_interrupt
BTIMER0_OVF_vect
Cmain
Doverflow_handler
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic or incorrect names like 'main' or 'timer_interrupt'.
4fill in blank
hard

Fill both blanks to create a dictionary that maps interrupt names to their priority levels.

Embedded C
const int interrupt_priority[] = {
    [[1]] = 1,
    [[2]] = 2
};
Drag options to blanks, or click blank then click option'
ATIMER0_OVF_vect
BUSART_RX_vect
CADC_vect
DINT0_vect
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid or duplicate interrupt names.
5fill in blank
hard

Fill all three blanks to complete the code that checks if an interrupt flag is set and clears it.

Embedded C
if ([1] & (1 << [2])) {
    [3] |= (1 << [2]); // Clear flag
}
Drag options to blanks, or click blank then click option'
ATIFR
BTOV0
DTIMSK
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong registers or bits to check or clear flags.