EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1370 background imageLoading...
Page #1370 background image
Chapter 4. API Guides
Although an SMP system allows threads to switch cores, there are scenarios where a thread must/should only run on
a particular core. Therefore, threads in an SMP systems will also have a core affinity that specifies which particular
core the thread is allowed to run on.
A thread that is pinned to a particular core will only be able to run on that core
A thread that is unpinned will be allowed to switch between cores during execution instead of being pinned to
a particular core.
SMP on an ESP Target
ESP targets (such as the ESP32, ESP32-S3) are dual core SMP SoCs. These targets have the following hardware
features that make them SMP capable:
Two identical cores known as CPU0 (i.e., Protocol CPU or PRO_CPU) and CPU1 (i.e., Application CPU or
APP_CPU). This means that the execution of a piece of code is identical regardless of which core it runs on.
Symmetric memory (with some small exceptions).
If multiple cores access the same memory address, their access will be serialized at the memory bus level.
True atomic access to the same memory address is achieved via an atomic compare-and-swap instruction
provided by the ISA.
Cross-core interrupts that allow one CPU to trigger and interrupt on another CPU. This allows cores to signal
each other.
Note: ThePRO_CPUandAPP_CPUaliases for CPU0 and CPU1 exist in ESP-IDF as they reflect how typical
IDF applications will utilize the two CPUs. Typically, the tasks responsible for handling wireless networking (e.g.,
WiFi or Bluetooth) will be pinned to CPU0 (thus the name PRO_CPU), whereas the tasks handling the remainder
of the application will be pinned to CPU1 (thus the name APP_CPU).
4.14.3 Tasks
Creation
Vanilla FreeRTOS provides the following functions to create a task:
xTaskCreate() creates a task. The tasks memory is dynamically allocated
xTaskCreateStatic() creates a task. The tasks memory is statically allocated (i.e., provided by the
user)
However, in an SMP system, tasks need to be assigned a particular affinity. Therefore, ESP-IDF provides a Pinned-
ToCore version of Vanilla FreeRTOSs task creation functions:
xTaskCreatePinnedToCore() creates a task with a particular core affinity. The tasks memory is
dynamically allocated.
xTaskCreateStaticPinnedToCore() creates a task with a particular core affinity. The tasks mem-
ory is statically allocated (i.e., provided by the user)
The PinnedToCore versions of the task creation functions API differ from their vanilla counter parts by having an
extra xCoreID parameter that is used to specify the created tasks core affinity. The valid values for core affinity
are:
0 which pins the created task to CPU0
1 which pins the created task to CPU1
tskNO_AFFINITY which allows the task to be run on both CPUs
Note that ESP-IDF FreeRTOS still supports the vanilla versions of the task creation functions. However, they have
been modified to simply call their PinnedToCore counterparts with tskNO_AFFINITY.
Note: ESP-IDF FreeRTOS also changes the units of ulStackDepth in the task creation functions. Task stack
sizes in Vanilla FreeRTOS are specified in number of words, whereas in ESP-IDF FreeRTOS, the task stack sizes
Espressif Systems 1359
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish