Espressif ESP32-S2 Programming Manual page 1454

Table of Contents

Advertisement

Chapter 4. API Guides
• Wi-Fi wpa_supplicant component may create dedicated tasks while the Wi-Fi Protected Setup (WPS), WPA2
EAP-TLS, Device Provisioning Protocol (DPP) or BSS Transition Management (BTM) features are in use.
These tasks all have low priority (2).
• The Ethernet driver creates a task for the MAC to receive Ethernet frames. If using the default config
ETH_MAC_DEFAULT_CONFIG then the priority is medium-high (15). This setting can be changed by pass-
ing a custom
eth_mac_config_t
• If using the
mDNS
component, it creates a task with default low priority 1 (configurable.
• If using the
MQTT
on
CONFIG_MQTT_USE_CUSTOM_CONFIG
esp_mqtt_client_config_t)
Choosing application task priorities
in Wi-Fi operations as starving them of CPU may make the system unstable. For very short timing-critical operations
that don't use the network, use an ISR or a very restricted task (very short bursts of runtime only) at highest priority
(24). Choosing priority 19 will allow lower layer Wi-Fi functionality to run without delays, but still preempts the
lwIP TCP/IP stack and other less time-critical internal functionality - this is the best option for time-critical tasks that
don't perform network operations. Any task that does TCP/IP network operations should run at lower priority than
the lwIP TCP/IP task (18) to avoid priority inversion issues.
Note: Task execution is always completely suspended when writing to the built-in SPI flash chip. Only
Interrupt Handlers
will continue executing.
Improving Interrupt Performance
Each interrupt in the system has a priority, and higher priority interrupts will preempt lower priority ones.
Interrupt handlers will execute in preference to any task (provided the task is not inside a critical section). For this
reason, it's important to minimize the amount of time spent executing in an interrupt handler.
To obtain the best performance for a particular interrupt handler:
• Assign more important interrupts a higher priority using a flag such as ESP_INTR_FLAG_LEVEL2 or
ESP_INTR_FLAG_LEVEL3 when calling esp_intr_alloc().
• If you' re sure the entire interrupt handler can run from IRAM (see
ESP_INTR_FLAG_IRAM flag when calling
being temporarily disabled if the application firmware writes to the internal SPI flash.
• Even if the interrupt handler is not IRAM safe, if it is going to be executed frequently then consider moving the
handler function to IRAM anyhow. This minimizes the chance of a flash cache miss when the interrupt code is
executed (see
Targeted
flag to mark the interrupt as IRAM-safe, if only part of the handler is guaranteed to be in IRAM.
Improving Network Speed
• For Wi-Fi, see
How to improve Wi-Fi performance
• For lwIP TCP/IP (Wi-Fi and Ethernet), see
• The
wifi/iperf
example contains a configuration that is heavily optimized for Wi-Fi TCP/IP through-
put. Append the contents of the files wifi/iperf/sdkconfig.defaults,
wifi/iperf/sdkconfig.ci.99
of these options may have trade-offs in terms of reduced debuggability, increased firmware size, increased
memory usage, or reduced performance of other features. To get the best result, read the documentation pages
linked above and use this information to determine exactly which options are best suited for your app.
Minimizing Binary Size
The ESP-IDF build system compiles all source files in the project and ESP-IDF, but only functions and variables that
are actually referenced by the program are linked into the final binary. In some cases, it is necessary to reduce the
total size of the firmware binary (for example, in order to fit it into the available flash partition size).
Espressif Systems
struct when initializing the Ethernet MAC.
component, it creates a task with default priority 5 (configurable, depends
(also configurable runtime by task_prio field in the
In general, it' s not recommended to set task priorities higher than the built-
ESP-IDF supports dynamic
esp_intr_alloc()
Optimizations). It's possible to do this without adding the ESP_INTR_FLAG_IRAM
Performance Optimization
to your project sdkconfig file in order to add all of these options. Note that some
1443
Submit Document Feedback
Interrupt allocation
IRAM-Safe Interrupt
to assign the interrupt. This prevents it
and
Wi-Fi Buffer Usage
wifi/iperf/sdkconfig.defaults.esp32s2
IRAM-Safe
with interrupt preemption.
Handlers) then set the
and
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents

Save PDF