-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
LoRa fails to start running dual core ESP32 with Bodmers TFT_eSPI library #290
Comments
Hi, I failed to mention that the problem is only with a ILI9488 display. Regards. |
Are you certain each device is using the correct pins? Have you called |
Hi morganrallen and thanks for your response. Firstly, is it absolutely necessary to use the "correct pins" as follows: My setup is as follows - the GPIO's are the default for TFT_eSPI using the ESP32's VSPI bus: I'm calling LoRa.setPins() with: NOTE: SS_GPIO5 has been left out as I think it interferes with the TFT_eSPI chip select settings ? These settings work using shared VSPI bus as I tested all day today and more than 3500+ packets were received without LoRa stopping and running dual core with an ILI9341 display. I contacted Bodmer and this was his response: What do you think ? Is it possible what Bodmer says ? How can the issue be solved ? Is it a problem with the LoRa library/TFT_eSPI library or both ? I'm running out of ideas. Thanks in advance for looking into this issue. |
The more I'm digging into this I'm realizing this library simply cannot use non-standard SPI pins. Your call to
This might work but as a couple config steps are skipped there's no way to tell. The only other thing I can think of is using LoRa on it's default pins and moving the display to other... assuming it has better support for alternative SPI config. |
oh! this actually might work a bit better than I thought. I've looked into how |
Hi morganrallen, Thanks again for your valued response. I tried your suggestions but with no success. I had more success in getting LoRa to start. /***************************************************
// LoRa setup using default GPIO's /***************************************************
/* In setup() I have: // Start SPI Service & setup the GPIO's Serial.println("==========================="); if (LoRa.begin(LoRa_BAND)) Here is the output from the first run: 10:13:36.317 -> Packet count: 2525 This is a good packet (number of packets received 2525) - but timed out - caught in a loop somewhere? The fields consist of: Output from the second run: 10:33:45.259 -> Packet count: 41 Where did this packet come from ? Note the RSSI - LoRa re-started Then received this - note the RSSI is positive !! - LoRa then re-started - Am I actually receiving this packet or is it interference from the TFT. 10:34:57.401 -> Packet count: 51 0:38:00.609 -> Packet count: 153 LoRa then re-started - third time !! Program left running - then crashed with a Guru Meditation Error !! Final output: 11:07:44.466 -> Packet count: 1615 A total of 1615 packets received then a Guru Meditation Error !! What caused this and how can it be fixed ? So, what do you think ? My thoughts are that LoRa needs to be setup with the default pins to work with a ILI9488 display. But where are the spurious packets coming from - I don't (seem) to get them when running with a ILI9341 display. Are they coming specifically from the ILI9488 library as this is different from the ILI9341 one as Bodmer mentions ? Do I need to set up something different ? I'll incorporate what seems to work (?) into the main project sketch over the weekend if I have time and see what happens. In the meantime your further thoughts would be appreciated. If you like, I can send you the full sketch (not the full project). Regards. |
Hi, I have incorporated what seemed to work into the main project sketch and ran several tests over the weekend. These are my findings: Running on both cores with either ILI9341 or ILI9488 displays - LoRa on core 0 and TFT on core 1 does not work. LoRa fetches the first packet OK then afterwards the behaviour is undetermined. So what's happening ? What's causing this strange behaviour where the program works fine using just one core but doesn't work when using both cores ? I really need to use both cores because the updates to the TFT take too long when running on just one core. I'm scratching my head out in finding a solution !! Thanks in advance. Regards. |
Hi, But, I have an issue. After an undetermined amount of time the receiver stops receiving packets but the transmitter continues to transmit. I've written some code to check if after 1 minute no packets are received then the LoRa module is reset with LoRa.begin(). The module resets and works as expected both transmitting and receiving until the next time the receiver stops. Any ideas what and why this is happening ? I've looked at the HOPERF documentation v1.1 and on page 27 it states "The receiver undertakes a preamble detection process that periodically restarts." Could this be the problem ? Writing code to reset the module is a work-a-round and by no means a satisfactory solution so I would like to find and rectify the problem. |
I cannot think of a reason off hand the preamble detection would cause a receiver to suddenly stop. The preamble is simply how the sender tell the receiver a packet is starting. The first thing I'd look into is how you're handling the receive interrupt, it's well known (#55) the included examples are problematic in this handling. If you are doing any major work within the receive handler this could be causing issues. If this is the case, follow the advice in PR #55 to eliminate that work. Additionally we might be able to glean some extra info my dumping the registers at various points. I'd suggest calling
additionally PLEASE take the time to properly format (using a code block) the reply as 3 calls to |
Hi morganrallen, Thanks again for your input. I've attached the output from LoRa.dumpRegisters(Serial); for you to have a look at. But, an interesting thing - due to incorporating the Serial.println() statements into the program I noticed that the number of resets were greatly reduced. That got me thinking that perhaps they were giving the necessary delays for the LoRa module to "catch up" on the processing. So I changed the values in the calls to vTaskDelay() from 25 to 50. At the same time I put additional yield() calls at certain points in the program. The program has been running now for over 9 hours with 15000+ packets received, 6100+ packets sent and 11 resets which represents 0.07% of the total packets received. I think this is acceptable and I can live with that !! You might be able to glean more information from the register dump. BTW I'm not using interrupts. If I have any more information than I'll post the results. Regards. |
Hi, I know this topic is quite old. Did you ever find the solution? |
Hi j45p41. It's been some time since I worked on that project as I've been busy with other projects. From memory the problem was solved but I'm not 100% certain. I think it was the case to use the default pins for the LoRa module otherwise there was an interaction. If GPIO's were assigned other than the default ones then the problem occurred. I would have to look at the code to verify what I actually did. What are you actually trying to achieve? |
Wow, so great that you have responded. You seem to be the only one that has spoken of a solution to an issue that is really making me scratch my head :). I am setting up a display module based on ESP32-WROOM-32D, RFM95W and ILI9488 display. I already have my hardware on PCB and I am using the default pins for TFT_eSPI and the following pins for LoRa:
This seems to work for about a day with about 20 packets an hour being exchanged but then freezes. I have not gone for sharing the SPI bus because this seems to work ok. It would be great to know how you implemented multi-threading and/or the final working solution. |
This is the last code that I have showing the GPIO's I used and how running on dual cores can be set up - hope some of it might help: // LoRa GPIO setup using the default GPIO's /***************************************************
/***************************************************
/***************************************************
Serial.println("LoRa "); // Start LoRa Service // Pin the tasks to the appropriate cores // <<< IMPORTANT >>> - LoRa core - 2, TFT core - 1 <<< IMPORTANT >>> // /***************************************************
/***************************************************
for (;;)
} /***************************************************
for (;;)
} |
Thank you very much indeed. I will give it a try. |
@FLYINGSC0T So actually, LoRa and TFT will run in the same core 1. However, LoRa task has higher priority than TFT task. // <<< IMPORTANT >>> - LoRa core - 2, TFT core - 1 <<< IMPORTANT >>> // |
Yes, LoRa and TFT will run on the same core but to achieve multitasking and realise the benefit of both cores you need to setup dual core as mentioned. I personally assigned LoRa to core 2 so that it had 100% of that CPU's time to process just the LoRa commands while at the same time the TFT was running on core 1. In fact, I had the TFT, acquisition of GPS data, Temperature, Pressure and Humidity running on core 1. In the case of priority, for example, if you assign other tasks to the same core then the priority comes into play e.g. if you assigned GPS and TFT to core 1 but gave the GPS priority 1 and TFT priority 5 then the TFT would have the higher priority, i.e. higher the number = higher the priority. This link gives a full explanation of how to use dual cores on the ESP32: https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/ and you will find some other great tutorials on this website. // <<< IMPORTANT >>> - LoRa core - 2, TFT core - 1 <<< IMPORTANT >>> // Sorry if I may have mislead you - I forgot which parameter was the core and the one for the priority !! As an aside, do you use the sprites that are available in Bodmer's TFT_eSPI library ? Well worth looking at and implementing if you haven't already done so. The screen redraws are very fast and avoids any flicker. I now use sprites all of the time. Regards. |
Excellent. Thanks for the additional info. I tried it last night on my current pinout setup but I am going back to the breadboard and use common connections, as you pointed and will let you know how it went. I am actually using lvgl, which sits on top of Bodmer excellent library. https://lvgl.io, https://www.youtube.com/watch?v=FYhmi6MamRs&ab_channel=LVGL |
That's great and I look forward to hear how you get on. I hadn't come across LVGL before but it looks very interesting - thank you for sharing. If you are interested in sharing ideas, code etc. and continuing this discussion here is my email address: |
Hiu @j45p41 i want to use LoRaDuplexcallback function but LoRa2.receive() function mostly doesn't work |
Guys, |
Hi,
Can anyone help with this issue.
I'm running dual core on ESP32 - LoRa on core 0 and TFT_eSPI on core 1.
LoRa is assigned to VSPI and TFT_eSPI to HSPI.
The problem is that LoRa will not start if I initialize tft.begin(). If I comment out tft.begin() then LoRa starts ok. I've also tried running on single core with same results.
Ideas why this is happening ?
Any advice greatly appreciated.
Thanks in advance.
The text was updated successfully, but these errors were encountered: