-->
Page 1 of 1

attachInterrupt ICACHE_RAM_ATTR function definition order

PostPosted: Tue May 16, 2017 4:25 pm
by btidey
I was having crashes with pin change interrupt handler and thought that I should give the interrupt handler an ICACHE_RAM_ATTR but when I first tried to do this I was getting a 'not defined in scope' error from the compiler.

I.e. function without attribute compile -> OK, function with ICACHE_RAM_ATTR compile -> error.

I then thought maybe it would help if I put the interrupt handler definition above the setup code that called attachInterrupt. I had got used to the compiler not normally worrying about definition order.

That was the trick. Now compiled OK and crashes gone away in the runtime.

Not a problem now I know what to do, but I am curious why adding the attribute changes the compiler behaviour and whether there any other ordering rules to worry about.

Re: attachInterrupt ICACHE_RAM_ATTR function definition orde

PostPosted: Sat May 01, 2021 12:19 pm
by mager
In 2021 it's still the same

Re: attachInterrupt ICACHE_RAM_ATTR function definition orde

PostPosted: Sat May 01, 2021 6:27 pm
by RichardS
Not an Espressif issue, its Arduino and the funky way it deals with includes, total breaks the normal rules all the time.

RichardS