Interrupt initialization, especially with vectored interrupts, is usually part of the global initialization. This means that these are done once at the beginning to configure the system before starting the infinite loop in the main routine in an embedded system.
Steps that need to be taken when initializing interrupts:
- Disable all interrupts.
- Enable device interface interrupts by setting the appropriate device interface registers.
- Set interrupt mask to allow interrupts from device, configure priority.
- Initialize interrupt vector with address of ISR.
- Enable interrupts as required.
Steps 2, 3, and 4 may be performed in any order provided that all interrupts are disabled.