Page 1 of 1

ESP32 dual core - is there an internal interrupt from one core to the other?

Posted: Wed Sep 14, 2022 6:19 pm
by rtarb41323
Greetings! I'm using the ESP32 dual core with the Arduino IDE. I'm passing data between the two cores using a queue.

--> Is there a way for one core to generate an internal interrupt to the other core, so that the interrupted core knows that "it's time to read the queue"?

Setup:
Right now, I have CORE0 using GPIO 34 as an output, and CORE1 using GPIO 23 as an input (with an attached interrupt). Pins 34 and 23 are tied together by an external wire.

--> CORE0 writes to the queue, and then it raises GPIO 34 high
--> CORE1 gets the interrupt on GPIO 23, and then reads the queue in the ISR

The above setup works, but it uses two GPIO pins. I'm wondering if there is a better way to do this.

Re: ESP32 dual core - is there an internal interrupt from one core to the other?

Posted: Thu Sep 15, 2022 2:52 am
by ESP_Sprite
Yes, there is, and it's heavily used internally by the multicore features of the FreeRTOS RTOS. Effectively, if you try to read from an empty queue on core 1, the RTOS will simply stop executing the task. Then, if core 0 pushes something into the queue, it'll use the internal interrupt to tell core 1 that the queue has something in it. FreeRTOS on core 1 will then schedule the task again, and the read will succeed.

In other words, the proper way would be to (instead of an ISR) start a task that simply reads from the queue and processes whatever it can read. The task will only run when needed, so it's CPU-efficient.