The vector table structure helps the processor know where to jump when an interrupt or exception happens. It organizes addresses for handling different events.
Vector table structure in ARM Architecture
Vector Table: - Entry 0: Initial Stack Pointer - Entry 1: Reset Handler Address - Entry 2: NMI Handler Address - Entry 3: HardFault Handler Address - ... - Other exception and interrupt handler addresses
The vector table is usually placed at a fixed memory address, often at the start of the memory.
Each entry is a 32-bit address pointing to the start of a handler function.
0x00000000: 0x20002000 ; Initial Stack Pointer 0x00000004: 0x00001000 ; Reset Handler 0x00000008: 0x00001010 ; NMI Handler 0x0000000C: 0x00001020 ; HardFault Handler
Vector Table in C: void (* const vector_table[])(void) __attribute__((section(".isr_vector"))) = { (void (*)(void))((unsigned long)&_estack), Reset_Handler, NMI_Handler, HardFault_Handler, // Other handlers };
This program defines a simple vector table with initial stack pointer and three handlers. The vector table is placed in a special memory section so the processor can find it at startup.
# Example vector table entries in C #include <stdint.h> extern uint32_t _estack; void Reset_Handler(void) { // Reset code here } void NMI_Handler(void) { // NMI code here } void HardFault_Handler(void) { // HardFault code here } void (* const vector_table[])(void) __attribute__((section(".isr_vector"))) = { (void (*)(void))&_estack, // Initial Stack Pointer Reset_Handler, // Reset Handler NMI_Handler, // NMI Handler HardFault_Handler // HardFault Handler }; int main() { // Main program return 0; }
The first entry is not a function but the initial stack pointer value.
Each following entry is the address of a function that handles a specific interrupt or exception.
The vector table must be aligned and placed at the correct memory address for the processor to use it properly.
The vector table organizes addresses for interrupt and exception handlers.
The first entry is the initial stack pointer, followed by handler addresses.
It is essential for the processor to know where to jump when events occur.
Practice
Solution
Step 1: Understand vector table structure
The ARM vector table begins with the initial stack pointer value to set up the stack.Step 2: Identify the first entry
The first entry is the initial stack pointer address, followed by the reset handler address.Final Answer:
Initial stack pointer address -> Option CQuick Check:
First entry = Initial stack pointer address [OK]
- Confusing reset handler as first entry
- Thinking program counter is first
- Assuming interrupt routine is first
Solution
Step 1: Recall vector table order
The first entry is the initial stack pointer, so the second entry is the reset handler.Step 2: Confirm second entry role
The reset handler is the address where the processor starts executing after reset.Final Answer:
Reset handler address -> Option AQuick Check:
Second entry = Reset handler address [OK]
- Mixing up with interrupt handlers
- Choosing stack pointer again
- Confusing with exception handlers
0x00000000: 0x20001000 (Initial SP)
0x00000004: 0x00001005 (Reset Handler)
0x00000008: 0x00001010 (NMI Handler)
0x0000000C: 0x00001020 (HardFault Handler)
Which address will the processor jump to on a HardFault exception?
Solution
Step 1: Locate HardFault entry in vector table
The HardFault handler address is at offset 0x0C in the vector table.Step 2: Identify the address at 0x0000000C
The address at 0x0000000C is 0x00001020, which is the HardFault handler.Final Answer:
0x00001020 -> Option DQuick Check:
HardFault handler = 0x00001020 [OK]
- Choosing reset handler address
- Confusing NMI and HardFault handlers
- Selecting initial stack pointer
Solution
Step 1: Understand role of first vector entry
The first entry sets the initial stack pointer address for the processor.Step 2: Analyze effect of setting it to zero
Setting it to 0x00000000 means the stack pointer points to an invalid memory location, causing a crash.Final Answer:
Stack pointer will be invalid causing a crash -> Option AQuick Check:
Invalid stack pointer = Crash [OK]
- Thinking reset handler won't run
- Assuming interrupts are disabled
- Believing processor resets normally
Solution
Step 1: Understand vector table layout
The vector table has fixed slots for each exception and interrupt type.Step 2: Identify correct slot for custom interrupt
Custom peripheral interrupts must be placed at their assigned interrupt vector slot, not at stack pointer or reset handler entries.Final Answer:
At the specific interrupt vector slot assigned to that peripheral -> Option BQuick Check:
Custom handler = Assigned interrupt vector slot [OK]
- Replacing stack pointer or reset handler
- Appending handler at vector table end
- Ignoring fixed vector slot assignments
Ready to prove it?
Pass the test and this pattern moves unknown
