Bird
Raised Fist0
ARM Architectureknowledge~20 mins

NVIC (Nested Vectored Interrupt Controller) in ARM Architecture - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
NVIC Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding NVIC Priority Grouping

What does the priority grouping in NVIC control?

AIt controls how many bits are used for pre-emption priority and how many for subpriority.
BIt sets the total number of interrupts the NVIC can handle.
CIt determines the clock speed of the NVIC module.
DIt enables or disables the nested interrupt feature.
Attempts:
2 left
💡 Hint

Think about how NVIC decides which interrupt is more important when multiple occur.

📋 Factual
intermediate
2:00remaining
NVIC Interrupt Enable Registers

Which NVIC register is used to enable a specific interrupt?

ANVIC_STIR (Software Trigger Interrupt Register)
BNVIC_ICER (Interrupt Clear-Enable Register)
CNVIC_IPR (Interrupt Priority Register)
DNVIC_ISER (Interrupt Set-Enable Register)
Attempts:
2 left
💡 Hint

Look for the register that sets bits to enable interrupts.

🔍 Analysis
advanced
2:00remaining
NVIC Behavior on Nested Interrupts

Given two interrupts with different pre-emption priorities, what happens when both occur simultaneously?

AThe interrupt with lower pre-emption priority executes first.
BBoth interrupts execute simultaneously in parallel.
CThe interrupt with higher pre-emption priority executes first and can pre-empt the other.
DThe NVIC disables both interrupts to avoid conflict.
Attempts:
2 left
💡 Hint

Consider how NVIC prioritizes interrupts based on priority levels.

❓ Comparison
advanced
2:00remaining
Difference Between NVIC and Traditional Interrupt Controllers

Which feature distinguishes the NVIC from traditional interrupt controllers?

ANVIC does not support interrupt masking or disabling.
BNVIC supports dynamic priority levels and nested interrupts with hardware support.
CNVIC requires software to manually save and restore context for interrupts.
DNVIC can only handle one interrupt at a time without nesting.
Attempts:
2 left
💡 Hint

Think about how NVIC improves interrupt handling efficiency.

❓ Reasoning
expert
2:00remaining
Effect of Incorrect Priority Configuration in NVIC

If all interrupts are configured with the same pre-emption priority but different subpriorities, what is the effect on interrupt handling?

ANo interrupt can pre-empt another; subpriority only decides order when interrupts are pending simultaneously.
BInterrupts with higher subpriority will pre-empt those with lower subpriority.
CNVIC will treat all interrupts as having different pre-emption priorities ignoring subpriority.
DNVIC disables all interrupts due to priority conflict.
Attempts:
2 left
💡 Hint

Recall the role of pre-emption priority versus subpriority in NVIC.

Practice

(1/5)
1. What is the main purpose of the NVIC in ARM microcontrollers?
easy
A. To increase the clock speed of the processor
B. To manage and prioritize multiple interrupts efficiently
C. To store program instructions
D. To handle memory allocation

Solution

  1. Step 1: Understand NVIC's role

    NVIC stands for Nested Vectored Interrupt Controller, which manages interrupts.
  2. Step 2: Identify its main function

    It enables, disables, and prioritizes interrupts so the processor can respond quickly to important events.
  3. Final Answer:

    To manage and prioritize multiple interrupts efficiently -> Option B
  4. Quick Check:

    NVIC controls interrupts = B [OK]
Hint: NVIC is about interrupt control, not speed or memory [OK]
Common Mistakes:
  • Confusing NVIC with clock or memory functions
  • Thinking NVIC stores program code
  • Assuming NVIC increases processor speed
2. Which of the following is the correct way to enable an interrupt using NVIC in ARM Cortex-M?
easy
A. NVIC_SetPriority(IRQn, priority);
B. NVIC_DisableIRQ(IRQn);
C. NVIC_EnableIRQ(IRQn);
D. NVIC_ClearPendingIRQ(IRQn);

Solution

  1. Step 1: Identify function purpose

    NVIC_EnableIRQ is used to enable a specific interrupt request (IRQ).
  2. Step 2: Compare other options

    NVIC_DisableIRQ disables interrupts, NVIC_SetPriority sets priority, NVIC_ClearPendingIRQ clears pending interrupts.
  3. Final Answer:

    NVIC_EnableIRQ(IRQn); -> Option C
  4. Quick Check:

    Enable interrupt function = NVIC_EnableIRQ [OK]
Hint: Enable interrupts with NVIC_EnableIRQ function [OK]
Common Mistakes:
  • Confusing enable with disable functions
  • Mixing priority setting with enabling
  • Using clear pending instead of enable
3. Consider the following code snippet for ARM Cortex-M NVIC:
NVIC_SetPriority(TIM2_IRQn, 2);
NVIC_EnableIRQ(TIM2_IRQn);
NVIC_SetPriority(USART1_IRQn, 1);
NVIC_EnableIRQ(USART1_IRQn);
Which interrupt has higher priority?
medium
A. USART1_IRQn has higher priority
B. TIM2_IRQn has higher priority
C. Both have equal priority
D. Priority cannot be determined

Solution

  1. Step 1: Understand priority values

    Lower numeric priority value means higher priority in NVIC.
  2. Step 2: Compare priorities set

    TIM2_IRQn is set to 2, USART1_IRQn is set to 1, so USART1_IRQn has higher priority.
  3. Final Answer:

    USART1_IRQn has higher priority -> Option A
  4. Quick Check:

    Lower number = higher priority = USART1_IRQn [OK]
Hint: Lower priority number means higher priority [OK]
Common Mistakes:
  • Assuming higher number means higher priority
  • Ignoring priority values and focusing on enable order
  • Confusing IRQ names
4. A developer wrote this code to disable an interrupt but it does not work as expected:
NVIC_EnableIRQ(EXTI0_IRQn);
NVIC_DisableIRQ(EXTI1_IRQn);
What is the likely mistake?
medium
A. The priority must be set before disabling
B. NVIC_DisableIRQ cannot disable interrupts
C. Interrupts must be disabled before enabling
D. They enabled EXTI0_IRQn but disabled EXTI1_IRQn instead

Solution

  1. Step 1: Analyze the code

    The code enables EXTI0_IRQn but disables EXTI1_IRQn, which are different interrupts.
  2. Step 2: Identify the mistake

    If the goal was to disable EXTI0_IRQn, disabling EXTI1_IRQn is incorrect.
  3. Final Answer:

    They enabled EXTI0_IRQn but disabled EXTI1_IRQn instead -> Option D
  4. Quick Check:

    Mismatch in IRQ numbers = mistake [OK]
Hint: Check IRQ names carefully when enabling/disabling [OK]
Common Mistakes:
  • Disabling wrong interrupt number
  • Believing disable function doesn't work
  • Thinking priority affects disabling
5. You want to ensure that a critical sensor interrupt always preempts a less important communication interrupt. How should you configure NVIC priorities for SENSOR_IRQn and COMM_IRQn?
hard
A. Set SENSOR_IRQn priority lower than COMM_IRQn (e.g., SENSOR=0, COMM=1)
B. Set SENSOR_IRQn priority higher than COMM_IRQn (e.g., SENSOR=2, COMM=1)
C. Disable COMM_IRQn and enable SENSOR_IRQn only
D. Set both priorities equal and enable both

Solution

  1. Step 1: Recall NVIC priority rules

    Lower numeric priority means higher priority and can preempt others.
  2. Step 2: Apply to SENSOR and COMM interrupts

    To let SENSOR_IRQn preempt COMM_IRQn, SENSOR_IRQn must have a lower priority number.
  3. Final Answer:

    Set SENSOR_IRQn priority lower than COMM_IRQn (e.g., SENSOR=0, COMM=1) -> Option A
  4. Quick Check:

    Lower number = higher priority = SENSOR_IRQn preempts [OK]
Hint: Lower priority number means higher interrupt priority [OK]
Common Mistakes:
  • Assigning higher number for higher priority
  • Disabling interrupts instead of prioritizing
  • Setting equal priorities expecting preemption
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard