0
0
Embedded Cprogramming~10 mins

Interrupt priority levels in Embedded C - Interactive Code Practice

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

Complete the code to set the priority level of an interrupt to 3.

Embedded C
NVIC_SetPriority(IRQn, [1]);
Drag options to blanks, or click blank then click option'
A3
B0
C5
D7
Attempts:
3 left
💡 Hint
Common Mistakes
Using a priority level outside the allowed range.
Confusing priority number with interrupt number.
2fill in blank
medium

Complete the code to enable the interrupt with IRQ number 10.

Embedded C
NVIC_EnableIRQ([1]);
Drag options to blanks, or click blank then click option'
A5
B10
C3
D15
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong IRQ number.
Confusing IRQ number with priority level.
3fill in blank
hard

Fix the error in setting the priority level to the highest priority (0).

Embedded C
NVIC_SetPriority(IRQn, [1]);
Drag options to blanks, or click blank then click option'
A0
B3
C1
D7
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-zero number for highest priority.
Confusing priority levels with IRQ numbers.
4fill in blank
hard

Fill both blanks to create a dictionary mapping IRQ numbers to priority levels for IRQ 2 and IRQ 4.

Embedded C
const uint8_t irq_priorities[] = { [[1]] = 1, [[2]] = 3 };
Drag options to blanks, or click blank then click option'
A2
B1
C4
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping IRQ numbers and priority values.
Using invalid IRQ numbers.
5fill in blank
hard

Fill all three blanks to set priority 2 for IRQ 5, enable IRQ 5, and set priority 0 for IRQ 7.

Embedded C
NVIC_SetPriority([1], 2);
NVIC_EnableIRQ([2]);
NVIC_SetPriority([3], 0);
Drag options to blanks, or click blank then click option'
A5
B7
C3
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing IRQ numbers between calls.
Setting wrong priority levels.