What is an interrupt vector table in embedded systems?
It is a special table in memory that holds addresses of interrupt service routines (ISRs). When an interrupt happens, the processor uses this table to find and run the correct ISR.
Click to reveal answer
beginner
How does the processor use the interrupt vector table?
When an interrupt occurs, the processor looks up the interrupt number in the vector table to get the address of the ISR, then jumps to that address to handle the interrupt.
Click to reveal answer
intermediate
Why is the interrupt vector table usually placed at a fixed memory location?
Because the processor expects the table at a known address to quickly find ISRs without searching, making interrupt handling fast and reliable.
Click to reveal answer
intermediate
In C, how do you typically define an interrupt vector table?
You create an array of function pointers where each pointer points to an ISR. This array is placed at the fixed memory address the processor expects.
Click to reveal answer
advanced
What happens if an interrupt occurs but its vector table entry points to a null or wrong address?
The processor may jump to an invalid location causing a crash or undefined behavior, so every interrupt vector must point to a valid ISR or a default handler.
Click to reveal answer
What does the interrupt vector table store?
AData values for interrupts
BMemory addresses of variables
CProcessor status flags
DAddresses of interrupt service routines
✗ Incorrect
The interrupt vector table stores addresses of ISRs to handle interrupts.
Where is the interrupt vector table usually located?
AAt a fixed memory address
BRandom memory location
CInside the CPU registers
DIn external storage
✗ Incorrect
It is placed at a fixed memory address so the processor can find it quickly.
What is the role of the interrupt vector table when an interrupt occurs?
ATo disable all interrupts
BTo find the ISR address and jump to it
CTo reset the processor
DTo store interrupt data
✗ Incorrect
The processor uses the table to find the ISR address and execute it.
In embedded C, how is the interrupt vector table commonly implemented?
AAs an array of function pointers
BAs a linked list
CAs a string array
DAs a set of variables
✗ Incorrect
An array of function pointers points to ISRs for each interrupt.
What can happen if an interrupt vector points to an invalid address?
AProcessor resets automatically
BInterrupt is ignored safely
CProcessor may crash or behave unpredictably
DInterrupt is handled by default
✗ Incorrect
Jumping to an invalid address can cause a crash or undefined behavior.
Explain what an interrupt vector table is and why it is important in embedded systems.
Think about how the processor finds the right code to run when an interrupt happens.
You got /3 concepts.
Describe how you would implement an interrupt vector table in embedded C.
Consider how C handles functions and memory layout.
You got /4 concepts.
Practice
(1/5)
1.
What is the main purpose of an interrupt vector table in embedded C programming?
easy
A. To store global variables for the program
B. To link interrupt events to their handler functions
C. To manage memory allocation dynamically
D. To perform arithmetic operations automatically
Solution
Step 1: Understand the role of interrupt vector table
The interrupt vector table is a special array that holds addresses of interrupt handler functions.
Step 2: Identify its purpose in program flow
When an interrupt occurs, the processor uses this table to jump to the correct handler automatically.
Final Answer:
To link interrupt events to their handler functions -> Option B
Quick Check:
Interrupt vector table = links interrupts to handlers [OK]
Hint: Interrupt vector table connects interrupts to handlers [OK]
Common Mistakes:
Thinking it stores variables
Confusing with memory management
Assuming it performs calculations
2.
Which of the following is the correct way to declare an interrupt vector table as an array of function pointers in embedded C?
void (*interrupt_vector_table[])(void) = {
easy
A. void interrupt_vector_table(void) = {handler1, handler2};
B. int interrupt_vector_table[] = {handler1, handler2};
C. void (*interrupt_vector_table[])(void) = {handler1, handler2};
D. void *interrupt_vector_table = {handler1, handler2};
Solution
Step 1: Recognize function pointer array syntax
Function pointers to void functions with no parameters are declared as void (*name[])(void).
Step 2: Match declaration with initialization
void (*interrupt_vector_table[])(void) = {handler1, handler2}; correctly declares an array of such pointers and initializes it with handler functions.
Final Answer:
void (*interrupt_vector_table[])(void) = {handler1, handler2}; -> Option C
A. Index 2 is out of bounds, causing undefined behavior
B. handlerB is not a valid function pointer
C. interrupt_vector_table must be declared as int array
D. No problem, code runs fine
Solution
Step 1: Check the size of interrupt_vector_table
The array has 2 elements at indices 0 and 1 only.
Step 2: Analyze the call to interrupt_vector_table[2]()
Index 2 is outside the array bounds, leading to undefined behavior or crash.
Final Answer:
Index 2 is out of bounds, causing undefined behavior -> Option A
Quick Check:
Accessing beyond array size = out of bounds error [OK]
Hint: Array indices start at 0; index 2 is invalid here [OK]
Common Mistakes:
Assuming array auto-expands
Thinking handlerB is invalid
Ignoring out-of-bounds errors
5.
You want to add a new interrupt handler handler2 to an existing vector table with 2 handlers. Which is the correct way to update the vector table to include handler2 at index 2?