The Interrupt Handling Structure of a Microcontroller (MCU) is a mechanism that allows the
MCU to temporarily suspend its normal execution of instructions and respond to high-priority
events or interrupts..
Interrupt Handling Structure :
Interrupt Handling Structure
1. Identification of Interrupt Source:
● Interrupt Request (IRQ): When a peripheral or external event occurs, it generates an
interrupt request signal to the MCU.
● Interrupt Controller: The MCU has an interrupt controller that receives and processes
these IRQs.
● Interrupt Source Identification: The interrupt controller identifies the specific source of
the interrupt based on the unique vector associated with each source.
2. Enabling and Masking of Interrupts:
● Interrupt Enable/Disable: Each interrupt source can be individually enabled or
disabled. This allows the MCU to selectively respond to specific interrupts while
ignoring others.
● Primary Level (All): This level provides a global enable/disable mechanism for all
interrupt sources. Disabling at this level disables all interrupts.
● Secondary Level (Individual): This level allows for individual enable/disable of
specific interrupt sources.
3. Finding Vector Address for CPU to Vector for ISR:
● Vector Table: The MCU has a vector table that contains addresses of the Interrupt
Service Routines (ISRs) for each interrupt source.
● Vector Address: The interrupt controller uses the identified interrupt source to locate
the corresponding vector address in the vector table.
● ISR Address: The vector address points to the memory location where the ISR code
for that specific interrupt is stored.
4. Vector to ISR Address:
● Vector to ISR Address: The vector address fetched from the vector table is used to
load the Program Counter (PC) with the starting address of the ISR code.
● Interrupt Service Routine (ISR): The ISR is a dedicated piece of code that handles
the specific event or condition that triggered the interrupt. It typically performs the
necessary actions to service the interrupt and then returns control back to the main
program.
5. Priority Assignment:
● Default Priority: On reset, the MCU may have a default priority level assigned to each
interrupt source. This determines the order in which interrupts are serviced if multiple
interrupts occur simultaneously.
● User-Assigned Priority: The user can override the default priority levels to customize
the interrupt handling behavior according to their application needs. application
needs.
A data transfer instruction is a type of instruction that moves data from one
location to another within a computer system, such as:
1. MOV (Move Data)
● Function: Copies data from a source operand to a destination operand without
changing the source.
● Operands: Can be registers, immediate values, or memory locations.
● Example: MOV A, #25H
○ This copies the immediate value 25H into the accumulator (A).
2. MOVC (Move Code Memory)
● Function: Moves data from program memory (code memory) to the accumulator
using an index (DPTR or PC).
● Purpose: Primarily used to retrieve constants stored in program memory.
● Example: MOVC A, @A+DPTR
○ This moves the value from the program memory location (DPTR + A) into
the accumulator.
3. MOVX (Move External Data)
● Function: Moves data between external memory (RAM) and the accumulator using
the DPTR or R0/R1 as a pointer.
● Purpose: Used to interface with external data memory.
● Example: MOVX A, @DPTR
○ This reads data from an external memory location (pointed by DPTR) into the
accumulator.
4. PUSH (Push onto Stack)
● Function: Saves a byte of data from a register or memory onto the stack and
increments the stack pointer.
● Example: PUSH 0E0H
○ This pushes the accumulator’s value onto the stack.
5. POP (Pop from Stack)
● Function: Retrieves a byte of data from the stack and places it into a specified
register or memory location. The stack pointer is decremented.
● Example: POP 0E0H
○ This pops a value from the stack into the accumulator.
6. XCH (Exchange Data)
● Function: Exchanges the data between the accumulator and another specified
register or memory location. The values are swapped.
● Example: XCH A, R1
○ This swaps the value of the accumulator with the value in register R1.
Instruction Summary Table:
Instruction Function Syntax Example
MOV Move data between MOV dest, src MOV A, #25H
registers/memory
MOVC Move data from MOVC A, @A+DPTR MOVC A, @A+DPTR
code memory to A
MOVX Move data from MOVX dest, src MOVX A, @DPTR
external memory to
A
PUSH Push data onto PUSH direct PUSH 40H
stack
POP Pop data from stack POP direct POP 40H
XCH Exchange data XCH A, src XCH A, R0
between A and
another