Author Topic: Arduino ESP32 using both Cores ?  (Read 1152 times)

0 Members and 1 Guest are viewing this topic.

Offline LindleyTopic starter

  • Regular Contributor
  • *
  • Posts: 223
  • Country: gb
Arduino ESP32 using both Cores ?
« on: October 26, 2023, 02:55:58 pm »
Currently have code running as a single loop in the default Core 1 and have been viewing various web pages and ytubes about creating two Tasks and running one Task in each Core, which seems straight forwards enough.

However some of those ytubes are several years old and some also contain comment that Core 0 should ideally be left unused as much as possible to avold problems with the Wifi/Bt etc that RTOS runs in Core 0.
One video even said this what Espressif recommends.

As things may have moved on, do those comments still hold ?   can we use for our Core 0 for our Tasks safely or is it better to run the two Tasks in Core 1, abeit possibly slower ?

 

Online globoy

  • Frequent Contributor
  • **
  • Posts: 286
  • Country: us
Re: Arduino ESP32 using both Cores ?
« Reply #1 on: October 26, 2023, 03:19:31 pm »
I successfully run tasks on Core 0 in systems using Wifi or Bluetooth with no deleterious effects.   Usually the Espressif stacks are running at a pretty high priority so get the CPU time they need.  Of course you could create a task or tasks that would impact them so it's up to you to test your system.

I generally am conscious of when designing and then profile my tasks to understand what kind of load they put on the CPU (and memory system).  I usually try to design tasks so they have idle periods between evaluation periods (conscious of the minimum time slice - usually 10 mSec - the scheduler uses) so the OS has plenty of time to schedule them with other things.  When using hardware interfaces it is much more efficient to have the interface use a DMA engine to move data to/from buffers (rather, for example, than the typical Arduino way of moving a byte at a time under CPU control).

With some thought - and profiling - I've been quite impressed at how much real time data processing I can do on the dual CPU ESP32 cores.
 
The following users thanked this post: Lindley


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf