• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 designating a core for specific interrupt service

Q&A Forum › Category: ESP32 › ESP32 designating a core for specific interrupt service
0 Vote Up Vote Down
Rajiv Tyagi asked 7 years ago

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…
Rajiv

Question Tags: dual core, Hardware Interrupt, interrupt service
7 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

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,
Rui

0 Vote Up Vote Down
Rajiv Tyagi answered 7 years ago

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…
RT

0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

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,
Rui

0 Vote Up Vote Down
Walter Mota answered 4 years ago

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++.

Thank you.

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi Walter.
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:

  • https://esp32.com/viewtopic.php?t=5553
  • https://esp32.com/viewtopic.php?t=5505

I hope this helps.
Regards,
Sara
 

0 Vote Up Vote Down
Walter Mota answered 4 years ago

Ola Sara,
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.
 

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Great!
Thank you for that.
Then, let us know the results.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.