Using two CPU Cores

Posts: 5
Joined: Thu Jul 05, 2018 11:47 pm

Using two CPU Cores

Postby plajjd » Fri Jul 13, 2018 1:50 am

I apologize in advance that I am new to ESP32, and have never used a dual-Core CPU bfore.

I am evaluating the ESP32 for use in a product that needs to do both WiFi mesh (ESP-MESH) and also run very high speed control calculations from Matlab Simulink.

I need around 25 kHz update rate on my Simulink model calculations.

I think the only way to run at 25 kHz, is to have a hardware group timer with an alarm occurring at 25 kHz (every 40 us), and then have ONLY ONE task, that reads a global flag from the timer ISR, and executes the Simulink model code. (If I use more than one task, then the 10 ms RTOS tick means I cannot share information between tasks - the XQueueReceive (for instance) only updates every 10 ms.

This means that I cannot also do WiFi mesh on the same CPU at the same time.


1. Is there a way to FORCE a task to run (in my case, every 40 us, when the timer alarm occurs)?

2. Is it possible for me to run my Simulink model on the first CPU Core, and run my WiFi Mesh on the second CPU Core? Are there any issues I should be concerned about if running Mesh on a different Core than my main application?

Thank you!

User avatar
Posts: 176
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Using two CPU Cores

Postby urbanze » Fri Jul 13, 2018 10:56 am

1. Yes, call portYIELD() or portYIELD_FROM_ISR() to force context switch. If you use queue or semaphore or etc from ISR, freertos implements ...FROM_ISR functions (ISR SAFE) that maybe force context switch, see later on freertos page.

2. Yes to separate functions (I never used simulink ), but I think is better to keep your WiFi functions in same core as marked in menuconfig (default is core 0).

You can leave core 0 to all "miscellaneous" tasks and leave core 1 with one task "like" bare-metal (deactivating time slice or preemp (scheduler)) if you need better performace.

Posts: 1663
Joined: Thu Nov 26, 2015 4:08 am

Re: Using two CPU Cores

Postby ESP_Sprite » Sat Jul 14, 2018 3:06 pm

Note that FreeRTOS in ESP-IDF is pre-emptive - if a task is blocking on a queue and another task (or interrupt) puts something in that queue, if the first task has a higher priority than the second it will get woken immediately. FreeRTOS doesn't wait for the tick interrupt in that case.

Who is online

Users browsing this forum: wsgsra and 6 guests