Interrupt

From SEGGER Wiki
Revision as of 23:47, 6 June 2019 by MartinBaldwin (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In the context of an Embedded System, an interrupt is an interruption of the program flow by hardware. Interrupts are widely used in almost all Embedded Systems. Most systems use a timer to trigger a periodic interrupt so the system can keep track of its "up time", which is the time from the start of the system, to the time after RESET. Another very common use of an interrupt is for communication. When data is received, typically an interrupt is issued, causing the CPU to jump into the Interrupt Service Routine (ISR) handling the received data. This is a scheme used for almost all data, regardless of whether it is a single byte (such as in the case of a UART), or a packet, such as for Ethernet or CAN.

How interrupts are handled

How interrupts are handled on different CPUs is very different on different architectures. Typically, Interrupts are disabled at program start. They first need to be enabled, typically in 3 places: The CPU has a general Interrupt-Enable (or Disable) Flag. So interrupts need to be enabled in general. The Peripheral which is supposed to generate an interrupt needs to be "told to do so". And the interrupt controller, which is also typically part of the CPU, needs to also be "told to" enable this particular interrupt. Most modern CPUs come with an Interrupt Vector Table.