Interrupts in Embedded System QA

Interrupts Q and A


1. What is interrupt?
	Interrupt is an input signal to the processor or microcontroller that an event needs immediate attention.
Interrupt is a request for the processor to stop the currently executing program and to execute the interrupt routine.
If the interrupt is accepted by the processor, it will stop the currently executing program, 
It will save the registers values, and return address of the program, then it will move to execute the interrupt 
program. After executing the interrupt routine, using return address it will start executing program which it was executing earlier program . 

There are two types of interrupts
Hardware interrupt:
It is a hardware signal to the cpu that it should be responded immediately. 
The cpu should save its current context and execute the inerrupt routine.

Software Interrupt:
Software interrupt is an software instruction which causes the inerrupt to occur.

2. What is iterrupt latency?
Interrupt latency is the time it take from when the interrupt is generated to the interrupt routine
started to execute. The interrupt latency is affected by microcontroller design.

Causes for interrupt latency time?
 - The interrupt requesting signal should be synchronised to cpu clock, it takes 3 clock time for interrupt signal to reach the 
   cpu core.
 - Typically the cpu complete the current instruction and then executes the isr. The time taken for the instruction to execute 
   is depending on the instruction it executes. If the instruction takes more time the latency time increases.
 - Memory system requires additional cycle states for wait states.
 - after executing the current instruction the cpu do the mode switch or pushes the register contents on to the stack.
   Arm controllers uses the mode switch which takes less time than pushing registers to the stack.
 - pipeline fill - most modern cpus are pipelined, if the interrupt is occured when the pipeline is filled then if the mode 
   switch is occured then extra cycles are needed to refill the pipline.
 - an Rtos disable interrupts to executes its api, it increases the latency time since it has to complete the executing the api 
   and then it will execute the interrupt.


3. How the interrupt routine should be?
    The interrupt routine size should be small as much possible as.
The isr size made small to make place for other isr to execute, otherwise the delay increases
for other ISRs to execute.



4. What are the different types of interrupt?

There are two types of interrupts
Hardware interrupt:
It is a hardware signal to the cpu that it should be responded immediately. 
The cpu should save its current context and execute the inerrupt routine.

Software Interrupt:
Software interrupt is an software instruction which causes the inerrupt to occur.

5. what is instruction pipeline?
   While executing the code the cpu loads the instructions to a pipeline, then it executes the instructions one by one.
 instructions are loaded as per the program flow.

6. what is interrupt priority?
  The interrupt priority is the priority set to each interrupt routine. 
  The high priority routine executes first and then the low priority interrupt will executes.
  If the low priority interrupt is executing, then if some high priority interrupt is requested, then the
  controller will stop executing the low priority interrupt and execute the high priority interrupt then
  executes the low priority interrupts.

7. what is interrupt vector table?
  Interrupt vector table is a addresses of the ISRs for the Interrupt handler to search Isrs.
  All interrupts are assigned with a number from 0 to 255. each of these interrupts are associated
  with aspecific interrupt address.
  Normally interrupt vector table is located in the first 1024 bytes 0000 to 03ff. Each interrupt takes 
  the 4 bytes address. so it needs 256 * 4 = 1024 bytes memory space.


8. what are different Triggering methods for interrupts?
   each interrupt can be triggered by either a logic level or edge 
  logic level can be low or high level
  edge triggered means rising edge or flaaing edge.
  Inerrupt can occur on rising edge or falling edge.
  Interrupt can occur on low or high logic level.

 
9. what are maskable interrupts?
   The ineterrupts in the microcontroller can be enable and disable using the register mask.
   To enable an interrupt a perticular bit has to be set in the mask register.
   To disable an interrupt a perticular  bit has to be reset in the mask register.
   the interrupt which are affected by mask register are called maskable interrupts.

10. what are non maskable interrupts?
   some interrupts cannot be disabled using interrupt mask, these interrupts are called Non maskable interrupts.