1

I'm not sure how to use the terms "exception" and "interrupt" correctly.

In the book Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C it says:

"Exceptions are the interrupts that come from the processor core. These interrupt numbers are defined by ARM."

(Yifeng Zhu, Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C)

From the ARM documentation:

"The term interrupt is sometimes used as a synonym for exception. In ARM terminology, certain types of asynchronous exceptions are referred to as interrupts"

(ARM documentation - AArch64 Exception and Interrupt Handling)

In the book Mastering STM32 - Second Edition (this one is even more confusing):

"ARM architecture distinguishes between the two types: interrupts originate by the hardware, exceptions by the software (e.g., an access to invalid memory location). In ARM terminology, an interrupt is a type of exception."

(Carmine Noviello, Mastering STM32 - Second Edition)

I know this is not a major issue, but I was wondering what this community would think about this.

ocrdu
  • 8,705
  • 21
  • 30
  • 42
gbt
  • 671
  • 6
  • 17
  • Are you asking for opinions or more definitions that may still be arbitrary? But regardless of those definitions, how would you use the terms? – Justme Sep 20 '22 at 14:32
  • I don't know if this is universal, but for all MCUs that I have used, an *exception* is something that causes the processor to vector from its normal path. It can be an interrupt, software error, or possibly other events. These are subsets of *exceptions*. – Mattman944 Sep 20 '22 at 14:33
  • @Mattman944 I believe x86 calls them all *interrupts* and then exceptions are specific kinds of interrupts that are generated by trying to run bad instructions. Of course, there aren't x86 microcontrollers. – user253751 Sep 20 '22 at 16:54
  • @user253751 Do you mean, there **currently** is no x86 microcontrollers? Because there sure have been plenty. – Justme Sep 20 '22 at 17:00

1 Answers1

4

Any given manufacturer might have very specific meanings, but the general idea is that

  • Any exception is anything where the processor does not complete its instruction and continue to the next one in the normal way
  • As such, an interrupt is an exception generated by something like a timer expiring or an IO device becoming ready
  • And a software exception is where the instruction isn't possible, such as divide by zero

Whether a bus issue such as invalid address is an interrupt or not depends on the hardware and CPU; some have other methods to detect bus errors. Whether it can restart or redo an instruction after a bus error is one of the enabling features for virtual memory.

Some CPUs (perhaps beginning most notably with the 68000) have "software interrupts" or "traps", which are exactly like an interrupt, but which are triggered by a particular machine instruction. They're like an interrupt in that they set interrupt condition-codes, have prioritisation, and do interrupt vector indirection. Most importantly, they also trigger supervisor mode (on 68000) or similar in other processors.

jonathanjo
  • 12,049
  • 3
  • 27
  • 60