Reputation: 303
is it a must to specify __attribute__((interrupt)) for my (C function) interrupt/exception handlers?
i understand that in Cortex-m3, the processor will automatically do the stacking BEFORE branching to the exception handler, and also do the unstacking AFTER returning from exception handler, independent of the exception handler contents.
In this case, the exception handler works just like a generic function call.. so why do we need to specifically tell the compiler that the routine is a exception/interrupt handler?
thank you.
Upvotes: 2
Views: 5912
Reputation: 61
The exception handler takes care of aligning the stack after the ISR is called. This is definetly a good thing, since if this is not the case subsequent calls with 64 bit types (double, long long int) can fail.
More details about aligning: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0046b/IHI0046B_ABI_Advisory_1.pdf
Upvotes: 3
Reputation: 7701
why do we need to specifically tell the compiler that the routine is a exception/interrupt handler?
We don't need to. My interrupt handlers for Contex M3 work fine without any attibutes, see this Systick handler for example.
However, it is not an error to add this attribute to the handler function.
Upvotes: 2