简体   繁体   中英

ISR syntax with ARM-GCC

The demo code on the web for defining an ISR for ARM is generally this:

__irq void ISRFunc (void);

Using ARM-GCC, this gives syntax errors on compile, I've tried obvious variants like _irq but they all have the same problem. Some google references state that you don't need to specify the function as an ISR, ie void ISRFunc(...) will also work. However, I'm having trouble getting my programs to run, so it would help a lot if someone could confirm (a) is the type specifier __irq (or equivalent) required, and (b) what should it be to avoid compile errors.

Thanks for any information.

__isr is ARM C compiler specific keyword (and looks like it was Keil specific too , but obsoleted), and will not compile via GCC.

As per GCC documentation , following is the syntax for declaring ARM interrupt service routine:

void __attribute__((interrupt("IRQ"))) do_irq()
{
    //your irq service code goes here
}

Extra details:

In fact, you may use any of the following to inform compiler that your function is the interrupt handler.

void __attribute__((interrupt)) ...
void __attribute__((interrupt("FIQ"))) ...
void __attribute__((interrupt("IRQ"))) ...

The difference is both "IRQ" and "FIQ" should switch register contexts and save certain registers ( "FIQ" stacks nothing), while plain interrupt is more a general "save what you use here and restore when exiting".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM