The tutorial on ESP32 with Arduino has solved many problems for me. But one remains…
How do I designate a particular core to service a hardware interrupt from a specified pin? I have two interrupts that I want serviced by different cores…
At the moment, I don’t have any example about that subject and I’ve actually never tried it myself. This documentation covers everything about interrupts on the ESP32 and their allocation: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/intr_alloc.html
I hope it helps! Regards,
Thanks! yes, here it is…
Non-internal interrupt slots in both CPU cores are wired to an interrupt multiplexer, which can be used to route any external interrupt source to any of these interrupt slots.
- Allocating an external interrupt will always allocate it on the core that does the allocation.
- Freeing an external interrupt must always happen on the same core it was allocated on.
- Disabling and enabling external interrupts from another core is allowed.
- Multiple external interrupt sources can share an interrupt slot by passing
ESP_INTR_FLAG_SHAREDas a flag to esp_intr_alloc().
Care should be taken when calling esp_intr_alloc() from a task which is not pinned to a core. During task switching, these tasks can migrate between cores. Therefore it is impossible to tell which CPU the interrupt is allocated on, which makes it difficult to free the interrupt handle and may also cause debugging difficulties. It is advised to use xTaskCreatePinnedToCore() with a specific CoreID argument to create tasks that will allocate interrupts. In the case of internal interrupt sources, this is required.
Thank you. I have profited enormously from your knowledge of this processor…
I’m glad it had the answer that you were looking for! I’ve never tried that before, so I don’t have any examples. I also love this chip and there are so many applications that we can do! Regards,
My current project is a stand-alone control of a CNC lathe using an ESP32.
One of the tasks to be performed by this lathe should be cutting threads.
To do this, it is necessary to synchronize the position of the tool (Z axis) with the rotation of the spindle.
My goal is to reserve the first core of the ESP32 for managing, among other things, communications with a Nextion touch screen and to reserve the second exclusively for managing stepper motors based on information coming from a rotary encoder.
I am looking for a while now for a way to assign the necessary interrupts to one or the other core without having interrupts assigned to the first core affecting the execution of instructions in the second and vice versa.
It would be great if someone could help me to achieve my goal with an example knowing that:
– I am developing this project in the Arduino ID Environment.
– I have basic knowledge in C++ programation.
I consulted the Espressif informations about interrupt allocation on ESP32 but I am unable to implement them it in C++.
We only have this tutorial about dual-core: https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/
From what I read, you need to create a task. Then, you need to make sure the task that allocated the interrupt is pinned to the core that you want the interrupt to occur on. In our tutorial, we show how to create the tasks.
See more information on the following discussions:
I hope this helps.
I will study the matter based on the information you were kind enough to provide me.
If I manage to write a code that works I will come back and place it on your forum, I think it could be useful for other makers like me.
Thanks for your support.