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

ESP32 + SX1272 Lora #276

Closed
PhilColbert opened this issue Mar 21, 2017 · 7 comments
Closed

ESP32 + SX1272 Lora #276

PhilColbert opened this issue Mar 21, 2017 · 7 comments

Comments

@PhilColbert
Copy link

Hi,

Just trying to port esp8266 code to esp32....all going well until an issue within an irq receiver.

Within this function which is run many times the esp calls an abort ( even if the variable address is trying to be printed out to serial - it aborts ), the only differences is that the code is called from in an IRQ........

https://github.com/3s1d/fanet/blob/master/fanet_stack/sx1272.cpp - line 100

void SX1272::writeRegister(byte address, byte data)
{
select();
/* bit 7 set to read from registers */
SPI.transfer(address | 0x80); /
SPI.transfer(data);
unselect();

#if (SX1272_debug_mode > 1)
Serial.print(F("## SX1272 write reg("));
Serial.print(address, HEX);
Serial.print(F(")="));
Serial.print(data, HEX);
Serial.println();
#endif
}

/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./queue.c:1445 (xQueueGenericReceive)- assert failed!
abort() was called at PC 0x4008375d
Guru Meditation Error: Core 1 panic'ed (abort)

Backtrace: 0x40009203:0x3ffc1050 0x400d5596:0x3ffc1070 0x400d5d5c:0x3ffc10b0 0x400d4c5c:0x3ffc10d0 0x400d4d75:0x3ffc10f0 0x400d4db0:0x3ffc1110 0x400d4e92:0x3ffc1130 0x400d41fb:0x3ffc1150 0x400d43e6:0x3ffc1170 0x400d4aae:0x3ffc11a0 0x400d4b2d:0x3ffc11c0 0x400809e0:0x3ffc11e0 0x40081861:0x3ffc1200

CPU halted.

This is well beyond me :) Any ideas ?

Thanks

@me-no-dev
Copy link
Member

I have some, yes. Peripherals are not optimized for calls from IRQs directly. I'm going to do what I can to change that, but I can not promise full success. ESP32 is quite different than other MCUs and requires different approach towards tasks :) Best case to get it running is the author to optimize for ESP32 and not use IRQs, but rather use Queue and a thread to manage the events on ESP32

@PhilColbert
Copy link
Author

Thanks for the information, will look into what you mentioned - looks like quite a bit rewrite ... ahh well, nothings ever easy :)

Do IRQ's always fail then ?

Thanks

@me-no-dev
Copy link
Member

me-no-dev commented Mar 21, 2017

It's not that they fail, it's because we have two cores and need to protect the peripherals from accessing them at the same time, or while in interrupt. Imagine you have a code that writes periodically to I2C OLED some info and that you have IRQ setup to read some I2C sensor (that has IRQ). If the ISR is called while you are talking to the OLED, things will go bad :)
Same example is valid for a task running on the other core (instead of IRQ)

@PhilColbert
Copy link
Author

Understood - just had a quick play, just doing an interrupt just to set a variable works fine, its further into the code that it decides to stop abort, so I can hopefully sort in the main thread - we shall see !

Thank you for the info - do you have a contribution paypal address or something to send some funds for this project , or is this a paid job now ;)

Thanks

@me-no-dev
Copy link
Member

I do work for Espressif now, so no contribution is necessary :)

@sabas1080
Copy link

Maybe this can help

matthijskooijman/arduino-lmic#77

@PhilColbert
Copy link
Author

Thanks, will look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants