. This is the first code the MCU executes upon power-up. System Exceptions: Addresses for handlers that manage internal errors like Hard Faults, usage faults, or Non-Maskable Interrupts (NMI). Peripheral Interrupts: Addresses for Interrupt Service Routines (ISRs) triggered by hardware like timers, UART, or GPIO pins. Medium +5 How it Works (The Fetch Mechanism) When an interrupt occurs, the microcontroller follows these automated hardware steps: Context Saving: The CPU automatically pushes current registers (like PC and PSR) onto the stack to save the state of the running program. Vector Lookup: The hardware uses the interrupt's unique ID to calculate an offset into the vector table (e.g., 𝐼
The vector table would contain a list of addresses like this: what is vector table in microcontroller
It separates the "what happened" (hardware signal) from the "how to handle it" (your software code). By default, the vector table sits at address 0x0000_0000
By default, the vector table sits at address 0x0000_0000 . However, in complex systems, developers use a feature called the to move the table to a different location in Flash or even into RAM (for faster execution). in complex systems
| Interrupt | Vector Address | | --- | --- | | Timer 0 overflow | 0x1000 | | External interrupt 0 | 0x1004 | | Serial receive interrupt | 0x1008 | | Timer 1 overflow | 0x100C |
Imagine you are writing code for a microwave oven using a microcontroller. You have a button connected to an external interrupt pin.
Here is how it might look in a linker script or startup file. The __attribute__((section(".vectors"))) ensures this array is placed at address 0x00000000 .