Hi, I am currently working with the esp-now example code that was available in the Arduino code examples after downloading the Espressif addon. I thought I remember reading somewhere that the program is set up such that one of the esp cores is dedicated to running/managing the wireless communication hardware, and the second core is available for whatever code you write in the Arduino IDE. I can't seem to find any confirmation on this, however. Does anyone here know if this is the case?
When the "OnDataRecv" callback function runs, I want it to put the data it received in a global queue to be processed by code in the main loop(). If the entire program is running on one core, then I think just disabling interrupts around the part where the main loop gets the data from the queue should be enough to avoid a possible race condition where the callback function writes data at the same time. If however the callback function was called from code on a different core, I'm not sure if using interrupts like this still works, hence my question. Thanks!
Question regarding core usage on the esp32 with Arduino esp-now example
Re: Question regarding core usage on the esp32 with Arduino esp-now example
This is how I use esp-now:
/*
__________________________________________
GLOBAL INFO
core 0 is the communications processor.
Uses the ESP-NOW protocol
on the 2.4 GHz radio
This process runs as a task created
on core 1
core 1 is the UI processor.
Maintains the M5Stack LCD menu
Runs Arduino setup() and loop()
___________________________________________
*/
Use RTOS semaphores when accessing the global vars to/from the local versions.
/*
__________________________________________
GLOBAL INFO
core 0 is the communications processor.
Uses the ESP-NOW protocol
on the 2.4 GHz radio
This process runs as a task created
on core 1
core 1 is the UI processor.
Maintains the M5Stack LCD menu
Runs Arduino setup() and loop()
___________________________________________
*/
Use RTOS semaphores when accessing the global vars to/from the local versions.
-
- Posts: 166
- Joined: Wed Aug 01, 2018 12:06 pm
Re: Question regarding core usage on the esp32 with Arduino esp-now example
I understand that the WiFi takes up a 'lot' of time on one of the cores.
With my GPS program, on the ESP32, I do not run the WiFi, which seems to give me access to both cores without WiFi thingies.
Using freeRTOS, I thought I could get away with not using queues and semaphores to pass data from one core to the next by properly organizing the functions and variable access. It became more of a pain in the behind then just going ahead and using the queue/semaphore route.
This link was passed to me and I pass it on to you: https://docs.espressif.com/projects/esp ... rrors.html that may help as you run into issues.
Me, even if I was to use WiFi, I'd put a few low priority tasks on the Wifi core.
You can use to pin a task to a core.
You can use to figure out how much stack space to allocate to a task. I found it is best to let your program to run for a few hours before settling in a stack size. Put this code to run at the bottom of your taskings and comment out for production code.
This is a shameless endorsement: You might want to pick up Koolban's PDF file and give him the $5.00 for a nice collection of information on the ESP32.
With my GPS program, on the ESP32, I do not run the WiFi, which seems to give me access to both cores without WiFi thingies.
Using freeRTOS, I thought I could get away with not using queues and semaphores to pass data from one core to the next by properly organizing the functions and variable access. It became more of a pain in the behind then just going ahead and using the queue/semaphore route.
This link was passed to me and I pass it on to you: https://docs.espressif.com/projects/esp ... rrors.html that may help as you run into issues.
Me, even if I was to use WiFi, I'd put a few low priority tasks on the Wifi core.
You can use
Code: Select all
xTaskCreatePinnedToCore( fGetUTM, "fGetUTM", TaskStack15K, NULL, Priority4, NULL, TaskCore0 ); // assigned to core 0
You can use
Code: Select all
// Serial.println( "fRunTime" );
// Serial.print( "fRunTime " );
// Serial.print(uxTaskGetStackHighWaterMark( NULL ));
// Serial.println();
// Serial.flush();
This is a shameless endorsement: You might want to pick up Koolban's PDF file and give him the $5.00 for a nice collection of information on the ESP32.
-
- Posts: 22
- Joined: Mon Feb 12, 2018 6:50 pm
Re: Question regarding core usage on the esp32 with Arduino esp-now example
You may want to look at my Arduino multi-tab example here... a rework of the Andreas Spiess' code on YouTube.
https://www.hackster.io/rayburne/esp32- ... both-cores
Ray
https://www.hackster.io/rayburne/esp32- ... both-cores
Ray
Who is online
Users browsing this forum: Basalt and 56 guests