15.4.4.1 Cortex-M Interrupts

Stack Usage Report prints a list of the interrupt handlers defined in the application along with their stack consumption, so that the stack overhead generated by interrupts can be estimated.

In this context, use the interrupt function attribute to allow the compiler to identify and analyze the function as an interrupt handler and report it as such.

without __attribute__((interrupt)) with __attribute__((interrupt))
1. The following functions cannot be connected to the main call graph.
This is usually caused by some indirection:
FstHandler uses 408 bytes
SndHandler uses 408 bytes
1. The following functions are interrupt functions:
FstHandler uses 408 bytes
SndHandler uses 408 bytes
Important:

When interrupts occur on a Cortex-M target, the stack estimate should be adjusted by adding the appropriate space for interrupt context saving as follows:

  • with software floating-point support - 32 bytes (4 bytes * 7 caller saved registers: R0-R3, R12, LR, PC and the address of the next instruction to be execute when exiting an interrupt handler.
  • with a hardware Floating-Point Unit (FPU) - 164 bytes (above 32 bytes + 4 bytes * 33 floating-point registers) - assuming Lazy Context Save is disabled.

Be sure to add the appropriate value to account for interrupt context saving when estimating stack usage. Interrupt context is saved by the core, not by the compiler.