MC Module-4 Notes
MC Module-4 Notes
MODULE-4
Page 1 of 10
Module 4 2
Whenever an exception occurs, the core enter a specific mode. The ARM
processor modes can be entered manually by changing the cpsr.
When an exception occurs the ARM processor always switches to ARM
state. Figure 4.1 shows an exceptions and associated modes.
Page 2 of 10
Module 4 3
Page 3 of 10
Module 4 4
Page 4 of 10
Module 4 5
Page 5 of 10
Module 4 6
Example(1)
This show the method of returning from an IRQ and FIQ handler is to use
a SUBS instruction:
Since there is an S at the end of the SUB instruction and the pc is the
destination register, the cpsr is automatically restored from the spsr
register.
4.2 Interrupts
There are two types of interrupts available on the ARM processor. The
first type of interrupt causes an exception raised by an external
peripheral—namely, IRQ and FIQ.
a) Assigning Interrupts
• A system designer can decide which hardware peripheral can produce
which interrupt request.
• This decision can be implemented in hardware or software (or both)
and depends upon the embedded system being used.
• An interrupt controller unit is used to connects multiple external
interrupts to one of the two ARM interrupt requests either IRQ or FIQ.
• The system designers will use a standard design practice to
assigning interrupts.
• Software Interrupts are normally reserved to call privileged operating
system routines.
• IRQ Requests are normally assigned for general-purpose interrupts.
The IRQ exception has a lower priority and higher interrupt latency
than the FIQ exception.
• Fast Interrupt Requests are normally reserved for a single interrupt
source that requires a fast response time.
• In an embedded operating system design, the FIQ exception is used for
a specific application and the IRQ exception are used for more general
operating system activities.
Page 6 of 10
Module 4 7
b) Interrupt Latency
• It is the time interval, from an external interrupt request signal
being raised to the first fetch of an instruction of a specific
interrupt service routine (ISR).
• Interrupt latency depends on a combination of hardware and
software. System designer must balance the system design to
handle multiple simultaneous interrupt sources and minimize
interrupt latency.
• Software handlers have two main methods to minimize interrupt
latency.
1) Nested interrupt handler,
2) Prioritization.
2)Prioritization
▪ We can program the interrupt controller to ignore interrupts of
the same or lower priority than the interrupt we are handling
presently, so only a higher-priority task can interrupt our handler.
We then re-enable the interrupts.
Page 7 of 10
Module 4 8
IRQ and FIQ exceptions only occur when a specific interrupt mask is
cleared in the cpsr.
The ARM processor will continue executing the current instruction in the
execution stage of the pipeline before handling the interrupt.
An IRQ or FIQ exception causes the processor hardware to go through a
standard procedure listed below,
1) The processor changes to a specific interrupt request mode, which
being raised.
2) The previous mode’s cpsr is saved into the spsr of the new interrupt
request mode.
3) The pc is saved in the lr of the new interrupt request mode.
4) Interrupt/s are disabled—either the IRQ or both IRQ and FIQ exceptions
are disabled in the cpsr. This immediately stops another interrupt request
of the same type being raised.
4)The processor branches to a specific entry in the vector table.
The ARM processor core has a simple procedure to manually enable and
disable interrupts by modifying the cpsr when the processor is in a
privileged mode.
The procedure uses three ARM instructions.
1)The instruction MRS copies the contents of the cpsr into register r1.
2)The instruction BIC clears the IRQ or FIQ mask bit.
3) The instruction MSR then copies the updated contents in register r1
back into the cpsr, to enable the interrupt request.
Table 4.5 shows how IRQ and FIQ interrupts are enabled.
Table 4.5 Enabling an interrupt.
Page 8 of 10
Module 4 9
■ The location: which determines where in the memory map the stack
begins. Most ARM-based systems are designed with a stack that descends
downwards, with the top of the stack at a high memory address.
◼ Stack size: depends upon the type of handler, nested or non nested.
A nested interrupt handler requires more memory space since the stack
will grow with the number of nested interrupts.
Page 9 of 10
Module 4 10
The IRQ mode stack has to be set up during the initialization code for the
system. The stack size is reserved in the initial stages of boot-up .
Figure 4.6 shows two memory layouts in a linear address space.
Page 10 of 10