Module4_ARM_Detailed_Answers_Clean
Module4_ARM_Detailed_Answers_Clean
The ARM processor has several exceptions that interrupt normal program execution.
These include Reset, Undefined Instruction, SWI, Prefetch Abort, Data Abort, IRQ, and FIQ.
The processor switches to special modes to handle these exceptions.
Modes: User, System, Supervisor (SVC), IRQ, FIQ, Abort, and Undefined. Each has its own
stack pointer (r13) and link register (r14).
Vector Table: Located at 0x00000000, contains addresses of handlers (Reset: 0x00, IRQ: 0x18,
FIQ: 0x1C, etc.).
On an exception, CPSR is saved to SPSR, PC to LR, and processor mode changes to the exception
mode.
ARM exceptions have a priority order: Reset > Data Abort > FIQ > IRQ > Prefetch Abort >
SWI/Undefined.
When an exception occurs, the Link Register (LR) is set to PC+4 or +8 due to pipeline effects.
On return, the handler subtracts 4 from LR to get the accurate resume address.
Draw a priority diagram and PC-LR offset diagram.
On IRQ: Processor disables further IRQs, saves CPSR to SPSR_irq, PC to LR_irq, enters IRQ
mode,
and jumps to 0x18. After handler, resumes using LR-4.
On FIQ: Disables both IRQ and FIQ, saves CPSR to SPSR_fiq, uses banked registers r8-r12 for
speed,
jumps to 0x1C. After handler, resumes similarly.
Enable IRQ:
MRS r1, cpsr
BIC r1, r1, #0x80
MSR cpsr_c, r1
Disable IRQ:
MRS r1, cpsr
ORR r1, r1, #0x80
MSR cpsr_c, r1
Use #0x40 for FIQ and #0xC0 for both IRQ and FIQ.
Draw a diagram of CPSR register highlighting I and F bits.
Each mode has its own stack pointer (r13) to save registers during exceptions.
Stack layouts (A and B) show where stack memory is placed.
Execution Flow: Reset -> Init -> HAL -> Load OS/App -> Relinquish control.
Draw a firmware execution flow diagram.
uHAL: Hardware Abstraction Layer - standard API, drivers for serial, LEDs, timers.
Angel: Debug monitor - allows host debugger to control target via SWI/IRQ/FIQ.