Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wemos D1 Mini - "ISR not in IRAM!" when trying the Interrupt Examples #176

Closed
EpicLPer opened this issue Aug 25, 2020 · 7 comments
Closed
Labels
question Generic question about code or usage resolved Issue was resolved (e.g. bug fixed, or feature implemented)

Comments

@EpicLPer
Copy link

EpicLPer commented Aug 25, 2020

I'm new to LoRa (and in general playing around with breakout boards or Arduino programming :) ) and I just tried out the Receive and Transmit Interrupt Examples included with the project.

The non-interrupt ones worked fine and I was able to successfully transmit data which got me hyped up for LoRa already!
But trying the Interrupt examples results in the ESP8266 (Wemos D1 Mini clone) to constantly crash with the following crashdump and error:

[SX1278] Initializing ... success!
ISR not in IRAM!

User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Abort called

>>>stack>>>

ctx: cont
sp: 3ffffeb0 end: 3fffffc0 offset: 0000
3ffffeb0:  00000008 4023cb38 00000000 40203ea5  
3ffffec0:  000000fe 00000000 00000000 00000000  
3ffffed0:  00000000 00000000 00000000 00ff0000  
3ffffee0:  5ffffe00 5ffffe00 00000000 00000000  
3ffffef0:  00000001 00000004 3ffee36c 40204a22  
3fffff00:  40100702 00000000 000a0d00 40204a34  
3fffff10:  3ffe861f 00000000 3ffee36c 40204f49  
3fffff20:  00000000 00000000 3ffee310 0000000a  
3fffff30:  40203c3c 3ffee36c 3ffe861d 0000000a  
3fffff40:  00000000 3ffee310 3ffee36c 40205010  
3fffff50:  00000000 00000008 3ffee36c 4020159f  
3fffff60:  00000000 3ffee310 3ffee36c 4020241a  
3fffff70:  3fffdad0 3ffee310 3ffee36c 402010c3  
3fffff80:  0000000a 00000008 00000000 feefeffe  
3fffff90:  feefeffe feefeffe feefeffe 3ffee3d4  
3fffffa0:  3fffdad0 00000000 3ffee394 40204630  
3fffffb0:  feefeffe feefeffe 3ffe84e4 40100ff9  
<<<stack<<<

With my limited understanding of Arduino stuff so far it seems to get hung up on radio.setDio0Action(setFlag);.

Any way to fix this? Did I maybe do something wrong or is something not right in the Library?
Thanks already :)

@lillefyr
Copy link

I don't know if this can help.
I wrote it as a comment top myself last year. Seems the link could cover it

// Note if you use an Wemos D1 as MCU, ICACHE_RAM_ATTR is required
// https://community.blynk.cc/t/error-isr-not-in-iram/37426/20
//ICACHE_RAM_ATTR

I put the ICACHE_RAM_ATTR after variables and before procedures.

@EpicLPer
Copy link
Author

I don't know if this can help.
I wrote it as a comment top myself last year. Seems the link could cover it

// Note if you use an Wemos D1 as MCU, ICACHE_RAM_ATTR is required
// https://community.blynk.cc/t/error-isr-not-in-iram/37426/20
//ICACHE_RAM_ATTR

I put the ICACHE_RAM_ATTR after variables and before procedures.

I'm kinda lost... not sure where to put this or how.

@naggie
Copy link
Contributor

naggie commented Aug 25, 2020

https://stackoverflow.com/a/58131720 explains it pretty well, see the next answer for an example.

@jgromes
Copy link
Owner

jgromes commented Aug 25, 2020

@EpicLPer ICACHE_RAM_ATTR is an ESP8266 attribute that will place a function into RAM (as opposed to the usual program storage, which is flash). On ESP8266, all interrupt service routines must be placed in RAM. Try placing the attribute before the ISR, like this:

void ICACHE_RAM_ATTR  setFlag(void) {
  // check if the interrupt is enabled
  if(!enableInterrupt) {
    return;
  }

  // we got a packet, set the flag
  receivedFlag = true;
}

@jgromes jgromes added the question Generic question about code or usage label Aug 25, 2020
@EpicLPer
Copy link
Author

If I do this then I get the following compile error:

In function 'void setup()':
SX127x_Receive_Interrupt_Example:54:23: error: 'setFlag' was not declared in this scope
   radio.setDio0Action(setFlag);
                       ^
exit status 1
'setFlag' was not declared in this scope

@EpicLPer
Copy link
Author

EpicLPer commented Aug 25, 2020

Okay, fixed it :) Had to put it before void for it to work!

ICACHE_RAM_ATTR void setFlag(void) {
  // check if the interrupt is enabled
  if(!enableInterrupt) {
    return;
  }

  // we sent a packet, set the flag
  transmittedFlag = true;
}

@jgromes jgromes added the resolved Issue was resolved (e.g. bug fixed, or feature implemented) label Aug 25, 2020
@jgromes
Copy link
Owner

jgromes commented Aug 25, 2020

Couldn't remember which way it was, I'm glad it's working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Generic question about code or usage resolved Issue was resolved (e.g. bug fixed, or feature implemented)
Projects
None yet
Development

No branches or pull requests

4 participants