Esp32 Technical Reference Manual en
Esp32 Technical Reference Manual en
www.espressif.com
About This Manual
The ESP32 Technical Reference Manual is addressed to application developers. The manual provides detailed
and complete information on how to use the ESP32 memory and peripherals.
For pin definition, electrical characteristics, and package information, please see ESP32 Datasheet.
Document Updates
Please always refer to the latest version at https://www.espressif.com/en/support/download/documents.
Revision History
For any changes to this document over time, please refer to the last page.
Certification
Download certificates for Espressif products from www.espressif.com/en/certificates.
Contents
Contents
3.2.4.2 REF_TICK 43
3.2.4.3 LEDC_SCLK Source 44
3.2.4.4 APLL_SCLK Source 44
3.2.4.5 PLL_F160M_CLK Source 44
3.2.4.6 Clock Source Considerations 44
3.2.5 Wi-Fi BT Clock 44
3.2.6 RTC Clock 45
3.2.7 Audio PLL 45
3.3 Register Summary 45
3.4 Registers 46
5 DPort Registers 94
5.1 Introduction 94
5.2 Features 94
Glossary 732
Abbreviations for Peripherals 732
Abbreviations for Registers 732
List of Tables
1-1 Address Mapping 26
1-2 Embedded Memory Address Mapping 28
1-3 Module with DMA 30
1-4 External Memory Address Mapping 30
1-5 Cache memory mode 31
1-6 Peripheral Address Mapping 32
2-1 PRO_CPU, APP_CPU Interrupt Configuration 36
2-2 CPU Interrupts 38
3-1 PRO_CPU and APP_CPU Reset Reason Values 40
3-2 CPU_CLK Source 42
3-3 CPU_CLK Derivation 42
3-4 Peripheral Clock Usage 43
3-5 APB_CLK 43
3-6 REF_TICK 44
3-7 LEDC_SCLK Derivation 44
4-1 IO_MUX Light-sleep Pin Function Registers 54
4-2 GPIO Matrix Peripheral Signals 56
4-3 IO_MUX Pad Summary 61
4-4 RTC_MUX Pin Summary 62
4-8 Mapping of Bits to Pins 83
7-1 Mapping Between SPI Bus Signals and Pin Function Signals 127
7-2 Command Definitions Supported by GP-SPI Slave in Half-duplex Mode 129
7-3 Clock Polarity and Phase, and Corresponding SPI Register Values for SPI Master 131
7-4 Clock Polarity and Phase, and Corresponding SPI Register Values for SPI Slave 131
9-1 SD/MMC Signal Description 195
9-2 DES0 201
9-3 DES1 202
9-4 DES2 202
9-5 DES3 202
9-6 SD/MMC Timing Requirements 204
10-1 Destination Address Filtering 233
10-2 Source Address Filtering 233
10-3 Timing Parameters - Receiving Data 238
10-4 Timing Parameters – Transmitting Data 239
10-5 Transmit Descriptor 0 (TDES0) 240
10-6 Transmit Descriptor 1 (TDES1) 244
10-7 Transmit Descriptor 2 (TDES2) 244
10-8 Transmit Descriptor 3 (TDES3) 244
10-9 Receive Descriptor 0 (RDES0) 245
10-10 Receive Descriptor 1 (RDES1) 247
10-11 Receive Descriptor 2 (RDES2) 248
10-12 Receive Descriptor 3 (RDES3) 248
10-13 Receive Descriptor 4 (RDES4) 248
27-4 Page Mode of MMU for the Remaining 128 KB of Internal SRAM0 and SRAM2 614
27-5 Page Boundaries for SRAM0 MMU 615
27-6 Page Boundaries for SRAM2 MMU 615
27-7 DPORT_DMMU_TABLEn_REG & DPORT_IMMU_TABLEn_REG 616
27-8 MPU for DMA 617
27-9 Virtual Address for External Memory 619
27-10 MMU Entry Numbers for PRO_CPU 619
27-11 MMU Entry Numbers for APP_CPU 619
27-12 MMU Entry Numbers for PRO_CPU (Special Mode) 620
27-13 MMU Entry Numbers for APP_CPU (Special Mode) 620
27-14 Virtual Address Mode for External SRAM 621
27-15 Virtual Address for External SRAM ( Normal Mode ) 622
27-16 Virtual Address for External SRAM ( Low-High Mode ) 622
27-17 Virtual Address for External SRAM (Even-Odd Mode) 622
27-18 MMU Entry Numbers for External RAM 623
27-19 MPU for Peripheral 624
27-20 DPORT_AHBLITE_MPU_TABLE_X_REG 625
28-1 Interrupt Vector Entry Address 627
28-2 Configuration of PIDCTRL_LEVEL_REG 627
28-3 Configuration of PIDCTRL_FROM_n_REG 628
29-1 ESP32 Capacitive Sensing Touch Pads 638
29-2 Inputs of SAR ADC 643
29-3 ESP32 SAR ADC Controllers 643
29-4 Fields of the Pattern Table Register 645
29-5 Fields of Type I DMA Data Format 646
29-6 Fields of Type II DMA Data Format 646
30-1 ALU Operations Among Registers 667
30-2 ALU Operations with Immediate Value 668
30-3 ALU Operations with Stage Count Register 669
30-4 Input Signals Measured Using the ADC Instruction 673
31-1 RTC Power Domains 696
31-2 Wake-up Source 700
List of Figures
1-1 System Structure 25
1-2 System Address Mapping 25
1-3 Cache Block Diagram 31
2-1 Interrupt Matrix Structure 35
3-1 System Reset 40
3-2 System Clock 41
4-1 IO_MUX, RTC IO_MUX and GPIO Matrix Overview 49
4-2 Peripheral Input via IO_MUX, GPIO Matrix 50
4-3 Output via GPIO Matrix 52
4-4 ESP32 I/O Pad Power Sources (QFN 6*6, Top View) 55
4-5 ESP32 I/O Pad Power Sources (QFN 5*5, Top View) 56
6-1 DMA Engine Architecture 122
6-2 Linked List Structure 123
6-3 Data Transfer in UDMA Mode 124
6-4 SPI DMA 125
7-1 SPI Architecture 127
7-2 SPI Master and Slave Full-duplex/Half-duplex Communication 128
7-3 SPI Data Buffer 130
7-4 GP-SPI ������ 133
7-5 Parallel QSPI 133
7-6 Communication Format of Parallel QSPI 134
8-1 SDIO Slave Block Diagram 161
8-2 SDIO Bus Packet Transmission 162
8-3 CMD53 Content 162
8-4 SDIO Slave DMA Linked List Structure 163
8-5 SDIO Slave Linked List 163
8-6 Packet Sending Procedure (Initiated by Slave) 164
8-7 Packet Receiving Procedure (Initiated by Host) 165
8-8 Loading Receiving Buffer 166
8-9 Sampling Timing Diagram 166
8-10 Output Timing Diagram 167
9-1 SD/MMC Controller Topology 194
9-2 SD/MMC Controller External Interface Signals 195
9-3 SDIO Host Block Diagram 196
9-4 Command Path State Machine 197
9-5 Data Transmit State Machine 198
9-6 Data Receive State Machine 198
9-7 Descriptor Chain 200
9-8 The Structure of a Linked List 201
9-9 SD/MMC Timing in HS Mode 204
9-10 Clock Phase Selection 205
10-1 Ethernet MAC Functionality Overview 226
10-2 Ethernet Block Diagram 228
1.1 Introduction
The ESP32 is a dual-core system with two Harvard Architecture Xtensa LX6 CPUs. All embedded memory,
external memory and peripherals are located on the data bus and/or the instruction bus of these CPUs.
With some minor exceptions (see below), the address mapping of two CPUs is symmetric, meaning that they
use the same addresses to access the same memory. Multiple peripherals in the system can access embedded
memory via DMA.
The two CPUs are named “PRO_CPU” and “APP_CPU” (for “protocol” and “application”), however, for most
purposes the two CPUs are interchangeable.
1.2 Features
• Address Space
– 4 GB (32-bit) address space for both data bus and instruction bus
– Some embedded and external memory regions can be accessed by either data bus or instruction
bus
• Embedded Memory
• External Memory
Off-chip SPI memory can be mapped into the available address space as external memory. Parts of the
embedded memory can be used as transparent cache for this external memory.
• Peripherals
– 41 peripherals
• DMA
The block diagram in Figure 1-1 illustrates the system structure, and the block diagram in Figure 1-2 illustrates the
address map structure.
Addresses below 0x4000_0000 are serviced using the data bus. Addresses in the range 0x4000_0000 ~
0x4FFF_FFFF are serviced using the instruction bus. Finally, addresses over and including 0x5000_0000 are
shared by the data and instruction bus.
The data bus and instruction bus are both little-endian: for example, byte addresses 0x0, 0x1, 0x2, 0x3 access
the least significant, second least significant, second most significant, and the most significant bytes of the
32-bit word stored at the 0x0 address, respectively. The CPU can access data bus addresses via aligned or
non-aligned byte, half-word and word read-and-write operations. The CPU can read and write data through the
instruction bus, but only in a word aligned manner; non-word-aligned access will cause a CPU exception.
Each CPU can directly access embedded memory through both the data bus and the instruction bus, external
memory which is mapped into the address space (via transparent caching & MMU), and peripherals. Table 1-1
illustrates address ranges that can be accessed by each CPU’s data bus and instruction bus.
Some embedded memories and some external memories can be accessed via the data bus or the instruction
bus. In these cases, the same memory is available to either of the CPUs at two address ranges.
Boundary Address
Bus Type Size Target
Low Address High Address
0x0000_0000 0x3F3F_FFFF Reserved
Data 0x3F40_0000 0x3F7F_FFFF 4 MB External Memory
Data 0x3F80_0000 0x3FBF_FFFF 4 MB External Memory
0x3FC0_0000 0x3FEF_FFFF 3 MB Reserved
Data 0x3FF0_0000 0x3FF7_FFFF 512 KB Peripheral
Data 0x3FF8_0000 0x3FFF_FFFF 512 KB Embedded Mem-
ory
Instruction 0x4000_0000 0x400C_1FFF 776 KB Embedded Mem-
ory
Instruction 0x400C_2000 0x40BF_FFFF 11512 KB External Memory
0x40C0_0000 0x4FFF_FFFF 244 MB Reserved
Data / Instruction 0x5000_0000 0x5000_1FFF 8 KB Embedded Mem-
ory
0x5000_2000 0xFFFF_FFFF Reserved
The 448 KB internal ROM is divided into two parts: Internal ROM 0 (384 KB) and Internal ROM 1 (64 KB). The 520
KB internal SRAM is divided into three parts: Internal SRAM 0 (192 KB), Internal SRAM 1 (128 KB), and Internal
SRAM 2 (200 KB). RTC FAST Memory and RTC SLOW Memory are both implemented as SRAM.
Table 1-2 lists all embedded memories and their address ranges on the data and instruction buses.
Boundary Address
Bus Type Size Target Comment
Low Address High Address
Data 0x3FF8_0000 0x3FF8_1FFF 8 KB RTC FAST Memory PRO_CPU Only
0x3FF8_2000 0x3FF8_FFFF 56 KB Reserved -
Data 0x3FF9_0000 0x3FF9_FFFF 64 KB Internal ROM 1 -
0x3FFA_0000 0x3FFA_DFFF 56 KB Reserved -
Data 0x3FFA_E000 0x3FFD_FFFF 200 KB Internal SRAM 2 DMA
Data 0x3FFE_0000 0x3FFF_FFFF 128 KB Internal SRAM 1 DMA
Boundary Address
Bus Type Size Target Comment
Low Address High Address
Instruction 0x4000_0000 0x4000_7FFF 32 KB Internal ROM 0 Remap
Instruction 0x4000_8000 0x4005_FFFF 352 KB Internal ROM 0 -
0x4006_0000 0x4006_FFFF 64 KB Reserved -
Instruction 0x4007_0000 0x4007_FFFF 64 KB Internal SRAM 0 Cache
Instruction 0x4008_0000 0x4009_FFFF 128 KB Internal SRAM 0 -
Instruction 0x400A_0000 0x400A_FFFF 64 KB Internal SRAM 1 -
Instruction 0x400B_0000 0x400B_7FFF 32 KB Internal SRAM 1 Remap
Instruction 0x400B_8000 0x400B_FFFF 32 KB Internal SRAM 1 -
Instruction 0x400C_0000 0x400C_1FFF 8 KB RTC FAST Memory PRO_CPU Only
Boundary Address
Bus Type Size Target Comment
Low Address High Address
Data Instruc-
0x5000_0000 0x5000_1FFF 8 KB RTC SLOW Memory -
tion
The address range of the first 32 KB of the ROM 0 (0x4000_0000 ~ 0x4000_7FFF) can be remapped in order
to access a part of Internal SRAM 1 that normally resides in a memory range of 0x400B_0000 ~ 0x400B_7FFF.
While remapping, the 32 KB SRAM cannot be accessed by an address range of 0x400B_0000 ~ 0x400B_7FFF
any more, but it can still be accessible through the data bus (0x3FFE_8000 ~ 0x3FFE_FFFF). This can be done
on a per-CPU basis: setting bit 0 of register DPORT_PRO_BOOT_REMAP_CTRL_REG or DPORT_APP_BOOT_REMAP_CTRL_REG
will remap SRAM for the PRO_CPU and APP_CPU, respectively.
0x4007_0000 ~ 0x4007_FFFF of the instruction bus. The remaining 128 KB can always be read and written by
either CPU at addresses 0x4008_0000 ~ 0x4009_FFFF of instruction bus.
The address range accessed via the instruction bus is in reverse order (word-wise) compared to access via the
data bus. That is to say, address
0x3FFE_0000 and 0x400B_FFFC access the same word
0x3FFE_0004 and 0x400B_FFF8 access the same word
0x3FFE_0008 and 0x400B_FFF4 access the same word
……
0x3FFF_FFF4 and 0x400A_0008 access the same word
0x3FFF_FFF8 and 0x400A_0004 access the same word
0x3FFF_FFFC and 0x400A_0000 access the same word
The data bus and instruction bus of the CPU are still both little-endian, so the byte order of individual words is
not reversed between address spaces. For example, address
0x3FFE_0000 accesses the least significant byte in the word accessed by 0x400B_FFFC.
0x3FFE_0001 accesses the second least significant byte in the word accessed by 0x400B_FFFC.
0x3FFE_0002 accesses the second most significant byte in the word accessed by 0x400B_FFFC.
0x3FFE_0003 accesses the most significant byte in the word accessed by 0x400B_FFFC.
0x3FFE_0004 accesses the least significant byte in the word accessed by 0x400B_FFF8.
0x3FFE_0005 accesses the second least significant byte in the word accessed by 0x400B_FFF8.
0x3FFE_0006 accesses the second most significant byte in the word accessed by 0x400B_FFF8.
0x3FFE_0007 accesses the most significant byte in the word accessed by 0x400B_FFF8.
……
0x3FFF_FFF8 accesses the least significant byte in the word accessed by 0x400A_0004.
0x3FFF_FFF9 accesses the second least significant byte in the word accessed by 0x400A_0004.
0x3FFF_FFFA accesses the second most significant byte in the word accessed by 0x400A_0004.
0x3FFF_FFFB accesses the most significant byte in the word accessed by 0x400A_0004.
0x3FFF_FFFC accesses the least significant byte in the word accessed by 0x400A_0000.
0x3FFF_FFFD accesses the second most significant byte in the word accessed by 0x400A_0000.
0x3FFF_FFFE accesses the second most significant byte in the word accessed by 0x400A_0000.
0x3FFF_FFFF accesses the most significant byte in the word accessed by 0x400A_0000.
Part of this memory can be remapped onto the ROM 0 address space. See Internal Rom 0 for more informa-
tion.
1.3.2.6 DMA
DMA uses the same addressing as the CPU data bus to read and write Internal SRAM 1 and Internal SRAM 2.
This means DMA uses an address range of 0x3FFE_0000 ~ 0x3FFF_FFFF to read and write Internal SRAM 1
and an address range of 0x3FFA_E000 ~ 0x3FFD_FFFF to read and write Internal SRAM 2.
In the ESP32, 13 peripherals are equipped with DMA. Table 1-3 lists these peripherals.
The two address ranges of PRO_CPU access RTC FAST Memory in the same order, so, for example, addresses
0x3FF8_0000 and 0x400C_0000 access the same word. On the APP_CPU, these address ranges do not
provide access to RTC FAST Memory or any other memory location.
Boundary Address
Bus Type Size Target Comment
Low Address High Address
Data 0x3F40_0000 0x3F7F_FFFF 4 MB External Flash Read
Data 0x3F80_0000 0x3FBF_FFFF 4 MB External SRAM Read and Write
Boundary Address
Bus Type Size Target Comment
Low Address High Address
1.3.4 Cache
As shown in Figure 1-3, each of the two CPUs in ESP32 has 32 KB of cache featuring a block size of 32 bytes for
accessing external storage. PRO CPU uses bit PRO_CACHE_ENABLE in register DPORT_PRO_CACHE_CTRL_REG
to enable the Cache, while APP CPU uses bit APP_CACHE_ENABLE in register DPORT_APP_CACHE_CTRL_REG
to enable the same function.
ESP32 uses a two-way set-associative cache. When the Cache function is to be used either by PRO CPU or APP
CPU, bit CACHE_MUX_MODE[1:0] in register DPORT_CACHE_MUX_MODE_REG can be set to select POOL0 or
POOL1 in the Internal SRAM0 as the cache memory. When both PRO CPU and APP CPU use the Cache function,
POOL0 and POOL1 in the Internal SRAM0 will be used simultaneously as the cache memory, while they can also
be used by the instruction bus. This is depicted in table 1-5 below.
As described in table 1-5, when bit CACHE_MUX_MODE is set to 1 or 2, PRO CPU and APP CPU cannot enable
the Cache function at the same time. When the Cache function is enabled, POOL0 or POOL1 can only be used
as the cache memory, and cannot be used by the instruction bus as well.
ESP32 Cache supports the Flush function. It is worth noting that when the Flush function is used, the data
written in the cache will be disposed rather than being rewritten into the External SRAM. To enable the Flush
function, first clear bit x_CACHE_FLUSH_ENA in register DPORT_x_CACHE_CTRL_REG, then set this bit to 1.
Afterwards, the system hardware will set bit x_CACHE_FLUSH_DONE to 1, where x can be ”PRO” or ”APP”,
indicating that the cache flush operation has been completed.
For more information about the address mapping of ESP32 Cache, please refer to Embedded Memory and
External Memory.
1.3.5 Peripherals
The ESP32 has 41 peripherals. Table 1-6 specifically describes the peripherals and their respective address
ranges. Nearly all peripheral modules can be accessed by either CPU at the same address with just a single
exception; this being the PID Controller.
Boundary Address
Bus Type Size Target Comment
Low Address High Address
Data 0x3FF0_0000 0x3FF0_0FFF 4 KB DPort Register
Data 0x3FF0_1000 0x3FF0_1FFF 4 KB AES Accelerator
Data 0x3FF0_2000 0x3FF0_2FFF 4 KB RSA Accelerator
Data 0x3FF0_3000 0x3FF0_3FFF 4 KB SHA Accelerator
Data 0x3FF0_4000 0x3FF0_4FFF 4 KB Secure Boot
0x3FF0_5000 0x3FF0_FFFF 44 KB Reserved
Data 0x3FF1_0000 0x3FF1_3FFF 16 KB Cache MMU Table
0x3FF1_4000 0x3FF1_EFFF 44 KB Reserved
Data 0x3FF1_F000 0x3FF1_FFFF 4 KB PID Controller Per-CPU peripheral
0x3FF2_0000 0x3FF3_FFFF 128 KB Reserved
Data 0x3FF4_0000 0x3FF4_0FFF 4 KB UART0
0x3FF4_1000 0x3FF4_1FFF 4 KB Reserved
Data 0x3FF4_2000 0x3FF4_2FFF 4 KB SPI1
Data 0x3FF4_3000 0x3FF4_3FFF 4 KB SPI0
Data 0x3FF4_4000 0x3FF4_4FFF 4 KB GPIO
0x3FF4_5000 0x3FF4_7FFF 12 KB Reserved
Data 0x3FF4_8000 0x3FF4_8FFF 4 KB RTC
Data 0x3FF4_9000 0x3FF4_9FFF 4 KB IO MUX
0x3FF4_A000 0x3FF4_AFFF 4 KB Reserved
Data 0x3FF4_B000 0x3FF4_BFFF 4 KB SDIO Slave One of three parts
Data 0x3FF4_C000 0x3FF4_CFFF 4 KB UDMA1
0x3FF4_D000 0x3FF4_EFFF 8 KB Reserved
Data 0x3FF4_F000 0x3FF4_FFFF 4 KB I2S0
Data 0x3FF5_0000 0x3FF5_0FFF 4 KB UART1
0x3FF5_1000 0x3FF5_2FFF 8 KB Reserved
Data 0x3FF5_3000 0x3FF5_3FFF 4 KB I2C0
Data 0x3FF5_4000 0x3FF5_4FFF 4 KB UDMA0
Data 0x3FF5_5000 0x3FF5_5FFF 4 KB SDIO Slave One of three parts
Data 0x3FF5_6000 0x3FF5_6FFF 4 KB RMT
Data 0x3FF5_7000 0x3FF5_7FFF 4 KB PCNT
Data 0x3FF5_8000 0x3FF5_8FFF 4 KB SDIO Slave One of three parts
Boundary Address
Bus Type Size Target Comment
Low Address High Address
Data 0x3FF5_9000 0x3FF5_9FFF 4 KB LED PWM
Data 0x3FF5_A000 0x3FF5_AFFF 4 KB eFuse Controller
Data 0x3FF5_B000 0x3FF5_BFFF 4 KB Flash Encryption
0x3FF5_C000 0x3FF5_DFFF 8 KB Reserved
Data 0x3FF5_E000 0x3FF5_EFFF 4 KB MCPWM0
Data 0x3FF5_F000 0x3FF5_FFFF 4 KB TIMG0
Data 0x3FF6_0000 0x3FF6_0FFF 4 KB TIMG1
0x3FF6_1000 0x3FF6_3FFF 12 KB Reserved
Data 0x3FF6_4000 0x3FF6_4FFF 4 KB SPI2
Data 0x3FF6_5000 0x3FF6_5FFF 4 KB SPI3
Data 0x3FF6_6000 0x3FF6_6FFF 4 KB SYSCON
Data 0x3FF6_7000 0x3FF6_7FFF 4 KB I2C1
Data 0x3FF6_8000 0x3FF6_8FFF 4 KB SDMMC
Data 0x3FF6_9000 0x3FF6_AFFF 8 KB EMAC
Data 0x3FF6_B000 0x3FF6_BFFF 4KB TWAI
Data 0x3FF6_C000 0x3FF6_CFFF 4 KB MCPWM1
Data 0x3FF6_D000 0x3FF6_DFFF 4 KB I2S1
Data 0x3FF6_E000 0x3FF6_EFFF 4 KB UART2
Data 0x3FF6_F000 0x3FF6_FFFF 4 KB Reserved
Data 0x3FF7_0000 0x3FF7_0FFF 4 KB Reserved
0x3FF7_1000 0x3FF7_4FFF 16 KB Reserved
Data 0x3FF7_5000 0x3FF7_5FFF 4 KB RNG
0x3FF7_6000 0x3FF7_FFFF 40 KB Reserved
Notice:
• Peripherals accessed by the CPU via 0x3FF40000 ~ 0x3FF7FFFF address space (DPORT address) can
also be accessed via 0x60000000 ~ 0x6003FFFF (AHB address). (0x3FF40000 + n) address and
(0x60000000 + n) address access the same content, where n = 0 ~ 0x3FFFF.
• The CPU can access peripherals via DPORT address more efficiently than via AHB address. However,
DPORT address is characterized by speculative reads, which means it cannot guarantee that each read
is valid. In addition, DPORT address will upset the order of r/w operations on the bus to improve perfor-
mance, which may cause programs that have strict requirements on the r/w order to crash. On the other
hand, using AHB address to read FIFO registers will cause unpredictable errors. To address above issues
please strictly follow the instructions documented in ESP32 ECO and Workarounds for Bugs, specifically
sections 3.3, 3.10, 3.16, and 3.17.
Internally, the SRAM is organized in 32K-sized banks. Each CPU and DMA channel can simultaneously access
the SRAM at full speed, provided they access addresses in different memory banks.
2.1 Overview
The Interrupt Matrix embedded in the ESP32 independently allocates peripheral interrupt sources to the two
CPUs’ peripheral interrupts. This configuration is made to be highly flexible in order to meet many different
needs.
2.2 Features
• Accepts 71 peripheral interrupt sources as input.
The four remaining peripheral interrupt sources are CPU-specific, two per CPU. GPIO_INTERRUPT_PRO and
GPIO_INTERRUPT_PRO_NMI can only be allocated to PRO_CPU. GPIO_INTERRUPT_APP and GPIO_INTERRUPT
_APP_NMI can only be allocated to APP_CPU. As a result, PRO_CPU and APP_CPU each have 69 peripheral
interrupt sources.
• PRO_X_MAP_REG (or APP_X_MAP_REG) stands for any particular peripheral interrupt configuration reg-
ister of the PRO_CPU (or APP_CPU). The peripheral interrupt configuration register corresponds to the
peripheral interrupt source Source_X. In Table 2-1 the registers listed under “PRO_CPU (APP_CPU) - Pe-
ripheral Interrupt Configuration Register” correspond to the peripheral interrupt sources listed in “Peripheral
Interrupt Source - Name”.
• Interrupt_P stands for CPU peripheral interrupt, numbered as Num_P. Num_P can take the ranges 0 ~ 5,
8 ~ 10, 12 ~ 14, 17 ~ 28, 30 ~ 31.
• Interrupt_I stands for the CPU internal interrupt numbered as Num_I. Num_I can take values 6, 7, 11, 15, 16,
29.
Using this terminology, the possible operations of the Interrupt Matrix controller can be described as fol-
lows:
• Allocate multiple peripheral sources Source_Xn ORed to PRO_CPU (APP_CPU) peripheral interrupt
Set multiple PRO_Xn_MAP_REG (APP_Xn_MAP_REG) to the same Num_P. Any of these peripheral inter-
rupts will trigger CPU Interrupt_P.
2.4 Registers
The interrupt matrix registers are part of the DPORT registers and are described in Section 5.4 in Chapter 5 DPort
Registers.
• CPU reset: Only resets the registers of one or both of the CPU cores.
• Core reset: Resets all the digital registers, including CPU cores, external GPIO and digital GPIO. The RTC
is not reset.
• System reset: Resets all the registers on the chip, including those of the RTC.
– PLL_CLK is an internal PLL clock with a frequency of 320 MHz or 480 MHz.
– XTL_CLK is a clock signal generated using an external crystal with a frequency range of 2 ~ 40 MHz.
– RC_FAST_CLK is an internal clock with a default frequency of 8 MHz. This frequency is adjustable.
– RC_FAST_DIV_CLK is divided from RC_FAST_CLK. Its frequency is (RC_FAST_CLK / 256). With the
default RC_FAST_CLK frequency of 8 MHz, this clock runs at 31.250 KHz.
– RC_SLOW_CLK is an internal low power clock with a default frequency of 150 KHz. This frequency is
adjustable.
• Audio Clock
– APLL_CLK is an internal Audio PLL clock with a frequency range of 16 ~ 128 MHz.
The CPU_CLK clock source is determined by the RTC_CNTL_SOC_CLK_SEL register. PLL_CLK, APLL_CLK,
RC_FAST_CLK, and XTL_CLK can be set as the CPU_CLK source; see Table 3-2 and 3-3.
3.2.4.1 APB_CLK
The APB_CLK frequency is determined by CPU_CLK source, as detailed in Table 3-5.
3.2.4.2 REF_TICK
REF_TICK is derived from APB_CLK. The APB_CLK frequency is determined by CPU_CLK source. The REF_TICK
frequency should be fixed. When CPU_CLK source changes, users need to make sure the REF_TICK frequency
remains unchanged by setting a correct divider value.
For example, when CPU_CLK source is PLL_CLK and users need to keep the REF_TICK frequency at 1 MHz,
then they should set SYSCON_PLL_TICK_NUM to 79 (0x4F) so that the REF_TICK frequency = 80 MHz / (79+1)
= 1 MHz.
The LED PWM module can use RC_FAST_CLK as a clock source when APB_CLK is disabled. In other words,
when the system is in low-power consumption mode (see Power Management Chapter), normal peripherals will
be halted (APB_CLK is turned off), but the LED PWM can work normally via RC_FAST_CLK.
RTC_SLOW_CLK is used to clock the Power Management module. It can be sourced from RC_SLOW_CLK,
XTL32K_CLK or RC_FAST_DIV_CLK.
RTC_FAST_CLK is used to clock the On-chip Sensor module. It can be sourced from a divided XTL_CLK or from
RC_FAST_CLK.
Providing an integrated precision clock source can minimize system cost. To this end, ESP32 integrates an
audio PLL. The Audio PLL formula is as follows:
The operating frequency range of the numerator is 350 MHz ~ 500 MHz:
sdm1 sdm0
350M Hz < fxtal (sdm2 + + + 4) < 500M Hz
28 216
Please note that sdm1 and sdm0 are not available on revision0 of ESP32. Please consult the silicon revision in
ECO and Workarounds for Bugs in ESP32 for further details.
Audio PLL can be manually enabled or disabled via registers RTC_CNTL_PLLA_FORCE_PU and RTC_CNTL_PLLA
_FORCE_PD, respectively. Disabling it takes priority over enabling it. When RTC_CNTL_PLLA_FORCE_PU and
RTC_CNTL_PLLA_FORCE_PD are 0, PLL will follow the state of the system, i.e., when the system enters sleep
mode, PLL will be disabled automatically; when the system wakes up, PLL will be enabled automatically.
3.4 Registers
The addresses in this section are relative to the SYSCON base address provided in Table 1-6 Peripheral Address
Mapping in Chapter 1 System and Memory.
T
CN
IV_
_D
RE
_P
)
ed
ON
rv
SC
se
(re
SY
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
SYSCON_PRE_DIV_CNT Configures the divider value of CPU_CLK when the source of CPU_CLK
is XTL_CLK or RC_FAST_CLK. The value range is 0x0 ~ 0x3FF. CPU_CLK = XTL_CLK ( or
RC_FAST_CLK) / (the value of this field +1). (R/W)
M
NU
K_
IC
_T
L
TA
_X
)
ed
ON
rv
SC
se
(re
SY
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 Reset
SYSCON_XTAL_TICK_NUM Configures the divider value of REF_TICK when the source of APB_CLK
is XTL_CLK. The value range is 0x0 ~ 0xFF. REF_TICK = APB_CLK /(the value of this field + 1).
(R/W)
M
NU
K_
IC
_T
LL
_P
d)
ve
ON
r
SC
se
(re
SY
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 79 Reset
SYSCON_PLL_TICK_NUM Configures the divider value of REF_TICK when the source of APB_CLK
is PLL_CLK. The value range is 0x0 ~ 0xFF. REF_TICK = APB_CLK /(the value of this field + 1).
(R/W)
UM
_N
ICK
_T
K8M
_C
)
ed
ON
rv
SC
se
(re
SY
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 Reset
SYSCON_CK8M_TICK_NUM Configures the divider value of REF_TICK when the source of APB_CLK
is FOSC_CLK. The value range is 0x0 ~ 0xFF. REF_TICK = APB_CLK /(the value of this field + 1).
(R/W)
ON
rv
SC
se
(re
SY
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 99 Reset
SYSCON_APLL_TICK_NUM Configures the divider value of REF_TICK when the source of APB_CLK
is APLL_CLK. The value range is 0x0 ~ 0xFF. REF_TICK = APB_CLK /(the value of this field + 1).
(R/W)
E
AT
_D
ON
SC
SY
31 0
0x16042000 Reset
SYSCON_DATE Chip revision register. For more information see ESP32 Series SoC Errata. (R/W)
4.1 Overview
The ESP32 chip features 34 physical GPIO pads. Each pad can be used as a general-purpose I/O, or be
connected to an internal peripheral signal. The IO_MUX, RTC IO_MUX and the GPIO matrix are responsible
for routing signals from the peripherals to GPIO pads. Together these systems provide highly configurable
I/O.
Note that the I/O GPIO pads are 0-19, 21-23, 25-27, 32-39, while the output GPIOs are 0-19, 21-23, 25-27,
32-33. GPIO pads 34-39 are input-only.
GPIO 20 serves as a valid input and output only on ESP32-PICO-V3 and ESP32-PICO-V3-02. Please refer to
ESP32-PICO Series Datasheet for more information.
This chapter describes the signal selection and connection between the digital pads (FUN_SEL, IE, OE, WPU,
WDU, etc.), 162 peripheral input and 176 output signals (control signals: SIG_IN_SEL, SIG_OUT_SEL, IE, OE,
etc.), fast peripheral input/output signals (control signals: IE, OE, etc.), and RTC IO_MUX.
1. The IO_MUX contains one register per GPIO pad. Each pad can be configured to perform a ”GPIO” function
(when connected to the GPIO Matrix) or a direct function (bypassing the GPIO Matrix). Some high-speed
digital functions (Ethernet, SDIO, SPI, JTAG, UART) can bypass the GPIO Matrix for better high-frequency
digital performance. In this case, the IO_MUX is used to connect these pads directly to the peripheral.)
See Section 4.10 for a list of IO_MUX functions for each I/O pad.
2. The GPIO Matrix is a full-switching matrix between the peripheral input/output signals and the pads.
• For input to the chip: Each of the 162 internal peripheral inputs can select any GPIO pad as the input
source.
• For output from the chip: The output signal of each of the 34 GPIO pads can be from one of the 176
3. RTC IO_MUX is used to connect GPIO pads to their low-power and analog functions. Only a subset of
GPIO pads have these optional ”RTC” functions.
The input signal is read from the GPIO pad through the IO_MUX. The IO_MUX must be configured to set the
chosen pad to ”GPIO” function. This causes the GPIO pad input signal to be routed into the GPIO Matrix, which
in turn routes it to the selected peripheral input.
To read GPIO pad X into peripheral signal Y, follow the steps below:
1. Configure the GPIO_FUNCy_IN_SEL_CFG register corresponding to peripheral signal Y in the GPIO Matrix:
• Set the GPIO_FUNCy_IN_SEL field in this register, corresponding to the GPIO pad X to read from.
2. Configure the GPIO_FUNCx_OUT_SEL_CFG register and clear the GPIO_ENABLE_DATA[x] field correspond-
ing to GPIO pad X in the GPIO Matrix:
• Set the GPIO_FUNCx_OEN_SEL bit in the GPIO_FUNCx_OUT_SEL_CFG register to force the pin’s
output state to be determined always by the GPIO_ENABLE_DATA[x] field.
3. Configure the IO_MUX to select the GPIO Matrix. Set the IO_MUX_x_REG register corresponding to GPIO
pad X as follows:
• Set the function field (MCU_SEL) to the IO_MUX function corresponding to GPIO X (this is Function
2—numeric value 2—for all pins).
• Set or clear the FUN_WPU and FUN_WPD bits, as desired, to enable/disable internal pull-up/pull-
down resistors.
Notes:
• It is possible to have a peripheral read a constantly low or constantly high input value without connecting
this input to a pad. This can be done by selecting a special GPIO_FUNCy_IN_SEL input, instead of a GPIO
number:
For example, to connect RMT peripheral channel 0 input signal (RMT_SIG_IN0_IDX, signal index 83) to GPIO 15,
please follow the steps below. Note that GPIO 15 is also named the MTDO pin:
4. Set the IO_MUX_GPIO15 register MCU_SEL field to 2 (GPIO function) and also set the FUN_IE bit (input
mode).
The input value of any GPIO pin can be read at any time without configuring the GPIO Matrix for a particular
peripheral signal. However, it is necessary to enable the input in the IO_MUX by setting the FUN_IE bit in the
IO_MUX_x_REG register corresponding to pad X, as mentioned in Section 4.2.2.
4.3 Peripheral Output via GPIO Matrix
4.3.1 Summary
To output a signal from a peripheral via the GPIO Matrix, the GPIO Matrix is configured to route the peripheral
output signal (0-18, 23-37, 61-121, 140-125, 224-228) to one of the 28 GPIOs (0-19, 21-23, 25-27, 32-33).
The output signal is routed from the peripheral into the GPIO Matrix. It is then routed into the IO_MUX, which is
configured to set the chosen pad to ”GPIO” function. This causes the output GPIO signal to be connected to
the pad.
Note:
The peripheral output signals 224 to 228 can be configured to be routed in from one GPIO and output directly from
another GPIO.
signal0_out 0 MCU_SEL
signal1_out 1
signal2_out 2
signal3_out 3
0 (FUNC)
1 (FUNC)
GPIO X out I/O Pad x
2 (GPIO)
GPIOx_out
signal228_out 228
FUN_OE = 1
GPIO_OUT_DATA bit x 256 (0x100)
256sdfsdfasdfgas
• Set the GPIO_FUNCx_OUT_SEL field in GPIO_FUNCx_OUT_SEL_CFG to the numeric index (Y) of de-
sired peripheral output signal Y.
• If the signal should always be enabled as an output, set the GPIO_FUNCx_OEN_SEL bit in the
GPIO_FUN
Cx_OUT_SEL_CFG register and the GPIO_ENABLE_DATA[x] field in the GPIO_ENABLE_REG register
corresponding to GPIO pad X. To have the output enable signal decided by internal logic, clear the
GPIO_FUNCx_OEN_SEL bit instead.
2. For an open drain output, set the GPIO_PINx_PAD_DRIVER bit in the GPIO_PINx register corresponding to
GPIO pad X. For push/pull mode (default), clear this bit.
3. Configure the IO_MUX to select the GPIO Matrix. Set the IO_MUX_x_REG register corresponding to GPIO
pad X as follows:
• Set the function field (MCU_SEL) to the IO_MUX function corresponding to GPIO X (this is Function
2—numeric value 2—for all pins).
• Set the FUN_DRV field to the desired value for output strength (0-3). The higher the drive strength,
the more current can be sourced/sunk from the pin.
• If using open drain mode, set/clear the FUN_WPU and FUN_WPD bits to enable/disable the internal
pull-up/down resistors.
Notes:
• The output signal from a single peripheral can be sent to multiple pads simultaneously.
To configure a pad as simple GPIO output, the GPIO Matrix GPIO_FUNCx_OUT_SEL register is configured with a
special peripheral index value (0x100).
Selecting this option is less flexible than using the GPIO Matrix, as the IO_MUX register for each GPIO pad can
only select from a limited number of functions. However, better high-frequency digital performance will be
maintained.
1. IO_MUX for the GPIO pad must be set to the required pad function. (Please refer to section 4.10 for a list
of pad functions.)
2. For inputs, the SIG_IN_SEL register must be cleared to route the input directly to the peripheral.
When configured as RTC GPIOs, the output pads can still retain the output level value when the chip is in
Deep-sleep mode, and the input pads can wake up the chip from Deep-sleep.
If SLP_SEL is set to 0, the pin functions remain the same in both normal execution and Light-sleep mode.
The Hold state of each pin is controlled by the result of OR operation of the pin’s Hold enable signal and the
global Hold enable signal.
• Digital Pins (GPIO18 ~ GPIO19, GPIO21 ~ GPIO23, GPIO25 ~ GPIO27, GPIO32 ~ GPIO39)
– RTCIO_DIG_PAD_HOLD_REG[n], controls the Hold enable signal of each digital pin. See Table 4-8 for
the bit mapping for the pins.
– Alternatively, set RTC_CNTL_DG_PAD_FORCE_HOLD to hold the values of all digital pins, or set
RTC_CNTL_DG_PAD_FORCE_UNHOLD to disable the hold function of all digital pins.
– RTC_CNTL_HOLD_FORCE_REG[n](n = 0 ~ 17), controls the Hold enable signal of each RTC pins
(GPIO0 ~ GPIO17).
– Alternatively, set RTC_CNTL_DG_PAD_FORCE_HOLD to hold the values of all RTC pins, or set
RTC_CNTL_DG_PAD_FORCE_UNHOLD to disable the hold function of all RTC pins.
VDD3P3_CPU
GPIO21
GPIO22
GPIO19
XTAL_N
XTAL_P
U0RXD
U0TXD
VDDA
VDDA
CAP1
CAP2
48
47
46
45
44
43
42
41
40
39
38
37
VDDA 1 36 GPIO23
LNA_IN 2 35 GPIO18
VDD3P3 3 34 GPIO5
VDD3P3 4 33 SD_DATA_1
SENSOR_VP 5 32 SD_DATA_0
SENSOR_VN 8 29 SD_DATA_3
CHIP_PU 9 28 SD_DATA_2
VDET_1 10 27 GPIO17
VDET_2 11 26 VDD_SDIO
32K_XP 12 25 GPIO16
13
14
15
16
17
18
19
20
21
22
23
24
Analog pads
32K_XN
GPIO25
GPIO26
GPIO27
MTMS
MTDI
VDD3P3_RTC
MTCK
MTDO
GPIO2
GPIO0
GPIO4
Figure 4-4. ESP32 I/O Pad Power Sources (QFN 6*6, Top View)
GPIO21
GPIO22
XTAL_N
XTAL_P
U0RXD
U0TXD
VDDA
VDDA
CAP1
CAP2
48
47
46
45
44
43
42
41
40
39
VDDA 1 38 GPIO19
LNA_IN 2 37 VDD3P3_CPU
VDD3P3 3 36 GPIO23
VDD3P3 4 35 GPIO18
SENSOR_VP 5 34 GPIO5
SENSOR_CAPP 6 33 SD_DATA_1
SENSOR_CAPN 7 32 SD_DATA_0
ESP32
49 GND
SENSOR_VN 8 31 SD_CLK
CHIP_PU 9 30 SD_CMD
VDET_1 10 29 SD_DATA_3
VDET_2 11 28 SD_DATA_2
32K_XP 12 27 GPIO17
32K_XN 13 26 VDD_SDIO
GPIO25 14 25 GPIO16
15
16
17
18
19
20
21
22
23
24
Analog pads
GPIO26
GPIO27
MTMS
MTDI
VDD3P3_RTC
MTCK
MTDO
GPIO2
GPIO0
Figure 4-5. ESP32 I/O Pad Power Sources (QFN 5*5, Top View)
• Pads marked blue are RTC pads that have their individual analog function and can also act as normal digital
IO pads. For details, please see Section 4.11.
• Pads marked green can be powered externally or internally via VDD_SDIO (see below).
Without an external power supply, the internal regulator will supply VDD_SDIO. The VDD_SDIO voltage can be
configured to be either 1.8V or the same as VDD3P3_RTC, depending on the state of the MTDI pad at reset –
a high level configures 1.8V and a low level configures the voltage to be the same as VDD3P3_RTC. Setting the
efuse bit determines the default voltage of the VDD_SDIO. In addition, software can change the voltage of the
VDD_SDIO by configuring register bits.
Direct I/O in IO_MUX ”YES” means that this signal is also available directly via IO_MUX. To apply the GPIO Matrix
to these signals, their corresponding SIG_IN_SEL register must be cleared.
GPIO Pad Name Function 0 Function 1 Function 2 Function 3 Function 4 Function 5 Reset Notes
0 GPIO0 GPIO0 CLK_OUT1 GPIO0 - - EMAC_TX_CLK 3 R
1 U0TXD U0TXD CLK_OUT3 GPIO1 - - EMAC_RXD2 3 -
2 GPIO2 GPIO2 HSPIWP GPIO2 HS2_DATA0 SD_DATA0 - 2 R
3 U0RXD U0RXD CLK_OUT2 GPIO3 - - - 3 -
4 GPIO4 GPIO4 HSPIHD GPIO4 HS2_DATA1 SD_DATA1 EMAC_TX_ER 2 R
5 GPIO5 GPIO5 VSPICS0 GPIO5 HS1_DATA6 - EMAC_RX_CLK 3 -
6 SD_CLK SD_CLK SPICLK GPIO6 HS1_CLK U1CTS - 3 -
7 SD_DATA_0 SD_DATA0 SPIQ GPIO7 HS1_DATA0 U2RTS - 3 -
8 SD_DATA_1 SD_DATA1 SPID GPIO8 HS1_DATA1 U2CTS - 3 -
9 SD_DATA_2 SD_DATA2 SPIHD GPIO9 HS1_DATA2 U1RXD - 3 -
10 SD_DATA_3 SD_DATA3 SPIWP GPIO10 HS1_DATA3 U1TXD - 3 -
GPIO Pad Name Function 1 Function 2 Function 3 Function 4 Function 5 Function 6 Reset Notes
11 SD_CMD SD_CMD SPICS0 GPIO11 HS1_CMD U1RTS - 3 -
12 MTDI MTDI HSPIQ GPIO12 HS2_DATA2 SD_DATA2 EMAC_TXD3 2 R
13 MTCK MTCK HSPID GPIO13 HS2_DATA3 SD_DATA3 EMAC_RX_ER 2 R
14 MTMS MTMS HSPICLK GPIO14 HS2_CLK SD_CLK EMAC_TXD2 3 R
15 MTDO MTDO HSPICS0 GPIO15 HS2_CMD SD_CMD EMAC_RXD3 3 R
16 GPIO16 GPIO16 - GPIO16 HS1_DATA4 U2RXD EMAC_CLK_OUT 1 -
17 GPIO17 GPIO17 - GPIO17 HS1_DATA5 U2TXD EMAC_CLK_180 1 -
18 GPIO18 GPIO18 VSPICLK GPIO18 HS1_DATA7 - - 1 -
19 GPIO19 GPIO19 VSPIQ GPIO19 U0CTS - EMAC_TXD0 1 -
21 GPIO21 GPIO21 VSPIHD GPIO21 - - EMAC_TX_EN 1 -
22 GPIO22 GPIO22 VSPIWP GPIO22 U0RTS - EMAC_TXD1 1 -
23 GPIO23 GPIO23 VSPID GPIO23 HS1_STROBE - - 1 -
25 GPIO25 GPIO25 - GPIO25 - - EMAC_RXD0 0 R
26 GPIO26 GPIO26 - GPIO26 - - EMAC_RXD1 0 R
27 GPIO27 GPIO27 - GPIO27 - - EMAC_RX_DV 0 R
32 32K_XP GPIO32 - GPIO32 - - - 0 R
33 32K_XN GPIO33 - GPIO33 - - - 0 R
34 VDET_1 GPIO34 - GPIO34 - - - 0 R, I
35 VDET_2 GPIO35 - GPIO35 - - - 0 R, I
36 SENSOR_VP GPIO36 - GPIO36 - - - 0 R, I
37 SENSOR_CAPP GPIO37 - GPIO37 - - - 0 R, I
38 SENSOR_CAPN GPIO38 - GPIO38 - - - 0 R, I
39 SENSOR_VN GPIO39 - GPIO39 - - - 0 R, I
Reset Configurations
Notes
• I - Pad can only be configured as input GPIO. These input-only pads do not feature an output driver or
internal pull-up/pull-down circuitry.
Please refer to the ESP32 Pin Lists in ESP32 Datasheet for more details.
Note:
For more information on the configuration of sar_i2c_xx, see Section RTC I2C Controller in Chapter 30 ULP Coprocessor
(ULP).
1. GPIO20 is only available for ESP32-PICO-V3 and ESP32-PICO-V3-02. Please refer to ESP32-PICO Series Datasheet
for more information.
4.13 Registers
4.13.1 GPIO Matrix Registers
The addresses in parenthesis besides register names are the register addresses relative to the GPIO base ad-
dress provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute register
addresses are listed in Section 4.12.1 GPIO Matrix Register Summary.
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
GPIO_OUT_W1TS_REG GPIO0-31 output set register. For every bit that is 1 in the value written here,
the corresponding bit in GPIO_OUT_REG will be set. (WO)
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
GPIO_OUT_W1TC_REG GPIO0-31 output clear register. For every bit that is 1 in the value written
here, the corresponding bit in GPIO_OUT_REG will be cleared. (WO)
U
_O
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
TA
DA
T_
)
ed
U
_O
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_OUT_DATA GPIO32-39 output value set register. For every bit that is 1 in the value written
here, the corresponding bit in GPIO_OUT1_DATA will be set. (WO)
TA
DA
T_
)
ed
U
_O
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_OUT_DATA GPIO32-39 output value clear register. For every bit that is 1 in the value written
here, the corresponding bit in GPIO_OUT1_DATA will be cleared. (WO)
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
GPIO_ENABLE_W1TS_REG GPIO0-31 output enable set register. For every bit that is 1 in the value
written here, the corresponding bit in GPIO_ENABLE will be set. (WO)
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
GPIO_ENABLE_W1TC_REG GPIO0-31 output enable clear register. For every bit that is 1 in the value
written here, the corresponding bit in GPIO_ENABLE will be cleared. (WO)
TA
DA
E_
BL
)
NA
ed
_E
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
TA
DA
E_
BL
)
NA
ed
_E
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_ENABLE_DATA GPIO32-39 output enable set register. For every bit that is 1 in the value written
here, the corresponding bit in GPIO_ENABLE1 will be set. (WO)
NA
ed
_E
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_ENABLE_DATA GPIO32-39 output enable clear register. For every bit that is 1 in the value
written here, the corresponding bit in GPIO_ENABLE1 will be cleared. (WO)
NG
PI
AP
)
TR
ed
_S
rv
se
IO
(re
GP
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x x x x x x x x x Reset
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
GPIO_IN_REG GPIO0-31 input value. Each bit represents a pad input value, 1 for high level and 0 for
low level. (RO)
EXT
_N
TA
DA
)
ed
N_
rv
_I
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_IN_DATA_NEXT GPIO32-39 input value. Each bit represents a pad input value. (RO)
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
GPIO_STATUS_INT GPIO0-31 interrupt status register. Each bit can be either of the two interrupt
sources for the two CPUs. The enable bits in GPIO_PINn_INT_ENA, corresponding to the 13-16
bits in GPIO_PINn_REG should be set to 1. (R/W)
S
1T
_W
NTI
S_
TU
TA
_S
IO
GP
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
GPIO_STATUS_INT_W1TS GPIO0-31 interrupt status set register. For every bit that is 1 in the value
written here, the corresponding bit in GPIO_STATUS_INT will be set. (WO)
C
1T
_W
NT
_I
US
AT
ST
IO_
GP
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
GPIO_STATUS_INT_W1TC GPIO0-31 interrupt status clear register. For every bit that is 1 in the value
written here, the corresponding bit in GPIO_STATUS_INT will be cleared. (WO)
TA
ed
_S
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_STATUS1_INT GPIO32-39 interrupt status register. Each bit can be either of the two interrupt
sources for the two CPUs. The enable bits in GPIO_PINn_INT_ENA, corresponding to the 13-16
bits in GPIO_PINn_REG should be set to 1. (R/W)
S
1T
_W
NT
_I
S1
TU
d)
TA
ve
_S
r
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_STATUS1_INT_W1TS GPIO32-39 interrupt status set register. For every bit that is 1 in the value
written here, the corresponding bit in GPIO_STATUS1_INT will be set. (WO)
C
1T
_W
NT
_I
S1
TU
)
TA
ed
_S
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_STATUS1_INT_W1TC GPIO32-39 interrupt status clear register. For every bit that is 1 in the
value written here, the corresponding bit in GPIO_STATUS1_INT will be cleared. (WO)
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
NT
I
U_
CP
)
PP
ed
_A
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
PP
ed
_A
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
T
IN
U_
CP
RO
)
ed
_P
rv
se
IO
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
T
IN
I_
N M
U_
CP
RO
)
ed
P
rv
O_
se
I
(re
GP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
LE
AB
R
EN
VE
P_
PE
RI
A
EN
EU
_D
TY
T_
T_
AK
AD
IN
IN
W
_P
n_
n_
n_
(re INn
d)
GP ed)
)
ed
ed
IN
IN
IN
ve
_P
_P
_P
rv
rv
rv
O_
r
se
se
se
se
IO
IO
IO
I
(re
(re
(re
GP
GP
GP
31 18 17 13 12 11 10 9 7 6 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x 0 0 x x x x 0 0 0 0 x 0 0 Reset
GPIO_PINn_WAKEUP_ENABLE GPIO wake-up enable will only wake up the CPU from Light-sleep.
(R/W)
L
SE
IN
_I L
Cy SE
N_
N_
UN IN_
_I
Cy
_F _
IO IGy
UN
)
ed
GP _S
_F
rv
se
IO
IO
GP
GP
(re
31 8 7 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x Reset
GPIO_SIGy_IN_SEL Bypass the GPIO Matrix. 1: route through GPIO Matrix, 0: connect signal directly
to peripheral configured in the IO_MUX. (R/W)
GPIO_FUNCy_IN_SEL Selection control for peripheral input y. A value of 0-39 selects which of the
40 GPIO Matrix input pins this signal is connected to, or 0x38 for a constantly high input or 0x30
for a constantly low input. (R/W)
UT EL EL
EL
_O _S _S
_S
EL
Cn EN INV
NV
_S
_I
UN n_O _
UT
_F C EN
IO UN _O
_O
GP _F Cn
Cn
d)
IO UN
UN
ve
GP _F
_F
r
se
IO
IO
(re
GP
GP
31 12 11 10 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x x x x x Reset
GPIO_FUNCn_OEN_INV_SEL 1: Invert the output enable signal; 0: do not invert the output enable
signal. (R/W)
GPIO_FUNCn_OUT_INV_SEL 1: Invert the output value; 0: do not invert the output value. (R/W)
K2
K3
K1
CL
CL
CL
L_
L_
L_
)
ed
R
CT
CT
CT
rv
se
N_
N_
N_
(re
PI
PI
PI
31 12 11 8 7 4 3 0
Note:
• Only the above mentioned combinations of clock source (i.e. I2S0/1_CLK, APLL clock) and clock output pins
(i.e. CLK_OUT1 ~ 3) are possible.
U
P_ PD
)
CU V
N_ PU
CU D
EL
FU RV
ed
CU P
R
E
CU L
P
M _IE
M _W
SL _W
_D
_O
M SE
_S
FU IE
FU _W
W
rv
D
N_
N_
se
CU
CU
N
(re
FU
M
M
31 15 14 12 11 10 9 8 7 6 5 4 3 2 1 0
MCU_SEL Select the IO_MUX function for this signal. 0 selects Function 0, 1 selects Function 1,
etc. (R/W)
FUN_DRV Select the drive strength of the pad. A higher value corresponds with a higher strength.
For GPIO34-39, FUN_DRV is always 0. For detailed drive strength, please see note 8 in Table
”Notes on ESP32 Pin Lists”, in ESP32 Datasheet. (R/W)
FUN_IE Input enable of the pad. 1: input enabled; 0: input disabled. (R/W)
FUN_WPU Pull-up enable of the pad. 1: internal pull-up enabled; 0: internal pull-up disabled. GPIO
pins 34-39 are input-only. These pins do not feature an output driver or internal pull- up/pull-
down circuitry, therefore, their FUN_WPU is always 0. (R/W)
FUN_WPD Pull-down enable of the pad. 1: internal pull-down enabled, 0: internal pull-down dis-
abled. GPIO pins 34-39 are input-only. These pins do not feature an output driver or internal
pull- up/pull-down circuitry, therefore, their FUN_WPD is always 0. (R/W)
MCU_DRV Select the drive strength of the pad during sleep mode. A higher value corresponds
with a higher strength. (R/W)
MCU_IE Input enable of the pad during sleep mode. 1: input enabled; 0: input disabled. (R/W)
MCU_WPU Pull-up enable of the pad during sleep mode. 1: internal pull-up enabled; 0: internal
pull-up disabled. (R/W)
MCU_WPD Pull-down enable of the pad during sleep mode. 1: internal pull-down enabled; 0: in-
ternal pull-down disabled. (R/W)
SLP_SEL Sleep mode selection of this pad. Set to 1 to put the pad in sleep mode. (R/W)
MCU_OE Output enable of the pad in sleep mode. 1: enable output; 0: disable output. (R/W)
A
AT
_D
UT
_O
IO
GP
C_
d)
RT
ve
O_
r
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_OUT_DATA GPIO0-17 output register. Bit14 is GPIO[0], bit15 is GPIO[1], etc. (R/W)
)
RT
ed
O_
rv
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_OUT_DATA_W1TS GPIO0-17 output set register. For every bit that is 1 in the value
written here, the corresponding bit in RTCIO_RTC_GPIO_OUT will be set. (WO)
)
RT
ed
O_
rv
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_OUT_DATA_W1TC GPIO0-17 output clear register. For every bit that is 1 in the
value written here, the corresponding bit in RTCIO_RTC_GPIO_OUT will be cleared. (WO)
B LE
NA
_E
IO
GP
C_
d)
RT
ve
O_
r
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_ENABLE GPIO0-17 output enable. Bit14 is GPIO[0], bit15 is GPIO[1], etc. 1 means
this GPIO pad is output. (R/W)
)
RT
ed
O_
rv
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_ENABLE_W1TS GPIO0-17 output enable set register. For every bit that is 1 in the
value written here, the corresponding bit in RTCIO_RTC_GPIO_ENABLE will be set. (WO)
)
RT
ed
O_
rv
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_ENABLE_W1TC GPIO0-17 output enable clear register. For every bit that is 1 in
the value written here, the corresponding bit in RTCIO_RTC_GPIO_ENABLE will be cleared. (WO)
NTI
S_
TU
TA
_S
IO
GP
C_
d)
RT
ve
O_
r
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
)
RT
ed
O_
rv
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_STATUS_INT_W1TS GPIO0-17 interrupt set register. For every bit that is 1 in the
value written here, the corresponding bit in RTCIO_RTC_GPIO_STATUS_INT will be set. (WO)
)
RT
ed
O_
rv
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_STATUS_INT_W1TC GPIO0-17 interrupt clear register. For every bit that is 1 in the
value written here, the corresponding bit in RTCIO_RTC_GPIO_STATUS_INT will be cleared. (WO)
XT
NE
N_
_I
IO
GP
C_
d)
RT
ve
O_
r
se
CI
(re
RT
31 14 13 0
x x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_RTC_GPIO_IN_NEXT GPIO0-17 input value. Bit14 is GPIO[0], bit15 is GPIO[1], etc. Each bit
represents a pad input value, 1 for high level, and 0 for low level. (RO)
LE
AB
ER
EN
IV
P_
DR
P
EU
TY
D_
T_
AK
PA
IN
W
n_
n_
n_
IN
IN
IN
_P
_P
_P
IO
IO
ed PIO
GP
GP
se C_G
C_
C_
)
)
RT
RT
(re RT
ed
ed
O_
O_
O_
rv
rv
rv
se
se
CI
CI
CI
(re
(re
RT
RT
RT
31 11 10 9 7 6 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x x 0 0 0 0 x 0 0 Reset
RTCIO_RTC_GPIO_PINn_WAKEUP_ENABLE GPIO wake-up enable. This will only wake up the ESP32
from Light-sleep. (R/W)
31 0
0 Reset
RTCIO_DIG_PAD_HOLD_REG Selects the digital pads which should be put on hold. While 0 allows
normal operation, 1 puts the pad on hold. (R/W)
Name Description
Bit[0] Set to 1 to enable the Hold function of pad U0RXD
Bit[1] Set to 1 to enable the Hold function of pad U0TXD
Bit[2] Set to 1 to enable the Hold function of pad
SD_CLK
Bit[3] Set to 1 to enable the Hold function of pad
SD_DATA0
Bit[4] Set to 1 to enable the Hold function of pad
SD_DATA1
Bit[5] Set to 1 to enable the Hold function of pad
SD_DATA2
Bit[6] Set to 1 to enable the Hold function of pad
SD_DATA3
Bit[7] Set to 1 to enable the Hold function of pad
SD_CMD
Bit[8] Set to 1 to enable the Hold function of pad GPIO5
Bit[9] Set to 1 to enable the Hold function of pad GPIO16
Bit[10] Set to 1 to enable the Hold function of pad GPIO17
Bit[11] Set to 1 to enable the Hold function of pad GPIO18
Bit[12] Set to 1 to enable the Hold function of pad GPIO19
Bit[13] Set to 1 to enable the Hold function of pad
GPIO201
Bit[14] Set to 1 to enable the Hold function of pad GPIO21
Bit[15] Set to 1 to enable the Hold function of pad
GPIO22
Bit[16] Set to 1 to enable the Hold function of pad
GPIO23
1. GPIO20 is only available for ESP32-PICO-V3 and ESP32-PICO-V3-02. Please refer to ESP32-PICO Series Datasheet
for more information.
R_ SE4 U SEL
UX EL
EL
S E LP L
_S SE SL EL
NS SEN E3_ UX EL
E LP EL
_S E3_ P_ L
4_ P_ L
O_ SOR SEN E2_ _SE
O_ NS _S E3_ _IE
L E
SE SL SE
O_ NS _S E4_ _IE
IE
M _S
_S
S SL E
S
IE
SE 2_F _IE
UN E
_ S M S
FU I E
SO ENS 2_S _S
_S
EN FU E
M _
C SE OR EN 3_ LD
EN 1_ _S
CI SE OR EN 4_ LD
RT SE OR EN 1_M LD
NS _S SE UN_
N_
I
O_ SOR SEN E2_ UX_
C SE OR EN 2_ D
N_
N_
EN 4_ P_
X
UN
SE E3 LP
RT IO_ NS _S SE OL
P
RT IO_ NS _S SE HO
RT IO_ NS _S SE HO
O_ NS _S SE HO
FU
FU
FU
_S SE SL
S
S
F
F
C SE OR EN 1_H
O_ NS _S E2_
_
_
OR EN _
O_ NS _S E1_
OR EN 1_
4
RT IO_ NS _S SE
NS _S SE
N _ S
N _ S
S
NS
N _ S
S
S
NS
C SE OR EN
EN
RT SE OR EN
RT SE OR EN
RT SE OR EN
SE OR EN
E
RT IO_ NS _S
R_
_
C SE OR
CI E R
OR
CI SE OR
CI SE OR
OR
CI SE OR
O
O
RT IO_ NS
RT O_ NS
NS
RT O_ NS
RT IO_ NS
RT _ S
EN
EN
)
C SE
RT SE
CI SE
RT SE
CI SE
C SE
CI SE
ed
S
S
RT IO_
RT _
O_
RT O_
RT _
RT O_
rv
O
se
CI
CI
CI
CI
CI
CI
CI
CI
C
(re
RT
RT
RT
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_SENSOR_SENSEn_HOLD Set to 1 to hold the output value on sensen; 0 is for normal oper-
ation. (R/W)
RTCIO_SENSOR_SENSEn_FUN_SEL Select the RTC IO_MUX function for this pad. 0: select Func-
tion 0. (R/W)
RTCIO_SENSOR_SENSEn_SLP_SEL Selection of sleep mode for the pad: set to 1 to put the pad in
sleep mode. (R/W)
EL
AD AD 2_S SEL
UX EL
RT AD AD _SL EL
C2 LP EL
C LP EL
E
_S
_F E
_F _IE
C_ 2_M X_S
AD _S _S
_I
C_ 1_F _IE
AD _M LD
_
AD _S _S
_I
RT AD AD _H D
N_
UN
UN
C_ C2 LP
UN
O_ C_ C OL
C_ C1 P
C_ C1 O
C U
FU
CI AD AD H
RT IO_ C_ C1_
_
2
C2
C1
1
O_ C_ C
O_ C_ C
C AD AD
AD
CI AD AD
AD
CI AD AD
RT O_ C_
RT _ _
RT O_ C_
C
)
CI AD
RT AD
CI AD
RT AD
CI AD
ed
RT IO_
O_
RT O_
O_
RT O_
rv
O
se
CI
CI
CI
CI
C
(re
RT
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_ADC_ADCn_HOLD Set to 1 to hold the output value on the pad; 0 is for normal operation.
(R/W)
RTCIO_ADC_ADCn_FUN_SEL Select the RTC function for this pad. 0: select Function 0; 3: select
Function 1. (R/W)
RTCIO_ADC_ADCn_SLP_SEL Signal selection of pad’s sleep mode. Set this bit to 1 to put the pad
to sleep. (R/W)
RTCIO_ADC_ADCn_SLP_IE Input enable of the pad in sleep mode. 1 enabled; 0 disabled. (R/W)
E
RC
FO
D_
FU EL
AC UX_ C
CI PA PD 1_S SEL
O_ D_ AC L EL
M DA
XP
AC FU E
DA IE
S
D_ AC SL E
PD 1_ P_O
CI PA PD 1_S _S
PD 1_ LD
N_
1_ N_
PA PD 1_ P_I
C_
D_ C1_ D_
C
V
E
1_ E
RT _ _ C LP
D_ AC HO
RU
DR
AC RD
DA
A XP
1_
PA D _
1_
O_ _PD C1_
1_
1
AC
O_ D_ AC
AC
RT O_ D_ AC
D A
A
PD
CI PA PD
PD
RT PA PD
PD
CI PA PD
P
D_
RT _ _
D_
O_ D_
RT O_ D_
D
)
RT PA
CI PA
PA
CI PA
RT PA
CI PA
ed
O_
RT IO_
O_
RT O_
RT O_
rv
O
se
CI
CI
CI
CI
CI
C
(re
RT
RT
RT
31 30 29 28 27 26 19 18 17 16 15 14 13 12 11 10 9 0
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_PAD_PDAC1_HOLD Set to 1 to hold the output value on the pad; set to 0 for normal opera-
tion. (R/W)
RTCIO_PAD_PDAC1_SLP_SEL Sleep mode selection signal of the pad. Set this bit to 1 to put the
pad to sleep. (R/W)
RTCIO_PAD_PDAC1_SLP_IE Input enable of the pad in sleep mode. 1: enabled; 0: disabled. (R/W)
E
RC
FO
D_
UN L
DA MU DAC
RT IO_ D_ AC SLP L
PA PD 2_ P_ L
_F SE
XP
AC FU OE
O_ D_ AC SL E
DA IE
_S
D_ AC SL IE
CI PA PD 2_ _S
C2 X_
PD 2_ LD
2_ N_
C_
D_ C2_ PD_
PD 2_ P_
C
O_ D_ AC RV
E
2_ E
D_ AC HO
RU
AC RD
DA
D
A X
2_
PA D _
2_
O_ _PD C2_
C PA PD 2_
2
AC
AC
RT _ _ C
D A
A
PD
CI PA PD
PD
RT PA PD
CI A D
P
P
D_
RT _ _
D_
O_ D_
RT O_ D_
D
)
RT PA
CI PA
PA
CI PA
RT PA
CI PA
ed
P
O_
RT IO_
O_
RT O_
RT _
rv
O
se
CI
CI
CI
CI
CI
C
(re
RT
RT
RT
31 30 29 28 27 26 19 18 17 16 15 14 13 12 11 10 9 0
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_PAD_PDAC2_HOLD Set to 1 to hold the output value on the pad; 0 is for normal operation.
(R/W)
RTCIO_PAD_PDAC2_FUN_SEL Select the RTC function for this pad. 0: select Function 0. (R/W)
RTCIO_PAD_PDAC2_SLP_SEL Sleep mode selection signal of the pad. Set this bit to 1 to put the
pad to sleep. (R/W)
RTCIO_PAD_PDAC2_SLP_IE Input enable of the pad in sleep mode. 1: enabled; 0: disabled. (R/W)
K
K
2N X_S L
32
CI XT X3 _S SEL
CI XT X3 FUN L
O_ AL 2 LP L
32
2K
2P U 2K
L_ 2N LP EL
U SE
L_ 2P LP_ L
E
E
X3 FUN E
E
DR UN E
RT XTA X3 _S SE
_X E
L_
X3 _S _IE
_S
_ _O
X3 _S IE
_3
L_
RT XTA _X3 _S _S
_I
X3 M 3
_M X_
_F _O
_I
X3 _R D
_
X3 _R D
TA
L_ 2N OL
CI XT X3 DRV
X3 RUE
2N DE
N P
2N LP
UN
L_ 2P OL
RV
UE
TA
2P DE
CI XT XP TAL
L_ 2N L
2P LP
O_ AL 2 L
A
_X
RT XTA _X3 _H
RT XTA _X3 XT
_D
RT XTA X3 _H
_R
CI XT X3 _S
_F
_
_
X
AS
C_
ES
_
2N
RT _ L_ N
2P
2P
RT O_ L_ 2P
P
O_ AL D
O_ AL 2
O_ AL 2
ed DBI
DA
X3
CI XT X3
X3
CI XT X3
L_
RT _ L_
L_
RT O_ AL_
L_
RT O_ L_
L_
RT O_ L_
L_
RT IO_ AL_
L_
L_
RT XTA
RT XTA
RT XTA
RT XTA
A
A
RT XTA
(re XTA
)
CI XT
CI XT
CI XT
CI XT
C T
XT
X
O_
RT IO_
O_
RT _
O_
RT _
O_
RT _
O_
RT O_
O_
O_
rv
O
se
CI
CI
CI
CI
CI
CI
CI
CI
CI
CI
CI
C
RT
RT
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 0 0 0 2 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 Reset
RTCIO_XTAL_X32N_HOLD Set to 1 to hold the output value on the pad; 0 is for normal operation.
(R/W)
RTCIO_XTAL_X32P_HOLD Set to 1 to hold the output value on the pad, 0 is for normal operation.
(R/W)
RTCIO_XTAL_X32N_MUX_SEL 0: route X32N pad to the digital IO_MUX; 1: route to RTC block.
(R/W)
RTCIO_XTAL_X32P_MUX_SEL 0: route X32P pad to the digital IO_MUX; 1: route to RTC block.
(R/W)
RTCIO_XTAL_X32N_SLP_SEL Sleep mode selection. Set this bit to 1 to put the pad to sleep. (R/W)
RTCIO_XTAL_X32N_SLP_IE Input enable of the pad in sleep mode. 1: enabled; 0: disabled. (R/W)
RTCIO_XTAL_X32P_SLP_SEL Sleep mode selection. Set this bit to 1 to put the pad to sleep. (R/W)
RTCIO_XTAL_X32P_SLP_IE Input enable of the pad in sleep mode. 1: enabled; 0: disabled. (R/W)
GE
FH
UR
AN
EF
UC PD_
DC
DR
DR
X
O_ CH_
H_
H
CH
CH
UC
RT TOU
)
TO
TO
TO
TO
ed
O_
O_
O_
O_
rv
se
CI
CI
CI
CI
CI
(re
RT
RT
RT
RT
31 30 29 28 27 26 25 24 23 22 0
0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_TOUCH_XPD_BIAS Touch sensor bias power on bit. 1: power on; 0: disabled. (R/W)
RTCIO_TOUCH_DCUR Touch sensor bias current. When BIAS_SLEEP is enabled, this setting is
available. (R/W)
FU EL
RT IO_T UC PA _SL EL
TO H D LP EL
IO
Dn D T
Dn UN E
O_ E
S
RT TOU PA _XP OP
_S
GP
PA _F _O
P _T T
O_ UC PA _S S
_T _I
Dn X_
D
RT TOU H_ Dn TAR
CI O _ n P_
N
PA HOL
AC
E
n_ E
H_ Dn LP
U
RU
R
AD RD
_M
_D
_D
O_ UC PA _S
_
) _P n_
_
Dn
Dn
Dn
CI O _ n
C O H_ Dn
ed H D
D
RT TOU PA
rv C A
PA
RT O_T UC PA
RT IO_T UC PA
P
P
O_ CH_
RT IO_T H_
se OU H_
H_
CI O H_
RT IO_T H_
C O _
H
H
C
(re O_T UC
UC
RT _T C
RT O_T UC
RT TOU
d)
CI O
TO
CI O
CI O
ve
RT O_T
O_
O_
r
se
CI
CI
CI
CI
CI
C
(re
RT
RT
RT
31 30 29 28 27 26 25 23 22 21 20 19 18 17 16 15 14 13 12 11 0
0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_TOUCH_PADn_DRV Selects the drive strength of the pad. A higher value corresponds with a
higher strength. For detailed drive strength, please see ESP32 Datasheet > Appendix A.1 Notes
on ESP32 Pin Lists > Note 8. (R/W)
RTCIO_TOUCH_PADn_DAC Touch sensor slope control. 3-bit for each touch pad. Default is b’100.
(R/W)
RTCIO_TOUCH_PADn_SLP_SEL Sleep mode selection signal of the pad. Set this bit to 1 to put the
pad to sleep. (R/W)
RTCIO_TOUCH_PADn_FUN_IE Input enable of the pad in normal working mode (SLP_SEL = 0).
1: Enabled
0: Disabled
(R/W)
IO
Dm XP PT
GP
UC _PA m_ ART
PA _ _O
AC
_T D
O_
H_ Dm TIE
TO H D ST
_D
O_ UC PA _
Dm
CI O H_ Dm
PA
RT _T C A P
H_
CI O _ H
UC
RT O_T UC
U
)
d)
TO
CI O
ed
ve
RT _T
O_
rv
r
se
se
CI
CI
(re
(re
RT
RT
31 26 25 23 22 21 20 19 16 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_TOUCH_PADm_DAC Touch sensor slope control. 3-bit for each touch pad. Default b’100.
(R/W)
)
ed
E
O_
rv
se
CI
(re
RT
31 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_EXT_WAKEUP0_SEL GPIO[0-17] can be used to wake up the chip when the chip is in the
sleep mode. This register prompts the pad source to wake up the chip when the latter is in
deep/light sleep mode. 0: select GPIO0; 1: select GPIO2, etc. (R/W)
S EL
R_
CT
T_
_EX
TL
d)
X
ve
O_
r
se
CI
(re
RT
31 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_XTL_EXT_CTR_SEL Select the external crystal power down enable source to get into
sleep mode. 0: select GPIO0; 1: select GPIO2, etc. The input value on this pin XOR
RTC_CNTL_XTL_EXT_CTR_LV is the crystal power down enable signal. (R/W)
L
SE
SE
A_
L_
SC
SD
C_
C_
I2
I2
R_
R_
)
SA
SA
ed
O_
O_
rv
se
CI
CI
(re
RT
RT
31 30 29 28 27 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_SAR_I2C_SDA_SEL Selects the other pad as the RTC I2C SDA signal. 0: pad
TOUCH_PAD[1]; 1: pad TOUCH_PAD[3]. Default value is 0. (R/W)
RTCIO_SAR_I2C_SCL_SEL Selects the other pad as the RTC I2C SCL signal. 0: pad
TOUCH_PAD[0]; 1: pad TOUCH_PAD[2]. Default value is 0. (R/W)
5 DPort Registers
5.1 Introduction
The ESP32 integrates a large number of peripherals, and enables the control of individual peripherals to achieve
optimal characteristics in performance-vs-power-consumption scenarios. The DPort registers control clock
management (clock gating), power management, and the configuration of peripherals and core-system mod-
ules. The system arranges each module with configuration registers contained in the DPort Register.
5.2 Features
DPort registers correspond to different peripheral blocks and core modules:
• Interrupt matrix
• DMA
• MPU/MMU
• APP_CPU controller
• DPORT_PERI_CLK_EN_REG
• DPORT_PERI_RST_EN_REG
• DPORT_PERIP_CLK_EN_REG
• DPORT_PERIP_RST_EN_REG
• DPORT_WIFI_CLK_EN_REG
• DPORT_WIFI_RST_EN_REG
Notice:
• Reset registers cannot be cleared by hardware. Therefore, SW reset clear is required after setting the reset
registers.
• ESP32 features low power consumption. This is why some peripheral clocks are gated (disabled) by
default. Before using any of these peripherals, it is mandatory to enable the clock for the given periph-
eral by setting the corresponding CLK_EN bit to 1, and release the peripheral from reset state to make it
operational by setting the RST_EN bit to 0.
5.5 Registers
The addresses in parenthesis besides register names are the register addresses relative to the DPORT base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 5.4 Register Summary.
AP
EM
_R
OT
BO
O_
R
d)
_P
ve
RT
r
se
O
(re
DP
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
AP
EM
R
T_
OO
_B
PP
)
ed
_A
rv
RT
se
O
(re
DP
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
S
_E SH
PE E S
AE
T_ RI_ _R
OR PE _EN
DP RT_ ERI
)
ed
O P
DP RT_
rv
se
O
(re
DP
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_PERI_EN_RSA Set the bit to enable the clock of RSA module. Clear the bit to disable the
clock of RSA module. (R/W)
DPORT_PERI_EN_SHA Set the bit to enable the clock of SHA module. Clear the bit to disable the
clock of SHA module. (R/W)
DPORT_PERI_EN_AES Set the bit to enable the clock of AES module. Clear the bit to disable the
clock of AES module. (R/W)
ST HA
RI ST_ A
ES
PE R RS
_A
_R S
T_ RI_ T_
OR PE _RS
DP RT_ ERI
d)
O P
ve
DP RT_
r
se
O
(re
DP
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_PERI_RST_RSA Set the bit to reset RSA module. Clear the bit to release RSA module. (R/W)
DPORT_PERI_RST_SHA Set the bit to reset SHA module. Clear the bit to release SHA module. (R/W)
DPORT_PERI_RST_AES Set the bit to reset AES module. Clear the bit to release AES module. (R/W)
NG
I
E TT
ES
R
U_
CP
PP
)
ed
A
T_
rv
OR
se
(re
DP
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
DPORT_APPCPU_RESETTING Set to 1 to reset APP_CPU. Clear the bit to release APP_CPU. (R/W)
N
E _E
AT
KG
CL
U_
CP
PP
d)
_A
ve
RT
r
se
O
(re
DP
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_APPCPU_CLKGATE_EN Set to 1 to enable the clock of APP_CPU. Clear the bit to disable
the clock of APP_CPU. (R/W)
ALL
ST
RUN
U_
CP
PP
d)
_A
ve
RT
r
se
O
(re
DP
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_APPCPU_RUNSTALL Set to 1 to put APP_CPU into stalled state. Clear the bit to release
APP_CPU from stalled state. (R/W)
31 0
0x000000000 Reset
L
SE
D_
IO
ER
P UP
_C
PU
)
ed
C
T_
rv
OR
se
(re
DP
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_CPU_CPUPERIOD_SEL Select CPU clock. Refer to Table 3-3 for details. (R/W)
EN H_ NE
LE A
NA
E_ US DO
AB EN
_E
CH FL H_
M
CA E_ US
LE LIT
RA
O_ CH FL
NG SP
L
_I
_H
PR CA E_
SI _
M
O_ AM
T_ O_ CH
RA
PR DR
OR PR CA
_D
T_ O_
DP T_ O_
RO
OR PR
OR PR
)
)
ed
ed
ed
ed
P
T_
DP RT_
DP T_
rv
rv
rv
rv
OR
OR
se
se
se
se
O
(re
(re
(re
(re
DP
DP
DP
31 17 16 15 12 11 10 9 6 5 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 Reset
DPORT_PRO_DRAM_HL Determines the virtual address mode of the external SRAM. (R/W)
DPORT_PRO_DRAM_SPLIT Determines the virtual address mode of the external SRAM. (R/W)
O_ CH M K_ OM M
PR CA E_ S R A
CA E_ AS DR 0
T_ O_ CH MA _D DR
E_ AS IRO 1
M K_ M0
R
0
CH M K_ AM
IR 1
CL
K_ AM
AM
OR PR CA E_ ASK PS
A_
AS IR
DP RT_ RO_ ACH _M K_O
PD _I
U_ U
O P C E AS
M MM
O P C E
O_ CH
O P C
T_ O_
DP T_ O_
OR PR
OR PR
d)
)
ed
ve
DP RT_
DP RT_
rv
r
se
se
O
O
(re
(re
DP
DP
31 14 13 12 11 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 Reset
EN H_ NE
LE A
NA
E_ US DO
AB EN
_E
CH FL H_
M
CA E_ US
LE LIT
RA
P_ CH FL
NG SP
L
_I
_H
AP CA E_
SI _
AM
P_ AM
T_ P_ CH
rv _DR
AP DR
OR AP CA
T_ _
DP T_ P_
P
P
(re _AP
OR AP
OR AP
)
OR )
)
ed
ed
ed
e
DP T_
DP T_
rv
rv
rv
T
OR
OR
se
se
se
se
(re
(re
(re
DP
DP
DP
31 15 14 13 12 11 10 9 6 5 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 Reset
DPORT_APP_DRAM_HL Determines the virtual address mode of the External SRAM. (R/W)
DPORT_APP_DRAM_SPLIT Determines the virtual address mode of the External SRAM. (R/W)
AP CA E_ SK RO AM
CA E_ S R 0
T_ P_ CH MA _D DR
E_ AS IRO 1
M K_ M0
R
0
P_ CH MA _D M
CH M K_ AM
IR 1
CL
K_ AM
AM
OR AP CA E_ SK PS
A_
AS IR
DP RT_ PP_ CH MA K_O
PD _I
U_ U
O A CA E_ S
M MM
DP RT_ PP_ CH MA
CM E_
O A CA E_
P_ CH
DP RT_ PP_ CH
AP CA
O A CA
T_ P_
DP RT_ PP_
OR AP
d)
)
ed
O A
ve
DP RT_
DP RT_
rv
r
se
se
O
O
(re
(re
DP
DP
31 14 13 12 11 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 Reset
E
OD
_M
UX
M
E_
CH
CA
)
ed
T_
rv
OR
se
(re
DP
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_CACHE_MUX_MODE The mode of the two caches sharing the memory. (R/W)
E
OD
_M
GE
ed _PA
U
M
)
(re _IM
)
ed
rv
rv
T
OR
se
se
(re
DP
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_IMMU_PAGE_MODE Page size in the MMU for the internal SRAM 0. (R/W)
E
OD
_M
GE
PA
U_
M
(re _DM
)
)
ed
ed
rv
rv
T
OR
se
se
(re
DP
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_DMMU_PAGE_MODE Page size in the MMU for the internal SRAM 2. (R/W)
31 0
0xFFFFFFFF Reset
1
T_
RAN
_G
SS
E
CC
_A
HB
)
ed
A
T_
rv
OR
se
(re
DP
31 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1FF Reset
DP T_ NT LK N EN
DP RT_ HCI RO EN K_E
DP RT_ S1_ A_ EN EN
OR PC _C _E LK_
se I2 1_ E EN
O TW 1_ EN EN
O TI C K_ EN
O I2 DM K_ _
O U RG K_ L
DP RT_ ME CL 1_C
DP RT_ I_ CL CLK
DP RT_ ME LK_ EN
DP RT_ I3_ CL K_
DP RT_ DC CLK _C
DP RT_ I2 T0_ EN
K_ N
DP RT_ C_ LK_ EN
EN
DP RT_ HCI LK_ N
DP RT_ MT_ LK N
) CL EN
DP RT_ WM T1_ N
EN
DP rve S0 CLK N
DP RT_ US RO N
O d _CL _E
OR I2 0_ EN
O TI E_ UP
O LE 1_ UP
O P CL CL
O U C _E
O R _C _E
O SP 0_ CL
O SP EX K_
O SP 2_ _
O UA _C C
O P EX E
O I2 _C _
O EF RG E
K_
ed 1_ _
DP RT_ RT EM
DP RT_ AI CLK
DP T_ C_ CL
rv I0 LK
O UA _M
se SP _C
DP T_ RT
(re RT_ RT
OR UA
O UA
d)
se d)
DP RT_ )
DP RT_ )
O d
ve
(re rve
DP rve
r
se
se
(re
(re
31 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
11111 0 0 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 0 1 1 1 1 Reset
Set the following bit to enable the clock of the corresponding module. Clear the bit to disable the
clock of the corresponding module.
ST
ST
DP RT_ ME RS 1_R
DP RT_ I_ RS RST
DP RT_ DC RST _R
(re RT_ RT ST ST
DP RT_ WM T T
DP RT_ I3_ RS T
O P RS RS
O TI E_ UP
P
O SP 0_ RS
O SP 2_ _
O UA _R R
U
O U RG T
O I2 DM T
O TI R T
O SP EX T
DP RT_ RT EM
DP rve S0 RST
DP T_ AI ST
DP RT_ I2 T0_
DP RT_ S1_ A_
T
DP RT_ MT_ ST
DP T_ NT ST
DP RT_ WM T1_
DP RT_ US RO
DP RT_ HCI RO
DP RT_ C_ RS
rv I0 ST
DP RT_ C_ ST
T
DP RT_ ME ST
DP T_ CI T
) RS
O d _RS
OR TW 1_R
OR UH RS
O UA _M
R
OR PC _R
se SP _R
O I2 0_
O EF RG
O I2 _R
se I2 1_
O P EX
O LE _
ed 1_
_
1
DP T_ RT
(re RT_ RT
OR UA
O UA
)
se d)
DP RT_ )
DP RT_ )
ed
O d
R
(re rve
DP rve
rv
se
se
O
(re
(re
31 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Set each bit to reset the corresponding module. Clear the bit to release the corresponding module. For the list
of modules, please refer to register 5.19.
N
_E
T_
E
OS
IO EN
AV
_H
SL
SD C_
IO
K_ A
CL EM
SD
I_ _
K_
IF K
W CL
CL
T_ FI_
I_
IF
)
)
OR WI
W
ed
ed
ed
DP RT_
T_
rv
rv
rv
OR
se
se
se
O
(re
(re
(re
DP
DP
31 15 14 13 12 5 4 3 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 Reset
DPORT_WIFI_CLK_EMAC_EN Set the bit to enable the clock of Ethernet MAC module. Clear the bit
to disable the clock of Ethernet MAC module. (R/W)
DPORT_WIFI_CLK_SDIO_HOST_EN Set the bit to enable the clock of SD/MMC module. Clear the
bit to disable the clock of SD/MMC module. (R/W)
DPORT_WIFI_CLK_SDIOSLAVE_EN Set the bit to enable the clock of SDIO module. Clear the bit to
disable the clock of SDIO module. (R/W)
T
ST RS
_R T_
T_ IO ST
IO OS
OR SD _R
SD _H
DP T_ AC
OR EM
d)
)
ed
ve
DP RT_
rv
r
se
se
O
(re
(re
DP
31 8 7 6 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DPORT_EMAC_RST Set the bit to reset Ethernet MAC module. Clear the bit to release Ethernet MAC
module. (R/W)
DPORT_SDIO_HOST_RST Set the bit to reset SD/MMC module. Clear the bit to release SD/MMC
module. (R/W)
DPORT_SDIO_RST Set the bit to reset SDIO module. Clear the bit to release SDIO module. (R/W)
n
PU_
_C
M
RO
_F
TR
IN
U_
P
)
ed
_C
rv
RT
se
O
(re
DP
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
AP
M
*_
O_
PR
d)
ve
T_
r
OR
se
(re
DP
31 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10000 Reset
AP
_M
_*
PP
d)
A
ve
T_
r
OR
se
(re
DP
31 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10000 Reset
IG
NF
CO
T_
AN
GR
S_
ES
C
AC
*_
E_
T
LI
HB
)
ed
A
T_
rv
OR
se
(re
DP
31 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I
ve
T_
r
OR
se
(re
DP
31 7 6 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000000 Reset
DPORT_IMMU_TABLEn MMU for internal SRAM. When n is 0 ~ 9, the reset value is 0. When n is 10
~ 15, the reset value is 10, 11, 12, 13, 14, 15, respectively. (R/W)
En
BL
TA
U_
M
M
d)
D
ve
T_
r
OR
se
(re
DP
31 7 6 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000000 Reset
DPORT_DMMU_TABLEn MMU for internal SRAM. When n is 0 ~ 15, the reset value is 0 ~ 15, respec-
tively. (R/W)
EL
L
EL
E
_S
_S
_S
AN
AN
AN
CH
CH
CH
A_
A_
A_
M
M
DM
_D
_D
I1_
I2
I3
P
P
_S
_S
_S
PI
PI
PI
)
ed
S
T_
T_
T_
rv
OR
OR
OR
se
(re
DP
DP
DP
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
6.1 Overview
Direct Memory Access (DMA) is used for high-speed data transfer between peripherals and memory, as well as
from memory to memory. Data can be quickly moved with DMA without any CPU intervention, thus allowing for
more efficient use of the cores when processing data.
In the ESP32, 13 peripherals are capable of using DMA for data transfer, namely, UART0, UART1, UART2, SPI1,
SPI2, SPI3, I2S0, I2S1, SDIO slave, SD/MMC host, EMAC, BT, and Wi-Fi.
6.2 Features
The DMA controllers in the ESP32 feature:
Each DMA controller features different functions. However, the architecture of the DMA engine (DMA_ENGINE)
is the same in all DMA controllers.
The DMA Engine accesses SRAM over the AHB BUS. In Figure 6-1, the RAM represents the internal SRAM banks
available on ESP32. Further details on the SRAM addressing range can be found in Chapter System and Memory.
Software can use a DMA Engine by assigning a linked list to define the DMA operational parameters.
The DMA Engine transmits the data from the RAM to a peripheral, according to the contents of the out_link
descriptor. Also, the DMA Engine stores the data received from a peripheral into a specified RAM location,
according to the contents of the in_link descriptor.
The DMA descriptor’s linked lists (out_link and in_link) have the same structure. As shown in Figure 6-2, a
linked-list descriptor consists of three words. The meaning of each field is as follows:
• owner (DW0) [31]: The allowed operator of the buffer corresponding to the current linked list.
1’b0: the allowed operator is the CPU;
1’b1: the allowed operator is the DMA controller.
• length (DW0) [23:12]: The number of valid bytes in the buffer corresponding to the current linked list. The
field value indicates the number of bytes to be transferred to/from the buffer denoted by word DW1.
• size (DW0) [11:0]: The size of the buffer corresponding to the current linked list.
NOTE: The size must be word-aligned.
• buffer address pointer (DW1): Buffer address pointer. This is the address of the data buffer.
NOTE: The buffer address must be word-aligned.
• next descriptor address (DW2): The address pointer of the next linked-list item. The value is 0, if the
current linked-list item is the last on the list (eof=1).
When receiving data, if the data transfer length is smaller than the specified buffer size, DMA will not use
the remaining space. This enables the DMA engine to be used for transferring an arbitrary number of data
bytes.
Figure 6-3 shows the data transfer in UDMA mode. Before the DMA Engine receives data, software must initialize
the receive-linked-list. UHCI_INLINK_ADDR is used to point to the first in_link descriptor. The register must be
programmed with the lower 20 bits of the address of the initial linked-list item. After UHCI_INLINK_START is
set, the Universal Host Controller Interface (UHCI) will transmit the data received by UART to the Decoder. After
being parsed, the data will be stored in the RAM as specified by the receive-linked-list descriptor.
Before DMA transmits data, software must initialize the transmit-linked-list and the data to be transferred. UHCI_
OUTLINK_ADDR is used to point to the first out_link descriptor. The register must be programmed with the lower
20 bits of the address of the initial transmit-linked-list item. After UHCI_OUTLINK_START is set, the DMA Engine
will read data from the RAM location specified by the linked-list descriptor and then transfer the data through
the Encoder. The DMA Engine will then shift the data out serially through the UART transmitter.
The UART DMA follows a format of (separator + data + separator). The Encoder is used for adding separa-
tors before and after data, as well as using special-character sequences to replace data that are the same
as separators. The Decoder is used for removing separators before and after data, as well as replacing the
special-character sequences with separators. There can be multiple consecutive separators marking the be-
ginning or end of data. These separators can be configured through UHCI_SEPER_CH, with the default val-
ues being 0xC0. Data that are the same as separators can be replaced with UHCI_ESC_SEQ0_CHAR0 (0xDB
by default) and UHCI_ESC_SEQ0_CHAR1 (0xDD by default). After the transmission process is complete, a
UHCI_OUT_TOTAL_EOF_INT interrupt will be generated. After the reception procedure is complete, a UHCI_IN_
SUC_EOF_INT interrupt will be generated.
Note:
Please note that the buffer address pointer field in in_link descriptors should be word-aligned, and the size field in the
last in_link descriptor should be at least 4 bytes larger than the length of received data.
ESP32 SPI modules can use DMA as well as the CPU for data exchange with peripherals. As can be seen from
Figure 6-4, two DMA channels are shared by SPI1, SPI2 and SPI3 controllers. Each DMA channel can be used
by any one SPI controller at any given time.
The ESP32 SPI DMA Engine also uses a linked list to receive/transmit data. Burst transmission is supported. The
data size for a single transfer must be four bytes aligned. Consecutive data transfer is also supported.
I2S_OUTLINK_START bit in I2S_OUT_LINK_REG and I2S_INLINK_START bit in I2S_IN_LINK_REG are used for en-
abling the DMA Engine and are self-cleared by hardware. When I2S_OUTLINK_START is set to 1, the DMA Engine
starts processing the outbound linked-list descriptor and gets prepared to send data. When I2S_INLINK_START
is set to 1, the DMA Engine starts processing the inbound linked-list descriptor and gets prepared to receive
data.
4. In I2S master mode, set I2S_TX_START bit or I2S_RX_START bit to initiate an I2S operation;
In I2S slave mode, set I2S_TX_START bit or I2S_RX_START bit and wait for data transfer to be initiated by
the host device.
For more information on I2S DMA interrupts, please see Section DMA Interrupts, in Chapter I2S.
7.1 Overview
As Figure 7-1 shows, ESP32 integrates four SPI controllers which can be used to communicate with external
devices that use the SPI protocol. Controller SPI0 is used as a buffer for accessing external memory. Controller
SPI1 can be used as a master. Controllers SPI2 and SPI3 can be configured as either a master or a slave. When
used as a master, each SPI controller can drive multiple CS signals (CS0~CS2) to activate multiple slaves.
Controllers SPI1~SPI3 share two DMA channels.
The SPI signal buses consist of D, Q, CS0-CS2, CLK, WP, and HD signals, as Table 7-1 shows. Controllers SPI0
and SPI1 share one signal bus through an arbiter; the signals of the shared bus start with “SPI”. Controllers SPI2
and SPI3 use signal buses starting with “HSPI” and “VSPI” respectively. The I/O lines included in the above-
mentioned signal buses can be mapped to pins via either the IO_MUX module or the GPIO matrix. (Please refer
to Chapter IO_MUX for details.)
The SPI controller supports four-line full-duplex/half-duplex communication (MOSI, MISO, CS, and CLK lines)
and three-line half-duplex-only communication (DATA, CS, and CLK lines) in GP-SPI mode. In QSPI mode, an
SPI controller accesses the flash or SRAM by using signal buses D, Q, CS0~CS2, CLK, WP, and HD as a four-bit
parallel SPI bus. The mapping between SPI bus signals and pin function signals under different communication
modes is shown in Table 7-1.
Table 7-1. Mapping Between SPI Bus Signals and Pin Function Signals
• Programmable clock
Parallel QSPI
• SPI interrupts
7.3 GP-SPI
The SPI master mode supports four-line full-duplex/half-duplex communication and three-line half-duplex com-
munication. Figure 7-2 outlines the connections needed for four-line full-duplex/half-duplex communications.
The SPI1~SPI3 controllers can communicate with other slaves as a standard SPI master. SPI2 and SPI3 can be
configured as either a master or a slave. Every SPI master can be connected to three slaves at most by default.
When not using DMA, the maximum length of data received/sent in one burst is 64 bytes. The data length is in
multiples of one byte.
Command Description
0x1 Received by slave; writes data sent by the master into the slave status register via MOSI.
0x2 Received by slave; writes data sent by the master into the slave data buffer via MOSI.
0x3 Sent by slave; sends data in the slave buffer to master via MISO.
0x4 Sent by slave; sends data in the slave status register to master via MISO.
Writes master data on MOSI into data buffer and then sends the date in the slave data buffer
0x6
to MISO.
4. received and/or sent data: length of 0~512 bits (64 bytes); Master Out Slave In (MOSI) or Master In Slave
Out (MISO).
The address length is up to 32 bits in GP-SPI master mode and 64 bits in QSPI master mode. The command
phase, address phase, dummy phase and received/sent data phase are controlled by bits SPI_USR_COMMAND,
SPI_USR_ADDR, SPI_USR_DUMMY, and SPI_USR_MISO/SPI_USR_MOSI respectively in register SPI_USER_REG.
A certain phase is enabled only when its corresponding control bit is set to 1. Details can be found in register
description. When SPI works as a master, the register can be configured by software as required to determine
whether or not to enable a certain phase.
When SPI works as a slave, the communication format must contain command, address, received and/or sent
data, among which the command has several options listed in Table 7-2. During data transmission or reception,
the CS signal should keep logic level low. If the CS signal is pulled up during transmission, the internal state of
the slave will be reset.
The master can write the slave status register SPI_SLV_WR_STATUS_REG, and decide whether to read data from
register SPI_SLV_WR_STATUS_REG or register SPI_RD_STATUS_REG via the SPI_SLV_STATUS_READBACK bit in
register SPI_SLAVE1_REG. The SPI master can maintain communication with the slave by reading and writing
slave status register, thus realizing complex communication with ease.
The length of received and sent data is controlled by SPI_MISO_DLEN_REG and SPI_MOSI_DLEN_REG in master
mode, as well as SPI_SLV_RDBUF_DLEN_REG and SPI_SLV_WRBUF_DLEN_REG in slave mode. A reception or
transmission of data is controlled by bit SPI_USR_MOSI or SPI_USR_MISO in SPI_USER_REG. The SPI_USR bit
in register SPI_CMD_REG needs to be configured to initialize a data transfer.
Note:
• In half-duplex communication, the order of command, address, received and/or sent data in the communication
format should be followed strictly.
• In half-duplex communication, communication formats ”command + address + received data + sent data” and
”received data + sent data” are not applicable to DMA.
• When ESP32 SPI acts as a slave, the master CS should be active at least one SPI clock period before a read/write
process is initiated, and should be inactive at least one SPI clock period after the read/write process is com-
pleted.
ESP32 SPI has 16 × 32 bits of data buffer to buffer data-send and data-receive operations. As is shown in Figure
7-3, received data is written from the low byte of SPI_W0_REG by default and the writing ends with SPI_W15_REG.
If the data length is over 64 bytes, the extra part will be written from SPI_W0_REG.
Data buffer blocks SPI_W0_REG ~ SPI_W7_REG and SPI_W8_REG ~ SPI_W15_REG data correspond to the
lower part and the higher part respectively. They can be used separately, and are controlled by the SPI_USR_MOSI
_HIGHPART bit and the SPI_USR_MISO_HIGHPART bit in register SPI_USER_REG. For example, if SPI is config-
ured as a master, when SPI_USR_MOSI_HIGHPART = 1, SPI_W8_REG ~ SPI_W15_REG are used as buffer for
sending data; when SPI_USR_MISO_HIGHPART = 1, SPI_W8_REG ~ SPI_W15_REG are used as buffer for re-
ceiving data. If SPI acts as a slave, when SPI_USR_MOSI_HIGHPART = 1, SPI_W8_REG ~ SPI_W15_REG are
used as buffer for receiving data; when SPI_USR_MISO_HIGHPART = 1, SPI_W8_REG ~ SPI_W15_REG are used
as buffer for sending data.
Table 7-3. Clock Polarity and Phase, and Corresponding SPI Register Values for SPI Master
fapb
fspi =
(SPI_CLKCNT_N+1)(SPI_CLKDIV_PRE+1)
SPI_CLKCNT_N and SPI_CLKDIV_PRE are two bits of register SPI_CLOCK_REG (Please refer to 7.7 Register De-
scription for details). SPI_CLKCNT_H = ⌊ SPI_CLKCNT_N+1
2 –1⌋, SPI_CLKCNT_N=SPI_CLKCNT_L. When the SPI_CLK_EQU_SYSCLK
bit in register SPI_CLOCK_REG is set to 1, and the other bits are set to 0, SPI output clock frequency is
fapb . For other clock frequencies, SPI_CLK_EQU_SYSCLK needs to be 0. In slave mode, SPI_CLKCNT_N,
SPI_CLKCNT_L, SPI_CLKCNT_H and SPI_CLKDIV_PRE should all be 0.
Table 7-4. Clock Polarity and Phase, and Corresponding SPI Register Values for SPI Slave
1. mode0 means CPOL=0, CPHA=0. When SPI is idle, the clock output is logic low; data changes on the
falling edge of the SPI clock and is sampled on the rising edge;
2. mode1 means CPOL=0, CPHA=1. When SPI is idle, the clock output is logic low; data changes on the
rising edge of the SPI clock and is sampled on the falling edge;
Espressif Systems 131 ESP32 TRM (Version 5.2)
Submit Documentation Feedback
7 SPI Controller (SPI)
3. mode2 means when CPOL=1, CPHA=0. When SPI is idle, the clock output is logic high; data changes on
the rising edge of the SPI clock and is sampled on the falling edge;
4. mode3 means when CPOL=1, CPHA=1. When SPI is idle, the clock output is logic high; data changes on
the falling edge of the SPI clock and is sampled on the rising edge.
When GP-SPI is used as master and the data signals are not received by the SPI controller via GPIO matrix, if GP-
SPI output clock frequency is clkapb /2, register SPI_MISO_DELAY_MODE should be set to 0 when configuring
the clock polarity. If GP-SPI output clock frequency is not higher than clkapb /4, register SPI_MISO_DELAY_MODE
can be set to the corresponding value in Table 7-3 when configuring the clock polarity.
When GP-SPI is used in master mode and the data signals enter the SPI controller via the GPIO matrix:
1. If GP-SPI output clock frequency is clkapb /2, register SPI_MISO_DELAY_MODE should be set to 0 and the
dummy phase should be enabled (SPI_USR_DUMMY = 1) for one clkspi clock cycle (SPI_USR_DUMMY_CYC
LELEN = 0) when configuring the clock polarity;
2. If GP-SPI output clock frequency is clkapb /4, register SPI_MISO_DELAY_MODE should be set to 0 when
configuring the clock polarity;
3. If GP-SPI output clock frequency is not higher than clkapb /8, register SPI_MISO_DELAY_MODE can be set
to the corresponding value in Table 7-3 when configuring the clock polarity.
When GP-SPI is used in slave mode, the clock signal and the data signals should be routed to the SPI controller
via the same path, i.e., neither the clock signal nor the data signals passes through GPIO matrix, or both of
them pass through GPIO matrix. This is important in ensuring that the signals are not delayed by different time
periods before they reach the SPI hardware.
Assume that tspi , tpre and tv in Figure 7-4 denote SPI clock period, how far ahead data output is, and data output
delay time, respectively. Assume the SPI slave’s main clock period is tapb . For non-DMA mode0, SPI slave data
output is delayed by tv :
• tv < 3.5 ∗ tapb , if CLK does not pass through GPIO matrix;
In DMA mode1 and mode3, SPI slave data output is delayed by the same period of time as in non-DMA mode.
However, for mode0 and mode2, SPI slave data is output earlier by tpre :
• tpre < (tspi /2 − 5.5 ∗ tapb ), if CLK does not pass through GPIO matrix;
• tpre < (tspi /2 − 7.5 ∗ tapb ), if CLK passes through GPIO matrix.
To conclude, if signals do not pass through GPIO matrix, the SPI slave clock frequency is up to fapb /8; if signals
pass through GPIO matrix, the SPI slave clock frequency is up to fapb /12. Note that (tspi /2–tpre ) represents data
output hold time for SPI slave in mode0 and mode2.
SPI1, SPI2 and SPI3 controllers can also be configured as QSPI master to connect to external memory. The
maximum output clock frequency of the SPI memory interface is fapb , with the same clock configuration as that
of the GP-SPI master.
ESP32 QSPI supports flash-read operation in one-line, two-line, and four-line modes. When working as a QSPI
master, the command phase, address phase, dummy phase and data phase can be configured as needed, as
flexible as in GP-SPI mode.
Note that GPI-SPI full-duplex mode does not support dummy phase.
ESP32 SPI reckons the completion of send- and/or receive-operations as the completion of one operation from
the controller and generates one interrupt. When ESP32 SPI is configured to slave mode, the slave will generate
read/write status registers and read/write buffer data interrupts according to different operations.
• SPI_OUT_DONE_INT: Triggered when the last linked list item has zero length.
• SPI_IN_DONE_INT: Triggered when the last received linked list had a length of 0.
7.8 Registers
The addresses in parenthesis besides register names are the register addresses relative to the SPI0/SPI1/SPI2/SPI3
base addresses provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The ab-
solute register addresses are listed in Section 7.7 Register Summary.
)
ed
ed
R
US
rv
rv
se
se
I_
(re
(re
SP
31 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_USR An SPI operation will be triggered when this bit is set. The bit will be cleared once the
operation is done. (R/W)
31 0
0x000000000 Reset
SPI_ADDR_REG It stores the transmitting address when master is in half-duplex mode or QSPI mode.
If the address length is bigger than 32 bits, this register stores the higher 32 bits of address value,
SPI_SLV_WR_STATUS_REG stores the rest lower part of address value. If the address length is
smaller than 33 bits, this register stores all the address value. The register is in valid only when
SPI_USR_ADDR bit is set to 1. (R/W)
I_ EA OR R
se EA IO R
E
SP FR IT_ DE
(re FR D_Q DE
OD
AD
_M L
RD A
I_ d DIO
I_ _B OR
ST DU
QU
SP RD IT_
SP rve D_
D_
FA D_
)
SP WP )
d)
I_ _B
EA
I_ EA
ed
ed
ve
SP WR
FR
SP FR
rv
rv
r
se
se
se
I_
I_
I_
(re
(re
(re
SP
SP
31 27 26 25 24 23 22 21 20 19 15 14 13 12 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_WR_BIT_ORDER This bit determines the bit order for command, address and data in transmitted
signal. 1: sends LSB first; 0: sends MSB first. (R/W)
SPI_RD_BIT_ORDER This bit determines the bit order for received data in received signal. 1: re-
ceives LSB first; 0: receives MSB first. (R/W)
SPI_FREAD_QIO This bit is used to enable four-line address writes and data reads in QSPI mode.
(R/W)
SPI_FREAD_DIO This bit is used to enable two-line address writes and data reads in QSPI mode.
(R/W)
SPI_WP This bit determines the write-protection signal output when SPI is idle in QSPI mode. 1:
output high; 0: output low. (R/W)
SPI_FREAD_QUAD This bit is used to enable four-line data reads in QSPI mode. (R/W)
SPI_FREAD_DUAL This bit is used to enable two-line data reads in QSPI mode. (R/W)
SPI_FASTRD_MODE Reserved.
)
ed
S_
rv
_C
se
I
(re
SP
31 28 27 0
0x05 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_CS_HOLD_DELAY Reserved.
XT
_E
US
US
AT
AT
ST
ST
I_
I_
SP
SP
31 24 23 16 15 0
SPI_STATUS_EXT Reserved.
SPI_STATUS Reserved.
E
OD
M
OD
UM
E
NU
OD
UM
_M
_N
Y_
Y_
_M
AY
AY
_N
E
LA
LA
M
EL
EL
AY
AY
M
DE
DE
TI
I
D
D
EL
EL
_T
P_
I_
I_
O_
O_
LD
_D
_D
TU
OS
OS
ed
d
IS
IS
HO
CS
CS
SE
ve
M
_M
rv
r
I_
I_
I_
I_
I_
I_
I_
se
se
I
SP
SP
SP
SP
SP
SP
SP
SP
re
re
31 28 27 26 25 23 22 21 20 18 17 16 15 12 11 8 7 4 3 0
0x00 0x0 0x0 0x0 0x0 0x0 0x00 0x00 0x01 0x01 Reset
SPI_CS_DELAY_NUM Reserved.
SPI_CS_DELAY_MODE Reserved.
SPI_MOSI_DELAY_NUM It is used to configure the number of system clock cycles by which the
MOSI signals are delayed. (R/W)
SPI_MOSI_DELAY_MODE This register field determines the way the MOSI signals are delayed by
SPI clock. (R/W)
After being delayed by SPI_MOSI_DELAY_NUM system clocks, the MOSI signals will then be
delayed by the configuration of SPI_MOSI_DELAY_MODE, specifically:
0: no delay.
1: if SPI_CK_OUT_EDGE or SPI_CK_I_EDGE is set, the MOSI signals are delayed by half a cycle,
otherwise they are delayed by one cycle.
2: if SPI_CK_OUT_EDGE or SPI_CK_I_EDGE is set, the MOSI signals are delayed by one cycle,
otherwise they are delayed by half a cycle.
3: the MOSI signals are delayed one cycle.
SPI_MISO_DELAY_NUM It is used to configure the number of system clock cycles by which the
MISO signals are delayed. (R/W)
SPI_MISO_DELAY_MODE This register field determines the way MISO signals are delayed by SPI
clock. (R/W)
After being delayed by SPI_MISO_DELAY_NUM system clock, the MISO signals will then be de-
layed by the configuration of SPI_MISO_DELAY_MODE, specifically:
0: no delay.
1: if SPI_CK_OUT_EDGE or SPI_CK_I_EDGE is set, the MISO signals are delayed by half a cycle,
otherwise they are delayed by one cycle.
2: if SPI_CK_OUT_EDGE or SPI_CK_I_EDGE is set, the MISO signals are delayed by one cycle,
otherwise they are delayed by half a cycle.
3: the MISO signals are delayed by one cycle.
SPI_HOLD_TIME The number of SPI clock cycles by which CS pin signals are delayed. It is only
valid when SPI_CS_HOLD is set to 1. (R/W)
SPI_SETUP_TIME It is to configure the time between the CS signal active edge and the first SPI
clock edge. It is only valid in half-duplex mode or QSPI mode and when SPI_CS_SETUP is set
to 1. (R/W)
LK
SC
SY
E
PR
U_
_N
_H
_L
IV_
NT
NT
NT
EQ
KD
KC
KC
KC
K_
CL
CL
CL
CL
CL
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
31 30 18 17 12 11 6 5 0
SPI_CLK_EQU_SYSCLK In master mode, when this bit is set to 1, SPI output clock is equal to system
clock; when set to 0, SPI output clock is divided from system clock. In slave mode, it should be
set to 0. (R/W)
SPI_CLKDIV_PRE In master mode, it is used to configure the pre-divider value for SPI output clock.
It is only valid when SPI_CLK_EQU_SYSCLK is 0. In slave mode, it should be set to 0. (R/W)
SPI_CLKCNT_N In master mode, it is used to configure the divider for SPI output clock. It is only
valid when SPI_CLK_EQU_SYSCLK is 0. In slave mode, it should be set to 0. (R/W)
GH RT
RT
HI PA
PA
M I_H LE
d) OR R
R
O_ H
R_ OS Y_ID
E
I_ R_ DR ND
DE
IS IG
E_ D
I_ _S GE E
SP WR TE_ UAD
(re _B E_ L
YT OR
SP CS ED DG
SP US AD MA
SP US MIS MY
RD YT A
SP FW TE_ IO
SP FW TE_ IO
I_ R_ MM
I_ _B DU
_H UP
I_ R_ O
I_ R_ SI
I_ _I_ _E
I_ RI D
I_ RI Q
I_ RI Q
I_ R_ M
I_ R_ M
N
SP FW E_
SP US MO
SP US DU
SP US DU
SP US CO
SP CK UT
OL
CS ET
DI
US M
I_ RIT
)
UT
I_ _O
I_ R_
ed
ed
e
SP SIO
SP FW
DO
SP US
SP CK
rv
rv
rv
se
se
se
I_
I_
I_
I_
I_
(re
(re
SP
SP
SP
SP
31 30 29 28 27 26 25 24 23 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 Reset
SPI_USR_COMMAND This bit enables the command phase of an SPI operation in SPI half-duplex
mode and QSPI mode. (R/W)
SPI_USR_ADDR This bit enables the address phase of an SPI operation in SPI half-duplex mode
and QSPI mode. (R/W)
SPI_USR_DUMMY This bit enables the dummy phase of an SPI operation in SPI half-duplex mode
and QSPI mode. (R/W)
SPI_USR_MISO This bit enables the read-data phase of an SPI operation in SPI half-duplex mode
and QSPI mode. (R/W)
SPI_USR_MOSI This bit enables the write-data phase of an SPI operation in SPI half-duplex mode
and QSPI mode. (R/W)
SPI_USR_DUMMY_IDLE The SPI clock signal is disabled in the dummy phase when the bit is set in
SPI half-duplex mode and QSPI mode. (R/W)
SPI_USR_MOSI_HIGHPART If set, MOSI data is stored in SPI_W8 ~ SPI_W15 of the SPI buffer.
(R/W)
SPI_USR_MISO_HIGHPART If set, MISO data is stored in SPI_W8 ~ SPI_W15 of the SPI buffer.
(R/W)
SPI_FWRITE_QIO Reserved.
SPI_FWRITE_DIO Reserved.
SPI_FWRITE_QUAD Reserved.
SPI_FWRITE_DUAL Reserved.
SPI_WR_BYTE_ORDER This bit determines the byte order of the command, address and data in
transmitted signal. 1: big-endian; 0: little-endian. (R/W)
SPI_RD_BYTE_ORDER This bit determines the byte order of received data in transmitted signal. 1:
big-endian; 0: little_endian. (R/W)
SPI_CK_OUT_EDGE This bit, combined with SPI_MOSI_DELAY_MODE, sets the MOSI signal delay
mode. It is only valid in master mode. (R/W)
SPI_CK_I_EDGE In slave mode, the bit is the same as SPI_CK_OUT_EDGE in master mode. It is
combined with SPI_MISO_DELAY_MODE. It is only valid in slave mode. (R/W)
SPI_CS_SETUP Setting this bit enables a delay between CS active edge and the first clock edge,
in multiples of one SPI clock cycle. In full-duplex mode and QSPI mode, setting this bit results in
(SPI_SETUP_TIME + 1.5) SPI clock cycles delay. In full-duplex mode, there will be 1.5 SPI clock
cycles delay for mode0 and mode2, and 1 SPI clock cycle delay for mode1 and mode3. (R/W)
SPI_CS_HOLD Setting this bit enables a delay between the end of a transmission and CS being
inactive, as specified in SPI_HOLD_TIME. (R/W)
EN
EL
N
CL
LE
CY
IT
Y_
B
R_
M
UM
DD
D
A
)
R_
R_
ed
US
US
rv
se
I_
I_
(re
SP
SP
31 26 25 8 7 0
23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 Reset
SPI_USR_ADDR_BITLEN It indicates the bit length of the transmitted address minus one in half-
duplex mode and QSPI mode, in multiples of one bit. It is only valid when SPI_USR_ADDR is set
to 1. (RO)
SPI_USR_DUMMY_CYCLELEN It indicates the number of SPI clock cycles for the dummy phase
minus one in SPI half-duplex mode and QSPI mode. It is only valid when SPI_USR_DUMMY is
set to 1. (R/W)
E
LE
LU
IT
VA
B
D_
D_
AN
AN
M
M
M
M
CO
CO
)
R_
R_
ed
US
US
rv
se
I_
I_
(re
SP
SP
31 28 27 16 15 0
7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_USR_COMMAND_BITLEN It indicates the bit length of the command phase minus one in SPI
half-duplex mode and QSPI mode. It is only valid when SPI_USR_COMMAND is set to 1. (R/W)
E N
TL
BI
_D
I
OS
M
)
R_
ed
US
rv
se
I_
(re
SP
31 24 23 0
0 0 0 0 0 0 0 0 0x0000000 Reset
SPI_USR_MOSI_DBITLEN It indicates the length of MOSI data minus one, in multiples of one bit. It
is only valid when SPI_USR_MOSI is set to 1 in master mode. (R/W)
R_
ed
US
rv
se
I_
(re
SP
31 24 23 0
0 0 0 0 0 0 0 0 0x0000000 Reset
SPI_USR_MISO_DBITLEN It indicates the length of MISO data minus one, in multiples of one bit. It
is only valid when SPI_USR_MISO is set to 1 in master mode. (R/W)
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_SLV_WR_STATUS_REG In the slave mode this register is the status register for the master to
write the slave. In the master mode, if the address length is bigger than 32 bits, SPI_ADDR_REG
stores the higher 32 bits of address value, and this register stores the rest lower part of address
value. (R/W)
OL
ED IVE
E L
GE
_P
_S
E_ T
DL AC
CS
CK
_I P_
R_
R_
SP CS DIS
S
CS IS
CK EE
DI
IS
TE
TE
I_ 1_D
I_ d)
SP ed)
(re _D
I_ 2_
0_
I_ _K
ed
ed
AS
AS
SP rve
SP CS
SP CS
CK
rv
rv
rv
M
M
se
se
se
se
I_
I_
I_
I_
(re
(re
(re
SP
SP
SP
31 30 29 28 14 13 11 10 9 8 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 Reset
SPI_CS_KEEP_ACTIVE This bit is only used in master mode where when it is set, the CS signal will
keep active. (R/W)
SPI_CK_IDLE_EDGE This bit is only used in master mode to configure the logicl level of SPI output
clock in idle state. (R/W)
1: the spi_clk line keeps high when idle;
0: the spi_clk line keeps low when idle.
SPI_MASTER_CK_SEL Reserved.
SPI_MASTER_CS_POL Reserved.
SPI_CK_DIS Reserved.
SPI_CS2_DIS This bit enables the SPI CS2 signal. 1: disables CS2; 0: enables CS2. (R/W)
SPI_CS1_DIS This bit enables the SPI CS1 signal. 1: disables CS1; 0: enables CS1. (R/W)
SPI_CS0_DIS This bit enables the SPI CS0 signal. 1: disables CS0; 0: enables CS0. (R/W)
D
D_ ST EN
FI EN
SP SLV R_ NE TEN
SP SLV R_ A_ TEN
_D NE
SP TRA D_ UF_ TEN
E
V_ _B D E
_B F_D E
ON
SL R A_ N
CM D F_
RD U ON
DE A_
NE
UF O
I_ _W ST DO
TE
I_ N BU I N
I_ _W O IN
I_ _W ST IN
V_ _R BU
I_ _R B I N
OM
TA
SP SLV R_ EN
SP SLV D_ A_
SP SLV D_ A_
SP SLV R_ DE
SP SLV E_M ET
SL R _
_
E
NT
_C
_S
I_ _W RD
I_ _R ST
I_ _R ST
I_ _W NT
I_ _W O
SP RA OD
I_ AV ES
ST
ST
_C
SP SLV S_I
SP SL _R
_M
LA
LA
NS
)
I_ NC
I_ N
ed
_I
V_
V_
RA
CS
rv
SP SY
SL
SL
I_T
I_T
se
I_
I_
I_
I_
(re
SP
SP
SP
SP
SP
SP
31 30 29 28 27 26 23 22 20 19 17 16 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_SYNC_RESET When set, it resets the latched values of the SPI clock line, CS line and data line.
(R/W)
SPI_SLAVE_MODE This bit is used to set the mode of the SPI device. (R/W)
1: slave mode;
0: master mode.
SPI_SLV_WR_RD_BUF_EN This bit is only used in slave half-duplex mode, where when it is set, the
write and read data commands are enabled. (R/W)
SPI_SLV_WR_RD_STA_EN This bit is only used in slave half-duplex mode, where when it is set, the
write and read status commands are enabled. (R/W)
SPI_SLV_CMD_DEFINE Reserved.
SPI_TRANS_CNT The counter for operations in both the master mode and the slave mode. (RO)
SPI_SLV_LAST_STATE In slave mode, this contains the state of the SPI state machine. (RO)
SPI_SLV_LAST_COMMAND Reserved.
SPI_CS_I_MODE Reserved.
SPI_TRANS_INTEN The interrupt enable bit for the SPI_TRANS_DONE_INT interrupt. (R/W)
SPI_SLV_WR_STA_INTEN The interrupt enable bit for the SPI_SLV_WR_STA_INT interrupt. (R/W)
SPI_SLV_RD_STA_INTEN The interrupt enable bit for the SPI_SLV_RD_STA_INT interrupt. (R/W)
SPI_SLV_WR_BUF_INTEN The interrupt enable bit for the SPI_SLV_WR_BUF_INT interrupt. (R/W)
SPI_SLV_RD_BUF_INTEN The interrupt enable bit for the SPI_SLV_RD_BUF_INT interrupt. (R/W)
SPI_TRANS_DONE The raw interrupt status bit for the SPI_TRANS_DONE_INT interrupt. It is set by
hardware and cleared by software. (R/W)
SPI_SLV_WR_STA_DONE The raw interrupt status bit for the SPI_SLV_WR_STA_INT interrupt. It is
set by hardware and cleared by software, and only applicable to slave half-duplex mode. (R/W)
SPI_SLV_RD_STA_DONE The raw interrupt status bit for the SPI_SLV_RD_STA_INT interrupt. It is set
by hardware and cleared by software, and only applicable to slave half-duplex mode. (R/W)
SPI_SLV_WR_BUF_DONE The raw interrupt status bit for the SPI_SLV_WR_BUF_INT interrupt. It is
set by hardware and cleared by software, and only applicable to slave half-duplex mode. (R/W)
SPI_SLV_RD_BUF_DONE The raw interrupt status bit for the SPI_SLV_RD_BUF_INT interrupt. It is
set by hardware and cleared by software, and only applicable to slave half-duplex mode. (R/W)
M N
EN
BU DU MY N
K
F_ M _EN
M _E
EN
AC
RD F_ M _E
N
EA EN
Y_
LE
DU MY
V_ BU U Y
N
TL
DB
SL R _D M
_R T_
LE
IT
BI
I_ _W TA UM
US AS
B
IT
R_
R_
_B
AT _F
SP SLV DS _D
DD
DD
US
ST S
I_ _R TA
V_ TU
A
A
AT
SP SLV RS
R_
D_
SL TA
ST
I_ _W
R
I_ _S
)
ed
V_
V_
V_
SP LV
SP SLV
rv
SL
SL
SL
S
se
I_
I_
I_
I_
I_
(re
SP
SP
SP
SP
SP
31 27 26 25 24 16 15 10 9 4 3 2 1 0
SPI_SLV_STATUS_BITLEN It is only used in slave half-duplex mode to configure the length of the
master writing into the status register. (R/W)
SPI_SLV_STATUS_FAST_EN Reserved.
SPI_SLV_STATUS_READBACK Reserved.
SPI_SLV_RD_ADDR_BITLEN It indicates the address length in bits minus one for a slave-read op-
eration. It is only valid in slave half-duplex mode. (R/W)
SPI_SLV_WR_ADDR_BITLEN It indicates the address length in bits minus one for a slave-write op-
eration. It is only valid in slave half-duplex mode. (R/W)
SPI_SLV_WRSTA_DUMMY_EN In slave mode, this bit enables the dummy phase for write-status
operations. It is only valid in slave half-duplex mode.(R/W)
SPI_SLV_RDSTA_DUMMY_EN In slave mode, this bit enables the dummy phase for read-status op-
erations. It is only valid in slave half-duplex mode. (R/W)
SPI_SLV_WRBUF_DUMMY_EN In slave mode, this bit enables the dummy phase for write-buffer
operations. It is only valid in slave half-duplex mode. (R/W)
SPI_SLV_RDBUF_DUMMY_EN In slave mode, this bit enables the dummy phase for read-buffer op-
erations. It is only valid in slave half-duplex mode. (R/W)
EN
EN
EN
LE
EL
EL
EL
E
CL
CL
CL
CL
CY
CY
CY
CY
Y_
Y_
Y_
Y_
M
M
UM
UM
M
DU
DU
D
_D
F_
F_
A_
TA
U
ST
RB
RS
DB
RD
W
W
R
V_
V_
V_
V_
SL
SL
SL
SL
I_
I_
I_
I_
SP
SP
SP
SP
31 24 23 16 15 8 7 0
SPI_SLV_WRBUF_DUMMY_CYCLELEN It indicates the number of SPI clock cycles minus one for the
dummy phase for write-data operations. It is only valid when SPI_SLV_WRBUF_DUMMY_EN is set
to 1 in slave half-duplex mode. (R/W)
SPI_SLV_RDBUF_DUMMY_CYCLELEN It indicates the number of SPI clock cycles minus one for the
dummy phase for read-data operations. It is only valid when SPI_SLV_RDBUF_DUMMY_EN is set
to 1 in slave half-duplex mode. (R/W)
E
E
LU
LU
LU
LU
VA
VA
VA
VA
D_
D_
D_
D_
M
M
CM
_C
_C
_C
A_
UF
UF
TA
ST
RB
RS
DB
RD
W
R
V_
V_
V_
V_
SL
SL
SL
SL
I_
I_
I_
I_
SP
SP
SP
SP
31 24 23 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_SLV_WRSTA_CMD_VALUE Reserved.
SPI_SLV_RDSTA_CMD_VALUE Reserved.
SPI_SLV_WRBUF_CMD_VALUE Reserved.
SPI_SLV_RDBUF_CMD_VALUE Reserved.
N
LE
BIT
_D
UF
RB
W
d)
V_
ve
SL
r
se
I_
(re
SP
31 24 23 0
0 0 0 0 0 0 0 0 0x0000000 Reset
SPI_SLV_WRBUF_DBITLEN It indicates the length of written data minus one, in multiples of one bit.
It is only valid in slave half-duplex mode. (R/W)
N
LE
T
BI
_D
UF
DB
R
)
ed
V_
rv
SL
se
I_
(re
SP
31 24 23 0
0 0 0 0 0 0 0 0 0x0000000 Reset
SPI_SLV_RDBUF_DBITLEN It indicates the length of read data minus one, in multiples of one bit. It
is only valid in slave half-duplex mode. (R/W)
V_
rv
SL
se
I_
(re
SP
31 24 23 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_SLV_RDATA_BIT It indicates the bit length of data the master reads from the slave, minus one.
It is only valid in slave half-duplex mode. (R/W)
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_TX_CRC_REG Reserved.
d)
ve
ST
r
se
I_
(re
SP
31 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T_ CR_ ST _EN
E N
OD _E
F_ UR N
R T
EO B _E
M ST
P
I_ d _S P
SP OU CR_ _BU
TO
(re DM TX IN
SP rve RX TO
I N RS _
I_ T_ IFO
I_ A_ NT
I_ BM ST
I_ S A
SP IND AT
SP DM CO
SP AH _R
SP OU _F
T
OU S
D
I_ BM
I_ A_
)
SP OU )
)
I_ T_
ed
ed
ed
SP DM
SP AH
rv
rv
rv
se
se
se
I_
I_
(re
(re
SP
SP
31 17 16 15 14 13 12 11 10 9 8 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 Reset
SPI_DMA_CONTINUE This bit enables SPI DMA continuous data TX/RX mode. (R/W)
SPI_DMA_TX_STOP When in continuous TX/RX mode, setting this bit stops sending data. (R/W)
SPI_DMA_RX_STOP When in continuous TX/RX mode, setting this bit stops receiving data. (R/W)
SPI_OUT_DATA_BURST_EN SPI DMA reads data from memory in burst mode. (R/W)
SPI_AHBM_FIFO_RST This bit is used to reset SPI DMA AHB master FIFO pointer. (R/W)
SPI_OUT_RST The bit is used to reset DMA out-FSM and out-data FIFO pointer. (R/W)
SPI_IN_RST The bit is used to reset DMA in-DSM and in-data FIFO pointer. (R/W)
ST T
DR
OP
K_ R
AD
OU IN E
I_ TL _R
K_
SP OU INK
IN
I_ d)
d)
I_ TL
TL
SP rve
ve
SP OU
OU
r
se
se
I_
(re
(re
SP
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000000 Reset
ET
NK TA T
R
LI S AR
O_
_S RT
R
P
IN K_ T
DD
UT
I_ IN RES
TO
_A
_A
SP INL K_
NK
NK
I_ d)
)
I_ IN
ed
LI
LI
SP rve
SP INL
rv
IN
IN
se
se
I_
I_
(re
(re
SP
SP
31 30 29 28 27 21 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000000 Reset
SPI_INLINK_AUTO_RET when the bit is set, inlink descriptor jumps to the next descriptor when a
packet is invalid. (R/W)
N
RX N
_E
A_ _E
DM TX
I_ A_
)
ed
SP DM
rv
se
I_
(re
SP
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EN A
T_ N
PT R_ ENA
A
I N _E
Y_ INT
EM RO T_
A
R_ ER IN
SP IN_ C_ _IN NA EN
SC R_ R_
SP OU K_ INT T_E A
I_ TL DS _E NA
I_ SU NE E T_
I_ IN E_ IN N
I_ D EO IN A
_D SC RO
SP IN_ DO INT_ _IN
SP INL ON F_ T_E
SP IN_ R_ F_ EN
IN IN CR NA
NK D ER
I_ ER EO T_
I_ T_ F_ OF
LI K_ _
SP OU EO _E
I_ T_ AL
SP OU OT
I_ T_T
)
ed
SP OU
rv
se
I_
(re
SP
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_OUT_EOF_INT_ENA The interrupt enable bit for the SPI_OUT_EOF_INT interrupt. (R/W)
SPI_OUT_DONE_INT_ENA The interrupt enable bit for the SPI_OUT_DONE_INT interrupt. (R/W)
SPI_IN_SUC_EOF_INT_ENA The interrupt enable bit for the SPI_IN_SUC_EOF_INT interrupt. (R/W)
SPI_IN_ERR_EOF_INT_ENA The interrupt enable bit for the SPI_IN_ERR_EOF_INT interrupt. (R/W)
SPI_IN_DONE_INT_ENA The interrupt enable bit for the SPI_IN_DONE_INT interrupt. (R/W)
RA W
T_ A
PT R_ RAW
W
I N _R
Y_ INT
EM RO T_
W
R_ ER IN
SP IN_ C_ _IN AW RA
SC R_ R_
I_ IN E_ IN AW
I_ TL DS _R AW
I_ SU NE R T_
I_ D EO IN W
_D SC RO
SP INL ON F_ T_R
SP IN_ DO INT_ _IN
SP OU K_ INT T_R
SP IN_ R_ F_ RA
IN IN CR AW
NK D ER
I_ ER EO T_
I_ T_ F_ OF
LI K_ _
SP OU EO _E
I_ T_ AL
SP OU TOT
d)
I_ T_
ve
SP OU
r
se
I_
(re
SP
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_OUT_TOTAL_EOF_INT_RAW The raw interrupt status bit for the SPI_OUT_TOTAL_EOF_INT inter-
rupt. (RO)
SPI_OUT_EOF_INT_RAW The raw interrupt status bit for the SPI_OUT_EOF_INT interrupt. (RO)
SPI_OUT_DONE_INT_RAW The raw interrupt status bit for the SPI_OUT_DONE_INT interrupt. (RO)
SPI_IN_SUC_EOF_INT_RAW The raw interrupt status bit for the SPI_IN_SUC_EOF_INT interrupt.
(RO)
SPI_IN_ERR_EOF_INT_RAW The raw interrupt status bit for the SPI_IN_ERR_EOF_INT interrupt.
(RO)
SPI_IN_DONE_INT_RAW The raw interrupt status bit for the SPI_IN_DONE_INT interrupt. (RO)
T_ T
IN _S
PT R_ ST
ST
Y_ INT
EM RO T_
R_ ER IN
SP IN_ C_ _IN T ST
SC R_ R_
I_ SU NE S T_
I_ IN E_ IN T
I_ TL DS _S T
_D SC RO
SP INL ON F_ T_S
SP IN_ DO INT_ _IN
SP OU K_ INT T_S
SP IN_ R_ F_ ST
NK D ER
IN IN CR T
I_ ER EO T_
I_ T_ F_ OF
I_ D EO IN
LI K_ _
SP OU EO _E
I_ T_ AL
SP OU OT
I_ T_T
)
ed
SP OU
rv
se
I_
(re
SP
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_OUT_TOTAL_EOF_INT_ST The masked interrupt status bit for the SPI_OUT_TOTAL_EOF_INT in-
terrupt. (RO)
SPI_OUT_EOF_INT_ST The masked interrupt status bit for the SPI_OUT_EOF_INT interrupt. (RO)
SPI_OUT_DONE_INT_ST The masked interrupt status bit for the SPI_OUT_DONE_INT interrupt. (RO)
SPI_IN_SUC_EOF_INT_ST The masked interrupt status bit for the SPI_IN_SUC_EOF_INT interrupt.
(RO)
SPI_IN_ERR_EOF_INT_ST The masked interrupt status bit for the SPI_IN_ERR_EOF_INT interrupt.
(RO)
SPI_IN_DONE_INT_ST The masked interrupt status bit for the SPI_IN_DONE_INT interrupt. (RO)
CL R
T_ L
PT R_ LR
R
IN _C
EM RO T_C
Y_ INT
R
R_ ER IN
SP IN_ C_ _IN LR CL
SC R_ R_
I_ IN E_ IN LR
I_ TL DS _C LR
I_ SU NE C T_
I_ D EO IN R
_ D S C RO
SP INL ON F_ T_C
SP IN_ DO INT_ _IN
SP OU K_ INT T_C
SP IN_ R_ F_ CL
IN IN CR LR
NK D ER
I_ ER EO T_
I_ T_ F_ OF
LI K_ _
SP OU EO _E
I_ T_ AL
SP OU OT
I_ T_T
d)
ve
SP OU
r
se
I_
(re
SP
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_IN_SUC_EOF_DES_ADDR_REG The last inlink descriptor address when SPI DMA encountered
EOF. (RO)
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_OUT_EOF_DES_ADDR_REG The last outlink descriptor address when SPI DMA encountered
EOF. (RO)
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RE
LL
O_ P
DD
IF EM
_A
)
_F _
ed
TX FIFO
ES
rv
_D
se
_
(re
TX
TX
31 30 29 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TX_DES_ADDRESS The LSB of the SPI DMA outlink descriptor address. (RO)
SS
FU TY
RE
LL
O_ P
DD
IF EM
A
)
_F _
ed
S_
RX FIFO
rv
E
_D
se
_
(re
RX
RX
31 30 29 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RX_DES_ADDRESS The LSB of the SPI DMA inlink descriptor address. (RO)
8.1 Overview
The ESP32 features hardware support for the industry-standard Secure Digital (SD) device interface that
conforms to the SD Input/Output (SDIO) Specification Version 2.0. This allows a host controller to access the
ESP32 via an SDIO bus protocol, enabling high-speed data transfer.
The SDIO interface may be used to read ESP32 SDIO registers directly and access shared memory via Direct
Memory Access (DMA), thus reducing processing overhead while maintaining high performance.
8.2 Features
• Meets SDIO V2.0 specification
The Host System represents any SDIO specification V2.0-compatible host device. The Host System interacts
with the ESP32 (configured as the SDIO slave) via the standard SDIO bus implementation.
The SDIO Device Interface block enables effective communication with the external Host by directly providing
SDIO interface registers and enabling DMA operation for high-speed data transfer over the Advanced
High-performance Bus (AHB) without engaging the CPU.
ESP32 segregates data into packets sent to/from the Host. To achieve high bus utilization and data transfer
rates, we recommend the single block transmission mode. For detailed information on this mode, please refer
to the SDIO V2.0 protocol specification. When Host and Slave exchange data as blocks on the SDIO bus, the
Slave automatically pads data-when sending data out-and automatically strips padding data from the incoming
data block.
Whether the Slave pads or discards the data depends on the data address on the SDIO bus. When the data
address is equal to, or greater than, 0x1F800, the Slave will start padding or discarding data. Therefore, the
starting data address should be 0x1F800 - Packet_length, where Packet_length is measured in bytes. Data
flow on the SDIO bus is shown in Figure 8-2.
The standard IO_RW_EXTENDED (CMD53) command is used to initiate a packet transfer of an arbitrary length.
The content of the CMD53 command used in data transmission is as illustrated in Figure 8-3 below. For
detailed information on CMD53, please refer to the SDIO protocol specifications.
There are 52 bytes of field between SLCHOST_CONF_W0_REG and SLCHOST_CONF_W15_REG. Host and Slave
can access and change these fields, thus facilitating the information interaction between Host and
Slave.
8.3.4 DMA
The SDIO Slave module uses dedicated DMA to access data residing in the RAM. As shown in Figure 8-1, the
RAM is accessed over the AHB. DMA accesses RAM through a linked-list descriptor. Every linked list is
• Owner: The allowed operator of the buffer that corresponds to the current linked list. 0: CPU is the
allowed operator; 1: DMA is the allowed operator.
• Eof: End-of-file marker, indicating that this linked-list element is the last element of the data packet.
• Length: The number of valid bytes in the buffer, i.e., the number of bytes that should be accessed from
the buffer for reading/writing.
• Buffer Address Pointer: The address of the data buffer as seen by the CPU (according to the RAM
address space).
• Next Descriptor Address: The address of the next linked-list element in the CPU RAM address space. If
the current linked list is the last one, the Eof bit should be 1, and the last descriptor address should be 0.
When the Host is interrupted, it reads relevant information from the Slave by visiting registers SLC0HOST_INT
and SLCHOST_PKT_LEN.
• SLCHOST_PKT_LEN: Packet length accumulator register. The current value minus the value of last time
equals the packet length sent this time.
In order to start DMA, the CPU needs to write the low 20 bits of the address of the first linked-list element to
the SLC0_RXLINK_ADDR bit of SLC0RX_LINK, then set the SLC0_RXLINK_START bit of SLC0RX_LINK. The
DMA will automatically complete the data transfer. Upon completion of the operation, DMA will interrupt the
CPU so that the buffer space can be freed or reused.
The Host obtains the number of available receiving buffers from the Slave by accessing register
SLC0HOST_TOKEN_RDATA. The Slave CPU should update this value after the receiving DMA linked list is
prepared.
The Host can figure out the available buffer space, using HOSTREG_SLC0_TOKEN1 minus the number of
buffers already used.
If the buffers are not enough, the Host needs to constantly poll the register until there are enough buffers
available.
To ensure sufficient receiving buffers, the Slave CPU must constantly load buffers on the receiving linked list.
The process is shown in Figure 8-8.
The CPU first needs to append new buffer segments at the end of the linked list that is being used by DMA
and is available for receiving data.
The CPU then needs to notify the DMA that the linked list has been modified. This can be done by setting bit
SLC0_TXLINK_RESTART of the SLC0TX_LINK register. Please note that when the CPU initiates DMA to receive
packets for the first time, SLC0_TXLINK_RESTART should be set to 1.
Lastly, the CPU refreshes any available buffer information by writing to the SLC0TOKEN1 register.
When the incoming data changes near the rising edge of the clock, the Slave will perform sampling on the
falling edge of the clock, or vice versa, as Figure 8-9 shows.
By default, the MTDO strapping value determines the Slave’s sampling edge. However, users can decide the
sampling edge by configuring the SLCHOST_CONF_REG register, with priority from high to low: (1) Set
SLCHOST_FRC_POS_SAMP to sample the corresponding signal at the rising edge; (2) Set
SLCHOST_FRC_NEG_SAMP to sample the corresponding signal at the falling edge.
SLCHOST_FRC_POS_SAMP and SLCHOST_FRC_NEG_SAMP fields are five bits wide. The bits correspond to
the CMD line and four DATA lines (0-3). Setting a bit causes the corresponding line to be sampled for input at
the rising clock edge or falling clock edge.
The Slave can also select which edge to drive the output lines, in order to accommodate for any latency
caused by the physical signal path. The output timing is shown in Figure 8-10.
By default, the GPIO5 strapping value determines the Slave’s output driving edge. However, users can decide
the output driving edge by configuring the following registers, with priority from high to low: (1) Set
SLCHOST_FRC_SDIO11 in SLCHOST_CONF_REG to output the corresponding signal at the falling clock edge;
(2) Set SLCHOST_FRC_SDIO22 in SLCHOST_CONF_REG to output the corresponding signal at the rising clock
edge; (3) Set HINF_HIGHSPEED_ENABLE in HINF_CFG_DATA1_REG and SLCHOST_HSPEED_CON_EN in
SLCHOST_CONF_REG, then set the EHS (Enable High-Speed) bit in CCCR at the Host side to output the
corresponding signal at the rising clock edge.
SLCHOST_FRC_SDIO11 and SLCHOST_FRC_SDIO22 fields are five bits wide. The bits correspond to the CMD
line and four DATA lines (0-3). Setting a bit causes the corresponding line to output at the rising clock edge or
falling clock edge.
Notes on priority setting: The configuration of strapping pins has the lowest priority when controlling the
sampling edge or driving edge. The lower-priority configuration takes effect only when the higher-priority
configuration is not set. For example, the MTDO strapping value determines the sampling edge only when
SCLHOST_FRC_POS_SAMP and SCLHOST_FRC_NEG_SAMP are not set.
8.3.7 Interrupt
Host and Slave can interrupt each other via the interrupt vector. Both Host and Slave have eight interrupt
vectors. The interrupt is enabled by configuring the interrupt vector register (setting the enable bit to 1). The
interrupt vector registers can clear themselves automatically, which means one interrupt at a time and no other
configuration is required.
P_ ST K
R
OO TE AC
CL
_L P_ RB
ST
O_
TE
TX OO W
UT
0_ _L O_
_A
LC RX UT
TX ST
ST
EN
_S 0_ _A
0_ _R
_R
K
LC RX
TO
0_
O 0_ 0_
_S 0_
LC
CC F LC
F0 LC
_S
SL CON 0_S
ON 0_S
F0
d)
CC )
C F
CC F
ed
d
ON
SL CON
SL ON
ve
e
rv
rv
r
CC
se
se
se
C
(re
(re
SL
SL
SL
31 15 14 13 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 Reset
SLCCONF0_SLC0_RX_LOOP_TEST Loop around when the slave buffer finishes sending packets.
When set to 1, hardware will not change the owner bit in the linked list. (R/W)
SLCCONF0_SLC0_TX_LOOP_TEST Loop around when the slave buffer finishes receiving packets.
When set to 1, hardware will not change the owner bit in the linked list. (R/W)
IN AW
RA W
RA
IT T_ W
W
W
HO _B _IN AW
C_ HO BI IN AW
SL INT LC_ RHO _B _IN RAW
IN AW
R_ T_R
T_ RA
_B IN RA
RA
IN LC RH _B _IN RA
T_
FR ST T2 T_R
SL R T_ 3_ T_R
0_ R
IN T_
ER IN
C0 _S F ST IT7 RA
C0 _S F ST IT5 T_
ST IT1_ T_
T_
C0 _S F ST IT4 T_
C0 _S F ST _IN W
SU _I W
C0 _S F ST _I RA
C0 _S F ST IT6 T_
C0 _S 0_ ST INT W
_D _E _R
R_ R_
E_ _IN
SL INT LC X_ F_ _RA
SL _TX O T_
C0 _S 0_ UD NT
N
T_ _F OS IT
_D CR_
C0 X_ F_I
C0 _S 0_ EO
C0 _S 0_ OV
D
SL rve LC RX_
SL INT LC RX_
SL INT C X_
TX
T
se _S 0_
C0 _S 0_
C0 _S 0_
(re INT LC
SL INT LC
SL NT C
L
L
L
C0 _S
C0 _S
C0 _S
)
)
_
ed
ed
ed
SL INT
SL INT
SL INT
IN
rv
rv
rv
I
C0
C0
se
se
se
(re
(re
(re
SL
SL
31 27 26 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SLC0INT_SLC0_RX_DSCR_ERR_INT_RAW The raw interrupt bit for Slave sending descriptor error
(RO)
SLC0INT_SLC0_TX_DSCR_ERR_INT_RAW The raw interrupt bit for Slave receiving descriptor error.
(RO)
SLC0INT_SLC0_RX_EOF_INT_RAW The interrupt mark bit for Slave sending operation finished. (RO)
SLC0INT_SLC0_RX_DONE_INT_RAW The raw interrupt bit to mark single buffer as sent by Slave.
(RO)
SLC0INT_SLC0_TX_DONE_INT_RAW The raw interrupt bit to mark a single buffer as finished during
Slave receiving operation. (RO)
SLC0INT_SLC0_TX_OVF_INT_RAW The raw interrupt bit to mark Slave receiving buffer overflow.
(RO)
SLC0INT_SLC0_RX_UDF_INT_RAW The raw interrupt bit for Slave sending buffer underflow. (RO)
SLC0INT_SLC0_TX_START_INT_RAW The raw interrupt bit for registering Slave receiving initialization
interrupt. (RO)
SLC0INT_SLC0_RX_START_INT_RAW The raw interrupt bit to mark Slave sending initialization inter-
rupt. (RO)
SLC0INT_SLC_FRHOST_BIT7_INT_RAW The interrupt mark bit 7 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT6_INT_RAW The interrupt mark bit 6 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT5_INT_RAW The interrupt mark bit 5 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT4_INT_RAW The interrupt mark bit 4 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT3_INT_RAW The interrupt mark bit 3 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT2_INT_RAW The interrupt mark bit 2 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT1_INT_RAW The interrupt mark bit 1 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT0_INT_RAW The interrupt mark bit 0 for Host to interrupt Slave. (RO)
IN ST
ST
T_ ST
C0 T_ _F O BI IN T
IT NT_ T
ST
R_ T_
T_ _ O B IN ST
HO _B _ ST
C_ HO _B _I ST
T_
C T_ _ O BI IN T
IN T
SL 0IN SLC FRH ST_ T5_ T_S
_B _I _S
SL 0IN SLC FRH ST_ T6_ T_S
0_ S
IN T_
ER IN
T_
IN SLC RH ST_ T4_ T_
SL 0IN SLC FRH ST_ T7_ ST
ON OF ST
FR ST IT2 NT_
SL FR ST IT3 T_
SL 0IN SLC FRH ST_ _IN ST
ST
ST IT1 INT
E_ _IN
R_ RR_
C T_ _ _S T_ ST
ST
C T_ _ O BI T_
_D _E T_
C T_ 0 _S _I ST
C T_ _ O BI IN
C T_ _ O RT T_
SL 0IN SLC _RX TAR NT_
LC TX ON T_
SL ed) _TX UC _IN
C T_ 0 _U IN
E
_D R
SL IN SLC RX VF_
SL 0IN ) _TX SC
IN LC RX OF
C d 0 _D
C0 T_ 0_ _E
C0 T_ 0_ _O
_S
SL rve SLC _RX
SL IN SLC RX
SL IN LC TX
C0 T_ 0_
C0 T_ 0_
se T_ 0
0
(re 0IN SLC
SL IN SLC
SL IN SLC
S
S
d)
d)
C T_
C0 T_
C0 _ T
ve
ve
SL 0IN
SL 0IN
rv
r
r
se
se
se
C
C
(re
(re
SL
31 27 26 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SLC0INT_SLC0_RX_DSCR_ERR_INT_ST The interrupt status bit for Slave sending descriptor error.
(RO)
SLC0INT_SLC0_TX_DSCR_ERR_INT_ST The interrupt status bit for Slave receiving descriptor error.
(RO)
SLC0INT_SLC0_RX_EOF_INT_ST The interrupt status bit for finished Slave sending operation. (RO)
SLC0INT_SLC0_RX_DONE_INT_ST The interrupt status bit for finished Slave sending operation.
(RO)
SLC0INT_SLC0_TX_SUC_EOF_INT_ST The interrupt status bit for marking Slave receiving operation
as finished. (RO)
SLC0INT_SLC0_TX_DONE_INT_ST The interrupt status bit for marking a single buffer as finished
during the receiving operation. (RO)
SLC0INT_SLC0_TX_OVF_INT_ST The interrupt status bit for Slave receiving overflow interrupt. (RO)
SLC0INT_SLC0_RX_UDF_INT_ST The interrupt status bit for Slave sending buffer underflow. (RO)
SLC0INT_SLC0_TX_START_INT_ST The interrupt status bit for Slave receiving interrupt initialization.
(RO)
SLC0INT_SLC0_RX_START_INT_ST The interrupt status bit for Slave sending interrupt initialization.
(RO)
SLC0INT_SLC_FRHOST_BIT7_INT_ST The interrupt status bit 7 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT6_INT_ST The interrupt status bit 6 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT5_INT_ST The interrupt status bit 5 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT4_INT_ST The interrupt status bit 4 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT3_INT_ST The interrupt status bit 3 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT2_INT_ST The interrupt status bit 2 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT1_INT_ST The interrupt status bit 1 for Host to interrupt Slave. (RO)
SLC0INT_SLC_FRHOST_BIT0_INT_ST The interrupt status bit 0 for Host to interrupt Slave. (RO)
IN NA
A
EN
T_ ENA
_B _IN ENA
A
A
T_ 2_I ENA
T_ A
R_ _E
_IN NA
SL INT_ C_F OST IT5_ T_EN
EN
SL INT_ C_F OST IT4_ T_EN
T_ _FR ST_ T3_ _EN
SL INT_ C_F OST IT6_ _EN
T_
DO OF NA
IT0 T_E
_IN T_
T_
EN
HO BIT NT
SL INT_ C0_ _STA INT_ A
T
_E _E
SL RH _B INT
R T_E
RT EN
NE _IN
_
IN
IN
F_ EN
IN
SL RH _B T_
IN
SC ERR
E
_T SUC INT
T_ 0_T DO NT_
1
_
T
_D R_
R_
I
I
I
SL RH _B
SL RH _B
SL RH _B
B
SL RX F_I
F_
N
C
A
SL rved C0_ _DS
ST
SL INT_ C0_ _EO
C_ OS
O
_
_
X_
SL RH
H
SL RX
SL RX
SL RX
SL RX
TX
SL TX
SL TX
FR
(re INT_ C0_
SL INT_ C0_
0_
C0
C
C
SL
SL
SL
SL
S
d)
d)
)
SL INT_
SL INT_
SL INT_
_
d
T
rve
rve
rve
IN
IN
I
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
se
se
se
se
(re
(re
(re
SL
SL
SL
31 27 26 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SLC0INT_SLC0_RX_DSCR_ERR_INT_ENA The interrupt enable bit for Slave sending linked list de-
scriptor error. (R/W)
SLC0INT_SLC0_TX_DSCR_ERR_INT_ENA The interrupt enable bit for Slave receiving linked list de-
scriptor error. (R/W)
SLC0INT_SLC0_RX_EOF_INT_ENA The interrupt enable bit for Slave sending operation completion.
(R/W)
SLC0INT_SLC0_RX_DONE_INT_ENA The interrupt enable bit for single buffer’s sent interrupt, in
Slave sending mode. (R/W)
SLC0INT_SLC0_TX_SUC_EOF_INT_ENA The interrupt enable bit for Slave receiving operation com-
pletion. (R/W)
SLC0INT_SLC0_TX_DONE_INT_ENA The interrupt enable bit for single buffer’s full event, in Slave
receiving mode. (R/W)
SLC0INT_SLC0_TX_OVF_INT_ENA The interrupt enable bit for Slave receiving buffer overflow.
(R/W)
SLC0INT_SLC0_RX_UDF_INT_ENA The interrupt enable bit for Slave sending buffer underflow.
(R/W)
SLC0INT_SLC0_TX_START_INT_ENA The interrupt enable bit for Slave receiving operation initializa-
tion. (R/W)
SLC0INT_SLC0_RX_START_INT_ENA The interrupt enable bit for Slave sending operation initializa-
tion. (R/W)
SLC0INT_SLC_FRHOST_BIT7_INT_ENA The interrupt enable bit 7 for Host to interrupt Slave. (R/W)
SLC0INT_SLC_FRHOST_BIT6_INT_ENA The interrupt enable bit 6 for Host to interrupt Slave. (R/W)
SLC0INT_SLC_FRHOST_BIT5_INT_ENA The interrupt enable bit 5 for Host to interrupt Slave. (R/W)
SLC0INT_SLC_FRHOST_BIT4_INT_ENA The interrupt enable bit 4 for Host to interrupt Slave. (R/W)
SLC0INT_SLC_FRHOST_BIT3_INT_ENA The interrupt enable bit 3 for Host to interrupt Slave. (R/W)
SLC0INT_SLC_FRHOST_BIT2_INT_ENA The interrupt enable bit 2 for Host to interrupt Slave. (R/W)
SLC0INT_SLC_FRHOST_BIT1_INT_ENA The interrupt enable bit 1 for Host to interrupt Slave. (R/W)
Espressif Systems 173 ESP32 TRM (Version 5.2)
SLC0INT_SLC_FRHOST_BIT0_INT_ENA
Submit The interrupt enable
Documentation bit 0 for Host to interrupt Slave. (R/W)
Feedback
8 SDIO Slave Controller
IN LR
R
CL
T_ CLR
_B _IN CLR
R
I N LR
R_ _C
T_ 2_I CLR
T_ R
R
_IN LR
L
CL
T_ _FR ST_ T3_ _CL
T_
IT0 T_C
_IN T_
T_
CL
HO BIT NT
SL RH _B T_C
_E _C
F_ CLR
T
R T_C
SL RH _B INT
NE _IN
_
RT CL
L
IN
IN
IN
SC ERR
C
_T SUC INT
1
_
T
_D R_
R_
I
I
I
SL RH _B
SL RH _B
SL RH _B
B
SL RX F_I
F_
N
C
A
SL rved C0_ _DS
ST
SL INT_ C0_ _EO
C_ OS
O
_
_
X_
SL RH
H
SL RX
SL RX
SL RX
SL RX
TX
SL TX
SL TX
FR
(re INT_ C0_
SL INT_ C0_
0_
C0
C
C
SL
SL
SL
SL
S
d)
d)
)
SL INT_
SL INT_
SL INT_
_
d
T
rve
rve
rve
IN
IN
I
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
se
se
se
se
(re
(re
(re
SL
SL
SL
31 27 26 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SLC0INT_SLC0_RX_DSCR_ERR_INT_CLR Interrupt clear bit for Slave sending linked list descriptor
error. (WO)
SLC0INT_SLC0_TX_DSCR_ERR_INT_CLR Interrupt clear bit for Slave receiving linked list descriptor
error. (WO)
SLC0INT_SLC0_RX_EOF_INT_CLR Interrupt clear bit for Slave sending operation completion. (WO)
SLC0INT_SLC0_RX_DONE_INT_CLR Interrupt clear bit for single buffer’s sent interrupt, in Slave
sending mode. (WO)
SLC0INT_SLC0_TX_DONE_INT_CLR Interrupt clear bit for single buffer’s full event, in Slave receiv-
ing mode. (WO)
SLC0INT_SLC0_TX_OVF_INT_CLR Set this bit to clear the Slave receiving overflow interrupt. (WO)
SLC0INT_SLC0_RX_UDF_INT_CLR Set this bit to clear the Slave sending underflow interrupt. (WO)
SLC0INT_SLC0_TX_START_INT_CLR Set this bit to clear the interrupt for Slave receiving operation
initialization. (WO)
SLC0INT_SLC0_RX_START_INT_CLR Set this bit to clear the interrupt for Slave sending operation
initialization. (WO)
DR
P
RX K EST
TO
AD
0_ LIN R
LC RX K_
K_
_S 0_ LIN
IN
XL
RX LC RX
R
C0 _S 0_
0_
SL 0RX LC
LC
C _S
_S
SL RX )
)
C0 d
ed
SL rve
RX
rv
C0
se
se
(re
(re
SL
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000000 Reset
SLC0RX_SLC0_RXLINK_RESTART Set this bit to restart and continue the linked list operation for
sending packets. (R/W)
SLC0RX_SLC0_RXLINK_START Set this bit to start the linked list operation for sending packets.
Sending will start from the address indicated by SLC0_RXLINK_ADDR. (R/W)
SLC0RX_SLC0_RXLINK_STOP Set this bit to stop the linked list operation. (R/W)
SLC0RX_SLC0_RXLINK_ADDR The lowest 20 bits in the initial address of Slave’s sending linked list.
(R/W)
NK TA T
LI S AR
_S RT
R
P
TX K_ ST
DD
TO
0_ LIN RE
_A
LC TX K_
K
_S 0_ LIN
IN
XL
TX LC TX
_T
C0 _S 0_
C0
SL 0TX LC
SL
C _S
SL TX )
)
C0 d
ed
X_
SL rve
rv
T
C0
se
se
(re
(re
SL
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000000 Reset
SLC0TX_SLC0_TXLINK_RESTART Set this bit to restart and continue the linked list operation for
receiving packets. (R/W)
SLC0TX_SLC0_TXLINK_START Set this bit to start the linked list operation for receiving packets.
Receiving will start from the address indicated by SLC0_TXLINK_ADDR. (R/W)
SLC0TX_SLC0_TXLINK_STOP Set this bit to stop the linked list operation for receiving packets.
(R/W)
SLC0TX_SLC0_TXLINK_ADDR The lowest 20 bits in the initial address of Slave’s receiving linked
list. (R/W)
EC
TV
N
_I
ST
HO
TO
0_
LC
S
C_
)
VE
ed
ed
ed
NT
rv
rv
rv
se
se
se
CI
(re
(re
(re
SL
31 24 23 16 15 8 7 0
E
OR
_M
TA
DA
NC
W
_I
1_
1
N1
EN
EN
KE
OK
OK
TO
_T
_T
0_
C0
C0
ed SLC
SL
SL
1_
1_
se EN1
EN
EN
)
TO )
)
ed
C0 d
K
K
SL rve
TO
TO
rv
rv
C0
C0
se
se
(re
(re
(re
SL
SL
31 28 27 16 15 14 13 12 11 0
LR
N_ CH N
TO N
LE TIT _E
_C
AU _E
0_ _S CH
LC TX TIT
_S 0_ S
F1 LC RX_
ON 1_S 0_
CC F LC
SL CON 1_S
)
C F
ed
ed
ed
SL CON
rv
rv
rv
se
se
se
C
(re
(re
(re
SL
31 23 22 16 15 7 6 5 4
0x000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 Reset
E
AC
PL
E
_R
NO
N_
KE
TO
0_
d)
LC
ve
S
r
se
C_
(re
SL
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TA
DA
N
_W
_I
EN
EN
)
)
ed
ed
_L
_L
rv
rv
rv
C0
C0
se
se
se
(re
(re
(re
SL
31 29 28 23 22 21 20 19
SL 0
SLC0_LEN_INC_MORE Set this bit to add the value of SLC0_LEN to that of SLC0_LEN_WDATA.
(WO)
LE
rv
_
C0
se
(re
SL
31 20 19 0
N1
KE
TO
0_
LC
_S
)
d)
ed
EG
ve
rv
r
ST
se
se
HO
(re
(re
31 28 27 16 15 0
W
RA
IT0 T_R W
W
HO _SL _TO ST_B 4_IN RAW
HO _BIT INT W
LC OH T_B _INT AW
SL HOS SLC OH T_BI _INT AW
_IN AW
T_
1_ _RA
RA
A
_R
_IN
_R
R
T6 _R
T_
_
T_
W
_IN AW
_B IN
RA
CK
_
_
DF _R
0_ OS IT2
T5
T_
3
T7
PA
T
T
_U NT
I
W_
RX F_I
T
ST
T_ 0_T OS
T_ 0_T OS
T_ 0_T OS
T_ 0_T OS
S
NE
0_ OV
O
ST C0 HO
X_
SL HOS SLC OH
LC X_
TO
R
_S _T
T_ 0_T
_S _T
0_
ST C0
0
LC
SL HOS SLC
HO SL
_S
T_
T_
ST
T
d)
d)
d)
d)
OS
SL HOS
rve
rve
rve
rve
HO
H
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
C0
se
se
se
se
(re
(re
(re
(re
SL
SL
SL
SL
31 26 25 24 23 22 18 17 16 15 8 7 6 5 4 3 2 1 0
0x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
_S
INT
_IN ST
T
C0 ST_S 0_TO ST_B _INT T
0_ ST
_S
_S
S
_S
T_
_
_
ET_
INT
C0 ST_S 0_TO ST_B _INT
T
_ IN
T
F_ ST
CK
_S
IT5
IT3
IT 7
IT4
HO BIT1
_
INT
PA
BIT
X_ _INT
B
W_
ST_
T_
ST_
F
UD
NE
C0 _OV
HO
HO
HO
HO
HO
HO
X_
C0 ST_S 0_TO
O
_TO
X
_R
_R
ST_ C0_T
ST_ 0_T
C0
LC
LC
LC
LC
LC
LC
LC
SL
L
SL
SL
C0 ST_S
C0 ST_S
ST_
d)
d)
d)
d)
rve
rve
rve
rve
HO
HO
HO
HO
HO
HO
HO
HO
HO
HO
HO
C0
C0
C0
se
se
se
se
(re
(re
(re
(re
SL
SL
SL
SL
SL
SL
SL
SL
SL
SL
SL
31 26 25 24 23 22 18 17 16 15 8 7 6 5 4 3 2 1 0
0x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
K
H EC
_C
EN
N
LE
L
0_
0_
LC
LC
_S
_S
EG
EG
TR
TR
OS
OS
H
_H
T_
ST
OS
O
CH
CH
SL
SL
31 20 19 0
SLCHOST_HOSTREG_SLC0_LEN The accumulated value of the data length sent by the Slave. The
value gets updated only when the Host reads it.
F0
F2
F3
F1
ON
ON
ON
CO
C
C
T_
T_
T_
T_
OS
OS
OS
OS
CH
CH
CH
CH
SL
SL
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF3 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
SLCHOST_CONF2 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
SLCHOST_CONF1 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
SLCHOST_CONF0 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
F5
4
F7
NF
F
ON
ON
ON
CO
C
C
T_
T_
T_
T_
OS
OS
OS
OS
CH
CH
CH
CH
SL
SL
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF7 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
SLCHOST_CONF6 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
SLCHOST_CONF5 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
SLCHOST_CONF4 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
F9
8
F1
NF
F
ON
ON
ON
O
_C
C
T_
T_
T_
ST
OS
OS
OS
O
CH
CH
CH
CH
SL
SL
SL
31 24 23 16 15 8 7
SL 0
SLCHOST_CONF11 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
SLCHOST_CONF10 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF9 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
SLCHOST_CONF8 The information interaction register between Host and Slave. Both Host and Slave
can access it. (R/W)
15
1 4
NF
NF
O
O
_C
_C
)
ed
ed
ST
ST
rv
rv
O
O
CH
CH
se
se
(re
(re
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF15 The information interaction register between Host and Slave. Both Host and
Slave can be read from and written to this. (R/W)
SLCHOST_CONF14 The information interaction register between Host and Slave. Both Host and
Slave can be read from and written to this. (R/W)
8
F1
F
ON
N
CO
C
T_
T_
)
ed
ed
OS
OS
rv
rv
CH
CH
se
se
(re
(re
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF19 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF18 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
26
24
7
F2
F2
NF
F
ON
ON
ON
O
C
_C
C
T_
T_
T_
ST
OS
OS
OS
O
CH
CH
CH
CH
SL
SL
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF27 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF26 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF25 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF24 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
32
4
F3
F3
F
F
ON
ON
ON
ON
C
C
T_
T_
T_
T_
OS
OS
OS
OS
CH
CH
CH
CH
SL
SL
SL
31 24 23 16 15 8 7 SL 0
SLCHOST_CONF35 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF34 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF33 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF32 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
36
9
7
F3
F3
NF
F
ON
ON
ON
CO
C
C
T_
T_
T_
T_
OS
OS
OS
OS
CH
CH
CH
CH
SL
SL
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF39 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF38 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF37 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF36 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
40
2
43
1
F4
F4
NF
F
ON
ON
ON
O
_C
C
T_
T_
T_
ST
OS
OS
OS
O
CH
CH
CH
CH
SL
SL
SL
31 24 23 16 15 8 7 SL 0
SLCHOST_CONF43 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF42 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF41 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF40 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
46
44
47
F4
NF
NF
F
ON
ON
O
O
_C
_C
C
T_
T_
ST
ST
OS
OS
O
O
CH
CH
CH
CH
SL
SL
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF47 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF46 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF45 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF44 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
48
9
51
F5
F4
F
F
ON
ON
ON
ON
C
C
T_
T_
T_
T_
OS
OS
OS
OS
CH
CH
CH
CH
SL
SL
SL
31 24 23 16 15 8 7 SL 0
SLCHOST_CONF51 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF50 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF49 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF48 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
55
52
5 4
F5
NF
NF
F
ON
ON
O
O
_C
_C
C
T_
T_
ST
ST
OS
OS
O
O
CH
CH
CH
CH
SL
SL
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF55 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF54 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF53 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF52 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
56
8
9
7
F5
F5
F5
F
ON
ON
ON
ON
C
C
T_
T_
T_
T_
OS
OS
OS
OS
CH
CH
CH
CH
SL
SL
SL
31 24 23 16 15 8 7 SL 0
SLCHOST_CONF59 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF58 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF57 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF56 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
60
3
62
61
F6
NF
NF
F
ON
ON
CO
O
C
_C
C
T_
T_
T_
ST
OS
OS
OS
O
CH
CH
CH
CH
SL
SL
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF63 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF62 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF61 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
SLCHOST_CONF60 The information interaction register between Host and Slave. Both Host and
Slave can access it. (R/W)
LR
_C
_IN CLR
LR
C0 ST_S 0_TO ST_B _INT LR
R
_IN LR
C0 ST_S 0_TO ST_B _INT R
0_ CLR
INT
_C
C
_C
T_
_
T_
ET_
INT
C0 ST_S 0_TO ST_B _INT
LR
_ IN
F_ CLR
CK
_C
IT5
IT3
IT 7
IT4
HO BIT1
_
INT
PA
BIT
X_ _INT
B
W_
ST_
T_
ST_
F
UD
NE
C0 _OV
HO
HO
HO
HO
HO
HO
X_
C0 ST_S 0_TO
O
_TO
X
_R
_R
ST_ C0_T
ST_ 0_T
C0
LC
LC
LC
LC
LC
LC
LC
SL
L
SL
SL
C0 ST_S
C0 ST_S
ST_
d)
d)
d)
d)
rve
rve
rve
rve
HO
HO
HO
HO
HO
HO
HO
HO
HO
HO
HO
C0
C0
C0
se
se
se
se
(re
(re
(re
(re
SL
SL
SL
SL
SL
SL
SL
SL
SL
SL
SL
31 26 25 24 23 22 18 17 16 15 8 7 6 5 4 3 2 1 0
0x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
NA
_E
_IN NA
_IN ENA
NA
ST_ 1_SL _TOH T_BI INT_ A
0_ ENA
N
INT
EN
C0 ST_F SLC OHO BIT5 NT_E
_E
C0 ST_F SLC OHO BIT4 T_E
C0 ST_F SLC OHO BIT6 T_E
_
BI INT_
T_
T_
NT
INT
A
_IN NA
_IN
EN
KE
_I
_
_
E
AC
T_
T3
C0 ST_F SLC OHO BIT7
HO BIT1
_U INT_
B IT
_P
ST_
ST_
T_
ST_
T_
_
ST_
EW
0_ OVF_
DF
S
OS
_N
H
_
RX
RX
1_S _TO
TO
1_S 0_TX
N1_ 0_T
N1_ 0_T
N1_ 0_T
N1_ 0_T
N1_ 0_T
0_
0
C0
LC
C
LC
C0 ST_F SLC
LC
ST_ 1_SL
1_S
N1_
FN
N
FN
N
FN
C0 ST_F
C0 ST_F
ST_
d)
d)
d)
d)
rve
rve
rve
rve
HO
HO
HO
HO
HO
HO
HO
HO
HO
HO
HO
C0
C0
C0
se
se
se
se
(re
(re
(re
(re
SL
SL
SL
SL
SL
SL
SL
SL
SL
SL
SL
31 26 25 24 23 22 18 17 16 15 8 7 6 5 4 3 2 1 0
0x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
9
1
F2
F3
ON
ON
C
C
T_
T_
)
)
ed
ed
OS
OS
rv
rv
CH
CH
se
se
(re
(re
SL
SL
31 24 23 16 15 8 7 0
SLCHOST_CONF31 The interrupt vector used by Host to interrupt Slave. This bit will not be cleared
automatically. (WO)
SLCHOST_CONF29 The interrupt vector used by Host to interrupt Slave. This bit will not be cleared
automatically. (WO)
P
_E
M
N
20
CO
_S
_S
11
IO
IO
OS
EG
D_
D
_N
_P
EE
_S
_S
SP
RC
RC
RC
RC
H
_F
_F
F
T_
T_
T_
)
)
ed
ed
ST
ST
OS
OS
OS
rv
rv
O
CH
CH
CH
CH
CH
se
se
(re
(re
SL
SL
SL
SL
SL
31 28 27 26 20 19 15 14 10 9 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SLCHOST_HSPEED_CON_EN Set this bit and HINF_HIGHSPEED_ENABLE, then set the EHS (Enable
High-Speed) bit in CCCR at the Host side to output the corresponding signal at the rising clock
edge. (R/W)
SLCHOST_FRC_POS_SAMP Set this bit to sample the corresponding signal at the rising clock edge.
(R/W)
SLCHOST_FRC_NEG_SAMP Set this bit to sample the corresponding signal at the falling clock edge.
(R/W)
SLCHOST_FRC_SDIO20 Set this bit to output the corresponding signal at the rising clock edge.
(R/W)
SLCHOST_FRC_SDIO11 Set this bit to output the corresponding signal at the falling clock edge.
(R/W)
Y1 LE
AD AB
RE N
IO _E
O_ ED
DI PE
_S HS
)
ed
NF IG
HI _H
rv
se
NF
(re
HI
31 3 2 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
9.1 Overview
The ESP32 memory card interface controller provides a hardware interface between the Advanced Peripheral
Bus (APB) and an external memory device. The memory card interface allows the ESP32 to be connected to
SDIO memory cards, MMC cards and devices with a CE-ATA interface. It supports two external cards (Card0
and Card1).
9.2 Features
This module has the following features:
The SD/MMC controller topology is shown in Figure 9-1. The controller supports two peripherals which cannot
be functional at the same time.
• Bus Interface Unit (BIU): It provides APB interfaces for registers, data read and write operation by FIFO and
DMA.
• Card Interface Unit (CIU): It handles external memory card interface protocols. It also provides clock
control.
9.4.1.1 BIU
The BIU provides the access to registers and FIFO data through the Host Interface Unit (HIU). Additionally, it
provides FIFO access to independent data through a DMA interface. The host interface can be configured
as an APB interface. Figure 9-3 illustrates the internal components of the BIU. The BIU provides the following
functions:
• Host interface
• DMA interface
• Interrupt control
• Register access
• FIFO access
9.4.1.2 CIU
The CIU module implements the card-specific protocols. Within the CIU, the command path control unit and
data path control unit prompt the controller to interface with the command and data ports, respectively, of the
SD/MMC/CE-ATA cards. The CIU also provides clock control. Figure 9-3 illustrates the internal structure of the
CIU, which consists of the following primary functional blocks:
• Command path
• Data path
• Clock control
• Mux/demux unit
If the data_expected bit is set in the Command register, the new command is a data-transfer command and the
data path starts one of the following operations:
If no data are received by the data timeout, the data path signals a data timeout to the BIU, which marks an end
to the data transfer. Based on the value of the transfer_mode bit in the Command register, the data-receive
state machine gets data from the card’s data bus in a stream or block(s). The data receive state machine is
shown in Figure 9-6.
• During an open-ended card-write operation, if the card clock is stopped due to FIFO being empty, the
software must fill FIFO with data first, and then start the card clock. Only then can it issue a stop/abort
command to the card.
• During an SDIO/COMBO card transfer, if the card function is suspended and the software wants to resume
the suspended transfer, it must first reset FIFO, and then issue the resume command as if it were a new
data-transfer command.
• When issuing card reset commands (CMD0, CMD15 or CMD52_reset), while a card data transfer is in
progress, the software must set the stop_abort_cmd bit in the Command register, so that the CIU can
stop the data transfer after issuing the card reset command.
• When the data’s end bit error is set in the RINTSTS register, the CIU does not guarantee SDIO interrupts. In
such a case, the software ignores SDIO interrupts and issues a stop/abort command to the card, so that
the card stops sending read-data.
• If the card clock is stopped due to FIFO being full during a card read, the software will read at least two
FIFO locations to restart the card clock.
• Only one CE-ATA device at a time can be selected for a command or data transfer. For example, when
data are transferred from a CE-ATA device, a new command should not be sent to another CE-ATA device.
• If a CE-ATA device’s interrupts are enabled (nIEN=0), a new RW_BLK command should not be sent to the
same device if the execution of a RW_BLK command is already in progress (the RW_BLK command used
in this databook is the RW_MULTIPLE_BLOCK MMC command defined by the CE-ATA specifications). Only
the CCSD can be sent while waiting for the CCS.
• If, however, a CE-ATA device’s interrupts are disabled (nIEN=1), a new command can be issued to the same
device, allowing it to read status information.
• The send_auto_stop signal is not supported (software should not set the send_auto_stop bit) in CE-ATA
transfers.
After configuring the command start bit to 1, the values of the following registers cannot be changed before a
command has been issued:
• CMD - command
• TMOUT - timeout
If SDIO-sending is enabled, data can be written to the transferred RAM module by APB interface or DMA. Data
will be written from register EMAC_FIFO to the CPU, directly, by an APB interface.
When a subunit of the data path receives data, the subdata will be written onto the receive-RAM. Then, these
subdata can be read either with the APB or the DMA method at the reading end. Register EMAC_FIFO can be
read by the APB directly.
The DES2 element contains the address pointer to the data buffer.
The DES3 element contains the address pointer to the next descriptor if the present descriptor is not the last
one in a chained descriptor structure.
Table 9-5. DES3
9.9 Initialization
9.9.1 DMAC Initialization
The DMAC initialization should proceed as follows:
• Write to the DMAC Bus Mode Register (BMOD_REG) will set the Host bus’s access parameters.
• Write to the DMAC Interrupt Enable Register (IDINTEN) will mask any unnecessary interrupt causes.
• The software driver creates either the transmit or the receive descriptor list. Then, it writes to the DMAC
Descriptor List Base Address Register (DBADDR), providing the DMAC with the starting address of the list.
1. The Host sets up the elements (DES0-DES3) for transmission, and sets the OWN bit (DES0[31]). The Host
also prepares the data buffer.
2. The Host programs the write-data command in the CMD register in BIU.
3. The Host also programs the required transmit threshold (TX_WMARK field in FIFOTH register).
4. The DMAC engine fetches the descriptor and checks the OWN bit. If the OWN bit is not set, it means that
the host owns the descriptor. In this case, the DMAC enters a suspend-state and asserts the Descriptor
Unable interrupt in the IDSTS register. In such a case, the host needs to release the DMAC by writing any
value to PLDMND_REG.
5. It then waits for the Command Done (CD) bit and no errors from BIU, which indicates that a transfer can
be done.
6. Subsequently, the DMAC engine waits for a DMA interface request (dw_dma_req) from BIU. This request
will be generated, based on the programmed transmit-threshold value. For the last bytes of data which
cannot be accessed using a burst, single transfers are performed on the AHB Master Interface.
7. The DMAC fetches the transmit data from the data buffer in the Host memory and transfers them to FIFO
for transmission to card.
8. When data span across multiple descriptors, the DMAC fetches the next descriptor and extends its op-
eration using the following descriptor. The last descriptor bit indicates whether the data span multiple
descriptors or not.
9. When data transmission is complete, the status information is updated in the IDSTS register by setting the
Transmit Interrupt, if it has already been enabled. Also, the OWN bit is cleared by the DMAC by performing
a write transaction to DES0.
1. The Host sets up the element (DES0-DES3) for reception, and sets the OWN bit (DES0[31]).
2. The Host programs the read-data command in the CMD register in BIU.
3. Then, the Host programs the required level of the receive-threshold (RX_WMARK field in FIFOTH register).
4. The DMAC engine fetches the descriptor and checks the OWN bit. If the OWN bit is not set, it means that
the host owns the descriptor. In this case, the DMA enters a suspend-state and asserts the Descriptor
Unable interrupt in the IDSTS register. In such a case, the host needs to release the DMAC by writing any
value to PLDMND_REG.
5. It then waits for the Command Done (CD) bit and no errors from BIU, which indicates that a transfer can
be done.
6. The DMAC engine then waits for a DMA interface request (dw_dma_req) from BIU. This request will be
generated, based on the programmed receive-threshold value. For the last bytes of the data which cannot
be accessed using a burst, single transfers are performed on the AHB.
7. The DMAC fetches the data from FIFO and transfers them to the Host memory.
8. When data span across multiple descriptors, the DMAC will fetch the next descriptor and extend its op-
eration using the following descriptor. The last descriptor bit indicates whether the data span multiple
descriptors or not.
9. When data reception is complete, the status information is updated in the IDSTS register by setting
Receive-Interrupt, if it has already been enabled. Also, the OWN bit is cleared by the DMAC by performing
a write-transaction to DES0.
tW(CKH) tW(CKL)
CK
tOV tOH
D, CMD
(output)
tISU tIH
D, CMD
(input)
Legend:
• tW (CKL) /tW (CKH) - Clock Low/High Time: tW (CKL) /tW (CKH) represents the time that the clock signal
(CK) should remain in the low or high state.
• tISU - Input Setup Time in HS Mode: tISU represents the setup time required for CMD and D (data lines)
inputs.
• tIH - Input Hold Time in HS Mode: tIH specifies the hold time required for CMD and D inputs.
• tOV - Output Valid Time in HS Mode: tOV defines the time it takes for the CMD and D outputs to be ready.
• tOH - Output Hold Time in HS Mode: tOH specifies the hold time required for the CMD and D outputs to
be valid.
• The timing of the CMD and D inputs and outputs are measured in relation to the clock signal CK.
Please find detailed information on the clock phase selection register CLK_EDGE_SEL in Section Registers.
9.12 Interrupt
Interrupts can be generated as a result of various events. The IDSTS register contains all the bits that might
cause an interrupt. The IDINTEN register contains an enable bit for each of the events that can cause an
interrupt.
There are two groups of summary interrupts, ”Normal” ones (bit8 NIS) and ”Abnormal” ones (bit9 AIS), as
outlined in the IDSTS register. Interrupts are cleared by writing 1 to the position of the corresponding bit. When
all the enabled interrupts within a group are cleared, the corresponding summary bit is also cleared. When both
summary bits are cleared, the interrupt signal dmac_intr_o is de-asserted (stops signalling).
Interrupts are not queued up, and if a new interrupt-event occurs before the driver has responded to it, no
additional interrupts are generated. For example, the Receive Interrupt IDSTS[1] indicates that one or more data
were transferred to the Host buffer.
An interrupt is generated only once for concurrent events. The driver must scan the IDSTS register for the
interrupt cause.
9.14 Registers
SD/MMC controller registers can be accessed by the APB bus of the CPU.
The addresses in this section are relative to the SD/MMC base address provided in Table 1-6 Peripheral Address
Mapping in Chapter 1 System and Memory.
S
TU
D STA
CS T_
_C UP
SE RT_ SD OP RR
ET
NS
O C ST TE
ES
O
(re _W _R AT
AB D_C TO_ _IN
_R
AD RQ _D
se AI S
N U E
E
SE D_A VIC
ER
RE D_I AD
CO _R ET
RO T
DM rve LE
T
NT ESE
LL
N RE
)
d)
(re EN )
FI _R )
N DE
FO ES
se B
ed
ed
T_ d
A d
A
ve
IN ve
SE A_
rv
rv
r
se
se
se
AT
(re
(re
(re
CE
31 25 24 23 12 11 10 9 8 7 6 5 4 3 2 1 0
CEATA_DEVICE_INTERRUPT_STATUS Software should appropriately write to this bit after the power-
on reset or any other reset to the CE-ATA device. After reset, the CE-ATA device’s interrupt is
usually disabled (nIEN = 1). If the host enables the CE-ATA device’s interrupt, then software
should set this bit. (R/W)
SEND_CCSD When set, SD/MMC sends CCSD to the CE-ATA device. Software sets this bit only if
the current command is expecting CCS (that is, RW_BLK), and if interrupts are enabled for the
CE-ATA device. Once the CCSD pattern is sent to the device, SD/MMC automatically clears the
send_ccsd bit. It also sets the Command Done (CD) bit in the RINTSTS register, and generates
an interrupt for the host, in case the Command Done interrupt is not masked. NOTE: Once the
send_ccsd bit is set, it takes two card clock cycles to drive the CCSD on the CMD line. Due to
this, within the boundary conditions the CCSD may be sent to the CE-ATA device, even if the
device has signalled CCS. (R/W)
SEND_IRQ_RESPONSE Bit automatically clears once response is sent. To wait for MMC card inter-
rupts, host issues CMD40 and waits for interrupt response from MMC card(s). In the meantime,
if host wants SD/MMC to exit waiting for interrupt state, it can set this bit, at which time SD/MMC
command state-machine sends CMD40 response on bus and returns to idle state. (R/W)
DMA_RESET To reset DMA interface, firmware should set bit to 1. This bit is auto-cleared after two
AHB clocks. (R/W)
FIFO_RESET To reset FIFO, firmware should set bit to 1. This bit is auto-cleared after completion
of reset operation. Note: FIFO pointers will be out of reset after 2 cycles of system clocks in
addition to synchronization delay (2 cycles of card clock), after the fifo_reset is cleared. (R/W)
CONTROLLER_RESET To reset controller, firmware should set this bit. This bit is auto-cleared after
two AHB and two cclk_in clock cycles. (R/W)
0
2
3
R1
R
ER
ER
DE
DE
ID
D
VI
VI
VI
V
DI
DI
DI
DI
K_
K_
K_
K_
CL
CL
CL
CL
31 24 23 16 15 8 7 0
CLK_DIVIDER3 Clock divider-3 value. Clock division factor is 2*n, where n=0 bypasses the divider
(division factor of 1). For example, a value of 1 means divide by 2*1 = 2, a value of 0xFF means
divide by 2*255 = 510, and so on. In MMC-Ver3.3-only mode, these bits are not implemented
because only one clock divider is supported. (R/W)
CLK_DIVIDER2 Clock divider-2 value. Clock division factor is 2*n, where n=0 bypasses the divider
(division factor of 1). For example, a value of 1 means divide by 2*1 = 2, a value of 0xFF means
divide by 2*255 = 510, and so on. In MMC-Ver3.3-only mode, these bits are not implemented
because only one clock divider is supported. (R/W)
CLK_DIVIDER1 Clock divider-1 value. Clock division factor is 2*n, where n=0 bypasses the divider
(division factor of 1). For example, a value of 1 means divide by 2*1 = 2, a value of 0xFF means
divide by 2*255 = 510, and so on. In MMC-Ver3.3-only mode, these bits are not implemented
because only one clock divider is supported. (R/W)
CLK_DIVIDER0 Clock divider-0 value. Clock division factor is 2*n, where n=0 bypasses the divider
(division factor of 1). For example, a value of 1 means divide by 2*1 = 2, a value of 0xFF means
divide by 2*255 = 510, and so on. In MMC-Ver3.3-only mode, these bits are not implemented
because only one clock divider is supported. (R/W)
G
RE
)
ed
C_
rv
R
KS
se
(re
CL
31 4 3 0
CLKSRC_REG Clock divider source for two SD cards is supported. Each card has two bits assigned
to it. For example, bit[1:0] are assigned for card 0, bit[3:2] are assigned for card 1. Card 0 maps
and internally routes clock divider[0:3] outputs to cclk_out[1:0] pins, depending on bit value.
00 : Clock divider 0;
01 : Clock divider 1;
10 : Clock divider 2;
11 : Clock divider 3.
In MMC-Ver3.3-only controller, only one clock divider is supported. The cclk_out is always from
clock divider 0, and this register is not implemented. (R/W)
L
BE
NA
)
ed
_E
rv
LK
se
CC
(re
31 2 1 0
CCLK_ENABEL Clock-enable control for two SD card clocks and one MMC card clock is supported.
0: Clock disabled;
1: Clock enabled.
In MMC-Ver3.3-only mode, since there is only one cclk_out, only cclk_enable[0] is used. (R/W)
UT
EO
M
UT
I
_T
EO
SE
M
ON
I
_T
SP
TA
DA
RE
31 8 7 0
DATA_TIMEOUT Value for card data read timeout. This value is also used for data starvation by
host timeout. The timeout counter is started only after the card clock is stopped. This value is
specified in number of card output clocks, i.e. cclk_out of the selected card.
NOTE: The software timer should be used if the timeout value is in the order of 100 ms. In this
case, read data timeout interrupt needs to be disabled. (R/W)
RESPONSE_TIMEOUT Response timeout value. Value is specified in terms of number of card output
clocks, i.e., cclk_out. (R/W)
4
TH
TH
ID
ID
)
)
ed
ed
W
W
rv
rv
D_
D_
se
se
R
R
(re
(re
CA
CA
31 18 17 16 15 2 1 0
CARD_WIDTH4 One bit per card indicates if card is 1-bit or 4-bit mode.
0: 1-bit mode;
1: 4-bit mode.
Bit[1:0] correspond to card[1:0] respectively. Only NUM_CARDS*2 number of bits are imple-
mented. (R/W)
SI
ed
K_
rv
OC
se
(re
BL
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00200 Reset
31 0
0x000000200 Reset
BYTCNT_REG Number of bytes to be transferred, should be an integral multiple of Block Size for
block transfers. For data transfers of undefined byte lengths, byte count should be set to 0.
When byte count is set to 0, it is the responsibility of host to explicitly send stop/abort command
to terminate data transfer. (R/W)
K
AS
_M
)
K
ed
NT
AS
rv
_I
M
se
IO
T_
(re
SD
IN
31 18 17 16 15 0
SDIO_INT_MASK SDIO interrupt mask, one bit for each card. Bit[17:16] correspond to card[15:0]
respectively. When masked, SDIO interrupt detection for that card is disabled. 0 masks an
interrupt, and 1 enables an interrupt. In MMC-Ver3.3-only mode, these bits are always 0. (R/W)
INT_MASK These bits used to mask unwanted interrupts. A value of 0 masks interrupt, and a value
of 1 enables the interrupt. (R/W)
Bit 15 (EBE): End-bit error, read/write (no CRC)
Bit 14 (ACD): Auto command done
Bit 13 (SBE/BCI): Start Bit Error/Busy Clear Interrupt
Bit 12 (HLE): Hardware locked write error
Bit 11 (FRUN): FIFO underrun/overrun error
Bit 10 (HTO): Data starvation-by-host timeout/Volt_switch_int
Bit 9 (DRTO): Data read timeout
Bit 8 (RTO): Response timeout
Bit 7 (DCRC): Data CRC error
Bit 6 (RCRC): Response CRC error
Bit 5 (RXDR): Receive FIFO data request
Bit 4 (TXDR): Transmit FIFO data request
Bit 3 (DTO): Data transfer over
Bit 2 (CD): Command done
Bit 1 (RE): Response error
Bit 0 (CD): Card detect
31 0
0x000000000 Reset
Y
NL
_O
RS
E
ET
TE
_E GT RC
DA D/W _M OP PL
IS
SE EN E_C
ND RV _C ION
CK ICE
EG
A ER ST M
XP H
T
RE NSF TO_ _CO
TR _A DAT MD
EC
_R
LO EV
CH _E ITE DE
SE _P RT AT
ON E_L NS
RE PON ESP D
DA EA ED
AI B LIZ
_C _D
TA R O
S R TE
SP S O
A U A
BE
UP D_C ECT
RE K_ EC
TE TA
W P_A TIA
X
US rve D
UM
(re rve E
DE
T O
se CM
(re _HO )
(re rve )
se d )
(re rve )
CC rve )
RE _EX )
EC P
E d
se d
se L
se d
se d
S d
A P
O NI
X
_N
(re rve
IN
ST _I
(re T_
D_
RD
ND
AR
CM
CA
SE
ST
31 30 29 28 27 26 25 24 23 22 21 20 16 15 14 13 12 11 10 9 8 7 6 5 0
START_CMD Start command. Once command is served by the CIU, this bit is automatically cleared.
When this bit is set, host should not attempt to write to any command registers. If a write is
attempted, hardware lock error is set in raw interrupt register. Once command is sent and a
response is received from SD_MMC_CEATA cards, Command Done bit is set in the raw interrupt
Register. (R/W)
USE_HOLE Use Hold Register. (R/W) 0: CMD and DATA sent to card bypassing HOLD Register; 1:
CMD and DATA sent to card through the HOLD Register.
UPDATE_CLOCK_REGISTERS_ONLY (R/W)
0: Normal command sequence.
1: Do not send commands, just update clock register value into card clock domain
Following register values are transferred into card clock domain: CLKDIV, CLRSRC, and CLKENA.
Changes card clocks (change frequency, truncate off or on, and set low-frequency mode). This
is provided in order to change clock frequency or stop clock without having to send command
to cards.
During normal command sequence, when update_clock_registers_only = 0, following control
registers are transferred from BIU to CIU: CMD, CMDARG, TMOUT, CTYPE, BLKSIZ, and BYTCNT.
CIU uses new register values for new command sequence to card(s). When bit is set, there are
no Command Done interrupts because no command is sent to SD_MMC_CEATA cards.
CARD_NUMBER Card number in use. Represents physical slot number of card being accessed. In
MMC-Ver3.3-only mode, up to two cards are supported. In SD-only mode, up to two cards are
supported. (R/W)
SEND_INITIALIZATION (R/W)
0: Do not send initialization sequence (80 clocks of 1) before sending this command.
1: Send initialization sequence before sending this command.
After power on, 80 clocks must be sent to card for initialization before sending any commands
to card. Bit should be set while sending first command to card so that controller will initialize
clocks before sending command to card.
STOP_ABORT_CMD (R/W)
0: Neither stop nor abort command can stop current data transfer. If abort is sent to function-
number currently selected or not in data-transfer mode, then bit should be set to 0.
1: Stop or abort command intended to stop current data transfer in progress. When open-ended
or predefined data transfer is in progress, and host issues stop or abort command to stop data
transfer, bit should be set so that command/data state-machines of CIU can return correctly to
idle state.
WAIT_PRVDATA_COMPLETE (R/W)
0: Send command at once, even if previous data transfer has not completed;
1: Wait for previous data transfer to complete before sending Command.
The wait_prvdata_complete = 0 option is typically used to query status of card during data trans-
fer or to stop current data transfer. card_number should be same as in previous command.
SEND_AUTO_STOP (R/W)
0: No stop command is sent at the end of data transfer;
1: Send stop command at the end of data transfer.
TRANSFER_MODE (R/W)
0: Block data transfer command;
1: Stream data transfer command. Don’t care if no data expected.
READ/WRITE (R/W)
0: Read from card;
1: Write to card.
Don’t care if no data is expected from card.
DATA_EXPECTED (R/W)
0: No data transfer expected.
1: Data transfer expected.
CHECK_RESPONSE_CRC (R/W)
0: Do not check;
1: Check response CRC.
Some of command responses do not return valid CRC bits. Software should disable CRC checks
for those commands in order to disable CRC checking by controller.
RESPONSE_LENGTH (R/W)
0: Short response expected from card;
1: Long response expected from card.
RESPONSE_EXPECT (R/W)
0: No response expected from card;
1: Response expected from card.
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
SK
PT
_M
RU
ER
US
)
ed
NT
AT
rv
ST
_I
se
IO
T_
(re
SD
IN
31 18 17 16 15 0
SDIO_INTERRUPT_MSK Interrupt from SDIO card, one bit for each card. Bit[17:16] correspond
to card1 and card0, respectively. SDIO interrupt for card is enabled only if corresponding
sdio_int_mask bit is set in Interrupt mask register (Setting mask bit enables interrupt). (RO)
INT_STATUS_MSK Interrupt enabled only if corresponding bit in interrupt mask register is set. (RO)
Bit 15 (EBE): End-bit error, read/write (no CRC)
Bit 14 (ACD): Auto command done
Bit 13 (SBE/BCI): Start Bit Error/Busy Clear Interrupt
Bit 12 (HLE): Hardware locked write error
Bit 11 (FRUN): FIFO underrun/overrun error
Bit 10 (HTO): Data starvation by host timeout (HTO)
Bit 9 (DTRO): Data read timeout
Bit 8 (RTO): Response timeout
Bit 7 (DCRC): Data CRC error
Bit 6 (RCRC): Response CRC error
Bit 5 (RXDR): Receive FIFO data request
Bit 4 (TXDR): Transmit FIFO data request
Bit 3 (DTO): Data transfer over
Bit 2 (CD): Command done
Bit 1 (RE): Response error
Bit 0 (CD): Card detect
AW
_R
AW
PT
RU
_R
ER
US
)
ed
NT
AT
rv
ST
_I
se
IO
T_
(re
SD
IN
31 18 17 16 15 0
SDIO_INTERRUPT_RAW Interrupt from SDIO card, one bit for each card. Bit[17:16] correspond to
card1 and card0, respectively. Setting a bit clears the corresponding interrupt bit and writing 0
has no effect. (R/W)
0: No SDIO interrupt from card;
1: SDIO interrupt from card.
In MMC-Ver3.3-only mode, these bits are always 0. Bits are logged regardless of interrupt-mask
status. (R/W)
INT_STATUS_RAW Setting a bit clears the corresponding interrupt and writing 0 has no effect. Bits
are logged regardless of interrupt mask status. (R/W)
Bit 15 (EBE): End-bit error, read/write (no CRC)
Bit 14 (ACD): Auto command done
Bit 13 (SBE/BCI): Start Bit Error/Busy Clear Interrupt
Bit 12 (HLE): Hardware locked write error
Bit 11 (FRUN): FIFO underrun/overrun error
Bit 10 (HTO): Data starvation by host timeout (HTO)
Bit 9 (DTRO): Data read timeout
Bit 8 (RTO): Response timeout
Bit 7 (DCRC): Data CRC error
Bit 6 (RCRC): Response CRC error
Bit 5 (RXDR): Receive FIFO data request
Bit 4 (TXDR): Transmit FIFO data request
Bit 3 (DTO): Data transfer over
Bit 2 (CD): Command done
Bit 1 (RE): Response error
Bit 0 (CD): Card detect
S
TE
SY
K
ER RK
TA
BU
AR
_S
AT A
X
_3 Y C_
M
W RM
E
M
S
ND
TA US M
TU
FS
X_ TE
DA _B TE_
T
_I
FI _TX TY
TA
D_
_R WA
UN
SE
FI _EM L
se d)
P
_S
TA TA
FO L
ed
AN
FO _
O
FI _FU
ON
(re rve
DA _S
_C
rv
M
SP
se
M
TA
FO
FO
FO
CO
(re
DA
RE
FI
FI
31 30 29 17 16 11 10 9 8 7 4 3 2 1 0
RESPONSE_INDEX Index of previous response, including any auto-stop sent by core. (RO)
FIFO_TX_WATERMARK FIFO reached Transmit watermark level, not qualified with data transfer. (RO)
FIFO_RX_WATERMARK FIFO reached Receive watermark level, not qualified with data transfer. (RO)
IZE
_S
ON
I
CT
SA
AN
TR
E_
PL
TI
K
UL
d)
d)
AR
AR
ed
ve
ve
M
M
rv
A_
r
r
_W
_W
se
se
se
DM
(re
(re
(re
RX
TX
31 30 28 27 26 16 15 12 11 0
RX_WMARK FIFO threshold watermark level when receiving data to card.When FIFO data count
reaches greater than this number (FIFO_RX_WATERMARK), DMA/FIFO request is raised. During
end of packet, request is generated regardless of threshold programming in order to complete
any remaining data.In non-DMA mode, when receiver FIFO threshold (RXDR) interrupt is enabled,
then interrupt is generated instead of DMA request.During end of packet, interrupt is not gen-
erated if threshold programming is larger than any remaining data. It is responsibility of host to
read remaining bytes on seeing Data Transfer Done interrupt.In DMA mode, at end of packet,
even if remaining bytes are less than threshold, DMA request does single transfers to flush out
any remaining bytes before Data Transfer Done interrupt is set. (R/W)
TX_WMARK FIFO threshold watermark level when transmitting data to card. When FIFO data count
is less than or equal to this number (FIFO_TX_WATERMARK), DMA/FIFO request is raised. If In-
terrupt is enabled, then interrupt occurs. During end of packet, request or interrupt is generated,
regardless of threshold programming.In non-DMA mode, when transmit FIFO threshold (TXDR)
interrupt is enabled, then interrupt is generated instead of DMA request. During end of packet,
on last interrupt, host is responsible for filling FIFO with only required remaining bytes (not be-
fore FIFO is full or after CIU completes data transfers, because FIFO may not be empty). In DMA
mode, at end of packet, if last transfer is less than burst size, DMA controller does single cycles
until required bytes are transferred. (R/W)
_N
CT
TE
)
ed
DE
rv
D_
se
R
(re
CA
31 2 1 0
CARD_DETECT_N Value on card_detect_n input ports (1 bit per card), read-only bits.0 represents
presence of card. Only NUM_CARDS number of bits are implemented. (RO)
T
EC
OT
)
PR
ed
_
rv
TE
se
RI
(re
W
31 2 1 0
WRITE_PROTECT Value on card_write_prt input ports (1 bit per card).1 represents write protection.
Only NUM_CARDS number of bits are implemented. (RO)
31 0
0x000000000 Reset
31 0
0x000000000 Reset
TBBCNT_REG Number of bytes transferred between Host/DMA memory and BIU FIFO. (RO)
NT
OU
_C
CE
)
ed
UN
rv
BO
se
(re
DE
31 24 23 0
0 0 0 0 0 0 0 0 0x0000000 Reset
DEBOUNCE_COUNT Number of host clocks (clk) used by debounce filter logic. The typical de-
bounce time is 5 ~ 25 ms to prevent the card instability when the card is inserted or removed.
(R/W)
31 0
0x000000000 Reset
USRID_REG User identification register, value set by user. Default reset value can be picked by
user while configuring core before synthesis. Can also be used as a scratchpad register by user.
(R/W)
ET
ES
_R
)
RD
ed
CA
rv
se
T_
(re
RS
31 2 1 0
0 0x1 Reset
RST_CARD_RESET Hardware reset.1: Active mode; 0: Reset. These bits cause the cards to enter
pre-idle state, which requires them to be re-initialized. CARD_RESET[0] should be set to 1’b0 to
reset card0, CARD_RESET[1] should be set to 1’b0 to reset card1.The number of bits implemented
is restricted to NUM_CARDS. (R/W)
R
BL
W
)
)
E
OD FB
ed
ed
_D
_P
_S
BM D_
rv
rv
OD
OD
se
se
O
BM
BM
BM
(re
(re
31 11 10 8 7 6 2 1 0
BMOD_PBL Programmable Burst Length. These bits indicate the maximum number of beats to be
performed in one IDMAC transaction. The IDMAC will always attempt to burst as specified in PBL
each time it starts a burst transfer on the host bus. The permissible values are 1, 4, 8, 16, 32, 64,
128 and 256. This value is the mirror of MSIZE of FIFOTH register. In order to change this value,
write the required value to FIFOTH register. This is an encode value as follows:
000: 1-byte transfer; 001: 4-byte transfer; 010: 8-byte transfer; 011: 16-byte transfer; 100: 32-
byte transfer; 101: 64-byte transfer; 110: 128-byte transfer; 111: 256-byte transfer.
PBL is a read-only value and is applicable only for data access, it does not apply to descriptor
access. (R/W)
BMOD_FB Fixed Burst. Controls whether the AHB Master interface performs fixed burst transfers
or not. When set, the AHB will use only SINGLE, INCR4, INCR8 or INCR16 during start of normal
burst transfers. When reset, the AHB will use SINGLE and INCR burst transfer operations. (R/W)
BMOD_SWR Software Reset. When set, the DMA Controller resets all its internal registers. It is
automatically cleared after one clock cycle. (R/W)
31 0
0x000000000 Reset
PLDMND_REG Poll Demand. If the OWN bit of a descriptor is not set, the FSM goes to the Suspend
state. The host needs to write any value into this register for the IDMAC FSM to resume normal
descriptor fetch operation. This is a write only register, PD bit is write-only. (WO)
31 0
0x000000000 Reset
DBADDR_REG Start of Descriptor List. Contains the base address of the First Descriptor. The LSB
bits [1:0] are ignored and taken as all-zero by the IDMAC internally. Hence these LSB bits may
be treated as read-only. (R/W)
E
OD
_C
M
(re S_ S
BE
ID S_ E
(re NIS
)
S_ S
ID S_ )
s e DU
ST FB
ST CE
FS
ed
ed
ST d
ST AI
ST RI
TI
F
ID rve
S_
S_
ID S_
ID S_
S_
rv
rv
se
se
ST
ST
ST
ST
(re
ID
ID
ID
ID
31 17 16 13 12 10 9 8 7 6 5 4 3 2 1 0
IDSTS_FBE_CODE Fatal Bus Error Code. Indicates the type of error that caused a Bus Error. Valid
only when the Fatal Bus Error bit IDSTS[2] is set. This field does not generate an interrupt. (RO)
3b001: Host Abort received during transmission;
3b010: Host Abort received during reception;
Others: Reserved.
IDSTS_AIS Abnormal Interrupt Summary. Logical OR of the following: IDSTS[2] : Fatal Bus Interrupt,
IDSTS[4] : DU bit Interrupt. Only unmasked bits affect this bit. This is a sticky bit and must be
cleared each time a corresponding bit that causes AIS to be set is cleared. Writing 1 clears this
bit. (R/W)
IDSTS_NIS Normal Interrupt Summary. Logical OR of the following: IDSTS[0] : Transmit Interrupt,
IDSTS[1] : Receive Interrupt. Only unmasked bits affect this bit. This is a sticky bit and must be
cleared each time a corresponding bit that causes NIS to be set is cleared. Writing 1 clears this
bit. (R/W)
IDSTS_CES Card Error Summary. Indicates the status of the transaction to/from the card, also
present in RINTSTS. Indicates the logical OR of the following bits: EBE : End Bit Error, RTO :
Response Timeout/Boot Ack Timeout, RCRC : Response CRC, SBE : Start Bit Error, DRTO : Data
Read Timeout/BDS timeout, DCRC : Data CRC for Receive, RE : Response Error.
Writing 1 clears this bit. The abort condition of the IDMAC depends on the setting of this CES
bit. If the CES bit is enabled, then the IDMAC aborts on a response error. (R/W)
IDSTS_DU Descriptor Unavailable Interrupt. This bit is set when the descriptor is unavailable due to
OWN bit = 0 (DES0[31] =0). Writing 1 clears this bit. (R/W)
IDSTS_FBE Fatal Bus Error Interrupt. Indicates that a Bus Error occurred (IDSTS[12:10]) . When this
bit is set, the DMA disables all its bus accesses. Writing 1 clears this bit. (R/W)
IDSTS_RI Receive Interrupt. Indicates the completion of data reception for a descriptor. Writing 1
clears this bit. (R/W)
IDSTS_TI Transmit Interrupt. Indicates that data transmission is finished for a descriptor. Writing 1
clears this bit. (R/W)
ID TEN FBE
ID rve DU
I
TE AI
TE RI
TI
(re N_N
)
ID TEN )
ed
ed
IN d
IN _
IN _
se _
IN _
IN _
N_
ID TEN
ID TEN
rv
rv
se
se
N
IN
(re
I
ID
ID
31 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
IDINTEN_CES Card Error summary Interrupt Enable. When set, it enables the Card Interrupt sum-
mary. (R/W)
IDINTEN_DU Descriptor Unavailable Interrupt. When set along with Abnormal Interrupt Summary
Enable, the DU interrupt is enabled. (R/W)
IDINTEN_FBE Fatal Bus Error Enable. When set with Abnormal Interrupt Summary Enable, the Fatal
Bus Error Interrupt is enabled. When reset, Fatal Bus Error Enable Interrupt is disabled. (R/W)
IDINTEN_RI Receive Interrupt Enable. When set with Normal Interrupt Summary Enable, Receive
Interrupt is enabled. When reset, Receive Interrupt is disabled. (R/W)
IDINTEN_TI Transmit Interrupt Enable. When set with Normal Interrupt Summary Enable, Transmit
Interrupt is enabled. When reset, Transmit Interrupt is disabled. (R/W)
31 0
0x000000000 Reset
DSCADDR_REG Host Descriptor Address Pointer, updated by IDMAC during operation and cleared
on reset. This register points to the start address of the current descriptor read by the IDMAC.
(RO)
31 0
0x000000000 Reset
BUFADDR_REG Host Buffer Address Pointer, updated by IDMAC during operation and cleared on
reset. This register points to the current Data Buffer Address being accessed by the IDMAC.
(RO)
EL
L
E
SE
_S
S
V_
F_
DR
SA
L
_N
_S
L
E_
E_
E_
E
GE
GE
DG
DG
DG
DG
ED
ED
)
_E
_E
_E
_E
ed
N_
N_
IN
IN
IN
IN
rv
I
LK
LK
LK
LK
LK
LK
se
CC
CC
CC
CC
CC
CC
(re
31 21 20 17 16 13 12 9 8 6 5 3 2 0
CCLKIN_EDGE_L The low level of the divider clock. The value should be larger than
CCLKIN_EDGE_H. (R/W)
CCLKIN_EDGE_H The high level of the divider clock. The value should be smaller than
CCLKIN_EDGE_L. (R/W)
CCLKIN_EDGE_SLF_SEL It is used to select the clock phase of the internal signal from phase90,
phase180, or phase270. (R/W)
CCLKIN_EDGE_SAM_SEL It is used to select the clock phase of the input signal from phase90,
phase180, or phase270. (R/W)
CCLKIN_EDGE_DRV_SEL It is used to select the clock phase of the output signal from phase90,
phase180, or phase270. (R/W)
10.1 Overview
Features of Ethernet
By using the external Ethernet PHY (physical layer), ESP32 can send and receive data via Ethernet MAC (Media
Access Controller) according to the IEEE 802.3 standard, as Figure 10-1 shows. Ethernet is currently the most
commonly used network protocol that controls how data is transmitted over local- and wide-area networks,
abbreviated as LAN and WAN, respectively.
• Two industry-standard interfaces conforming with IEEE 802.3-2002: Media-Independent Interface (MII)
and Reduced Media-Independent Interface (RMII).
• Support for a data transmission rate of 10 Mbit/s or 100 Mbit/s through an external PHY interface
• Communication with an external Fast Ethernet PHY through IEEE 802.3-compliant MII and RMII interfaces
• Support for:
– Carrier Sense Multiple Access / Collision Detection (CSMA/CD) protocol in half-duplex mode
– operations in full-duplex mode, forwarding the received pause-control frame to the user application
– If the flow control input signal disappears during a full-duplex operation, a pause frame with zero
pause time value is automatically transmitted.
• The Preamble and the Start Frame Delimiter (SFD) are inserted in the Transmit path, and deleted in the
Receive path.
• Cyclic Redundancy Check (CRC) and Pad can be controlled on a per-frame basis.
• The Pad is generated automatically, if data is below the minimum frame length.
– All frames in mixed mode can be transmitted without being filtered for network monitoring
– A status report is attached each time all incoming packets are transmitted and filtered
• Use of the Management Data Input/Output (MDIO) interface to configure and manage PHY devices
• Support for the offloading of received IPv4 and TCP packets encapsulated by an Ethernet frame in the
reception function
• Support for checking IPv4 header checksums, as well as TCP, UDP, or ICMP (Internet Control Message
Protocol) checksums encapsulated in IPv4/IPv6 packets in the enhanced reception function
• Two sets of FIFOs: one 2 KB Tx FIFO with programmable threshold and one 2 KB Rx FIFO with configurable
threshold (64 bytes by default)
• When Rx FIFO stores multiple frames, the Receive Status Vector is inserted into the Rx FIFO after trans-
mitting an EOF (end of frame), so that the Rx FIFO does not need to store the Receive Status of these
frames.
• In store-and-forward mode, all error frames can be filtered during reception, but not forwarded to the
application.
• Support for data statistics by generating pulses for lost or corrupted frames in the Rx FIFO due to an
overflow
• Support for store-and-forward mechanism when transmitting data to the MAC core
• Automatic re-transmission of collided frames during transmission (subject to certain conditions, see sec-
tion 10.2.1.2)
• Discarding frames in cases of late collisions, excessive collisions, excessive deferrals, and under-run con-
ditions
• Calculating the IPv4 header checksum, as well as the TCP, UDP, or ICMP checksum, and then inserting
them into frames transmitted in store-and-forward mode.
Ethernet MAC consists of the MAC-layer configuration register module and three layers: EMAC_CORE (MAC Core
Layer), EMAC_MTL (MAC Transition Layer), and EMAC_DMA (Direct Memory Access). Each of these three layers
has two directions: Tx and Rx. They are connected to the system through the Advanced High-Performance Bus
(AHB) and the Advanced Peripheral Bus (APB) on the chip. Off the chip, they communicate with the external
PHY through the MII and RMII interfaces to establish an Ethernet connection.
10.2 EMAC_CORE
The MAC supports many interfaces with the PHY chip. The PHY interface can be selected only once after reset.
The MAC communicates with the application side (DMA side), using the MAC Transmit Interface (MTI), MAC
Receive Interface (MRI) and the MAC Control Interface (MCI).
After the EOF (end of frame) is transmitted to the MAC, the MAC completes the normal transmission and yields
the Transmit Status to the MTL. If a normal collision (in half-duplex mode) occurs during transmission, the MAC
makes valid the Transmit Status in the MTL. It then accepts and drops all further data until the next SOF is
received. The MTL block should retransmit the same frame from SOF upon observing a retry request (in the
Status) from the MAC.
The MAC issues an underflow status if the MTL is not able to provide the data continuously during transmission.
During the normal transmission of a frame from MTL, if the MAC receives an SOF without getting an EOF for the
previous frame, it ignores the SOF and considers the new frame as a continuation of the previous one.
When the application sets the Flow Control Busy bit (FCB bit in the Flow Control Register) to 1, or when the Rx
FIFO is full, a pause frame is transmitted.
• If an application has requested flow control by setting the FCB bit in the Flow Control Register to 1, the MAC
will generate and send a single pause frame. The pause time value in the generated frame is the pause
time value programmed in the Flow Control Register. To extend or end the pause time before the time
specified in the previously transmitted pause frame, the application program must configure the pause
time value in the Flow Control Register to the appropriate value and, then, request another pause frame
transmission.
• If the application has requested flow control when the Rx FIFO is full, the MAC will generate and transmit a
pause frame. The value of the pause time of the generated frame is the pause time value programmed in
the Flow Control Register. If the Rx FIFO remains full during the configurable interval, which is determined
by the Pause Low Threshold bit (PLT) in the Flow Control Register before the pause time expires, a second
pause frame will be transmitted. As long as the Rx FIFO remains full, the process repeats itself. If the FIFO
is no longer full before the sample time, the MAC will send a pause frame with zero pause time, indicating
to the remote end that the Rx buffer is ready to receive the new data frame.
The MAC transmitter may abort the transmission of a frame because of collision, Tx FIFO underflow, loss of
carrier, jabber timeout, no carrier, excessive deferral, and late collision. When frame transmission is aborted
because of collision, the MAC requests retransmission of the frame.
The frame received by the MAC will be pushed into the Rx FIFO. Once the FIFO status exceeds the Receive
Threshold, configured by the Receive Threshold Control (RTC) bit in the Operation Mode register, the DMA can
initiate a preconfigured burst transmission to the AHB interface.
In the default pass-through mode, when the FIFO receives a complete packet or 64 bytes configured by the
RTC bit in the Operation Mode Register, the data pops up and its availability is notified to the DMA. After the DMA
initiates the transmission to the AHB interface, the data transmission continues from the FIFO until the complete
packet is transmitted. Upon completing transmitting the EOF, the status word will pop up and be transmitted to
the DMA controller.
In the Rx FIFO Store-and-Forward mode (configured through the RSF or Receive Store and Forward bit in the
Operation Mode Register), only the valid frames are read and forwarded to the application. In the passthrough
mode, error frames are not discarded because the error status is received at the end of the frame. The start of
frame will have been read from the FIFO at that point.
If the received frame length/type is less than 0x600 and the automatic CRC/Pad removal option is programmed
for the MAC, the MAC will send frame data to the Rx FIFO (the amount of data does not exceed the number
specified in the length/type field). Then MAC begins discarding the remaining section, including the FCS field.
If the frame length/type is greater than, or equal to, 0x600, the MAC will send all received Ethernet frame data
to the Rx FIFO, regardless of the programmed value of the automatic CRC removal option. By default, the MAC
watchdog timer is enabled, meaning that frames, including DA, SA, LT, data, pad and FCS, which exceed 2048
bytes, are cut off. This function can be disabled by programming the Watchdog Disable (WD) bit in the MAC
Configuration Register. However, even if the watchdog timer is disabled, frames longer than 16 KB will be cut
off and the watchdog timeout status will be given.
The MAC will also decode the type, the opcode, and the pause timer field of the Receive Control Frame. If
the value of the status byte counter is 64 bits and there are no CRC errors, the MAC transmitter will halt the
transmission of any data frame. The duration of the pause is the decoded pause time value multiplied by the
interval (which is 64 bytes for both 10 Mbit/s and 100 Mb/s modes). At the same time, if another pause frame
of zero pause time is detected, the MAC will reset the pause time to manage the new pause request.
If the type field (0x8808), the opcode (0x00001), and the byte length (64 bytes) of the received control frame
are not 0x8808, 0x00001, and 64 bytes, respectively, or if there is a CRC error, the MAC will not generate a
pause.
If a pause frame has a multicast destination address, the MAC filters the frame, according to the address match-
ing.
For pause frames with a unicast destination address, the MAC checks whether the DA matches the content of
the EMACADDR0 Register, and whether the Unicast Pause Frame Detect (UPFD) bit in the Flow Control Register
is set to 1. The Pass Control Frames (PCF) bits in the Frame Filter Register [7:6] control the filtering of frames
and addresses.
If the function that corresponds to the Flush Transmit FIFO (FTF) bit and the Forward Undersized Good Frames
(FUGF) bit in the Operation Mode Register is enabled, the Rx FIFO can filter error frames and runt frames.
If the receive FIFO is configured to operate in store-and-forward mode, all error frames will be filtered and
discarded.
In passthrough mode, if a frame’s status and length are available when reading a SOF from the Rx FIFO, the entire
error frame can be discarded. DMA can clear the error frame being read from the FIFO by enabling the Receive
Frame Clear bit. The data transmission to the application (DMA) will then stop, and the remaining frames will be
read internally and discarded. If FIFO is available, the transmission of the next frame will be initiated.
The interrupt register bits only indicate various interrupt events. To clear the interrupts, the corresponding status
register and other registers must be read. An Interrupt Status Register describes the events that prompt the MAC
core to generate interrupts. Each interrupt event can be prevented by setting the corresponding mask bit in
the Interrupt Mask Register to 1. For example, if bit3 of the interrupt register is set high, it indicates that a magic
packet or Wake-on-LAN frame has been received in Power-down mode. The PMT Control and Status register
must be read to clear this interrupt event.
Physical (MAC) addresses are used for address checking during address filtering.
In perfect filtering mode, the multicast address is compared with the programmed MAC Destination Address
Registers (EMACADDR0 ~ EMACADDR7). Group address filtering is also supported.
When the SAF enable bit is set to 1, the result of the SA filtering and DA filtering is AND’ed to determine whether
or not to forward the frame. Any frame that fails to pass will be discarded. Frames need to pass both filterings
in order to be forwarded to the application.
The following two tables summarize the destination address and source address filtering, based on the type of
the frames received.
The filtering parameters in the MAC Frame Filter Register described in Table 10-1 are as follows.
The filtering parameters in the MAC Frame Filter Register described in Table 10-2 are as follows.
• Jabber timeout
• Late collision
• Frame underflow
• Excessive deferral
• Excessive collision
The received frames are considered ”good frames”, if there are not any of the following errors:
• CRC error
• Frame size over the maximum size (for non-type frames over the maximum frame size only)�
For details please refer to Register Summary and Linked List Descriptors.
• MII_TX_CLK: TX clock signal. This signal provides the reference timing for TX data transmission. The
frequencies are divided into two types: 2.5 MHz at a data transmission rate of 10 Mbit/s, and 25 MHz at
100 Mbit/s.
• MII_TXD[3:0]: Transmit data signal in groups of four, syn-driven by the MAC sub-layer, and valid only
when the MII_TX_EN signal is valid. MII_TXD[0] is the lowest significant bit and MII_TXD[3] is the highest
significant bit. When the signal MII_TX_EN is pulled low, sending data does not have any effect on the
PHY.
• MII_TX_EN: Transmit data enable signal. This signal indicates that the MAC is currently sending nibbles
(4 bits) for the MII. This signal must be synchronized with the first nibble of the header (MII_TX_CLK) and
must be synchronized when all nibbles to be transmitted are sent to the MII.
• MII_RX_CLK: RX clock signal. This signal provides the reference timing for RX data transmission. The
frequencies are divided into two types: 2.5 MHz at the data transmission rate of 10 Mbit/s, and 25 MHz
at 100 Mbit/s.
• MII_RXD[3:0]: Receive data signal in groups of four, syn-driven by the PHY, and valid only when MII_RX_DV
signal is valid. MII_RXD[0] is the lowest significant bit and MII_RXD[3] is the highest significant bit. When
MII_RX_DV is disabled and MII_RX_ER is enabled, the specific MII_RXD[3:0] value represents specific
information from the PHY.
• MII_RX_DV: Receive data valid signal. This signal indicates that the PHY is currently receiving the recov-
ered and decoded nibble that will be transmitted to the MII. This signal must be synchronized with the first
nibble of the recovered frame (MII_RX_CLK) and remain synchronized till the last nibble of the recovered
frame. This signal must be disabled before the first clock cycle following the last nibble. In order to re-
ceive the frame correctly, the MII_RX_DV signal must cover the frame to be received over the time range,
starting no later than when the SFD field appears.
• MII_CRS: Carrier sense signal. When the transmitting or receiving medium is in the non-idle state, the
signal is enabled by the PHY. When the transmitting or receiving medium is in the idle state, the signal
is disabled by the PHY. The PHY must ensure that the MII_CRS signal remains valid under conflicting
conditions. This signal does not need to be synchronized with the TX and RX clocks. In full-duplex mode,
this signal is insignificant.
• MII_COL: Collision detection signal. After a collision is detected on the medium, the PHY must immediately
enable the collision detection signal, and the collision detection signal must remain active as long as a
condition for collision exists. This signal does not need to be synchronized with the TX and RX clocks. In
full-duplex mode, this signal is meaningless.
• MII_RX_ER: Receive error signal. The signal must remain for one or more cycles (MII_RX_CLK) to indicate
to the MAC sublayer that an error has been detected somewhere in the frame.
• MDIO and MDC: Management Data Input/Output and Management Data Clock. The two signals constitute
a serial bus defined for the Ethernet family of IEEE 802.3 standards, used to transfer control and data
information to the PHY, see section Station Management Agent (SMA) Interface.
• The same reference clock must be provided to the MAC and the external Ethernet PHY. The PHY provides
independent 2-bit-wide TX and RX data paths.
• Note: If Wi-Fi and Ethernet are used simultaneously, the RMII clock cannot be generated by the internal
APLL clock, as it would result in clock instability. In this case, please use an external PHY or external clock
source to provide the reference clock.
Please refer to Register Summary for details about the EMII Address Register and the EMII Data Register.
Reserved
OWN
Ctrl/status Status
TDES0 Ctrl[30:26] Ctrl[24:18] Status[16:7] [6:3] [2:0]
Ctrl
TDES1 [31:29] Reserved Transmit Buffer Size[12:0]
TDES4 Reserved
TDES5 Reserved
TDES6 Reserved
TDES7 Reserved
31 0
OWN
RDES0 Status[30:0]
Ctrl
Res
Ctrl
RDES1 Reserved[30:16] [15:14] Receive Buffer 1 Size[12:0]
RDES5 Reserved
RDES6 Reserved
RDES7 Reserved
• Latched-low (LL)
• Latched-high (LH)
10.10 Registers
The addresses in parenthesis besides register names are the register addresses relative to the EMAC base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 10.9 Register Summary.
Note: The value of all reset registers must be set to the reset value.
EN
US 8_M LIB T
E_ O EA
A S
EN
_L
ZE
CH
LX DR R
L
SE DE
ST
RA ST
PB AD DBU
_L
PB
ST _S
PB
_S
IP
UR
R
O
P_
)
_R RB
SC
A_
PR BU
ed
K
A E
TI
_B
_S
X
SW _A
DE
M
rv
D_
DM MI
OG
SC
_D
se
A
I_
T_
A
XE
DM
DM
(re
DE
PR
RX
AL
FI
31 27 26 25 24 23 22 17 16 15 14 13 8 7 6 2 1 0
DMAMIXEDBURST When this bit is set high and the FB(FIXES_BURST) bit is low, the AHB master
interface starts all bursts of a length more than 16 with INCR (undefined burst), whereas it reverts
to fixed burst transfers (INCRx and SINGLE) for burst length of 16 and less. (R/W)
DMAADDRALIBEA When this bit is set high and the FB bit is 1, the AHB interface generates all bursts
aligned to the start address LS bits. If the FB bit is 0, the first burst (accessing the start address
of data buffer) is not aligned, but subsequent bursts are aligned to the address. (R/W)
PBLX8_MODE When set high, this bit multiplies the programmed PBL(PROG_BURST_LEN) value
(Bits[22:17] and Bits[13:8]) eight times. Therefore, the DMA transfers the data in 8, 16, 32, 64,
128, and 256 beats depending on the PBL value. (R/W)
USE_SEP_PBL When set high, this bit configures the Rx DMA to use the value configured in
Bits[22:17] as PBL. The PBL value in Bits[13:8] is applicable only to the Tx DMA operations. When
reset to low, the PBL value in Bits[13:8] is applicable for both DMA engines. (R/W)
RX_DMA_PBL This field indicates the maximum number of beats to be transferred in one Rx DMA
transaction. This is the maximum value that is used in a single block Read or Write.The Rx
DMA always attempts to burst as specified in the RPBL(RX_DMA_PBL) bit each time it starts
a burst transfer on the host bus. You can program RPBL with values of 1, 2, 4, 8, 16, and
32. Any other value results in undefined behavior. This field is valid and applicable only when
USP(USE_SEP_PBL) is set high. (R/W)
FIXED_BURST This bit controls whether the AHB master interface performs fixed burst transfers or
not. When set, the AHB interface uses only SINGLE, INCR4, INCR8, or INCR16 during start of
the normal burst transfers. When reset, the AHB interface uses SINGLE and INCR burst transfer
operations. (R/W)
PRI_RATIO These bits control the priority ratio in the weighted round-robin arbitration between the
Rx DMA and Tx DMA. These bits are valid only when Bit 1 (DA) is reset. The priority ratio Rx:Tx
represented by each bit: (R/W)
• 2’b00 — 1: 1
• 2’b01 — 2: 0
• 2’b10 — 3: 1
• 2’b11 — 4: 1
PROG_BURST_LEN These bits indicate the maximum number of beats to be transferred in one DMA
transaction. If the number of beats to be transferred is more than 32, then perform the following
steps: 1. Set the PBLx8 mode; 2. Set the PBL. (R/W)
ALT_DESC_SIZE When set, the size of the alternate descriptor increases to 32 bytes. (R/W)
DESC_SKIP_LEN This bit specifies the number of Word to skip between two unchained descriptors.
The address skipping starts from the end of current descriptor to the start of next descriptor.
When the DSL(DESC_SKIP_LEN) value is equal to zero, the descriptor table is taken as contigu-
ous by the DMA in Ring mode. (R/W)
DMA_ARB_SCH This bit specifies the arbitration scheme between the transmit and receive paths.
1’b0: weighted round-robin with RX: TX or TX: RX, priority specified in PR (bit[15:14]); 1’b1 Fixed
priority (Rx priority to Tx). (R/W)
SW_RST When this bit is set, the MAC DMA Controller resets the logic and all internal registers of
the MAC. It is cleared automatically after the reset operation is complete in all of the ETH_MAC
clock domains. Before reprogramming any register of the ETH_MAC, you should read a zero (0)
value in this bit. (R/WS/SC)
31 0
0x000000000 Reset
TRANS_POLL_DEMAND When these bits are written with any value, the DMA reads the current
descriptor to which the Register (Current Host Transmit Descriptor Register) is pointing. If that
descriptor is not available (owned by the Host), the transmission returns to the suspend state
and Bit[2] (TU) of Status Register is asserted. If the descriptor is available, the transmission
resumes. (RO/WT)
31 0
0x000000000 Reset
RECV_POLL_DEMAND When these bits are written with any value, the DMA reads the current de-
scriptor to which the Current Host Receive Descriptor Register is pointing. If that descriptor is
not available (owned by the Host), the reception returns to the Suspended state and Bit[7] (RU)
of Status Register is asserted. If the descriptor is available, the Rx DMA returns to the active
state. (RO/WT)
31 0
0x000000000 Reset
START_RECV_LIST This field contains the base address of the first descriptor in the Receive De-
scriptor list. The LSB Bits[1:0] are ignored and internally taken as all-zero by the DMA. Therefore,
these LSB bits are read-only. (R/W)
31 0
0x000000000 Reset
START_TRANS_LIST This field contains the base address of the first descriptor in the Transmit De-
scriptor list. The LSB Bits[1:0] are ignored and are internally taken as all-zero by the DMA. There-
fore, these LSB bits are read-only. (R/W)
IN _S AIL
T
E
P
IN
IL
AT
AN PR UN O
E
TO
S_ OC AV
TR V_IN _U OP
FA LY_R SU MM
TR NS_ UF_ _T
TR NS_ LO OW
VA
RE V_P T_T INT
R_
AT
ST
S_ T
TA E MM
T
A B ER
ST
C UF ST
A T NA
(re BU IN
ER
C_
F L
R T_ U
C D _
IN
AN JA W
C RO O
TR _O DF
RE _W NS
_
C_
RE V_B C_
TR S_ BB
EA IN _S
TS
T_
RO
L_ CV
T
_ )
CV UN
N_ NT
O
CV RA
(R ed)
EA ed)
(re PM
AC ed
BI
ed
PR
V
I
R_
S_
RE NS_
RE Y_T
EM erv
AB _
rv
rv
rv
_
RM
RO
AN
CV
se
se
se
RL
es
A
NO
(re
TR
ER
RE
31 30 29 28 27 26 25 23 22 20 19 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
EMAC_PMT_INT This bit indicates an interrupt event in the PMT module of the ETH_MAC. The
software must read the PMT Control and Status Register in the MAC to get the exact cause of
interrupt and clear its source to reset this bit to 1’b0. (RO)
ERROR_BITS This field indicates the type of error that caused a Bus Error, for example, error re-
sponse on the AHB interface. This field is valid only when Bit[13] (FBI) is set. This field does not
generate an interrupt. (RO)
TRANS_PROC_STATE This field indicates the Transmit DMA FSM state. This field does not generate
an interrupt. (RO)
• 3’b110: Reserved.
• 3’b111: Running. Transferring the TX packets data from transmit buffer to host memory.
RECV_PROC_STATE This field indicates the Receive DMA FSM state. This field does not generate
an interrupt. (RO)
• 3’b110: Reserved.
• 3’b111: Running. Transferring the TX packets data from receive buffer to host memory.
NORM_INT_SUMM Normal Interrupt Summary bit value is the logical OR of the following bits when
the corresponding interrupt bits are enabled in Interrupt Enable Register:(R/SS/WC)
• Bit[14]: Early Receive Interrupt. Only unmasked bits affect the Normal Interrupt Summary bit.
This is a sticky bit and must be cleared (by writing 1 to this bit) each time a corresponding
bit, which causes NIS to be set, is cleared.
ABN_INT_SUMM Abnormal Interrupt Summary bit value is the logical OR of the following when the
corresponding interrupt bits are enabled in Interrupt Enable Register: (R/SS/WC)
• Bit[13]: Fatal Bus Error. Only unmasked bits affect the Abnormal Interrupt Summary bit. This
is a sticky bit and must be cleared (by writing 1 to this bit) each time a corresponding bit,
which causes AIS to be set, is cleared.
EARLY_RECV_INT This bit indicates that the DMA filled the first data buffer of the packet. This bit is
cleared when the software writes 1 to this bit or when Bit[6] (RI) of this register is set (whichever
occurs earlier). (R/SS/WC)
FATAL_BUS_ERR_INT This bit indicates that a bus error occurred, as described in Bits [25:23].
When this bit is set, the corresponding DMA engine disables all of its bus accesses. (R/SS/WC)
EARLY_TRANS_INT This bit indicates that the frame to be transmitted is fully transferred to the MTL
Transmit FIFO. (R/SS/WC)
RECV_WDT_TO When set, this bit indicates that the Receive Watchdog Timer expired while receiving
the current frame and the current frame is truncated after the watchdog timeout. (R/SS/WC)
RECV_PROC_STOP This bit is asserted when the Receive Process enters the Stopped state.
(R/SS/WC)
RECV_BUF_UNAVAIL This bit indicates that the host owns the Next Descriptor in the Receive List and
the DMA cannot acquire it. The Receive Process is suspended. To resume processing Receive
descriptors, the host should change the ownership of the descriptor and issue a Receive Poll
Demand command. If no Receive Poll Demand is issued, the Receive Process resumes when
the next recognized incoming frame is received. This bit is set only when the previous Receive
Descriptor is owned by the DMA. (R/SS/WC)
RECV_INT This bit indicates that the frame reception is complete. When reception is complete, the
Bit[31] of RDES1 (Disable Interrupt on Completion) is reset in the last Descriptor, and the specific
frame status information is updated in the descriptor. The reception remains in the Running state.
(R/SS/WC)
TRANS_UNDFLOW This bit indicates that the Transmit Buffer had an Underflow during frame trans-
mission. Transmission is suspended and an Underflow Error TDES0[1] is set. (R/SS/WC)
RECV_OVFLOW This bit indicates that the Receive Buffer had an Overflow during frame reception.
If the partial frame is transferred to the application, the overflow status is set in RDES0[11].
(R/SS/WC)
TRANS_JABBER_TO This bit indicates that the Transmit Jabber Timer expired, which happens when
the frame size exceeds 2,048 (10,240 bytes when the Jumbo frame is enabled). When the
Jabber Timeout occurs, the transmission process is aborted and placed in the Stopped state.
This causes the Transmit Jabber Timeout TDES0[14] flag to assert. (R/SS/WC)
TRANS_BUF_UNAVAIL This bit indicates that the host owns the Next Descriptor in the Transmit List
and the DMA cannot acquire it. Transmission is suspended. Bits[22:20] explain the Transmit
Process state transitions. To resume processing Transmit descriptors, the host should change
the ownership of the descriptor by setting TDES0[31] and then issue a Transmit Poll Demand
command. (R/SS/WC)
TRANS_INT This bit indicates that the frame transmission is complete. When transmission is com-
plete, Bit[31] (OWN) of TDES0 is reset, and the specific frame status information is updated in
the descriptor. (R/SS/WC)
D
AN
M
OM
_C
M
ON
ES
se d RE RD FRA
SI
AM
IS
(re rve H_ WA R_
) X E
SM
R
se S OR ER
ed _R M
_F
rv P RA
AN
AR CO TRL
_ ER E
(re FLU _F IP_
L
CV
TR
OP D AM
M F
se STO _F
O
TR
RX GFR _G
S_ R P
IF
C
_C
DI STO _TC
DR U FR
(re T_ ND
P_
H_ WD
H_
_F
SH
(re STO
D_ R_
E
)
TX rve )
_S d)
(re ed)
D_ d)
_ OP
ES
US _F
TX
ed
ed
ed
RE
N
R
FW rve
ST SE
FL TR
HR
RX DR
T_
FW E
rv
rv
rv
rv
H
se
se
se
se
se
T_
AR
_T
_T
S_
OP
(re
(re
(re
ST
TX
DI
31 27 26 25 24 23 22 21 20 19 17 16 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DIS_DROP_TCPIP_ERR_FRAM When this bit is set, the MAC does not drop the frames which only
have errors detected by the Receive Checksum engine.When this bit is reset, all error frames are
dropped if the Fwd_Err_Frame bit is reset. (R/W)
RX_STORE_FORWARD When this bit is set, the MTL reads a frame from the Rx FIFO only after the
complete frame has been written to it. (R/W)
DIS_FLUSH_RECV_FRAMES When this bit is set, the Rx DMA does not flush any frames because
of the unavailability of receive descriptors or buffers. (R/W)
TX_STR_FWD When this bit is set, transmission starts when a full frame resides in the MTL Trans-
mit FIFO. When this bit is set, the TX_THRESH_CTRL values specified in TX_THRESH_CTRL are
ignored. (R/W)
FLUSH_TX_FIFO When this bit is set, the transmit FIFO controller logic is reset to its default values
and thus all data in the Tx FIFO is lost or flushed. This bit is cleared internally when the flushing
operation is complete. (R/WS/SC)
TX_THRESH_CTRL These bits control the threshold level of the MTL Transmit FIFO. Transmission
starts when the frame size within the MTL Transmit FIFO is larger than the threshold. In addition,
full frames with a length less than the threshold are also transmitted. These bits are used only
when TX_STR_FWD is reset. 3’b000: 64, 3’b001: 128, 3’b010: 192, 3’b011: 256, 3’b100: 40,
3’b101: 32, 3’b110: 24, 3’b111: 16. (R/W)
FWD_ERR_FRAME When this bit is reset, the Rx FIFO drops frames with error status (CRC error,
collision error, giant frame, watchdog timeout, or overflow). (R/W)
FWD_UNDER_GF When set, the Rx FIFO forwards Undersized frames (that is, frames with no Error
and length less than 64 bytes) including pad-bytes and CRC.
DROP_GFRM When set, the MAC drops the received giant frames in the Rx FIFO, that is, frames that
are larger than the computed giant frame limit. (R/W)
RX_THRESH_CTRL These two bits control the threshold level of the MTL Receive FIFO. Transfer
(request) to DMA starts when the frame size within the MTL Receive FIFO is larger than the
threshold. 2’b00: 64; 2’b01: 32; 2’b10: 96; 2’b11: 128. (R/W)
OPT_SECOND_FRAME When this bit is set, it instructs the DMA to process the second frame of the
Transmit data even before the status for the first frame is obtained. (R/W)
START_STOP_RX When this bit is set, the Receive process is placed in the Running state. The
DMA attempts to acquire the descriptor from the Receive list and processes the incoming
frames.When this bit is cleared, the Rx DMA operation is stopped after the transfer of the current
frame. (R/W)
DM IN_ BUE
EE
DM IN_ UE
DM IN_ ISE
DM IN_ WT
DM N_ E
N IE
DM IN_ TIE
DM IN_ TE
DM N_ E
AI TSE
DM IN_ IE
AI AIS
DM IN_ IE
DM IN_ IE
E
AI RS
(re _FB
AI ER
A TB
)
DM ed)
A TJ
ed
TI
A N
A O
A U
A R
A R
A R
A E
DM IN_
DM IN_
N_
rv
rv
se
se
A
A
DM
(re
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DMAIN_NISE When this bit is set, normal interrupt summary is enabled. When this bit is reset,
normal interrupt summary is disabled. This bit enables the following interrupts in Status Register:
(R/W)
DMAIN_AISE When this bit is set, abnormal interrupt summary is enabled. When this bit is reset,
the abnormal interrupt summary is disabled. This bit enables the following interrupts in Status
Register:(R/W)
DMAIN_ERIE When this bit is set with Normal Interrupt Summary Enable (Bit[16]), the Early Receive
Interrupt is enabled. When this bit is reset, the Early Receive Interrupt is disabled. (R/W)
DMAIN_FBEE When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]), the Fatal Bus
Error Interrupt is enabled. When this bit is reset, the Fatal Bus Error Enable Interrupt is disabled.
(R/W)
DMAIN_ETIE When this bit is set with an Abnormal Interrupt Summary Enable (Bit[15]), the Early
Transmit Interrupt is enabled. When this bit is reset, the Early Transmit Interrupt is disabled.
(R/W)
DMAIN_RWTE When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]), the Receive
Watchdog Timeout Interrupt is enabled. When this bit is reset, the Receive Watchdog Timeout
Interrupt is disabled. (R/W)
DMAIN_RSE When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]), the Receive
Stopped Interrupt is enabled. When this bit is reset, the Receive Stopped Interrupt is disabled.
(R/W)
DMAIN_RBUE When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]), the Receive
Buffer Unavailable Interrupt is enabled. When this bit is reset, the Receive Buffer Unavailable
Interrupt is disabled. (R/W)
DMAIN_RIE When this bit is set with Normal Interrupt Summary Enable (Bit[16]), the Receive Interrupt
is enabled. When this bit is reset, the Receive Interrupt is disabled. (R/W)
DMAIN_UIE When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]), the Transmit Un-
derflow Interrupt is enabled. When this bit is reset, the Underflow Interrupt is disabled. (R/W)
DMAIN_OIE When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]), the Receive Over-
flow Interrupt is enabled. When this bit is reset, the Overflow Interrupt is disabled. (R/W)
DMAIN_TJTE When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]), the Transmit
Jabber Timeout Interrupt is enabled. When this bit is reset, the Transmit Jabber Timeout Interrupt
is disabled. (R/W)
DMAIN_TBUE When this bit is set with Normal Interrupt Summary Enable (Bit 16), the Transmit Buffer
Unavailable Interrupt is enabled. When this bit is reset, the Transmit Buffer Unavailable Interrupt
is disabled. (R/W)
DMAIN_TSE When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]), the Transmis-
sion Stopped Interrupt is enabled. When this bit is reset, the Transmission Stopped Interrupt is
disabled. (R/W)
DMAIN_TIE When this bit is set with Normal Interrupt Summary Enable (Bit[16]), the Transmit Interrupt
is enabled. When this bit is reset, the Transmit Interrupt is disabled. (R/W)
FC
C
FO
M
FC
B
C
Ov ed)
w_
w_
w_
_F
ed
rv
flo
flo
flo
se
er
er
er
iss
(re
Ov
Ov
M
30 29 28 27 17 16 10 0
Overflow_BFOC This bit is set every time the Overflow Frame Counter (Bits[27:17]) overflows, that
is, the Rx FIFO overflows with the overflow frame counter at maximum value. In such a scenario,
the overflow frame counter is reset to all-zeros and this bit indicates that the rollover happened.
(R/SS/RC)
Overflow_FC This field indicates the number of frames missed by the application. This counter is
incremented each time the MTL FIFO overflows. The counter is cleared when this register is
read. (R/SS/RC)
Overflow_BMFC This bit is set every time Missed Frame Counter (Bits[15:0]) overflows, that is, the
DMA discards an incoming frame because of the Host Receive Buffer being unavailable with the
missed frame counter at maximum value. In such a scenario, the Missed frame counter is reset
to all-zeros and this bit indicates that the rollover happened. (R/SS/RC)
Missed_FC This field indicates the number of frames missed by the controller because of the Host
Receive Buffer being unavailable. This counter is incremented each time the DMA discards an
incoming frame. The counter is cleared when this register is read. (R/SS/RC)
TC
se
W
(re
RI
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
RIWTC This bit indicates the number of system clock cycles multiplied by 256 for which the watch-
dog timer is set. The watchdog timer gets triggered with the programmed value after the Rx
DMA completes the transfer of a frame for which the RI (RECV_INT) status bit is not set because
of the setting in the corresponding descriptor RDES1[31]. When the watchdog timer runs out,
the RI bit is set and the timer is stopped. The watchdog timer is reset when the RI bit is set high
because of automatic setting of RI as per RDES1[31] of any received frame. (R/W)
31 0
0x000000000 Reset
TRANS_DSCR_ADDR_PTR The address of the current receive descriptor list. Cleared on Reset.
Pointer updated by the DMA during operation. (RO)
31 0
0x000000000 Reset
RECV_DSCR_ADDR_PTR The address of the current receive descriptor list. Cleared on Reset.
Pointer updated by the DMA during operation. (RO)
31 0
0x000000000 Reset
TRANS_BUFF_ADDR_PTR The address of the current receive descriptor list. Cleared on Reset.
Pointer updated by the DMA during operation. (RO)
31 0
0x000000000 Reset
RECV_BUFF_ADDR_PTR The address of the current receive descriptor list. Cleared on Reset.
Pointer updated by the DMA during operation. (RO)
K
AP
EC
AD
IT
E
EG
P
AM
CH
IM
RI
RS
EM rve RY LO
AM
EM rve BER G
AC UPL ACK
ST
AL
FR
se B DO
se ET FF
AC II EC
FF
A XO D
FR
AC CRC
A XIP X
EM CT ERR
EM R EE
BO
(re CR CO
EM CLO WN
EM M BL
(re CJA CH
EM CD PB
O
EM R E
R
K
AC ESP
)
AC d)
AC d)
AC ISA
TE
M
A AT
A O
EM AC
EM AD
ed
ed
A F E
JU
PL X
AC X
P
IN
EM CW
rv
rv
EM CD
EM CD
B
P
R
EM F
2K
C
AC
se
se
TF
IR
A
S
EM
EM
EM
(re
(re
SA
AS
31 30 28 27 26 24 23 22 21 20 19 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SAIRC This field controls the source address insertion or replacement for all transmitted frames.
Bit[30] specifies which MAC Address register (0 or 1) is used for source address insertion or
replacement based on the values of Bits [29:28]: (R/W)
• 2’b0x: The input signals mti_sa_ctrl_i and ati_sa_ctrl_i control the SA field generation.
• 2’b10: If Bit[30] is set to 0, the MAC inserts the content of the MAC Address 0 registers in
the SA field of all transmitted frames. If Bit[30] is set to 1 the MAC inserts the content of the
MAC Address 1 registers in the SA field of all transmitted frames.
• 2’b11: If Bit[30] is set to 0, the MAC replaces the content of the MAC Address 0 registers in
the SA field of all transmitted frames. If Bit[30] is set to 1, the MAC replaces the content of
the MAC Address 1 registers in the SA field of all transmitted frames.
ASS2KP When set, the MAC considers all frames, with up to 2,000 bytes length, as normal packets.
When Bit[20] (JE) is not set, the MAC considers all received frames of size more than 2K bytes
as Giant frames. When this bit is reset and Bit[20] (JE) is not set, the MAC considers all received
frames of size more than 1,518 bytes (1,522 bytes for tagged) as Giant frames. When Bit[20] is
set, setting this bit has no effect on Giant Frame status. (R/W)
EMACWATCHDOG When this bit is set, the MAC disables the watchdog timer on the receiver. The
MAC can receive frames of up to 16,383 bytes. When this bit is reset, the MAC does not allow a
receive frame which more than 2,048 bytes (10,240 if JE is set high) or the value programmed in
Register (Watchdog Timeout Register). The MAC cuts off any bytes received after the watchdog
limit number of bytes. (R/W)
EMACJABBER When this bit is set, the MAC disables the jabber timer on the transmitter. The MAC
can transfer frames of up to 16,383 bytes. When this bit is reset, the MAC cuts off the transmitter
if the application sends out more than 2,048 bytes of data (10,240 if JE is set high) during
transmission. (R/W)
EMACJUMBOFRAME When this bit is set, the MAC allows Jumbo frames of 9,018 bytes (9,022 bytes
for VLAN tagged frames) without reporting a giant frame error in the receive frame status. (R/W)
EMACINTERFRAMEGAP These bits control the minimum IFG between frames during transmission.
(R/W)
• 3’b111: 40 bit times. In the half-duplex mode, the minimum IFG can be configured only for
64 bit times (IFG = 100). Lower values are not considered.
EMACDISABLECRS When set high, this bit makes the MAC transmitter ignore the MII CRS signal
during frame transmission in the half-duplex mode. This request results in no errors generated
because of Loss of Carrier or No Carrier during such transmission. When this bit is low, the MAC
transmitter generates such errors because of Carrier Sense and can even abort the transmis-
sions. (R/W)
EMACMII This bit selects the Ethernet line speed. It should be set to 1 for 10 or 100 Mbps operations.
In 10 or 100 Mbps operations, this bit, along with FES(EMACFESPEED) bit, it selects the exact
linespeed. In the 10/100 Mbps-only operations, the bit is always 1. (R/W)
EMACFESPEED This bit selects the speed in the MII, RMII interface. 0: 10 Mbps; 1: 100 Mbps.
(R/W)
EMACRXOWN When this bit is set, the MAC disables the reception of frames when the TX_EN is
asserted in the half-duplex mode. When this bit is reset, the MAC receives all packets that are
given by the PHY while transmitting. This bit is not applicable if the MAC is operating in the
full-duplex mode. (R/W)
EMACLOOPBACK When this bit is set, the MAC operates in the loopback mode MII. The MII Receive
clock input (CLK_RX) is required for the loopback to work properly, because the transmit clock
is not looped-back internally. (R/W)
EMACDUPLEX When this bit is set, the MAC operates in the full-duplex mode where it can transmit
and receive simultaneously. This bit is read only with default value of 1’b1 in the full-duplex-mode.
(R/W)
EMACRXIPCOFFLOAD When this bit is set, the MAC calculates the 16-bit one’s complement of the
one’s complement sum of all received Ethernet frame payloads. It also checks whether the IPv4
Header checksum (assumed to be bytes 25/26 or 29/30 (VLAN-tagged) of the received Ethernet
frame) is correct for the received frame and gives the status in the receive status word. The MAC
also appends the 16-bit checksum calculated for the IP header datagram payload (bytes after
the IPv4 header) and appends it to the Ethernet frame transferred to the application (when Type
2 COE is deselected). When this bit is reset, this function is disabled. (R/W)
EMACRETRY When this bit is set, the MAC attempts only one transmission. When a collision occurs
on the MII interface, the MAC ignores the current frame transmission and reports a Frame Abort
with excessive collision error in the transmit frame status. When this bit is reset, the MAC attempts
retries based on the settings of the BL field (Bits [6:5]). This bit is applicable only in the half-
duplex mode. (R/W)
EMACPADCRCSTRIP When this bit is set, the MAC strips the Pad or FCS field on the incoming frames
only if the value of the length field is less than 1,536 bytes. All received frames with length field
greater than or equal to 1,536 bytes are passed to the application without stripping the Pad or
FCS field. When this bit is reset, the MAC passes all incoming frames, without modifying them,
to the Host. (R/W)
EMACBACKOFFLIMIT The Back-Off limit determines the random integer number (r) of slot time de-
lays (512 bit times for 10/100 Mbps) for which the MAC waits before rescheduling a transmission
attempt during retries after a collision. This bit is applicable only in the half-duplex mode.
• 11: k = min (n, 1), n = retransmission attempt. The random integer r takes the value in the
range 0 ~ 2000.
EMACTX When this bit is set, the transmit state machine of the MAC is enabled for transmission on
the MII. When this bit is reset, the MAC transmit state machine is disabled after the completion
of the transmission of the current frame, and does not transmit any further frames. (R/W)
EMACRX When this bit is set, the receiver state machine of the MAC is enabled for receiving frames
from the MII. When this bit is reset, the MAC receive state machine is disabled after the com-
pletion of the reception of the current frame, and does not receive any further frames from the
MII. (R/W)
PLTF These bits control the number of preamble bytes that are added to the beginning of every
Transmit frame. The preamble reduction occurs only when the MAC is operating in the full-duplex
mode. 2’b00: 7 bytes of preamble. 2’b01: 5 bytes of preamble. 2’b10: 3 bytes of preamble.
(R/W)
L
AL
PM ed)
E_
ed
E
IV
rv
rv
OD
CE
se
se
FE
IF
M
IF
F
F
(re
(re
RE
DB
PC
DA
SA
SA
PA
31 30 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 0 0 0 0 0 0 Reset
RECEIVE_ALL When this bit is set, the MAC Receiver module passes all received frames, irrespec-
tive of whether they pass the address filter or not, to the Application. The result of the SA or DA
filtering is updated (pass or fail) in the corresponding bits in the Receive Status Word. When this
bit is reset, the Receiver module passes only those frames to the Application that pass the SA
or DA address filter. (R/W)
SAFE When this bit is set, the MAC compares the SA field of the received frames with the values
programmed in the enabled SA registers. If the comparison fails, the MAC drops the frame.
When this bit is reset, the MAC forwards the received frame to the application with updated SAF
bit of the Rx Status depending on the SA address comparison. (R/W)
SAIF When this bit is set, the Address Check block operates in inverse filtering mode for the SA
address comparison. The frames whose SA matches the SA registers are marked as failing the
SA Address filter. When this bit is reset, frames whose SA does not match the SA registers are
marked as failing the SA Address filter. (R/W)
PCF These bits control the forwarding of all control frames (including unicast and multicast Pause
frames). (R/W)
• 2’b00: MAC filters all control frames from reaching the application.
• 2’b01: MAC forwards all control frames except Pause frames to application even if they fail
the Address filter.
• 2’b10: MAC forwards all control frames to application even if they fail the Address Filter.
• 2’b11: MAC forwards control frames that pass the Address Filter.
The following conditions should be true for the Pause frames processing:
• Condition 1: The MAC is in the full-duplex mode and flow control is enabled by setting Bit
2 (RFE) of Register (Flow Control Register) to 1.
• Condition 2: The destination address (DA) of the received frame matches the special mul-
ticast address or the MAC Address 0 when Bit 3 (UP) of the Register(Flow Control Register)
is set.
• Condition 3: The Type field of the received frame is 0x8808 and the OPCODE field is 0x0001.
DBF When this bit is set, the AFM(Address Filtering Module) module blocks all incoming broadcast
frames. In addition, it overrides all other filter settings. When this bit is reset, the AFM module
passes all received broadcast frames. (R/W)
PAM When set, this bit indicates that all received frames with a multicast destination address (first
bit in the destination address field is ’1’) are passed. (R/W)
DAIF When this bit is set, the Address Check block operates in inverse filtering mode for the DA
address comparison for both unicast and multicast frames. When reset, normal filtering of frames
is performed. (R/W)
PMODE When this bit is set, the Address Filter module passes all incoming frames irrespective of
the destination or source address. The SA or DA Filter Fails status bits of the Receive Status
Word are always cleared when PR(PRT_RATIO) is set. (R/W)
K
)
ed
CL
IIB E
Y
M RIT
rv
US
SR
EG
EV
se
IIW
IIC
IID
IIR
(re
M
M
M
31 16 15 11 10 6 5 2 1 0
MIIDEV This field indicates which of the 32 possible PHY devices are being accessed. (R/W)
MIIREG This field selects the desired MII register in the selected PHY device. (R/W)
MIICSRCLK This field selects the APB clock frequency. It has the following two values. Other values
are reserved.
• 4’b0000: The APB clock frequency is 80 MHz. The MDC clock frequency is APB_CLK/42.
• 4’b0011: The APB clock frequency is 40 MHz. The MDC clock frequency is APB_CLK/26.
(R/W)
MIIWRITE When set, this field indicates to the PHY that this is a Write operation using MII_DATA. If
this field is not set, it indicates that this is a Read operation, that is, placing the data in MII_DATA.
(R/W)
Before writing to MIIREG and MII_DATA, this field should read logic 0 (idle state by default).
To read or write to MIIREG and MII_DATA, software (the user) should set this field to 1.
MII_DATA should be kept valid (data remains unchanged) when it is accessed until this field is
cleared by hardware (the MAC).
Note that ESP32 MAC does not receive ACK from PHY during a read or write access to MIIREG
and MII_DATA. (R/WS/SC)
)
ed
TA
rv
DA
se
II_
(re
M
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00000 Reset
MII_DATA This field contains the 16-bit data value read from the PHY after a Management Read
operation or the 16-bit data value to be written to the PHY before a Management Write operation.
(R/W)
E
M
)
ed
TI
E_
rv
A
RF D
US
se
BB
CE
FC E
F
C
T
(re
UP
PA
TF
PL
31 16 15 6 5 4 3 2 1 0
PAUSE_TIME This field holds the value to be used in the Pause Time field in the transmit control
frame. If the Pause Time bits is configured to be double-synchronized to the MII clock domain,
then consecutive writes to this register should be performed only after at least four clock cycles
in the destination clock domain. (R/W)
PLT This field configures the threshold of the Pause timer automatic retransmission of the Pause
frame. The threshold values should be always less than the Pause Time configured in Bits[31:16].
For example, if PT = 100H (256 slot-times), and PLT = 01, then a second Pause frame is auto-
matically transmitted at 228 (256-28) slot times after the first Pause frame is transmitted. The
following list provides the threshold values for different values: (R/W)
• 2’b00: The threshold is Pause time minus 4 slot times (PT-4 slot times).
• 2’b01: The threshold is Pause time minus 28 slot times (PT-28 slot times).
• 2’b10: The threshold is Pause time minus 144 slot times (PT-144 slot times).
• 2’b11: The threshold is Pause time minus 256 slot times (PT-256 slot times). The slot time
is defined as the time taken to transmit 512 bits (64 bytes) on the MII interface.
UPFD A pause frame is processed when it has the unique multicast address specified in the IEEE
Std 802.3. When this bit is set, the MAC can also detect Pause frames with unicast address
of the station. This unicast address should be as specified in the EMACADDR0 High Register
and EMACADDR0 Low Register. When this bit is reset, the MAC only detects Pause frames with
unique multicast address. (R/W)
RFCE When this bit is set, the MAC decodes the received Pause frame and disables its transmitter
for a specified (Pause) time. When this bit is reset, the decode function of the Pause frame is
disabled. (R/W)
TFCE In the full-duplex mode, when this bit is set, the MAC enables the flow control operation to
transmit Pause frames. When this bit is reset, the flow control operation in the MAC is disabled,
and the MAC does not transmit any Pause frames. In the half-duplex mode, when this bit is set,
the MAC enables the backpressure operation. When this bit is reset, the backpressure feature
is disabled. (R/W)
FCBBA This bit initiates a Pause frame in the full-duplex mode and activates the backpressure func-
tion in the half-duplex mode if the TFCE bit is set. In the full-duplex mode, this bit should be
read as 1’b0 before writing to the Flow Control register. To initiate a Pause frame, the Application
must set this bit to 1’b1. During a transfer of the Control Frame, this bit continues to be set to
signify that a frame transmission is in progress. After the completion of Pause frame transmis-
sion, the MAC resets this bit to 1’b0. The Flow Control register should not be written to until this
bit is cleared. In the half-duplex mode, when this bit is set (and TFCE is set), then backpressure
is asserted by the MAC. During backpressure, when the MAC receives a new frame, the trans-
mitter starts sending a JAM pattern resulting in a collision. When the MAC is configured for the
full-duplex mode, the BPA is automatically disabled. (R/WS/SC)(FCB)/(R/W)(BPA(backpressure
activate))
rv AS
TL CS
S
S
S
se ES
d)
TF )
)
(re FLS
S
se C
ES
FC
TL d
ed
ed
ed
CS
ES
RC
RC
TL F
(re FW
ve
M rve
W
(re TFN
M TSF
rv
rv
RP
RF
TP
TP
TF
RF
RF
TF
r
R
se
se
se
AC
AC
AC
AC
AC
TL
TL
TL
TL
(re
(re
M
M
31 26 25 24 23 22 21 20 19 18 17 16 15 10 9 8 7 6 5 4 3 2 1 0
MTLTSFFS When high, this bit indicates that the MTL TxStatus FIFO is full. Therefore, the MTL
cannot accept any more frames for transmission. (RO)
MTLTFNES When high, this bit indicates that the MTL Tx FIFO is not empty and some data is left for
transmission. (RO)
MTLTFWCS When high, this bit indicates that the MTL Tx FIFO Write Controller is active and is trans-
ferring data to the Tx FIFO. (RO)
MTLTFRCS This field indicates the state of the Tx FIFO Read Controller: (RO)
MACTP When high, this bit indicates that the MAC transmitter is in the Pause condition (in the full-
duplex-mode) and hence does not schedule any frame for transmission. (RO)
MACTFCS This field indicates the state of the MAC Transmit Frame Controller module: (RO)
• 2’b01: Waiting for status of previous frame or IFG or backoff period to be over.
• 2’b10: Generating and transmitting a Pause frame (in the full-duplex mode).
MACTPES When high, this bit indicates that the MAC MII transmit protocol engine is actively trans-
mitting data and is not in the IDLE state. (RO)
MTLRFFLS This field gives the status of the fill-level of the Rx FIFO: (RO)
MTLRFRCS This field gives the state of the Rx FIFO read Controller: (RO)
2’b10: Reserved.
MTLRFWCAS When high, this bit indicates that the MTL Rx FIFO Write Controller is active and is
transferring a received frame to the FIFO. (RO)
MACRFFCS When high, this field indicates the active state of the FIFO Read and Write controllers
of the MAC Receive Frame Controller Module. MACRFFCS[1] represents the status of FIFO Read
controller. MACRFFCS[0] represents the status of small FIFO Write controller. (RO)
MACRPES When high, this bit indicates that the MAC MII receive protocol engine is actively receiv-
ing data and not in IDLE state. (RO)
F R
UF
R W
T_
PM
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
WKUPPKTFILTER The MSB (31st bit) must be zero. Bit j[30:0] is the byte mask. If Bit 1/2/3/4 (byte
number) of the byte mask is set, the CRC block processes the filter 0/1/2/3 Offset + j of the
incoming packet (RWKPTR is 0/1/2/3). (R/W)
• RWKPTR is 4: Bit 3/11/19/27 specifies the address type, defining the destination address
type of the pattern. When the bit is set, the pattern applies to only multicast packets; when
the bit is reset, the pattern applies only to unicast packet for filter 0/1/2/3. Bit 0/8/16/24 is
the enable bit for filter 0/1/2/3;
• RWKPTR is 5: This filter 0/1/2/3 offset register defines the offset (within the packet) from
which the filter 0/1/2/3 examines the packets;
• RWKPTR is 6: This filter 0 (bit[15:0])/1 (bit[31:16]) CRC16 register contains the CRC16 value
calculated from the pattern and also the byte mask programmed to the wake-up filter register
block; The polynomial:
• RWKPTR is 7: This filter 2 bit[15:0])/3(bit[31:16]) CRC16 register contains the CRC16 value
calculated from the pattern and also the byte mask programmed to the wake-up filter register
block. The polynomial:
se ST
se D
PR D
RD TEN
PW PK N
)
d)
RW ed)
(re CAS
(re CV
GK CV
(re TR
ed
ed
G K TE
N
e
TR
W
IL
rv
rv
rv
rv
M PR
M PK
U
KP
KF
se
se
BL
K
RW
RW
RW
(re
GL
31 30 29 28 24 23 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 Reset
RWKFILTRST When this bit is set, it resets the remote RWKPTR register to 3’b000. (R/WS/SC)
RWKPTR The maximum value of the pointer is 7 ,the detail information ,please refer to
PMT_RWUFFR. (RO)
GLBLUCAST When set, enables any unicast packet filtered by the MAC (DAFilter) address recogni-
tion to be a remote wake-up frame. (R/W)
RWKPRCVD When set, this bit indicates the power management event is generated because of the
reception of a remote wake-up frame. This bit is cleared by a Read into this register. (R/SS/RC)
MGKPRCVD When set, this bit indicates that the power management event is generated because
of the reception of a magic packet. This bit is cleared by a Read into this register. (R/SS/RC)
RWKPKTEN hen set, enables generation of a power management event because of remote wake-
up frame reception. (R/W)
MGKPKTEN When set, enables generation of a power management event because of magic packet
reception. (R/W)
PWRDWN hen set, the MAC receiver drops all received frames until it receives the expected magic
packet or remote wake-up frame. This bit must only be set when MGKPKTEN, GLBLUCAST, or
RWKPKTEN bit is set high. (R/WS/SC)
d)
S d)
)
ed
ed
ve
PL rve
rv
rv
TL IEN
EN
TL IST
ST
(re XA
RL IEX
TL EX
r
N
se
se
se
se
PI
IT
PI
PI
IE
P
P
(re
(re
(re
RL
LP
LP
RL
31 20 19 18 17 16 15 10 9 8 7 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LPITXA This bit controls the behavior of the MAC when it is entering or coming out of the LPI mode
on the transmit side.If the LPITXA and LPIEN bits are set to 1, the MAC enters the LPI mode only
after all outstanding frames and pending frames have been transmitted. The MAC comes out
of the LPI mode when the application sends any frame.When this bit is 0, the LPIEN bit directly
controls behavior of the MAC when it is entering or coming out of the LPI mode. (R/W)
PLS This bit indicates the link status of the PHY. When set, the link is considered to be okay (up)
and when reset, the link is considered to be down. (R/W)
LPIEN When set, this bit instructs the MAC Transmitter to enter the LPI state. When reset, this bit
instructs the MAC to exit the LPI state and resume normal transmission.This bit is cleared when
the LPITXA bit is set and the MAC exits the LPI state because of the arrival of a new packet for
transmission. (R/W/SC)
RLPIST When set, this bit indicates that the MAC is receiving the LPI pattern on the MII interface.
(R/W)
TLPIST When set, this bit indicates that the MAC is receiving the LPI pattern on the MII interface.
(R/W)
RLPIEX When set, this bit indicates that the MAC Receiver has stopped receiving the LPI pattern on
the MII interface, exited the LPI state, and resumed the normal reception. This bit is cleared by
a read into this register. (R/SS/RC)
RLPIEN When set, this bit indicates that the MAC Receiver has received an LPI pattern and entered
the LPI state. This bit is cleared by a read into this register. (R/SS/RC)
TLPIEX When set, this bit indicates that the MAC transmitter has exited the LPI state after the user
has cleared the LPIEN bit and the LPI_TW_Timer has expired.This bit is cleared by a read into this
register. (R/SS/RC)
TLPIEN When set, this bit indicates that the MAC Transmitter has entered the LPI state because of
the setting of the LPIEN bit. This bit is cleared by a read into this register. (R/SS/RC)
ER
ER
IM
M
)
I
ed
_T
_T
W
rv
LS
_T
se
I_
I
(re
LP
LP
31 26 25 16 15 0
0 0 0 0 0 0 0 x 3 E 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LPI_LS_TIMER This field specifies the minimum time (in milliseconds) for which the link status from
the PHY should be up (OKAY) before the LPI pattern can be transmitted to the PHY. The MAC does
not transmit the LPI pattern even when the LPIEN bit is set unless the LPI_LS_Timer reaches the
programmed terminal count. The default value of the LPI_LS_Timer is 1000 (1 sec) as defined in
the IEEE standard.(R/W)
LPI_TW_TIMER This field specifies the minimum time (in microseconds) for which the MAC waits af-
ter it stops transmitting the LPI pattern to the PHY and before it resumes the normal transmission.
The TLPIEX status bit is set after the expiry of this timer.(R/W)
)
ed
ed
ed
ed
TS
(re TS
rv
rv
rv
rv
N
se
se
se
se
IIN
TI
PM
(re
(re
(re
LP
31 11 10 9 8 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LPIINTS When the Energy Efficient Ethernet feature is enabled, this bit is set for any LPI state entry
or exit in the MAC Transmitter or Receiver. This bit is cleared on reading Bit[0] of Register (LPI
Control and Status Register). (RO)
PMTINTS This bit is set when a magic packet or remote wake-up frame is received in the power-
down mode (see Bit[5] and Bit[6] in the PMT Control and Status Register). This bit is cleared
when both Bits[6:5] are cleared because of a read operation to the PMT Control and Status
register. This bit is valid only when you select the optional PMT module during core configuration.
(RO)
K
AS
rv K
se AS
)
d)
)
ed
ed
ed
M
ve
(re TM
NT
rv
rv
r
se
se
se
IIN
TI
PM
(re
(re
(re
LP
31 11 10 9 8 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LPIINTMASK When set, this bit disables the assertion of the interrupt signal because of the setting
of the LPI Interrupt Status bit in Register (Interrupt Status Register). (R/W)
PMTINTMASK When set, this bit disables the assertion of the interrupt signal because of the setting
of PMT Interrupt Status bit in Register (Interrupt Status Register). (R/W)
I
_H
BL
S0
A
S
EN
RE
S_
DD
ed
ES
_A
rv
DR
se
AC
(re
AD
M
31 30 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0FFFF Reset
MAC_ADDRESS0_HI This field contains the upper 16 bits (47:32) of the first 6-byte MAC address.
The MAC uses this field for filtering the received frames and inserting the MAC address in the
Transmit Flow Control (Pause) Frames. (R/W)
31 0
0x0FFFFFFFF Reset
EMACADDR0LOW_REG This field contains the lower 32 bits of the first 6-byte MAC address. This is
used by the MAC for filtering the received frames and inserting the MAC address in the Transmit
Flow Control (Pause) Frames. (R/W)
OL
TR
RE 1
I
SS
_H
DD LE
ON
_A AB
S1
_C
ES
CE EN
TE
R
UR S_
DD
BY
ed
SO RES
_A
K_
rv
se
AC
AS
D
(re
AD
M
31 30 29 24 23 16 15 0
ADDRESS_ENABLE1 When this bit is set, the address filter module uses the second MAC address
for perfect filtering. When this bit is reset, the address filter module ignores the address for
filtering. (R/W)
SOURCE_ADDRESS When this bit is set, the EMACADDR1[47:0] is used to compare with the SA
fields of the received frame. When this bit is reset, the EMACADDR1[47:0] is used to compare
with the DA fields of the received frame. (R/W)
MASK_BYTE_CONTROL These bits are mask control bits for comparison of each of the EMACADDR1
bytes. When set high, the MAC does not compare the corresponding byte of received DA or
SA with the contents of EMACADDR1 registers. Each bit controls the masking of the bytes as
follows:
You can filter a group of addresses (known as group address filtering) by masking one or more
bytes of the address. (R/W)
MAC_ADDRESS1_HI This field contains the upper 16 bits, Bits[47:32] of the second 6-byte MAC
address. (R/W)
31 0
0x0FFFFFFFF Reset
EMACADDR1LOW_REG This field contains the lower 32 bits of the second 6-byte MAC address. The
content of this field is undefined, so the register needs to be configured after the initialization
process. (R/W)
2
OL
2
TR
I
RE 2
_H
SS
DD LE
ON
S2
_A AB
_C
S
CE EN
RE
TE
UR S_
d)
DD
BY
ve
SO RES
_A
K_
r
se
AC
AS
D
(re
AD
M
31 30 29 24 23 16 15 0
ADDRESS_ENABLE2 When this bit is set, the address filter module uses the third MAC address for
perfect filtering. When this bit is reset, the address filter module ignores the address for filtering.
(R/W)
SOURCE_ADDRESS2 When this bit is set, the EMACADDR2[47:0] is used to compare with the SA
fields of the received frame. When this bit is reset, the EMACADDR2[47:0] is used to compare
with the DA fields of the received frame. (R/W)
MASK_BYTE_CONTROL2 These bits are mask control bits for comparison of each of the
EMACADDR2 bytes. When set high, the MAC does not compare the corresponding byte of
received DA or SA with the contents of EMACADDR2 registers. Each bit controls the masking of
the bytes as follows:
You can filter a group of addresses (known as group address filtering) by masking one or more
bytes of the address. (R/W)
MAC_ADDRESS2_HI This field contains the upper 16 bits, Bits[47:32] of the third 6-byte MAC ad-
dress. (R/W)
31 0
0x0FFFFFFFF Reset
EMACADDR2LOW_REG This field contains the lower 32 bits of the third 6-byte MAC address. The
content of this field is undefined, so the register needs to be configured after the initialization
process. (R/W)
3
OL
TR
3
I
RE 3
_H
SS
DD LE
ON
S3
_A AB
_C
S
CE EN
RE
TE
UR S_
d)
DD
BY
ve
SO RES
_A
K_
r
se
AC
AS
D
(re
AD
M
31 30 29 24 23 16 15 0
ADDRESS_ENABLE3 When this bit is set, the address filter module uses the fourth MAC address for
perfect filtering. When this bit is reset, the address filter module ignores the address for filtering.
(R/W)
SOURCE_ADDRESS3 When this bit is set, the EMACADDR3[47:0] is used to compare with the SA
fields of the received frame. When this bit is reset, the EMACADDR3[47:0] is used to compare
with the DA fields of the received frame. (R/W)
MASK_BYTE_CONTROL3 These bits are mask control bits for comparison of each of the
EMACADDR3 bytes. When set high, the MAC does not compare the corresponding byte of
received DA or SA with the contents of EMACADDR3 registers. Each bit controls the masking of
the bytes as follows:
You can filter a group of addresses (known as group address filtering) by masking one or more
bytes of the address. (R/W)
MAC_ADDRESS3_HI This field contains the upper 16 bits, Bits[47:32] of the fourth 6-byte MAC ad-
dress. (R/W)
31 0
0x0FFFFFFFF Reset
EMACADDR3LOW_REG This field contains the lower 32 bits of the fourth 6-byte MAC address. The
content of this field is undefined, so the register needs to be configured after the initialization
process. (R/W)
4
OL
TR
4
I
RE 4
_H
SS
DD LE
ON
S4
_A AB
_C
S
CE EN
RE
TE
UR S_
DD
BY
ed
SO RES
_A
K_
rv
se
AC
AS
D
(re
AD
M
31 30 29 24 23 16 15 0
ADDRESS_ENABLE4 When this bit is set, the address filter module uses the fifth MAC address for
perfect filtering. When this bit is reset, the address filter module ignores the address for filtering.
(R/W)
SOURCE_ADDRESS4 When this bit is set, the EMACADDR4[47:0] is used to compare with the SA
fields of the received frame. When this bit is reset, the EMACADDR4[47:0] is used to compare
with the DA fields of the received frame. (R/W)
MASK_BYTE_CONTROL4 These bits are mask control bits for comparison of each of the
EMACADDR4 bytes. When set high, the MAC does not compare the corresponding byte of
received DA or SA with the contents of EMACADDR4 registers. Each bit controls the masking of
the bytes as follows:
You can filter a group of addresses (known as group address filtering) by masking one or more
bytes of the address. (R/W)
MAC_ADDRESS4_HI This field contains the upper 16 bits, Bits[47:32] of the fifth 6-byte MAC ad-
dress. (R/W)
31 0
0x0FFFFFFFF Reset
EMACADDR4LOW_REG This field contains the lower 32 bits of the fifth 6-byte MAC address. The
content of this field is undefined, so the register needs to be configured after the initialization
process. (R/W)
5
OL
TR
5
I
RE 5
_H
SS
DD LE
ON
S5
_A AB
_C
S
CE EN
RE
TE
UR S_
d)
DD
BY
ve
SO RES
_A
K_
r
se
AC
AS
D
(re
AD
M
31 30 29 24 23 16 15 0
ADDRESS_ENABLE5 When this bit is set, the address filter module uses the sixth MAC address for
perfect filtering. When this bit is reset, the address filter module ignores the address for filtering.
(R/W)
SOURCE_ADDRESS5 When this bit is set, the EMACADDR5[47:0] is used to compare with the SA
fields of the received frame. When this bit is reset, the EMACADDR5[47:0] is used to compare
with the DA fields of the received frame. (R/W)
MASK_BYTE_CONTROL5 These bits are mask control bits for comparison of each of the
EMACADDR5 bytes. When set high, the MAC does not compare the corresponding byte of
received DA or SA with the contents of EMACADDR5 registers. Each bit controls the masking of
the bytes as follows:
You can filter a group of addresses (known as group address filtering) by masking one or more
bytes of the address. (R/W)
MAC_ADDRESS5_HI This field contains the upper 16 bits, Bits[47:32] of the sixth 6-byte MAC ad-
dress. (R/W)
31 0
0x0FFFFFFFF Reset
EMACADDR5LOW_REG This field contains the lower 32 bits of the sixth 6-byte MAC address. The
content of this field is undefined, so the register needs to be configured after the initialization
process. (R/W)
6
OL
6
TR
I
RE 6
_H
SS
DD LE
ON
S6
_A AB
_C
S
CE EN
RE
TE
UR S_
DD
BY
ed
SO RES
_A
K_
rv
se
AC
AS
D
(re
AD
M
31 30 29 24 23 16 15 0
ADDRESS_ENABLE6 When this bit is set, the address filter module uses the seventh MAC address
for perfect filtering. When this bit is reset, the address filter module ignores the address for
filtering. (R/W)
SOURCE_ADDRESS6 When this bit is set, the EMACADDR6[47:0] is used to compare with the SA
fields of the received frame. When this bit is reset, the EMACADDR6[47:0] is used to compare
with the DA fields of the received frame. (R/W)
MASK_BYTE_CONTROL6 These bits are mask control bits for comparison of each of the
EMACADDR6 bytes. When set high, the MAC does not compare the corresponding byte of
received DA or SA with the contents of EMACADDR6 registers. Each bit controls the masking of
the bytes as follows:
You can filter a group of addresses (known as group address filtering) by masking one or more
bytes of the address. (R/W)
MAC_ADDRESS6_HI This field contains the upper 16 bits, Bits[47:32] of the seventh 6-byte MAC
address. (R/W)
31 0
0x0FFFFFFFF Reset
EMACADDR6LOW_REG This field contains the lower 32 bits of the seventh 6-byte MAC address.
The content of this field is undefined, so the register needs to be configured after the initialization
process. (R/W)
7
OL
TR
7
RE 7
I
SS
_H
DD LE
ON
S7
_A AB
_C
ES
CE EN
TE
R
UR S_
d)
DD
BY
ve
SO RES
_A
K_
r
se
AC
AS
D
(re
AD
M
31 30 29 24 23 16 15 0
ADDRESS_ENABLE7 When this bit is set, the address filter module uses the eighth MAC address for
perfect filtering. When this bit is reset, the address filter module ignores the address for filtering.
(R/W)
SOURCE_ADDRESS7 When this bit is set, the EMACADDR7[47:0] is used to compare with the SA
fields of the received frame. When this bit is reset, the EMACADDR7[47:0] is used to compare
with the DA fields of the received frame. (R/W)
MASK_BYTE_CONTROL7 These bits are mask control bits for comparison of each of the
EMACADDR7 bytes. When set high, the MAC does not compare the corresponding byte of
received DA or SA with the contents of EMACADDR7 registers. Each bit controls the masking of
the bytes as follows:
You can filter a group of addresses (known as group address filtering) by masking one or more
bytes of the address. (R/W)
MAC_ADDRESS7_HI This field contains the upper 16 bits, Bits[47:32] of the eighth 6-byte MAC ad-
dress. (R/W)
31 0
0x0FFFFFFFF Reset
EMACADDR7LOW_REG This field contains the lower 32 bits of the eighth 6-byte MAC address. The
content of this field is undefined, so the register needs to be configured after the initialization
process. (R/W)
)
(re EN
ed
ed
O
G
GT
rv
rv
DO
se
se
DO
PW
(re
W
31 17 16 15 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0000 Reset
PWDOGEN When this bit is set and Bit[23] (WD) of EMACCONFIG_REG is reset, the WTO field
(Bits[13:0]) is used as watchdog timeout for a received frame. When this bit is cleared, the
watchdog timeout for a received frame is controlled by the setting of Bit[23] (WD) and Bit[20]
(JE) in EMACCONFIG_REG. (R/W)
WDOGTO When Bit[16] (PWE) is set and Bit[23] (WD) of EMACCONFIG_REG is reset, this field is used
as watchdog timeout for a received frame. If the length of a received frame exceeds the value
of this field, such frame is terminated and declared as an error frame. (R/W)
M
NU
UM
V_
N
DI
V_
H_
DI
T_
T_
OU
OU
K_
K_
)
L
ed
_C
_C
rv
AC
AC
se
EM
EM
(re
31 8 7 4 3 0
EMAC_CLK_OUT_H_DIV_NUM RMII CLK using internal APLL CLK, the half divider number, when
using RMII PHY. (R/W)
EMAC_CLK_OUT_DIV_NUM RMII CLK using internal APLL CLK, the whole divider number, when
using RMII PHY. (R/W)
0M
00
0M
M
_1
_1
0
0
M
M
_1
_1
NU
NU
M
M
L
SE
NU
NU
V_
V_
K_
DI
DI
V_
V_
H_
H_
CL
DI
DI
C_
C_
C_
C_
C_
)
S
ed
_O
_O
_O
_O
_O
rv
AC
AC
AC
AC
AC
se
EM
EM
EM
EM
EM
(re
31 25 24 23 18 17 12 11 6 5 0
0 0 0 0 0 0 0 0 0 1 9 19 Reset
EMAC_OSC_CLK_SEL Ethernet work using external PHY output clock or not for RMII CLK, when
using RMII PHY. When this bit is set to 1, external PHY CLK is used. When this bit is set to 0, APLL
CLK is used. (R/W)
TX N
N
A d LK_ X_E
_E
N
SC N
_E
_O _E
EM rve I_C _R
XT C
se MI LK
S
_E O
(re C_ I_C
AC INT_
)
EM C_ )
EM C_ )
ed
A d
A MI
EM rve
rv
se
se
(re
(re
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
L
SE
F_
NT
_I
HY
)
d)
ed
_P
ve
rv
r
AC
se
se
EM
(re
(re
31 16 15 13 12 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EMAC_PHY_INTF_SEL The PHY interface selected. 0x0: PHY MII, 0x4: PHY RMII. (R/W)
EN
D_
_P
AM
)
ed
_R
rv
AC
se
EM
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EMAC_RAM_PD_EN Ethernet RAM power-down enable signal. Bit[0]: TX SRAM; Bit[1]: RX SRAM.
Setting the bit to 1 powers down the RAM. (R/W)
11.1 Overview
An I2C (Inter-Integrated Circuit) bus can be used for communication with several external devices connected
to the same bus as ESP32. The ESP32 has dedicated hardware to communicate with peripherals on the I2C
bus.
11.2 Features
The I2C controller has the following features:
• Supports continuous data transmission with disabled Serial Clock Line (SCL)
Communication starts when a master sends out a start condition: it will pull the SDA line low, and will then pull
the SCL line high. It will send out nine clock pulses over the SCL line. The first eight pulses are used to shift
out a byte consisting of a 7-bit address and a read/write bit. If a slave with this address is active on the bus,
the slave can answer by pulling the SDA low on the ninth clock pulse. The master can then send out more 9-bit
clock pulse clusters and, depending on the read/write bit sent, the device or the master will shift out data on
the SDA line, with the other side acknowledging the transfer by pulling the SDA low on the ninth clock pulse.
During data transfer, the SDA line changes only when the SCL line is low. When the master has finished the
communication, it will send a stop condition on the bus by raising SDA, while SCL will already be high.
The ESP32 I2C peripheral can handle the I2C protocol, freeing up the processor cores for other tasks.
11.3.2 Architecture
An I2C controller can operate either in master mode or slave mode. The I2C_MS_MODE register is used to
select the mode. Figure 11-1 shows the I2C Master architecture, while Figure 11-2 shows the I2C Slave architec-
ture.
• RAM, the size of which is 32 x 8 bits, and it is directly mapped onto the address space of the CPU cores,
starting at address REG_I2C_BASE+0x100. Each byte of I2C data is stored in a 32-bit word of memory (so,
the first byte is at +0x100, the second byte at +0x104, the third byte at +0x108, etc.) Users need to set
register I2C_NONFIFO_EN.
• A CMD_Controller and 16 command registers (cmd0 ~ cmd15), which are used by the I2C Master to control
data transmission. One command at a time is executed by the I2C controller.
• SCL_FSM: A state machine that controls the SCL clock. The I2C_SCL_HIGH_PERIOD_REG and I2C_SCL_
LOW_PERIOD_REG registers are used to configure the frequency and duty cycle of the signal on the SCL
line.
• DATA_Shifter which converts the byte data to an outgoing bitstream, or converts an incoming bitstream to
byte data. I2C_RX_LSB_FIRST and I2C_TX_LSB_FIRST can be used for configuring whether the LSB or
MSB is stored or transmitted first.
• SCL_Filter and SDA_Filter: Input noise filter for the I2C_Slave. The filter can be enabled or disabled by
configuring I2C_SCL_FILTER_EN and I2C_SDA_FILTER_EN. The filter can remove line glitches with pulse
width less than I2C_SCL_FILTER_THRES and I2C_SDA_FILTER_THRES ABP clock cycles.
Figure 11-3 is an I2C sequence chart. When the I2C controller works in master mode, SCL is an output signal. In
contrast, when the I2C controller works in slave mode, the SCL becomes an input signal. The values assigned
to I2C_SDA_HOLD_REG and I2C_SDA_SAMPLE_REG are still valid in slave mode. Users need to configure the
values of I2C_SDA_HOLD_TIME and I2C_SDA_SAMPLE_TIME, according to the host characteristics, for the I2C
slave to receive data properly. Table 11-1 shows available settings of SCL low and high level cycles when SCL is
configured to direct output mode. The settings determine the SCL output frequency fscl .
80 MHz
fscl =
SCL_Low_Level_Cycles + SCL_High_Level_Cycles
According to the I2C protocol, each transmission of data begins with a START condition and ends with a STOP
condition. Data is transmitted by one byte at a time, and each byte has an ACK bit. The receiver informs the
transmitter to continue transmission by pulling down SDA, which indicates an ACK. The receiver can also indicate
it wants to stop further transmission by pulling up the SDA line, thereby not indicating an ACK.
Figure 11-3 also shows the registers that can configure the START bit, STOP bit, SDA hold time, and SDA sample
time.
Notice: If the I2C pads are configured in open-drain mode, it will take longer for the signal lines to transition from
a low level to a high level. The transition duration is determined together by the pull-up resistor and capacitor.
The output frequency of SCL is relatively low in open-drain mode.
The Command register is active only in I2C master mode, with its internal structure shown in Figure 11-4.
CMD_DONE: The CMD_DONE bit of every command can be read by software to tell if the command has been
handled by hardware.
op_code: op_code is used to indicate the command. The I2C controller supports four commands:
• RSTART: op_code = 0 is the RSTART command to control the transmission of a START or RESTART I2C
condition.
• WRITE: op_code = 1 is the WRITE command for the I2C Master to transmit data.
• READ: op_code = 2 is the READ command for the I2C Master to receive data.
• STOP: op_code = 3 is the STOP command to control the transmission of a STOP I2C condition.
• END: op_code = 4 is the END command for continuous data transmission. When the END command is
given, SCL is temporarily disabled to allow software to reload the command and data registers for subse-
quent events before resuming. Transmission will then continue seamlessly.
A complete data transmission process begins with an RSTART command, and ends with a STOP command.
ack_value: When receiving data, this bit is used to indicate whether the receiver will send an ACK after this byte
has been received.
ack_exp: This bit is to set an expected ACK value for the transmitter.
ack_check_en: When transmitting a byte, this bit enables checking the ACK value received against the ack_exp
value. Checking is enabled by 1, while 0 disables it.
byte_num: This register specifies the length of data (in bytes) to be read or written. The maximum length is
255, while the minimum is 1. When the op_code is RSTART, STOP or END, this value is meaningless.
In all subsequent figures that illustrate I2C transactions and behavior, both the I2C Master and Slave devices
are assumed to be ESP32 I2C peripheral controllers for ease of demonstration.
Figure 11-5 shows the I2C Master writing N bytes of data to an I2C Slave. According to the I2C protocol, the first
byte is the Slave address. As shown in the diagram, the first byte of the RAM unit has been populated with the
Slave’s 7-bit address plus the 1-bit read/write flag. In this case, the flag is zero, indicating a write operation. The
rest of the RAM unit holds N bytes of data ready for transmission. The cmd unit has been populated with the
sequence of commands for the operation.
For the I2C master to begin an operation, the bus must not be busy, i.e. the SCL line must not be pulled low
by another device on the I2C bus. The I2C operation can only begin when the SCL line is released (made
high) to indicate that the I2C bus is free. After the cmd unit and data are prepared, I2C_TRANS_START bit in
I2C_CTR_REG must be set to begin the configured I2C Master operation. The I2C Master then initiates a START
condition on the bus and progresses to the WRITE command which will fetch N+1 bytes from RAM and send
them to the Slave. The first of these bytes is the address byte.
When the transmitted data size exceeds I2C_NONFIFO_TX_THRES, an I2C_TX_SEND_EMPTY_INT interrupt will
be generated. After detecting the interrupt, software can read TXFIFO_END_ADDR in register RXFIFO_ST_REG,
get the last address of the data in the RAM and refresh the old data in the RAM. TXFIFO_END_ADDR will be
refreshed each time interrupt I2C_TX_SEND_EMPTY_INT or I2C_TRANS_COMPLETE_INT occurs.
When ack_check_en is set to 1, the Master will check the ACK value each time it sends a data byte. If the ACK
value received does not match ack_exp (the expected ACK value) in the WRITE command, then the Master will
generate an I2C_ACK_ERR_INT interrupt and stop the transmission.
During transmission, when the SCL is high, if the input value and output value of SDA do not match, then the
Master will generate an I2C_ARBITRATION_LOST_INT interrupt. When the transmission is finished, the Master
will generate an I2C_TRANS_COMPLETE_INT interrupt.
After detecting the START bit sent from the Master, the Slave will start receiving the address and comparing it
to its own. If the address does not match I2C_SLAVE_ADDR, then the Slave will ignore the rest of the trans-
mission. If they do match, the Slave will store the rest of the data into RAM in the receiving order. When the
data size exceeds I2C_NONFIFO_RX_THRES, an I2C_RX_REC_FULL_INT interrupt is generated. After detecting
the interrupt, software will get the starting and ending addresses in the RAM by reading RXFIFO_START_ADDR
and RXFIFO_END_ADDR bits in register RXFIFO_ST_REG, and fetch the data for further processing. Register RX-
FIFO_START_ADDR is refreshed only once during each transmission, while RXFIFO_END_ADDR gets refreshed
every time when either I2C_RX_REC_FULL_INT or I2C_TRANS_COMPLETE_INT interrupt is generated.
When the END command is not used, the I2C master can transmit up to (14*255-1) bytes of valid data, and the
cmd unit is populated with RSTART + 14 WRITE + 1 STOP.
• If the Master fails to send a STOP bit, because the SDA is pulled low by other devices, then the Master
needs to be reset.
• If the Master fails to send a START bit, because the SDA or SCL is pulled low by other devices, then the
Master needs to be reset. It is recommended that the software uses a timeout period to implement the
reset.
• If the SDA is pulled low by the Slave during transmission, the Master can simply release it by sending it
nine SCL clock signals at the most.
It is important to note that the behaviour of another I2C master or slave device on the bus may not always
be similar to that of the ESP32 I2C peripheral in the master- or slave-mode operation described above. Please
consult the datasheets of the respective I2C devices to ensure proper operation under all bus conditions.
The ESP32 I2C controller uses 7-bit addressing by default. However, 10-bit addressing can also be used. In
the master, this is done by sending a second I2C address byte after the first address byte. In the slave, the
I2C_SLAVE_ADDR_10BIT_EN bit in I2C_SLAVE_ADDR_REG can be set to activate a 10-bit addressing mode.
I2C_SLAVE_ADDR is used to configure the I2C Slave address, as per usual. Figure 11-6 shows the equivalent of
I2C Master operation writing N-bytes of data to an I2C Slave with a 10-bit address. Since 10-bit Slave addresses
require an extra address byte, both the byte_num field of the WRITE command and the number of total bytes in
RAM increase by one.
When the END command is not used, the I2C master can transmit up to (14*255-2) bytes of valid data to Slave
with 10-bit address.
One way many I2C Slave devices are designed is by exposing a register block containing various settings. The
I2C Master can write one or more of these registers by sending the Slave a register address. The ESP32 I2C
Specifically, on the Slave, I2C_FIFO_ADDR_CFG_EN can be set so that the I2C Master can write to a specified
register address inside the I2C Slave memory block. Figure 11-7 shows the Master writing N-bytes of data byte0
~ byte(N-1) from the RAM unit to register address M (determined by addrM in RAM unit) with the Slave. In this
mode, Slave can receive up to 32 bytes of valid data. When Master needs to transmit extra amount of data,
segmented transmission can be enabled.
Figure 11-7. I2C Master Writes to addrM in RAM of Slave with 7-bit Address
If the data size exceeds the capacity of a 14-byte read/write cmd, the END command can be called to en-
able segmented transmission. Figure 11-8 shows the Master writing data to the Slave, in three segments. The
first segment shows the configuration of the Master’s commands and the preparation of data in the RAM unit.
When the I2C_TRANS_START bit is enabled, the Master starts transmission. After executing the END command,
the Master will turn off the SCL clock and pull the SCL low to reserve the bus and prevent any other device
from transacting on the bus. The controller will generate an I2C_END_DETECT_INT interrupt to notify the soft-
ware.
Figure 11-8. Master Writes to Slave with 7-bit Address in Three Segments
After detecting an I2C_END_DETECT_INT interrupt, the software can refresh the contents of the cmd and RAM
blocks, as shown in the second segment. Subsequently, it should clear the I2C_END_DETECT_INT interrupt and
resume the transaction by setting the I2C_TRANS_START bit. To stop the transaction, it should configure the
cmd, as the third segment shows, and enable the I2C_TRANS_START bit to generate a STOP bit, after detecting
the I2C_END_DETECT_INT interrupt.
Please note that the other masters on the bus will be starved of bus time between two segments. The bus is
only released after a STOP signal is sent.
Note: When there are more than three segments, the address of an END command in the cmd should not be
altered into another command by the next segment.
Figure 11-9 shows the Master reading N-bytes of data from an Slave with a 7-bit address. At first, the Master
needs to send the address of the Slave, so cmd1 is a WRITE command. The byte that this command sends is
the slave address plus the R/W flag, which in this case is 1 and, therefore, indicates that this is going to be a
read operation. The Slave starts to send data to the Master if the addresses match. The Master will return ACK,
according to the ack_value in the READ command, upon receiving every byte. As can be seen from Figure 11-9,
READ is divided into two segments. The Master replies ACK to N-1 bytes in cmd2 and does not reply ACK to the
single byte READ command in cmd3, i.e., the last transmitted data. Users can configure it as they wish.
When storing the received data, Master will start from the first address in RAM. Byte0 (Slave address + 1-bit R/W
marker bit) will be overwritten.
When the END command is not used, the Master can receive up to (13*255) bytes of valid data. The cmd unit
is populated with RSTART + 1 WRITE + 13 READ + 1 STOP.
Figure 11-10 shows the Master reading data from a slave with a 10-bit address. This mode can be enabled
by setting I2C_SLAVE_ADDR_10BIT_EN bit and preparing data to be sent in the slave RAM. In the Master, two
bytes of RAM are used for a 10-bit address. Finally, the I2C _TRANS_START bit must be set to enable one
transaction.
Figure 11-11 shows the Master reading data from a specified address in the Slave. This mode can be enabled
by setting I2C_FIFO_ADDR_CFG_EN and preparing the data to be read by the master in the Slave RAM block.
Subsequently, the address of the Slave and the address of the specified register (that is, M) have to be deter-
mined by the master. Finally, the I2C_TRANS_START bit must be set in the Master to initiate the read operation,
following which the Slave will fetch N bytes of data from RAM and send them to the Master.
Figure 11-11. Master Reads N Bytes of Data from addrM in Slave with 7-bit Address
Figure 11-12 shows the Master reading N+M bytes of data in three segments from the Slave. The first segment
shows the configuration of the cmd and the preparation of data in the Slave RAM. When the I2C_TRANS_START
bit is enabled, the Master starts the operation. The Master will refresh the cmd after executing the END com-
mand. It will clear the I2C_END_DETECT_INT interrupt, set the I2C_TRANS_START bit and resume the transac-
tion. To stop the transaction, the Master will configure the cmd, as the third segment shows, after detecting
the I2C_END_DETECT_INT interrupt. After setting the I2C_TRANS_START bit, Master will send a STOP bit to stop
the transaction.
Figure 11-12. Master Reads from Slave with 7-bit Address in Three Segments
11.3.7 Interrupts
• I2C_TX_SEND_EMPTY_INT: Triggered when the Master or Slave has sent nonfifo_tx_thres bytes of data.
• I2C_RX_REC_FULL_INT: Triggered when the Master or Slave has received nonfifo_rx_thres bytes of data.
• I2C_ACK_ERR_INT: Triggered when the Master receives an ACK that is not as expected, or when the Slave
receives an ACK whose value is 1.
• I2C_TRANS_START_INT: Triggered when the Master or Slave sends the START bit.
• I2C_TIME_OUT_INT: Triggered when the SCL stays high or low for more than I2C_TIME_OUT clocks.
• I2C_ARBITRATION_LOST_INT: Triggered when the Master’s SCL is high, while the output value and input
value of the SDA do not match.
• I2C_END_DETECT_INT: Triggered when the Master deals with the END command.
11.5 Registers
The addresses in parenthesis besides register names are the register addresses relative to the I2C base address
provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute register
addresses are listed in Section 11.4 Register Summary.
D
IO
ER
_P
W
LO
d)
L_
ve
SC
r
se
C_
(re
I2
31 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SCL_LOW_PERIOD This register is used to configure for how long SCL remains low in master
mode, in APB clock cycles. (R/W)
RC OU EL
FO E_ EV
T
E_ T
OU
A_ RC _L
C_ N F T
(re S S_S RST
I2 rve O RT
I2 TRA B_ IRS
SD FO CL
se _M TA
C_ L_ _S
C_ d DE
I
C_ L F
I2 TX_ SB_
I2 SC LE
S
P
)
I2 SA )
C_ _L
ed
C_ M
I2 RX
rv
M
se
C_
(re
I2
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 Reset
I2C_RX_LSB_FIRST This bit is used to control the storage mode for received data. (R/W)
1: receive data from the least significant bit;
0: receive data from the most significant bit.
I2C_TX_LSB_FIRST This bit is used to control the sending mode for data needing to be sent. (R/W)
1: send data from the least significant bit;
0: send data from the most significant bit.
I2C_TRANS_START Set this bit to start sending the data in txfifo. (R/W)
I2C_MS_MODE Set this bit to configure the module as an I2C Master. Clear this bit to configure the
module as an I2C Slave. (R/W)
I2C_SAMPLE_SCL_LEVEL 1: sample SDA data on the SCL low level; 0: sample SDA data on the
SCL high level. (R/W)
T
LAS
D
E_
SE
ST
AT
C_ B_ SY S
LA
I2 AR BU DRE
ST
I2 BU E_A S
E_
NT
T
N_
K_ RW
N
C_ E ST
C_ S_ D
C_ AV T
C_ AV A
AT
_C
C
_C
AI
I2 SL OU
I2 SL _TR
I2 TIM LO
RE
ST
AC E_
M
FO
FO
_
)
d)
I2 BY )
L_
L_
C_ TE
ed
ed
C_ d
FI
FI
ve
I2 rve
SC
SC
RX
rv
rv
TX
r
se
se
se
se
C_
C_
C_
C_
(re
(re
(re
(re
I2
I2
I2
I2
31 30 28 27 26 24 23 18 17 14 13 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SCL_STATE_LAST This field indicates the states of the state machine used to produce SCL.
(RO)
0: Idle; 1: Start; 2: Negative edge; 3: Low; 4: Positive edge; 5: High; 6: Stop
I2C_SCL_MAIN_STATE_LAST This field indicates the states of the I2C module state machine. (RO)
0: Idle; 1: Address shift; 2: ACK address; 3: Rx data; 4: Tx data; 5: Send ACK; 6: Wait ACK
I2C_TXFIFO_CNT This field stores the amount of received data in RAM. (RO)
I2C_RXFIFO_CNT This field represents the amount of data needed to be sent. (RO)
I2C_SLAVE_ADDRESSED When configured as an I2C Slave, and the address sent by the master is
equal to the address of the slave, then this bit will be of high level. (RO)
I2C_BUS_BUSY 1: the I2C bus is busy transferring data; 0: the I2C bus is in idle state. (RO)
I2C_ARB_LOST When the I2C controller loses control of SCL line, this register changes to 1. (RO)
I2C_TIME_OUT When the I2C controller takes more than I2C_TIME_OUT clocks to receive a data
bit, this field changes to 1. (RO)
I2C_SLAVE_RW When in slave mode, 1: master reads from slave; 0: master writes to slave. (RO)
I2C_ACK_REC This register stores the value of the received ACK bit. (RO)
M
rv
TI
se
C_
(re
I2
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_TIME_OUT_REG This register is used to configure the timeout for receiving a data bit in APB
clock cycles. (R/W)
E N
T_
BI
10
R_
R
DD
DD
_A
_A
E
E
d)
AV
AV
ve
SL
SL
r
se
C_
C_
(re
I2
I2
31 30 15 14 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SLAVE_ADDR_10BIT_EN This field is used to enable the slave 10-bit addressing mode in master
mode. (R/W)
I2C_SLAVE_ADDR When configured as an I2C Slave, this field is used to configure the slave ad-
dress. (R/W)
R
DD
R
DD
_A
_A
RT
R
ND
TA
DD
R
DD
_S
_E
A
T_
A
FO
FO
D_
AR
FI
FI
ST
TX
_E
_T
O_
O_
FO
FO
)
IF
IF
ed
I
XF
XF
XF
XF
rv
R
se
C_
C_
C_
C_
(re
I2
I2
I2
I2
31 20 19 15 14 10 9 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_TXFIFO_END_ADDR This is the offset address of the last sent data, as described
in nonfifo_tx_thres register. The value refreshes when I2C_TX_SEND_EMPTY_INT or
I2C_TRANS_COMPLETE_INT interrupt is generated. (RO)
I2C_TXFIFO_START_ADDR This is the offset address of the first sent data, as described in non-
fifo_tx_thres register. (RO)
I2C_RXFIFO_END_ADDR This is the offset address of the last received data, as de-
scribed in nonfifo_rx_thres_register. This value refreshes when I2C_RX_REC_FULL_INT or
I2C_TRANS_COMPLETE_INT interrupt is generated. (RO)
I2C_RXFIFO_START_ADDR This is the offset address of the last received data, as described in non-
fifo_rx_thres_register. (RO)
EN
S
ES
RE
EN G_
HR
O_ F
_T
_T
IF _C
RX
X
N F DDR
_T
O_
FO
IF
NO _A
FI
d)
d)
F
ON
ON
C_ O
ve
I2 FIF
rv
N
N
r
se
se
C_
C_
C_
(re
(re
I2
I2
I2
31 26 25 20 19 14 13 12 11 10
I2C_NONFIFO_TX_THRES When I2C sends more than nonfifo_tx_thres bytes of data, it will generate
a tx_send_empty_int_raw interrupt and update the current offset address of the sent data. (R/W)
I2C_NONFIFO_RX_THRES When I2C receives more than nonfifo_rx_thres bytes of data, it will gen-
erate a rx_send_full_int_raw interrupt and update the current offset address of the received
data. (R/W)
I2C_FIFO_ADDR_CFG_EN When this bit is set to 1, the byte received after the I2C address byte
represents the offset address in the I2C Slave RAM. (R/W)
AW RA W
_R T_ RA
W
CT OS P_ W
NT IN _
T E _ L M RA
C_ E T _R R W
_I T_ INT
I2 TIM S_S INT INT_ _RA
DE ON CO NT_
I2 TRA OU RT AW AW
I2 AR ER MP RAW W
A
C_ N R_ _ NT
D_ ATI N_ _I
C_ S O _ R
I2 MA S_C INT T_
I2 TRA ER ULL Y_I
EN TR RA TE
_ N
C_ BI _T LE
C_ K_ F PT
C_ N T _I
I2 AC EC_ EM
_ A
C_ _R _
I2 RX END
d)
T
C_ S
ve
I2 TX_
r
se
C_
(re
I2
31 13 12 11 10 9 8 7 6 5 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_TX_SEND_EMPTY_INT_RAW The raw interrupt status bit for the I2C_TX_SEND_EMPTY_INT in-
terrupt. (RO)
I2C_RX_REC_FULL_INT_RAW The raw interrupt status bit for the I2C_RX_REC_FULL_INT interrupt.
(RO)
I2C_ACK_ERR_INT_RAW The raw interrupt status bit for the I2C_ACK_ERR_INT interrupt. (RO)
I2C_TRANS_START_INT_RAW The raw interrupt status bit for the I2C_TRANS_START_INT interrupt.
(RO)
I2C_TIME_OUT_INT_RAW The raw interrupt status bit for the I2C_TIME_OUT_INT interrupt. (RO)
I2C_END_DETECT_INT_RAW The raw interrupt status bit for the I2C_END_DETECT_INT interrupt.
(RO)
LR CL R
_C T_ CL
R
CT OS P_ R
NT IN _
TE _L M CL
_I T_ INT
C_ E T _C C R
I2 TIM S_S INT INT_ _CL
DE ON CO NT_
I2 TRA OU RT LR LR
I2 AR ER MP LR R
C L
C_ N R_ _ NT
D_ ATI N_ _I
C_ S O _ C
I2 MA S_C INT T_
I2 TRA ER ULL Y_I
EN TR RA TE
_ N
C_ BI _T LE
C_ K_ F PT
C_ N T _I
I2 AC EC_ EM
_ A
C_ _R _
I2 RX END
)
T
ed
C_ S
I2 TX_
rv
se
C_
(re
I2
31 13 12 11 10 9 8 7 6 5 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
NA EN A
_E T_ EN
A
CT OS P_ A
NT IN _
TE _L M EN
C_ E T _E E A
_I T_ INT
I2 TIM S_S INT INT_ _EN
DE ON CO NT_
I2 TRA OU RT NA NA
I2 AR ER MP ENA A
C_ S O _ EN
C_ N R_ _ NT
D_ ATI N_ _I
I2 MA S_C INT T_
I2 TRA ER ULL Y_I
EN TR RA TE
_ N
C_ BI _T LE
C_ K_ F PT
C_ N T _I
I2 AC EC_ EM
_ A
C_ _R _
I2 RX END
)
T
ed
C_ S
I2 TX_
rv
se
C_
(re
I2
31 13 12 11 10 9 8 7 6 5 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_ACK_ERR_INT_ENA The interrupt enable bit for the I2C_ACK_ERR_INT interrupt. (R/W)
I2C_TIME_OUT_INT_ENA The interrupt enable bit for the I2C_TIME_OUT_INT interrupt. (R/W)
I2C_END_DETECT_INT_ENA The interrupt enable bit for the I2C_END_DETECT_INT interrupt. (R/W)
_S T_ ST
NT IN _
T ST
TE _L M ST
_I T_ INT
I2 TIM S_S INT INT_ _ST
DE ON CO NT_
CT OS P_
I2 TRA OU RT T T
C_ S O _ ST
C_ N R_ _ NT
C_ E T _S S
D_ ATI N_ _I
I2 MA S_C INT T_
I2 TRA ER ULL Y_I
EN TR RA TE
I2 AR ER MP T
_ N
S
C_ BI _T LE
C_ K_ F PT
C_ N T _I
I2 AC EC_ EM
_ A
C_ _R _
I2 RX END
)
T
ed
C_ S
I2 TX_
rv
se
C_
(re
I2
31 13 12 11 10 9 8 7 6 5 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_RX_REC_FULL_INT_ST The masked interrupt status bit for the I2C_RX_REC_FULL_INT inter-
rupt. (RO)
I2C_ACK_ERR_INT_ST The masked interrupt status bit for the I2C_ACK_ERR_INT interrupt. (RO)
I2C_TRANS_START_INT_ST The masked interrupt status bit for the I2C_TRANS_START_INT interrupt.
(RO)
I2C_TIME_OUT_INT_ST The masked interrupt status bit for the I2C_TIME_OUT_INT interrupt. (RO)
I2C_END_DETECT_INT_ST The masked interrupt status bit for the I2C_END_DETECT_INT interrupt.
(RO)
A_
ed
SD
rv
se
C_
(re
I2
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SDA_HOLD_TIME This register is used to configure the time to hold the data after the negative
edge of SCL, in APB clock cycles. (R/W)
E
M
TI
E_
PL
M
SA
d)
A_
ve
SD
r
se
C_
(re
I2
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SDA_SAMPLE_TIME This register is used to configure for how long SDA is sampled, in APB
clock cycles. (R/W)
D
IO
ER
_P
GH
HI
)
L_
ed
SC
rv
se
C_
(re
I2
31 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SCL_HIGH_PERIOD This register is used to configure for how long SCL remains high in master
mode, in APB clock cycles. (R/W)
E
M
TI
D_
OL
_H
A RT
ST
)
L_
ed
SC
rv
se
C_
(re
I2
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Reset
I2C_SCL_START_HOLD_TIME This register is used to configure the time between the negative edge
of SDA and the negative edge of SCL for a START condition, in APB clock cycles. (R/W)
E
IM
_T
UP
ET
_S
RT
TA
RS
)
L_
ed
SC
rv
se
C_
(re
I2
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Reset
I2C_SCL_RSTART_SETUP_TIME This register is used to configure the time between the positive
edge of SCL and the negative edge of SDA for a RESTART condition, in APB clock cycles. (R/W)
E
T IM
D_
H OL
O P_
ST
)
L_
ed
SC
rv
se
C_
(re
I2
31 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SCL_STOP_HOLD_TIME This register is used to configure the delay after the STOP condition,
in APB clock cycles. (R/W)
L_
ed
SC
rv
se
C_
(re
I2
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SCL_STOP_SETUP_TIME This register is used to configure the time between the positive edge
of SCL and the positive edge of SDA, in APB clock cycles. (R/W)
ES
HR
N
_E
_T
ER
ER
LT
LT
FI
FI
d)
L_
L_
ve
SC
SC
r
se
C_
C_
(re
I2
I2
31 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Reset
I2C_SCL_FILTER_THRES When a pulse on the SCL input has smaller width than this register value
in APB clock cycles, the I2C controller will ignore that pulse. (R/W)
ES
HR
N
_E
_T
ER
ER
LT
LT
FI
FI
)
A_
A_
ed
SD
SD
rv
se
C_
C_
(re
I2
I2
31 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Reset
I2C_SDA_FILTER_THRES When a pulse on the SDA input has smaller width than this register value
in APB clock cycles, the I2C controller will ignore that pulse. (R/W)
Dn
AN
AN
M
M
)
ed
M
M
CO
CO
rv
se
C_
C_
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_COMMANDn_DONE When command n is done in I2C Master mode, this bit changes to high
level. (R/W)
12.1 Overview
The I2S bus provides a flexible communication interface for streaming digital data in multimedia applications,
especially digital audio applications. The ESP32 includes two I2S interfaces: I2S0 and I2S1.
The I2S standard bus defines three signals: a clock signal, a channel selection signal, and a serial data signal. A
basic I2S data bus has one master and one slave. The roles remain unchanged throughout the communication.
The I2S modules on the ESP32 provide separate transmit and receive channels for high performance.
Figure 12-1 is the system block diagram of the ESP32 I2S module. In the figure above, the value of ”n” can be
either 0 or 1. There are two independent I2S modules embedded in ESP32, namely I2S0 and I2S1. Each I2S
module contains a Tx (transmit) unit and a Rx (receive) unit. Both the Tx unit and the Rx unit have a three-wire
interface that includes a clock line, a channel selection line and a serial data line. The serial data line of the Tx
unit is fixed as output, and the serial data line of the Rx unit is fixed as input. The clock line and the channel
selection line of the Tx and Rx units can be configured to both master transmitting mode and slave receiving
mode. In the LCD mode, the serial data line extends to the parallel data bus. Both the Tx unit and the Rx unit
have a 32-bit-wide FIFO with a depth of 64. Besides, only I2S0 supports on-chip DAC/ADC modes, as well as
receiving and transmitting PDM signals.
The right side of Figure 12-1 shows the signal bus of the I2S module. The signal naming rule of the Rx and Tx
units is I2SnA_B_C, where ”n” stands for either I2S0 or I2S1; ”A” represents the direction of I2S module’s data
bus signal, ”I” represents input, ”O” represents output; ”B” represents signal function; ”C” represents the signal
direction, ”in” means that the signal is input into the I2S module, while ”out” means that the I2S module outputs
the signal. For a detailed description of the I2S signal bus, please refer to Table 12-1. Table 12-1 describes the
signal bus of the I2S module. Except for the I2Sn_CLK signal, all other signals are mapped to the chip pin via
the GPIO matrix and IO MUX. The I2Sn_CLK signal is mapped to the chip pin via the IO_MUX. For details, please
refer to the chapter about IO_MUX and the GPIO Matrix.
Note:
1. Assume that the bit width of the input/output signal is N, the input signal should be configured to I2SnI_Data_in[N-
1:0], and the output signal to I2SnO_Data_out[23:23-N+1]. Generally, for input signals, N=8 or 16; while for output
signals, N=8, 16 or 24 (note that I2S1 does not support 24-bit width).
2. I2Sn_CLK can only be mapped to GPIO0, U0RXD (GPIO3) or U0TXD (GPIO1) by selecting GPIO functions CLK_OUT1,
CLK_OUT2, or CLK_OUT3. For more information, see Table 4-3: IO_MUX Pad List.
12.2 Features
I2S mode
LCD mode
I2S interrupts
Notice:
• When using PLL_F160M_CLK as the clock source, it is not recommended to divide it using decimals. For
high performance audio applications, the analog PLL output clock source APLL_CLK must be used to
acquire highly accurate I2Sn_CLK and BCK. For further details, please refer to the chapter entitled Reset
and Clock.
• When ESP32 I2S works in slave mode, the master must use I2Sn_CLK as the master clock and fi2s >= 8
* fBCK .
The relation between I2Sn_CLK frequency fi2s and the divider clock source frequency fpll can be seen in the
equation below:
fpll
fi2s = b
N+ a
”N”, whose value is >=2, corresponds to the REG _CLKM_DIV_NUM [7:0] bits of register I2S_CLKM_CONF_REG
, ”b” is the I2S_CLKM_DIV_B[5:0] bit and ”a” is the I2S_CLKM_DIV_A[5:0] bit.
In master mode, the serial clock BCK in the I2S module is derived from I2Sn_CLK, that is:
fi2s
fBCK =
M
In master transmitting mode, ”M”, whose value is >=2, is the I2S_TX_BCK_DIV_NUM[5:0] bit of register I2S_SAMPLE
_RATE_CONF_REG. In master receiving mode, ”M” is the I2S_RX_BCK_DIV_NUM[5:0] bit of register I2S_SAMPLE
_RATE_CONF_REG.
As is shown in Figure 12-3, the Philips I2S bus specifications require that the WS signal starts to change one
BCK clock cycle earlier than the SD signal on BCK falling edge, which means the WS signal becomes valid one
clock cycle before the first bit of data transfer on the current channel, and changes one clock cycle earlier than
the end of data transfer on the current channel. The SD signal line transmits the most significant bit of audio
data first. If the I2S_RX_MSB_SHIFT bit and the I2S_TX_MSB_SHIFT bit of register I2S_CONF_REG are set to 1,
respectively, the I2S module will use the Philips standard when receiving and transmitting data.
The MSB alignment standard is shown in Figure 12-4. WS and SD signals both change simultaneously on the
falling edge of BCK under the MSB alignment standard. The WS signal continues until the end of the current
channel-data transmission, and the SD signal line transmits the most significant bit of audio data first. If the
I2S_RX_MSB_SHIFT and I2S_TX_MSB_SHIFT bits of register I2S_CONF_REG are cleared, the I2S module will
use the MSB alignment standard when receiving and transmitting data.
Generally, both the I2S_RX_FIFO_MOD_FORCE_EN bit and I2S_TX_FIFO_MOD_FORCE_EN bits of register I2S_
FIFO_CONF_REG should be set to 1. I2S_TX_DATA_NUM[5:0] bit and I2S_RX_DATA_NUM[5:0] are used to
control the length of the data that have been sent, received and buffered. Hardware inspects the received-data
length RX_LEN and the transmitted-data length TX_LEN. Both the received and the transmitted data are buffered
in the FIFO method.
When RX_LEN is greater than I2S_RX_DATA_NUM[5:0], the received data, which is buffered in FIFO, has reached
the set threshold and needs to be read out to prevent an overflow. When TX_LEN is less than I2S_TX_DATA_NUM[5:0],
the transmitted data, which is buffered in FIFO, has not reached the set threshold and software can continue
feeding data into FIFO.
I2S_TX_FIFO_MOD[2:0] Description
0 16-bit dual channel data
Tx FIFO mode0 2 32-bit dual channel data
3 32-bit single channel data
Tx FIFO mode1 1 16-bit single channel data
At the first stage, there are two modes for data to be sent and written into FIFO. In Tx FIFO mode0, the Tx data-
to-be-sent are written into FIFO according to the time order. In Tx FIFO mode1, the data-to-be-sent are divided
into 16 high- and 16 low-order bits. Then, both the 16 high- and 16 low-order bits are recomposed and written
′
into FIFO. The details are shown in Figure 12-6 with the corresponding registers listed in Table 12-2. Dn consists
′′
of 16 high-order bits of Dn and 16 zeros. Dn consists of 16 low-order bits of Dn and 16 zeros. That is to say,
′ ′′
Dn = {Dn [31 : 16], 16′ h0}, Dn = {Dn [15 : 0], 16′ h0}.
At the second stage, the system reads data that will be sent from FIFO, according to the relevant regis-
ter configuration. The mode in which the system reads data from FIFO is relevant to the configuration of
I2S_TX_CHAN_MOD[2:0] Description
0 Dual channel mode
Mono mode
When I2S_TX_MSB_RIGHT equals 0, the left-channel data are ”holding”
1 their values and the right-channel data change into the left-channel data.
When I2S_TX_MSB_RIGHT equals 1, the right-channel data are ”holding”
their values and the left-channel data change into the right-channel data.
Mono mode
When I2S_TX_MSB_RIGHT equals 0, the right-channel data are ”hold-
2 ing” their values and the left-channel data change into the right-channel
data.
When I2S_TX_MSB_RIGHT equals 1, the left-channel data are ”holding”
their values and the right-channel data change into the left-channel data.
Mono mode
When I2S_TX_MSB_RIGHT equals 0, the left-channel data are constants
3 in the range of REG[31:0].
When I2S_TX_MSB_RIGHT equals 1, the right-channel data are constants
in the range of REG[31:0].
Mono mode
When I2S_TX_MSB_RIGHT equals 0, the right-channel data are con-
4 stants in the range of REG[31:0].
When I2S_TX_MSB_RIGHT equals 1, the left-channel data are constants
in the range of REG[31:0].
The output of the third stage is determined by the mode of the I2S and I2S_TX_BITS_MOD[5:0] bits of register
I2S_SAMPLE_RATE_CONF_REG.
• The input serial-bit stream is transformed into a 64-bit parallel-data stream in I2S mode. In LCD mode, the
input parallel-data stream will be extended to a 64-bit parallel-data stream.
• Data are read from FIFO by CPU/DMA and written into the internal memory.
At the first stage of receiving data, the received-data stream is expanded to a zero-padded parallel-data stream
with 32 high-order bits and 32 low-order bits, according to the level of the I2SnI_WS_out (or I2SnI_WS_in)
signal. The I2S_RX_MSB_RIGHT bit of register I2S_CONF_REG is used to determine how the data are to be
expanded.
For example, as is shown in Figure 12-7, if the width of serial data is 16 bits, when I2S_RX_RIGHT_FIRST equals
1, Data0 will be discarded and I2S will start receiving data from Data1. If I2S_RX_MSB_RIGHT equals 1, data
of the first stage would be {0xF EDC0000, 0x32100000}. If I2S_RX_MSB_RIGHT equals 0, data of the first
stage would be {0x32100000, 0xF EDC0000}. When I2S_RX_RIGHT_FIRST equals 0, I2S will start receiving
data from Data0. If I2S_RX_MSB_RIGHT equals 1, data of the first stage would be {0xF EDC0000, 0x76540000}.
If I2S_RX_MSB_RIGHT equals 0, data of the first stage would be {0x76540000, 0xF EDC0000}.
As is shown in Table 12-4 and Figure 12-8, at the second stage, the received data of the Rx unit is written
into FIFO. There are four modes of writing received data into FIFO. Each mode corresponds to a value of
I2S_RX_FIFO_MOD[2:0] bit.
Table 12-4. Modes of Writing Received Data into FIFO and the Corresponding Register Configuration
At the third stage, CPU or DMA will read data from FIFO and write them into the internal memory directly. The
register configuration that each mode corresponds to is shown in Table 12-5.
Table 12-5. The Register Configuration to Which the Four Modes Correspond
I2S_RX_SLAVE_MOD bit and I2S_TX_SLAVE_MOD bit of register I2S_CONF_REG can configure I2S to slave
receiving mode and slave transmitting mode, respectively.
I2S_TX_START bit of register I2S_CONF_REG is used to enable transmission. When I2S is in master transmitting
mode and this bit is set, the module will keep driving the clock signal and data of left and right channels. If
FIFO sends out all the buffered data and there are no new data to shift, the last batch of data will be looped
on the data line. When this bit is reset, master will stop driving clock and data lines. When I2S is configured to
slave transmitting mode and this bit is set, the module will wait for the master BCK clock to enable a transmit
operation.
The I2S_RX_START bit of register I2S_CONF_REG is used to enable a receive operation. When I2S is in master
receiving mode and this bit is set, the module will keep driving the clock signal and sampling the input data
stream until this bit is reset. If I2S is configured to slave receiving mode and this bit is set, the receiving module
will wait for the master BCK clock to enable a receiving operation.
The output clock of PDM is mapped to the I2S0*_WS_out signal. Its configuration is identical to I2S’s BCK.
Please refer to section 12.3, ”The Clock of I2S Module”, for further details. The bit width for both received and
transmitted I2S PCM signals is 16 bits.
The PDM transmitting module is used to convert PCM signals into PDM signals, as shown in Figure 12-9. HPF
is a high-speed channel filter, and LPF is a low-speed channel filter. The PDM signal is derived from the PCM
signal, after upsampling and filtering. Signal I2S_TX_PDM_HP_BYPASS of register I2S_PDM_CONF_REG can be
set to bypass the HPF at the PCM input. Filter module group0 carries out the upsampling. If the frequency of
the PDM signal is fpdm and the frequency of the PCM signal is fpcm , the relation between fpdm and fpcm is given
by:
I2S_T X_P DM _F P
fpdm = 64×fpcm ×
I2S_T X_P DM _F S
The upsampling factor of 64 is the result of the two upsampling stages.
Table 12-6 lists the configuration rates of the I2S_TX_PDM_FP bit and the I2S_TX_PDM_FS bit of register
I2S_PDM
_FREQ_CONF_REG, whose output PDM signal frequency remains 48×128 KHz at different PCM signal frequen-
cies.
The I2S_TX_PDM_SINC_OSR2 bit of I2S_PDM_CONF_REG is the upsampling rate of the Filter group0.
I2S_T X_P DM _F P
I2S_T X_P DM _SIN C_OSR2 =
I2S_T X_P DM _F S
As is shown in Figure 12-10, the I2S_TX_PDM_EN bit and the I2S_PCM2PDM_CONV_EN bit of register I2S_PDM_
CONF_REG should be set to 1 to use the PDM sending module. The I2S_TX_PDM_SIGMADELTA_IN_SHIFT bit,
I2S_TX_PDM_SINC_IN_SHIFT bit, I2S_TX_PDM_LP_IN_SHIFT bit and I2S_TX_PDM_HP_IN_SHIFT bit of register
I2S_PDM_CONF_REG are used to adjust the size of the input signal of each filter module.
As is shown in Figure 12-11, the I2S_RX_PDM_EN bit and the I2S_PDM2PCM_CONV_EN bit of register I2S_PDM_
CONF_REG should be set to 1, in order to use the PDM receiving module. As is shown in Figure 12-12, the
PDM receiving module will convert the received PDM signal into a 16-bit PCM signal. Filter group1 is used to
downsample the PDM signal, and the I2S_RX_PDM_SINC_DSR_16_EN bit of register I2S_PDM_CONF_REG is
used to adjust the corresponding down-sampling rate.
Table 12-7 shows the configuration of the I2S_RX_PDM_SINC_DSR_16_EN bit whose PCM signal frequency
remains 48 KHz at different PDM signal frequencies.
• ADC/DAC mode
The clock configuration of the LCD master transmitting mode is identical to I2S’ clock configuration. In the LCD
mode, the frequency of WS is half of f BCK .
The I2S_LCD_EN bit of register I2S_CONF2_REG needs to be set and the I2S_TX_SLAVE_MOD bit of register
I2S_CONF_REG needs to be cleared, in order to configure I2S to the LCD master transmitting mode. Mean-
while, data should be sent under the correct mode, according to the I2S_TX_CHAN_MOD[2:0] bit of regis-
ter I2S_CONF_CHAN_REG and the I2S_TX_FIFO_MOD[2:0] bit of register I2S_FIFO_CONF_REG. The WS signal
needs to be inverted when it is routed through the GPIO Matrix. For details, please refer to the chapter about
IO_MUX and the GPIO Matrix. The I2S_LCD_TX_SDX2_EN bit and the I2S_LCD_TX_WRX2_EN bit of register
I2S_CONF2_REG should be set to the LCD master transmitting mode, so that both the data bus and WR signal
work in the appropriate mode.
As is shown in Figure 12-14 and Figure 12-15, the I2S_LCD_TX_WRX2_EN bit should be set to 1 and the I2S_LCD_TX_SDX2_EN
bit should be set to 0 in the data frame, form 1. Both I2S_LCD_TX_SDX2_EN bit and I2S_LCD_TX_WRX2_EN bit
are set to 1 in the data frame, form 2.
I2SnI_Data_in, there are other signals, such as I2Sn_H_SYNC, I2Sn_V_SYNC and I2Sn_H_ENABLE.
The PCLK in the Camera module connects to I2SnI_WS_in in the I2S module, as Figure 12-16 shows.
When I2S is in the camera slave receiving mode, and when I2Sn_H_SYNC, I2S_V_SYNC and I2S_H_REF are
held high, the master starts transmitting data, that is,
Thus, during data transmission, these three signals should be kept at a high level. For example, if the I2Sn_V_SYNC
signal of a camera is at low level during data transmission, it will be inverted when routed to the I2S module.
ESP32 supports signal inversion through the GPIO matrix. For details, please refer to the chapter about IO_MUX
and the GPIO Matrix.
In order to make I2S work in camera mode, the I2S_LCD_EN bit and the I2S_CAMERA_EN bit of register
I2S_CONF2
_REG are set to 1, the I2S_RX_SLAVE_MOD bit of register I2S_CONF_REG is set to 1, the I2S_RX_MSB_RIGHT
bit and the I2S_RX_RIGHT_FIRST bit of I2S_CONF_REG are set to 0. Thus, I2S works in the LCD slave receiving
mode. At the same time, in order to use the correct mode to receive data, both the I2S_RX_CHAN_MOD[2:0]
bit of register I2S_CONF_CHAN_REG and the I2S_RX_FIFO_MOD[2:0] bit of register I2S_FIFO_CONF_REG are
set to 1.
Firstly, the I2S_LCD_EN bit of register I2S_CONF2_REG is set to 1, and the I2S_RX_SLAVE_MOD bit of register
I2S_CONF_REG is set to 0, so that the I2S0 module works in LCD master receiving mode, and the I2S0 module
clock is configured such that the WS signal of I2S0 outputs an appropriate frequency. Then, the SYSCON_SAR
ADC_DATA_TO_I2S bit of register SYSCON_APB_SARADC_CTRL_REG is set to 1. Enable I2S to receive data after
configuring the relevant registers of SARADC. For details, please refer to Chapter On-Chip Sensors and Analog
Signal Processing.
The I2S0 module should be configured to master transmitting mode when it connects to the on-chip DAC.
Figure 12-18 shows the signal connection between the I2S0 module and the DAC. The DAC’s control module
regards I2S_CLK as the clock in this configuration. As shown in Figure 12-19, when the data bus inputs data to
the DAC’s control module, the latter will input right-channel data to DAC1 module and left-channel data to DAC2
module. When using the I2S DMA module, 8 bits of data-to-be-transmitted are shifted to the left by 8 bits of
data-to-be-received into the DMA double-byte type of buffer.
The I2S_LCD_EN bit of register I2S_CONF2_REG should be set to 1, while I2S_RX_SHORT_SYNC, I2S_TX_SHORT
_SYNC, I2S_CONF_REG , I2S_RX_MSB_SHIFT and I2S_TX_MSB_SHIFT should all be reset to 0. The I2S_TX_
SLAVE_MOD bit of register I2S_CONF_REG should be set to 0, as well, when using the DAC mode of I2S0.
Select a suitable transmit mode according to the standards of transmitting a 16-bit digital data stream. Configure
the I2S0 module clock to output a suitable frequency for the I2S_CLK and the WS of I2S. Enable I2S0 to send
data after configuring the relevant DAC registers.
• I2S_IN_DSCR_EMPTY_INT: Triggered when there are no valid receiving linked lists left.
• I2S_OUT_DONE_INT: Triggered when all transmitted and buffered data have been read.
12.8 Registers
The addresses in parenthesis besides register names are the register addresses relative to the I2S0/I2S1 base
addresses provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 12.7 Register Summary.
G
RE
R_
W
O_
IF
F
S_
I2
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0
I2S_FIFO_RD_REG Stores the data that I2S receives from FIFO. (RO)
I2 TX_ SB SY C
S C
S_ _S E_ OD
S_ S E ST
S_ _R R ET
S_ _M _R T
S_ S T D
S_ _M T N
_R ET ET
S_ _R _S T
S_ M O T
S_ _S T_ S
S_ M _ K
S_ M _ N
S_ R T_ T
I2 RX SB IGH
I2 X_ AR MO
I2 RX SB HIF
I2 TX_ ON IGH
I2 RX HOR _SY
I2 RX IGH FIR
I2 TX_ SB AC
I2 RX FO_ ES
I2 RX LAV M
TX ES ES
_
B
_
R
S_ F _R
S_ S RT
S_ _M P
ET
S_ _S O
S_ _F T
I2 RX OO
I2 RX AR
I2 RX ON
I2 TX_ IFO
I2 TX_ HO
ES
T
T
)
I
ed
S_ _
I2 SIG
rv
T
se
S_
(re
I2
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2S_SIG_LOOPBACK Enable signal loopback mode, with transmitter module and receiver module
sharing the same WS and BCK signals. (R/W)
I2S_RX_MSB_RIGHT Set this to place right-channel data at the MSB in the receive FIFO. (R/W)
I2S_TX_MSB_RIGHT Set this bit to place right-channel data at the MSB in the transmit FIFO. (R/W)
I2S_RX_MONO Set this bit to enable receiver’s mono mode in PCM standard mode. (R/W)
I2S_TX_MONO Set this bit to enable transmitter’s mono mode in PCM standard mode. (R/W)
I2S_RX_SHORT_SYNC Set this bit to enable receiver in PCM standard mode. (R/W)
I2S_TX_SHORT_SYNC Set this bit to enable transmitter in PCM standard mode. (R/W)
I2S_RX_MSB_SHIFT Set this bit to enable receiver in Philips standard mode. (R/W)
I2S_TX_MSB_SHIFT Set this bit to enable transmitter in Philips standard mode. (R/W)
se T_ F_ _I T_ W
S_ T_ _ RR NT W
S_ d NE R R W
(re OU EO ERR _IN _RA
AW
I2 OU SCR _E Y_I RA
NT W
W
_T _D NT_ AW
_I A
S_ D CR PT T_
_R
S_ _W PT T_ W
AW
S_ _H G_ _R A
E_ A_ AW
TA T_R
I2 TX_ FU Y_I RAW
I2 RX EM _IN _RA
I2 RX FUL Y_I AW
I2 RX UN INT T_R
I2 IN_ DS EM _IN
I2 TX_ EM INT AW
I2 TX_ UN INT AW
RX UT _I T_R
_R
AK AT R
DA IN
R
S_ T_ _ OF
S_ R G_ _R
S_ _R L NT
S_ H _ IN
NT
S_ W PT _
S_ P LL N
I2 TX_ ONE F_
I2 OU SCR _E
O
L
S_ D E
S_ D A
I2 IN_ C_
I2 IN_ TOT
U
d)
I2 IN_ )
S_ T_
S_ S
ve
I2 OU
r
se
S_
(re
I2
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2S_OUT_TOTAL_EOF_INT_RAW The raw interrupt status bit for the I2S_OUT_TOTAL_EOF_INT inter-
rupt. (RO)
I2S_IN_DSCR_EMPTY_INT_RAW The raw interrupt status bit for the I2S_IN_DSCR_EMPTY_INT in-
terrupt. (RO)
I2S_OUT_DSCR_ERR_INT_RAW The raw interrupt status bit for the I2S_OUT_DSCR_ERR_INT inter-
rupt. (RO)
I2S_IN_DSCR_ERR_INT_RAW The raw interrupt status bit for the I2S_IN_DSCR_ERR_INT interrupt.
(RO)
I2S_OUT_EOF_INT_RAW The raw interrupt status bit for the I2S_OUT_EOF_INT interrupt. (RO)
I2S_OUT_DONE_INT_RAW The raw interrupt status bit for the I2S_OUT_DONE_INT interrupt. (RO)
I2S_IN_SUC_EOF_INT_RAW The raw interrupt status bit for the I2S_IN_SUC_EOF_INT interrupt.
(RO)
I2S_IN_DONE_INT_RAW The raw interrupt status bit for the I2S_IN_DONE_INT interrupt. (RO)
I2S_TX_HUNG_INT_RAW The raw interrupt status bit for the I2S_TX_HUNG_INT interrupt. (RO)
I2S_RX_HUNG_INT_RAW The raw interrupt status bit for the I2S_RX_HUNG_INT interrupt. (RO)
I2S_TX_REMPTY_INT_RAW The raw interrupt status bit for the I2S_TX_REMPTY_INT interrupt. (RO)
I2S_TX_WFULL_INT_RAW The raw interrupt status bit for the I2S_TX_WFULL_INT interrupt. (RO)
I2S_RX_REMPTY_INT_RAW The raw interrupt status bit for the I2S_RX_REMPTY_INT interrupt. (RO)
I2S_RX_WFULL_INT_RAW The raw interrupt status bit for the I2S_RX_WFULL_INT interrupt. (RO)
I2S_TX_PUT_DATA_INT_RAW The raw interrupt status bit for the I2S_TX_PUT_DATA_INT interrupt.
(RO)
I2S_RX_TAKE_DATA_INT_RAW The raw interrupt status bit for the I2S_RX_TAKE_DATA_INT interrupt.
(RO)
T
_I T T
S_ D CR PT T_
_I T
_S
se T_ F_ _I T_
S_ T_ _ RR NT
S_ d NE S S
S_ _H G_ _S T
TA T_S
_T _D NT_ T
I2 RX EM _IN _ST
I2 RX UN INT T_S
I2 IN_ DS EM _IN
NT
T
RX UT _I T_S
E_ A_ T
I2 TX_ FU Y_I ST
_S
I2 RX FUL Y_I T
AK AT S
I2 TX_ EM INT T
I2 TX_ UN INT T
DA IN
S
S_ T_ _ OF
S_ R G_ _S
S_ _R L NT
S_ H E_ IN
S_ _W PT T_
NT
S_ W PT _
S_ P LL N
I2 TX_ ON F_
I2 OU SCR _E
O
L
S_ D E
S_ D A
I2 TX_ C_
I2 IN_ TOT
U
)
I2 IN_ )
S_ T_
ed
S_ S
I2 OU
rv
se
S_
(re
I2
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2S_OUT_TOTAL_EOF_INT_ST The masked interrupt status bit for the I2S_OUT_TOTAL_EOF_INT in-
terrupt. (RO)
I2S_OUT_DSCR_ERR_INT_ST The masked interrupt status bit for the I2S_OUT_DSCR_ERR_INT in-
terrupt. (RO)
I2S_IN_DSCR_ERR_INT_ST The masked interrupt status bit for the I2S_IN_DSCR_ERR_INT inter-
rupt. (RO)
I2S_OUT_EOF_INT_ST The masked interrupt status bit for the I2S_OUT_EOF_INT interrupt. (RO)
I2S_OUT_DONE_INT_ST The masked interrupt status bit for the I2S_OUT_DONE_INT interrupt. (RO)
I2S_IN_SUC_EOF_INT_ST The masked interrupt status bit for the I2S_IN_SUC_EOF_INT interrupt.
(RO)
I2S_IN_DONE_INT_ST The masked interrupt status bit for the I2S_IN_DONE_INT interrupt. (RO)
I2S_TX_HUNG_INT_ST The masked interrupt status bit for the I2S_TX_HUNG_INT interrupt. (RO)
I2S_RX_HUNG_INT_ST The masked interrupt status bit for the I2S_RX_HUNG_INT interrupt. (RO)
I2S_TX_REMPTY_INT_ST The masked interrupt status bit for the I2S_TX_REMPTY_INT interrupt.
(RO)
I2S_TX_WFULL_INT_ST The masked interrupt status bit for the I2S_TX_WFULL_INT interrupt. (RO)
I2S_RX_REMPTY_INT_ST The masked interrupt status bit for the I2S_RX_REMPTY_INT interrupt.
(RO)
I2S_RX_WFULL_INT_ST The masked interrupt status bit for the I2S_RX_WFULL_INT interrupt. (RO)
I2S_TX_PUT_DATA_INT_ST The masked interrupt status bit for the I2S_TX_PUT_DATA_INT interrupt.
(RO)
I2S_RX_TAKE_DATA_INT_ST The masked interrupt status bit for the I2S_RX_TAKE_DATA_INT inter-
rupt. (RO)
se T_ F_ _I T_ A
S_ T_ _ RR NT A
S_ d NE E E A
(re OU EO ERR _IN _EN
I2 OU SCR _E Y_I EN
NA
I2 rve DO INT_ NT_ EN
_I NA NA
NT A
A
_I N
S_ D CR PT T_
_E
_T _D NT_ NA
S_ _W PT T_ A
S_ _H G_ _E N
NA
TA T_E
E_ A_ NA
I2 TX_ FU Y_I ENA
I2 RX EM _IN _EN
I2 IN_ DS EM _IN
I2 RX UN INT T_E
I2 RX FUL Y_I NA
I2 X_ M INT A
I2 TX_ UN INT NA
RX UT _I T_E
_E
AK AT E
DA IN
E
S_ T_ _ OF
S_ R G_ _E
S_ _R L NT
S_ H _ IN
NT
S_ W PT _
S_ P LL N
I2 TX_ ONE F_
I2 OU SCR _E
O
L
S_ D E
S_ D A
I2 IN_ C_
I2 IN_ TOT
E
d)
I2 IN_ )
S_ T_
S_ S
ve
I2 OU
r
T
se
S_
(re
I2
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2S_OUT_EOF_INT_ENA The interrupt enable bit for the I2S_OUT_EOF_INT interrupt. (R/W)
I2S_OUT_DONE_INT_ENA The interrupt enable bit for the I2S_OUT_DONE_INT interrupt. (R/W)
I2S_IN_SUC_EOF_INT_ENA The interrupt enable bit for the I2S_IN_SUC_EOF_INT interrupt. (R/W)
I2S_IN_DONE_INT_ENA The interrupt enable bit for the I2S_IN_DONE_INT interrupt. (R/W)
I2S_TX_HUNG_INT_ENA The interrupt enable bit for the I2S_TX_HUNG_INT interrupt. (R/W)
I2S_RX_HUNG_INT_ENA The interrupt enable bit for the I2S_RX_HUNG_INT interrupt. (R/W)
I2S_TX_REMPTY_INT_ENA The interrupt enable bit for the I2S_TX_REMPTY_INT interrupt. (R/W)
I2S_TX_WFULL_INT_ENA The interrupt enable bit for the I2S_TX_WFULL_INT interrupt. (R/W)
I2S_RX_REMPTY_INT_ENA The interrupt enable bit for the I2S_RX_REMPTY_INT interrupt. (R/W)
I2S_RX_WFULL_INT_ENA The interrupt enable bit for the I2S_RX_WFULL_INT interrupt. (R/W)
se T_ F_ _I T_ R
S_ T_ _ RR NT R
S_ d NE C C R
(re OU EO ERR _IN _CL
I2 OU SCR _E Y_I CL
LR
I2 rve DO INT_ NT_ CL
_I LR LR
NT R
R
S_ D CR PT T_
_C
_I L
_T _D NT_ LR
S_ _W PT T_ R
S_ _H G_ _C L
TA T_C
LR
E_ A_ LR
I2 TX_ FU Y_I CLR
I2 RX EM _IN _CL
I2 RX UN INT T_C
I2 IN_ DS EM _IN
I2 RX FUL Y_I LR
RX UT _I T_C
I2 TX_ EM INT LR
I2 TX_ UN INT LR
_C
AK AT C
DA IN
C
S_ T_ _ OF
S_ R G_ _C
S_ _R L NT
S_ H _ IN
NT
S_ W PT _
S_ P LL N
I2 TX_ ONE F_
I2 OU SCR _E
O
L
S_ D E
S_ D A
I2 IN_ C_
I2 IN_ TOT
U
d)
I2 IN_ )
S_ T_
S_ S
ve
I2 OU
r
se
S_
(re
I2
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
AY
LA
Y
Y
LA
Y
AY
Y
Y
LA
EL
LA
DE
LA
LA
AY
Y
DE
LA
EL
LA
_D
DE
EN NV
DE
TX SY LE_
DE
C_ W
EL
DE
SW
DE
_D
_
DE
UT
T_
S
UT
T_
I
_D
T_
TA N_
N_
SY C_
AB
IN
N_
OU
_O
_O
OU
IN
IN
_I
_I
K_
_D N
O
N
_I
_
S_
CK
D_
S_
CK
CK
CK
D_
S
S
_
d)
_W
_W
S_ _D
_B
_B
_S
_W
_W
_B
_B
_B
_S
ve
DA
I2 RX
RX
RX
RX
RX
RX
TX
TX
TX
TX
TX
TX
r
se
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
(re
I2
I2
I2
I2
I2
I2
I2
I2
I2
I2
I2
I2
I2
31 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2S_TX_BCK_IN_INV Set this bit to invert the BCK signal into the slave transmitter. (R/W)
I2S_RX_DSYNC_SW Set this bit to synchronize signals into the receiver in double sync method.
(R/W)
I2S_TX_DSYNC_SW Set this bit to synchronize signals into the transmitter in double sync method.
(R/W)
I2S_RX_BCK_OUT_DELAY Number of delay cycles for BCK signal out of the receiver. (R/W)
I2S_RX_WS_OUT_DELAY Number of delay cycles for WS signal out of the receiver. (R/W)
I2S_TX_SD_OUT_DELAY Number of delay cycles for SD signal out of the transmitter. (R/W)
I2S_TX_WS_OUT_DELAY Number of delay cycles for WS signal out of the transmitter. (R/W)
I2S_TX_BCK_OUT_DELAY Number of delay cycles for BCK signal out of the transmitter. (R/W)
I2S_RX_SD_IN_DELAY Number of delay cycles for SD signal into the receiver. (R/W)
I2S_RX_WS_IN_DELAY Number of delay cycles for WS signal into the receiver. (R/W)
I2S_RX_BCK_IN_DELAY Number of delay cycles for BCK signal into the receiver. (R/W)
I2S_TX_WS_IN_DELAY Number of delay cycles for WS signal into the transmitter. (R/W)
I2S_TX_BCK_IN_DELAY Number of delay cycles for BCK signal into the transmitter. (R/W)
CE EN
N
_E
OR E_
_F RC
OD O
M _F
UM
UM
O_ D
OD
OD
IF MO
_N
M
_N
M
_F O_
O_
N
O_
A
A
_E
AT
AT
TX IF
IF
IF
)
CR
_D
S_ _F
_F
ed
_D
_F
DS
I2 RX
RX
RX
rv
TX
TX
se
S_
S_
S_
S_
S_
S_
(re
I2
I2
I2
I2
I2
I2
31 21 20 19 18 16 15 13 12 11 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 32 32 Reset
31 0
64 Reset
31 0
0 Reset
I2S_CONF_SINGLE_DATA_REG The right channel or the left channel outputs constant values stored
in this register according to TX_CHAN_MOD and I2S_TX_MSB_RIGHT. (R/W)
OD
OD
M
_M
N_
AN
A
CH
H
d)
_C
X_
ve
TX
r
R
se
S_
S_
(re
I2
I2
31 5 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2S_RX_CHAN_MOD I2S receiver channel mode configuration bits. Please refer to Section 12.4.5
for further details. (R/W)
I2S_TX_CHAN_MOD I2S transmitter channel mode configuration bits. Please refer to Section 12.4.4
for further details. (R/W)
ST T
R
OP
K_ R
DD
OU IN RE
_A
S_ TL _
I2 OU INK
NK
LI
I2 OU )
)
S_ TL
S_ d
ed
T
I2 rve
OU
rv
se
se
S_
(re
(re
I2
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000000 Reset
DR
P
IN K_ ST
TO
AD
S_ IN E
I2 INL K_R
K_
I2 INL )
)
S_ IN
IN
S_ d
ed
I2 rve
NL
rv
se
se
I
S_
(re
(re
I2
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
se T_ R_ T_ EN
DE EN
S_ BM _T ST K
I2 rve EO BU EN
(re OU SC URS ST_
I2 AH OP _TE AC
I2 OU ) MO T_
ST
S
O P B
S_ TD B R
S_ S A R
S_ d F_ R
S_ BM S T
_R T R
I2 OU CR_ BU
I2 IND DAT NE
I2 IN_ LOO _W
I2 AH _R ES
IN RS O_
_
S_ T_ OW
T
S_ T_ TO
S_ T_ IF
I2 OU _F
I2 OU K_
I2 OU AU
ST
d)
S_ EC
S_ T_
S_ L
ve
I2 CH
r
se
S_
(re
I2
31 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 Reset
I2S_CHECK_OWNER Set this bit to check the owner bit by hardware. (R/W)
I2S_OUT_AUTO_WRBACK Set this bit to enable automatic outlink-writeback when all the data in tx
buffer has been transmitted. (R/W)
I2S_AHBM_FIFO_RST Set this bit to reset AHB interface cmdFIFO of DMA. (R/W)
31 0
0x000000000 Reset
31 0
0x000000000 Reset
FT
NA
HI
_S
_E
UT
UT
UT
EO
EO
EO
M
M
TI
TI
TI
O_
O_
O_
IF
IF
IF
)
_F
_F
ed
_F
LC
LC
rv
LC
se
S_
S_
S_
(re
I2
I2
I2
31 12 11 10 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0x010 Reset
I2S_LC_FIFO_TIMEOUT_SHIFT The bits are used to set the tick counter threshold. The tick counter
is reset when the counter value >= 88000/2i2s_lc_fifo_timeout_shift . (R/W)
I2S_LC_FIFO_TIMEOUT When the value of FIFO hung counter is equal to this bit value, sending
data-timeout interrupt or receiving data-timeout interrupt will be triggered. (R/W)
S
AS
AS
F
F
ON
ON
YP
YP
CM EN
_B
_C
_B
_C
_P P_
CM
RX TO
C
)
_P
ed
_P
_P
S_ S
I2 TX_
RX
rv
TX
TX
se
S_
S_
S_
S_
(re
I2
I2
I2
I2
31 9 8 7 6 4 3 2 0
I2S_TX_STOP_EN Set this bit and the transmitter will stop transmitting BCK signal and WS signal
when tx FIFO is empty. (R/W)
I2S_RX_PCM_BYPASS Set this bit to bypass the Compress/Decompress module for the received
data. (R/W)
I2S_TX_PCM_BYPASS Set this bit to bypass the Compress/Decompress module for the transmitted
data. (R/W)
CE U
D
OR _P
_P
_F CE
FO R
FI _FO
)
se d)
I2 FIF )
ed
S_ d
S_ O
(re rve
I2 rve
rv
se
se
(re
(re
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 Reset
N
_E
N
ER R EN
EN _E
(re D_ C_S EN
RT
M _W 2_
A _ X2
se EN TA
_
CA TX DX
LC AD ID
S_ _ AL
S_ D_ S
I2 LC TX_
I2 EXT _V
R
d)
)
S_ D_
ed
S_ E
ve
I2 INT
rv
I2 C
r
L
se
S_
S_
(re
I2
I2
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 Reset
I2S_EXT_ADC_START_EN Set this bit to enable the start of external ADC . (R/W)
I2S_LCD_TX_SDX2_EN Set this bit to duplicate data pairs (Data Frame, Form 2) in LCD mode. (R/W)
M
NU
B
A
IV_
IV_
IV_
ed NA
_D
_D
_D
rv _E
)
KM
KM
KM
se K A
ed
rv
(re CL
CL
CL
CL
se
S_
S_
S_
S_
(re
I2
I2
I2
I2
31 22 21 20 19 14 13 8 7 0
M
NU
NU
OD
OD
IV_
IV_
_M
_M
_D
_D
TS
CK
TS
CK
BI
d)
B
_B
_B
X_
X_
ve
TX
TX
r
R
se
S_
S_
S_
S_
(re
I2
I2
I2
I2
31 24 23 18 17 12 11 6 5 0
0 0 0 0 0 0 0 0 16 16 6 6 Reset
I2S_RX_BITS_MOD Set the bits to configure the bit length of I2S receiver channel. (R/W)
I2S_TX_BITS_MOD Set the bits to configure the bit length of I2S transmitter channel. (R/W)
FT
HI
_S
EN
IN
T
AD 6_
IF
A_
FT
FT
1
SH
DM EN NV N
N
IG SR_
DM NC ASS
R2
LT
HI
_P M _ O E
_E
HI
_
TX D _C V_
E
OS
_S
_S
IN
_D
SI P
S_ _P M ON
TX M_ _BY
C_
C_
IN
IN
M
P_
I2 RX PD _C
P_
IN
IN
D HP
N
_H
_S
_S
_S
_E
S_ M M
_L
_P _
I2 PC PC
RX DM
DM
DM
DM
D M
2
2
d)
)
ed
S_ P
_P
_P
_P
_P
_P
S_ M
ve
I2 TX_
I2 P D
rv
TX
TX
TX
TX
r
se
se
S_
S_
S_
S_
S_
S_
S_
(re
(re
I2
I2
I2
I2
I2
I2
I2
31 26 25 24 23 22 21 20 19 18 17 16 15 8 7 4 3 2 1 0
I2S_TX_PDM_HP_BYPASS Set this bit to bypass the transmitter’s PDM HP filter. (R/W)
I2S_RX_PDM_SINC_DSR_16_EN PDM downsampling rate for filter group 1 in receiver mode. (R/W)
1: downsampling rate = 128;
0: downsampling rate = 64.
I2S_TX_PDM_SIGMADELTA_IN_SHIFT Adjust the size of the input signal into filter module. (R/W)
0: divided by 2; 1: multiplied by 1; 2: multiplied by 2; 3: multiplied by 4.
I2S_TX_PDM_SINC_IN_SHIFT Adjust the size of the input signal into filter module. (R/W)
0: divided by 2; 1: multiplied by 1; 2: multiplied by 2; 3: multiplied by 4.
I2S_TX_PDM_LP_IN_SHIFT Adjust the size of the input signal into filter module. (R/W)
0: divided by 2; 1: multiplied by 1; 2: multiplied by 2; 3: multiplied by 4.
I2S_TX_PDM_HP_IN_SHIFT Adjust the size of the input signal into filter module. (R/W)
0: divided by 2; 1: multiplied by 1; 2: multiplied by 2; 3: multiplied by 4.
S
_F
_F
DM
DM
)
ed
_P
_P
rv
TX
TX
se
S_
S_
(re
I2
I2
31 20 19 10 9 0
T_ CK
CK
E SE BA
BA
DL RE T_
_I _ SE
TX IFO E
S_ F _R
I2 TX_ IFO
d)
S_ _F
ve
I2 RX
r
se
S_
(re
I2
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
I2S_RX_FIFO_RESET_BACK This bit is used to confirm if the Rx FIFO reset is done. 1: reset is not
ready; 0: reset is ready. (RO)
I2S_TX_FIFO_RESET_BACK This bit is used to confirm if the Tx FIFO reset is done. 1: reset is not
ready; 0: reset is ready. (RO)
I2S_TX_IDLE The status bit of the transmitter. 1: the transmitter is idle; 0: the transmitter is busy.
(RO)
13.1 Overview
Embedded applications often require a simple method of exchanging data between devices that need minimal
system resources. The Universal Asynchronous Receiver/Transmitter (UART) is one such standard that can
realize a flexible full-duplex data exchange among different devices. The three UART controllers available on a
chip are compatible with UART-enabled devices from various manufacturers. The UART can also carry out an
IrDA (Infrared Data Exchange), or function as an RS-485 modem.
All UART controllers integrated in the ESP32 feature an identical set of registers for ease of programming and
flexibility. In this documentation, these controllers are referred to as UARTn, where n = 0, 1, and 2, referring to
UART0, UART1, and UART2, respectively.
A typical UART frame begins with a START bit, followed by a “character” and an optional parity bit for error
detection, and it ends with a STOP condition. The UART controllers available on the ESP32 provide hardware
support for multiple lengths of data and STOP bits. In addition, the controllers support both software and
hardware flow control, as well as DMA, for seamless high-speed data transfer. This allows the developer to
employ multiple UART ports in the system with minimal software overhead.
Figure 13-1 shows the basic block diagram of the UART controller. The UART block can derive its clock from two
sources: the 80-MHz APB_CLK, or the reference clock REF_TICK (please refer to Chapter Reset and Clock for
more details). These two clock sources can be selected by configuring UART_TICK_REF_ALWAYS_ON.
Then, a divider in the clock path divides the selected clock source to generate clock signals that drive the
UART module. UART_CLKDIV_REG contains the clock divider value in two parts — UART_CLKDIV (integral part)
and UART_CLKDIV_FRAG (decimal part).
The UART controller can be further broken down into two functional blocks — the transmit block and the receive
block.
The transmit block contains a transmit-FIFO buffer, which buffers data awaiting to be transmitted. Software can
write Tx_FIFO via APB, and transmit data into Tx_FIFO via DMA. Tx_FIFO_Ctrl is used to control read- and write-
access to the Tx_FIFO. When Tx_FIFO is not null, Tx_FSM reads data via Tx_FIFO_Ctrl, and transmits data out
according to the set frame format. The outgoing bit stream can be inverted by appropriately configuring the
register UART_TXD_INV.
The receive-block contains a receive-FIFO buffer, which buffers incoming data awaiting to be processed. The
input bit stream, rxd_in, is fed to the UART controller. Negation of the input stream can be controlled by config-
uring the UART_RXD_INV register. Baudrate_Detect measures the baud rate of the input signal by measuring the
minimum pulse width of the input bit stream. Start_Detect is used to detect a START bit in a frame of incoming
data. After detecting the START bit, RX_FSM stores data retrieved from the received frame into Rx_FIFO through
Rx_FIFO_Ctrl.
Software can read data in the Rx_FIFO through the APB. In order to free the CPU from engaging in data transfer
operations, the DMA can be configured for sending or receiving data.
HW_Flow_Ctrl is able to control the data flow of rxd_in and txd_out through standard UART RTS and CTS flow
control signals (rtsn_out and ctsn_in). SW_Flow_Ctrl controls the data flow by inserting special characters in the
incoming and outgoing data flow. When UART is in Light-sleep mode (refer to Chapter Low-Power Management),
Wakeup_Ctrl will start counting pulses in rxd_in. When the number or positive edges of RxD signal is greater
than or equal to (UART_ACTIVE_THRESHOLD+2), a wake_up signal will be generated and sent to RTC. RTC will
then wake up the UART controller. Note that only UART1 and UART2 support Light-sleep mode and that rxd_in
cannot be input through GPIO Matrix but only through IO_MUX.
Three UART controllers share a 1024 × 8-bit RAM space. As illustrated in Figure 13-2, RAM is allocated in different
blocks. One block holds 128 × 8-bit data. Figure 13-2 illustrates the default RAM allocated to Tx_FIFO and Rx_FIFO
of the three UART controllers. Tx_FIFO of UARTn can be extended by setting UARTn_TX_SIZE, while Rx_FIFO
of UARTn can be extended by setting UARTn_RX_SIZE.
NOTICE: Extending the FIFO space of a UART controller may take up the FIFO space of another UART con-
troller.
If none of the UART controllers is active, setting UART_MEM_PD, UART1_MEM_PD, and UART2_MEM_PD can
prompt the RAM to enter low-power mode.
In UART0, bit UART_TXFIFO_RST and bit UART_RXFIFO_RST can be set to reset Tx_FIFO or Rx_FIFO, respec-
tively. In UART1, bit UART1_TXFIFO_RST and bit UART1_RXFIFO_RST can be set to reset Tx_FIFO or Rx_FIFO,
respectively.
Note:
UART2 doesn’t have any register to reset Tx_FIFO or Rx_FIFO, and the UART1_TXFIFO_RST and UART1_RXFIFO_RST
in UART1 may impact the functioning of UART2. Therefore, these 2 registers in UART1 should only be used when the
Tx_FIFO and Rx_FIFO in UART2 do not have any data.
In order to use the baud rate detection feature, some random data should be sent to the receiver before
starting the UART communication stream. This is required so that the baud rate can be determined based on
the pulse width. UART_LOWPULSE_MIN_CNT stores minimum low-pulse width, UART_HIGHPULSE_MIN_CNT
stores minimum high-pulse width. By reading these two registers, software can calculate the baud rate of the
transmitter.
The length of a character (BIT0 to BITn) can comprise 5 to 8 bits and can be configured by UART_BIT_NUM.
When UART_PARITY_EN is set, the UART controller hardware will add the appropriate parity bit after the data.
UART_PARITY is used to select odd parity or even parity. If the receiver detects an error in the input character,
interrupt UART_PARITY_ERR_INT will be generated. If the receiver detects an error in the frame format, interrupt
UART_FRM_ERR_INT will be generated.
Interrupt UART_TX_DONE_INT will be generated when all data in Tx_FIFO have been transmitted. When UART_TXD
_BRK is set, the transmitter enter the Break condition and send several NULL characters after the process
of sending data is completed. The number of NULL characters can be configured by UART_TX_BRK_NUM.
After the transmitter finishes sending all NULL characters, interrupt UART_TX_BRK_DONE_INT will be gener-
ated. The minimum interval between data frames can be configured with UART_TX_IDLE_NUM. If the idle
time of a data frame is equal to, or larger than, the configured value of register UART_TX_IDLE_NUM, inter-
rupt UART_TX_BRK_IDLE_DONE_INT will be generated.
The receiver can also detect the Break conditions when the RX data line remains logical low for one NULL
character transmission, and a UART_BRK_DET_INT interrupt will be triggered to detect that a Break condition
has been completed.
The receiver can detect the current bus state through the timeout interrupt UART_RXFIFO_TOUT_INT. The
UART_RXFIFO_TOUT_INT interrupt will be triggered when the bus is in the idle state for more than UART_RX_TOUT_THRHD
bit time on current baud rate after the receiver has received at least one byte. You can use this interrupt to detect
whether all the data from the transmitter has been sent.
Figure 13-4 shows a special AT_CMD character format. If the receiver constantly receives UART_AT_CMD_CHAR
characters and these characters satisfy the following conditions, interrupt UART_AT_CMD_CHAR_DET_INT will
be generated.
• Between the first UART_AT_CMD_CHAR and the last non-UART_AT_CMD_CHAR, there are at least UART_
PER_IDLE_NUM APB clock cycles.
• Between every UART_AT_CMD_CHAR character there must be less than UART_RX_GAP_TOUT APB clock
cycles.
• The number of received UART_AT_CMD_CHAR characters must be equal to, or greater than, UART_CHAR_NUM.
• Between the last UART_AT_CMD_CHAR character received and the next non-UART_AT_CMD_CHAR, there
are at least UART_POST_IDLE_NUM APB clock cycles.
Figure 13-5 illustrates how the UART hardware flow control works. In hardware flow control, a high state of the
output signal rtsn_out signifies that a data transmission is requested, while a low state of the same signal notifies
the counterpart to stop data transmission until rtsn_out is pulled high again. There are two ways for a transmitter
to realize hardware flow control:
If the UART controller detects an edge on ctsn_in, it will generate interrupt UART_CTS_CHG_INT and will stop
transmitting data, once the current data transmission is completed.
The high level of the output signal dtrn_out signifies that the transmitter has finished data preparation. UART
controller will generate interrupt UART_DSR_CHG_INT, after it detects an edge on the input signal dsrn_in. After
the software detects the above-mentioned interrupt, the input signal level of dsrn_in can be figured out by
reading UART_DSRN. The software then decides whether it is able to receive data at that time or not.
Setting UART_LOOPBACK will enable the UART loopback detection function. In this mode, the output signal
txd_out of UART is connected to its input signal rxd_in, rtsn_out is connected to ctsn_in, and dtrn_out is
connected to dsrn_out. If the data transmitted corresponds to the data received, UART is able to transmit and
receive data normally.
UART can also control the software flow by transmitting special characters. Setting UART_SW_FLOW_CON_EN
will enable the software flow control function. If the number of data bytes that UART has received exceeds that
of the UART_XOFF threshold, the UART controller can send UART_XOFF_CHAR to instruct its counterpart to stop
data transmission.
When UART_SW_FLOW_CON_EN is 1, software can send flow control characters at any time. When UART_SEND
_XOFF is set, the transmitter will insert a UART_XOFF_CHAR and send it after the current data transmission is
completed. When UART_SEND_XON is set, the transmitter will insert a UART_XON_CHAR and send it after the
current data transmission is completed.
• UART_RS485_CLASH_INT: Triggered when a collision is detected between transmitter and receiver in RS-
485 mode.
• UART_TX_DONE_INT: Triggered when the transmitter has sent out all FIFO data.
• UART_TX_BRK_IDLE_DONE_INT: Triggered when the transmitter’s idle state has been kept to a minimum
after sending the last data.
• UART_TX_BRK_DONE_INT: Triggered when the transmitter completes sending NULL characters, after all
data in transmit-FIFO are sent.
• UART_SW_XOFF_INT: Triggered, if the receiver gets an Xon char when UART_SW_FLOW_CON_EN is set to
1.
• UART_SW_XON_INT: Triggered, if the receiver gets an Xoff char when UART_SW_FLOW_CON_EN is set to
1.
• UART_RXFIFO_TOUT_INT: Triggered when the receiver takes more time than RX_TOUT_THRHD to receive
a byte.
• UART_BRK_DET_INT: Triggered when the receiver detects a NULL character (i.e. logic 0 for one NULL
character transmission) after stop bits.
• UART_CTS_CHG_INT: Triggered when the receiver detects an edge change of the CTSn signal.
• UART_DSR_CHG_INT: Triggered when the receiver detects an edge change of the DSRn signal.
• UART_RXFIFO_OVF_INT: Triggered when the receiver gets more data than the FIFO can store.
• UART_PARITY_ERR_INT: Triggered when the receiver detects a parity error in the data.
• UART_TXFIFO_EMPTY_INT: Triggered when the amount of data in the transmit-FIFO is less than what
tx_mem_cnttxfifo_cnt specifies.
• UART_RXFIFO_FULL_INT: Triggered when the receiver gets more data than what (rx_flow_thrhd_h3, rx_flow_thrhd)
specifies.
• UHCI_SEND_S_REG_Q_INT: When using the single_send registers to send a series of short packets, this
is triggered when DMA has sent a short packet.
• UHCI_OUTLINK_EOF_ERR_INT: Triggered when there are some errors in EOF in the outlink descriptor.
• UHCI_IN_DSCR_EMPTY_INT: Triggered when there are not enough inlinks for DMA.
• UHCI_OUT_DSCR_ERR_INT: Triggered when there are some errors in the inlink descriptor.
• UHCI_IN_DSCR_ERR_INT: Triggered when there are some errors in the outlink descriptor.
• UHCI_IN_ERR_EOF_INT: Triggered when there are some errors in EOF in the inlink descriptor.
• UHCI_TX_HUNG_INT: Triggered when DMA takes much time to read data from RAM.
13.5 Registers
13.5.1 UART Registers
The addresses in parenthesis besides register names are the register addresses relative to the UART base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 13.4.1 UART Register Summary.
TE
Y
_B
RD
O_
IF
)
XF
ed
_R
rv
RT
se
(re
UA
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RT XF N_ T_ RA W W
R X_ NE ITY _I W W
RA
UA T_G BR IDL RA _IN W
R X_ K_ T_ RR RA
R X_ _P _E T_ T_
R LI K_ E_ W T_
_ F I T_ T
_R W
UA _S XO ET IN _IN
AW
UA T_T BR _IN _E NT_
UA T_R _C _IN RA AW
UA T_T 85 RM _IN _IN
NT A
UA _B IFO IN RA W
_R FO RR R W
FU Y_ AW
_I _R
RT W_ _D NE NE
RT XFI _E NT_ RA
R S4 _F SH ET
R SR HG T_ _R
XF _E _IN AW
R AR R _I W
R RM _O T W
R RK _T T_ W
R XF HG T_ W
LL INT
O_ PT R
UA T_C _D OU RAW
UA T_P _E VF _RA
UA T_D _C _IN INT
IF M T_
_
R S4 _C AR
R TS ET T_
_
UA T_R 85 CH
R S4 D_
F
UA T_R CM
)
R T_
ed
W
UA T_A
rv
se
R
(re
UA
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UART_RS485_CLASH_INT_RAW The raw interrupt status bit for the UART_RS485_CLASH_INT inter-
rupt. (RO)
UART_TX_DONE_INT_RAW The raw interrupt status bit for the UART_TX_DONE_INT interrupt. (RO)
UART_TX_BRK_DONE_INT_RAW The raw interrupt status bit for the UART_TX_BRK_DONE_INT in-
terrupt. (RO)
UART_GLITCH_DET_INT_RAW The raw interrupt status bit for the UART_GLITCH_DET_INT interrupt.
(RO)
UART_SW_XOFF_INT_RAW The raw interrupt status bit for the UART_SW_XOFF_INT interrupt. (RO)
UART_SW_XON_INT_RAW The raw interrupt status bit for the UART_SW_XON_INT interrupt. (RO)
UART_RXFIFO_TOUT_INT_RAW The raw interrupt status bit for the UART_RXFIFO_TOUT_INT inter-
rupt. (RO)
UART_BRK_DET_INT_RAW The raw interrupt status bit for the UART_BRK_DET_INT interrupt. (RO)
UART_CTS_CHG_INT_RAW The raw interrupt status bit for the UART_CTS_CHG_INT interrupt. (RO)
UART_DSR_CHG_INT_RAW The raw interrupt status bit for the UART_DSR_CHG_INT interrupt. (RO)
UART_RXFIFO_OVF_INT_RAW The raw interrupt status bit for the UART_RXFIFO_OVF_INT interrupt.
(RO)
UART_FRM_ERR_INT_RAW The raw interrupt status bit for the UART_FRM_ERR_INT interrupt. (RO)
UART_PARITY_ERR_INT_RAW The raw interrupt status bit for the UART_PARITY_ERR_INT interrupt.
(RO)
UART_TXFIFO_EMPTY_INT_RAW The raw interrupt status bit for the UART_TXFIFO_EMPTY_INT in-
terrupt. (RO)
UART_RXFIFO_FULL_INT_RAW The raw interrupt status bit for the UART_RXFIFO_FULL_INT inter-
rupt. (RO)
ST
R X_ K_ T_ RR ST
R X_ _P _E T_ T_
T_
R W_ FF _I T_ T
UA _S XO ET IN _IN
UA T_T BR _IN _E NT_
UA T_T 85 RM _IN _IN
NT T
T
_I _S
UA T_R _C _IN ST T
RT W_ _D NE NE
R XF N T_ ST
_S
R S4 _F SH ET
RT XFI _E NT_ ST
R SR HG T_ _S
FU Y_ T
R X_ NE ITY _I
LL INT
O_ PT S
XF _E _IN T
UA T_P _E VF _ST
UA T_D _C _IN INT
UA T_S TCH DO DO
UA T_R 85 LA _D
IF M T_
UA T_B IFO _IN ST
_R FO RR S
UA T_C _D OU ST
_
R XF HG T_
R S4 _C AR
R LI K_ E_
R TS ET T_
R RM _O T
R RK _T T_
R AR R _I
UA T_R 85 CH
R S4 D_
UA T_R CM
)
R T_
ed
UA T_A
rv
se
R
(re
UA
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UART_RS485_CLASH_INT_ST The masked interrupt status bit for the UART_RS485_CLASH_INT in-
terrupt. (RO)
UART_TX_DONE_INT_ST The masked interrupt status bit for the UART_TX_DONE_INT interrupt. (RO)
UART_GLITCH_DET_INT_ST The masked interrupt status bit for the UART_GLITCH_DET_INT inter-
rupt. (RO)
UART_SW_XOFF_INT_ST The masked interrupt status bit for the UART_SW_XOFF_INT interrupt. (RO)
UART_SW_XON_INT_ST The masked interrupt status bit for the UART_SW_XON_INT interrupt. (RO)
UART_RXFIFO_TOUT_INT_ST The masked interrupt status bit for the UART_RXFIFO_TOUT_INT inter-
rupt. (RO)
UART_BRK_DET_INT_ST The masked interrupt status bit for the UART_BRK_DET_INT interrupt. (RO)
UART_CTS_CHG_INT_ST The masked interrupt status bit for the UART_CTS_CHG_INT interrupt.
(RO)
UART_DSR_CHG_INT_ST The masked interrupt status bit for the UART_DSR_CHG_INT interrupt.
(RO)
UART_RXFIFO_OVF_INT_ST The masked interrupt status bit for the UART_RXFIFO_OVF_INT inter-
rupt. (RO)
UART_FRM_ERR_INT_ST The masked interrupt status bit for the UART_FRM_ERR_INT interrupt.
(RO)
UART_PARITY_ERR_INT_ST The masked interrupt status bit for the UART_PARITY_ERR_INT interrupt.
(RO)
UART_TXFIFO_EMPTY_INT_ST The masked interrupt status bit for the UART_TXFIFO_EMPTY_INT in-
terrupt. (RO)
RT XF N_ T_ EN A A
R X_ NE ITY _I A A
EN
UA T_G BR IDL EN _IN A
R X_ K_ T_ RR EN
R X_ _P _E T_ T_
R LI K_ E_ A T_
_ F I T_ T
_E A
UA _S XO ET IN _IN
UA T_T BR _IN _E NT_
UA T_T 85 RM _IN _IN
NA
NT N
UA T_R _C _IN EN NA
UA _B IFO IN EN A
_R FO RR E A
FU Y_ NA
_I _E
RT W_ _D NE NE
RT XFI _E NT_ EN
R S4 _F SH ET
R SR HG T_ _E
XF _E _IN NA
R AR R _I A
LL INT
R RM _O T A
R RK _T T_ A
R XF HG T_ A
O_ PT E
UA T_C _D OU ENA
UA T_P _E VF _EN
UA T_F IFO _IN EN
UA T_D _C _IN INT
UA T_S TCH DO DO
UA T_R 85 LA _D
IF M T_
_
R S4 _C AR
R TS ET T_
_
UA T_R 85 CH
R S4 D_
F
UA T_R CM
)
R T_
ed
W
UA T_A
rv
se
R
(re
UA
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UART_TX_DONE_INT_ENA The interrupt enable bit for the UART_TX_DONE_INT interrupt. (R/W)
UART_SW_XOFF_INT_ENA The interrupt enable bit for the UART_SW_XOFF_INT interrupt. (R/W)
UART_SW_XON_INT_ENA The interrupt enable bit for the UART_SW_XON_INT interrupt. (R/W)
UART_BRK_DET_INT_ENA The interrupt enable bit for the UART_BRK_DET_INT interrupt. (R/W)
UART_CTS_CHG_INT_ENA The interrupt enable bit for the UART_CTS_CHG_INT interrupt. (R/W)
UART_DSR_CHG_INT_ENA The interrupt enable bit for the UART_DSR_CHG_INT interrupt. (R/W)
UART_FRM_ERR_INT_ENA The interrupt enable bit for the UART_FRM_ERR_INT interrupt. (R/W)
RT XF N_ T_ CL R R
R X_ NE ITY _I R R
CL
UA T_G BR IDL CL _IN LR
R X_ _P _E T_ T_
R LI K_ E_ R T_
_ F I T_ T
R X_ K_ T_ RR C
_C R
UA _S XO ET IN _IN
UA T_T BR _IN _E NT_
UA T_T 85 RM _IN _IN
LR
NT L
UA T_R _C _IN CL LR
UA _B IFO IN CL R
_I _C
_R FO RR C R
FU Y_ LR
RT W_ _D NE NE
R S4 _F SH ET
R SR HG T_ _C
RT XFI _E NT_ CL
XF _E _IN LR
LL INT
R AR R _I R
R RM _O T R
O_ PT C
R RK _T T_ R
R XF HG T_ R
UA T_C _D OU CLR
UA T_P _E VF _CL
UA T_D _C _IN INT
UA T_S TCH DO DO
UA T_R 85 LA _D
IF M T_
_
R S4 _C AR
R TS ET T_
_
UA T_R 85 CH
R S4 D_
F
UA T_R CM
)
R T_
ed
W
UA T_A
rv
se
R
(re
UA
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UART_RXFIFO_TOUT_INT_CLR Set this bit to clear the UART_RXFIFO_TOUT_INT interrupt. This bit
can be set only when both rxfifo_cnt and rx_mem_cnt are 0. (WO)
UART_RXFIFO_FULL_INT_CLR Set this bit to clear the UART_RXFIFO_FULL_INT interrupt. This bit
can be set only when data in Rx_FIFO is less than UART_RXFIFO_FULL_THRHD. (WO)
AG
FR
V_
IV
DI
D
)
LK
LK
ed
_C
_C
rv
RT
RT
se
(re
UA
UA
31 24 23 20 19 0
EN
LT
D_
FI
AU
H_
OB
TC
)
UT
ed
ed
LI
_G
_A
rv
rv
RT
RT
se
se
(re
(re
UA
UA
31 16 15 8 7 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x010 0 0 0 0 0 0 0 0 Reset
UART_GLITCH_FILT When the input pulse width is lower than this value, the pulse is ignored. This
register is used in the autobauding process. (R/W)
T
UT
T
NT
OU
CN
_O
_C
X_
O_
X
FO
UR
UT
rv N
IF
rv N
(re T_D N
(re T_D N
se SR
)
)
RT XD
se TR
FI
R TS
R TS
XF
RT XD
T_
T_
ed
ed
X
UA _C
UA _R
UA T_R
_R
_S
_S
UA T_T
_T
RT
RT
RT
RT
R
R
UA
UA
UA
UA
UA
UA
31 30 29 28 27 24 23 16 15 14 13 12 11 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UART_TXD This bit represents the level of the internal UART RxD signal. (RO)
UART_RTSN This bit corresponds to the level of the internal UART CTS signal. (RO)
UART_DTRN This bit corresponds to the level of the internal UAR DSR signal. (RO)
UART_ST_UTX_OUT This register stores the state of the transmitter’s finite state machine. 0:
TX_IDLE; 1: TX_STRT; 2: TX_DAT0; 3: TX_DAT1; 4: TX_DAT2; 5: TX_DAT3; 6: TX_DAT4; 7:
TX_DAT5; 8: TX_DAT6; 9: TX_DAT7; 10: TX_PRTY; 11: TX_STP1; 12: TX_STP2; 13: TX_DL0; 14:
TX_DL1. (RO)
UART_TXFIFO_CNT (tx_mem_cnt, txfifo_cnt) stores the number of bytes of valid data in transmit-
FIFO. tx_mem_cnt stores the three most significant bits, txfifo_cnt stores the eight least signifi-
cant bits. (RO)
UART_RXD This bit corresponds to the level of the internal UART RxD signal. (RO)
UART_CTSN This bit corresponds to the level of the internal UART CTS signal. (RO)
UART_DSRN This bit corresponds to the level of the internal UAR DSR signal. (RO)
UART_ST_URX_OUT This register stores the value of the receiver’s finite state machine. 0: RX_IDLE;
1: RX_STRT; 2: RX_DAT0; 3: RX_DAT1; 4: RX_DAT2; 5: RX_DAT3; 6: RX_DAT4; 7: RX_DAT5; 8:
RX_DAT6; 9: RX_DAT7; 10: RX_PRTY; 11: RX_STP1; 12:RX_STP2; 13: RX_DL1. (RO)
UART_RXFIFO_CNT (rx_mem_cnt, rxfifo_cnt) stores the number of bytes of valid data in the
receive-FIFO. rx_mem_cnt register stores the three most significant bits, rxfifo_cnt stores the
eight least significant bits. (RO)
ON
S_
AY
M
LW
NU
R D X_ V
R D AC N
R D C V
UA T_T A_D EN
UA T_T A_E ST
UA T_IR IFO ST
UA _IR PB _E
UA T_IR A_W IN
UA T_IR A_T TL
UA T_S _B LX
UA T_IR A_R K
IT N
T_
R D _R
R D X_
EF
R XF _R
RT OO W
AR Y_E
M
RT W_ RK
R XD P
R TS V
R X_ N
RT S V
R XF V
R XD V
R D X
R XD V
BI
W R
R SR V
_S TS
UA T_C _IN
UA _R _IN
UA T_L FLO
UA T_T _IN
UA _T _IN
NU
UA T_R _IN
_R
Y
_S DT
UA T_D _IN
UA T_R IFO
P_
_P IT
_R
IT_
(re ICK
)
UA ed)
RT TR
TO
RT AR
ed
T
UA D
_B
UA _P
_T
rv
rv
_
RT
RT
RT
RT
RT
se
se
(re
UA
UA
UA
UA
31 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3 0 0 Reset
UART_TICK_REF_ALWAYS_ON This register is used to select the clock; 1: APB clock; 0: REF_TICK.
(R/W)
UART_DTR_INV Set this bit to invert the level of the UART DTR signal. (R/W)
UART_RTS_INV Set this bit to invert the level of the UART RTS signal. (R/W)
UART_TXD_INV Set this bit to invert the level of the UART TxD signal. (R/W)
UART_DSR_INV Set this bit to invert the level of the UART DSR signal. (R/W)
UART_CTS_INV Set this bit to invert the level of the UART CTS signal. (R/W)
UART_RXD_INV Set this bit to invert the level of the UART Rxd signal. (R/W)
UART_TXFIFO_RST Set this bit to reset the UART transmit-FIFO. NOTICE: UART2 doesn’t have any
register to reset Tx_FIFO or Rx_FIFO, and the UART1_TXFIFO_RST and UART1_RXFIFO_RST in
UART1 may impact the functioning of UART2. Therefore, these two registers in UART1 should
only be used when the Tx_FIFO and Rx_FIFO in UART2 do not have any data. (R/W)
UART_RXFIFO_RST Set this bit to reset the UART receive-FIFO. NOTICE: UART2 doesn’t have any
register to reset Tx_FIFO or Rx_FIFO, and the UART1_TXFIFO_RST and UART1_RXFIFO_RST in
UART1 may impact the functioning of UART2. Therefore, these two registers in UART1 should
only be used when the Tx_FIFO and Rx_FIFO in UART2 do not have any data. (R/W)
UART_TX_FLOW_EN Set this bit to enable the flow control function for the transmitter. (R/W)
UART_LOOPBACK Set this bit to enable the UART loopback test mode. (R/W)
UART_IRDA_RX_INV Set this bit to invert the level of the IrDA receiver. (R/W)
UART_IRDA_TX_INV Set this bit to invert the level of the IrDA transmitter. (R/W)
UART_IRDA_WCTL 1: The IrDA transmitter’s 11th bit is the same as its 10th bit; 0: set IrDA transmitter’s
11th bit to 0. (R/W)
UART_IRDA_TX_EN This is the start enable bit of the IrDA transmitter. (R/W)
UART_IRDA_DPLX Set this bit to enable the IrDA loopback mode. (R/W)
UART_TXD_BRK Set this bit to enable the transmitter to send NULL, when the process of sending
data is completed. (R/W)
UART_SW_DTR This register is used to configure the software DTR signal used in software flow
control. (R/W)
UART_SW_RTS This bit is used in hardware flow control when UART_RX_FLOW_EN is 0. Set this bit
to drive the RTS (or rtsn_out) signal low, and reset to drive the signal high. (R/W)
UART_STOP_BIT_NUM This register is used to set the length of the stop bit.
0: Invalid. No effect
1: 1 bit
2: 1.5 bits
3: 2 bits
(R/W)
UART_BIT_NUM This register is used to set the length of data; 0: 5 bits, 1: 6 bits, 2: 7 bits, 3: 8
bits. (R/W)
UART_PARITY_EN Set this bit to enable the UART parity check. (R/W)
UART_PARITY This register is used to configure the parity check mode; 0: even, 1: odd. (R/W)
D
RH
RH
TH
HD
H
D
Y_
_T
RH
HR
PT
N
L
N
TH
UL
_E
_T
E
M
T_
T_
OW
_F
_E
U
LO
FO
FO
FL
TO
TO
I
d)
)
I
X_
X_
X_
X_
XF
XF
ed
ve
_R
_R
_R
_R
_R
_T
rv
r
RT
RT
RT
RT
RT
RT
se
se
(re
(re
UA
UA
UA
UA
UA
UA
31 30 24 23 22 16 15 14 8 7 6 0
UART_RX_TOUT_EN This is the enable bit for the UART receive-timeout function. (R/W)
UART_RX_TOUT_THRHD This register is used to configure the UART receiver’s timeout value when
receiving a byte. When using APB_CLK as the clock source, the register counts by UART baud
cycle multiplied by 8. When using REF_TICK as the clock source, the register counts by
UART baud cycle * 8 * (REF_TICK frequency)/(APB_CLK frequency). (R/W)
UART_RX_FLOW_EN This is the flow enable bit of the UART receiver; 1: choose software flow control
by configuring the sw_rts signal; 0: disable software flow control. (R/W)
UART_RX_FLOW_THRHD When UART_RX_FLOW_EN is 1 and the receiver gets more data than its
threshold value, the receiver produces an rtsn_out signal that tells the transmitter to stop trans-
ferring data. The threshold value is (rx_flow_thrhd_h3, rx_flow_thrhd). (R/W)
UART_TXFIFO_EMPTY_THRHD When the data amount in transmit-FIFO is less than its thresh-
old value, it will produce a TXFIFO_EMPTY_INT_RAW interrupt. The threshold value is
(tx_mem_empty_thrhd, txfifo_empty_thrhd). (R/W)
UART_RXFIFO_FULL_THRHD When the receiver gets more data than its threshold value,
the receiver will produce an RXFIFO_FULL_INT_RAW interrupt. The threshold value is
(rx_flow_thrhd_h3, rxfifo_full_thrhd). (R/W)
_L
rv
RT
se
(re
UA
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x0FFFFF Reset
UART_LOWPULSE_MIN_CNT This register stores the value of the minimum duration of the low-level
pulse. It is used in the baud rate detection process. (RO)
NT
_C
IN
M
E_
LS
PU
H
)
IG
ed
_H
rv
RT
se
(re
UA
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x0FFFFF Reset
UART_HIGHPULSE_MIN_CNT This register stores the value of the minimum duration of the high
level pulse. It is used in baud rate detection process. (RO)
TN
_C
GE
D
_E
)
XD
ed
_R
rv
RT
se
(re
UA
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
UART_RXD_EDGE_CNT This register stores the count of the RxD edge change. It is used in the
baud rate detection process. (RO)
N
_E
ON
RT ON _X F
LO EL
_C
_S O ON
UA T_X CE OF
UA T_F D_ FF
UA T_F CE N
_F D
W
R EN XO
R OR XO
R OR _X
W FF_
UA T_S D_
d)
R EN
ve
UA T_S
r
se
R
(re
UA
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UART_FORCE_XOFF Set this bit to set the internal CTSn and stop the transmitter from sending data.
(R/W)
UART_FORCE_XON Set this bit to clear the internal CTSn and enable the transmitter to continue
sending data. (R/W)
UART_XONOFF_DEL Set this bit to remove the flow-control char from the received data. (R/W)
UART_SW_FLOW_CON_EN Set this bit to enable software flow control. It is used with register
sw_xon or sw_xoff. (R/W)
D
OL
SH
E
HR
_T
VEI
)
CT
ed
_A
rv
RT
se
(re
UA
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0F0 Reset
UART_ACTIVE_THRESHOLD When the number of positive edges of RxD signal is larger than or equal
to (UART_ACTIVE_THRESHOLD+2), the system emerges from Light-sleep mode and becomes
active. (R/W)
LD
D
OL
HO
SH
ES
AR
AR
RE
R
CH
TH
H
H
_C
_T
F_
F_
ON
ON
OF
OF
_X
_X
_X
_X
RT
RT
RT
RT
UA
UA
UA
UA
31 24 23 16 15 8 7 0
UART_XOFF_CHAR This register stores the Xoff flow control char. (R/W)
UART_XON_CHAR This register stores the Xon flow control char. (R/W)
UART_XOFF_THRESHOLD When the data amount in receive-FIFO is more than what this register
indicates, it will send an Xoff char, with uart_sw_flow_con_en set to 1. (R/W)
UART_XON_THRESHOLD When the data amount in receive-FIFO is less than what this register indi-
cates, it will send an Xon char, with uart_sw_flow_con_en set to 1. (R/W)
HD
M
UM
R
NU
TH
_N
E_
E_
K
DL
DL
BR
I
)
_I
X_
X_
ed
_R
_T
_T
rv
RT
RT
RT
se
(re
UA
UA
UA
31 28 27 20 19 10 9 0
UART_TX_BRK_NUM This register is used to configure the number of zeros (0) sent, after the pro-
cess of sending data is completed. It is active when txd_brk is set to 1. (R/W)
UART_TX_IDLE_NUM This register is used to configure the duration between transfers. (R/W)
UART_RX_IDLE_THRHD When the receiver takes more time to receive Byte data than what this reg-
ister indicates, it will produce a frame-end signal. (R/W)
UA T_D _EN _R _E M
M
R L1 TX TX U
NU
X_ N
UA T_D 85 BY_ Y_N
EN
Y_
R S 4 RX D L
DL
UA _R 85 X_
X_
N
RT S4 _R
_E
_T
S4 N
_R _E
85
UA _R 85
85
d)
RT L0
S4
RT S4
ve
_R
UA R _
r
RT
RT
se
(re
UA
UA
31 10 9 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UART_RS485_TX_DLY_NUM This register is used to delay the transmitter’s internal data signal.
(R/W)
UART_RS485_RX_DLY_NUM This register is used to delay the receiver’s internal data signal. (R/W)
UART_RS485RXBY_TX_EN 1: enable the RS-485 transmitter to send data, when the RS-485 receiver
line is busy; 0: the RS-485 transmitter should not send data, when its receiver is busy. (R/W)
UART_RS485TX_RX_EN Set this bit to enable the transmitter’s output signal loop back to the re-
ceiver’s input signal. (R/W)
UART_DL1_EN Set this bit to delay the STOP bit by 1 bit. (R/W)
UART_DL0_EN Set this bit to delay the STOP bit by 1 bit after DL1. (R/W)
RE
ed
_P
rv
RT
se
(re
UA
31 24 23 0
0 0 0 0 0 0 0 0 0x0186A00 Reset
UART_PRE_IDLE_NUM This register is used to configure the idle-time duration before the first
at_cmd is received by the receiver. When the duration is less than what this register indicates,
it will not take the next data received as an at_cmd char. (R/W)
M
NU
E_
L
ID
T_
OS
)
ed
_P
rv
RT
se
(re
UA
31 24 23 0
0 0 0 0 0 0 0 0 0x0186A00 Reset
UART_POST_IDLE_NUM This register is used to configure the duration between the last at_cmd
and the next data. When the duration is less than what this register indicates, it will not take the
previous data as an at_cmd char. (R/W)
U T
TO
P_
GA
)
X_
ed
_R
rv
RT
se
(re
UA
31 24 23 0
0 0 0 0 0 0 0 0 0x0001E00 Reset
UART_RX_GAP_TOUT This register is used to configure the interval between the at_cmd chars.
When the interval is greater than the value of this register, it will not take the data as continuous
at_cmd chars. The register should be configured to more than half of the baud rate. (R/W)
D_
N
R_
CM
HA
)
T_
ed
_C
_A
rv
RT
RT
se
(re
UA
UA
31 16 15 8 7 0
UART_CHAR_NUM This register is used to configure the number of continuous at_cmd chars re-
ceived by the receiver. (R/W)
UART_AT_CMD_CHAR This register is used to configure the content of an at_cmd char. (R/W)
HD
RH
3
_H
3
HR
TH
_H
_H
_H
LD
Y_
_T
LD
HD
HD
PT
HO
LL
HO
HR
HR
M
FU
ES
ES
_T
_E
T
_
_
R
OW
HR
D
UT
EM
TH
EM
ZE
ZE
_P
_T
FL
TO
F_
M
SI
_M
SI
EM
ON
)
UA ed)
X_
X_
X_
X_
OF
X_
ed
ed
X
_M
_R
_R
_R
_R
_X
_X
_T
_T
rv
rv
rv
RT
RT
RT
RT
RT
RT
RT
RT
RT
se
se
se
(re
(re
(re
UA
UA
UA
UA
UA
UA
UA
UA
31 30 28 27 25 24 23 22 21 20 18 17 15 14 11 10 7 6 3 2 1 0
UART_TX_SIZE This register is used to configure the amount of memory allocated to the transmit-
FIFO. The default number is 128 bytes. (R/W)
UART_RX_SIZE This register is used to configure the amount of memory allocated to the receive-
FIFO. The default number is 128 bytes. (R/W)
UART_MEM_PD Set this bit to power down the memory. When the reg_mem_pd register is set to
1 for all UART controllers, Memory will enter the low-power mode. (R/W)
R
DD
DD
A
A
R_
D_
_W
_R
X
X
_T
_T
EM
EM
)
)
ed
ed
_M
_M
rv
rv
RT
RT
se
se
(re
(re
UA
UA
31 24 23 13 12 2 1 0
0 0 0 0 Reset
R
DD
DD
A
_A
R_
RD
W
X_
X_
_R
_R
EM
EM
d)
)
ed
ve
_M
_M
rv
r
RT
RT
se
se
(re
(re
UA
UA
31 24 23 13 12 2 1 0
0 0 0 0 Reset
T
NT
N
_C
_C
EM
EM
M
_M
)
X_
ed
_R
_T
rv
RT
RT
se
(re
UA
UA
31 6 5 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_P
rv
RT
se
(re
UA
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x0FFFFF Reset
UART_POSEDGE_MIN_CNT This register stores the count of RxD positive edges. It is used in the
autobaud detection process. (RO)
NT
_C
IN
M
E_
E DG
EG
)
ed
_N
rv
RT
se
(re
UA
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x0FFFFF Reset
UART_NEGEDGE_MIN_CNT This register stores the count of RxD negative edges. It is used in the
autobaud detection process. (RO)
The addresses in parenthesis besides register names are the register addresses relative to the UDMA base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 13.4.2 UHCI Register Summary.
_S D_ _E F_
CI EA EC EO
C AR OF C
C RC IDL N
UH I_U _E _CR
UH I_H _R E_
_U T1 E
E
T0 E
CI AR _C
_C
_E
AR _C
C EN E
UH I_L OD
UH I_U T2
ER
C NC
)
)
C AR
ed
ed
ed
UH I_U
UH I_E
rv
rv
rv
se
se
se
C
C
UH
UH
(re
(re
(re
31 22 21 20 19 18 17 16 15 12 11 10 9 8 0
0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UHCI_SEPER_EN Set this bit to use a special char and separate the data frame. (R/W)
UHCI_UART2_CE Set this bit to use UART2 and transmit or receive data. (R/W)
UHCI_UART1_CE Set this bit to use UART1 and transmit or receive data. (R/W)
UHCI_UART0_CE Set this bit to use UART and transmit or receive data. (R/W)
C _ ON T_ T_ AW
C UT OF R IN RA
C UT CR ER IN _
C _ _ IN W W
UH I_O DS R_ TY_ INT
UH _IN _D EM ER _R
UH I_T HU _IN RA AW
UH I_IN ERR E_ RA RA
W
AR NT AW
C X_ NG T_ R
IN AW
X_ AR NT W
C X_ NE F_ R
CI X_S NG T_ W
RA
UH I_T DO EO NT_
UH I_IN SU EOF T_R
_R T _I RA
UH I_O DS _EO F_
ST T_I _R
T_ _R
T_
C _ K EO
UH I_IN LIN AL_
C UT T
UH _O _TO
CI UT
d)
ve
UH I_O
r
se
C
UH
31
(re 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UHCI_IN_DSCR_ERR_INT_RAW The raw interrupt status bit for the UHCI_IN_DSCR_ERR_INT inter-
rupt. (RO)
UHCI_OUT_EOF_INT_RAW The raw interrupt status bit for the UHCI_OUT_EOF_INT interrupt. (RO)
UHCI_OUT_DONE_INT_RAW The raw interrupt status bit for the UHCI_OUT_DONE_INT interrupt.
(RO)
UHCI_IN_ERR_EOF_INT_RAW The raw interrupt status bit for the UHCI_IN_ERR_EOF_INT interrupt.
(RO)
UHCI_IN_SUC_EOF_INT_RAW The raw interrupt status bit for the UHCI_IN_SUC_EOF_INT interrupt.
(RO)
UHCI_IN_DONE_INT_RAW The raw interrupt status bit for the UHCI_IN_DONE_INT interrupt. (RO)
UHCI_TX_HUNG_INT_RAW The raw interrupt status bit for the UHCI_TX_HUNG_INT interrupt. (RO)
UHCI_RX_HUNG_INT_RAW The raw interrupt status bit for the UHCI_RX_HUNG_INT interrupt. (RO)
UHCI_TX_START_INT_RAW The raw interrupt status bit for the UHCI_TX_START_INT interrupt. (RO)
UHCI_RX_START_INT_RAW The raw interrupt status bit for the UHCI_RX_START_INT interrupt. (RO)
C _ K EO IN T _ST
UH _IN LIN L_ Q_ _S NT
UH I_O _E _ER R_ T_ T
C UT CR ER IN _S
CI UT TA G_ INT _I
C UT OF R IN ST
C _ SC P R_ T
C _ ON T_ T_ T
C UT CR F_ IN T
UH I_O _TO RE Q_ WM
UH I_IN ERR E_ ST ST
UH I_T HU _IN ST T
UH I_R HU _IN INT_ T
C UT S_ G_ L_
C X_ NG T_ S
C X_ NE F_ S
C _ C_ _I T
UH I_T DO EO NT_
UH I_IN SU EOF T_S
ST
AR NT T
UH I_O D_ RE FUL
IN T
_R T _I ST
ST T_I _S
T_ _S
T_
CI X_S NG T_
X_ AR NT
C _ _ IN
C EN A_ _
UH I_S D_ IFO
C EN NF
UH I_S A_I
)
C M
ed
UH I_D
rv
se
C
UH
(re
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UHCI_IN_DSCR_ERR_INT_ST The masked interrupt status bit for the UHCI_IN_DSCR_ERR_INT in-
terrupt. (RO)
UHCI_OUT_EOF_INT_ST The masked interrupt status bit for the UHCI_OUT_EOF_INT interrupt. (RO)
UHCI_OUT_DONE_INT_ST The masked interrupt status bit for the UHCI_OUT_DONE_INT interrupt.
(RO)
UHCI_IN_ERR_EOF_INT_ST The masked interrupt status bit for the UHCI_IN_ERR_EOF_INT inter-
rupt. (RO)
UHCI_IN_SUC_EOF_INT_ST The masked interrupt status bit for the UHCI_IN_SUC_EOF_INT inter-
rupt. (RO)
UHCI_IN_DONE_INT_ST The masked interrupt status bit for the UHCI_IN_DONE_INT interrupt. (RO)
UHCI_TX_HUNG_INT_ST The masked interrupt status bit for the UHCI_TX_HUNG_INT interrupt. (RO)
UHCI_RX_HUNG_INT_ST The masked interrupt status bit for the UHCI_RX_HUNG_INT interrupt.
(RO)
UHCI_TX_START_INT_ST The masked interrupt status bit for the UHCI_TX_START_INT interrupt.
(RO)
UHCI_RX_START_INT_ST The masked interrupt status bit for the UHCI_RX_START_INT interrupt.
(RO)
A
C _ K EO IN NA _EN
C _ ON T_ T_ NA
C UT CR F_ IN NA
C UT OF R IN EN
C UT T G_ IN _
C UT CR ER IN _
C _ _ IN A A
UH I_O _TO RE Q_ WM
UH I_IN ERR E_ EN EN
UH I_T HU _IN EN NA
UH I_R HU _IN INT_ NA
UH I_T DO EO NT_ A
C UT S_ G_ L_
C X_ NG T_ E
A
AR NT NA
C _ C_ _I N
C X_ NE F_ E
IN NA
X_ AR NT A
CI X_S NG T_ A
EN
UH I_IN SU EOF T_E
_R T _I EN
UH I_O D_ RE FUL
ST T_I _E
T_ _E
T_
C EN A_ _
UH I_S D_ IFO
C EN NF
UH I_S A_I
)
C M
ed
UH I_D
rv
se
C
UH
(re
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UHCI_OUT_EOF_INT_ENA The interrupt enable bit for the UHCI_OUT_EOF_INT interrupt. (R/W)
UHCI_OUT_DONE_INT_ENA The interrupt enable bit for the UHCI_OUT_DONE_INT interrupt. (R/W)
UHCI_IN_DONE_INT_ENA The interrupt enable bit for the UHCI_IN_DONE_INT interrupt. (R/W)
UHCI_TX_HUNG_INT_ENA The interrupt enable bit for the UHCI_TX_HUNG_INT interrupt. (R/W)
UHCI_RX_HUNG_INT_ENA The interrupt enable bit for the UHCI_RX_HUNG_INT interrupt. (R/W)
UHCI_TX_START_INT_ENA The interrupt enable bit for the UHCI_TX_START_INT interrupt. (R/W)
UHCI_RX_START_INT_ENA The interrupt enable bit for the UHCI_RX_START_INT interrupt. (R/W)
LR
C _ K EO IN LR _C
UH I_O _E _ER R_ T_ LR
UH _IN LIN L_ Q_ _C NT
C _ SC P R_ LR
C _ ON T_ T_ LR
CI UT CR_ F_ INT LR
C UT OF R IN CL
UH I_O _TO RE Q_ WM
C _ _ IN R R
UH I_O DS R_ TY_ INT
UH _IN D EM ER _C
UH I_O DS _EO F_ T_C
UH I_IN ERR E_ CL CL
UH I_T HU _IN CL LR
UH I_R HU _IN INT_ LR
C _ C_ _I LR
C UT S_ G_ L_
C X_ NG T_ C
C X_ NE F_ C
R
AR NT LR
IN LR
X_ AR NT R
CI X_S NG T_ R
UH I_T DO EO NT_
UH I_IN SU EOF T_C
CL
UH I_O D_ RE FUL
_R T _I CL
ST T_I _C
T_ _C
T_
C EN A_ _
UH I_S D_ IFO
C EN NF
UH I_S A_I
_
)
C M
ed
UH I_D
rv
se
C
UH
(re
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UL Y
_F T
L
UT MP
_O _E
CI UT
)
ed
UH I_O
rv
se
C
UH
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 Reset
TA
H
DA
US
_W
_P
FO
FO
FI
I
TF
UT
)
)
ed
ed
U
_O
_O
rv
rv
se
se
CI
CI
UH
UH
(re
(re
31 17 16 15 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
UHCI_OUTFIFO_PUSH Set this bit to push data into DMA FIFO. (R/W)
UHCI_OUTFIFO_WDATA This is the data that need to be pushed into DMA FIFO. (R/W)
DA
_P
_R
FO
FO
)
)
FI
I
NF
ed
ed
IN
rv
rv
_I
_
se
se
CI
CI
UH
UH
(re
(re
31 17 16 15 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0000 Reset
UHCI_INFIFO_POP Set this bit to pop data from DMA FIFO. (R/W)
UHCI_INFIFO_RDATA This register stores the data popping from DMA FIFO. (RO)
NK TA T
LI _S TAR
_S RT
R
P
CI UT K_ RK
DD
UT NK ES
TO
UH I_O LIN _PA
_O LI R
_A
C UT K
NK
UH I_O LIN
LI
C UT
UT
)
ed
UH I_O
_O
rv
se
CI
C
UH
UH
(re
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000000 Reset
UHCI_OUTLINK_PARK 1: the outlink descriptor’s FSM is in idle state; 0: the outlink descriptor’s FSM
is working. (RO)
UHCI_OUTLINK_RESTART Set this bit to restart the outlink descriptor from the last address. (R/W)
UHCI_OUTLINK_STOP Set this bit to stop dealing with the outlink descriptor. (R/W)
UHCI_OUTLINK_ADDR This register stores the least significant 20 bits of the first outlink descriptor’s
address. (R/W)
ST T
DR
OP
CI LI _R K
K_ R
_I NK ES
UH I_IN INK AR
AD
C L _P
K_
UH I_IN INK
IN
)
ed
C NL
NL
rv
_I
_I
se
CI
CI
UH
UH
UH
(re
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000000 Reset
UHCI_INLINK_PARK 1: the inlink descriptor’s FSM is in idle state; 0: the inlink descriptor’s FSM is
working. (RO)
UHCI_INLINK_START Set this bit to start dealing with the inlink descriptors. (R/W)
UHCI_INLINK_STOP Set this bit to stop dealing with the inlink descriptors. (R/W)
UHCI_INLINK_ADDR This register stores the 20 least significant bits of the first inlink descriptor’s
address. (R/W)
E
_R
_S RE
N
UM
UM N
_E
CK M_
_S _E
CK EQ
HE NU
HE _S
(re X_C K_
_C CK
_T C
CI X_A
d)
d)
CI HE
ve
UH I_C
UH I_T
rv
r
se
se
C
C
UH
UH
(re
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UH I_T 13_ SC N
UH I_T 11_ C_ N
SC N
N
C X_ ES EN
CI X_D ESC EN
C X_ _E _E
C X_ _E EN
C X_ ES _E
_E _E
X_ _E EN
_E
UH I_R 11_ C_
UH I_T C0 SC
UH I_R DB C_
C0 SC
_T B _
C X_ ES
UH I_R 13_
)
C X_
ed
UH I_R
rv
se
C
UH
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 Reset
UHCI_RX_13_ESC_EN Set this bit to enable replacing flow control char 0x13, when DMA sends data.
(R/W)
UHCI_RX_11_ESC_EN Set this bit to enable replacing flow control char 0x11, when DMA sends data.
(R/W)
UHCI_RX_DB_ESC_EN Set this bit to enable replacing 0xdb char, when DMA sends data. (R/W)
UHCI_RX_C0_ESC_EN Set this bit to enable replacing 0xc0 char, when DMA sends data. (R/W)
UHCI_TX_13_ESC_EN Set this bit to enable decoding flow control char 0x13, when DMA receives
data. (R/W)
UHCI_TX_11_ESC_EN Set this bit to enable decoding flow control char 0x11, when DMA receives
data. (R/W)
UHCI_TX_DB_ESC_EN Set this bit to enable decoding 0xdb char, when DMA receives data. (R/W)
UHCI_TX_C0_ESC_EN Set this bit to enable decoding 0xc0 char, when DMA receives data. (R/W)
FT
FT
NA
NA
HI
HI
_S
_E
_S
_E
UT
UT
UT
UT
UT
UT
EO
EO
EO
EO
EO
EO
M
M
TI
TI
TI
TI
TI
TI
O_
O_
O_
O_
O_
O_
IF
IF
IF
IF
IF
IF
)
XF
XF
XF
XF
XF
XF
ed
_R
_R
_R
_T
_T
_T
rv
se
CI
CI
CI
CI
CI
CI
UH
UH
UH
UH
UH
UH
(re
31 24 23 22 20 19 12 11 10 8 7 0
UHCI_RXFIFO_TIMEOUT_ENA This is the enable bit for DMA send-data timeout. (R/W)
UHCI_RXFIFO_TIMEOUT_SHIFT The tick count is cleared when its value is equal to or greater than
(17’d8000»reg_rxfifo_timeout_shift). (R/W)
UHCI_RXFIFO_TIMEOUT This register stores the timeout value. When DMA takes more time to read
data from RAM than what this register indicates, it will produce the UHCI_RX_HUNG_INT interrupt.
(R/W)
UHCI_TXFIFO_TIMEOUT_SHIFT The tick count is cleared when its value is equal to or greater than
(17’d8000»reg_txfifo_timeout_shift). (R/W)
UHCI_TXFIFO_TIMEOUT This register stores the timeout value. When DMA takes more time to re-
ceive data than what this register indicates, it will produce the UHCI_TX_HUNG_INT interrupt.
(R/W)
AR
HA
H
_C
_C
Q2
Q2
Q2
SE
SE
SE
C_
C_
C_
)
ed
ES
ES
ES
rv
I_
_
se
CI
CI
C
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_ESC_SEQ2_CHAR1 This register stores the second char used to replace the reg_esc_seq2
in data. (R/W)
UHCI_ESC_SEQ2_CHAR0 This register stores the first char used to replace the reg_esc_seq2 in
data. (R/W)
UHCI_ESC_SEQ2 This register stores the flow_control char to turn off the flow_control. (R/W)
14.1 Introduction
The LED_PWM controller is primarily designed to control the intensity of LEDs, although it can be used to gen-
erate PWM signals for other purposes as well. It has 16 channels which can generate independent waveforms
that can be used to drive RGB LED devices. For maximum flexibility, the high-speed as well as the low-speed
channels can be driven from one of four high-speed/low-speed timers. The PWM controller also has the ability
to automatically increase or decrease the duty cycle gradually, allowing for fades without any processor inter-
ference. To increase resolution, the LED_PWM controller is also able to dither between two values, when a
fractional PWM value is configured.
The LED_PWM controller has eight high-speed and eight low-speed PWM generators. In this document, they
will be referred to as hschn and lschn, respectively. These channels can be driven from four timers which will
be indicated by h_timerx and l_timerx.
14.2 Functional Description
14.2.1 Architecture
Figure 14-1 shows the architecture of the LED_PWM controller. As can be seen in the figure, the LED_PWM
controller contains eight high-speed and eight low-speed channels. There are four high-speed clock modules
for the high-speed channels, from which one h_timerx can be selected. There are also four low-speed clock
modules for the low-speed channels, from which one l_timerx can be selected.
Figure 14-2 illustrates a PWM channel with its selected timer; in this instance a high-speed channel and associ-
ated high-speed timer.
Fractional
divider (18 bit)
14.2.2 Timers
Divider input ... ... ... ... ... ... ... ... ... ... ...
clock
Clock pulses ... Clock pulses Clock pulses divided Clock pulses ... Clock pulses Clock pulses divided Clock pulses Clock pulses divided
divided by A divided by A by (A+1) divided by A divided by A by (A+1)
divided by A by (A+1)
...
...
Divider output
clock
The clock of each high-speed timer, LEDC_CLKx, has two clock sources: REF_TICK or APB_CLK. For more
information on the clock sources, please see Chapter Reset And Clock. The input clock is divided down by a
divider first. The division factor is specified by LEDC_CLK_DIV_NUM_HSTIMERx which contains a fixed point
number: the highest 10 bits represent the integer portion A, while the lowest eight bits contain the fractional
portion B. The effective division factor LEDC_CLK_DIVx is as follows:
B
LEDC_CLK_DIV x = A + 256
When the fractional part B is not 0, the input and output clock of the divider is shown as in figure 14-3. Among
the 256 output clocks, B of them are divided by (A+1), whereas the remaining (256-B) are divided by A. Output
clocks divided by (A+1) are evenly distributed in the total 256 output clocks.
The output clock of the divider is the base clock for the counter which will count up to the value specified in
LEDC_HSTIMERx_DUTY_RES. An overflow interrupt will be generated once the counting value reaches
2LEDC_HST IM ERx_DU T Y _RES − 1, at which point the counter restarts counting from 0. It is also possible to
reset, suspend, and read the values of the counter by software.
The output signal of the timer is the 20-bit value generated by the counter. The cycle period of this signal
defines the frequency of the signals of any PWM channels connected to this timer.
The frequency of a PWM generator output signal, sig_outn, depends on the frequency of the timer’s clock
source LEDC_CLKx, the division factor of the divider LEDC_CLK_DIVx, as well as the duty resolution (counter
width) LEDC_HSTIMERx_DUTY_RES:
fLEDC_CLKx
fsig_outn =
LEDC_CLK_DIVx · 2LEDC_HSTIMERx_DUTY_RES
Based on the formula above, the desired duty resolution can be calculated as follows:
fLEDC_CLKx
LEDC_HSTIMERx_DUTY_RES = log2
fsig_outn · LEDC_CLK_DIVx
Table 14-1 lists the commonly-used frequencies and their corresponding resolutions.
The low-speed timers l_timerx on the low-speed channel differ from the high-speed timers h_timerx in two
aspects:
1. Where the high-speed timer clock source can be clocked from REF_TICK or APB_CLK, the low-speed
timers are sourced from either REF_TICK or SLOW_CLOCK. The SLOW_CLOCK source can be either APB_CLK
(80 MHz) or 8 MHz, and can be selected using LEDC_APB_CLK_SEL.
2. The high-speed counter and divider are glitch-free, which means that if the software modifies the maximum
counter or divisor value, the update will come into effect after the next overflow interrupt. In contrast, the
low-speed counter and divider will update these values only when LEDC_LSTIMERx_PARA_UP is set.
14.2.3 Channels
A channel takes the 20-bit value from the counter of the selected high-speed timer and compares it to a
set of two values in order to set the channel output. The first value it is compared to is the content of
LEDC_HPOINT_HSCHn; if these two match, the output will be latched high. The second value is the sum
of LEDC_HPOINT_HSCHn and LEDC_DUTY_HSCHn[24..4]. When this value is reached, the output is latched
low. By using these two values, the relative phase and the duty cycle of the PWM output can be set. Figure
14-4 illustrates this.
LEDC_DUTY_HSCHn is a fixed-point register with four fractional bits. As mentioned before, when LEDC_DUTY_
HSCHn[24..4] is used in the PWM calculation directly, LEDC_DUTY_HSCHn[3..0] can be used to dither the out-
put. If this value is non-zero, with a statistical chance of LEDC_DUTY_HSCHn[3..0]/16, the actual PWM pulse
will be one cycle longer. This effectively increases the resolution of the PWM generator to 25 bits, but at the
The channels also have the ability to automatically fade from one duty cycle value to another. This feature is
enabled by setting LEDC_DUTY_START_HSCHn. When this bit is set, the PWM controller will automatically incre-
ment or decrement the value in LEDC_DUTY_HSCHn, depending on whether the bit LEDC_DUTY_INC_HSCHn is
set or cleared, respectively. The speed the duty cycle changes is defined as such: every time the LEDC_DUTY_CYCLE_
HSCHn cycles, the content of LEDC_DUTY_SCALE_HSCHn is added to or subtracted from LEDC_DUTY_HSCHn[24..4].
The length of the fade can be limited by setting LEDC_DUTY_NUM_HSCHn: the fade will only last that number
of cycles before finishing. A finished fade also generates an interrupt.
Notes
• When the LEDC is in fade mode, it is not supported to perform operations (e.g., pause) on the process or
configure the following registers:
– LEDC_HPOINT_H/LSCHn
– LEDC_DUTY_H/LSCHn
– LEDC_DUTY_START_H/LSCHn
– LEDC_DUTY_INC_H/LSCHn
– LEDC_DUTY_NUM_H/LSCHn
– LEDC_DUTY_CYCLE_H/LSCHn
– LEDC_DUTY_SCALE_H/LSCHn
• When LEDC is in decremental fade mode and LEDC_DUTY_HSCHn is 2LEDC_HST IM ERx_DU T Y _RES , LEDC_
DUTY_SCALE_HSCHn cannot be set to 1. When LEDC is in decremental fade mode and LEDC_DUTY_LSCHn
is 2LEDC_LST IM ERx_DU T Y _RES , LEDC_DUTY_SCALE_LSCHn cannot be set to 1.
14.2.4 Interrupts
• LEDC_DUTY_CHNG_END_LSCHn_INT: Triggered when a fade on a low-speed channel has finished.
• LEDC_HS_TIMERx_OVF_INT: Triggered when a high-speed timer has reached its maximum counter value.
• LEDC_LS_TIMERx_OVF_INT: Triggered when a low-speed timer has reached its maximum counter value.
14.4 Registers
The addresses in parenthesis besides register names are the register addresses relative to the LED PWM base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 14.3 Register Summary.
_H Hn
Hn
C
_S _HS
SC
_E Hn
UT C
N
DC _O HS
EL
IG LV_
ER
_S E_
d)
IM
DC DL
ve
_T
LE C_I
r
se
D
(re
LE
LE
31 4 3 2 1 0
0x00000000 0 0 0 Reset
LEDC_IDLE_LV_HSCHn This bit is used to control the output value when high-speed channel n is
inactive. (R/W)
LEDC_SIG_OUT_EN_HSCHn This is the output enable control bit for high-speed channel n. (R/W)
LEDC_TIMER_SEL_HSCHn There are four high-speed timers. These two bits are used to select one
of them for high-speed channel n: (R/W)
0: select hstimer0;
1: select hstimer1;
2: select hstimer2;
3: select hstimer3.
_H
rv
DC
se
(re
LE
31 20 19 0
LEDC_HPOINT_HSCHn The output value changes to high when htimerx(x=[0,3]), selected by high-
speed channel n, has reached LEDC_HPOINT_HSCHn[19:0]. (R/W)
n
S CH
_H
TY
)
ed
DU
rv
C_
se
D
(re
LE
31 25 24 0
LEDC_DUTY_HSCHn The register is used to control output duty. When hstimerx(x=[0,3]), selected
by high-speed channel n, has reached LEDC_LPOINT_HSCHn, the output signal changes to low.
(R/W)
LEDC_LPOINT_HSCHn=LEDC_LPOINT_HSCHn[19:0]+LEDC_DUTY_HSCHn[24:4] (1)
LEDC_LPOINT_HSCHn=LEDC_LPOINT_HSCHn[19:0]+LEDC_DUTY_HSCHn[24:4] +1) (2)
See the Functional Description for more information on when (1) or (2) is chosen.
n
Hn
CH n
CH
Hn
HS CH
SC
n
HS
SC
C_ HS
E_
E_
_H
IN T_
AL
CL
Y_ AR
UM
SC
CY
UT ST
N
_D TY_
Y_
Y_
Y_
UT
UT
UT
DC U
LE C_D
_D
_D
D
C_
DC
DC
D
D
LE
LE
LE
LE
31 30 29 20 19 10 9 0
LEDC_DUTY_INC_HSCHn This register is used to increase or decrease the duty of output signal for
high-speed channel n. (R/W)
LEDC_DUTY_NUM_HSCHn This register is used to control the number of times the duty cycle is
increased or decreased for high-speed channel n. (R/W)
LEDC_DUTY_CYCLE_HSCHn This register is used to increase or decrease the duty cycle every time
LEDC_DUTY_CYCLE_HSCHn cycles for high-speed channel n. (R/W)
LEDC_DUTY_SCALE_HSCHn This register is used to increase or decrease the step scale for high-
speed channel n. (R/W)
R
n_
CH
HS
Y_
UT
)
ed
_D
rv
DC
se
(re
LE
31 25 24 0
LEDC_DUTY_HSCHn_R This register represents the current duty cycle of the output signal for high-
speed channel n. (RO)
_L Hn
Hn
C
DC _O LS Hn
_S _LS
SC
_E n
UT CH
IG LV_ SC
N
_S E_ _L
EL
DC DL UP
LE _I A_
ER
DC AR
)
IM
ed
LE C_P
_T
rv
se
D
(re
LE
LE
31 5 4 3 2 1 0
0x0000000 0 0 0 0 Reset
LEDC_IDLE_LV_LSCHn This bit is used to control the output value, when low-speed channel n is
inactive. (R/W)
LEDC_SIG_OUT_EN_LSCHn This is the output enable control bit for low-speed channel n. (R/W)
LEDC_TIMER_SEL_LSCHn There are four low-speed timers, the two bits are used to select one of
them for low-speed channel n. (R/W)
0: select lstimer0;
1: select lstimer1;
2: select lstimer2;
3: select lstimer3.
Hn
SC
_L
NT
I
PO
)
ed
_H
rv
DC
se
(re
LE
31 20 19 0
LEDC_HPOINT_LSCHn The output value changes to high when lstimerx(x=[0,3]), selected by low-
speed channel n, has reached LEDC_HPOINT_LSCHn[19:0]. (R/W)
n
CH
LS
TY_
)
ed
DU
rv
C_
se
D
(re
LE
31 25 24 0
LEDC_DUTY_LSCHn The register is used to control output duty. When lstimerx(x=[0,3]), chosen
by low-speed channel n, has reached LEDC_LPOINT_LSCHn,the output signal changes to low.
(R/W)
LEDC_LPOINT_LSCHn=(LEDC_HPOINT_LSCHn[19:0]+LEDC_DUTY_LSCHn[24:4]) (1)
LEDC_LPOINT_LSCHn=(LEDC_HPOINT_LSCHn[19:0]+LEDC_DUTY_LSCHn[24:4] +1) (2)
See the Functional Description for more information on when (1) or (2) is chosen.
n
n
CH n
CH
CH
Hn
LS CH
n
LS
LS
SC
C_ LS
E_
E_
_L
IN T_
L
CL
Y_ AR
UM
CA
CY
UT ST
_S
_D TY_
Y_
Y_
TY
UT
UT
DC U
DU
LE C_D
_D
_D
C_
DC
DC
D
D
LE
LE
LE
LE
31 30 29 20 19 10 9 0
LEDC_DUTY_INC_LSCHn This register is used to increase or decrease the duty of output signal for
low-speed channel n. (R/W)
LEDC_DUTY_NUM_LSCHn This register is used to control the number of times the duty cycle is
increased or decreased for low-speed channel n. (R/W)
LEDC_DUTY_SCALE_LSCHn This register is used to increase or decrease the step scale for low-
speed channel n. (R/W)
_D
rv
DC
se
(re
LE
31 25 24 0
LEDC_DUTY_LSCHn_R This register represents the current duty of the output signal for low-speed
channel n. (RO)
x
ER
IM
ES
x_ T x
ST
ER RS ER
_R
E
_H
IM x_ IM
TY
US
ST ER ST
DU
PA
NU
_H IM _H
x_
V_
DC ST EL
ER
DI
LE C_H K_S
IM
K_
ST
)
ed
D IC
_H
_C
LE C_T
rv
DC
DC
se
D
(re
LE
LE
LE
31 26 25 24 23 22 5 4 0
LEDC_TICK_SEL_HSTIMERx This bit is used to select APB_CLK or REF_TICK for high-speed timer
x. (R/W)
1: APB_CLK;
0: REF_TICK.
LEDC_HSTIMERx_RST This bit is used to reset high-speed timer x. The counter value will be ’zero’
after reset. (R/W)
LEDC_HSTIMERx_PAUSE This bit is used to suspend the counter in high-speed timer x. (R/W)
LEDC_CLK_DIV_NUM_HSTIMERx This register is used to configure the division factor for the divider
in high-speed timer x. The least significant eight bits represent the fractional part. (R/W)
LEDC_HSTIMERx_DUTY_RES This register is used to control the range of the counter in high-speed
timer x. The counter range is [0, 2LEDC_HST IM ERx_DU T Y _RES ], the maximum bit width for
counter is 20. (R/W)
_H
rv
DC
se
(re
LE
31 20 19 0
0x0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LEDC_HSTIMERx_CNT Software can read this register to get the current counter value of high-
speed timer x. (RO)
x
ER
M
S
x_ T x
I M x _ IM P
E
I
ST
ER RS ER
ST ER ST U
_R
_L IM _L A_
_L
TY
US
DC ST EL AR
DU
PA
NU
LE C_L K_S x_P
x_
V_
D IC ER
ER
DI
LE C_T IM
M
K_
I
)
D ST
ST
ed
L
_C
LE C_L
_L
rv
DC
DC
se
D
(re
LE
LE
LE
31 27 26 25 24 23 22 5 4 0
LEDC_LSTIMERx_RST This bit is used to reset low-speed timer x. The counter will show 0 after
reset. (R/W)
LEDC_LSTIMERx_PAUSE This bit is used to suspend the counter in low-speed timer x. (R/W)
LEDC_CLK_DIV_NUM_LSTIMERx This register is used to configure the division factor for the divider
in low-speed timer x. The least significant eight bits represent the fractional part. (R/W)
LEDC_LSTIMERx_DUTY_RES This register is used to control the range of the counter in low-speed
timer x. The counter range is [0, 2LEDC_LST IM ERx_DU T Y _RES ], the max bit width for counter
is 20. (R/W)
ST
ed
_L
rv
DC
se
(re
LE
31 20 19 0
0x0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LEDC_LSTIMERx_CNT Software can read this register to get the current counter value of low-speed
timer x. (RO)
31
31
0
0
0
0
0
0
(re (re
0
0
se se
Espressif Systems
rv r ve
ed
0
0
) d)
terrupt. (RO)
terrupt. (RO)
0
0
interrupt. (RO)
interrupt. (RO)
0
24
0
24
0
0
23
23
LE LE
D D
14 LED PWM Controller (LEDC)
0
0
22
22
LE C_D LE C_D
D U D U
0
0
21
21
LE C_D TY_ LE C_D TY_
D U CH D U CH
0
0
20
20
0
0
19
19
LE _D TY_ NG ND LE _D TY_ NG ND
D U CH _E _L D U CH _E _L
0
0
18
18
0
0
17
17
0
0
16
16
LEDC_DUTY_CHNG_END_LSCHn_INT_ST The
LEDC_DUTY_CHNG_END_HSCHn_INT_ST The
D U CH _E _L H5 NT D U CH _E _L H5 NT W
LEDC_DUTY_CHNG_END_LSCHn_INT_RAW The
0
0
15
15
405
0
0
14
14
0
0
13
13
raw
DC U CH _E _L H2 T_ DC U CH _E _L H2 T_ W
masked
0
0
masked
12
12
LE _D TY_ NG ND SC _I ST LE _D TY_ NG ND SC _I RA
D U CH _E _L H1 NT D U CH _E _L H1 NT W
0
0
11
11
10
10
9
9
0
0
interrupt
D U CH _E _H H T_ D U CH _E _H H T_ W
interrupt
interrupt
8
8
0
0
DC U CH _E _H H NT DC U CH _E _H H NT W
7
7
0
0
6
6
0
0
status
D ST CH _E _H H NT D ST CH _E _H H NT AW
status
status
5
5
0
0
4
4
0
0
bit
D ST ER V _H H NT D ST ER V _H H NT W
bit
bit
3
3
0
0
2
2
0
0
for
D ST ER VF NT D ST ER VF NT W NT W
for
for
1
1
0
0
0
0
LE _H IM 3_ F_I ST LE _H IM 3_ F_I RA
DC ST ER V TO N O
DC ST ER V T W N
the
the
LEDC_HSTIMERx_OVF_INT_RAW The raw interrupt status bit for the LEDC_HSTIMERx_OVF_INT in-
LEDC_LSTIMERx_OVF_INT_RAW The raw interrupt status bit for the LEDC_LSTIMERx_OVF_INT in-
the
the
0 Reset
0 Reset
IM 1_O F_ _S IM 1_O F_ _R
ER V INT T ER V INT AW
31
31
0
0
0
0
0
0
(re (re
0
0
se se
Espressif Systems
rv rv
ed ed
0
0
) )
rupt. (R/W)
rupt. (R/W)
0
0
0
24
0
24
0
0
23
23
LE LE
D D
14 LED PWM Controller (LEDC)
0
0
22
22
LE C_D LE C_D
D U D U
0
0
21
21
LE C_D TY_ LE C_D TY_
D U CH D U CH
0
0
20
20
0
0
19
19
LE _D TY_ NG ND LE _D TY_ NG ND
D U CH _E _L D U CH _E _L
0
0
18
18
0
0
17
17
0
0
16
16
LEDC_DUTY_CHNG_END_LSCHn_INT_CLR Set
LEDC_DUTY_CHNG_END_HSCHn_INT_CLR Set
D U CH _E _L H5 NT R D U CH _E _L H5 NT A
LEDC_DUTY_CHNG_END_LSCHn_INT_ENA The
LEDC_DUTY_CHNG_END_HSCHn_INT_ENA The
0
0
15
15
406
0
0
14
14
0
0
13
13
this
LEDC_DUTY_CHNG_END_HSCHn_INT interrupt. (R/W)
0
0
12
12
this
LE _D TY_ NG ND SC _I CL LE _D TY_ NG ND SC _I EN
D U CH _E _L H1 NT R D U CH _E _L H1 NT A
0
0
11
11
interrupt
D U CH _E _H H0 T_ R D U CH _E _H H0 T_ A
10
10
9
9
0
0
bit
bit
LE C_D TY_ NG ND SC 7_IN _CL LE C_D TY_ NG ND SC 7_IN _EN
D U CH _E _H H T_ R D U CH _E _H H T_ A
8
8
0
0
7
7
0
0
enable
enable
to
to
6
6
0
0
5
5
0
0
bit
D ST ER _E _H H NT R D ST ER _E _H H NT A
4
4
0
0
3
3
0
0
clear
clear
2
2
0
0
for
for
LE C_H IM 1_O F_I _CL 0_I CL LE C_H IM 1_O F_I _EN 0_I EN
D ST ER VF NT R NT R D ST ER VF NT A NT A
1
1
0
0
0
0
LE _H IM 3_ F_I CL LE _H IM 3_ F_I EN
O
DC ST ER V T R N O
DC ST ER V T A N
_H IM 2_ F_ _C _H IM 2_ F_ _E
ST ER OV INT LR ST ER OV INT NA
0 Reset
0 Reset
IM 1_O F_ _C IM 1_O F_ _E
ER V INT LR ER V INT NA
L
SE
LK_
_C
PB
d)
ve
A
C_
r
se
D
(re
LE
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
15.1 Introduction
The RMT (Remote Control) module is primarily designed to send and receive infrared remote control signals that
implement on-off keying in a carrier frequency, but due to its design it can be used to generate various types of
signals. An RMT transmitter does this by reading consecutive duration values of an active and inactive output
from the built-in RAM block, optionally modulating it with a carrier wave. A receiver will inspect its input signal,
optionally filtering it, and will place the lengths of time the signal is active and inactive in the RAM block.
The RMT module has eight channels, numbered zero to seven; registers, signals and blocks that are duplicated
in each channel are indicated by an n which is used as a placeholder for the channel number.
The RMT module contains eight channels. Each channel has both a transmitter and a receiver, but only one of
them can be active in every channel. The eight channels share a 512x32-bit RAM block which can be read and
written by the processor cores over the APB bus, read by the transmitters, and written by the receivers. The
transmitted signal can optionally be modulated by a carrier wave. Each channel is clocked by a divided-down
signal derived from either the APB bus clock or REF_TICK.
The data structure in RAM is shown in Figure 15-2. Each 32-bit value contains two 16-bit entries, with two fields
in every entry, ”level” and ”period”. ”Level” indicates whether a high-/low-level value was received or is going to
be sent, while ”period” points out the divider-clock cycles for which the level lasts. A zero period is interpreted
as an end-marker: the transmitter will stop transmitting once it has read this, and the receiver will write this,
once it has detected that the signal it received has gone idle.
Normally, only one block of 64x32-bit worth of data can be sent or received. If the data size is larger than this
block size, blocks can be extended or the channel can be configured for the wraparound mode.
The RMT RAM can be accessed via the APB bus. The initial address is 0x3FF56800. The RAM block is divided
into eight 64x32-bit blocks. By default, each channel uses one block (block zero for channel zero, block
one for channel one, and so on). Users can extend the memory to a specific channel by configuring the
RMT_MEM_SIZE_CHn register; setting this to >1 will prompt the channel to use the memory of subsequent
channels as well. The RAM address range of channel n is start_addr_CHn to end_addr_CHn, which is defined
by:
To protect a receiver from overwriting the blocks a transmitter is about to transmit, RMT_MEM_OWNER_CHn can
be configured to designate the owner, be it a transmitter or receiver, of channel n’s RAM block. This way, if this
ownership is violated, the RMT_CHn_ERR interrupt will be generated.
Note: When enabling the continuous transmission mode by setting RMT_REG_TX_CONTI_MODE, the transmitter
will transmit the data on the channel continuously, that is, from the first byte to the last one, then from the first
to the last again, and so on. In this mode, there will be an idle level lasting one clk_div cycle between N and
N+1 transmissions.
15.2.3 Clock
The main clock of a channel is generated by taking either the 80 MHz APB clock or REF_TICK (usually 1MHz),
according to the state of RMT_REF_ALWAYS_ON_CHn. (For more information on clock sources, please see
Chapter Reset And Clock.) Then, the aforementioned state gets scaled down using a configurable 8-bit divider
to create the channel clock which is used by both the carrier wave generator and the counter. The divider value
can be set by configuring RMT_DIV_CNT_CHn.
15.2.4 Transmitter
When the RMT_TX_START_CHn register is 1, the transmitter of channel n will start reading and sending data from
RAM. The transmitter will receive a 32-bit value each time it reads from RAM. Of these 32 bits, the low 16-bit
To transmit more data than can be fitted in the channel’s RAM, the wraparound mode can be enabled. In this
mode, when the transmitter has reached the last entry in the channel’s memory, it will loop back to the first
byte. To use this mechanism for sending more data than can be fitted in the channel’s RAM, fill the RAM with
the initial events and set RMT_CHn_TX_LIM_REG to cause an RMT_CHn_TX_THR_EVENT_INT interrupt before
the wraparound happens. Then, when the interrupt happens, the already sent data should be replaced by
subsequent events, so that when the wraparound happens the transmitter will seamlessly continue sending
the new events.
With or without the wraparound mode enabled, transmission ends when an entry with zero length is encoun-
tered. When this happens, the transmitter will generate an RMT_CHn_TX_END_INT interrupt and return to the
idle state. When a transmitter is in the idle state, the output level defaults to end-mark 0. Users can also
configure RMT_IDLE_OUT_EN_CHn and RMT_IDLE_OUT_LV_CHn to control the output level manually.
The output of the transmitter can be modulated using a carrier wave by setting RMT_CARRIER_EN_CHn. The
carrier frequency and duty cycle can be configured by adjusting the carrier’s high and low durations in channel-
clock cycles, in RMT_CARRIER_HIGH_CHn and RMT_CARRIER_LOW_CHn.
15.2.5 Receiver
When RMT_RX_EN_CHn is set to 1, the receiver in channel n becomes active, measuring the duration between
input signal edges. These will be written as period/level value pairs to the channel RAM in the same fashion
as the transmitter sends them. Receiving ends, when the receiver detects no change in signal level for more
than RMT_IDLE_THRES_CHn channel clock ticks. The receiver will write a final entry with 0 period, generate an
RMT_CHn_RX_END_INT_RAW interrupt and return to the idle state.
The receiver has an input signal filter which can be configured using RMT_RX_FILTER_EN_CHn: The filter will
remove pulses with a length of less than RMT_RX_FILTER_THRES_CHn in APB clock periods.
When the RMT module is inactive, the RAM can be put into low-power mode by setting the RMT_MEM_PD
register to 1.
15.2.6 Interrupts
• RMT_CHn_TX_THR_EVENT_INT: Triggered when the amount of data the transmitter has sent matches the
value of RMT_CHn_TX_LIM_REG.
• RMT_CHn_TX_END_INT: Triggered when the transmitter has finished transmitting the signal.
15.4 Registers
The addresses in parenthesis besides register names are the register addresses relative to the RMT base ad-
dress provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute register
addresses are listed in Section 15.3 Register Summary.
Hn Hn
_C _C
n
EN LV
CH
R_ T_
CH
n
S_
IE OU
CH
E_
RE
RR R_
IZ
T_
T_ RR D
TH
RM _CA _P
_S
CN
CA IE
E_
T EM
EM
RM _M )
V_
T d
DL
RM rve
DI
M
I
T_
T_
T_
se
RM
RM
RM
(re
31 30 29 28 27 24 23 8 7 0
RMT_MEM_PD This bit is used to power down the entire RMT RAM block. (It only exists in
RMT_CH0CONF0). 1: power down memory; 0: power up memory. (R/W)
RMT_CARRIER_OUT_LV_CHn This bit is used for configuration when the carrier wave is being trans-
mitted. Transmit on low output level with 0, and transmit on high output level with 1. (R/W)
RMT_CARRIER_EN_CHn This is the carrier modulation enable-control bit for channel n. Carrier mod-
ulation is enabled with 1, while carrier modulation is disabled with 0. (R/W)
RMT_MEM_SIZE_CHn This register is used to configure the amount of memory blocks allocated to
channel n. (R/W)
RMT_IDLE_THRES_CHn In receive mode, when no edge is detected on the input signal for longer
than REG_IDLE_THRES_CHn channel clock cycles, the receive process is finished. (R/W)
RMT_DIV_CNT_CHn This register is used to set the divider for the channel clock of channel n. (R/W)
Hn
Hn n
CH Hn
_C CH
_C
T d WN OD n
T_ C
n
_S C T_ n
F_ WA _C n
RM rve _O _M CH
ER E_
TA Hn CH
RS N_
CN YS Hn
ES
TX N_ RS H
RE AL LV H
T_ _E R_ T_C
T_ F_ UT_ _C
se EM TI N_
HR
T_ _O
Hn
RM _RE _O _EN
RM _RX _W RS
(re _M ON R_E
_T
_C
ER
T M _
T LE UT
RT
T _C E
D
ILT
RM _TX FILT
RM M _R
RM _ID _O
_F
T_ EM
d)
RM _M )
T LE
E
ve
RX
RM RX
RM _ID
r
T_
T_
se
T
RM
RM
RM
(re
31 20 19 18 17 16 15 8 7 6 5 4 3 2 1 0
RMT_IDLE_OUT_EN_CHn This is the output enable-control bit for channel n in IDLE state. (R/W)
RMT_IDLE_OUT_LV_CHn This bit configures the level of output signals in channel n when the latter
is in IDLE state. (R/W)
RMT_REF_ALWAYS_ON_CHn This bit is used to select the channel’s base clock. 1:clk_apb;
0:clk_ref. (R/W)
RMT_REF_CNT_RST_CHn Setting this bit resets the clock divider of channel n. (R/W)
RMT_RX_FILTER_THRES_CHn In receive mode, channel n ignores input pulse when the pulse width
is smaller than this value in APB clock periods. (R/W)
RMT_TX_CONTI_MODE_CHn If this bit is set, instead of going to an idle state when transmission
ends, the transmitter will restart transmission. This results in a repeating output signal. (R/W)
RMT_MEM_OWNER_CHn This bit marks channel n’s RAM block ownership. Number 1 indicates that
the receiver is using the RAM, while 0 indicates that the transmitter is using the RAM. (R/W)
RMT_MEM_RD_RST_CHn Set this bit to reset the read-RAM address for channel n by accessing
the transmitter. (R/W)
RMT_MEM_WR_RST_CHn Set this bit to reset the write-RAM address for channel n by accessing
the receiver. (R/W)
31
31
RM RM
T T
0
0
30
30
RM _CH RM _CH
T 7_ T 7_
0
0
29
29
RM _CH TX RM _CH TX
T 6 _T T 6 _T
0
0
28
28
(RO)
(RO)
RM _CH _TX HR_ RM _CH _TX HR_
T 5 _T E T 5 _T E
0
0
27
27
RM _CH _TX HR VEN RM _CH _TX HR VEN
Espressif Systems
T 4 _T _E T_ T 4 _T _E T_
rupt. (RO)
rupt. (RO)
0
0
26
26
RM _CH _TX HR VE INT RM _CH _TX HR VE INT
T 3 _T _E NT _S T 3 _T _E NT _
0
0
25
25
RM _CH _TX HR VE _IN T RM _CH _TX HR VE _IN RAW
T 2 _T _E NT T_ T 2 _T _E NT T_
0
0
24
24
RM _CH _TX HR VE _IN ST RM _CH _TX HR VE _IN RA
W
T 1_ _T _E NT T_ T 1_ _T _E NT T_
0
0
23
23
RM _CH TX HR VE _IN ST RM _CH TX HR VE _IN RA
W
T 0 _T _E NT T_ T 0 _T _E NT T_
0
0
22
22
RM _CH _TX HR_ VE _IN ST RM _CH _TX HR_ VE _IN RAW
T 7_ _T E NT T_ _
T 7_ T E T _ N T
0
0
21
21
T 7_ R_ _E T_ T_ T_ 7_ R_ _EV T_ T_R
0
0
20
20
0
0
19
19
0
0
ST
18
18
RMT_CHn_TX_THR_EVENT_INT_ST The
R
T_ 6_ _ IN T _ S R
T_ 6_ _ IN A _ R
RMT_CHn_TX_THR_EVENT_INT_RAW The
0
0
17
17
RM CH RX IN T_ RM CH RX IN T_ W
T 6 _ T_ ST T 6 _ _ A T R
0
0
16
16
0
0
15
15
414
T 5 R _I _S T 5 R _I _R
0
0
14
14
masked
T 5 _ T_ S T 5 _ T_ R
0
0
13
13
0
0
12
12
0
0
11
11
10
10
interrupt
T 3 _E _ T 3 _E _
9
9
0
0
8
8
0
0
T 3 _ T_ ST T 3 _ T_ R
7
7
0
0
T 2 _E _ T 2 _E _
status
6
6
0
0
5
5
0
0
4
4
0
0
bit
RM _CH _TX END ST RM _CH _TX END RAW AW
T 1_ _E _ T 1_ _E _
3
3
0
0
2
2
0
0
for
T 1_ _E _S S T 1_ _E _R R
1
1
0
0
RM _CH TX ND T T RM _CH TX ND AW AW
T 0 _E _I T 0 _E _I
0
0
RMT_CHn_ERR_INT_RAW The raw interrupt status bit for the RMT_CHn_ERR_INT interrupt. (RO)
the
the
RMT_CHn_TX_END_INT_ST The masked interrupt status bit for the RMT_CHn_TX_END_INT inter-
RMT_CHn_RX_END_INT_ST The masked interrupt status bit for the RMT_CHn_RX_END_INT inter-
RMT_CHn_ERR_INT_ST The masked interrupt status bit for the RMT_CHn_ERR_INT interrupt. (RO)
RMT_CHn_TX_END_INT_RAW The raw interrupt status bit for the RMT_CHn_TX_END_INT interrupt.
RMT_CHn_RX_END_INT_RAW The raw interrupt status bit for the RMT_CHn_RX_END_INT interrupt.
CH RX IN T_ CH RX IN T_ W
0_ _E T_S ST 0_ _E T_R RA
0 Reset
0 Reset
TX ND T TX ND A W
_E _ _E _ W
31
31
RM RM
T T
0
0
30
30
RM _CH RM _CH
T 7_ T 7_
0
0
29
29
RM _CH TX RM _CH TX
T 6 _T T_ 6_ _TH
0
0
28
28
RM _CH _TX HR_ RM CH TX R_
(R/W)
(R/W)
T 5 _T E T 5 _T E
0
0
27
27
RM _CH _TX HR VEN RM _CH _TX HR VEN
Espressif Systems
T 4 _T _E T_ T 4 _T _E T_
rupt. (WO)
0
0
26
26
RM _CH _TX HR VE INT RM _CH _TX HR VE INT
T 3 _T _E NT _C T 3 _T _E NT _
0
0
25
25
RM _CH _TX HR VE _IN LR RM _CH _TX HR VE _IN ENA
T 2 _T _E NT T_ T 2 _T _E NT T_
0
0
24
24
RM _CH _TX HR VE _IN CLR RM _CH _TX HR VE _IN EN
T 1_ _T _E NT T_ T 1_ _T _E NT T_ A
0
0
23
23
RM _CH TX HR VE _IN CLR RM _CH TX HR VE _IN EN
T 0 _T _E NT T_ T 0 _T _E NT T_ A
0
0
22
22
0
0
21
21
T 7_ R_ _E T_ T_ T 7_ R_ _E T_ T_ A
0
0
20
20
0
0
19
19
0
0
18
18
0
0
17
17
RM CH RX IN T_ R RM CH RX IN T_ A
T 6 _ _ L T C T 6 _ _ N T E
0
0
16
16
0
0
15
15
415
T 5 R _I _C T 5 R _I _E
RMT_CHn_TX_THR_EVENT_INT interrupt. (R/W)
0
0
14
14
0
0
13
13
T 4 _E _ T 4 _E _ A
0
0
12
12
0
0
11
11
10
10
9
9
0
0
8
8
0
0
T 3 _ T_ C T 3 _ T_ E
7
7
0
0
6
6
0
0
5
5
0
0
4
4
0
0
3
3
0
0
2
2
0
0
1
1
0
0
0
0
T_ 0_ R_ _IN CL T_ 0_ R_ _IN EN
the
CH RX IN T_ R CH RX IN T_ A
0_ _E T_C CL 0_ _E T_E EN
0 Reset
0 Reset
TX ND L R TX ND N A
_E _ R _E _ A
Hn
CH
_C
H_
W
IG
LO
_H
R_
ER
E
RI
RI
R
R
CA
CA
T_
T_
RM
RM
31 16 15 0
RMT_CARRIER_HIGH_CHn This field is used to configure the carrier wave’s high-level clock period
for channel n. The clock source can be either REF_TICK or APB_CLK. (R/W)
RMT_CARRIER_LOW_CHn This field is used to configure the carrier wave’s low-level clock period
for channel n. The clock source can be either REF_TICK or APB_CLK. (R/W)
Hn
_C
IM
)
_L
ed
TX
rv
T_
se
RM
(re
31 9 8 0
RMT_TX_LIM_CHn When channel n sends more entries than specified here, it produces a
TX_THR_EVENT interrupt. (R/W)
S_ N
EN
ES _E
CC AP
_A WR
EM X_
M _T
T_ EM
)
ed
RM _M
rv
se
T
RM
(re
31 2 1 0
0x00000000 0 0 Reset
RMT_MEM_TX_WRAP_EN This bit enables wraparound mode: when the transmitter of a channel
has reached the end of its memory block, it will resume sending at the start of its memory
region. (R/W)
16.1 Introduction
The Motor Control Pulse Width Modulator (MCPWM) peripheral is intended for motor and power control. It
provides six PWM outputs that can be set up to operate in several topologies. One common topology uses a
pair of PWM outputs driving an H-bridge to control motor rotation speed and rotation direction.
The timing and control resources inside are allocated into two major types of submodules: PWM timers and
PWM operators. Each PWM timer provides timing references that can either run freely or be synced to other
timers or external sources. Each PWM operator has all necessary control resources to generate waveform pairs
for one PWM channel. The MCPWM peripheral also contains a dedicated capture submodule that is used in
systems where accurate timing of external events is important.
ESP32 contains two MCPWM peripherals: MCPWM0 and MCPWM1. Their control registers are located in 4-KB
memory blocks starting at memory locations 0x3FF5E000 and 0x3FF6C000 respectively.
16.2 Features
Each MCPWM peripheral has one clock divider (prescaler), three PWM timers, three PWM operators, and a
capture module. Figure 16-1 shows the submodules inside and the signals on the interface. PWM timers are
used for generating timing references. The PWM operators generate desired waveform based on the timing
references. Any PWM operator can be configured to use the timing references of any PWM timers. Different
PWM operators can use the same PWM timer’s timing references to produce related PWM signals. PWM oper-
ators can also use different PWM timers’ values to produce the PWM signals that work alone. Different PWM
timers can also be synced together.
– The 16-bit counter in the PWM timer can work in count-up mode, count-down mode or count-up-
down mode.
– A hardware sync can trigger a reload on the PWM timer with a phase register. It will also trigger the
prescaler’ restart, so that the timer’s clock can also be synced. The source of the sync can come
from any GPIO or any other PWM timer’s sync_out.
– Every PWM operator has two PWM outputs: PWMxA and PWMxB. They can work independently, in
symmetric and asymmetric configuration.
– Modulating of PWM output by high-frequency carrier signals, useful when gate drives are insulated
with a transformer.
– Period, time stamps and important control registers have shadow registers with flexible updating
methods.
– Programmable fault handling allocated on fault condition in both cycle-by-cycle mode and one-shot
mode.
– A fault condition can force the PWM output to either high or low logic levels.
• Capture Module
– Decoding current or voltage amplitude derived from duty-cycle-encoded signals from current/voltage
sensors
– Three individual capture channels, each of which has a time-stamp register (32 bits)
– The capture timer can sync with a PWM timer or external signals.
16.3 Submodules
16.3.1 Overview
This section lists the configuration parameters of key submodules. For information on adjusting a specific
parameter, e.g. synchronization source of PWM timer, please refer to Section 16.3.2 for details.
Configuration parameter:
Configuration parameters:
• Configure the the reloading phase (including the value and the phase) used during software and hardware
synchronization.
• Synchronize the PWM timers with each other. Either hardware or software synchronization may be used.
• Configure the source of the PWM timer’s the synchronization input to one of the seven sources below:
– Three synchronization signals from the GPIO matrix: SYNC0, SYNC1, SYNC2.
• Configure the source of the PWM timer’s synchronization output to one of the four sources below:
The configuration parameters of the operator submodule are shown in Table 16-1.
• Set up the PWM duty cycle for PWMxA and/or PWMxB out-
put.
• Set up at which time the timing events occur.
• Define what action should be taken on timing events:
– Switch high or low PWMxA and/or PWMxB outputs
PWM Generator – Toggle PWMxA and/or PWMxB outputs
– Take no action on outputs
• Use direct s/w control to force the state of PWM outputs
• Add a dead time to raising and / or failing edge on PWM
outputs.
• Configure update method for this submodule.
• Configure if and how the PWM module should react the fault
event signals.
• Specify the action taken when a fault event occurs:
– Force PWMxA and/or PWMxB high.
– Force PWMxA and/or PWMxB low.
– Configure PWMxA and/or PWMxB to ignore any fault
event.
Fault Handler • Configure how often the PWM should react to fault events:
– One-shot
– Cycle-by-cycle
• Generate interrupts.
• Bypass the fault handler submodule entirely.
• Set up an option for cycle-by-cycle actions clearing.
• If desired, independently-configured actions can be taken
when time-base counter is counting down or up.
Configuration parameters:
• Enable fault event generation and configure the polarity of fault event generation for every fault signal
Configuration parameters:
• Control how often events occur by specifying the PWM timer frequency or period.
• Configure a particular PWM timer to synchronize with other PWM timers or modules.
• Set one of the following timer counting modes: count-up, count-down, count-up-down.
• Change the rate of the PWM timer clock (PT_clk) with a prescaler. Each timer has its own prescaler con-
figured with PWM_TIMERx_PRESCALE of register PWM_TIMER0_CFG0_REG. The PWM timer increments
or decrements at a slower pace, depending on the setting of this register.
• Count-Up Mode:
In this mode, the PWM timer increments from zero until reaching the value configured in the period reg-
ister. Once done, the PWM timer returns to zero and starts increasing again. PWM period is equal to the
value of period register + 1.
Note: The period register is PWM_TIMERx_PERIOD (x = 0, 1, 2), i.e., PWM_TIMER0_PERIOD, PWM_TIMER1_PERIOD,
PWM_TIMER2_PERIOD.
• Count-Down Mode:
The PWM timer decrements to zero, starting from the value configured in the period register. After reaching
zero, it is set back to the period value. Then it starts to decrement again. In this case, the PWM period is
also equal to the value of period register + 1.
• Count-Up-Down Mode:
This is a combination of the two modes mentioned above. The PWM timer starts increasing from zero
until the period value is reached. Then, the timer decreases back to zero. This pattern is then repeated.
The PWM period is the result of (the value of period register × 2 + 1).
Figures 16-7 to 16-10 show PWM timer waveforms in different modes, including timer behavior during synchro-
nization events.
When the PWM timer is running, it generates the following timing events periodically and automatically:
• UTEP
The timing event generated when the PWM timer’s value equals to the value of the period register
(PWM_TIMERx_PERIOD) and when the PWM timer is increasing.
• UTEZ
The timing event generated when the PWM timer’s value equals to zero and when the PWM timer is
increasing.
• DTEP
The timing event generated when the PWM timer’s value equals to the value of the period register
(PWM_TIMERx_PERIOD) and when the PWM timer is decreasing.
• DTEZ
The timing event generated when the PWM timer’s value equals to zero and when the PWM timer is
decreasing.
Figures 16-11 to 16-13 show the timing waveforms of U/DTEP and U/DTEZ.
Please note that in the Count-Up-Down Mode, when the counting direction is increasing, the timer range is [0,
period value - 1], and when the counting direction is decreasing, the timer range is [period value, 1]. That
is, in this mode, when synchronizing the timer to 0, decreasing counting direction will be illegal, namely,
MCPWM_TIMERn_PHASE_DIRECTION cannot be set to 1. Similarly, when synchronizing the timer to period
value, increasing counting direction will be illegal, namely, MCPWM_TIMERn_PHASE_DIRECTION cannot be
set to 0. Therefore, when the timer is synchronized to 0, the counting direction can only be increasing, and
MCPWM_TIMERn_PHASE_DIRECTION will be 0. When the timer is synchronized to the period value, the count-
ing direction can only be decreasing, and MCPWM_TIMERn_PHASE_DIRECTION will be 1.
• Active Register
This register is directly responsible for controlling all actions performed by hardware.
• Shadow Register
It acts as a temporary buffer for a value to be written on the active register. Before this happens, the con-
tent of the shadow register has no direct effect on the controlled hardware. At a specific, user-configured
point in time, the value saved in the shadow register is copied to the active register. This helps to prevent
spurious operation of the hardware, which may happen when a register is asynchronously modified by
software. Both the shadow register and the active register have the same memory address. The software
always writes into, or reads from the shadow register. The moment of updating the active register is de-
termined by its specific update method register. The update can start when the PWM timer is equal to
zero, when the PWM timer is equal to period,at a synchronization moment, or immediately. Software can
trigger a globally forced update which will prompt all registers in the module to be updated according to
shadow registers.
• Generates a PWM signal pair, based on timing references obtained from the corresponding PWM timer.
• Each signal out of the PWM signal pair includes a specific pattern of dead time.
In this submodule, important timing events are generated or imported. The events are then converted into
specific actions to generate the desired waveforms at the PWMxA and PWMxB outputs.
• Generation of timing events based on time stamps configured using the A and B registers. Events happen
when the following conditions are satisfied:
– UTEA: the PWM timer is counting up and its value is equal to register A.
– UTEB: the PWM timer is counting up and its value is equal to register B.
– DTEA: the PWM timer is counting down and its value is equal to register A.
– DTEB: the PWM timer is counting down and its value is equal to register B.
• Qualification and generation of set, clear and toggle actions, based on the timing events.
• Controlling of the PWM duty cycle, depending on configuration of the PWM generator submodule.
• Handling of new time stamp values, using shadow, registers to prevent glitches in the PWM cycle.
The time stamp registers A and B, as well as action configuration registers PWM_GENx_A_REG and PWM_GENx_B_REG
are shadowed. Shadowing provides a way of updating registers in sync with the hardware. For a description of
the shadow registers, please see 16.3.2.3.
Timing Events
For convenience, all timing signals and events are summarized in Table 16-2.
The purpose of a software-force event is to impose non-continuous or continuous changes on the PWMxA and
PWMxB outputs. The change is done asynchronously. Software-force control is handled by the
PWM_PWM_GENx_FORCE_REG registers.
The selection and configuration of T0/T1 in the PWM generator submodule is independent of the configuration
of fault events in the fault handler submodule. A particular trip event may or may not be configured to cause trip
action in the fault handler submodule, but the same event can be used by the PWM generator to trigger T0/T1
for controlling PWM waveforms.
It is important to know that when the PWM timer is in count-up-down mode, it will always decrement after a TEP
event, and will always increment after a TEZ event. So when the PWM timer is in count-up-down mode, DTEP
and UTEZ events will occur, while the events UTEP and DTEZ will never occur.
The PWM generator can handle multiple events at the same time. Events are prioritized by the hardware and
relevant details are provided in Table 16-3 and Table 16-4. Priority levels range from 1 (the highest) to 7 (the
lowest). Please note that the priority of TEP and TEZ events depends on the PWM timer’s direction.
If the value of A or B is set to be greater than the period, then U/DTEA and U/DTEB will never occur.
Notes:
1. UTEP and UTEZ do not happen simultaneously. When the PWM timer is in count-up mode, UTEP will always
happen one cycle earlier than UTEZ, as demonstrated in Figure 16-11, so their action on PWM signals will
not interrupt each other. When the PWM timer is in count-up-down mode, UTEP will not occur.
2. DTEP and DTEZ do not happen simultaneously. When the PWM timer is in count-down mode, DTEZ will
always happen one cycle earlier than DTEP, as demonstrated in Figure 16-12, so their action on PWM
signals will not interrupt each other. When the PWM timer is in count-up-down mode, DTEZ will not occur.
The PWM generator submodule controls the behavior of outputs PWMxA and PWMxB when a particular timing
event occurs. The timing events are further qualified by the PWM timer’s counting direction (up or down).
Knowing the counting direction, the submodule may then perform an independent action at each stage of the
PWM timer counting up or down.
• Set High:
Set the output of PWMxA or PWMxB to a high level.
• Clear Low:
Clear the output of PWMxA or PWMxB by setting it to a low level.
• Toggle:
Change the current output level of PWMxA or PWMxB to the opposite value. If it is currently pulled high,
pull it low, or vice versa.
• Do Nothing:
Keep both outputs PWMxA and PWMxB unchanged. In this state, interrupts can still be triggered.
The configuration of actions on outputs is done by using registers PWN_GENx_A_REG and PWN_GENx_B_REG.
So, the action to be taken on each output is set independently. Also there is great flexibility in selecting actions
to be taken on a given output based on events. More specifically, any event listed in Table 16-2 can operate on
either output PWMxA or PWMxB. To check out registers for particular generator 0, 1 or 2, please refer to register
description in Section 16.4.
Figure 16-15 presents the symmetric PWM waveform generated when the PWM timer is counting up and down.
DC 0%–100% modulation can be calculated via the formula below:
If A matches the PWM timer value and the PWM timer is incrementing, then the PWM output is pulled up. If A
matches the PWM timer value while the PWM timer is decrementing, then the PWM output is pulled low.
The PWM waveforms in Figures 16-16 to 16-19 show some common PWM operator configurations. The following
conventions are used in the figures:
Figure 16-16. Count-Up, Single Edge Asymmetric Waveform, with Independent Modulation on PWMxA and
PWMxB — Active High
The duty modulation for PWMxA is set by B, active high and proportional to B.
The duty modulation for PWMxB is set by A, active high and proportional to A.
Figure 16-17. Count-Up, Pulse Placement Asymmetric Waveform with Independent Modulation on PWMxA
Pulses may be generated anywhere within the PWM cycle (zero – period).
PWMxA’s high time duty is proportional to (B – A).
Figure 16-18. Count-Up-Down, Dual Edge Symmetric Waveform, with Independent Modulation on PWMxA and
PWMxB — Active High
The duty modulation for PWMxA is set by A, active high and proportional to A.
The duty modulation for PWMxB is set by B, active high and proportional to B.
Outputs PWMxA and PWMxB can drive independent switches.
Figure 16-19. Count-Up-Down, Dual Edge Symmetric Waveform, with Independent Modulation on PWMxA and
PWMxB — Complementary
Software-Force Events
There are two types of software-force events inside the PWM generator:
Figure 16-20 shows a waveform of NCI software-force events. NCI events are used to force PWMxA output low.
Forcing on PWMxB is disabled in this case.
Figure 16-21 shows a waveform of CNTU software-force events. UTEZ events are selected as triggers for CNTU
software-force events. CNTU is used to force the PWMxB output low. Forcing on PWMxA is disabled.
Several options to generate signals on PWMxA and PWMxB outputs, with a specific placement of signal edges,
have been discussed in section 16.3.3.1. The required dead time is obtained by altering the edge placement
between signals and by setting the signal’s duty cycle. Another option is to control the dead time using a
specialized submodule – the Dead Time Generator.
The key functions of the dead time generator submodule are as follows:
• Generating signal pairs (PWMxA and PWMxB) with a dead time from a single PWMxA input
• This submodule may also be bypassed, if the dead time is configured directly in the generator submodule.
Delay registers RED and FED are shadowed with registers PWM_DTx_RED_CFG_REG and PWM_DTx_FED_CFG_REG.
For the description of shadow registers, please see section 16.3.2.3.
Options for setting up the dead-time submodule are shown in Figure 16-22.
Figure 16-22. Options for Setting up the Dead Time Generator Submodule
S0-8 in the figure above are switches controlled by registers PWM_DTx_CFG_REG shown in Table 16-5.
Switch Register
S0 PWM_DTx_B_OUTBYPASS
S1 PWM_DTx_A_OUTBYPASS
S2 PWM_DTx_RED_OUTINVERT
S3 PWM_DTx_FED_OUTINVERT
S4 PWM_DTx_RED_INSEL
S5 PWM_DTx_FED_INSEL
S6 PWM_DTx_A_OUTSWAP
S7 PWM_DTx_B_OUTSWAP
S8 PWM_DTx_DEB_MODE
All switch combinations are supported, but not all of them represent the typical modes of use. Table 16-6
documents some typical dead time configurations. In these configurations the position of S4 and S5 sets
PWMxA as the common source of both falling-edge and rising-edge delay. The modes presented in table 16-6
may be categorized as follows:
• Mode 1: Bypass delays on both falling (FED) as well as raising edge (RED)
In this mode the dead time submodule is disabled. Signals PWMxA and PWMxB pass through without any
modifications.
• Modes 6 and 7: Bypass delay on falling edge (FED) or rising edge (RED)
In these modes, either RED (Rising Edge Delay) or FED (Falling Edge Delay) is bypassed. As a result, the
corresponding delay is not applied.
Rising edge (RED) and falling edge (FED) delays may be set up independently. The delay value is programmed
using the 16-bit registers PWM_DTx_RED and PWM_DTx_FED. The register value represents the number of
clock (DT_clk) periods by which a signal edge is delayed. DT_CLK can be selected from PWM_clk or PT_clk
through register PWM_DTx_CLK_SEL.
To calculate the delay on falling edge (FED) and rising edge (RED), use the following formulas:
Function Overview
• Carrier frequency
Operational Highlights
The PWM carrier clock (PC_clk) is derived from PWM_clk. The frequency and duty cycle are configured by the
PWM_CARRIERx_PRESCALE and PWM_CARRIERx_DUTY bits in the PWM_CARRIERx_CFG_REG register. The
purpose of one-shot pulses is to provide high-energy impulse to reliably turn on the power switch. Subsequent
pulses sustain the power-on status. The width of a one-shot pulse is configurable with the PWM_CARRIERx_OSHTWTH
bits. Enabling/disabling of the carrier submodule is done with the PWM_CARRIERx_EN bit.
Waveform Examples
Figure 16-27 shows an example of waveforms, where a carrier is superimposed on original PWM pulses. This
figure do not show the first one-shot pulse and the duty-cycle control. Related details are covered in the
following two sections.
One-Shot Pulse
The width of the first pulse is configurable. It may assume one of 16 possible values and is described by the
formula below:
Where:
• (P W M _CARRIERx_OSHT W T H + 1) is the width of the first pulse (whose value ranges from 1 to 16).
The first one-shot pulse and subsequent sustaining pulses are shown in Figure 16-28.
Figure 16-28. Example of the First Pulse and the Subsequent Sustaining Pulses of the PWM Carrier Submodule
After issuing the first one-shot pulse, the remaining PWM signal is modulated according to the carrier frequency.
Users can configure the duty cycle of this signal. Tuning of duty may be required, so that the signal passes
through the isolating transformer and can still operate (turn on/off) the motor drive, changing rotation speed
and direction.
The duty cycle may be set to one of seven values, using PWM_CARRIERx_DUTY, or bits [7:5] of register
PWM_CARRIERx_CFG_REG.
Duty = P W M _CARRIERx_DU T Y ÷ 8
All seven settings of the duty cycle are shown in Figure 16-29.
Figure 16-29. Possible Duty Cycle Settings for Sustaining Pulses in the PWM Carrier Submodule
• Forcing outputs PWMxA and PWMxB, upon detected fault, to one of the following states:
– High
– Low
– Toggle
– No action taken
This section provides the operational tips and set-up options for the fault handler submodule.
Fault signals coming from pads are sampled and synced in the GPIO matrix. In order to guarantee the success-
ful sampling of fault pulses, each pulse duration must be at least two APB clock cycles. The fault detection
submodule will then sample fault signals by using PWM_clk. So, the duration of fault pulses coming from GPIO
matrix must be at least one PWM_clk cycle. Differently put, regardless of the period relation between APB
clock and PWM_clk, the width of fault signal pulses on pads must be at least equal to the sum of two APB clock
cycles and one PWM_clk cycle.
Each level of fault signals, FAULT0 to FAULT2, can be used by the fault handler submodule to generate fault
events (fault_event0 to fault_event2). Every fault event can be configured individually to provide CBC action,
OST action, or none.
• One 32-bit timer (counter) which can be synchronized with the PWM timer, another submodule or software.
• Three capture channels, each equipped with a 32-bit time-stamp and a capture prescaler.
• Independent edge polarity (rising/falling edge) selection for any capture channel.
16.5 Registers
The addresses in parenthesis besides register names are the register addresses relative to the MCPWM base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 16.4 Register Summary.
LE
CA
ES
_ PR
)
LK
ed
_C
rv
se
M
PW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
E
_U
AL
OD
SC
IO
I
ER
ER
RE
P
P
0_
0_
0_
ER
ER
ER
)
IM
M
ed
I
_T
_T
_T
rv
se
M
PW
PW
PW
(re
31 26 25 24 23 8 7 0
T
AR
OD
ST
M
0_
0_
ER
ER
d)
IM
IM
ve
_T
_T
r
se
M
PW
PW
(re
31 5 4 3 2 0
PWM_TIMER0_MOD PWM timer0 working mode. 0: freeze, 1: increase mode, 2: decrease mode,
3: up-down mode. (R/W)
PWM_TIMER0_START PWM timer0 start and stop control. 0: if PWM timer0 starts, then stops at
TEZ; 1: if timer0 starts, then stops at TEP; 2: PWM timer0 starts and runs on; 3: timer0 starts and
stops at the next TEZ; 4: timer0 starts and stops at the next TEP. TEP here and below means
the event that happens when the timer equals to period. (R/W)
L
IR
ER SY _SE
EN
NC W
_D
SY _S
I_
CO
SE
SE
0_ NC
HA
HA
YN
P
_S
0_
0_
IM 0_
M ER0
ER
ER
_T R
M IME
)
M
ed
I
_T
_T
_T
PW _T
rv
se
M
PW
PW
PW
PW
(re
31 21 20 19 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_TIMER1_SYNCI_EN When set, timer reloading with phase on sync input event is enabled.
(R/W)
ON
TI
EC
E
LU
IR
VA
D
0_
0_
ER
ER
)
M
ed
I
_T
_T
rv
se
M
PW
PW
(re
31 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
AL
D_
OD
SC
O
RI
I
ER
RE
PE
P
1_
1_
1_
ER
ER
ER
)
IM
IM
ed
I
_T
_T
_T
rv
se
M
PW
PW
PW
(re
31 26 25 24 23 8 7 0
PWM_TIMER1_PERIOD_UPMETHOD Updating method for the active register of PWM timer1 period.
0: immediately, 1: update at TEZ, 2: update at sync, 3: update at TEZ or sync. (R/W)
T
AR
OD
ST
M
1_
1_
ER
ER
d)
IM
IM
ve
_T
_T
r
se
M
PW
PW
(re
31 5 4 3 2 0
PWM_TIMER1_MOD PWM timer1 working mode. 0: freeze, 1: increase mode, 2: decrease mode,
3: up-down mode. (R/W)
PWM_TIMER1_START PWM timer1 start and stop control. 0: if PWM timer1 starts, then stops at TEZ;
1: if PWM timer1 starts, then stops at TEP; 2: PWM timer1 starts and runs on; 3: PWM timer1 starts
and stops at the next TEZ; 4: PWM timer1 starts and stops at the next TEP. (R/W)
EL
IR
EN
NC W
_S
_D
SY _S
I_
CO
SE
SE
1_ NC
HA
HA
M IME YN
ER SY
P
_S
1_
1_
IM 1_
M ER1
ER
ER
_T R
)
PW I M
ed
I
_T
_T
_T
PW _T
rv
se
M
PW
PW
PW
(re
31 21 20 19 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_TIMER1_SYNCI_EN When set, timer reloading with phase at a sync input event is enabled.
(R/W)
ON
TI
EC
E
LU
IR
VA
D
1_
1_
ER
ER
d)
M
ve
I
_T
_T
r
se
M
PW
PW
(re
31 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LE
_U
CA
OD
OD
ES
RI
RI
PR
PE
PE
2_
2_
2_
ER
ER
ER
)
IM
IM
IM
ed
_T
_T
_T
rv
se
M
PW
PW
PW
(re
31 26 25 24 23 8 7 0
T
AR
OD
ST
M
2_
2_
ER
ER
d)
IM
IM
ve
_T
_T
r
se
M
PW
PW
(re
31 5 4 3 2 0
PWM_TIMER2_MOD PWM timer2 working mode. 0: freeze, 1: increase mode, 2: decrease mode,
3: up-down mode. (R/W)
PWM_TIMER2_START PWM timer2 start and stop control. 0: if PWM timer2 starts, then stops at
TEZ; 1: if PWM timer2 starts, then stops at TEP; 2: PWM timer2 starts and runs on; 3: PWM
timer2 starts and stops at the next TEZ; 4: PWM timer2 starts and stops at the next TEP. (R/W)
L
IR
ER SY _SE
EN
NC W
_D
SY _S
I_
CO
E
2_ NC
AS
AS
YN
PH
PH
_S
2_
2_
IM 2_
M ER2
ER
ER
_T R
M IME
)
IM
IM
PW I M
ed
_T
_T
_T
PW _T
rv
se
M
PW
PW
PW
(re
31 21 20 19 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_TIMER2_SYNCI_EN When set, timer reloading with phase on sync input event is enabled.
(R/W)
ON
I
CT
E
LU
RE
VA
DI
2_
2_
ER
ER
)
M
ed
I
_T
_T
rv
se
M
PW
PW
(re
31 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
NC IN RT
T
_I RT
ER
SY I1_ VE
I0 VE
NV
L_ NC _IN
NA SY I2
EL
EL
E
ER L_ NC
IS
IS
IS
XT NA SY
NC
NC
NC
_E R _
SY
SY
SY
M XTE NAL
2_
0_
1_
PW _E R
ER
ER
ER
M XTE
)
IM
IM
IM
ed
PW _E
_T
_T
_T
rv
se
M
PW
PW
PW
PW
(re
31 12 11 10 9 8 6 5 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_TIMER2_SYNCISEL Select sync input for PWM timer2. 1: PWM timer0 sync_out, 2: PWM
timer1 sync_out, 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO
matrix, 6: SYNC2 from GPIO matrix, other values: no sync input selected. (R/W)
PWM_TIMER1_SYNCISEL Select sync input for PWM timer1. 1: PWM timer0 sync_out, 2: PWM
timer1 sync_out, 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO
matrix, 6: SYNC2 from GPIO matrix, other values: no sync input selected. (R/W)
PWM_TIMER0_SYNCISEL Select sync input for PWM timer0. 1: PWM timer0 sync_out, 2: PWM
timer1 sync_out, 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO
matrix, 6: SYNC2 from GPIO matrix, other values: no sync input selected. (R/W)
L
EL
SE
SE
RS
ER
ER
E
M
IM
M
TI
_T
TI
2_
1_
R0
OR
OR
TO
AT
AT
RA
ER
ER
PE
d)
P
ve
_O
_O
_O
r
se
M
PW
PW
PW
(re
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_OPERATOR2_TIMERSEL Select the PWM timer for PWM operator2’s timing reference. 0:
timer0, 1: timer1, 2: timer2. (R/W)
PWM_OPERATOR1_TIMERSEL Select the PWM timer for PWM operator1’s timing reference. 0:
timer0, 1: timer1, 2: timer2. (R/W)
PWM_OPERATOR0_TIMERSEL Select the PWM timer for PWM operator0’s timing reference. 0:
timer0, 1: timer1, 2: timer2. (R/W)
L
_F LL
D
D
UL
HO
HO
DW FU
SH _
ET
ET
A_ DW
M
M
UP
0_ SH
UP
A_
EN B_
B_
_G 0_
0_
0_
M EN
EN
EN
)
ed
PW _G
_G
_G
rv
se
M
PW
PW
PW
(re
31 10 9 8 7 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN0_B_SHDW_FULL Set and reset by hardware. If set, PWM generator 0 time stamp B’s
shadow register.ister is filled and to be transferred to time stamp B’s active register. If cleared,
time stamp B’s active register has been updated with Shadow register latest value. (RO)
PWM_GEN0_A_SHDW_FULL Set and reset by hardware. If set, PWM generator 0 time stamp A’s
shadow register.ister is filled and to be transferred to time stamp A’s active register. If cleared,
time stamp A’s active register has been updated with Shadow register latest value. (RO)
PWM_GEN0_B_UPMETHOD Updating method for PWM generator 0 time stamp B’s active register.
When all bits are set to 0: immediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP;
when bit2 is set to 1: sync; when bit3 is set to 1: disable the update. (R/W)
PWM_GEN0_A_UPMETHOD Updating method for PWM generator 0 time stamp A’s active register.
When all bits are set to 0: immediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP;
when bit2 is set to 1: sync; when bit3 is set to 1: disable the update. (R/W)
_A
N0
)
ed
E
_G
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
B
0_
EN
)
ed
_G
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
HO
ET
M
UP
EL
L
SE
G_
_S
1_
CF
T0
_T
0_
0_
N0
EN
EN
)
ed
E
_G
_G
_G
rv
se
M
PW
PW
PW
(re
31 10 9 7 6 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN0_T1_SEL Source selection for PWM generator 0 event_t1, taking effect immediately. 0:
fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none. (R/W)
PWM_GEN0_T0_SEL Source selection for PWM generator 0 event_t0, taking effect immediately,
0: fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none. (R/W)
PWM_GEN0_CFG_UPMETHOD Updating method for PWM generator 0’s active register of config-
uration. When all bits are set to 0: immediately; when bit0 is set to 1: TEZ; when bit1 is set to 1:
TEP; when bit2 is set to 1: sync; when bit3 is set to 1: disable the update. (R/W)
D
HO
E
E
OD
OD
ET
E
E
RC OD
OD
M
M
E_
UP
E_
_M
_M
C
RC
E_
CE
E
NC CE
NC CE
RC
FO
FO
_G _A_ OR
_G _B_ OR
_G _A_ OR
TU
TU
FO
IF
0_ CIF
IF
IF
NC
TU
CN
CN
N
CN
A_
_G _B_
B_
0_
0_
0
0
EN
PW EN
PW EN
PW EN
EN
EN
EN
d)
ve
_G
_G
_G
r
se
M
PW
PW
PW
PW
(re
31 16 15 14 13 12 11 10 9 8 7 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x20 Reset
B
EB
EZ
P
EZ
P
EA
A
0
T0
TE
TE
TE
TE
1
T1
UT
UT
UT
UT
DT
DT
_D
_D
_D
_D
_U
_U
A_
A_
A_
A_
A_
A_
_A
_A
_A
_A
0_
0_
0_
0_
0_
0_
0_
0_
N0
N0
0
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
d)
E
ve
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
r
se
M
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN0_A_DT0 Action on PWM0A triggered by event_t0 when the timer decreases. (R/W)
PWM_GEN0_A_DTEB Action on PWM0A triggered by event TEB when the timer decreases. (R/W)
PWM_GEN0_A_DTEA Action on PWM0A triggered by event TEA when the timer decreases. (R/W)
PWM_GEN0_A_DTEP Action on PWM0A triggered by event TEP when the timer decreases. (R/W)
PWM_GEN0_A_DTEZ Action on PWM0A triggered by event TEZ when the timer decreases. (R/W)
PWM_GEN0_A_UT1 Action on PWM0A triggered by event_t1 when the timer increases. (R/W)
PWM_GEN0_A_UT0 Action on PWM0A triggered by event_t0 when the timer increases. (R/W)
PWM_GEN0_A_UTEB Action on PWM0A triggered by event TEB when the timer increases. (R/W)
PWM_GEN0_A_UTEA Action on PWM0A triggered by event TEA when the timer increases. (R/W)
PWM_GEN0_A_UTEP Action on PWM0A triggered by event TEP when the timer increases. (R/W)
PWM_GEN0_A_UTEZ Action on PWM0A triggered by event TEZ when the timer increases. (R/W)
B
B
EZ
P
EZ
P
EA
EA
0
0
TE
TE
TE
TE
1
T1
UT
UT
UT
UT
DT
DT
DT
_D
_D
_D
_U
_U
B_
B_
B_
B_
B_
B_
B_
_B
_B
0_
0_
0_
0_
0_
0_
0_
0_
0_
0_
N0
0
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
)
ed
E
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
rv
se
M
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN0_B_DT0 Action on PWM0B triggered by event_t0 when the timer decreases. (R/W)
PWM_GEN0_B_DTEB Action on PWM0B triggered by event TEB when the timer decreases. (R/W)
PWM_GEN0_B_DTEA Action on PWM0B triggered by event TEA when the timer decreases. (R/W)
PWM_GEN0_B_DTEP Action on PWM0B triggered by event TEP when the timer decreases. (R/W)
PWM_GEN0_B_DTEZ Action on PWM0B triggered by event TEZ when the timer decreases. (R/W)
PWM_GEN0_B_UT1 Action on PWM0B triggered by event_t1 when the timer increases. (R/W)
PWM_GEN0_B_UT0 Action on PWM0B triggered by event_t0 when the timer increases. (R/W)
PWM_GEN0_B_UTEB Action on PWM0B triggered by event TEB when the timer increases. (R/W)
PWM_GEN0_B_UTEA Action on PWM0B triggered by event TEA when the timer increases. (R/W)
PWM_GEN0_B_UTEP Action on PWM0B triggered by event TEP when the timer increases. (R/W)
PWM_GEN0_B_UTEZ Action on PWM0B triggered by event TEZ when the timer increases. (R/W)
D
PW _D _B _IN EL RT
PW _D _R _IN IN RT
HO
HO
M T0 ED UT SS
M T0 ED BY SS
M T0 ED S VE
M T0 ED UT E
PW _D _F _O INV
OD P
EB TSW P
ET
ET
PW _D _R _O PA
PW _D _F UT PA
E
_M A
_D U A
_D _A UT L
T0 _O SW
PM
M T0 _O SE
PM
M T0 _O BY
M T0 _O EL
PW _D _A UT
_U
_U
PW _D _B _S
ED
ED
M T0 LK
PW _D _C
_R
_F
M T0
T0
T0
)
ed
PW _D
_D
_D
rv
se
M
PW
PW
PW
(re
31 18 17 16 15 14 13 12 11 10 9 8 7 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 Reset
PWM_DT0_RED_UPMETHOD Updating method for RED (rising edge delay) active register. 0: im-
mediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync; when
bit3 is set to 1: disable the update. (R/W)
PWM_DT0_FED_UPMETHOD Updating method for FED (falling edge delay) active register. 0: im-
mediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync; when
bit3 is set to 1: disable the update. (R/W)
_D
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
_ RE
T0
)
ed
_D
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RT
T_ RT
LE
VE
TH
CA
OU VE
IN
TY
0_ _IN
ES
SH
DU
EN
PR
ER IN
O
RI 0_
0_
0_
0_
0_
AR ER
ER
ER
ER
ER
_C RI
RI
RI
RI
RI
M AR
AR
AR
AR
AR
)
ed
PW _C
_C
_C
_C
_C
rv
se
M
PW
PW
PW
PW
PW
(re
31 14 13 12 11 8 7 5 4 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_CARRIER0_IN_INVERT When set, invert the input of PWM0A and PWM0B for this submodule.
(R/W)
PWM_CARRIER0_OUT_INVERT When set, invert the output of PWM0A and PWM0B for this sub-
module. (R/W)
PWM_CARRIER0_OSHWTH Width of the first pulse, in number of periods of the carrier. (R/W)
PWM_CARRIER0_PRESCALE PWM carrier0 clock (PC_clk) prescale value. Period of PC_clk = pe-
riod of PWM_clk * (PWM_CARRIER0_PRESCALE + 1). (R/W)
PWM_CARRIER0_EN When set, carrier0 function is enabled. When cleared, carrier0 is bypassed.
(R/W)
_D
_D
_U
U
_D
D
U
_U
BC
M H0 0_ T
C_
W C
M H0 1_C C
M H0 W T
M H0 1_ T
T_
T_
H0 2_ C
PW _F _F OST
PW _F _F _OS
BC
BC
BC
_S CB
ST
PW _F _F CB
PW _F _S OS
ST
PW F F S
_F _F B
_C
OS
CB
OS
O
_O
_O
_C
_C
_C
M H0 2_
M H0 0_
_
_
_
_B
_B
_B
_B
_A
_A
_A
_A
PW _F _F
_
H0
H0
H0
H0
H0
H0
H0
PW H0
M H0
)
ed
_F
_F
_F
_F
_F
_F
_F
_F
PW _F
rv
_
se
M
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH0_B_OST_U One-shot mode action on PWM0B when a fault event occurs and the timer
is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH0_B_OST_D One-shot mode action on PWM0B when a fault event occurs and the timer
is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH0_B_CBC_U Cycle-by-cycle mode action on PWM0B when a fault event occurs and the
timer is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH0_B_CBC_D Cycle-by-cycle mode action on PWM0B when a fault event occurs and the
timer is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH0_A_OST_U One-shot mode action on PWM0A when a fault event occurs and the timer
is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH0_A_OST_D One-shot mode action on PWM0A when a fault event occurs and the timer
is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH0_A_CBC_U Cycle-by-cycle mode action on PWM0A when a fault event occurs and the
timer is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH0_A_CBC_D Cycle-by-cycle mode action on PWM0A when a fault event occurs and the
timer is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH0_F0_OST event_f0 will trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH0_F1_OST event_f1 will trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH0_F2_OST event_f2 will trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH0_SW_OST Enable register for software-forced one-shot mode action. 0: disable, 1: en-
able. (R/W)
PWM_FH0_F0_CBC event_f0 will trigger cycle-by-cycle mode action. 0: disable, 1: enable. (R/W)
PWM_FH0_F1_CBC event_f1 will trigger cycle-by-cycle mode action. 0: disable, 1: enable. (R/W)
PWM_FH0_F2_CBC event_f2 will trigger cycle-by-cycle mode action. 0: disable, 1: enable. (R/W)
_F CBC CBC
CE ST
LR SE
_F FOR E_O
ST
L
_
PU
_O
_ C
PW H0 OR
_C
_F _F
_
M H0
PW H0
H0
d)
ve
PW _F
r
se
M
PW
(re
31 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH0_FORCE_OST A toggle (software negation of this bit’s value) triggers a one-shot mode
action. (R/W)
PWM_FH0_CBCPULSE The cycle-by-cycle mode action refresh moment selection. When bit0 is
set to 1: TEZ; when bit1 is set to 1: TEP. (R/W)
N
BC N
_O
_C _O
H0 ST
_F _O
M H0
)
ed
PW _F
rv
se
M
PW
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH0_OST_ON Set and reset by hardware. If set, a one-shot mode action is on-going. (RO)
PWM_FH0_CBC_ON Set and reset by hardware. If set, a cycle-by-cycle mode action is on-going.
(RO)
L
_F LL
D
D
UL
HO
HO
D W FU
SH _
ET
ET
A _ DW
M
M
UP
1_ SH
UP
A_
EN B_
B_
_G 1_
1_
1_
M EN
EN
EN
d)
ve
PW _G
_G
_G
r
se
M
PW
PW
PW
(re
31 10 9 8 7 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN1_B_SHDW_FULL Set and reset by hardware. If set, PWM generator 1 time stamp B’s
shadow register is filled and to be transferred to time stamp B’s active register. If cleared, time
stamp B’s active register has been updated with shadow register’s latest value. (RO)
PWM_GEN1_A_SHDW_FULL Set and reset by hardware. If set, PWM generator 1 time stamp A’s
shadow register is filled and to be transferred to time stamp A’s active register. If cleared, time
stamp A’s active register has been updated with shadow register latest value. (RO)
PWM_GEN1_B_UPMETHOD Updating method for PWM generator 1 time stamp B’s active register.
0: immediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync;
when bit3 is set to 1: disable the update. (R/W)
PWM_GEN1_A_UPMETHOD Updating method for PWM generator 1 time stamp A’s active register.
0: immediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync;
when bit3 is set to 1: disable the update. (R/W)
E
_G
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
_G
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
HO
ET
M
UP
EL
L
SE
G_
_S
1_
CF
T0
_T
1_
1_
N1
EN
EN
d)
E
ve
_G
_G
_G
r
se
M
PW
PW
PW
(re
31 10 9 7 6 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN1_T1_SEL Source selection for PWM generator1 event_t1, taking effect immediately, 0:
fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none. (R/W)
PWM_GEN1_T0_SEL Source selection for PWM generator1 event_t0, taking effect immediately, 0:
fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none. (R/W)
D
HO
E
E
OD
OD
ET
E
E
OD
OD
M
_M
E_
UP
_M
M
CE
E_
RC
E_
NC CE
CN CE
NC CE
OR
_ N RC
RC
FO
A_ OR
B_ OR
A_ OR
F
_B IFO
TU
TU
FO
F
IF
F
I
CI
NC
TU
CN
CN
A_
B_
1_
1_
1_
1_
1_
1_
1
EN
PW EN
PW EN
PW EN
EN
EN
EN
)
ed
_G
_G
_G
_G
_G
_G
_G
rv
se
M
PW
PW
PW
PW
(re
31 16 15 14 13 12 11 10 9 8 7 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x20 Reset
B
B
EZ
P
EZ
P
A
A
0
0
TE
TE
TE
TE
TE
TE
T1
T1
UT
UT
DT
DT
_D
_D
_D
_D
_U
_U
_U
_U
A_
A_
A_
A_
_A
_A
1_
1_
1_
1_
1_
1_
1_
1_
1_
1_
N1
1
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
d)
E
ve
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
r
se
M
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN1_A_DT0 Action on PWM1A triggered by event_t0 when the timer decreases. (R/W)
PWM_GEN1_A_DTEB Action on PWM1A triggered by event TEB when the timer decreases. (R/W)
PWM_GEN1_A_DTEA Action on PWM1A triggered by event TEA when the timer decreases. (R/W)
PWM_GEN1_A_DTEP Action on PWM1A triggered by event TEP when the timer decreases. (R/W)
PWM_GEN1_A_DTEZ Action on PWM1A triggered by event TEZ when the timer decreases. (R/W)
PWM_GEN1_A_UT1 Action on PWM1A triggered by event_t1 when the timer increases. (R/W)
PWM_GEN1_A_UT0 Action on PWM1A triggered by event_t0 when the timer increases. (R/W)
PWM_GEN1_A_UTEB Action on PWM1A triggered by event TEB when the timer increases. (R/W)
PWM_GEN1_A_UTEA Action on PWM1A triggered by event TEA when the timer increases. (R/W)
PWM_GEN1_A_UTEP Action on PWM1A triggered by event TEP when the timer increases. (R/W)
PWM_GEN1_A_UTEZ Action on PWM1A triggered by event TEZ when the timer increases. (R/W)
EB
B
EZ
EP
Z
EP
EA
A
T0
0
TE
TE
TE
1
T1
UT
UT
UT
UT
UT
DT
DT
_D
_D
_D
_D
_U
B_
B_
B_
B_
B_
B_
_B
B
1_
1_
1_
1_
1_
1_
1_
1_
1_
1_
1_
N1
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
)
ed
E
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
rv
se
M
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN1_B_DT0 Action on PWM1B triggered by event_t0 when the timer decreases. (R/W)
PWM_GEN1_B_DTEB Action on PWM1B triggered by event TEB when the timer decreases. (R/W)
PWM_GEN1_B_DTEA Action on PWM1B triggered by event TEA when the timer decreases. (R/W)
PWM_GEN1_B_DTEP Action on PWM1B triggered by event TEP when the timer decreases. (R/W)
PWM_GEN1_B_DTEZ Action on PWM1B triggered by event TEZ when the timer decreases. (R/W)
PWM_GEN1_B_UT1 Action on PWM1B triggered by event_t1 when the timer increases. (R/W)
PWM_GEN1_B_UT0 Action on PWM1B triggered by event_t0 when the timer increases. (R/W)
PWM_GEN1_B_UTEB Action on PWM1B triggered by event TEB when the timer increases. (R/W)
PWM_GEN1_B_UTEA Action on PWM1B triggered by event TEA when the timer increases. (R/W)
PWM_GEN1_B_UTEP Action on PWM1B triggered by event TEP when the timer increases. (R/W)
PWM_GEN1_B_UTEZ Action on PWM1B triggered by event TEZ when the timer increases. (R/W)
D
PW _D _B _IN L T
PW _D _R _IN INV T
M T1 ED SE ER
HO
M T1 D UT ER
HO
M T1 ED T S
M T1 D BY S
PW _D _R _OU PAS
PW _D _FE UT PAS
PW _D _FE _O INV
OD P
EB TSW P
ET
ET
E
_M A
_D U A
_D A T L
T1 _O SW
PM
M T1_ _OU SE
PM
M T1 _O BY
M T1 _O L
PW _D _B _SE
PW _D _A UT
_U
_U
ED
ED
M T1 LK
PW _D _C
_R
_F
d)
M T1
T1
T1
ve
PW _D
_D
_D
r
se
M
PW
PW
PW
(re
31 18 17 16 15 14 13 12 11 10 9 8 7 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 Reset
PWM_DT1_RED_UPMETHOD Updating method for RED active register. 0: immediately; when bit0
is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync; when bit3 is set to 1:
disable the update. (R/W)
PWM_DT1_FED_UPMETHOD Updating method for FED active register. 0: immediately; when bit0
is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync; when bit3 is set to 1:
disable the update. (R/W)
T1
ed
_D
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
ED
_R
)
T1
ed
_D
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RT
T_ RT
LE
VE
TH
CA
OU VE
IN
HW
TY
1_ IN
ES
ER N_
DU
OS
EN
PR
RI 1_I
1_
1_
1_
1_
AR ER
ER
ER
ER
ER
_C RI
RI
RI
RI
RI
M AR
AR
AR
AR
AR
)
ed
PW _C
_C
_C
_C
_C
rv
se
M
PW
PW
PW
PW
PW
(re
31 14 13 12 11 8 7 5 4 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_CARRIER1_IN_INVERT When set, invert the input of PWM1A and PWM1B for this submodule.
(R/W)
PWM_CARRIER1_OUT_INVERT When set, invert the output of PWM1A and PWM1B for this submod-
ule. (R/W)
PWM_CARRIER1_OSHWTH Width of the first pulse in number of periods of the carrier. (R/W)
PWM_CARRIER1_PRESCALE PWM carrier1 clock (PC_clk) prescale value. Period of PC_clk = period
of PWM_clk * (PWM_CARRIER1_PRESCALE + 1). (R/W)
PWM_CARRIER1_EN When set, carrier1 function is enabled. When cleared, carrier1 is bypassed.
(R/W)
_D
D
U
U
D
D
_U
_U
BC
C_
M H1 _ T
C_
C_
W C
M H1_ _C C
PW _F _S OST
PW F F ST
T_
T_
_F F BC
PW _F _F ST
PW _F _F OS
BC
_S CB
ST
PW _F _F CB
ST
_C
CB
OS
CB
CB
OS
M H1_ _O
M H1 _O
M H1 W_
O
_O
_C
2_
H1 2_
_
_
B_
0
1
1
_B
_B
_B
_A
_A
_A
_A
PW _F _F
_
)
H1
H1
H1
H1
H1
H1
H1
PW H1
M H1
M 1
ed
H
_F
_F
_F
_F
_F
_F
_F
_F
PW _F
rv
_
se
M
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH1_B_OST_U One-shot mode action on PWM1B when a fault event occurs and the timer is
increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH1_B_OST_D One-shot mode action on PWM1B when a fault event occurs and the timer is
decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH1_B_CBC_U Cycle-by-cycle mode action on PWM1B when a fault event occurs and the
timer is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH1_B_CBC_D Cycle-by-cycle mode action on PWM1B when a fault event occurs and the
timer is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH1_A_OST_U One-shot mode action on PWM1A when a fault event occurs and the timer is
increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH1_A_OST_D One-shot mode action on PWM1A when a fault event occurs and the timer is
decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH1_A_CBC_U Cycle-by-cycle mode action on PWM1A when a fault event occurs and the
timer is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH1_A_CBC_D Cycle-by-cycle mode action on PWM1A when a fault event occurs and the
timer is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH1_F0_OST Enable event_f0 to trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH1_F1_OST Enable event_f1 to trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH1_F2_OST Enable event_f2 to trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH1_SW_OST Enable the register for software-forced one-shot mode action. 0: disable, 1:
enable. (R/W)
PWM_FH1_F2_CBC Enable event_f2 to will trigger cycle-by-cycle mode action. 0: disable, 1: en-
able. (R/W)
PWM_FH1_SW_CBC Enable the register for software-forced cycle-by-cycle mode action. 0: dis-
able, 1: enable. (R/W)
BC
_C E_C T
C S
E
_F OR _O
_C ULS
ST
_F CE
_O
P
BC
PW H1 OR
LR
_F F
M H1_
d)
PW H1
H1
ve
PW _F
_F
r
se
M
PW
(re
31 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH1_FORCE_OST A toggle (software negation of this bit’s value) triggers a one-shot mode
action. (R/W)
PWM_FH1_CBCPULSE The cycle-by-cycle mode action refresh moment selection. When bit0 is
set to 1: TEZ; when bit1 is set to 1: TEP. (R/W)
N
BC N
_O
_C _O
H1 ST
_F O
M H1_
)
ed
PW _F
rv
se
M
PW
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH1_OST_ON Set and reset by hardware. If set, a one-shot mode action is on-going. (RO)
PWM_FH1_CBC_ON Set and reset by hardware. If set, a cycle-by-cycle mode action is on-going.
(RO)
L
_F LL
D
D
UL
HO
HO
DW FU
SH _
ET
ET
A _ DW
M
M
UP
2_ SH
UP
A_
EN B_
B_
_G 2_
2_
2_
M EN
EN
EN
d)
ve
PW _G
_G
_G
r
se
M
PW
PW
PW
(re
31 10 9 8 7 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN2_B_SHDW_FULL Set and reset by hardware. If set, PWM generator 2 time stamp B’s
shadow register is filled and to be transferred to time stamp B’s active register. If cleared, time
stamp B’s active register has been updated with shadow register’s latest value. (RO)
PWM_GEN2_A_SHDW_FULL Set and reset by hardware. If set, PWM generator 2 time stamp A’s
shadow register is filled and to be transferred to time stamp A’s active register. If cleared, time
stamp A’s active register has been updated with shadow register’s latest value. (RO)
PWM_GEN2_B_UPMETHOD Updating method for PWM generator 2 time stamp B’s active register.
0: immediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync;
when bit3 is set to 1: disable the update. (R/W)
PWM_GEN2_A_UPMETHOD Updating method for PWM generator 2 time stamp A’s active register.
0: immediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync;
when bit3 is set to 1: disable the update. (R/W)
E
_G
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
ve
_G
r
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
HO
ET
M
UP
EL
L
SE
G_
_S
1_
CF
T0
_T
2_
2_
N2
EN
EN
d)
E
ve
_G
_G
_G
r
se
M
PW
PW
PW
(re
31 10 9 7 6 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN2_T1_SEL Source selection for PWM generator2 event_t1, take effect immediately, 0:
fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none. (R/W)
PWM_GEN2_T0_SEL Source selection for PWM generator2 event_t0, take effect immediately, 0:
fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none. (R/W)
D
HO
E
E
OD
OD
ET
E
E
RC OD
OD
M
M
E_
UP
E_
_M
_M
C
RC
E_
CE
E
NC CE
NC CE
RC
FO
FO
_G _A_ OR
_G _B_ OR
_G _A_ OR
TU
TU
FO
IF
2_ CIF
IF
IF
NC
TU
CN
CN
N
CN
A_
_G _B_
B_
2_
2_
N2
2
PW EN
PW EN
PW EN
EN
EN
EN
)
ed
E
_G
_G
_G
rv
se
M
PW
PW
PW
PW
(re
31 16 15 14 13 12 11 10 9 8 7 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x20 Reset
B
B
EZ
P
EZ
P
EA
EA
0
0
TE
TE
TE
TE
1
T1
UT
UT
UT
UT
DT
DT
DT
_D
_D
_D
_U
_U
A_
A_
A_
A_
A_
A_
A_
_A
_A
2_
2_
2_
2_
2_
2_
2_
2_
2_
2_
N2
2
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
)
ed
E
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
rv
se
M
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN2_A_DT0 Action on PWM2A triggered by event_t0 when the timer decreases. (R/W)
PWM_GEN2_A_DTEB Action on PWM2A triggered by event TEB when the timer decreases. (R/W)
PWM_GEN2_A_DTEA Action on PWM2A triggered by event TEA when the timer decreases. (R/W)
PWM_GEN2_A_DTEP Action on PWM2A triggered by event TEP when the timer decreases. (R/W)
PWM_GEN2_A_DTEZ Action on PWM2A triggered by event TEZ when the timer decreases. (R/W)
PWM_GEN2_A_UT1 Action on PWM2A triggered by event_t1 when the timer increases. (R/W)
PWM_GEN2_A_UT0 Action on PWM2A triggered by event_t0 when the timer increases. (R/W)
PWM_GEN2_A_UTEB Action on PWM2A triggered by event TEB when the timer increases. (R/W)
PWM_GEN2_A_UTEA Action on PWM2A triggered by event TEA when the timer increases. (R/W)
PWM_GEN2_A_UTEP Action on PWM2A triggered by event TEP when the timer increases. (R/W)
PWM_GEN2_A_UTEZ Action on PWM2A triggered by event TEZ when the timer increases. (R/W)
B
B
EZ
P
EZ
P
EA
EA
0
0
TE
TE
TE
TE
1
1
UT
UT
UT
UT
DT
DT
DT
DT
_D
_D
_U
_U
B_
B_
B_
B_
B_
B_
B_
B_
B
_B
_
2_
2_
2_
2_
2_
2_
2_
2_
2_
2_
N2
2
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
EN
)
ed
E
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
_G
rv
se
M
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_GEN2_B_DT0 Action on PWM2B triggered by event_t0 when the timer decreases. (R/W)
PWM_GEN2_B_DTEB Action on PWM2B triggered by event TEB when the timer decreases. (R/W)
PWM_GEN2_B_DTEA Action on PWM2B triggered by event TEA when the timer decreases. (R/W)
PWM_GEN2_B_DTEP Action on PWM2B triggered by event TEP when the timer decreases. (R/W)
PWM_GEN2_B_DTEZ Action on PWM2B triggered by event TEZ when the timer decreases. (R/W)
PWM_GEN2_B_UT1 Action on PWM2B triggered by event_t1 when the timer increases. (R/W)
PWM_GEN2_B_UT0 Action on PWM2B triggered by event_t0 when the timer increases. (R/W)
PWM_GEN2_B_UTEB Action on PWM2B triggered by event TEB when the timer increases. (R/W)
PWM_GEN2_B_UTEA Action on PWM2B triggered by event TEA when the timer increases. (R/W)
PWM_GEN2_B_UTEP Action on PWM2B triggered by event TEP when the timer increases. (R/W)
PWM_GEN2_B_UTEZ Action on PWM2B triggered by event TEZ when the timer increases. (R/W)
D
PW _D _B _IN EL RT
PW _D _R _IN IN RT
HO
HO
M T2 ED UT SS
M T2 ED BY SS
M T2 ED S VE
M T2 ED UT E
PW _D _F _O INV
OD P
EB TSW P
ET
ET
PW _D _R _O PA
PW _D _F UT PA
E
_M A
_D U A
_D _A UT L
T2 _O SW
PM
M T2 _O SE
PM
M T2 _O BY
M T2 _O EL
PW _D _A UT
_U
_U
PW _D _B _S
ED
ED
M T2 LK
PW _D _C
_R
_F
M T2
T2
T2
)
ed
PW _D
_D
_D
rv
se
M
PW
PW
PW
(re
31 18 17 16 15 14 13 12 11 10 9 8 7 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 Reset
PWM_DT2_RED_UPMETHOD Updating method for RED (rising edge delay) active register. 0: im-
mediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync; when
bit3 is set to 1: disable the update. (R/W)
PWM_DT2_FED_UPMETHOD Updating method for FED (falling edge delay) active register. 0: im-
mediately; when bit0 is set to 1: TEZ; when bit1 is set to 1: TEP; when bit2 is set to 1: sync; when
bit3 is set to 1: disable the update. (R/W)
_D
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E D
_R
T2
)
ed
_D
rv
se
M
PW
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RT
T_ RT
LE
VE
TH
CA
OU VE
IN
TY
2_ _IN
ES
SH
DU
EN
PR
ER IN
O
RI 2_
2_
2_
2_
2_
AR ER
ER
ER
ER
ER
_C RI
RI
RI
RI
RI
M AR
AR
AR
AR
AR
)
ed
PW _C
_C
_C
_C
_C
rv
se
M
PW
PW
PW
PW
PW
(re
31 14 13 12 11 8 7 5 4 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_CARRIER2_IN_INVERT When set, invert the input of PWM2A and PWM2B for this submodule.
(R/W)
PWM_CARRIER2_OUT_INVERT When set, invert the output of PWM2A and PWM2B for this sub-
module. (R/W)
PWM_CARRIER2_OSHWTH Width of the first pulse in number of periods of the carrier. (R/W)
PWM_CARRIER2_PRESCALE PWM carrier2 clock (PC_clk) prescale value. Period of PC_clk = pe-
riod of PWM_clk * (PWM_CARRIER2_PRESCALE + 1). (R/W)
PWM_CARRIER2_EN When set, carrier2 function is enabled. When cleared, carrier2 is bypassed.
(R/W)
_D
_D
_U
U
_D
D
U
_U
BC
M H2 0_ T
C_
W C
M H2 1_C C
M H2 W T
M H2 1_ T
T_
T_
H2 2_ C
PW _F _F OST
PW _F _F _OS
BC
BC
BC
_S CB
ST
PW _F _F CB
PW _F _S OS
ST
PW F F S
_F _F B
_C
OS
CB
OS
O
_O
_O
_C
_C
_C
M H2 2_
M H2 0_
_
_
_
_B
_B
_B
_B
_A
_A
_A
_A
PW _F _F
_
H2
H2
H2
H2
H2
H2
H2
PW H2
M H2
)
ed
_F
_F
_F
_F
_F
_F
_F
_F
PW _F
rv
_
se
M
PW
PW
PW
PW
PW
PW
PW
PW
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH2_B_OST_U One-shot mode action on PWM2B when a fault event occurs and the timer
is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH2_B_OST_D One-shot mode action on PWM2B when a fault event occurs and the timer
is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH2_B_CBC_U Cycle-by-cycle mode action on PWM2B when a fault event occurs and the
timer is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH2_B_CBC_D Cycle-by-cycle mode action on PWM2B when a fault event occurs and the
timer is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH2_A_OST_U One-shot mode action on PWM2A when a fault event occurs and the timer
is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH2_A_OST_D One-shot mode action on PWM2A when a fault event occurs and the timer
is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH2_A_CBC_U Cycle-by-cycle mode action on PWM2A when a fault event occurs and the
timer is increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH2_A_CBC_D Cycle-by-cycle mode action on PWM2A when a fault event occurs and the
timer is decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle. (R/W)
PWM_FH2_F0_OST event_f0 will trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH2_F1_OST event_f1 will trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH2_F2_OST event_f2 will trigger one-shot mode action. 0: disable, 1: enable. (R/W)
PWM_FH2_SW_OST Enable register for software-forced one-shot mode action. 0: disable, 1: en-
able. (R/W)
PWM_FH2_F0_CBC event_f0 will trigger cycle-by-cycle mode action. 0: disable, 1: enable. (R/W)
PWM_FH2_F1_CBC event_f1 will trigger cycle-by-cycle mode action. 0: disable, 1: enable. (R/W)
PWM_FH2_F2_CBC event_f2 will trigger cycle-by-cycle mode action. 0: disable, 1: enable. (R/W)
_F CBC CBC
CE ST
LR SE
_F FOR E_O
ST
L
_
PU
_O
_ C
PW H2 OR
_C
_F _F
_
M H2
PW H2
H2
d)
ve
PW _F
r
se
M
PW
(re
31 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH2_FORCE_OST A toggle (software negation of this bit’s value) triggers a one-shot mode
action. (R/W)
PWM_FH2_CBCPULSE The cycle-by-cycle mode action refresh moment selection. When bit0 is
set to 1: TEZ; when bit1 is set to 1:TEP. (R/W)
N
BC N
_O
_C _O
H2 ST
_F _O
M H2
)
ed
PW _F
rv
se
M
PW
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_FH2_OST_ON Set and reset by hardware. If set, a one-shot mode action is on-going. (RO)
PWM_FH2_CBC_ON Set and reset by hardware. If set, a cycle-by-cycle mode action is on-going.
(RO)
PW _F PO 0
PW _E NT 2
PW _F NT 1
M 1_ LE
M 2_ LE
M VE _F
M VE _F
M 2_ _F
M 0_ LE
PW _F PO
PW _F EN
EN
PW _E NT
PW _F PO
_F N
M 1_E
0_
)
M VE
ed
PW _E
rv
se
M
PW
(re
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_F2_POLE Set event_f2 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, 1:
level high. (R/W)
PWM_F1_POLE Set event_f1 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, 1:
level high. (R/W)
PWM_F0_POLE Set event_f0 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, 1:
level high. (R/W)
ER N
N
SE
SW
IM _E
_E
I_
C_
_T CI
NC
YN
AP YN
SY
_S
_C S
_
M AP_
AP
AP
)
ed
_C
_C
PW _C
rv
se
M
PW
PW
PW
(re
31 6 5 4 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_CAP_SYNC_SW Set this bit to force a capture timer sync; the capture timer is loaded with
the value in the phase register. (WO)
PWM_CAP_TIMER_EN When set, the capture timer incrementing under APB_clk is enabled. (R/W)
31 0
0 Reset
PWM_CAP_TIMER_PHASE_REG Phase value for the capture timer sync operation. (R/W)
LE
ER
CA
V
E
IN
ES
AP OD
_
AP SW
EN
PR
IN
_C _M
_C 0_
0_
0_
0_
0
M AP
AP
PW AP
)
ed
PW _C
_C
_C
rv
se
M
PW
PW
PW
(re
31 13 12 11 10 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_CAP0_IN_INVERT When set, CAP0 form GPIO matrix is inverted before prescaling. (R/W)
PWM_CAP0_MODE Edge of capture on channel 0 after prescaling. When bit0 is set to 1: enable
capture on the negative edge; When bit1 is set to 1: enable capture on the positive edge. (R/W)
RT
E
AL
E
NV
SC
DE
E
_I
_C MO
AP SW
EN
PR
IN
_C 1_
1_
1_
1_
1_
M AP
AP
AP
AP
d)
ve
PW _C
_C
_C
r
se
M
PW
PW
PW
PW
(re
31 13 12 11 10 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_CAP1_IN_INVERT When set, CAP1 form GPIO matrix is inverted before prescaling. (R/W)
PWM_CAP1_MODE Edge of capture on channel 1 after prescaling. When bit0 is set to 1: enable
capture on the negative edge; When bit1 is set to 1: enable capture on the positive edge. (R/W)
RT
LE
CA
VE
E
IN
ES
AP OD
_
AP SW
EN
PR
IN
_C _M
_C 2_
2_
2_
2_
2
M AP
AP
PW AP
)
ed
PW _C
_C
_C
rv
se
M
PW
PW
PW
(re
31 13 12 11 10 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_CAP2_IN_INVERT When set, CAP2 form GPIO matrix is inverted before prescaling. (R/W)
PWM_CAP2_MODE Edge of capture on channel 2 after prescaling. When bit0 is set to 1: enable
capture on the negative edge; when bit1 is set to 1: enable capture on the positive edge. (R/W)
31 0
0 Reset
31 0
0 Reset
31 0
0 Reset
_C 1_ GE
GE
0_ GE
M AP ED
ED
AP ED
PW _C 2_
M AP
)
ed
PW _C
rv
se
M
PW
(re
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PWM_CAP2_EDGE Edge of the last capture trigger on channel 2. 0: posedge; 1: negedge. (RO)
PWM_CAP1_EDGE Edge of the last capture trigger on channel 1. 0: posedge; 1: negedge. (RO)
PWM_CAP0_EDGE Edge of the last capture trigger on channel 0. 0: posedge; 1: negedge. (RO)
N P
_E U
UP E_
PW _O _F EN P
_G BA EN P
PW _O _F EN P
M P1 P_ _U
M LO P_ _U
L _ RC
M P0 P_ _U
PW _O _U CE
PW _G _U CE
BA FO
PW _O _U CE
M P2 OR
M P0 OR
LO L_
M P1 OR
PW _O _F
M P2
d)
ve
PW _O
r
se
M
PW
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 Reset
PWM_OP2_FORCE_UP A toggle (software negation of this bit’s value) will trigger a forced update
of active registers in PWM operator 2. (R/W)
PWM_OP2_UP_EN When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM
operator 2 are enabled (R/W)
PWM_OP1_FORCE_UP A toggle (software negation of this bit’s value) will trigger a forced update
of active registers in PWM operator 1. (R/W)
PWM_OP1_UP_EN When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM
operator 1 are enabled. (R/W)
PWM_OP0_FORCE_UP A toggle (software negation of this bit’s value) will trigger a forced update
of active registers in PWM operator 0. (R/W)
PWM_OP0_UP_EN When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM
operator 0 are enabled. (R/W)
PWM_GLOBAL_FORCE_UP A toggle (software negation of this bit’s value) will trigger a forced up-
date of all active registers in the MCPWM module. (R/W)
PWM_GLOBAL_UP_EN The global enable of update of all active registers in the MCPWM module.
(R/W)
OP T_ A
NA
NT A
A
ST _IN EN
T_ ER TE NT NA
ER T IN A
T_ L IN IN A
T_ ER TE T A
Z T A
_I EN
T_ ER ST IN A
T_ ER TE NT A
T_ L CL NT N
T_ L IN N N
M _S P_ EN
_E
IN FAU 2_ R_ _EN
IN TIM 2_ Z_ _EN
IN IM 2_ P_I EN
IN FAU 0_ R_I T_E
0_ OP T_
IN OP CB NT_ NA
IN OP EB INT_ NA
IN TIM 0_ _I _E
IN OP TEB T_ NA
IN OP EA INT_ NA
IN FAU TEA T_ NA
IN FAU 1_C R_ NA
IN FH OST T_ NA
IN FH BC INT NA
IN OP TEB INT NA
IN P EA INT_ A
IN FAU 2_ INT_ A
IN FH CB INT_ A
TI 1 O T_
IN IM 0_ _E A
_
T_ 2_ _ EN
T_ L _ EN
T_ 2_ _ EN
T_ ER E NT
T_ ER IN NA
T_ 0_ _ _E
T_ 1_T _ _E
T_ 0_ _I E
T_ 1_T _ E
T_ 0_ _I E
T_ L C E
T_ L L IN
T_ 0_ _I E
T_ 1_C C_ E
T_ 2_ C_ E
T_ ER TE N
T_ ER E IN
T_ 0 T_ A
T_ 1_O _ A
IN FH ST INT_
IN FH _IN ENA
IN TIM 2_ T_E
IN CAP IN EN
IN FH OST EN
N
N
P
T T
T L
T_ 1_ T_
T_ 2_ T_
I
IN CAP _IN
T
T
T
)
T_ 2
ed
IN CAP
rv
T
se
T_
(re
IN
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
INT_CAP2_INT_ENA The enable bit for the interrupt triggered by capture on channel 2. (R/W)
INT_CAP1_INT_ENA The enable bit for the interrupt triggered by capture on channel 1. (R/W)
INT_CAP0_INT_ENA The enable bit for the interrupt triggered by capture on channel 0. (R/W)
INT_FH2_OST_INT_ENA The enable bit for the interrupt triggered by a one-shot mode action on
PWM2. (R/W)
INT_FH1_OST_INT_ENA The enable bit for the interrupt triggered by a one-shot mode action on
PWM1. (R/W)
INT_FH0_OST_INT_ENA The enable bit for the interrupt triggered by a one-shot mode action on
PWM0. (R/W)
INT_FH2_CBC_INT_ENA The enable bit for the interrupt triggered by a cycle-by-cycle mode action
on PWM2. (R/W)
INT_FH1_CBC_INT_ENA The enable bit for the interrupt triggered by a cycle-by-cycle mode action
on PWM1. (R/W)
INT_FH0_CBC_INT_ENA The enable bit for the interrupt triggered by a cycle-by-cycle mode action
on PWM0. (R/W)
INT_OP2_TEB_INT_ENA The enable bit for the interrupt triggered by a PWM operator 2 TEB event
(R/W)
INT_OP1_TEB_INT_ENA The enable bit for the interrupt triggered by a PWM operator 1 TEB event
(R/W)
INT_OP0_TEB_INT_ENA The enable bit for the interrupt triggered by a PWM operator 0 TEB event
(R/W)
INT_OP2_TEA_INT_ENA The enable bit for the interrupt triggered by a PWM operator 2 TEA event
(R/W)
INT_OP1_TEA_INT_ENA The enable bit for the interrupt triggered by a PWM operator 1 TEA event
(R/W)
INT_OP0_TEA_INT_ENA The enable bit for the interrupt triggered by a PWM operator 0 TEA event
(R/W)
INT_FAULT2_CLR_INT_ENA The enable bit for the interrupt triggered when event_f2 ends. (R/W)
INT_FAULT1_CLR_INT_ENA The enable bit for the interrupt triggered when event_f1 ends. (R/W)
INT_FAULT0_CLR_INT_ENA The enable bit for the interrupt triggered when event_f0 ends. (R/W)
INT_FAULT2_INT_ENA The enable bit for the interrupt triggered when event_f2 starts. (R/W)
INT_FAULT1_INT_ENA The enable bit for the interrupt triggered when event_f1 starts. (R/W)
INT_FAULT0_INT_ENA The enable bit for the interrupt triggered when event_f0 starts. (R/W)
INT_TIMER2_TEP_INT_ENA The enable bit for the interrupt triggered by a PWM timer 2 TEP event.
(R/W)
INT_TIMER1_TEP_INT_ENA The enable bit for the interrupt triggered by a PWM timer 1 TEP event.
(R/W)
Continued on the next page...
Espressif Systems 493 ESP32 TRM (Version 5.2)
Submit Documentation Feedback
16 Motor Control PWM (PWM)
INT_TIMER0_TEP_INT_ENA The enable bit for the interrupt triggered by a PWM timer 0 TEP event.
(R/W)
INT_TIMER2_TEZ_INT_ENA The enable bit for the interrupt triggered by a PWM timer 2 TEZ event.
(R/W)
INT_TIMER1_TEZ_INT_ENA The enable bit for the interrupt triggered by a PWM timer 1 TEZ event.
(R/W)
INT_TIMER0_TEZ_INT_ENA The enable bit for the interrupt triggered by a PWM timer 0 TEZ event.
(R/W)
INT_TIMER2_STOP_INT_ENA The enable bit for the interrupt triggered when the timer 2 stops.
(R/W)
INT_TIMER1_STOP_INT_ENA The enable bit for the interrupt triggered when the timer 1 stops. (R/W)
INT_TIMER0_STOP_INT_ENA The enable bit for the interrupt triggered when the timer 0 stops.
(R/W)
OP T_ W
AW
NT W
T_ L CL NT AW
T_ L IN A AW
T_ ER TE NT AW
ER T IN W
T_ ER TE T AW
T_ L IN IN AW
T_ ER E IN AW
ST _IN RA
T_ ER ST IN W
T_ ER TE NT W
_ I RA
_R
M _S P_ RA
IN IM 2_ Z_ _RA
IN IM 2_ P_I RA
IN OP CB NT_ AW
IN OP EB INT_ AW
0_ OP T_
IN TIM 0_ _I _R
IN OP TEB T_ AW
IN OP EA INT_ AW
IN FAU TEA T_ AW
IN FAU 1_C R_ AW
IN FH OST T_ AW
IN FH BC INT AW
IN OP TEB INT AW
IN FAU 2_ R_ _R
IN TIM 0_ _IN _R
IN TIM 1_T Z_ _R
IN P EA INT_ W
IN FAU 2_ INT_ W
IN FH CB INT_ W
TI 1 O T_
T T W
_
T_ ER IN AW
Z T
T_ 2_ _ RA
T_ L _ RA
T_ 2_ _ RA
T_ ER E NT
T_ 0_ _ _R
T_ 1_T _ _R
T_ 0_ _I R
T_ 1_T _ R
T_ 0_ _I R
T_ L C R
T_ 0_ _I R
T_ 1_C C_ R
T_ L L IN
T_ 2_ C_ R
T_ ER TE A
T_ 0 T_ W
T_ 1_O _ W
IN FH _IN RAW
IN FH ST INT_
IN TIM 2_ T_R
IN TIM 1_T P_I
IN IM 0_ _R
IN CAP IN RA
IN FH OST RA
N
N
P
T L
T_ 1_ T_
T_ 2_ T_
I
IN CAP _IN
T
T
T
)
T_ 2
ed
IN CAP
rv
T
se
T_
(re
IN
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
INT_CAP2_INT_RAW The raw status bit for the interrupt triggered by capture on channel 2. (RO)
INT_CAP1_INT_RAW The raw status bit for the interrupt triggered by capture on channel 1. (RO)
INT_CAP0_INT_RAW The raw status bit for the interrupt triggered by capture on channel 0. (RO)
INT_FH2_OST_INT_RAW The raw status bit for the interrupt triggered by a one-shot mode action
on PWM2. (RO)
INT_FH1_OST_INT_RAW The raw status bit for the interrupt triggered by a one-shot mode action on
PWM0. (RO)
INT_FH0_OST_INT_RAW The raw status bit for the interrupt triggered by a one-shot mode action
on PWM0. (RO)
INT_FH2_CBC_INT_RAW The raw status bit for the interrupt triggered by a cycle-by-cycle mode
action on PWM2. (RO)
INT_FH1_CBC_INT_RAW The raw status bit for the interrupt triggered by a cycle-by-cycle mode
action on PWM1. (RO)
INT_FH0_CBC_INT_RAW The raw status bit for the interrupt triggered by a cycle-by-cycle mode
action on PWM0. (RO)
INT_OP2_TEB_INT_RAW The raw status bit for the interrupt triggered by a PWM operator 2 TEB
event. (RO)
INT_OP1_TEB_INT_RAW The raw status bit for the interrupt triggered by a PWM operator 1 TEB event.
(RO)
INT_OP0_TEB_INT_RAW The raw status bit for the interrupt triggered by a PWM operator 0 TEB
event. (RO)
INT_OP2_TEA_INT_RAW The raw status bit for the interrupt triggered by a PWM operator 2 TEA
event. (RO)
INT_OP1_TEA_INT_RAW The raw status bit for the interrupt triggered by a PWM operator 1 TEA event.
(RO)
INT_OP0_TEA_INT_RAW The raw status bit for the interrupt triggered by a PWM operator 0 TEA
event. (RO)
INT_FAULT2_CLR_INT_RAW The raw status bit for the interrupt triggered when event_f2 ends. (RO)
INT_FAULT1_CLR_INT_RAW The raw status bit for the interrupt triggered when event_f1 ends. (RO)
INT_FAULT0_CLR_INT_RAW The raw status bit for the interrupt triggered when event_f0 ends. (RO)
INT_FAULT2_INT_RAW The raw status bit for the interrupt triggered when event_f2 starts. (RO)
INT_FAULT1_INT_RAW The raw status bit for the interrupt triggered when event_f1 starts. (RO)
INT_FAULT0_INT_RAW The raw status bit for the interrupt triggered when event_f0 starts. (RO)
INT_TIMER2_TEP_INT_RAW The raw status bit for the interrupt triggered by a PWM timer 2 TEP
event. (RO)
INT_TIMER1_TEP_INT_RAW The raw status bit for the interrupt triggered by a PWM timer 1 TEP event.
(RO)
Continued on the next page...
Espressif Systems 495 ESP32 TRM (Version 5.2)
Submit Documentation Feedback
16 Motor Control PWM (PWM)
INT_TIMER0_TEP_INT_RAW The raw status bit for the interrupt triggered by a PWM timer 0 TEP
event. (RO)
INT_TIMER2_TEZ_INT_RAW The raw status bit for the interrupt triggered by a PWM timer 2 TEZ
event. (RO)
INT_TIMER1_TEZ_INT_RAW The raw status bit for the interrupt triggered by a PWM timer 1 TEZ event.
(RO)
INT_TIMER0_TEZ_INT_RAW The raw status bit for the interrupt triggered by a PWM timer 0 TEZ
event. (RO)
INT_TIMER2_STOP_INT_RAW The raw status bit for the interrupt triggered when the timer 2 stops.
(RO)
INT_TIMER1_STOP_INT_RAW The raw status bit for the interrupt triggered when the timer 1 stops.
(RO)
INT_TIMER0_STOP_INT_RAW The raw status bit for the interrupt triggered when the timer 0 stops.
(RO)
ST _IN ST
T
_I ST
T_ L CL NT T
T_ L IN T T
_S
T_ ER TE NT T
M _S P_ ST
IN FAU 2_ R_ _ST
IN IM 2_ Z_ _ST
IN AU 0_ R_I T_S
IN IM 2_ P_I ST
0_ OP T_
IN TIM 0_ _I _S
OP T_
NT
TI 1 O T_
IN OP CB NT_ T
IN OP EB INT_ T
IN OP TEB T_ T
IN OP EA INT_ T
IN FAU TEA T_ T
IN FAU 1_C R_ T
IN FH OST T_ T
IN FH BC INT T
IN OP TEB INT T
ER T IN
_
Z T
T_ ER E NT
T_ ER TE NT
T_ 2_ _ ST
T_ L _ ST
T_ 2_ _ ST
T_ 0_ _ _S
T_ 1_T _ _S
T_ 0_ _I S
T_ 1_T _ S
T_ 0_ _I S
T_ L CL S
T_ ER TE T
T_ 0_ _I S
T_ 1_C C_ S
T_ L L IN
T_ L IN IN
T_ 2_ C_ S
T_ ER E IN
T_ ER ST IN
T_ ER TE T
T_ ER IN T
IN P EA INT_
IN FAU 2_ INT_
IN FH ST INT_
IN FH CB INT_
IN TIM 2_ T_S
IN TIM 1_T P_I
IN IM 0_ _S
IN CAP IN ST
IN FH OST ST
IN FH _IN ST
N
N
P
T T
T_ 1_ T_
T_ 2_ T_
I
T_ 0 T_
T_ 1_O _
IN CAP _IN
T
T
T
T
T
)
T_ 2
ed
IN CAP
rv
T
se
T_
(re
IN
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
INT_CAP2_INT_ST The masked status bit for the interrupt triggered by capture on channel 2. (RO)
INT_CAP1_INT_ST The masked status bit for the interrupt triggered by capture on channel 1. (RO)
INT_CAP0_INT_ST The masked status bit for the interrupt triggered by capture on channel 0. (RO)
INT_FH2_OST_INT_ST The masked status bit for the interrupt triggered by a one-shot mode action
on PWM2. (RO)
INT_FH1_OST_INT_ST The masked status bit for the interrupt triggered by a one-shot mode action
on PWM1. (RO)
INT_FH0_OST_INT_ST The masked status bit for the interrupt triggered by a one-shot mode action
on PWM0. (RO)
INT_FH2_CBC_INT_ST The masked status bit for the interrupt triggered by a cycle-by-cycle mode
action on PWM2. (RO)
INT_FH1_CBC_INT_ST The masked status bit for the interrupt triggered by a cycle-by-cycle mode
action on PWM1. (RO)
INT_FH0_CBC_INT_ST The masked status bit for the interrupt triggered by a cycle-by-cycle mode
action on PWM0. (RO)
INT_OP2_TEB_INT_ST The masked status bit for the interrupt triggered by a PWM operator 2 TEB
event. (RO)
INT_OP1_TEB_INT_ST The masked status bit for the interrupt triggered by a PWM operator 1 TEB
event. (RO)
INT_OP0_TEB_INT_ST The masked status bit for the interrupt triggered by a PWM operator 0 TEB
event. (RO)
INT_OP2_TEA_INT_ST The masked status bit for the interrupt triggered by a PWM operator 2 TEA
event. (RO)
INT_OP1_TEA_INT_ST The masked status bit for the interrupt triggered by a PWM operator 1 TEA
event. (RO)
INT_OP0_TEA_INT_ST The masked status bit for the interrupt triggered by a PWM operator 0 TEA
event. (RO)
INT_FAULT2_CLR_INT_ST The masked status bit for the interrupt triggered when event_f2 ends.
(RO)
INT_FAULT1_CLR_INT_ST The masked status bit for the interrupt triggered when event_f1 ends.
(RO)
INT_FAULT0_CLR_INT_ST The masked status bit for the interrupt triggered when event_f0 ends.
(RO)
INT_FAULT2_INT_ST The masked status bit for the interrupt triggered when event_f2 starts. (RO)
Continued on the next page...
INT_FAULT1_INT_ST The masked status bit for the interrupt triggered when event_f1 starts. (RO)
INT_FAULT0_INT_ST The masked status bit for the interrupt triggered when event_f0 starts. (RO)
INT_TIMER2_TEP_INT_ST The masked status bit for the interrupt triggered by a PWM timer 2 TEP
event. (RO)
INT_TIMER1_TEP_INT_ST The masked status bit for the interrupt triggered by a PWM timer 1 TEP
event. (RO)
INT_TIMER0_TEP_INT_ST The masked status bit for the interrupt triggered by a PWM timer 0 TEP
event. (RO)
INT_TIMER2_TEZ_INT_ST The masked status bit for the interrupt triggered by a PWM timer 2 TEZ
event. (RO)
INT_TIMER1_TEZ_INT_ST The masked status bit for the interrupt triggered by a PWM timer 1 TEZ
event. (RO)
INT_TIMER0_TEZ_INT_ST The masked status bit for the interrupt triggered by a PWM timer 0 TEZ
event. (RO)
INT_TIMER2_STOP_INT_ST The masked status bit for the interrupt triggered when the timer 2 stops.
(RO)
INT_TIMER1_STOP_INT_ST The masked status bit for the interrupt triggered when the timer 1 stops.
(RO)
INT_TIMER0_STOP_INT_ST The masked status bit for the interrupt triggered when the timer 0 stops.
(RO)
OP T_ R
LR
NT R
T_ L CL NT LR
T_ L IN L LR
ST _IN CL
T_ ER TE NT LR
ER T IN R
T_ L IN IN LR
T_ ER TE T LR
T_ ER E IN LR
_I CL
T_ ER ST IN R
T_ ER TE NT R
_C
M _S P_ CL
IN IM 2_ Z_ _CL
IN FAU 0_ R_I T_C
IN IM 2_ P_I CL
0_ OP T_
IN TIM 0_ _I _C
IN OP CB NT_ LR
IN OP EB INT_ LR
IN FAU 2_ R_ _C
IN TIM 0_ _IN _C
IN TIM 1_T Z_ _C
IN OP TEB T_ LR
IN OP EA INT_ LR
IN FAU TEA T_ LR
IN FAU 1_C R_ LR
IN FH OST T_ LR
IN FH BC INT LR
IN OP TEB INT LR
IN P EA INT_ R
IN FAU 2_ INT_ R
IN FH CB INT_ R
TI 1 O T_
_
T T R
Z T
T_ 2_ _ CL
T_ ER E NT
T_ L _ CL
T_ 2_ _ CL
T_ 0_ _ _C
T_ 1_T _ _C
T_ ER IN LR
T_ 0_ _I C
T_ 1_T _ C
T_ 0_ _I C
T_ L C C
T_ 0_ _I C
T_ 1_C C_ C
T_ 2_ C_ C
T_ L L IN
T_ ER TE L
T_ 0 T_ R
T_ 1_O _ R
IN FH ST INT_
IN TIM 2_ T_C
IN FH _IN LR
IN H ST CL
N
N
C
P
T L
T_ 1_ T_
T_ 2_ T_
I
IN CAP _IN
T
T
T
)
T_ 2
ed
IN CAP
rv
O
F
T
se
T_
(re
IN
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
INT_CAP2_INT_CLR Set this bit to clear interrupt triggered by capture on channel 2. (WO)
INT_CAP1_INT_CLR Set this bit to clear interrupt triggered by capture on channel 1. (WO)
INT_CAP0_INT_CLR Set this bit to clear interrupt triggered by capture on channel 0. (WO)
INT_FH2_OST_INT_CLR Set this bit to clear interrupt triggered by a one-shot mode action on PWM2.
(WO)
INT_FH1_OST_INT_CLR Set this bit to clear interrupt triggered by a one-shot mode action on PWM1.
(WO)
INT_FH0_OST_INT_CLR Set this bit to clear interrupt triggered by a one-shot mode action on PWM0.
(WO)
INT_FH2_CBC_INT_CLR Set this bit to clear interrupt triggered by a cycle-by-cycle mode action on
PWM2. (WO)
INT_FH1_CBC_INT_CLR Set this bit to clear interrupt triggered by a cycle-by-cycle mode action on
PWM1. (WO)
INT_FH0_CBC_INT_CLR Set this bit to clear interrupt triggered by a cycle-by-cycle mode action on
PWM0. (WO)
INT_OP2_TEB_INT_CLR Set this bit to clear interrupt triggered by a PWM operator 2 TEB event.
(WO)
INT_OP1_TEB_INT_CLR Set this bit to clear interrupt triggered by a PWM operator 1 TEB event. (WO)
INT_OP0_TEB_INT_CLR Set this bit to clear interrupt triggered by a PWM operator 0 TEB event.
(WO)
INT_OP2_TEA_INT_CLR Set this bit to clear interrupt triggered by a PWM operator 2 TEA event.
(WO)
INT_OP1_TEA_INT_CLR Set this bit to clear interrupt triggered by a PWM operator 1 TEA event. (WO)
INT_OP0_TEA_INT_CLR Set this bit to clear interrupt triggered by a PWM operator 0 TEA event.
(WO)
INT_FAULT2_CLR_INT_CLR Set this bit to clear interrupt triggered when event_f2 ends. (WO)
INT_FAULT1_CLR_INT_CLR Set this bit to clear interrupt triggered when event_f1 ends. (WO)
INT_FAULT0_CLR_INT_CLR Set this bit to clear interrupt triggered when event_f0 ends. (WO)
INT_FAULT2_INT_CLR Set this bit to clear interrupt triggered when event_f2 starts. (WO)
INT_FAULT1_INT_CLR Set this bit to clear interrupt triggered when event_f1 starts. (WO)
INT_FAULT0_INT_CLR Set this bit to clear interrupt triggered when event_f0 starts. (WO)
INT_TIMER2_TEP_INT_CLR Set this bit to clear interrupt triggered by a PWM timer 2 TEP event. (WO)
Continued on the next page...
INT_TIMER1_TEP_INT_CLR Set this bit to clear interrupt triggered by a PWM timer 1 TEP event. (WO)
INT_TIMER0_TEP_INT_CLR Set this bit to clear interrupt triggered by a PWM timer 0 TEP event.
(WO)
INT_TIMER2_TEZ_INT_CLR Set this bit to clear interrupt triggered by a PWM timer 2 TEZ event.
(WO)
INT_TIMER1_TEZ_INT_CLR Set this bit to clear interrupt triggered by a PWM timer 1 TEZ event. (WO)
INT_TIMER0_TEZ_INT_CLR Set this bit to clear interrupt triggered by a PWM timer 0 TEZ event.
(WO)
INT_TIMER2_STOP_INT_CLR Set this bit to clear interrupt triggered when the timer 2 stops. (WO)
INT_TIMER1_STOP_INT_CLR Set this bit to clear interrupt triggered when the timer 1 stops. (WO)
INT_TIMER0_STOP_INT_CLR Set this bit to clear interrupt triggered when the timer 0 stops. (WO)
17.1 Overview
The pulse counter module is designed to count the number of rising and/or falling edges of an input signal.
Each pulse counter unit has a 16-bit signed counter register and two channels that can be configured to either
increment or decrement the counter. Each channel has a signal input that accepts signal edges to be detected,
as well as a control input that can be used to enable or disable the signal input. The inputs have optional filters
that can be used to discard unwanted glitches in the signal.
The architecture of a pulse counter unit is illustrated in Figure 17-1. Each unit has two channels: ch0 and ch1,
which are functionally equivalent. Each channel has a signal input, as well as a control input, which can both
be connected to I/O pads. The counting behavior on both the positive and negative edge can be configured
separately to increase, decrease, or do nothing to the counter value. Separately, for both control signal levels,
the hardware can be configured to modify the edge action: invert it, disable it, or do nothing. The counter itself
is a 16-bit signed up/down counter. Its value can be read by software directly, but is also monitored by a set of
comparators which can trigger an interrupt.
To summarize, a few examples have been considered. In this table, the effect on the counter for a rising edge
is shown for both a low and a high control signal, as well as various other configuration options. For clarity, a
short description in brackets is added after the values. Note: x denotes ’do not care’.
POS_ MODE LCTRL_ MODE HCTRL_ MODE sig l→h when ctrl=0 sig l→h when ctrl=1
1 (inc) 0 (-) 0 (-) Inc ctr Inc ctr
2 (dec) 0 (-) 0 (-) Dec ctr Dec ctr
0 (-) x x No action No action
1 (inc) 0 (-) 1 (inv) Inc ctr Dec ctr
1 (inc) 1 (inv) 0 (-) Dec ctr Inc ctr
2 (dec) 0 (-) 1 (inv) Dec ctr Inc ctr
1 (inc) 0 (-) 2 (dis) Inc ctr No action
1 (inc) 2 (dis) 0 (-) No action Inc ctr
This table is also valid for negative edges (sig h→l) on substituting NEG_MODE for POS_MODE.
Each pulse counter unit also features a filter on each of the four inputs, adding the option to ignore short
glitches in the signals. If a PCNT_FILTER_EN_Un can be set to filter the four input signals of the unit. If this filter
is enabled, any pulses shorter than REG_FILTER_THRES_Un number of APB_CLK clock cycles will be filtered out
and will have no effect on the counter. With the filter disabled, in theory infinitely small glitches could possibly
trigger pulse counter action. However, in practice the signal inputs are sampled on APB_CLK edges and even
with the filter disabled, pulse widths lasting shorter than one APB_CLK cycle may be missed.
Apart from the input channels, software also has some control over the counter. In particular, the counter value
can be frozen to the current value by configuring PCNT_CNT_PAUSE_Un. It can also be reset to 0 by configuring
PCNT_PLUS_CNT_RST_Un.
17.2.3 Watchpoints
The pulse counters have five watchpoints that share one interrupt. Interrupt generation can be enabled or
disabled for each individual watchpoint. The watchpoints are:
• Maximum count value: Triggered when PULSE_CNT >= PCNT_CNT_H_LIM_Un. Additionally, this will reset
the counter to 0. PCNT_CNT_H_LIM_Un should be a positive number.
• Minimum count value: Triggered when PULSE_CNT <= PCNT_CNT_L_LIM_Un. Additionally, this will reset
17.2.4 Examples
Figure 17-2 shows channel 0 being used as an up-counter. The configuration of channel 0 is shown be-
low.
Figure 17-3 shows channel 0 decrementing the counter. The configuration of channel 0 differs from that in
Figure 17-2 in the following two aspects:
• PCNT_CH0_LCTRL_MODE_Un = 1: invert counter mode when ctrl_ch0_un is at low level, so it will de-
crease, rather than increase, the counter.
• PCNT_CNT_H_LIM_Un = –5: PULSE_CNT resets to 0 when the count value decreases to –5.
17.2.5 Interrupts
PCNT_CNT_THR_EVENT_Un_INT: This interrupt gets triggered when one of the five channel comparators de-
tects a match.
17.4 Registers
The addresses in parenthesis besides register names are the register addresses relative to the PCNT base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 17.3 Register Summary.
Un
Un
Un
Un
Un
n
E_
_F _Z IM _ n
E_
Un
Un
E_
PC T_T _H IM_ EN n
E_
_U
NT HR _L EN _U
_E EN Un
ILT ER _E Un
N HR _L 0_ U
Un n
E_
OD
Un
OD
E_
E_
OD
_
OD
N_ _U
DE
ER O_ N_
N
OD
S_
_M
OD
OD
_M
M
NT HR R _E
_M
RE
L_
_M
_M
_M
1
_M
RL
RL
PC T_T _T ES
PC _T L S
RL
TR
H
E
OS
PC T_T NEG
CT
CT
OS
EG
_T
N HR HR
CT
HC
H
_H
_P
_L
ER
_N
_P
_L
PC _T _T
_
_
_
H0
H0
H0
H0
ILT
NT HR
H1
H1
H1
H1
_C
_C
_C
_C
_C
_C
_C
_C
_F
NT
NT
NT
NT
NT
NT
NT
NT
NT
N
PC
PC
PC
PC
PC
PC
PC
PC
PC
PC
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 0
0 0 0 0 0 0 0 0 0 0 1 1 1 1 0x010 Reset
PCNT_CH1_POS_MODE_Un This register sets the behaviour when the signal input of channel 1
detects a positive edge. (R/W) 1: Increment the counter; 2: Decrement the counter; 0, 3: No
effect on counter
PCNT_CH1_NEG_MODE_Un This register sets the behaviour when the signal input of channel 1 de-
tects a negative edge. (R/W) 1: Increment the counter; 2: Decrement the counter; 0, 3: No
effect on counter
PCNT_CH0_POS_MODE_Un This register sets the behaviour when the signal input of channel 0
detects a positive edge. (R/W) 1: Increase the counter; 2: Decrease the counter; 0, 3: No
effect on counter
PCNT_CH0_NEG_MODE_Un This register sets the behaviour when the signal input of channel 0
detects a negative edge. (R/W) 1: Increase the counter; 2: Decrease the counter; 0, 3: No
effect on counter
PCNT_THR_THRES1_EN_Un This is the enable bit for unit n’s thres1 comparator. (R/W)
PCNT_THR_THRES0_EN_Un This is the enable bit for unit n’s thres0 comparator. (R/W)
PCNT_THR_L_LIM_EN_Un This is the enable bit for unit n’s thr_l_lim comparator. (R/W)
PCNT_THR_H_LIM_EN_Un This is the enable bit for unit n’s thr_h_lim comparator. (R/W)
PCNT_THR_ZERO_EN_Un This is the enable bit for unit n’s zero comparator. (R/W)
PCNT_FILTER_EN_Un This is the enable bit for unit n’s input filter. (R/W)
PCNT_FILTER_THRES_Un This sets the maximum threshold, in APB_CLK cycles, for the filter. Any
pulses lasting shorter than this will be ignored when the filter is enabled. (R/W)
n
Un
_U
1_
S0
ES
RE
R
TH
TH
T_
T_
N
N
_C
_C
NT
NT
PC
PC
31 16 15 0
PCNT_CNT_THRES1_Un This register is used to configure the thres1 value for unit n. (R/W)
PCNT_CNT_THRES0_Un This register is used to configure the thres0 value for unit n. (R/W)
_U
_U
IM
M
I
L
_L
H_
_L
T_
NT
N
_C
_C
NT
NT
PC
PC
31 16 15 0
PCNT_CNT_L_LIM_Un This register is used to configure the thr_l_lim value for unit n. (R/W)
PCNT_CNT_H_LIM_Un This register is used to configure the thr_h_lim value for unit n. (R/W)
31
31
31
0
0
0
0
Espressif Systems
0
0
0
(re
0
se
rv
ed
0
)
17 Pulse Count Controller (PCNT)
0
0
(re (re
0
se se
rv rv
0x0000000
0x0000000
ed ed
0
) )
PCNT_CNT_THR_EVENT_Un_INT_ST The
0
PCNT_CNT_THR_EVENT_Un_INT_RAW The
0
16
15
508
PCNT_CNT_THR_EVENT_Un_INT interrupt. (RO)
PCNT_CNT_THR_EVENT_Un_INT interrupt. (RO)
raw
masked
interrupt
Register 17.6. PCNT_INT_ST_REG (0x0084)
8
8
Register 17.5. PCNT_INT_RAW_REG (0x0080)
PC
7
7
0
0
PC PC NT
0x00000
N N
status
_P
6
6
0
0
status
PC T_C PC T_C LU
Register 17.4. PCNT_Un_CNT_REG (n: 0-7) (0x60+0x04*n)
NT NT NT NT S_
5
5
0
0
PC _C _T PC _C _T CN
N N HR N N HR T_
4
4
bit
0
0
Un
bit
PC T_C T_T _E PC T_C T_T _E
N N HR VE N N HR VE
3
3
0
0
N N HR VE U N N HR VE U
2
2
0
0
for
N N HR VE U T_ N N HR VE U T_
1
1
0
0
0
0
0
the
the
_C _T _E T_ _I S _C _T _E T_ _I R
NT HR VE U NT T NT HR VE U NT AW
0 Reset
0 Reset
Reset
_T _E NT 3_ _S _T _E NT 3_ _R
HR VE _U INT T HR VE _U INT AW
Espressif Systems
terrupt. (WO)
17 Pulse Count Controller (PCNT)
(re (re
se se
rv rv
0x0000000
0x0000000
ed ed
) )
PCNT_CNT_THR_EVENT_Un_INT_ENA The
509
PCNT_CNT_THR_EVENT_Un_INT interrupt. (R/W)
interrupt
8
8
Register 17.7. PCNT_INT_ENA_REG (0x0088)
7
7
0
0
PC PC
N N
6
6
0
0
PC T_C PC T_C
5
N N NT NT
5
bit
0
0
PC T_C T_T PC _C _T
N N HR N N HR
4
4
0
0
0
0
2
2
0
0
0
0
_C _T _E T_ _I C _C _T _E T_ _I E
NT HR VE U NT LR NT HR VE U NT NA
0 Reset
0 Reset
_T _E NT 3_ _C _T _E NT 3_ _E
HR VE _U INT LR HR VE _U INT NA
U0
N N CN _U 6
NT NT CN _U 2
N N CN _U 3
NT NT CN _U 5
N N CN _U 4
N N CN _U 7
CN _U U1
PC T_C S_ SE T_U
PC T_C S_ SE T_U
PC T_C S_ SE T_U
PC T_C S_ SE T_U
PC T_C S_ SE T_U
PC T_C S_ SE T_U
S_ SE T_
T_
T_ 0
PC T_P T_P T_ 6
PC T_P T_P T_ 2
PC T_P T_P T_ 3
PC T_P T_P T_ 5
PC _P _P T_ 4
PC T_P T_P T_ 7
_P _P T_ 1
N N CN _U
N LU AU RS
N LU AU RS
N LU AU RS
N LU AU RS
N LU AU RS
N LU AU RS
LU AU RS
RS
PC T_C S_ SE
N LU AU
N N N
PC T_P T_P
PC T_C _E
N LK
)
ed
PC T_C
rv
se
N
(re
PC
31 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0x0000 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Reset
Un
ER LAT Un
n
HR HR _L Un
ES LA n
_U
E_
NT HR _L _LA n
1_ T_
HR 0_ U
PC T_T _L IM T_U
_T _T IM T_
NT _T ES AT_
OD
N HR _L LA
M
PC T_T _H O_
O_
N HR ER
PC T_T _Z
_Z
)
N HR
HR
ed
PC T_T
_T
rv
se
N
(re
PC
PC
31 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 Reset
PCNT_THR_ZERO_LAT_Un The last interrupt happened on counter for unit n reaching 0. (RO)
PCNT_THR_H_LIM_LAT_Un The last interrupt happened on counter for unit n reaching thr_h_lim.
(RO)
PCNT_THR_L_LIM_LAT_Un The last interrupt happened on counter for unit n reaching thr_l_lim.
(RO)
PCNT_THR_THRES0_LAT_Un The last interrupt happened on counter for unit n reaching thres0.
(RO)
PCNT_THR_THRES1_LAT_Un The last interrupt happened on counter for unit n reaching thres1. (RO)
PCNT_THR_ZERO_MODE_Un This register stores the current status of the counter. 0: counting
value is +0 (the counter values are represented by signed binary numbers); 1: counting value is
-0; 2: counting value is negative; 3: counting value is positive. (RO)
18.1 Introduction
There are four general-purpose timers embedded in the ESP32. They are all 64-bit generic timers based on
16-bit prescalers and 64-bit auto-reload-capable up/downcounters.
The ESP32 contains two timer modules, each containing two timers. The two timers in a block are indicated by
an x in TIMGn_Tx; the blocks themselves are indicated by an n.
• Auto-reload at alarm
Counting can be enabled and disabled by setting and clearing TIMGn_Tx_EN. Clearing this bit essentially freezes
the counter, causing it to neither count up nor count down; instead, it retains its value until TIMGn_Tx_EN is
set again. Reloading the counter when TIMGn_Tx_EN is cleared will change its value, but counting will not be
resumed until TIMGn_Tx_EN is set.
Software can set a new counter value by setting registers TIMGn_Tx_LOAD_LO and TIMGn_Tx_LOAD_HI to the
intended new value. The hardware will ignore these register settings until a reload; a reload will cause the
contents of these registers to be copied to the counter itself. A reload event can be triggered by an alarm
(auto-reload at alarm) or by software (software instant reload). To enable auto-reload at alarm, the register
TIMGn_Tx_AUTORELOAD should be set. If auto-reload at alarm is not enabled, the time-base counter will con-
tinue incrementing or decrementing after the alarm. To trigger a software instant reload, any value can be written
The time-base counter can also be read by software, but because the counter is 64-bit, the CPU can only get the
value as two 32-bit values, the counter value needs to be latched onto TIMGn_TxLO_REG and TIMGn_TxHI_REG
first. This is done by writing any value to TIMGn_TxUPDATE_REG; this will instantly latch the 64-bit timer value
onto the two registers. Software can then read them at any point in time. This approach stops the timer
value being read erroneously when a carry-over happens between reading the low and high word of the timer
value.
18.2.4 MWDT
Each timer module also contains a Main System Watchdog Timer and its associated registers. While these regis-
ters are described here, their functional description can be found in the chapter entitled Watchdog Timer.
18.2.5 Interrupts
• TIMGn_INT_WDT_INT: Generated when a watchdog timer interrupt stage times out.
18.4 Registers
The addresses in parenthesis besides register names are the register addresses relative to the TIMG base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 18.3 Register Summary.
_E N
AL L_ EN
D
M T_E
A
N
x_ VE T_
LO
TO SE
AR IN
_T LE _IN
RE
R
AU EA
DE
Gn _ E
x_ R
M Tx G
I
_T INC
IV
TI n_ _EN
TI _ ED
D
Gn _
x_
Gn _
M Tx
M Tx
M Tx
_T
TI n_
TI n_
Gn
G
G
G
M
M
TI
TI
TI
31 30 29 28 13 12 11 10
0 1 1 0x00001 0 0 0 Reset
TIMGn_Tx_INCREASE When set, the timer x time-base counter will increment every clock tick.
When cleared, the timer x time-base counter will decrement. (R/W)
TIMGn_Tx_EDGE_INT_EN When set, an alarm will generate an edge type interrupt. (R/W)
TIMGn_Tx_LEVEL_INT_EN When set, an alarm will generate a level type interrupt. (R/W)
TIMGn_Tx_ALARM_EN When set, the alarm is enabled. This bit is automatically cleared once an
alarm occurs. (R/W)
31 0
0x000000000 Reset
TIMGn_TxLO_REG After writing to TIMGn_TxUPDATE_REG, the low 32 bits of the time-base counter
of timer x can be read here. (RO)
31 0
0x000000000 Reset
TIMGn_TxHI_REG After writing to TIMGn_TxUPDATE_REG, the high 32 bits of the time-base counter
of timer x can be read here. (RO)
31 0
0x000000000 Reset
TIMGn_TxUPDATE_REG Write any value to trigger a timer x time-base counter value update (timer
x current value will be stored in registers above). (WO)
31 0
0x000000000 Reset
TIMGn_TxALARMLO_REG Timer x alarm trigger time-base counter value, low 32 bits. (R/W)
31 0
0x000000000 Reset
TIMGn_TxALARMHI_REG Timer x alarm trigger time-base counter value, high 32 bits. (R/W)
31 0
0x000000000 Reset
TIMGn_TxLOADLO_REG Low 32 bits of the value that a reload will load onto timer x time-base
counter. (R/W)
31 0
0x000000000 Reset
TIMGn_TxLOADHI_REG High 32 bits of the value that a reload will load onto timer x time-base
counter. (R/W)
31 0
0x000000000 Reset
TIMGn_TxLOAD_REG Write any value to trigger a timer x time-base counter reload. (WO)
N
TH
_E
GT
NG
OD
EN
LE
_M
N
_I EN
_L
_E
T_
OT
ET
EL T_
NT
SE
BO
ES
EV IN
RE
_L E_
SH
_R
_
0
G2
3
1
PU
DT DG
TG
TG
TG
YS
LA
N
ST
_C
_S
_S
_S
_S
Gn T_E
_W T_E
_F
_
DT
DT
DT
DT
DT
DT
DT
D
Gn D
_W
_W
_W
_W
_W
M W
_W
_W
_W
TI n_
Gn
Gn
Gn
Gn
Gn
Gn
Gn
G
M
M
TI
TI
TI
TI
TI
TI
TI
TI
TI
31 30 29 28 27 26 25 24 23 22 21 20 18 17 15 14
TIMGn_WDT_STG0 Stage 0 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMGn_WDT_STG1 Stage 1 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMGn_WDT_STG2 Stage 2 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMGn_WDT_STG3 Stage 3 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMGn_WDT_EDGE_INT_EN When set, an edge type interrupt will occur at the timeout of a stage
configured to generate an interrupt. (R/W)
TIMGn_WDT_LEVEL_INT_EN When set, a level type interrupt will occur at the timeout of a stage
configured to generate an interrupt. (R/W)
TIMGn_WDT_CPU_RESET_LENGTH CPU reset signal length selection. 0: 100 ns, 1: 200 ns, 2: 300
ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 µs, 7: 3.2 µs. (R/W)
TIMGn_WDT_SYS_RESET_LENGTH System reset signal length selection. 0: 100 ns, 1: 200 ns, 2:
300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 µs, 7: 3.2 µs. (R/W)
E
AL
SC
RE
_P
LK
_C
DT
_W
Gn
M
TI
31 16
0x00001 Reset
TIMGn_WDT_CLK_PRESCALE MWDT clock prescale value. MWDT clock period = MWDT’s clock
source period * TIMGn_WDT_CLK_PRESCALE. (R/W)
31 0
26000000 Reset
31 0
0x007FFFFFF Reset
31 0
0x0000FFFFF Reset
31 0
0x0000FFFFF Reset
31 0
0x000000000 Reset
31 0
0x050D83AA1 Reset
TIMGn_WDTWPROTECT_REG If the register contains a different value than its reset value, write pro-
tection is enabled. (R/W)
G
IN
CL
CY
EL
T_
_S
T
AR
AR
AX
CA DY
_C CLK
ST
ST
M
R
I_
I_
I_
I_
LI
AL
AL
AL
AL
_C
_C
Gn C_C
_
TC
TC
TC
TC
)
T
ed
_R
_R
_R
_R
_R
rv
Gn
Gn
Gn
Gn
se
M
(re
TI
TI
TI
TI
TI
31 30 16 15 14 13 12 11 0
E
LU
VA
L I_
CA
C_
)
RT
ed
_
rv
Gn
se
M
(re
TI
31 7 5 0
0x00000 0 0 0 0 0 0 Reset
0_ _E A
_T NT EN
A
IN NA
EN
NT _I T_
T_
_I _T1 IN
Gn T T_
M IN D
TI _ _W
Gn T
)
M _IN
ed
rv
Gn
se
M
(re
TI
TI
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TIMGn_INT_WDT_INT_ENA The interrupt enable bit for the TIMGn_INT_WDT_INT interrupt. (R/W)
(R/W)
TIMGn_INT_T1_INT_ENA The interrupt enable bit for the TIMGn_INT_T1_INT interrupt. (R/W) (R/W)
TIMGn_INT_T0_INT_ENA The interrupt enable bit for the TIMGn_INT_T0_INT interrupt. (R/W) (R/W)
W
_T NT RA
IN AW
RA
NT _I T_
T_
_I _T1 IN
Gn T T_
M IN D
TI _ _W
Gn T
)
M IN
ed
TI n_
rv
se
G
M
(re
TI
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TIMGn_INT_WDT_INT_RAW The raw interrupt status bit for the TIMGn_INT_WDT_INT interrupt. (RO)
TIMGn_INT_T1_INT_RAW The raw interrupt status bit for the TIMGn_INT_T1_INT interrupt. (RO)
TIMGn_INT_T0_INT_RAW The raw interrupt status bit for the TIMGn_INT_T0_INT interrupt. (RO)
_T NT ST
ST
IN T
NT _I T_
0_ _S
T_
_I _T1 IN
Gn T T_
M IN D
TI _ _W
Gn T
d)
M IN
ve
TI n_
r
se
G
M
(re
TI
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TIMGn_INT_WDT_INT_ST The masked interrupt status bit for the TIMGn_INT_WDT_INT interrupt.
(RO)
TIMGn_INT_T1_INT_ST The masked interrupt status bit for the TIMGn_INT_T1_INT interrupt. (RO)
TIMGn_INT_T0_INT_ST The masked interrupt status bit for the TIMGn_INT_T0_INT interrupt. (RO)
0_ _C R
_T NT CL
R
IN LR
CL
NT _I T_
T_
_I _T1 IN
Gn T T_
M IN D
TI n_ T_W
)
M IN
ed
TI n_
rv
se
G
G
M
(re
TI
31 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
19.1 Introduction
The ESP32 has three watchdog timers: one in each of the two timer modules (called Main System Watchdog
Timer, or MWDT) and one in the RTC module (which is called the RTC Watchdog Timer, or RWDT). These
watchdog timers are intended to recover from an unforeseen fault, causing the application program to abandon
its normal sequence. A watchdog timer has four stages. Each stage may take one out of three or four actions
upon the expiry of a programmed period of time for this stage, unless the watchdog is fed or disabled. The
actions are: interrupt, CPU reset, core reset and system reset. Only the RWDT can trigger the system reset, and
is able to reset the entire chip and the main system including the RTC itself. A timeout value can be set for each
stage individually.
During flash boot, the RWDT and the first MWDT start automatically in order to detect and recover from booting
problems.
19.2 Features
• Four stages, each of which can be configured or disabled separately
• One out of three or four possible actions (interrupt, CPU reset, core reset and system reset) upon the
expiry of each stage
• Write protection, to prevent the RWDT and MWDT configuration from being inadvertently altered.
Every stage can be configured for one of the following actions when the expiry timer reaches the stage’s timeout
value:
• Trigger an interrupt
When the stage expires an interrupt is triggered.
• Disabled
This stage will have no effects on the system.
When software feeds the watchdog timer, it returns to stage 0 and its expiry counter restarts from 0.
19.3.1.4 Registers
The MWDT registers are part of the timer submodule and are described in the Timer Registers section. The
RWDT registers are part of the RTC submodule and are described in the RTC Registers section.
20 eFuse Controller
20.1 Introduction
The ESP32 has a number of eFuses which store system parameters. Fundamentally, an eFuse is a single bit of
non-volatile memory with the restriction that once an eFuse bit is programmed to 1, it can never be reverted to
0. Software can instruct the eFuse Controller to program each bit for each system parameter as needed.
Some of these system parameters can be read by software using the eFuse Controller. Some of the system
parameters are also directly used by hardware modules.
20.2 Features
• Configuration of 33 system parameters
• Optional write-protection
• Optional software-read-protection
Program Software-Read
Name Bit width -Protection by -Protection by Description
efuse_wr_disable efuse_rd_disable
efuse_wr_disable 16 1 - controls the eFuse Controller
efuse_rd_disable 4 0 - controls the eFuse Controller
governs the flash encryption/
flash_crypt_cnt 7 2 -
decryption
determines whether
XPD_SDIO_REG
sdio_force 1 5 -
and SDIO_TIEH can
control the flash regulator
BLK3_part_reserve 2 10 3 controls the eFuse controller
Program Software-Read
Name Bit width -Protection by -Protection by Description
efuse_wr_disable efuse_rd_disable
configures the SPI I/O to a
SPI_pad_config_clk 5 6 -
certain pad
configures the SPI I/O to a
SPI_pad_config_q 5 6 -
certain pad
configures the SPI I/O to a
SPI_pad_config_d 5 6 -
certain pad
configures the SPI I/O to a
SPI_pad_config_cs0 5 6 -
certain pad
governs flash encryption/
flash_crypt_config 4 10 3
decryption
coding_scheme* 2 10 3 controls the eFuse Controller
disables the ROM BASIC
console_debug_disable 1 15 - debug console fallback
mode when set to 1
determines the status of
abstract_done_0 1 12 -
Secure Boot
determines the status of
abstract_done_1 1 13 -
Secure Boot
disables access to the
JTAG controllers so as to
JTAG_disable 1 14 -
effectively disable external
use of JTAG
governs flash encryption/
download_dis_encrypt 1 15 -
decryption
governs flash encryption/
download_dis_decrypt 1 15 -
decryption
disables cache when boot
download_dis_cache 1 15 -
mode is the Download Mode
determines whether BLOCK3
key_status 1 10 3
is deployed for user purposes
Program Software-Read
Name Bit width -Protection by -Protection by Description
efuse_wr_disable efuse_rd_disable
stores the voltage level for
vol_level_hp_inv 2 3 - CPU to run at 240 MHz, or
for flash/PSRAM to run at 80
MHz
stores the difference be-
dig_vol_l6 4 11 - tween the digital regulator
voltage at level 6 and 1.2 V.
permanently disables Down-
load Boot mode when set to
uart_download_dis 1 2 -
1. Valid only for ESP32 ECO
V3.
If a system parameter is not write-protected, its unprogrammed bits can be programmed from 0 to 1. The bits
previously programmed to 1 will remain 1. When a system parameter is write-protected, none of its bits can be
programmed: The unprogrammed bits will always remain 0 and the programmed bits will always remain 1.
The write-protection status of each system parameter corresponds to a bit in efuse_wr_disable. When the
corresponding bit is set to 0, the system parameter is not write-protected. When the corresponding bit is set to
1, the system parameter is write-protected. If a system parameter is already write-protected, it will remain write-
protected. The column entitled “Program-Protection by efuse_wr_disable” in Table 20-1 lists the corresponding
bits that determine the write-protection status of each system parameter.
When not software-read-protected, the other six system parameters can both be read by software and used
by hardware modules. When they are software-read-protected, they can only be used by the hardware mod-
ules.
The column “Software-Read-Protection by efuse_rd_disable” in Table 20-1 lists the corresponding bits in efuse_rd
_disable that determine the software read-protection status of the six system parameters. If a bit in the system
parameter efuse_rd_disable is 0, the system parameter controlled by the bit is not software-read-protected. If
a bit in the system parameter efuse_rd_disable is 1, the system parameter controlled by the bit is software-read-
protected. If a system parameter is software-read-protected, it will remain in this state.
• BLOCKN represents any of the following three system parameters: BLOCK1, BLOCK2 or BLOCK3.
• BLOCKN [255 : 0], BLOCKN [191 : 0], and BLOCKN [127 : 0] represent each bit of the three system
parameters in the three encoding schemes.
e
• BLOCKN [255 : 0] represents each corresponding bit of those system parameters in eFuse after being
encoded.
None
e
BLOCKN [255 : 0] = BLOCKN [255 : 0]
3/4
BLOCKNij [7 : 0] j ∈ {0, 1, 2, 3, 4, 5}
BLOCKNi0 [7 : 0] ⊕ BLOCKNi1 [7 : 0]
⊕ BLOCKN 2 [7 : 0] ⊕ BLOCKN 3 [7 : 0]
i i j ∈ {6}
e
BLOCKN ji [7 : 0] = i ∈ {0, 1, 2, 3}
⊕ BLOCKNi [7 : 0] ⊕ BLOCKNi5 [7 : 0]
4
X5 X
7
(l + 1) BLOCKNil [k] j ∈ {7}
l=0 k=0
Repeat
e e
BLOCKN [255 : 128] = BLOCKN [127 : 0] = BLOCKN [127 : 0]
20.3.1.4 BLK3_part_reserve
System parameters coding_scheme, BLOCK1, BLOCK2, and BLOCK3 are controlled by the parameter BLK3_part
_reserve.
When the value of BLK3_part_reserve is 0, coding_scheme, BLOCK1, BLOCK2, and BLOCK3 can be set to any
value.
Each bit of the 30 fixed-length system parameters and the three encoded variable-length system parameters
corresponds to a program register bit, as shown in Table 20-3. The register bits will be used when programming
system parameters.
2. Set the corresponding register bit of the system parameter bit to be programmed to 1.
The configuration values of the EFUSE_CLK_SEL0 bit, EFUSE_CLK_SEL1 bit of register EFUSE_CLK, and the
EFUSE_DAC_CLK_DIV bit of register EFUSE_DAC_CONF are based on the current APB_CLK frequency, as is
shown in Table 20-4.
APB_CLK Frequency
Register Configuration Value
26 MHz 40 MHz 80 MHz
EFUSE_CLK_SEL0[7:0] 250 160 80
EFUSE_CLK
EFUSE_CLK_SEL1[7:0] 255 255 128
EFUSE_DAC_CONF EFUSE_DAC_CLK_DIV[7:0] 52 80 100
The two methods to identify the generation of program/read-done interrupts are as follows:
Method One:
1. Poll bit 1/0 in register EFUSE_INT_RAW until bit 1/0 is 1, which represents the generation of an program/read-
done interrupt.
2. Set the bit 1/0 in register EFUSE_INT_CLR to 1 to clear the program/read-done interrupts.
Method Two:
1. Set bit 1/0 in register EFUSE_INT_ENA to 1 to enable eFuse Controller to post a program/read-done inter-
rupt.
4. Read bit 1/0 in register EFUSE_INT_ST to identify the generation of the program/read-done interrupt.
The programming of different system parameters and even the programming of different bits of the same system
parameter can be completed separately in multiple programmings. It is, however, recommended that users
minimize programming cycles, and program all the bits that need to be programmed in a system parameter in one
programming action. In addition, after all system parameters controlled by a certain bit of efuse_wr_disable are
programmed, that bit should be immediately programmed. The programming of system parameters controlled
by a certain bit of efuse_wr_disable, and the programming of that bit can even be completed at the same time.
Repeated programming of programmed bits is strictly forbidden.
The bit width of system parameters BLOCK1, BLOCK2, and BLOCK3 is variable. Although 256 register bits have
been assigned to each of the three parameters, as shown in Table 20-5, some of the 256 register bits are useless
in the 3/4 coding and the Repeat coding scheme. In the None coding scheme, the corresponding register bit
of each bit of BLOCKN [255 : 0] is used. In the 3/4 coding scheme, only the corresponding register bits of
BLOCKN [191 : 0] are useful. In Repeat coding scheme, only the corresponding bits of BLOCKN [127 : 0] are
useful. In different coding schemes, the values of useless register bits read by software are invalid. The values
of useful register bits read by software are the system parameters BLOCK1, BLOCK2, and BLOCK3 themselves
instead of their values after being encoded.
20.3.5 Interrupts
• EFUSE_PGM_DONE_INT: Triggered when eFuse programming has finished.
20.5 Registers
The addresses in this section are relative to the eFuse Controller base address provided in Table 1-6 Peripheral
Address Mapping in Chapter 1 System and Memory.
D IS
T
D_
CN
OA
S
T_
IS
DI
NL
D
P
R_
D_
RY
OW
W
_R
_C
E_
_D
SE
SH
US
RT
FU
LA
A
F
_U
_E
_E
_F
RD
RD
RD
RD
)
ed
E_
E_
E_
E_
rv
US
US
US
US
se
(re
EF
EF
EF
EF
31 28 27 26 20 19 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_RD_UART_DOWNLOAD_DIS This bit returns the value of uart_download_dis. Valid only for
ESP32 . (RO)
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_BLK0_RDATA1_REG This field returns the value of the lower 32 bits of WIFI_MAC_Address.
(RO)
E_
rv
US
se
(re
EF
31 24 23 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
U
CP
HE
D
P_
_H
HI ER KG AC
AP
DI BT
IG
_C P_V _P _C
NF
R_ S_
S_
G
RD HI ER IS
PK
VE DI
CO
E_ _C _V D
R_
P_ _
D_
US RD HI ER
E
PA
_V
EF E_ _C P_V
IP
P
I_
US RD HI
CH
SP
EF E_ _C
D_
D_
US RD
)
ed
_R
E_
EF E_
rv
SE
US
US
se
U
(re
EF
EF
EF
31 12 11 9 8 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_RD_CHIP_VER_PKG These are the first three identification bits of chip packaging version
among the four identification bits. (RO)
EFUSE_RD_CHIP_VER_PKG This is the fourth identification bit of chip packaging version among the
four identification bits. (RO)
Q
PD TIE E
RE
_X O_ RC
_S H
O
_F
RD DI FO
DI
8M
E_ _S O_
K
US RD DI
_C
EF SE_ _S
RD
U RD
)
)
ed
ed
E_
EF SE_
rv
rv
S
FU
se
se
U
(re
(re
ES
EF
31 17 16 15 14 13 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
IG
LK
CS
NF
_D
_C
NV
G_
G_
CO
IG
IG
_I
I
HP
NF
NF
NF
NF
T_
P
CO
CO
CO
CO
L_
6
RY
_L
VE
D_
D_
D_
D_
_C
OL
LE
PA
PA
PA
PA
H
_V
L_
AS
I_
I_
I_
I_
IG
SP
P
O
FL
_D
_S
_S
_S
_V
D_
D_
RD
RD
RD
RD
RD
d)
R
R
ve
E_
E_
E_
E_
E_
E_
E_
r
US
US
US
US
US
US
US
se
(re
EF
EF
EF
EF
EF
EF
EF
31 28 27 24 23 22 21 20 19 15 14 10 9 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_RD_DIG_VOL_L6 This field stores the difference between the digital regulator voltage at
level 6 and 1.2 V. (RO)
EFUSE_RD_VOL_LEVEL_HP_INV This field stores the voltage level for CPU to run at 240 MHz, or
for flash/PSRAM to run at 80 MHz. 0x0: level 7; 0x1: level 6; 0x2: level 5; 0x3: level 4. (RO)
E
BL
SA
T
EF rve _A S_D _JT ENC YPT
YP
DI
(re SE_ _A AB _DL DEC E
US d) BS O AG R
G_
U RD IS LE _ H
se RD B LE _ R
EF SE_ _D AB _DL CAC
E
G_ BU
M
HE
0
U RD IS LE _
E
ON _1
E_
OD E_D
EF SE_ _D AB _DL
EF SE_ _D AB US
SC
_D NE
U RD IS TAT
U RD IS LE
_C OL
IN
EF E_ _D _S
RD NS
US RD EY
O
_C
EF SE_ _K
U RD
RD
d)
ve
EF SE_
E_
E_
r
US
se
U
(re
EF
EF
31 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
D_
CN
OA
T_
NL
YP
OW
CR
H_
D
S
IS
DI
T_
D
AS
R_
D_
AR
)
FL
ed
_W
_U
_R
E_
rv
E
US
US
US
US
se
(re
EF
EF
EF
EF
31 28 27 26 20 19 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_UART_DOWNLOAD_DIS This bit programs the value of uart_download_dis. Valid only for
ESP32 ECO V3. (R/W)
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
H
H IG
R C_
_C
AC
M
I_
IF
)
ed
W
E_
rv
US
se
(re
EF
31 24 23 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PU
E
_C
D
IP R_ G CH
_H
PP
IS T
CH _VE PK CA
IG
_D _B
_A
NF
E_ IP R_ S_
KG
ER IS
US CH VE DI
CO
_V D
P
R_
EF E_ IP_ R_
D_
VE
US CH VE
PA
P_
EF E_ IP_
I_
HI
US CH
SP
)
ed
_C
E_
EF SE_
rv
E
US
US
se
U
(re
EF
EF
EF
31 12 11 9 8 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_CHIP_VER_PKG These are the first three bits among the four bits to program chip packaging
version. (R/W)
EFUSE_CHIP_VER_PKG This is the fourth bit among the four bits to program chip packaging version.
(R/W)
EQ
XP _T CE
R
D_ IEH
E_ IO OR
IO
_F
SD
US SD _F
M
K8
EF SE_ IO
U SD
_C
)
)
ed
ed
EF SE_
SE
rv
rv
FU
se
se
U
(re
(re
ES
EF
31 17 16 15 14 13 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LK
S
NF
_D
_Q
_C
_C
NV
CO
IG
IG
IG
IG
I
P_
NF
NF
NF
NF
T_
_H
P
CO
CO
CO
CO
6
RY
EL
_L
D_
D_
D_
D_
_C
EV
L
VO
PA
PA
PA
PA
SH
_L
G_
I_
I_
I_
I_
LA
SP
SP
SP
SP
VO
)
DI
ed
F
E_
E_
E_
E_
E_
E_
E_
rv
US
US
US
US
US
US
US
se
(re
EF
EF
EF
EF
EF
EF
EF
31 28 27 24 23 22 21 20 19 15 14 10 9 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_DIG_VOL_L6 This field stores the difference between the digital regulator voltage at level 6
and 1.2 V. (R/W)
EFUSE_VOL_LEVEL_HP_INV These bits store the voltage level for CPU to run at 240 MHz, or for
flash/PSRAM to run at 80 MHz. 0x0: level 7; 0x1: level 6; 0x2: level 5; 0x3: level 4. (R/W)
E
BL
EM ISA
T
se AB D TA C T
EF rve S_ ONE G RYP
(re SE_ S_ E_J _EN RYP
CH _D
EF SE_ ISA E_D _DE HE
_S UG
U AB BL L C
U D BL L C
E
EF SE_ ISA E_D _CA
B
_0
DI _DE
US d) DO _1
U D BL L
U D BL S
EF SE_ ISA E_D
NE
EF SE_ ISA ATU
CO LE
NG
U D ST
E_ SO
EF E_ Y_
US ON
US KE
)
ed
C
EF SE_
E_
rv
se
U
(re
EF
EF
31 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
31 0
0x000000000 Reset
L
E
SE
_S
K_
LK
L
)
ed
_C
_C
rv
E
US
US
se
(re
EF
EF
31 16 15 8 7 0
DE
CO
P_
d)
_O
ve
E
r
US
se
(re
EF
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00000 Reset
D
AD MD
M
_C
RE _C
E_ M
US PG
)
ed
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_PGM_CMD Set this to 1 to start a program operation. Reverts to 0 when the program oper-
ation is done. (R/W)
EFUSE_READ_CMD Set this to 1 to start a read operation. Reverts to 0 when the read operation is
done. (R/W)
W
IN AW
RA
E_ T_R
T_
ON IN
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_PGM_DONE_INT_RAW The raw interrupt status bit for the EFUSE_PGM_DONE_INT inter-
rupt. (RO)
EFUSE_READ_DONE_INT_RAW The raw interrupt status bit for the EFUSE_READ_DONE_INT inter-
rupt. (RO)
ST
IN T
E_ T_S
T_
ON IN
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_PGM_DONE_INT_ST The masked interrupt status bit for the EFUSE_PGM_DONE_INT inter-
rupt. (RO)
EFUSE_READ_DONE_INT_ST The masked interrupt status bit for the EFUSE_READ_DONE_INT in-
terrupt. (RO)
A
IN NA
EN
E_ T_E
T_
ON IN
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
V
DI
K_
CL
C_
DA
)
ed
E_
rv
US
se
(re
EF
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 40 Reset
S
NG
NI
AR
_W
EC
)
ed
_D
rv
E
US
se
(re
EF
31 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EFUSE_DEC_WARNINGS If a bit is set in this register, it means some errors were corrected while
decoding the 3/4 encoding scheme. (RO)
21.1 Overview
The Two-wire Automotive Interface (TWAI® ) is a multi-master, multi-cast communication protocol with error
detection and signaling and inbuilt message priorities and arbitration.The TWAI protocol is suited for automotive
and industrial applications (Please see TWAI Protocol Description).
ESP32 contains a TWAI controller that can be connected to a TWAI bus via an external transceiver. The TWAI
controller contains numerous advanced features, and can be utilized in a wide range of use cases such as
automotive products, industrial automation controls, building automation etc.
21.2 Features
ESP32 TWAI controller supports the following features:
• Supports Standard Frame Format (11-bit ID) and Extended Frame Format (29-bit ID)
• Bit rates:
– Normal
• Special transmissions
– Self Reception (the TWAI controller transmits and receives messages simultaneously)
– Error counters
Single Channel and Non-Return-to-Zero: The bus consists of a single channel to carry bits, thus communication
is half-duplex. Synchronization is also derived from this channel, thus extra channels (e.g., clock or enable) are
not required. The bit stream of a TWAI message is encoded using the Non-Return-to-Zero (NRZ) method.
Bit Values: The single channel can either be in a Dominant or Recessive state, representing a logical 0 and
a logical 1 respectively. A node transmitting a Dominant state will always override a another node transmitting
a Recessive state. The physical implementation on the bus is left to the application level to decide (e.g.,
differential wiring).
Bit-Stuffing: Certain fields of TWAI messages are bit-stuffed. A Transmitter that transmits five consecutive bits
of the same value should automatically insert a complementary bit. Likewise, a Receiver that receives five
consecutive bits should treat the next bit as a stuff bit. Bit stuffing is applied to the following fields: SOF,
Arbitration Field, Control Field, Data Field, and CRC Sequence (see Section 21.3.2 for more details).
Multi-cast: All nodes receive the same bits as they are connected to the same bus. Data is consistent across
all nodes unless there is a bus error (See Section 21.3.3).
Multi-master: Any node can initiate a transmission. If a transmission is already ongoing, a node will wait until
the current transmission is over before beginning its own transmission.
Message-Priorities and Arbitration: If two or more nodes simultaneously initiate a transmission, the TWAI pro-
tocol ensures that one node will win arbitration of the bus. The Arbitration Field of the message transmitted by
each node is used to determine which node will win arbitration.
Error Detection and Signaling: Each node will actively monitor the bus for errors, and signal the detection errors
by transmitting an Error Frame.
Fault Confinement: Each node will maintain a set of error counts that are incremented/decremented according
to a set of rules. When the error counts surpass a certain threshold, a node will automatically eliminate itself
from the network by switching itself off.
Configurable Bit Rate: The bit rate for a single TWAI bus is configurable. However, all nodes within the same
bus must operate at the same bit rate.
Transmitters and Receivers: At any point in time, a TWAI node can either be a Transmitter or a Receiver.
• A node originating a message is a Transmitter. The node remains a Transmitter until the bus is idle or until
the node loses arbitration. Note that multiple nodes can be Transmitter if they have yet to lose arbitration.
• Data Frames
• Remote Frames
• Error Frames
• Overload Frames
• Interframe Space
Figure 21-1. The bit fields of Data Frames and Remote Frames
Arbitration Field
When two or more nodes transmits a Data or Remote Frame simultaneously, the Arbitration Field is used to de-
termine which node will win arbitration of the bus. During the Arbitration Field, if a node transmits a Recessive
bit but observes a Dominant bit, this indicates that another node has overridden its Recessive bit. Therefore,
the node transmitting the Recessive bit has lost arbitration of the bus and should immediately become a Re-
ceiver.
The Arbitration Field primarily consists of the Frame Identifier that is transmitted most significant bit first. Given
that a Dominant bit represents a logical 0, and a Recessive bit represents a logical 1:
• Given the same ID and format, Data Frames will always prevail over RTR Frames.
• Given the same first 11 bits of ID, a Standard Format Data Frame will prevail over an Extended Format Data
Frame due to the SRR being recessive.
Control Field
The control field primarily consists of the DLC (Data Length Code) which indicates the number of payload data
bytes for a Data Frame, or the number of requested data bytes for a Remote Frame. The DLC is transmitted most
significant bit first.
Data Field
The Data Field contains the actual payload data bytes of a Data Frame. Remote Frames do not contain a Data
Field.
CRC Field
The CRC Field primarily consists of a a CRC Sequence. The CRC Sequence is a 15-bit cyclic redundancy code
calculated form the de-stuffed contents (everything from the SOF to the end of the Data Field) of a Data or
Remote Frame.
ACK Field
The ACK Field primarily consists of an ACK Slot and an ACK Delim. The ACK Field is mainly intended for the
receiver to send a message to a transmitter, indicating it has received an effective message.
Table 21-1. Data Frames and Remote Frames in SFF and EFF
Error Frames are transmitted when a node detects a Bus Error. Error Frames notably consist of an Error Flag
which is made up of 6 consecutive bits of the same value, thus violating the bit-stuffing rule. Therefore, when
a particular node detects a Bus Error and transmits an Error Frame, all other nodes will then detect a Stuff Error
and transmit their own Error Frames in response. This has the effect of propagating the detection of a Bus Error
across all nodes on the bus. When a node detects a Bus Error, it will transmit an Error Frame starting on the next
bit. However, if the type of Bus Error was a CRC Error, then the Error Frame will start at the bit following the ACK
Delim (see Section 21.3.3). The following Figure 21-2 shows the various fields of an Error Frame:
Overload Frames
An Overload Frame has the same bit fields as an Error Frame containing an Active Error Flag. The key difference
is in the conditions that can trigger the transmission of an Overload Frame. Figure 21-3 below shows the bit
fields of an Overload Frame.
1. The internal conditions of a Receiver requires a delay of the next Data or Remote Frame.
3. If a Dominant bit is detected at the eighth (last) bit of an Error Delimeter. Note that in this case, TEC and
REC will not be incremented (See Section 21.3.3).
Transmitting an overload frame due to one of the conditions must also satisfy the following rules:
• Transmitting an Overload Frame due to condition 1 must only be started at the first bit of Intermission.
• Transmitting an Overload Frame due to condition 2 and 3 must start one bit after the detecting the Dominant
bit of the condition.
• A maximum of two Overload frames may be generated in order to delay the next Data or Remote Frame.
Bit Error
A Bit Error occurs when a node transmits a bit value (i.e., Dominant or Recessive) but the opposite bit is detected
(e.g., a Dominant bit is transmitted but a Recessive is detected). However, if the transmitted bit is Recessive
and is located in the Arbitration Field or ACK Slot or Passive Error Flag, then detecting a Dominant bit will not be
considered a Bit Error.
Stuff Error
A stuff error is detected when 6 consecutive bits of the same value are detected (thus violating the bit-stuffing
encoding).
CRC Error
A Receiver of a Data or Remote Frame will calculate a CRC based on the bits it has received. A CRC error occurs
when the CRC calculated by the Receiver does not match the CRC sequence in the received Data or Remote
Frame.
Form Error
A Form Error is detected when a fixed-form bit field of a message contains an illegal bit. For example, the r1 and
Acknowledgement Error
An Acknowledgment Error occurs when a Transmitter does not detect a Dominant bit at the ACK Slot.
Error Active
An Error Active node is able to participate in bus communication and transmit an Active Error Flag when it detects
an error.
Error Passive
An Error Passive node is able to participate in bus communication, but can only transmit an Passive Error Flag
when it detects an error. Error Passive nodes that have transmitted a Data or Remote Frame must also include
the Suspend Transmission field in the subsequent Interframe Space.
Bus Off
A Bus Off node is not permitted to influence the bus in any way (i.e., is not allowed to transmit anything).
1. When a Receiver detects an error, the REC will be increased by 1, except when the detected error was a
Bit Error during the transmission of an Active Error Flag or an Overload Flag.
2. When a Receiver detects a Dominant bit as the first bit after sending an Error Flag, the REC will be increased
by 8.
3. When a Transmitter sends an Error Flag the TEC is increased by 8. However, the following scenarios are
exempt form this rule:
• If a Transmitter is Error Passive that detects an Acknowledgment Error due to not detecting a Dominant
bit in the ACK slot, it should send a Passive Error Flag. If no Dominant bit is detected in that Passive
Error Flag, the TEC should not be increased.
• A Transmitter transmits an Error Flag due to a Stuff Error during Arbitration. If the offending bit should
have been Recessive but was monitored as Dominant, then the TEC should not be increased.
4. If a Transmitter detects a Bit Error whilst sending an Active Error Flag or Overload Flag, the REC is increased
by 8.
5. If a Receiver detects a Bit Error while sending an Active Error Flag or Overload Flag, the REC is increased
by 8.
6. Any node tolerates up to 7 consecutive Dominant bits after sending an Active/Passive Error Flag, or Over-
load Flag. After detecting the 14th consecutive Dominant bit (when sending an Active Error Flag or Over-
load Flag), or the 8th consecutive Dominant bit following a Passive Error Flag, a Transmitter will increase
its TEC by 8 and a Receiver will increase its REC by 8. Each additional eight consecutive Dominant bits
will also increase the TEC (for Transmitters) or REC (for Receivers) by 8 as well.
7. When a Transmitter successfully transmits a message (getting ACK and no errors until the EOF is complete),
the TEC is decremented by 1, unless the TEC is already at 0.
8. When a Receiver successfully receives a message (no errors before ACK Slot, and successful sending of
ACK), the REC is decremented.
• If the REC was greater than 127, the REC is set to 127.
9. A node becomes Error Passive when its TEC and/or REC is greater than or equal to 128. The error condition
that causes a node to become Error Passive will cause the node to send an Active Error Flag. Note that
once the REC has reached to 128, any further increases to its value are irrelevant until the REC returns to
a value less than 128.
10. A node becomes Bus Off when its TEC is greater than or equal to 256.
11. An Error Passive node becomes Error Active when both the TEC and REC are less than or equal to 127.
12. A Bus Off node can become Error Active (with both its TEC and REC reset to 0) after it monitors 128
occurrences of 11 consecutive Recessive bits on the bus.
• The Nominal Bit Rate is defined as number of bits transmitted per second from an ideal Transmitter and
without any synchronization.
A single Nominal Bit Time is divided into multiple segments, and each segment is made up of multiple Time
Quanta. A Time Quantum is a fixed unit of time, and is implemented as some form of prescaled clock signal in
each node. Figure 21-5 illustrates the segments within a single Nominal Bit Time.
TWAI Controllers will operate in time steps of one Time Quanta where the state of the TWAI bus is analyzed at
every Time Quanta. If two consecutive Time Quantas have different bus states (i.e., Recessive to Dominant or
vice versa), this will be considered an edge. When the bus is analyzed at the intersection of PBS1 and PBS2,
this is considered the Sample Point and the sampled bus value is considered the value of that bit.
Segment Description
SS The SS (Synchronization Segment) is 1 Time Quantum long. If all nodes are perfectly
synchronized, the edge of a bit will lie in the SS.
PBS1 PBS1 (Phase Buffer Segment 1) can be 1 to 16 Time Quanta long. PBS1 is meant
to compensate for the physical delay times within the network. PBS1 can also be
lengthened for synchronization purposes.
Segment Description
PBS2 PBS2 (Phase Buffer Segment 2) can be 1 to 8 Time Quanta long. PBS2 is meant to
compensate for the information processing time of nodes. PBS2 can also be short-
ened for synchronization purposes.
• A positive Phase Error (e > 0) is when the edge lies after the SS and before the Sample Point (i.e., the
edge is late).
• A negative Phase Error (e < 0) is when the edge lies after the Sample Point of the previous bit and before
SS (i.e., the edge is early).
To correct for Phase Errors, there are two forms of synchronization, known as Hard Synchronization and Resyn-
chronization. Hard Synchronization and Resynchronization obey the following rules.
Hard Synchronization
Hard Synchronization occurs on the Recessive to Dominant edges during Bus Idle (i.e., the SOF bit). All nodes
will restart their internal bit timings such that the Recessive to Dominant edge lies within the SS of the restarted
bit timing.
Resynchronization
Resynchronization occurs on Recessive to Dominant edges not during Bus Idle. If the edge has a positive
Phase Error (e > 0), PBS1 is lengthened by a certain number of Time Quanta. If the edge has a negative Phase
Error (e < 0), PBS2 will be shortened by a certain number of Time Quanta.
The number of Time Quanta to lengthen or shorten depends on the magnitude of the Phase Error, and is also
limited by the Synchronization Jump Width (SJW) value which is a programmable.
• When the magnitude of the Phase Error is less than or equal to the SJW, PBS1/PBS2 are lengthened/shortened
by e number of Time Quanta. This has a same effect as Hard Synchronization.
• When the magnitude of the Phase Error is greater to the SJW, PBS1/PBS2 are lengthened/shortened by
the SJW number of Time Quanta. This means it may take multiple bits of synchronization before the Phase
Error is entirely corrected.
Configuration Registers
The configuration registers store various configuration options for the TWAI controller such as bit rates, operating
mode, Acceptance Filter etc. Configuration registers can only be modified whilst the TWAI controller is in Reset
Mode (See Section 21.5.1).
Command Register
The command register is used by the CPU to drive the TWAI controller to initiate certain actions such as trans-
mitting a message or clearing the Receive Buffer. The command register can only be modified when the TWAI
controller is in Operation Mode (see section 21.5.1).
The error management registers include error counters and capture registers. The error counter registers repre-
sent TEC and REC values. The capture registers will record information about instances where TWAI controller
detects a bus error, or when it loses arbitration.
Note that the Transmit Buffer registers, Receive Buffer registers, and the Acceptance Filter registers share the
same address range (offset 0x0040 to 0x0070). Their access is governed by the following rules:
• When the TWAI controller is in Reset Mode, the address range maps to the Acceptance Filter registers.
– All reads to the address range maps to the Receive Buffer registers.
– All writes to the address range maps to the Transmit Buffer registers.
• Normal Mode: The TWAI controller can transmit and receive messages including error signaling (such as
Error and Overload Frames).
• Self Test Mode: Like Normal Mode, but the TWAI controller will consider the transmission of a Data or RTR
Frame successful even if it was not acknowledged. This is commonly used when self testing the TWAI
controller.
• Listen Only Mode: The TWAI controller will be able to receive messages, but will remain completely passive
on the TWAI bus. Thus, the TWAI controller will not be able to transmit any messages, acknowledgments,
or error signals. The error counters will remain frozen. This mode is useful for TWAI bus monitors.
Note that when exiting Reset Mode (i.e., entering Operation Mode), the TWAI controller must wait for 11 con-
secutive Recessive bits to occur before being able to fully connect the TWAI bus (i.e., be able to transmit or
receive).
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved SJW.1 SJW.0 BRP.5 BRP.4 BRP.3 BRP.2 BRP.1 BRP.0
Notes:
• SJW: Synchronization Jump Width (SJW) is configured in SJW.0 and SJW.1 where SJW = (2 x SJW.1 + SJW.0
+ 1).
• BRP: The TWAI Time Quanta clock is derived from a prescaled version of the APB clock that is usually
80 MHz. The Baud Rate Prescaler (BRP) field is used to define the prescaler according to the equation
below, where tT q is the Time Quanta clock period and tCLK is APB clock period :
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved SAM PBS2.2 PBS2.1 PBS2.0 PBS1.3 PBS1.2 PBS1.1 PBS1.0
Notes:
• PBS1: The number of Time Quanta in Phase Buffer Segment 1 is defined according to the following equa-
tion: (8 x PBS1.3 + 4 x PBS1.2 + 2 x PBS1.1 + PBS1.0 + 1).
• PBS2: The number of Time Quanta in Phase Buffer Segment 2 is defined according to the following
equation: (4 x PBS2.2 + 2 x PBS2.1 + PBS2.0 + 1).
• SAM: Enables triple sampling if set to 1. This is useful for low/medium speed buses where filtering spikes
on the bus line is beneficial.
• Receive Interrupt
• Transmit Interrupt
The TWAI controller’s interrupt signal to the interrupt matrix will be asserted whenever one or more interrupt
bits are set in the TWAI_INT_RAW_REG, and deasserted when all bits in TWAI_INT_RAW_REG are cleared. The
majority of interrupt bits in TWAI_INT_RAW_REG are automatically cleared when the register is read. However,
the Receive Interrupt is an exception and can only be cleared the Receive FIFO is empty.
• A message transmission has completed successfully (i.e., Acknowledged without any errors). Any failed
messages will automatically be retried.
• A single shot transmission has completed (successfully or unsuccessfully, indicated by the TWAI_TX_COMPLETE
bit).
– If the TWAI controller was in the Error Active state, it indicates both the TEC and REC have returned
below the threshold value set by TWAI_ERR_WARNING_LIMIT_REG.
– If the TWAI controller was previously in the Bus Recovery state, it indicates that Bus Recovery has
completed successfully.
• If TWAI_ERR_ST = 1 and TWAI_BUS_OFF_ST = 0: The TEC or REC error counters have exceeded the
threshold value set by TWAI_ERR_WARNING_LIMIT_REG.
• If TWAI_ERR_ST = 1 and TWAI_BUS_OFF_ST = 1: The TWAI controller has entered the BUS_OFF state (due
to the TEC >= 256).
• If TWAI_ERR_ST = 0 and TWAI_BUS_OFF_ST = 1: The TWAI controller’s TEC has dropped below the thresh-
old value set by TWAI_ERR_WARNING_LIMIT_REG during BUS_OFF recovery.
The DOI is only triggered on the first message that causes the Receive FIFO to overrun (i.e., the transition from
the Receive FIFO not being full to the Receive FIFO overrunning). Any subsequent overrun messages will not
trigger the DOI again. The DOI will only be able to trigger again when all received messages (valid or overrun)
have been cleared.
Table 21-8. Buffer Layout for Standard Frame Format and Extended Frame Format
Table 21-8 illustrates the layout of the Transmit Buffer and Receive Buffer registers. Both the Transmit and Receive
Buffer registers share the same address space and are only accessible when the TWAI controller is in Operation
Mode. CPU write operations will access the Transmit Buffer registers, and CPU read operations will access the
Receive Buffer registers. However, both buffers share the exact same register layout and fields to represent a
message (received or to be transmitted). The Transmit Buffer registers are used to configure a TWAI message
to be transmitted. The CPU would write to the Transmit Buffer registers specifying the message’s frame type,
frame format, frame ID, and frame data (payload). Once the Transmit Buffer is configured, the CPU would then
initiate the transmission by setting the TWAI_TX_REQ bit in TWAI_CMD_REG.
• For a single-shot transmission, set both the TWAI_TX_REQ and the TWAI_ABORT_TX simultaneously.
The Receive Buffer registers map to the first message in the Receive FIFO. The CPU would read the Receive
Buffer registers to obtain the first message’s frame type, frame format, frame ID, and frame data (payload).
Once the message has been read from the Receive Buffer registers, the CPU can set the TWAI_RELEASE_BUF
bit in TWAI_CMD_REG so that the next message in the Receive FIFO will be loaded in to the Receive Buffer
registers.
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 2 3 3 4 4 4
Reserved FF RTR X X XDLC.3 DLC.2 DLC.1 DLC.04
Notes:
• FF: The Frame Format (FF) bit specifies whether the message is Extended Frame Format (EFF) or Standard
Frame Format (SFF). The message is EFF when FF bit is 1, and SFF when FF bit is 0.
• RTR: The Remote Transmission Request (RTR) bit specifies whether the message is a Data Frame or a
Remote Frame. The message is a Remote Frame when the RTR bit is 1, and a Data Frame when the RTR
bit is 0.
• DLC: The Data Length Code (DLC) field specifies the number of data bytes for a Data Frame, or the number
of data bytes to request in a Remote Frame. TWAI Data Frames are limited to a maximum payload of 8 data
bytes, thus the DLC should range anywhere from 0 to 8.
The Frame Identifier fields for an SFF (11-bits) message is shown in Table 21-10-21-11.
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.28 ID.27 ID.26 ID.25 ID.24 ID.23 ID.22 ID.21
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 2 2 2
Reserved ID.20 ID.19 ID.18 X X X X X2
The Frame Identifier fields for an EFF (29-bits) message is shown in Table 21-12-21-15.
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.28 ID.27 ID.26 ID.25 ID.24 ID.23 ID.22 ID.21
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.20 ID.19 ID.18 ID.17 ID.16 ID.15 ID.14 ID.13
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.12 ID.11 ID.10 ID.9 ID.8 ID.7 ID.6 ID.5
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 2
Reserved ID.4 ID.3 ID.2 ID.1 ID.0 X X X2
For example, when transmitting a Data Frame with 5 data bytes, the CPU should write a value of 5 to the DLC
field, and then fill in data bytes 1 to 5 in the Frame Data fields. Likewise, when receiving a Data Frame with a DLC
of 5, only data bytes 1 to 5 will contain valid payload data for the CPU to read.
When the TWAI controller receives a message, but the Receive FIFO lacks the adequate free space to store
the received message in its entirety (either due to the message contents being larger than the free space
in the Receive FIFO, or the Receive FIFO being completely full), the Receive FIFO will internally mark overrun
messages as invalid. Subsequent overrun messages will still increment the TWAI_RX_MESSAGE_COUNTER up
to a maximum of 64.
To clear an overrun Receive FIFO, the TWAI_RELEASE_BUF must be called repeatedly called until TWAI_RX_
MESSAGE_COUNTER is 0. This has the effect of freeing all valid messages in the Receive FIFO and clearing all
overrun messages.
The Acceptance Filter configuration registers can only be accessed whilst the TWAI controller is in Reset
Mode, due to those registers sharing the same address space as the Transmit Buffer and Receive Buffer regis-
ters.
The registers consist of a 32-bit Acceptance Code Value and a 32-bit Acceptance Mask Value. The Code value
specifies a bit pattern in which each filtered bit of the message must match in order for the message to be
accepted. The Mask value is able to mask out certain bits of the Code value (i.e., set as “Don’t Care” bits).
Each filtered bit of the message must either match the acceptance code or be masked in order for the message
to be accepted, as demonstrated in Figure 21-7.
The TWAI Controller Acceptance Filter allows the 32-bit Code and Mask values to either define a single filter
(i.e., Single Filter Mode), or two filters (i.e., Dual Filter Mode). How the Acceptance Filter interprets the 32-bit
code and mask values is dependent on whether Single Filter Mode is enabled, and the received message (i.e.,
SFF or EFF).
• SFF
– RTR bit
• EFF
– RTR bit
The following Figure 21-8 illustrates how the 32-bit code and mask values will be interpreted under Single Filter
Mode.
The two filters can filter the following bits of a Data or Remote Frame:
• SFF
– RTR bit
• EFF
The following Figure 21-9 illustrates how the 32-bit code and mask values will be interpreted under Dual Filter
Mode.
The current error state of the TWAI controller is indicated via a combination of the following values and status
bits: TEC, REC, TWAI_ERR_ST, and TWAI_BUS_OFF_ST. Certain changes to these values and bits will also trigger
interrupts, thus allowing the users to be notified of error state transitions (see section 21.5.3). The following
figure 21-10 shows the relation between the error states, values and bits, and error state related interrupts.
• Set REC to 0
The Error Warning Interrupt is triggered whenever the value of the TWAI_BUS_OFF_ST bit (or the TWAI_ERR_ST
bit) changes.
To return to the Error Active state, the TWAI controller must undergo Bus-Off recovery. Bus-Off recovery requires
the TWAI controller to observe 128 occurrences of 11 consecutive Recessive bits on the bus. To initiate Bus-
Off recovery (after entering the Bus-Off state), the TWAI controller should enter Operation Mode by setting the
TWAI_RESET_MODE bit to 0. The TEC tracks the progress of Bus-Off recovery by decrementing the TEC each
time the TWAI controller observes 11 consecutive Recessive bits. When Bus-Off recovery has completed (i.e.,
TEC has decremented from 127 to 0), the TWAI_BUS_OFF_ST bit will automatically be reset to 0, thus triggering
the Error Warning Interrupt.
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 1 2 3 3 3 3
Reserved ERRC.1 ERRC.0 DIR SEG.4 SEG.3 SEG.2 SEG.1 SEG.03
Notes:
• ERRC: The Error Code (ERRC) indicates the type of bus error: 00 for bit error, 01 for form error, 10 for stuff
error, 11 for other type of error.
• DIR: The Direction (DIR) indicates whether the TWAI controller was transmitting or receiving when the bus
error: 0 for Transmitter, 1 for Receiver.
• SEG: The Error Segment (SEG) indicates which segment of the TWAI message (i.e., bit position) the bus
error occurred at.
The following Table 21-17 shows how to interpret the SEG.0 to SEG.4 bits.
Bit SEG.4 Bit SEG.3 Bit SEG.2 Bit SEG.1 Bit SEG.0 Description
0 0 0 1 1 start of frame
0 0 0 1 0 ID.28 to ID.21
0 0 1 1 0 ID.20 to ID.18
0 0 1 0 0 bit SRTR1
0 0 1 0 1 bit IDE2
0 0 1 1 1 ID.17 to ID.13
0 1 1 1 1 ID.12 to ID.5
0 1 1 1 0 ID.4 to ID.0
0 1 1 0 0 bit RTR
Bit SEG.4 Bit SEG.3 Bit SEG.2 Bit SEG.1 Bit SEG.0 Description
0 1 1 0 1 reserved bit 1
0 1 0 0 1 reserved bit 0
0 1 0 1 1 data length code
0 1 0 1 0 data field
0 1 0 0 0 CRC sequence
1 1 0 0 0 CRC delimeter
1 1 0 0 1 acknowledge slot
1 1 0 1 1 acknowledge delimeter
1 1 0 1 0 end of frame
1 0 0 1 0 intermission
1 0 0 0 1 active error flag
1 0 1 1 0 passive error flag
1 0 0 1 1 tolerate dominant bits
1 0 1 1 1 error delimeter
1 1 1 0 0 overload flag
Notes:
Subsequent loses in arbitration will trigger the Arbitration Lost Interrupt, but will not be recorded in the TWAI_ARB
LOST CAP_REG until the current Arbitration Lost Capture is read from the TWAI_ERR_CODE_CAP_REG.
Table 21-18 illustrates the bit fields of the TWAI_ERR_CODE_CAP_REG whilst Figure 21-11 illustrates the bit posi-
tions of a TWAI message.
Table 21-18. Bit Information of TWAI_ARB LOST CAP_REG; TWAI Address 0x2c
Notes:
• BITNO: Bit Number (BITNO) indicates the nth bit of a TWAI message where arbitration was lost.
21.7 Registers
The addresses in parenthesis besides register names are the register addresses relative to the TWAI base ad-
dress provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute register
addresses are listed in Section 21.6 Register Summary.
E DE
ES _O MO E
_M LY_ E
OD MO
_R EN T_ D
ET N D
AI IST ES MO
TW I_L F_T R_
A EL TE
TW _S FIL
)
AI X_
ed
TW I_R
rv
se
A
TW
(re
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
TWAI_RESET_MODE This bit is used to configure the operating mode of the TWAI Controller. 1:
Reset mode; 0: Operating mode (R/W)
TWAI_LISTEN_ONLY_MODE 1: Listen only mode. In this mode the nodes will only receive messages
from the bus, without generating the acknowledge signal nor updating the RX error counter.
(R/W)
TWAI_SELF_TEST_MODE 1: Self test mode. In this mode the TX nodes can perform a successful
transmission without receiving the acknowledge signal. This mode is often used to test a single
node with the self reception request command. (R/W)
TWAI_RX_FILTER_MODE This bit is used to configure the filter mode. 0: Dual filter mode; 1: Single
filter mode (R/W)
SC
UM
RE
P
J
D_
C_
)
AU
YN
ed
_B
_S
rv
se
AI
AI
TW
TW
(re
31 8 7 6 5 0
TWAI_BAUD_PRESC Baud Rate Prescaler, determines the frequency dividing ratio. (RO | R/W)
G2
G1
M
SA
SE
SE
E_
E_
E_
)
IM
IM
IM
ed
_T
_T
_T
rv
se
AI
AI
AI
TW
TW
TW
(re
31 8 7 6 4 3 0
TWAI_TIME_SAMP The number of sample points. 0: the bus is sampled once; 1: the bus is sampled
three times (RO | R/W)
IT
IM
_L
NG
NI
AR
_W
)
RR
ed
_E
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x60 Reset
TWAI_ERR_WARNING_LIMIT Error warning threshold. In the case when any of a error counter value
exceeds the threshold, or all the error counter values are below the threshold, an error warning
interrupt will be triggered (given the enable signal is valid). (RO | R/W)
_0
DE
O
_C
CE
AN
E PT
CC
_A
AI
W
|T
0
TE_
BY
d)
X_
ve
_T
r
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_0 Stored the 0th byte information of the data to be transmitted under operating
mode. (WO)
TWAI_ACCEPTANCE_CODE_0 Stored the 0th byte of the filter code under reset mode. (R/W)
_1
DE
O
_C
CE
N
TA
EP
CC
_A
AI
TW
1|
E_
T
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_1 Stored the 1st byte information of the data to be transmitted under operating
mode. (WO)
TWAI_ACCEPTANCE_CODE_1 Stored the 1st byte of the filter code under reset mode. (R/W)
_2
ODE
_C
CE
AN
PT
E
CC
_A
AI
W
|T
2
TE_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_2 Stored the 2nd byte information of the data to be transmitted under operating
mode. (WO)
TWAI_ACCEPTANCE_CODE_2 Stored the 2nd byte of the filter code under reset mode. (R/W)
_3
DE
O
_C
CE
N
TA
EP
CC
_A
AI
W
|T
3
E_
T
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_3 Stored the 3rd byte information of the data to be transmitted under operating
mode. (WO)
TWAI_ACCEPTANCE_CODE_3 Stored the 3rd byte of the filter code under reset mode. (R/W)
_0
K
AS
E_M
NC
TA
EP
CC
_A
AI
W
|T
4
T E_
BY
d)
X_
ve
_T
r
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_4 Stored the 4th byte information of the data to be transmitted under operating
mode. (WO)
TWAI_ACCEPTANCE_MASK_0 Stored the 0th byte of the filter code under reset mode. (R/W)
_1
K
AS
_M
CE
N
TA
EP
CC
_A
AI
W
|T
5
T E_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_5 Stored the 5th byte information of the data to be transmitted under operating
mode. (WO)
TWAI_ACCEPTANCE_MASK_1 Stored the 1st byte of the filter code under reset mode. (R/W)
2
K_
AS
E _M
NC
TA
EP
CC
_A
AI
W
|T
6
T E_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_6 Stored the 6th byte information of the data to be transmitted under operating
mode. (WO)
TWAI_ACCEPTANCE_MASK_2 Stored the 2nd byte of the filter code under reset mode. (R/W)
_3
K
AS
_M
CE
N
TA
EP
CC
_A
AI
W
|T
7
T E_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_7 Stored the 7th byte information of the data to be transmitted under operating
mode. (WO)
TWAI_ACCEPTANCE_MASK_3 Stored the 3rd byte of the filter code under reset mode. (R/W)
8
T E_
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_8 Stored the 8th byte information of the data to be transmitted under operating
mode. (WO)
9
E_
T
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_9 Stored the 9th byte information of the data to be transmitted under operating
mode. (WO)
10
TE_
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_10 Stored the 10th byte information of the data to be transmitted under operating
mode. (WO)
11
T E_
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_11 Stored the 11th byte information of the data to be transmitted under operating
mode. (WO)
12
E_
YT
_B
)
ed
X
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_12 Stored the 12th byte information of the data to be transmitted under operating
mode. (WO)
F
E
OF
OD
K_
_M
C
)
LO
XT
ed
ed
D
_C
_C
_E
rv
rv
se
se
AI
AI
AI
TW
TW
TW
(re
(re
31 8 7 6 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0x0 Reset
TWAI_CD These bits are used to configure frequency dividing coefficients of the external CLKOUT
pin. (R/W)
TWAI_CLOCK_OFF This bit can be configured under reset mode. 1: Disable the external CLKOUT
pin; 0: Enable the external CLKOUT pin (RO | R/W)
TWAI_EXT_MODE This bit can be configured under reset mode. 1: Extended mode, compatiable
with CAN2.0B; 0: Basic mode (RO | R/W)
AI BO SE_ UN
X_ _T UF
A EL VE Q
TW I_R _O _RE
TW I_A EA RR
_T RT B
RE X
A LR X
Q
TW I_C F_R
d)
A EL
ve
TW I_S
r
se
A
TW
(re
31 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TWAI_TX_REQ Set the bit to 1 to allow the driving nodes start transmission. (WO)
TWAI_CLR_OVERRUN Set the bit to 1 to clear the data overrun status bit. (WO)
TWAI_SELF_RX_REQ Self reception request command. Set the bit to 1 to allow a message be
transmitted and received simultaneously. (WO)
AI VE F_S TE
F_ T
A X_ T T
BU _S
TW I_O BU LE
TW I_T _S _S
ST
_R RR T
A X_ MP
X_ UN
A RR FF
TW I_E _O
TW I_T CO
TW I_T ST
TW I_R ST
A US
)
A X_
A X_
ed
TW I_B
rv
se
A
TW
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 Reset
TWAI_RX_BUF_ST 1: The data in the RX buffer is not empty, with at least one received data packet.
(RO)
TWAI_OVERRUN_ST 1: The RX FIFO is full and data overrun has occurred. (RO)
TWAI_TX_BUF_ST 1: The TX buffer is empty, the CPU may write a message into it. (RO)
TWAI_TX_COMPLETE 1: The TWAI controller has successfully received a packet from the bus. (RO)
TWAI_RX_ST 1: The TWAI Controller is receiving a message from the bus. (RO)
TWAI_ERR_ST 1: At least one of the RX/TX error counter has reached or exceeded the value set in
register TWAI_ERR_WARNING_LIMIT_REG. (RO)
TWAI_BUS_OFF_ST 1: In bus-off status, the TWAI Controller is no longer involved in bus activities.
(RO)
P
CA
T_
OS
_L
RB
d)
ve
_A
r
se
AI
TW
(re
31 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_ARB_LOST_CAP This register contains information about the bit position of lost arbitration.
(RO)
ON
T
EN
TI
EC
M
E
EG
YP
IR
_D
_S
_T
TW CC
CC
CC
)
ed
_E
_E
_E
rv
se
AI
AI
AI
TW
TW
(re
31 8 7 6 5 4 0
TWAI_ECC_SEGMENT This register contains information about the location of errors, see Table 21-
16 for details. (RO)
TWAI_ECC_DIRECTION This register contains information about transmission direction of the node
when error occurs. 1: Error occurs when receiving a message; 0: Error occurs when transmitting
a message (RO)
TWAI_ECC_TYPE This register contains information about error types: 00: bit error; 01: form error;
10: stuff error; 11: other type of error (RO)
X_
ed
_R
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_RX_ERR_CNT The RX error counter register, reflects value changes under reception status.
(RO | R/W)
T
CN
R_
ER
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_ERR_CNT The TX error counter register, reflects value changes under transmission status.
(RO | R/W)
R
NTE
OU
_C
GE
SA
ES
M
)
X_
ed
_R
rv
se
AI
TW
(re
31 7 6 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_RX_MESSAGE_COUNTER This register reflects the number of messages available within the
RX FIFO. (RO)
ST
T_
ST
IV ST
_R NT N_ ST
TW rve _P T_I ST
IN
IN T T_
A d ASS NT_
AI _I AR T_
se RR OS T_
E_
X_ _S IN
TW _T _W _IN
(re I_E _L _IN
ST
AI R N
A RB RR
T_
U
TW I_A _E
TW I_E RR
A US
)
TW I_O )
A VE
ed
R
X
TW I_B
rv
se
A
TW
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TWAI_RX_INT_ST Receive interrupt. If this bit is set to 1, it indicates there are messages to be
handled in the RX FIFO. (RO)
TWAI_TX_INT_ST Transmit interrupt. If this bit is set to 1, it indicates the message transmitting mis-
sion is finished and a new transmission is able to execute. (RO)
TWAI_ERR_WARN_INT_ST Error warning interrupt. If this bit is set to 1, it indicates the error status
signal and the bus-off status signal of Status register have changed (e.g., switched from 0 to 1
or from 1 to 0). (RO)
TWAI_OVERRUN_INT_ST Data overrun interrupt. If this bit is set to 1, it indicates the data in the RX
FIFO is invalid. (RO)
TWAI_ERR_PASSIVE_INT_ST Error passive interrupt. If this bit is set to 1, it indicates the TWAI Con-
troller is switched between error active status and error passive status due to the change of
error counters. (RO)
TWAI_ARB_LOST_INT_ST Arbitration lost interrupt. If this bit is set to 1, it indicates an arbitration lost
interrupt is generated. (RO)
TWAI_BUS_ERR_INT_ST Error interrupt. If this bit is set to 1, it indicates an error is detected on the
bus. (RO)
A
EN
A
E_ A
EN
X_ _E IN A
A d ASS NT_ A
T_
IV EN
N
TW rve _P T_I EN
IN
IN NA T_
_R NT N_ E
AI _I AR T_
se RR OS T_
TW _T _W _IN
(re I_E _L _IN
A
EN
AI R N
A RB RR
T_
U
TW I_A _E
TW I_E RR
A US
d)
TW I_O )
A VE
R
X
ve
TW I_B
r
se
A
TW
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
22.1 Introduction
The AES Accelerator speeds up AES operations significantly, compared to AES algorithms implemented solely
in software. The AES Accelerator supports six algorithms of FIPS PUB 197, specifically AES-128, AES-192 and
AES-256 encryption and decryption.
22.2 Features
• Supports AES-128 encryption and decryption
• Supports four variations of key endianness and four variations of text endianness
AES_MODE_REG[2:0] Operation
0 AES-128 Encryption
1 AES-192 Encryption
2 AES-256 Encryption
4 AES-128 Decryption
5 AES-192 Decryption
6 AES-256 Decryption
Plaintext and ciphertext is stored in the AES_TEXT_m_REG registers. There are four 32-bit registers. To enable
AES-128/192/256 encryption, initialize the AES_TEXT_m_REG registers with plaintext before encryption. When
encryption is finished, the AES Accelerator will store back the resulting ciphertext in the AES_TEXT_m_REG
registers. To enable AES-128/192/256 decryption, initialize the AES_TEXT_m_REG registers with ciphertext be-
fore decryption. When decryption is finished, the AES Accelerator will store back the resulting plaintext in the
AES_TEXT_m_REG registers.
22.3.3 Endianness
Key Endianness
Bit 0 and bit 1 in AES_ENDIAN_REG define the key endianness. For detailed information, please see Table 22-3,
Table 22-4 and Table 22-5. w[0] ~ w[3] in Table 22-3, w[0] ~ w[5] in Table 22-4 and w[0] ~ w[7] in Table 22-5
are “the first Nk words of the expanded key” as specified in “5.2: Key Expansion” of FIPS PUB 197. “Column Bit”
specifies the bytes in the word from w[0] to w[7]. The bytes of AES_KEY_n_REG comprise “the first Nk words
of the expanded key”.
Text Endianness
Bit 2 and bit 3 in AES_ENDIAN_REG define the endianness of input text, while Bit 4 and Bit 5 define the endian-
ness of output text. The input text refers to the plaintext in AES-128/192/256 encryption and the ciphertext in
decryption. The output text refers to the ciphertext in AES-128/192/256 encryption and the plaintext in decryp-
tion. For details, please see Table 22-2. “State” in Table 22-2 is defined as that in “3.4: The State” of FIPS PUB
197: “The AES algorithm operations are performed on a two-dimensional array of bytes called the State”. The
ciphertext or plaintexts stored in each byte of AES_TEXT_m_REG comprise the State.
Table 22-2. AES Text Endianness
AES_ENDIAN_REG[1] AES_ENDIAN_REG[0] Bit w[0] w[1] w[2] w[3] w[4] w[5] w[6] w[7]
[31:24] AES_KEY_7_REG[31:24] AES_KEY_6_REG[31:24] AES_KEY_5_REG[31:24] AES_KEY_4_REG[31:24] AES_KEY_3_REG[31:24] AES_KEY_2_REG[31:24] AES_KEY_1_REG[31:24] AES_KEY_0_REG[31:24]
[23:16] AES_KEY_7_REG[23:16] AES_KEY_6_REG[23:16] AES_KEY_5_REG[23:16] AES_KEY_4_REG[23:16] AES_KEY_3_REG[23:16] AES_KEY_2_REG[23:16] AES_KEY_1_REG[23:16] AES_KEY_0_REG[23:16]
0 0
[15:8] AES_KEY_7_REG[15:8] AES_KEY_6_REG[15:8] AES_KEY_5_REG[15:8] AES_KEY_4_REG[15:8] AES_KEY_3_REG[15:8] AES_KEY_2_REG[15:8] AES_KEY_1_REG[15:8] AES_KEY_0_REG[15:8]
[7:0] AES_KEY_7_REG[7:0] AES_KEY_6_REG[7:0] AES_KEY_5_REG[7:0] AES_KEY_4_REG[7:0] AES_KEY_3_REG[7:0] AES_KEY_2_REG[7:0] AES_KEY_1_REG[7:0] AES_KEY_0_REG[7:0]
[31:24] AES_KEY_7_REG[7:0] AES_KEY_6_REG[7:0] AES_KEY_5_REG[7:0] AES_KEY_4_REG[7:0] AES_KEY_3_REG[7:0] AES_KEY_2_REG[7:0] AES_KEY_1_REG[7:0] AES_KEY_0_REG[7:0]
[23:16] AES_KEY_7_REG[15:8] AES_KEY_6_REG[15:8] AES_KEY_5_REG[15:8] AES_KEY_4_REG[15:8] AES_KEY_3_REG[15:8] AES_KEY_2_REG[15:8] AES_KEY_1_REG[15:8] AES_KEY_0_REG[15:8]
0 1
[15:8] AES_KEY_7_REG[23:16] AES_KEY_6_REG[23:16] AES_KEY_5_REG[23:16] AES_KEY_4_REG[23:16] AES_KEY_3_REG[23:16] AES_KEY_2_REG[23:16] AES_KEY_1_REG[23:16] AES_KEY_0_REG[23:16]
[7:0] AES_KEY_7_REG[31:24] AES_KEY_6_REG[31:24] AES_KEY_5_REG[31:24] AES_KEY_4_REG[31:24] AES_KEY_3_REG[31:24] AES_KEY_2_REG[31:24] AES_KEY_1_REG[31:24] AES_KEY_0_REG[31:24]
[31:24] AES_KEY_0_REG[31:24] AES_KEY_1_REG[31:24] AES_KEY_2_REG[31:24] AES_KEY_3_REG[31:24] AES_KEY_4_REG[31:24] AES_KEY_5_REG[31:24] AES_KEY_6_REG[31:24] AES_KEY_7_REG[31:24]
[23:16] AES_KEY_0_REG[23:16] AES_KEY_1_REG[23:16] AES_KEY_2_REG[23:16] AES_KEY_3_REG[23:16] AES_KEY_4_REG[23:16] AES_KEY_5_REG[23:16] AES_KEY_6_REG[23:16] AES_KEY_7_REG[23:16]
1 0
[15:8] AES_KEY_0_REG[15:8] AES_KEY_1_REG[15:8] AES_KEY_2_REG[15:8] AES_KEY_3_REG[15:8] AES_KEY_4_REG[15:8] AES_KEY_5_REG[15:8] AES_KEY_6_REG[15:8] AES_KEY_7_REG[15:8]
[7:0] AES_KEY_0_REG[7:0] AES_KEY_1_REG[7:0] AES_KEY_2_REG[7:0] AES_KEY_3_REG[7:0] AES_KEY_4_REG[7:0] AES_KEY_5_REG[7:0] AES_KEY_6_REG[7:0] AES_KEY_7_REG[7:0]
[31:24] AES_KEY_0_REG[7:0] AES_KEY_1_REG[7:0] AES_KEY_2_REG[7:0] AES_KEY_3_REG[7:0] AES_KEY_4_REG[7:0] AES_KEY_5_REG[7:0] AES_KEY_6_REG[7:0] AES_KEY_7_REG[7:0]
[23:16] AES_KEY_0_REG[15:8] AES_KEY_1_REG[15:8] AES_KEY_2_REG[15:8] AES_KEY_3_REG[15:8] AES_KEY_4_REG[15:8] AES_KEY_5_REG[15:8] AES_KEY_6_REG[15:8] AES_KEY_7_REG[15:8]
1 1
[15:8] AES_KEY_0_REG[23:16] AES_KEY_1_REG[23:16] AES_KEY_2_REG[23:16] AES_KEY_3_REG[23:16] AES_KEY_4_REG[23:16] AES_KEY_5_REG[23:16] AES_KEY_6_REG[23:16] AES_KEY_7_REG[23:16]
[7:0] AES_KEY_0_REG[31:24] AES_KEY_1_REG[31:24] AES_KEY_2_REG[31:24] AES_KEY_3_REG[31:24] AES_KEY_4_REG[31:24] AES_KEY_5_REG[31:24] AES_KEY_6_REG[31:24] AES_KEY_7_REG[31:24]
22 AES Accelerator (AES)
2. Write 1 to AES_START_REG.
Consecutive Operations
Every time an operation is completed, only AES_TEXT_m_REG is modified by the AES Accelerator. Initialization
can, therefore, be simplified in a series of consecutive operations.
2. Load AES_TEXT_m_REG.
3. Write 1 to AES_START_REG.
22.3.5 Speed
The AES Accelerator requires 11 to 15 clock cycles to encrypt a message block, and 21 or 22 clock cycles to
decrypt a message block.
22.5 Registers
The addresses in parenthesis besides register names are the register addresses relative to the AES base address
provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute register
addresses are listed in Section 22.4 Register Summary.
RT
d)
A
ve
ST
r
se
S_
(re
AE
31 1 0
0x00000000 x Reset
E
ed
DL
rv
I
se
S_
(re
AE
31 1 0
0x00000000 1 Reset
AES_IDLE AES Idle register. Reads ’zero’ while the AES Accelerator is busy processing; reads ’one’
otherwise. (RO)
OD
ed
M
rv
se
S_
(re
AE
31 3 2 0
0x00000000 0 Reset
AES_MODE Selects the AES accelerator mode of operation. See Table 22-1 for details. (R/W)
31 0
0x000000000 Reset
31 0
0x000000000 Reset
N
IA
d)
D
ve
EN
r
se
S_
(re
AE
31 6 5 0
0x0000000 1 1 1 1 1 1 Reset
AES_ENDIAN Endianness selection register. See Table 22-2 for details. (R/W)
23.1 Introduction
The SHA Accelerator is included to speed up SHA hashing operations significantly, compared to SHA hashing
algorithms implemented solely in software. The SHA Accelerator supports four algorithms of FIPS PUB 180-4,
specifically SHA-1, SHA-256, SHA-384 and SHA-512.
23.2 Features
Hardware support for popular secure hashing algorithms:
• SHA-1
• SHA-256
• SHA-384
• SHA-512
The SHA Accelerator is unable to perform the padding operation of “5.1 Padding the Message” in FIPS PUB
180-4; Note that the user software is expected to pad the message before feeding it into the accelerator.
(i) (i)
As described in “2.2.1: Parameters” in FIPS PUB 180-4, “M0 is the leftmost word of message block i”. M0
is stored in SHA_TEXT_0_REG. In the same fashion, the SHA_TEXT_1_REG register stores the second left-most
(N )
word of a message block M1 , etc.
As described in “2.2.1 Parameters” in FIPS PUB 180-4, “H (N ) is the final hash value, and is used to determine the
(i) (N )
message digest”, while “H0 is the leftmost word of hash value i”, so the leftmost word H0 in the message
(N )
digest is stored in SHA_TEXT_0_REG. In the same fashion, the second leftmost word H1 in the message
digest is stored in SHA_TEXT_1_REG, etc.
(c) Wait for SHA_X_BUSY_REG to read 0, indicating that the operation is completed.
(c) Wait for SHA_X_BUSY_REG to read 0, indicating that the operation is completed.
23.3.4 Speed
The SHA Accelerator requires 60 to 100 clock cycles to process a message block and 8 to 20 clock cycles to
calculate the final digest.
23.5 Registers
The addresses in parenthesis besides register names are the register addresses relative to the SHA base address
provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute register
addresses are listed in Section 23.4 Register Summary.
31 0
0x000000000 Reset
SHA_TEXT_n_REG (n: 0-31) SHA Message block and hash result register. (R/W)
RT
TA
_S
)
A1
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA1_START Write 1 to start an SHA-1 operation on the first message block. (WO)
UE
IN
O NT
_C
)
A1
ed
H
rv
_S
se
A
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA1_CONTINUE Write 1 to continue the SHA-1 operation with subsequent blocks. (WO)
A
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA1_LOAD Write 1 to finish the SHA-1 operation to calculate the final message hash. (WO)
Y
US
_B
d)
A1
ve
SH
r
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA1_BUSY SHA-1 operation status: 1 if the SHA accelerator is processing data, 0 if it is idle.
(RO)
RT
TA
_S
56
A2
)
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA256_START Write 1 to start an SHA-256 operation on the first message block. (WO)
UE
IN
NT
O
_C
56
A2
)
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA256_CONTINUE Write 1 to continue the SHA-256 operation with subsequent blocks. (WO)
D
OA
_L
56
A2
d)
ve
SH
r
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA256_LOAD Write 1 to finish the SHA-256 operation to calculate the final message hash.
(WO)
SY
_ BU
56
A2
)
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
ART
ST
84_
A3
)
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA384_START Write 1 to start an SHA-384 operation on the first message block. (WO)
UE
IN
NT
CO
84_
A3
d)
ve
SH
r
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA384_CONTINUE Write 1 to continue the SHA-384 operation with subsequent blocks. (WO)
AD
LO
84_
A3
)
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA384_LOAD Write 1 to finish the SHA-384 operation to calculate the final message hash.
(WO)
SY
BU
84_
A3
)
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
RT
TA
_S
12
A5
d)
ve
SH
r
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA512_START Write 1 to start an SHA-512 operation on the first message block. (WO)
UE
N
TI
ON
_C
12
A5
)
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA512_CONTINUE Write 1 to continue the SHA-512 operation with subsequent blocks. (WO)
D
OA
_L
12
A5
)
ed
SH
rv
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
SHA_SHA512_LOAD Write 1 to finish the SHA-512 operation to calculate the final message hash.
(WO)
Y
US
_B
12
A5
d)
ve
SH
r
A_
se
(re
SH
31 1 0
0x00000000 0 Reset
24.1 Introduction
The RSA Accelerator provides hardware support for multiple precision arithmetic operations used in RSA asym-
metric cipher algorithms.
Sometimes, multiple precision arithmetic is also called ”bignum arithmetic”, ”bigint arithmetic” or ”arbitrary pre-
cision arithmetic”.
24.2 Features
• Support for large-number modular exponentiation
When the RSA Accelerator is released from reset, the register RSA_CLEAN_REG reads 0 and an initialization
process begins. Hardware initializes the four memory blocks by setting them to 0. After initialization is complete,
RSA_CLEAN_REG reads 1. For this reason, software should query RSA_CLEAN_REG after being released from
reset, and before writing to any RSA Accelerator memory blocks or registers for the first time.
The RSA Accelerator supports operand lengths of N ∈ {512, 1024, 1536, 2048, 2560, 3072, 3584, 4096} bits. The
bit length of arguments Z, X, Y , M , and r can be any one from the N set, but all numbers in a calculation must
be of the same length. The bit length of M ′ is always 32.
To represent the numbers used as operands, define a base-b positional notation, as follows:
b = 232
In this notation, each number is represented by a sequence of base-b digits, where each base-b digit is a 32-bit
word. Representing an N -bit number requires n base-b digits (all of the possible N lengths are multiples of
32).
N
n=
32
Z = (Zn−1 Zn−2 · · · Z0 )b
X = (Xn−1 Xn−2 · · · X0 )b
Y = (Yn−1 Yn−2 · · · Y0 )b
M = (Mn−1 Mn−2 · · · M0 )b
r = (rn−1 rn−2 · · · r0 )b
Each of the n values in Zn−1 ~ Z0 , Xn−1 ~ X0 , Yn−1 ~ Y0 , Mn−1 ~ M0 , rn−1 ~ r0 represents one base-b digit
(a 32-bit word).
Zn−1 , Xn−1 , Yn−1 , Mn−1 and rn−1 are the most significant bits of Z, X, Y , M , while Z0 , X0 , Y0 , M0 and r0 are
the least significant bits.
If we define
R = bn
r = R2 mod M (1)
M ′′ × M + 1 = R × R−1
(2)
M ′ = M ′′ mod b
(Equation 2 is written in a form suitable for calculations using the extended binary GCD algorithm.)
Users need to write data to each memory block only according to the length of the number; data beyond
this length are ignored.
3. Write M ′ to RSA_M_PRIME_REG.
4. Write 1 to RSA_MODEXP_START_REG.
5. Wait for the operation to be completed. Poll RSA_INTERRUPT_REG until it reads 1, or until the RSA_INTR
interrupt is generated.
After the operation, the RSA_MODEXP_MODE_REG register, memory blocks RSA_Y_MEM and RSA_M_MEM, as
well as the RSA_M_PRIME_REG will not have changed. However, Xi in RSA_X_MEM and ri in RSA_Z_MEM
will have been overwritten. In order to perform another operation, refresh the registers and memory blocks, as
required.
The RSA Accelerator supports large-number modular multiplication with eight different operand lengths, which
are the same as in the large-number modular exponentiation. The operation is performed by a combination of
software and hardware. The software performs two hardware operations in sequence.
2. Write Xi , Mi and ri (i ∈ [0, n) ∩ N) to registers RSA_X_MEM, RSA_M_MEM and RSA_Z_MEM. Write data
to each memory block only according to the length of the number. Data beyond this length are ignored.
3. Write M ′ to RSA_M_PRIME_REG.
4. Write 1 to RSA_MULT_START_REG.
5. Wait for the first round of the operation to be completed. Poll RSA_INTERRUPT_REG until it reads 1, or until
the RSA_INTR interrupt is generated.
Users need to write to the memory block only according to the length of the number. Data beyond this
length are ignored.
8. Write 1 to RSA_MULT_START_REG.
9. Wait for the second round of the operation to be completed. Poll RSA_INTERRUPT_REG until it reads 1, or
until the RSA_INTR interrupt is generated.
After the operation, the RSA_MULT_MODE_REG register, and memory blocks RSA_M_MEM and RSA_M_PRIME_REG
remain unchanged. Users do not need to refresh these registers or memory blocks if the values remain the
same.
Operands X and Y need to be extended to form arguments X̂ and Ŷ which have the same length (N̂ bits) as
N
n=
32
N̂ = 2 × N
N̂
n̂ = = 2n
32
X̂ = (X̂n̂−1 X̂n̂−2 · · · X̂0 )b = (00 · · · 0} X)b = (00
| {z · · · 0} Xn−1 Xn−2 · · · X0 )b
| {z
n n
2. Write X̂i and Ŷi (i ∈ [0, n̂) ∩ N) to RSA_X_MEM and RSA_Z_MEM, respectively.
Write the valid data into each number’s memory block, according to their lengths. Values beyond this
length are ignored. Half of the base-b positional notations written to the memory are zero (using the
derivations shown above). These zero values are indispensable.
3. Write 1 to RSA_MULT_START_REG.
4. Wait for the operation to be completed. Poll RSA_INTERRUPT_REG until it reads 1, or until the RSA_INTR
interrupt is generated.
24.5 Registers
The addresses in parenthesis besides register names are the register addresses relative to the RSA base address
provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute register
addresses are listed in Section 24.4 Register Summary.
31 0
0x000000000 Reset
E
OD
M
P_
EX
)
OD
ed
M
rv
A_
se
(re
RS
31 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
AR
ST
P_
EX
d)
OD
ve
M
r
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
OD
M
T_
)
UL
ed
M
rv
A_
se
(re
RS
31 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RSA_MULT_MODE This register contains the mode of modular multiplication and multiplication.
(R/W)
T
AR
ST
T_
)
UL
ed
M
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
UP
RR
)
TE
ed
IN
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RSA_INTERRUPT RSA interrupt status register. Will read 1 once an operation has completed. (R/W)
E
CL
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RSA_CLEAN This bit will read 1 once the memory initialization is completed. (RO)
25.1 Introduction
The ESP32 contains a true random number generator, which generates 32-bit random numbers that can be
used for cryptographical operations, among other things.
25.2 Feature
The random number generator generates true random numbers, which means random number generated from
a physical process, rather than by means of an algorithm. No number generated within the specified range is
more or less likely to appear than any other number.
Thermal noise comes from the high-speed ADC or SAR ADC or both. Whenever the high-speed ADC or SAR
ADC is enabled, bit streams will be generated and fed into the random number generator through an XOR logic
gate as random seeds.
Random bit
SAR ADC
seeds XOR
XOR
Random RNG_DATA_REG
Number
Generator
High Speed Random bit
ADC seeds
Random bit
RC_FAST_CLK
seeds
When there is noise coming from the SAR ADC, the random number generator is fed with a 2-bit entropy in one
clock cycle of RC_FAST_CLK (8 MHz), which is generated from an internal RC oscillator (see Chapter Reset and
Clock for details). Thus, it is advisable to read the RNG_DATA_REG register at a maximum rate of 500 kHz to
obtain the maximum entropy.
When there is noise coming from the high-speed ADC, the random number generator is fed with a 2-bit entropy
in one APB clock cycle, which is normally 80 MHz. Thus, it is advisable to read the RNG_DATA_REG register at
a maximum rate of 5 MHz to obtain the maximum entropy.
A data sample of 2 GB, which is read from the random number generator at a rate of 5 MHz with only the high-
speed ADC being enabled, has been tested using the Dieharder Random Number Testsuite (version 3.31.1). The
sample passed all tests.
• SAR ADC can be enabled by using the DIG ADC controller. For details, please refer to Chapter 29 On-Chip
Sensors and Analog Signal Processing.
• High-speed ADC is enabled automatically when the Wi-Fi or Bluetooth modules is enabled.
Note:
Note that, when the Wi-Fi module is enabled, the value read from the high-speed ADC can be saturated in some
extreme cases, which lowers the entropy. Thus, it is advisable to also enable the SAR ADC as the noise source for the
random number generator for such cases.
When using the random number generator, read the RNG_DATA_REG register multiple times until sufficient
random numbers have been generated. Ensure the rate at which the register is read does not exceed the
frequencies described in section 25.3 above.
25.6 Register
The addresses in parenthesis besides register names are the register addresses relative to the RNG base address
provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute register
addresses are listed in Section 25.5 Register Summary.
31 0
0x000000000 Reset
26.1 Overview
Many variants of the ESP32 must store programs and data in external flash memory. The external flash memory
chip is likely to contain proprietary firmware and sensitive user data, such as credentials for gaining access to
a private network. The Flash Encryption block can encrypt code and write encrypted code to off-chip flash
memory for enhanced hardware security. When the CPU reads off-chip flash through the cache, the Flash
Decryption block can automatically decrypt instructions and data read from the off-chip flash, thus providing
hardware-based security for application code.
26.2 Features
• Various key generation methods
• Software-based encryption
• Register configuration, system parameters and boot mode jointly determine the flash encryption/decryption
function.
The Flash Encryption/Decryption module consists of three parts, namely the Key Generator, Flash Encryption
block and Flash Decryption block. The structure of these parts is shown in Figure 26-1. The Key Generator
is shared by both the Flash Encryption block and the Flash Decryption block, which can function simultane-
ously.
In the peripheral DPort Register, the register relevant to Flash Encryption/Decryption is DPORT_SPI_ENCRYPT_ENABLE
bit and DPORT_SPI_DECRYPT_ENABLE bit in DPORT_SLAVE_SPI_CONFIG_REG. The Flash Encryption/Decryption
module will fetch six system parameters from the peripheral eFuse Controller. These parameters are: cod-
ing_scheme, BLOCK1, flash_crypt_config, download_dis_encrypt, flash_crypt_cnt, and download_dis_decrypt.
Then, according to system parameter flash_crypt_config, and off-chip flash physical addresses Addre and
Addrd accessed by the Flash Encryption block and the Flash Decryption block, the Key Generator will respec-
tively figure out that:
Keye = g(Keyo , f lash_crypt_conf ig, Addre ),
Keyd = g(Keyo , f lash_crypt_conf ig, Addrd ).
When all values of system parameter flash_crypt_config are 0, Keye and Keyd are not relevant to the physical
address of the off-chip flash. When all values of system parameter flash_crypt_config are not 0, every 8-word
block on the off-chip flash has a dedicated Keye and Keyd .
The Flash Encryption block requires software intervention during operation. The steps are as follows:
2. Write the physical address prepared for the off-chip flash on register FLASH_ENCRYPT_ADDRESS_REG.
The address must be 8-word boundary aligned.
3. The Flash Encryption block must encrypt 8-word long code segments. Write the lowest word to register
FLASH_ENCRYPT_BUFFER_0_REG, the second-lowest word into FLASH_ENCRYPT_BUFFER_1_REG, and
so on, up to FLASH_ENCRYPT_BUFFER_7_REG.
6. Use this function and write any 8-word code to the 8-word aligned address on the off-chip flash via the
peripheral SPI0.
In Steps 1 to 5, the Flash Encryption block encrypts 8-word long codes. The key encryption algorithm uses
Keye . The encryption result will also be 8-word long. In Step 6, the peripheral SPI0 writes encrypted results of
the Flash Encryption block to the off-chip flash. One parameter of the function used in Step 6 will be the physical
address of the off-chip flash. The physical address must be 8-word boundary aligned. Also, the value must
be the same as the value written into register FLASH_ENCRYPT_ADDRESS_REG during Step 2. Even though
the function used in Step 6 still has a parameter with an 8-word long code, the parameter will be meaningless
if Steps 1 to 5 are executed. The Peripheral SPI0 will use the encrypted result instead. If the Flash Encryption
block is not operating, or has not executed Steps 1 to 5, Step 6 will not use the encrypted result. Instead, the
function parameter will be used.
Even though software participates in the whole process, it cannot directly read the encrypted codes. Instead,
the encrypted codes are integrated into the off-chip flash. Even though the CPU can skip the cache and get
the encrypted code directly by reading the off-chip flash, the software can by no means access Keye .
When the Flash Decryption block is operating, the CPU will read instructions and data from the off-chip flash
via the cache. The Flash Decryption block automatically decrypts the instructions and data in the cache. The
entire decryption process does not need software intervention and is transparent to the cache. The decryption
algorithm can decrypt the code that has been encrypted by the Flash Encryption block. Software cannot access
the key algorithm Keyd used.
When the Flash Decryption block is not operating, it does not have any effect on the contents stored in the
off-chip flash, be they encrypted or unencrypted. What the CPU reads via the cache is the original information
stored in the off-chip flash.
In the efuse system parameter flash_crypt_cnt (7 bits wide), if the number of bits with value 1 is odd, the
Flash Decryption block is operational. Otherwise, it is not.
26.5 Register
The addresses in parenthesis besides register names are the register addresses relative to the FLASH base
address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The absolute
register addresses are listed in Section 26.4 Register Summary.
31 0
0x000000000 Reset
RT
TA
)
ed
_S
rv
H
se
AS
(re
FL
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
FLASH_START Set this bit to start encryption operation on data buffer. (WO)
31 0
0x000000000 Reset
E
ON
d)
_D
ve
H
r
se
AS
(re
FL
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
27.1 Introduction
Every peripheral and memory section in the ESP32 is accessed through either an MMU (Memory Management
Unit) or an MPU (Memory Protection Unit). An MPU can allow or disallow the access of an application to a mem-
ory range or peripheral, depending on what kind of permission the OS has given to that particular application.
An MMU can perform the same operation, as well as a virtual-to-physical memory address translation. This can
be used to map an internal or external memory range to a certain virtual memory area. These mappings can
be application-specific. Therefore, each application can be adjusted and have the memory configuration that
is necessary for it to run properly. To differentiate between the OS and applications, there are eight Process
Identifiers (or PIDs) that each application, or OS, can run. Furthermore, each application, or OS, is equipped
with their own sets of mappings and rights.
27.2 Features
• Eight processes in each of the PRO_CPU and APP_CPU
• MPU/MMU management of on-chip memories, off-chip memories, and peripherals, based on process ID
There are two peripheral PID controllers in the system, one for each of the two CPUs in the ESP32. Having a
PID controller per CPU allows running different processes on different CPUs, if so desired.
27.3.2 MPU/MMU
The MPU and MMU manage on-chip memories, off-chip memories, and peripherals. To do this they are based
on the process of accessing the peripheral or memory region. More specifically, when a code tries to access a
MMU/MPU-protected memory region or peripheral, the MMU or MPU will receive the PID from the PID generator
that is associated with the CPU on which the process is running.
For on-chip memory and peripherals, the decisions the MMU and MPU make are only based on this PID, whereas
the specific CPU the code is running on is not taken into account. Subsequently, the MMU/MPU configuration
for the internal memory and peripherals allows entries only for the eight different PIDs. In contrast, the MMU
moderating access to the external memory takes not only the PID into account, but also the CPU the request is
coming from. This means that MMUs have configuration options for every PID when running on the APP_CPU, as
well as every PID when running on the PRO_CPU. While, in practice, accesses from both CPUs will be configured
to have the same result for a specific process, doing so is not a hardware requirement.
The decision an MPU can make, based on this information, is to allow or deny a process to access the memory
region or peripheral. An MMU has the same function, but additionally it redirects the virtual memory access,
which the process acquired, into a physical memory access that can possibly reach out an entirely different
physical memory region. This way, MMU-governed memory can be remapped on a process-by-process ba-
sis.
Address range
Name Size Governed by
From To
ROM0 384 KB 0x4000_0000 0x4005_FFFF Static MPU
ROM1 64 KB 0x3FF9_0000 0x3FF9_FFFF Static MPU
64 KB 0x4007_0000 0x4007_FFFF Static MPU
SRAM0
128 KB 0x4008_0000 0x4009_FFFF SRAM0 MMU
128 KB 0x3FFE_0000 0x3FFF_FFFF Static MPU
SRAM1 (aliases) 128 KB 0x400A_0000 0x400B_FFFF Static MPU
32 KB 0x4000_0000 0x4000_7FFF Static MPU
72 KB 0x3FFA_E000 0x3FFB_FFFF Static MPU
SRAM2
128 KB 0x3FFC_0000 0x3FFD_FFFF SRAM2 MMU
8 KB 0x3FF8_0000 0x3FF8_1FFF RTC FAST MPU
RTC FAST (aliases)
8 KB 0x400C_0000 0x400C_1FFF RTC FAST MPU
RTC SLOW 8 KB 0x5000_0000 0x5000_1FFF RTC SLOW MPU
Static MPUs
ROM0, ROM1, the lower 64 KB of SRAM0, SRAM1 and the lower 72 KB of SRAM2 are governed by a static MPU.
The behaviour of these MPUs are hardwired and cannot be configured by software. They moderate access to
the memory region solely through the PID of the current process. When the PID of the process is 0 or 1, the
memory can be read (and written when it is RAM) using the addresses specified in Table 27-1. When it is 2 ~ 7,
the memory cannot be accessed.
The 8 KB RTC FAST Memory as well as the 8 KB of RTC SLOW Memory are governed by two configurable MPUs.
The MPUs can be configured to allow or deny access to each individual PID, using the RTC_CNTL_RTC_PID_
CONFIG_REG and DPORT_AHBLITE_MPU_TABLE_RTC_REG registers. Setting a bit in these registers will allow
the corresponding PID to read or write from the memory; clearing the bit disallows access. Access for PID 0 and
1 to RTC SLOW memory cannot be configured and is always enabled. Table 27-2 and 27-3 define the bit-to-PID
mappings of the registers.
Register RTC_CNTL_RTC_PID_CONFIG_REG is part of the RTC peripheral and can only be modified by processes
with a PID of 0; register DPORT_AHBLITE_MPU_TABLE_RTC_REG is a Dport register and can be changed by
processes with a PID of 0 or 1.
Both the upper 128 KB of SRAM0 and the upper 128 KB of SRAM2 are governed by an MMU. Not only can these
MMUs allow or deny access to the memory they govern (just like the MPUs do), but they are also capable of
translating the address a CPU reads from or writes to (which is a virtual address) to a possibly different address
in memory (the physical address).
In order to accomplish this, the internal RAM MMUs divide the memory range they govern into 16 pages. The
page size is configurable as 8 KB, 4 KB and 2 KB. When the page size is 8 KB, the 16 pages span the entire 128
KB memory region; when the page size is 4 KB or 2 KB, a non-MMU-covered region of 64 or 96 KB, respectively,
will exist at the end of the memory space. Similar to the virtual and physical addresses, it is also possible to
imagine the pages as having a virtual and physical component. The MMU can convert an address within a virtual
page to an address within a physical page.
For PID 0 and 1, this mapping is 1-to-1, meaning that a read from or write to a certain virtual page will always be
converted to a read from or write to the exact same physical page. This allows an operating system, running
under PID 0 and/or 1, to always have access to the entire physical memory range.
For PID 2 to 7, however, every virtual page can be reconfigured, on a per-PID basis, to map to a different physical
page. This way, reads and writes to an offset within a virtual page get translated into reads and writes to the
same offset within a different physical page. This is illustrated in Figure 27-1: the CPU (running a process with
a PID between 2 to 7) tries to access memory address 0x3FFC_2345. This address is within the virtual Page
1 memory region, at offset 0x0345. The MMU is instructed that for this particular PID, it should translate an
access to virtual page 1 into physical Page 2. This causes the memory access to be redirected to the same
offset as the virtual memory access, yet in Page 2, which results in the effective access of physical memory
address 0x3FFC_4345. The page size in this example is 8 KB.
3FFC_0000 3FFC_0000
PAGE 0 PAGE 0
3FFC_2000 3FFC_2000
3FFC_2345 PAGE 1 PAGE 1
3FFC_4000 3FFC_4000
3FFC_4345
PAGE 2 PAGE 2
3FFC_6000 3FFC_6000
3FFD_E000 3FFD_E000
PAGE 15 PAGE 15
3FFE_0000 3FFE_0000
Table 27-4. Page Mode of MMU for the Remaining 128 KB of Internal SRAM0 and SRAM2
For the MMU-managed region of SRAM0 and SRAM2, the page size is configurable as 8 KB, 4 KB and 2 KB. The
configuration is done by setting the DPORT_IMMU_PAGE_MODE (for SRAM0) and DPORT_DMMU_PAGE_MODE
(for SRAM2) bits in registers DPORT_IMMU_PAGE_MODE_REG and DPORT_DMMU_PAGE_MODE_REG, as de-
tailed in Table 27-4. Because the number of pages for either region is fixed at 16, the total amount of memory
covered by these pages is 128 KB when 8 KB pages are selected, 64 KB when 4 KB pages are selected, and 32
KB when 2 KB pages are selected. This implies that for 8 KB pages, the entire MMU-managed range is used, but
for the other page sizes there will be a part of the 128 KB memory that will not be governed by the MMU settings.
Concretely, for a page size of 4 KB, these regions are 0x4009_0000 to 0x4009_FFFF and 0x3FFD_0000 to
0x3FFD_FFFF; for a page size of 2 KB, the regions are 0x4008_8000 to 0x4009_FFFF and 0x3FFC_8000 to
0x3FFD_FFFF. These ranges are readable and writable by processes with a PID of 0 or 1; processes with other
PIDs cannot access this memory.
The layout of the pages in memory space is linear, namely, an SRAM0 MMU page n covers address space
0x40080000 + (pagesize ∗ n) to 0x40080000 + (pagesize ∗ (n + 1) − 1); similarily, an SRAM2 MMU page n covers
0x3F F C0000 + (pagesize ∗ n) to 0x3F F C0000 + (pagesize ∗ (n + 1) − 1). Tables 27-5 and 27-6 show the resulting
addresses in full.
MMU Mapping
For each of the SRAM0 and SRAM2 MMUs, access rights and virtual to physical page mapping are done by
a set of 16 registers. In contrast to most of the other MMUs, each register controls a physical page, not a
virtual one. These registers control which of the PIDs have access to the physical memory, as well as which
virtual page maps to this physical page. The bits in the register are described in Table 27-7. Keep in mind that
these registers only govern accesses from processes with PID 2 to 7; PID 0 and 1 always have full read and
write access to all pages and no virtual-to-physical mapping is done. In other words, if a process with a PID
of 0 or 1 accesses virtual page x, the access will always go to physical page x, regardless of these register
settings. These registers, as well as the page size selection registers DPORT_IMMU_PAGE_MODE_REG and
DPORT_DMMU_PAGE_MODE_REG, are only writable from a process with PID 0 or 1.
The memory governed by the SRAM0 MMU is accessed through the processors I-bus, while the processor
accesses the memory governed by the SRAM2 MMU through the D-bus. Thus, the normal envisioned use
is for the code to be stored in the SRAM0 MMU pages and data in the MMU pages of SRAM2. In general,
applications running under a PID of 2 to 7 are not expected to modify their own code, because for these PIDs
access to the MMU pages of SRAM0 is read-only. These applications must, however, be able to modify their
data section, so that they are allowed to read as well as write MMU pages located in SRAM2. As stated before,
processes running under PID 0 or 1 always have full read-and-write access to both memory ranges.
DMA MPU
Applications may want to configure the DMA to send data straight from or to the peripherals they can control.
With access to DMA, a malicious process may also be able to copy data from or to a region it cannot normally
access. In order to be secure against that scenario, there is a DMA MPU which can be used to disallow DMA
For each 8 KB region in the SRAM1 and SRAM2 regions, there is a bit in the DPORT_AHB_MPU_TABLE_n_REG
registers which tells the MPU to either allow or disallow DMA access to this region. The DMA MPU uses only
these bits to decide if a DMA transfer can be started; the PID of the process is not a factor. This means that
when the OS wants to restrict its processes in a heterogenous fashion, it will need to re-load these registers
with the values applicable to the process to be run on every context switch.
The register bits that govern access to the 8 KB regions are detailed in Table 27-8. When a register bit is set,
DMA can read/write the corresponding 8 KB memory range. When the bit is cleared, access to that memory
range is denied.
Note:
In hardware, there are three instruction buses corresponding to V Addr1 , V Addr2 , and V Addr3 , respectively. These
three buses can initiate load or fetch accesses simultaneously, but only one access is true. If more than one unmasked
instruction buses are present, then bit8 of all MMU entries should be set to zero. Otherwise, when an invalid MMU
entry is used by an access, the cache will be stalled even if there is no program at this access.
The MMU entries, as stated before, are used for mapping a virtual memory page access to a physical memory
page access. The MMU controls five regions of virtual address space, detailed in Table 27-9. V Addr1 to
V Addr4 are used for accessing external flash, whereas V AddrRAM is used for accessing external RAM. Note
that V Addr4 is a subset of V Addr0 .
Boundary address
Name Size Page quantity
Low High
V Addr0 4 MB 0x3F40_0000 0x3F7F_FFFF 64
V Addr1 4 MB 0x4000_0000 0x403F_FFFF 64*
V Addr2 4 MB 0x4040_0000 0x407F_FFFF 64
V Addr3 4 MB 0x4080_0000 0x40BF_FFFF 64
V Addr4 1 MB 0x3F40_0000 0x3F4F_FFFF 16
V AddrRAM 4 MB 0x3F80_0000 0x3FBF_FFFF 128
* The configuration entries for address range 0x4000_0000 ~ 0x403F_FFFF are implemented and doc-
umented as if it were a full 4 MB address range, but it is not accessible as such. Instead, the address range
0x4000_0000 ~ 0x400C_1FFF accesses on-chip memory. This means that some of the configuration entries
for V Addr1 will not be used.
External Flash
For flash, the relationships among entry numbers, virtual memory ranges, and PIDs are detailed in Tables 27-
10 and 27-11, which for every memory region and PID combination specify the first MMU entry governing the
mapping. This number refers to the MMU entry governing the very first page; the entire region is described by
the amount of pages specified in the ’count’ column.
These two tables are essentially the same, with the sole difference being that the APP_CPU entry numbers are
2048 higher than the corresponding PRO_CPU numbers. Note that memory regions V Addr0 and V Addr1 are
only accessible using PID 0 and 1, while V Addr4 can only be accessed by PID 2 ~ 7.
As these tables show, virtual address V Addr1 can only be used by processes with a PID of 0 or 1. There
is a special mode to allow processes with a PID of 2 to 7 to read the External Flash via address V Addr1 .
When the DPORT_PRO_SINGLE_IRAM_ENA bit of register DPORT_PRO_CACHE_CTRL_REG is 1, the MMU enters
this special mode for PRO_CPU memory accesses. Similarily, when the DPORT_APP_SINGLE_IRAM_ENA bit of
register DPORT_APP_CACHE_CTRL_REG is 1, the APP_CPU accesses memory using this special mode. In this
mode, the process and virtual address page supported by each configuration entry of MMU are different. For
details please see Table 27-12 and 27-13. As shown in these tables, in this special mode V Addr2 and V Addr3
cannot be used to access External Flash.
Every configuration entry of MMU maps a virtual address page of a CPU process to a physical address page. An
entry is 32 bits wide. Of these, bits 0~7 indicate the physical page the virtual page is mapped to. Bit 8 should
be cleared to indicate that the MMU entry is valid; entries with this bit set will not map any physical address to
the virtual address. Bits 10 to 32 are unused and should be written as zero. Because there are eight address
bits in an MMU entry, and the page size for external flash is 64 KB, a maximum of 256 * 64 KB = 16 MB of external
flash is supported.
Examples
Example 1. A PRO_CPU process, with a PID of 1, needs to read external flash address 0x07_2375 via virtual
address 0x3F70_2375. The MMU is not in the special mode.
• According to Table 27-9, virtual address 0x3F70_2375 resides in the 0x30’th page of V Addr0 .
• According to Table 27-10, the MMU entry for V Addr0 for PID 0/1 for the PRO_CPU starts at 0.
• The modified MMU entry is 0 + 0x30 = 0x30.
• Address 0x07_2375 resides in the 7’th 64 KB-sized page.
• MMU entry 0x30 needs to be set to 7 and marked as valid by setting the 8’th bit to 0. Thus, 0x007 is
written to MMU entry 0x30.
Example 2. An APP_CPU process, with a PID of 4, needs to read external flash address 0x44_048C via virtual
address 0x4044_048C. The MMU is not in special mode.
• According to Table 27-9, virtual address 0x4044_048C resides in the 0x4’th page of V Addr2 .
• According to Table 27-11, the MMU entry for V Addr2 for PID 4 for the APP_CPU starts at 2560.
• The modified MMU entry is 2560 + 0x4 = 2564.
• Address 0x44_048C resides in the 0x44’th 64 KB-sized page.
• MMU entry 2564 needs to be set to 0x44 and marked as valid by setting the 8’th bit to 0. Thus, 0x044 is
written to MMU entry 2564.
External RAM
Processes running on PRO_CPU and APP_CPU can read and write External SRAM via the Cache at virtual address
range V AddrRAM , which is 0x3F80_0000 ~ 0x3FBF_FFFF. As with the flash MMU, the address space and the
physical memory are divided into pages. For the External RAM MMU, the page size is 32 KB and the MMU is
able to map 256 physical pages into the virtual address space, allowing for 32 KB * 256 = 8 MB of physical
external RAM to be mapped.
The mapping of virtual pages into this memory range depends on the mode this MMU is in: Low-High mode,
Even-Odd mode, or Normal mode. In all cases, the DPORT_PRO_DRAM_HL bit and DPORT_PRO_DRAM_SPLIT
bit in register DPORT_PRO_CACHE_CTRL_REG, the DPORT_APP_DRAM_HL bit and DPORT_APP_DRAM_SPLIT
bit in register DPORT_APP_CACHE_CTRL_REG determine the virtual address mode for External SRAM. For details,
please see Table 27-14. If a different mapping for the PRO_CPU and APP_CPU is required, the Normal Mode
should be selected, as it is the only mode that can provide this. If it is allowable for the PRO_CPU and the
APP_CPU to share the same mapping, using either High-Low or Even-Odd mode can give a speed gain when
both CPUs access memory frequently.
In case the APP_CPU cache is disabled, which renders the region of 0x4007_8000 to 0x4007_FFFF usable
as normal internal RAM, the usability of the various cache modes changes. Normal mode will allow PRO_CPU
access to external RAM to keep functioning, but the APP_CPU will be unable to access the external RAM.
High-Low mode allows both CPUs to use external RAM, but only for the 2 MB virtual memory addresses from
0x3F80_0000 to 0x3F9F_FFFF. It is not advised to use Even-Odd mode with the APP_CPU cache region dis-
abled.
DPORT_PRO_DRAM_HL DPORT_PRO_DRAM_SPLIT
Mode
DPORT_APP_DRAM_HL DPORT_APP_DRAM_SPLIT
Low-High 1 0
Even-Odd 0 1
Normal 0 0
In normal mode, the virtual-to-physical page mapping can be different for both CPUs. Page mappings for
PRO_CPU are set using the MMU entries for L V AddrRAM , and page mappings for the APP_CPU can be con-
figured using the MMU entries for R V AddrRAM . In this mode, all 128 pages of both L V Addr and R V Addr are
fully used, allowing a maximum of 8 MB of memory to be mapped; 4 MB into PRO_CPU address space and a
possibly different 4 MB into the APP_CPU address space, as can be seen in Table 27-15.
PRO_CPU address
Virtual address Size
Low High
L
V AddrRAM 4 MB 0x3F80_0000 0x3FBF_FFFF
APP_CPU address
Virtual address Size
Low High
R
V AddrRAM 4 MB 0x3F80_0000 0x3FBF_FFFF
In Low-High mode, both the PRO_CPU and the APP_CPU use the same mapping entries. In this mode L V AddrRAM
is used for the lower 2 MB of the virtual address space, while R V AddrRAM is used for the upper 2 MB. This
also means that the upper 64 MMU entries for L V AddrRAM , as well as the lower 64 entries for R V AddrRAM ,
are unused. Table 27-16 details these address ranges.
PRO_CPU/APP_CPU address
Virtual address Size
Low High
L
V AddrRAM 2 MB 0x3F80_0000 0x3F9F_FFFF
R
V AddrRAM 2 MB 0x3FA0_0000 0x3FBF_FFFF
In Even-Odd memory, the VRAM is split into 32-byte chunks. The even chunks are resolved through the MMU
entries for L V AddrRAM , the odd chunks through the entries for R V AddrRAM . Generally, the MMU entries for
L
V AddrRAM and R V AddrRAM are set to the same values, so that the virtual pages map to a contiguous region
of physical memory. Table 27-17 details this mode.
PRO_CPU/APP_CPU address
Virtual address Size
Low High
L
V AddrRAM 32 Bytes 0x3F80_0000 0x3F80_001F
R
V AddrRAM 32 Bytes 0x3F80_0020 0x3F80_003F
L
V AddrRAM 32 Bytes 0x3F80_0040 0x3F80_005F
R
V AddrRAM 32 Bytes 0x3F80_0060 0x3F80_007F
...
L
V AddrRAM 32 Bytes 0x3FBF_FFC0 0x3FBF_FFDF
R
V AddrRAM 32 Bytes 0x3FBF_FFE0 0x3FBF_FFFF
The bit configuration of the External RAM MMU entries is the same as for the flash memory: the entries are
32-bit registers, with the lower nine bits being used. Bits 0~7 contain the physical page the entry should map
its associate virtual page address to, while bit 8 is cleared when the entry is valid and set when it is not. Table
27-18 details the first MMU entry number for L V AddrRAM and R V AddrRAM for all PIDs.
Examples
Example 1. A PRO_CPU process, with a PID of 7, needs to read or write external RAM address 0x7F_A375 via
virtual address 0x3FA7_2375. The MMU is in Low-High mode.
• According to Table 27-9, virtual address 0x3FA7_2375 resides in the 0x4E’th 32-KB-page of V AddrRAM .
• According to Table 27-16, virtual address 0x3FA7_2375 is governed by R V AddrRAM .
• According to Table 27-18, the MMU entry for R V AddrRAM for PID 7 for the PRO_CPU starts at 3968.
• The modified MMU entry is 3968 + 0x4E = 4046.
• Address 0x7F_A375 resides in the 255’th 32 KB-sized page.
• MMU entry 4046 needs to be set to 255 and marked as valid by clearing the 8’th bit. Thus, 0x0FF is
written to MMU entry 4046.
Example 2. An APP_CPU process, with a PID of 5, needs to read or write external RAM address 0x55_5805 up
to 0x55_5823 starting at virtual address 0x3F85_5805. The MMU is in Even-Odd mode.
• According to Table 27-9, virtual address 0x3F85_5805 resides in the 0x0A’th 32-KB-page of V AddrRAM .
• According to Table 27-17, the range to be read/written spans both a 32-byte region in R V AddrRAM and
L
V AddrRAM .
• According to Table 27-18, the MMU entry for L V AddrRAM for PID 5 starts at 1664.
• According to Table 27-18, the MMU entry for R V AddrRAM for PID 5 starts at 3712.
• The modified MMU entries are 1664 + 0x0A = 1674 and 3712 + 0x0A = 3722.
• The addresses 0x55_5805 to 0x55_5823 reside in the 0xAA’th 32 KB-sized page.
• MMU entries 1674 and 3722 need to be set to 0xAA and marked as valid by setting the 8’th bit to 0. Thus,
0x0AA is written to MMU entries 1674 and 3722. This mapping applies to both the PRO_CPU and the
APP_CPU.
Example 3. A PRO_CPU process, with a PID of 1, and an APP_CPU process whose PID is also 1, need to read
or write external RAM using virtual address 0x3F80_0876. The PRO_CPU needs this region to access physi-
cal address 0x10_0876, while the APP_CPU wants to access physical address 0x20_0876 through this virtual
address. The MMU is in Normal mode.
• According to Table 27-9, virtual address 0x3F80_0876 resides in the 0’th 32-KB-page of V AddrRAM .
• According to Table 27-18, the MMU entry for PID 1 for the PRO_CPU starts at 1152.
• According to Table 27-18, the MMU entry for PID 1 for the APP_CPU starts at 3200.
• The MMU entries that are modified are 1152 + 0 = 1152 for the PRO_CPU and 3200 + 0 = 3200 for the
APP_CPU.
• Address 0x10_0876 resides in the 0x20’th 32 KB-sized page.
• Address 0x20_0876 resides in the 0x40’th 32 KB-sized page.
• For the PRO_CPU, MMU entry 1152 needs to be set to 0x20 and marked as valid by clearing the 8’th bit.
Thus, 0x020 is written to MMU entry 1152.
• For the APP_CPU, MMU entry 3200 needs to be set to 0x40 and marked as valid by clearing the 8’th bit.
Thus, 0x040 is written to MMU entry 3200.
• Now, the PRO_CPU and the APP_CPU can access different physical memory regions through the same
virtual address.
27.3.2.3 Peripheral
The Peripheral MPU manages the 39 peripheral modules. This MMU can be configured per peripheral to only
allow access from a process with a certain PID. The registers to configure this are detailed in Table 27-19.
Authority
Peripheral
PID = 0/1 PID = 2 ~ 7
DPort Register Access Forbidden
AES Accelerator Access Forbidden
RSA Accelerator Access Forbidden
SHA Accelerator Access Forbidden
Secure Boot Access Forbidden
Cache MMU Table Access Forbidden
PID Controller Access Forbidden
UART0 Access DPORT_AHBLITE_MPU_TABLE_UART_REG
SPI1 Access DPORT_AHBLITE_MPU_TABLE_SPI1_REG
SPI0 Access DPORT_AHBLITE_MPU_TABLE_SPI0_REG
GPIO Access DPORT_AHBLITE_MPU_TABLE_GPIO_REG
RTC Access DPORT_AHBLITE_MPU_TABLE_RTC_REG
IO MUX Access DPORT_AHBLITE_MPU_TABLE_IO_MUX_REG
SDIO Slave Access DPORT_AHBLITE_MPU_TABLE_HINF_REG
UDMA1 Access DPORT_AHBLITE_MPU_TABLE_UHCI1_REG
I2S0 Access DPORT_AHBLITE_MPU_TABLE_I2S0_REG
UART1 Access DPORT_AHBLITE_MPU_TABLE_UART1_REG
I2C0 Access DPORT_AHBLITE_MPU_TABLE_I2C_EXT0_REG
UDMA0 Access DPORT_AHBLITE_MPU_TABLE_UHCI0_REG
SDIO Slave Access DPORT_AHBLITE_MPU_TABLE_SLCHOST_REG
RMT Access DPORT_AHBLITE_MPU_TABLE_RMT_REG
PCNT Access DPORT_AHBLITE_MPU_TABLE_PCNT_REG
SDIO Slave Access DPORT_AHBLITE_MPU_TABLE_SLC_REG
LED PWM Access DPORT_AHBLITE_MPU_TABLE_LEDC_REG
Efuse Controller Access DPORT_AHBLITE_MPU_TABLE_EFUSE_REG
Flash Encryption Access DPORT_AHBLITE_MPU_TABLE_SPI_ENCRYPT_REG
PWM0 Access DPORT_AHBLITE_MPU_TABLE_PWM0_REG
TIMG0 Access DPORT_AHBLITE_MPU_TABLE_TIMERGROUP_REG
TIMG1 Access DPORT_AHBLITE_MPU_TABLE_TIMERGROUP1_REG
SPI2 Access DPORT_AHBLITE_MPU_TABLE_SPI2_REG
SPI3 Access DPORT_AHBLITE_MPU_TABLE_SPI3_REG
SYSCON Access DPORT_AHBLITE_MPU_TABLE_APB_CTRL_REG
Authority
Peripheral
PID = 0/1 PID = 2 ~ 7
I2C1 Access DPORT_AHBLITE_MPU_TABLE_I2C_EXT1_REG
SDMMC Access DPORT_AHBLITE_MPU_TABLE_SDIO_HOST_REG
EMAC Access DPORT_AHBLITE_MPU_TABLE_EMAC_REG
PWM1 Access DPORT_AHBLITE_MPU_TABLE_PWM1_REG
I2S1 Access DPORT_AHBLITE_MPU_TABLE_I2S1_REG
UART2 Access DPORT_AHBLITE_MPU_TABLE_UART2_REG
RNG Access DPORT_AHBLITE_MPU_TABLE_PWR_REG
Each bit of register DPORT_AHBLITE_MPU_TABLE_X_REG determines whether each process can access the
peripherals managed by the register. For details please see Table 27-20. When a bit of register DPORT_AHBLITE_
MPU_TABLE_X_REG is 1, it means that a process with the corresponding PID can access the corresponding
peripheral of the register. Otherwise, the process cannot access the corresponding peripheral.
PID 234567
DPORT_AHBLITE_MPU_TABLE_X_REG bit 012345
All the DPORT_AHBLITE_MPU_TABLE_X_REG registers are in peripheral DPort Register. Only processes with PID
0/1 can modify these registers.
28.1 Overview
The ESP32 is a dual core device and is capable of running and managing multiple processes. The PID Controller
supports switching of PID when a process switch occurs. In addition to PID management, the PID Controller
also facilitates management of nested interrupts by recording execution status just before an interrupt service
routine is executed. This enables the user application to manage process switches and nested interrupts more
efficiently.
28.2 Features
The PID Controller features:
• An interrupt occurs and the CPU fetches an instruction from the interrupt vector. Instruction fetch or
execution from interrupt vector is always treated as a process with PID of 0, irrespective of which process
was being executed on the CPU when the interrupt occurred.
• A currently active process explicitly performs a process switch. Only elevated processes with PID of 0 or
1 may perform a process switch.
PIDCTRL_INTERRUPT_ENABLE_REG determines whether the PID Controller identifies and registers an interrupt
of certain priority. When a bit of register PIDCTRL_INTERRUPT_ENABLE_REG is 1, PID Controller will take action
when CPU fetches instruction from the interrupt vector entry address of the corresponding interrupt. Otherwise,
PID Controller performs no action. The registers PIDCTRL_INTERRUPT_ADDR_1_REG ~ PIDCTRL_INTERRUPT_ADDR_7_REG
define the interrupt vector entry address for all the interrupt priority levels. For details please refer to Table 28-
1.
PIDCTRL_INTERRUPT_ENABLE_REG bit
Priority level Interrupt vector entry address
controlling interrupt identification
Level 1 1 PIDCTRL_INTERRUPT_ADDR_1_REG
Level 2 2 PIDCTRL_INTERRUPT_ADDR_2_REG
Level 3 3 PIDCTRL_INTERRUPT_ADDR_3_REG
Level 4 4 PIDCTRL_INTERRUPT_ADDR_4_REG
Level 5 5 PIDCTRL_INTERRUPT_ADDR_5_REG
Level 6 ( Debug 6 PIDCTRL_INTERRUPT_ADDR_6_REG
)
NMI 7 PIDCTRL_INTERRUPT_ADDR_7_REG
PID Controller records the priority level of the current interrupt in register PIDCTRL_LEVEL_REG. For details
please refer to Table 28-2.
PID Controller also records in register PIDCTRL_FROM_n_REG the status of the system before the interrupt
occurred. The bit width of register PIDCTRL_FROM_n_REG is 7. The highest four bits represent the interrupt
status of the system before the interrupt indicated by the register occurred. The lowest three bits represent the
process running on the CPU before the interrupt indicated by the register occurred. For details please refer to
Table 28-3.
Though we can deal with interrupt nesting, an elevated process should not be interrupted during the process
switching, and therefore the interrupts have been masked in step 1 and step 2.
In step 3, the configured values of registers PIDCTRL_PID_DELAY_REG and PIDCTRL_NMI_DELAY_REG will affect
step 6.
In step 4, the configured value of register PIDCTRL_PID_NEW_REG will be the new PID after step 6.
If the system is currently in a nested interrupt and needs to revert to the previous interrupt, register PIDC-
TRL_LEVEL_REG must be restored based on the information recorded in register PIDCTRL_FROM_n_REG in
step 5.
In step 7, other tasks can be implemented as well. To do this, the cost of those tasks should be included when
configuring registers PIDCTRL_PID_DELAY_REG and PIDCTRL_NMI_DELAY_REG in step 3.
28.5 Registers
The addresses in parenthesis besides register names are the register addresses relative to the PID Controller
base address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and Memory. The
absolute register addresses are listed in Section 28.4 Register Summary.
B LE
NA
_E
PT
RU
ER
T
IN
)
d)
L_
ed
ve
TR
rv
r
se
se
DC
(re
(re
PI
31 8 7 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PIDCTRL_INTERRUPT_ENABLE These bits are used to enable interrupt identification and process-
ing. (R/W)
31 0
0x040000340 Reset
31 0
0x040000180 Reset
31 0
0x0400001C0 Reset
31 0
0x040000200 Reset
31 0
0x040000240 Reset
31 0
0x040000280 Reset
31 0
0x0400002C0 Reset
AY
EL
D
D_
PI
)
L_
ed
TR
rv
se
DC
(re
PI
31 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 Reset
L_
ed
TR
rv
se
DC
(re
PI
31 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 Reset
PIDCTRL_NMI_DELAY Delay for disabling CPU NMI interrupt mask signal. (R/W)
S
TU
TA
_S
NT
RRE
CU
d)
L_
ve
TR
r
se
DC
(re
PI
31 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_n
US
AT
ST
S_
OU
EVI
PR
)
L_
ed
R
rv
CT
se
D
(re
PI
31 7 6 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PIDCTRL_PREVIOUS_STATUS_n System status before any of Level 1 to Level 6, NMI interrupts oc-
curs. (R/W)
N EW
D_
PI
)
L_
ed
TR
rv
se
DC
(re
PI
31 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RM
I
O NF
_C
ID
_P
d)
L
ve
TR
r
se
DC
(re
PI
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LE
NAB
_E
K
AS
M
I_
M
_N
)
ed
L
TR
rv
se
DC
(re
PI
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PIDCTRL_NMI_MASK_ENABLE This bit is used to enable CPU NMI interrupt mask signal. (WO)
LE
AB
IS
_D
K
AS
M
I_
M
_N
)
ed
L
TR
rv
se
DC
(re
PI
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PIDCTRL_NMI_MASK_DISABLE This bit is used to disable CPU NMI interrupt mask signal. (WO)
29.1 Introduction
ESP32 has a capacitive touch sensor with up to 10 inputs.
The processing of analog signals is done by two successive approximation ADCs (SAR ADC). There are five
controllers dedicated to operating ADCs. This provides flexibility when it comes to converting analog inputs in
both high-performance and low-power modes, with minimum processor overhead.
ESP32 is also capable of generating analog signals, using two independent DACs and a cosine waveform gen-
erator.
29.2.2 Features
• Up to 10 capacitive touch pads / GPIOs
• The sensing pads can be arranged in different combinations, so that a larger area or more points can be
detected.
• The touch pad sensing process is under the control of a hardware-implemented finite-state machine (FSM)
which is initiated by software or a dedicated hardware timer.
– CPU waiting in deep sleep and saving power until touch detection and subsequent wake up
Note:
ESP32 Touch Sensor has not passed the Conducted Susceptibility (CS) test for now, and thus has limited application
scenarios.
The capacitance of a touch pad is periodically charged and discharged. The chart ”Pad Voltage” shows the
charge/discharge voltage that swings from DREFH (reference voltage high) to DREFL (reference voltage low).
During each swing, the touch sensor generates an output pulse, shown in the chart as ”OUT”. The swing slope
is different when the pad is touched (high capacitance) and when it is not (low capacitance). By comparing the
difference between the output pulse counts during the same time interval, we can conclude whether the touch
pad has been touched. TIE_OPT is used to establish the initial voltage level that starts the charge/discharge
cycle.
The Touch FSM can be active in sleep mode. The SENS_SAR_TOUCH_SLEEP_CYCLES register can be
used to set the cycles. The sensor is operated by RTC_FAST_CLK, which normally runs at 8 MHz. More
information on that can be found in chapter Reset and Clock.
The SAR ADC controllers have specialized uses. Two of them support high-performance multiple-channel scan-
ning. Another two are used for low-power operation during Deep-sleep, and the last one is dedicated to PWDET
/ PKDET (power and peak detection). A diagram of the SAR ADCs is shown in Figure 29-5.
Note:
PWDET/PKDET controller is for Wi-Fi internal use only. If Wi-Fi module is using the SAR ADC2, users can not measure
the analog signal from the pins using SAR ADC2. After SAR ADC2 is released by Wi-Fi, users can use SAR ADC2 normally.
29.3.2 Features
• Two SAR ADCs, with simultaneous sampling and conversion
• Up to five SAR ADC controllers for different purposes (e.g. high performance, low power or PWDET /
PKDET).
Table 29-2 lists all the analog signals that may be sent to the SAR ADC module via the ADC channels.
Note:
• Some of the SAR ADC2 pins are used as strapping pins (GPIO0, GPIO2, and GPIO15), thus can not be used
freely.
There are five ADC controllers in ESP32: RTC ADC1 CTRL, RTC ADC2 CTRL, DIG ADC1 CTRL, DIG ADC2 CTRL
and PWDET CTRL. The differences between them are summarized in Table 29-3.
The outline of a single controller’s function is shown in Figure 29-7. For each controller, the start of analog-to-
digital conversion can be triggered by register SENS_SAR_MEASn_START_SAR. The measurement’s result can
be obtained from register SENS_SAR_MEASn_DATA_SAR.
The controllers are intertwined with the ULP coprocessor, as the ULP coprocessor has a built-in instruction
to start an ADC measurement. In many cases, the controllers need to cooperate with the ULP coprocessor,
e.g.:
• when periodically monitoring a channel during deep sleep, where the ULP coprocessor is the only trigger
source during this mode;
• when scanning channels continuously in a sequence. Continuous scanning or DMA is not supported by
the controllers. However, it is possible with the help of the ULP coprocessor.
• High performance; the clock is much faster, therefore, the sample rate is highly increased.
• Multiple-channel scanning mode; there is a pattern table that defines the measurement rule for each SAR
ADC. The scanning mode can be configured as a single mode, double mode, or alternate mode.
Note:
We do not use the term “start of conversion” in this section, because there is no direct access to starting a single
SAR analog-to-digital conversion. We use “start of scan” instead, which implies that we expect to scan a sequence of
channels with DIG ADC controllers.
The pattern tables contain the measurement rules mentioned above. Each table has 16 items which store infor-
mation on channel selection, resolution and attenuation. When scanning starts, the controller reads measure-
ment rules one-by-one from a pattern table. For each controller the scanning sequence includes 16 different
rules at most, before repeating itself.
The 8-bit item (the pattern table register) is composed of three fields that contain channel, resolution and
attenuation information, as shown in Table 29-4.
There are three scanning modes: single mode, double mode and alternate mode.
• Single mode: channels of either SAR ADC1 or SAR ADC2 will be scanned.
• Double mode: channels of SAR ADC1 and SAR ADC2 will be scanned simultaneously.
• Alternate mode: channels of SAR ADC1 and SAR ADC2 will be scanned alternately.
ESP32 supports up to a 12-bit SAR ADC resolution. The 16-bit data in DMA is composed of the ADC result and
some necessary information related to the scanning mode:
• For double mode or alternate mode, 4-bit information on channel selection is added plus one extra bit
indicating which SAR ADC was selected.
For each scanning mode there is a corresponding data format, called Type I and Type II. Both data formats are
described in Tables 29-5 and 29-6.
For Type I the resolution of SAR ADC is up to 12 bits, while for Type II the resolution is 11 bits at most.
DIG SAR ADC Controllers allow the use of I2S for direct memory access. The WS signal of I2S acts as a
measurement-trigger signal. The DATA signal provides the information that the measurement result is ready.
Software can configure APB_SARADC_DATA_TO_I2S, in order to connect ADC to I2S.
29.4 DAC
29.4.1 Introduction
Two 8-bit DAC channels can be used to convert digital values into analog output signals (up to two of them).
The design structure is composed of integrated resistor strings and a buffer. This dual DAC supports power
supply and uses it as input voltage reference. The dual DAC also supports independent or simultaneous signal
conversions inside of its channels.
29.4.2 Features
The features of DAC are as follows:
• DMA capability
• Start of conversion can be triggered by software or SAR ADC FSM (please refer to the SAR ADC chapter
for more details)
A diagram showing the DAC channel’s function is presented in Figure 29-9. For a detailed description, see the
sections below.
29.4.3 Structure
The two 8-bit DAC channels can be configured independently. For each DAC channel, the output analog voltage
can be calculated as follows:
The start of conversion is determined by register RTCIO_PAD_PDACn_XPD_DAC. The conversion process itself
is controlled by software or SAR ADC FSM; see Figure 29-9.
• Adjustable frequency
The frequency of CW can be adjusted by register SENS_SAR_SW_FSTEP[15:0]:
• Scaling
Configuring register SENS_SAR_DAC_SCALEn[1:0]; the amplitude of a CW can be multiplied by 1, 1/2, 1/4
or 1/8.
• DC offset
The offset may be introduced by register SENS_SAR_DAC_DCn[7:0]. The result will be saturated.
• Phase shift
A phase-shift of 0 / 90 / 180 / 270 degrees can be added by setting register SENS_SAR_DAC_INVn[1:0].
29.5.1 Sensors
Name Description Address Access
Touch pad setup and control registers
SENS_SAR_TOUCH_CTRL1_REG Touch pad control 0x3FF48858 R/W
SENS_SAR_TOUCH_CTRL2_REG Touch pad control and status 0x3FF48884 RO
SENS_SAR_TOUCH_ENABLE_REG Wakeup interrupt control and working set 0x3FF4888C R/W
SENS_SAR_TOUCH_THRES1_REG Threshold setup for pads 0 and 1 0x3FF4885C R/W
SENS_SAR_TOUCH_THRES2_REG Threshold setup for pads 2 and 3 0x3FF48860 R/W
SENS_SAR_TOUCH_THRES3_REG Threshold setup for pads 4 and 5 0x3FF48864 R/W
SENS_SAR_TOUCH_THRES4_REG Threshold setup for pads 6 and 7 0x3FF48868 R/W
SENS_SAR_TOUCH_THRES5_REG Threshold setup for pads 8 and 9 0x3FF4886C R/W
SENS_SAR_TOUCH_OUT1_REG Counters for pads 0 and 1 0x3FF48870 RO
SENS_SAR_TOUCH_OUT2_REG Counters for pads 2 and 3 0x3FF48874 RO
SENS_SAR_TOUCH_OUT3_REG Counters for pads 4 and 5 0x3FF48878 RO
SENS_SAR_TOUCH_OUT4_REG Counters for pads 6 and 6 0x3FF4887C RO
SENS_SAR_TOUCH_OUT5_REG Counters for pads 8 and 9 0x3FF48880 RO
SAR ADC control register
SENS_SAR_START_FORCE_REG SAR ADC1 and ADC2 control 0x3FF4882C R/W
SAR ADC1 control registers
SENS_SAR_READ_CTRL_REG SAR ADC1 data and sampling control 0x3FF48800 R/W
SENS_SAR_MEAS_START1_REG SAR ADC1 conversion control and status 0x3FF48854 RO
SAR ADC2 control registers
SENS_SAR_READ_CTRL2_REG SAR ADC2 data and sampling control 0x3FF48890 R/W
SENS_SAR_MEAS_START2_REG SAR ADC2 conversion control and status 0x3FF48894 RO
ULP coprocessor configuration register
SENS_ULP_CP_SLEEP_CYC0_REG Sleep cycles for ULP coprocessor 0x3FF48818 R/W
Pad attenuation configuration registers
SENS_SAR_ATTEN1_REG 2-bit attenuation for each pad 0x3FF48834 R/W
SENS_SAR_ATTEN2_REG 2-bit attenuation for each pad 0x3FF48838 R/W
DAC control registers
SENS_SAR_DAC_CTRL1_REG DAC control 0x3FF48898 R/W
SENS_SAR_DAC_CTRL2_REG DAC output control 0x3FF4889C R/W
29.6 Registers
29.6.1 Sensors
The addresses in parenthesis besides register names are the register addresses relative to (the RTC base ad-
dress + 0x0800). The RTC base address is provided in Table 1-6 Peripheral Address Mapping in Chapter 1
System and Memory. The absolute register addresses are listed in Section 29.5.1 Sensors.
CLE
T
CY
E
BI
RC
G_ V
E_
E_
V
DI IN
FO
I
PL
PL
_D
1_ TA_
AM
AM
LK
AR DA
_C
_S
_S
_S 1_
R1
R1
R1
NS AR
)
d)
ed
A
ve
SE _S
_S
_S
_S
rv
r
NS
NS
NS
NS
se
se
(re
(re
SE
SE
SE
SE
31 29 28 27 26 18 17 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 9 2 Reset
SENS_SAR1_DIG_FORCE 1: SAR ADC1 controlled by DIG ADC1 CTR, 0: SAR ADC1 controlled by RTC
ADC1 CTRL. (R/W)
SENS_SAR1_SAMPLE_BIT Bit width of SAR ADC1, 00: for 9-bit, 01: for 10-bit, 10: for 11-bit, 11: for
12-bit. (R/W)
31 0
200 Reset
P
TO
T_
AR
RC OP
ST
T
CC
TH
E_
FO T_T
TH
T
T_
ID
ES
ID
P_ AR
DE
_W
W
OP
_T
2_ OP
_C ST
T_
T
PW
EN
ST
LP P_
BI
AR ST
BI
NI
2_
2_
2_
_U _C
_S 1_
1_
I
C_
NS AR
AR
AR
AR
AR
NS LP
)
NS d)
ed
SE rve
SE _U
_P
SE S_S
_S
_S
_S
_S
rv
NS
NS
NS
NS
NS
se
se
N
(re
(re
SE
SE
SE
SE
SE
SE
31 24 23 22 21 11 10 9 8 7 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 Reset
SENS_SAR2_BIT_WIDTH Bit width of SAR ADC2, 00: 9 bits, 01: 10 bits, 10: 11 bits, 11: 12 bits. (R/W)
SENS_SAR1_BIT_WIDTH Bit width of SAR ADC1, 00: 9 bits, 01: 10 bits, 10: 11 bits, 11: 12 bits. (R/W)
31 0
0x0FFFFFFFF Reset
SENS_SAR_ATTEN1_REG 2-bit attenuation for each pad, 11: 1 dB, 10: 6 dB, 01: 3 dB, 00: 0 dB, [1:0]
is used for ADC1_CH0, [3:2] is used for ADC1_CH1, etc. (R/W)
31 0
0x0FFFFFFFF Reset
SENS_SAR_ATTEN2_REG 2-bit attenuation for each pad, 11: 1 dB, 10: 6 dB, 01: 3 dB, 00: 0 dB,
[1:0] is used for ADC2_CH0, [3:2] is used for ADC2_CH1, etc (R/W)
CE
ON _SA CE
R
_D T R
E_ R
R
FO
R
S1 TAR FO
SA
SA
D_
EA _S RT_
D
A_
PA
PA
AT
_M AS TA
N_
N_
_D
NS E _S
_E
_E
SE S_M AS1
S1
R1
R1
EA
N E
A
SE S_M
_M
_S
_S
NS
NS
NS
N
SE
SE
SE
SE
31 30 19 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SENS_SAR1_EN_PAD_FORCE 1: SAR ADC1 pad enable bitmap is controlled by SW, 0: SAR ADC1 pad
enable bitmap is controlled by ULP coprocessor. (R/W)
SENS_SAR1_EN_PAD SAR ADC1 pad enable bitmap; active only when reg_sar1_en_pad_force = 1.
(R/W)
SENS_MEAS1_START_FORCE 1: SAR ADC1 controller (in RTC) is started by SW, 0: SAR ADC1 con-
troller is started by ULP coprocessor. (R/W)
SENS_MEAS1_START_SAR SAR ADC1 controller (in RTC) starts conversion; active only when
reg_meas1_start_force = 1. (R/W)
AI
UT EN
D
S_
_W
_S
_O T_1
EA
PD
CH OU
_M
_X
OU _
_T CH
CH
H
UC
NS OU
OU
)
se d )
SE S_T )
ed
N d
O
(re rve
SE rve
_T
_T
rv
NS
NS
se
se
(re
(re
SE
SE
31 28 27 26 25 24 23 16 15 0
SENS_TOUCH_OUT_SEL 1: the touch pad is considered touched when the value of the counter
is greater than the threshold, 0: the touch pad is considered touched when the value of the
counter is less than the threshold. (R/W)
SENS_TOUCH_XPD_WAIT The waiting time (in 8 MHz cycles) between TOUCH_START and
TOUCH_XPD. (R/W)
1
H
TH
_T
T_
UT
OU
_O
H_
H
UC
UC
O
O
_T
_T
NS
NS
SE
SE
31 16 15 0
3
TH
TH
T_
T_
OU
OU
H_
H_
UC
C
OU
O
_T
_T
NS
NS
SE
SE
31 16 15 0
TH
T_
T_
OU
U
_O
H_
H
UC
UC
O
O
_T
_T
NS
NS
SE
SE
31 16 15 0
7
H
H
_T
_T
UT
UT
_O
_O
H
H
UC
UC
O
O
_T
_T
NS
NS
SE
SE
31 16 15 0
9
8
TH
TH
T_
T_
OU
OU
H_
H_
UC
C
OU
O
_T
_T
NS
NS
SE
SE
31 16 15 0
1
UT
UT
O
O
S_
S_
EA
EA
_M
M
H_
H
UC
UC
O
O
_T
_T
NS
NS
SE
SE
31 16 15 0
3
UT
UT
O
O
S_
S_
EA
EA
M
M
H_
H_
UC
UC
O
O
_T
_T
NS
NS
SE
SE
31 16 15 0
5
4
UT
UT
O
O
S_
S_
EA
EA
M
M
H_
H_
UC
C
OU
O
_T
_T
NS
NS
SE
SE
31 16 15 0
7
UT
UT
O
O
S_
S_
EA
EA
M
_M
H_
H
UC
UC
O
O
_T
_T
NS
NS
SE
SE
31 16 15 0
9
8
UT
UT
O
O
S_
S_
EA
EA
M
M
H_
H_
UC
UC
O
O
_T
_T
NS
NS
SE
SE
31 16 15 0
NE N
S
LR
DO _E
CH STA _E CE
LE
_C
S_ M
C
OU _ RT R
CY
_M RT N
_T CH TA _FO
EN
N
EA _FS
E
P_
S_
S_
NS OU _S RT
EE
EA
EA
SE S_T CH STA
SL
M
M
H_
H_
N OU _
H_
SE S_T CH
C
UC
UC
OU
N OU
NS d)
O
SE rve
_T
_T
SE S_T
_T
NS
NS
se
N
(re
SE
SE
SE
31 30 29 14 13 12 11 10 9 0
SENS_TOUCH_START_FORCE 1: starts the Touch FSM via software; 0: starts the Touch FSM via
timer. (R/W)
SENS_TOUCH_START_EN 1: starts the Touch FSM; this is valid when reg_touch_start_force is set.
(R/W)
N
N2
N1
KE
TE
TE
OR
OU
OU
W
D_
D_
D_
PA
PA
PA
H_
H_
H_
UC
UC
UC
)
ed
O
_T
_T
_T
rv
NS
NS
NS
se
(re
SE
SE
SE
31 30 29 20 19 10 9 0
SENS_TOUCH_PAD_OUTEN1 Bitmap defining SET1 for generating a wakeup interrupt; SET1 is con-
sidered touched if at least one of the touch pads in SET1 is touched. (R/W)
SENS_TOUCH_PAD_OUTEN2 Bitmap defining SET2 for generating a wakeup interrupt; SET2 is con-
sidered touched if at least one of the touch pads in SET2 is touched. (R/W)
C LE
T
CY
E
BI
RC
G_ V
E_
E_
V
DI _IN
FO
DI
PL
PL
_
2_ TA
AM
AM
LK
AR DA
_C
_S
_S
_S 2_
R2
R2
R2
NS AR
SE ed)
)
ed
A
SE S_S
_S
_S
_S
rv
rv
NS
NS
NS
se
se
N
(re
(re
SE
SE
31 30 29 28 27 18 17 16 15 8 7 SE 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 9 2 Reset
SENS_SAR2_DIG_FORCE 1: SAR ADC2 controlled by DIG ADC2 CTRL or PWDET CTRL, 0: SAR ADC2
controlled by RTC ADC2 CTRL (R/W)
SENS_SAR2_SAMPLE_BIT Bit width of SAR ADC2, 00: for 9-bit, 01: for 10-bit, 10: for 11-bit, 11: for
12-bit. (R/W)
ON _SA CE
RC
_D RT R
E_ R
R
FO
AR
S2 TA FO
SA
D_
_S
EA _S RT_
D
A
PA
PA
AT
_M AS STA
N_
N_
_D
NS E _
_E
_E
SE S_M AS2
S2
R2
R2
EA
N E
A
SE S_M
_M
_S
_S
NS
NS
NS
N
SE
SE
SE
SE
31 30 19 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SENS_SAR2_EN_PAD_FORCE 1: SAR ADC2 pad enable bitmap is controlled by SW, 0: SAR ADC2
pad enable bitmap is controlled by ULP coprocessor. (R/W)
SENS_SAR2_EN_PAD SAR ADC2 pad enable bitmap; active only when reg_sar2_en_pad_force =
1. (R/W)
SENS_MEAS2_START_FORCE 1: SAR ADC2 controller (in RTC) is started by SW, 0: SAR ADC2 con-
troller is started by ULP coprocessor. (R/W)
SENS_MEAS2_START_SAR SAR ADC2 controller (in RTC) starts conversion; active only when
reg_meas2_start_force = 1. (R/W)
N
SE _D _C _IN
_E
_D _C _F
P
E
E
NS AC LK
ON
ST
SE S_D C_C
_F
_T
d)
W
ed
N A
ve
SE S_D
_S
_S
rv
r
NS
NS
se
se
N
(re
(re
SE
SE
SE
31 26 25 24 23 22 21 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SENS_DAC_DIG_FORCE 1: DAC1 & DAC2 use DMA, 0: DAC1 & DAC2 do not use DMA. (R/W)
SENS_SW_FSTEP Frequency step for CW generator; can be used to adjust the frequency. (R/W)
_D CW N2
NV 1
1
AC _EN
LE
LE
_ E
2
SE DAC CW_
C2
1
CA
CA
C1
NV
_D
_D
_S
_S
_I
_I
_ _
NS AC
AC
AC
AC
AC
AC
)
ed
SE S_D
_D
_D
_D
_D
_D
rv
NS
NS
NS
NS
NS
NS
se
N
(re
SE
SE
SE
SE
SE
SE
31 26 25 24 23 22 21 20 19 18 17 16 15 8 7 0
0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SENS_DAC_INV2 DAC2, 00: does not invert any bits, 01: inverts all bits, 10: inverts MSB, 11: inverts
all bits except for MSB. (R/W)
SENS_DAC_INV1 DAC1, 00: does not invert any bits, 01: inverts all bits, 10: inverts MSB, 11: inverts
all bits except for MSB. (R/W)
SENS_DAC_SCALE2 DAC2, 00: no scale; 01: scale to 1/2; 10: scale to 1/4; 11: scale to 1/8. (R/W)
SENS_DAC_SCALE1 DAC1, 00: no scale; 01: scale to 1/2; 10: scale to 1/4; 11: scale to 1/8. (R/W)
LE R
AR
_C A
_ P LE
ED
EN
TT _C
EN
1_ TT L
EL AT
AR PA SE
CE
PA _P
IV
_L
E
DC AR SA S
_L
OD
D
RA _S A_ _I2
_S _G
_S 2_ R_
TT
OR
_S T X
TT
K_
U
PA
M
AP ARA SAR LK
SA DC AT TO
PA
DC TA M
_F
CL
K_
2_
RA _S 2_
_ _C
B_ RA _D A_
RT
1_
R_
R
OR
AR
AR
DC A R
SA DC AR
AP _SA ADC DAT
TA
SA
AP _SA C_W
_S
_S
AP ARA C_S
B_ RA _S
B R _
C_
AP _SA ADC
DC
DC
AP SA DC
AD
S D
D
RA
RA
B_ RA
B_ RA
)
ed
B R
R
AP _SA
SA
SA
SA
AP _SA
rv
S
B_
B_
B_
B_
se
B
(re
AP
AP
AP
AP
AP
31 27 26 25 24 23 22 19 18 15 14 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 15 15 4 1 0 0 0 0 0 Reset
APB_SARADC_DATA_TO_I2S 1: I2S input data is from SAR ADC (for DMA), 0: I2S input data is from
GPIO matrix. (R/W)
APB_SARADC_DATA_SAR_SEL 1: sar_sel will be coded by the MSB of the 16-bit output data, in this
case, the resolution should not contain more than 11 bits; 0: using 12-bit SAR ADC resolution.
(R/W)
APB_SARADC_SAR2_PATT_P_CLEAR Clears the pointer of pattern table for DIG ADC2 CTRL. (R/W)
APB_SARADC_SAR1_PATT_P_CLEAR Clears the pointer of pattern table for DIG ADC1 CTRL. (R/W)
APB_SARADC_SAR_SEL 0: SAR1, 1: SAR2, this setting is applicable in the single SAR mode. (R/W)
APB_SARADC_SAR2_MUX 1: SAR ADC2 is controlled by DIG ADC2 CTRL, 0: SAR ADC2 is controlled
by PWDET CTRL. (R/W)
IT
M
IM
NU
_L
S_
M
EA
NU
1_ V
V
AR IN
IN
_M
S_
_S 2_
EA
AX
DC A R
_M
_M
RA _S
SA DC
DC
DC
B_ RA
RA
RA
)
ed
AP _SA
SA
SA
rv
B_
B_
se
B
(re
AP
AP
AP
31 11 10 9 8 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0 Reset
APB_SARADC_SAR2_INV 1: data to DIG ADC2 CTRL is inverted, 0: data is not inverted. (R/W)
APB_SARADC_SAR1_INV 1: data to DIG ADC1 CTRL is inverted, 0: data is not inverted. (R/W)
)
ed
ed
ed
R
SA
rv
rv
rv
B_
se
se
se
(re
(re
(re
AP
31 24 23 16 15 8 7 0
2 8 255 8 Reset
31 0
0x00F0F0F0F Reset
APB_SARADC_SAR1_PATT_TAB1_REG Pattern tables 0 - 3 for SAR ADC1, one byte for each pat-
tern table: [31:28] pattern0_channel, [27:26] pattern0_bit_width, [25:24] pattern0_attenuation,
[23:20] pattern1_channel, etc. (R/W)
31 0
0x00F0F0F0F Reset
APB_SARADC_SAR1_PATT_TAB2_REG Pattern tables 4 - 7 for SAR ADC1, one byte for each pat-
tern table: [31:28] pattern4_channel, [27:26] pattern4_bit_width, [25:24] pattern4_attenuation,
[23:20] pattern5_channel, etc. (R/W)
31 0
0x00F0F0F0F Reset
APB_SARADC_SAR1_PATT_TAB3_REG Pattern tables 8 - 11 for SAR ADC1, one byte for each pat-
tern table: [31:28] pattern8_channel, [27:26] pattern8_bit_width, [25:24] pattern8_attenuation,
[23:20] pattern9_channel, etc. (R/W)
31 0
0x00F0F0F0F Reset
APB_SARADC_SAR1_PATT_TAB4_REG Pattern tables 12 - 15 for SAR ADC1, one byte for each pattern
table: [31:28] pattern12_channel, [27:26] pattern12_bit_width, [25:24] pattern12_attenuation,
[23:20] pattern13_channel, etc. (R/W)
31 0
0x00F0F0F0F Reset
APB_SARADC_SAR2_PATT_TAB1_REG Pattern tables 0 - 3 for SAR ADC2, one byte for each pat-
tern table: [31:28] pattern0_channel, [27:26] pattern0_bit_width, [25:24] pattern0_attenuation,
[23:20] pattern1_channel, etc. (R/W)
31 0
0x00F0F0F0F Reset
APB_SARADC_SAR2_PATT_TAB2_REG Pattern tables 4 - 7 for SAR ADC2, one byte for each pat-
tern table: [31:28] pattern4_channel, [27:26] pattern4_bit_width, [25:24] pattern4_attenuation,
[23:20] pattern5_channel, etc. (R/W)
31 0
0x00F0F0F0F Reset
APB_SARADC_SAR2_PATT_TAB3_REG Pattern tables 8 - 11 for SAR ADC2, one byte for each pat-
tern table: [31:28] pattern8_channel, [27:26] pattern8_bit_width, [25:24] pattern8_attenuation,
[23:20] pattern9_channel, etc. (R/W)
31 0
0x00F0F0F0F Reset
30.1 Introduction
The ULP coprocessor is an ultra-low-power processor that remains powered on during the Deep-sleep mode
of the main SoC. Hence, the developer can store in the RTC memory a program for the ULP coprocessor to
access peripheral devices, internal sensors and RTC registers during deep sleep. This is useful for designing
applications where the CPU needs to be woken up by an external event, or timer, or a combination of these,
while maintaining minimal power consumption.
30.2 Features
• Contains up to 8 KB of SRAM for instructions and data
• Contains four 16-bit general-purpose registers (R0, R1, R2, R3) for manipulating data and accessing
memory
• Includes one 8-bit Stage_cnt register which can be manipulated by ALU and used in JUMP instructions
APB Bus
bridge
TSENS CTRL
ULP
RTC Timer
Coprocessor
SAR CTRL
ESP32 RTC
The ULP coprocessor can be started by software or a periodically-triggered timer. The operation of the ULP
coprocessor is ended by executing the HALT instruction. Meanwhile, it can access almost every module in
RTC domain, either through built-in instructions or RTC registers. In many cases the ULP coprocessor can be a
good supplement to, or replacement of, the CPU, especially for power-sensitive applications. Figure 30-1
shows the overall layout of a ULP coprocessor.
OpCode Operands
An instruction, which has one OpCode, can perform various different operations, depending on the setting of
Operands bits. A good example is the ALU instruction, which is able to perform 10 arithmetic and logic
operations; or the JUMP instruction, which may be conditional or unconditional, absolute or relative.
Each instruction has a fixed width of 32 bits. A series of instructions can make a program be executed by the
ULP coprocessor. The execution flow inside the program uses 32-bit addressing. The program is stored in a
dedicated region called Slow Memory (RTC_SLOW_MEM), which is visible to the main CPUs as one that has
an address range of 0x5000_0000 to 0x5000_1FFF (8 KB).
The OpCode in this chapter is represented by 4’dx, where 4 stands for 4-bit width, ’d is a decimal symbol, x
stands for the value of OpCode (x: 0 ~ 15).
The ALU instruction, which has one OpCode, can perform various different arithmetic and logic operations,
depending on the setting of the instruction’s bits [27:21] accordingly.
When bits [27:25] of the instruction in Figure 30-3 are set to 3’b0, ALU performs operations, using the ULP
coprocessor register R[0-3]. The types of operations depend on the setting of the instruction’s bits [24:21]
presented in Table 30-1.
Note:
• All ALU operations can be used to set/clear the zero flag in ALU.
Figure 30-4. Instruction Type — ALU for Operations with Immediate Value
When bits [27:25] of the instruction in Figure 30-4 are set to 3’b1, ALU performs operations, using register
R[0-3] and the immediate value stored in [19:4]. The types of operations depend on the setting of the
instruction’s bits [24:21] presented in Table 30-2.
Note:
• All ALU operations can be used to set/clear the zero flag in ALU.
Figure 30-5. Instruction Type — ALU for Operations with Stage Count Register
ALU is also able to increment/decrement by a given value, or reset the 8-bit register Stage_cnt. To do so, bits
[27:25] of instruction in Figure 30-5 should be set to 3’b2. The type of operation depends on the setting of
the instruction’s bits [24:21] presented in Table 30-3. The Stage_cnt is a separate register and is not a part of
the instruction in Figure 30-5.
Note:
• Data from Rsrc is always stored in the lower 16 bits of a memory word. Differently put, it is not possible to
store Rsrc in the upper 16 bits of memory.
• The ”Mem” written is the RTC_SLOW_MEM memory. Address 0, as seen by the ULP coprocessor,
corresponds to address 0x50000000, as seen by the main CPUs.
The instruction loads the lower 16-bit half-word from memory with address Rsrc + offset into the destination
register Rdst:
• In any case, it is always the lower 16 bits of a memory word that are loaded. Differently put, it is not
possible to read the upper 16 bits.
• The ”Mem” loaded is the RTC_SLOW_MEM memory. Address 0, as seen by the ULP coprocessor,
corresponds to address 0x50000000, as seen by the main CPUs.
Note:
All jump addresses are expressed in 32-bit words.
Note:
All jump addresses are expressed in 32-bit words.
30.4.6 JUMPS – Jump to a Relative Address (Conditional upon Stage Count Register)
31 28 27 25 24 17 16 15 7 0
• A description of how to set the stage count register is provided in section 30.4.1.3.
Description
The instruction prompts a jump to a relative address if the above-mentioned condition is true. The condition
itself is the result of comparing the value of Stage_cnt (stage count register) and the Threshold value.
4’d11
Description
The instruction ends the operation of the processor and puts it into power-down mode.
Note:
After executing this instruction, the ULP coprocessor timer gets started.
1’b1
4’d9 3’b0
Description
This instruction sends an interrupt from the ULP coprocessor to the RTC controller.
• If the SoC is in Deep-sleep mode, and the ULP wake-up is enabled, the above-mentioned interrupt will
wake up the SoC.
• If the SoC is not in Deep-sleep mode, and the ULP interrupt bit (RTC_CNTL_ULP_CP_INT_ENA) is set in
register RTC_CNTL_INT_ENA_REG, a RTC interrupt will be triggered.
4’d4 Cycles
Description
The instruction prompts the taking of measurements with the use of ADC. Pads/signals available for ADC
measurement are provided in Table 30-4.
Description
Communicate (read/write) with external I²C slave devices. Details on using the RTC I²C peripheral are provided
in section 30.6.
Note:
When working in master mode, RTC_I2C samples the SDA input on the negative edge of SCL.
R0 = REG[Addr][High:Low]
In case of more than 16 bits being requested, i.e. High - Low + 1 > 16, then the instruction will return
[Low+15:Low].
Note:
• This instruction can access registers in RTC_CNTL, RTC_IO, SENS and RTC_I2C peripherals. The address
of the register, as seen from the ULP coprocessor, can be calculated from the address of the same
register on the DPORT bus, as follows:
addr_ulp = (addr_dport - DR_REG_RTCCNTL_BASE)/4
• The addr_ulp is expressed in 32-bit words (not in bytes), and value 0 maps onto the
DR_REG_RTCCNTL_BASE (as seen from the main CPUs). Thus, 10 bits of address cover a 4096-byte
range of peripheral register space, including regions DR_REG_RTCCNTL_BASE, DR_REG_RTCIO_BASE,
DR_REG_SENS_BASE and DR_REG_RTC_I2C_BASE.
The instruction prompts the writing of up to 8 bits from an immediate data value into a peripheral register.
REG[Addr][High:Low] = Data
If more than 8 bits are requested, i.e. High - Low + 1 > 8, then the instruction will pad with zeros the bits above
the eighth bit.
Note:
See notes regarding addr_ulp in section 30.4.13 above.
In a typical power-saving scenario, the ULP coprocessor operates while the main CPUs are in deep sleep. To
save power even further, the ULP coprocessor can get into sleep mode, as well. In such a scenario, there is a
specific hardware timer in place to wake up the ULP coprocessor, since there is no software program running
at the same time. This timer should be configured in advance by setting and then selecting one of the
SENS_ULP_CP_SLEEP_CYCn_REG registers that contain the expiration period. This can be done either by the
main program, or the ULP program with the REG_WR and SLEEP instructions. Then, the ULP timer should be
enabled by setting bit RTC_CNTL_ULP_CP_SLP_TIMER_EN in the RTC_CNTL_STATE0_REG register.
The ULP coprocessor puts itself into sleep mode by executing the HALT instruction. This also triggers the ULP
timer to start counting RTC_SLOW_CLK ticks which, by default, originate from an internal 150 kHz RC oscillator.
Once the timer expires, the ULP coprocessor is powered up and runs a program with the program counter
(PC) which is stored in register SENS_PC_INIT. The relationship between the described signals and registers is
shown in Figure 30-19.
On reset or power-up the above-mentioned ULP program may start up only after the expiration of
SENS_ULP_CP_SLEEP_CYC0_REG, which is the default selection period of the ULP timer.
A sample operation sequence of the ULP program is shown in Figure 30-20, where the following steps are
executed:
2. The ULP timer expires and the ULP coprocessor starts running the program at PC = SENS_PC_INIT.
3. The ULP program executes the HALT instruction; the ULP coprocessor is halted and the timer gets
restarted.
4. The ULP program executes the SLEEP instruction to change the sleep timer period register.
5. The ULP program, or software, disables the ULP timer by using bit RTC_CNTL_ULP_CP_SLP_TIMER_EN.
The specific timing of the wakeup, program execution and sleep sequence is governed by the ULP FSM as
follows:
1. On the ULP timer expiration the FSM wakes up the ULP and this process takes two clock cycles.
2. Then, before executing the program, the FSM waits for the number of cycles configured in
RTC_CNTL_ULPCP_TOUCH_START_WAIT field of the RTC_CNTL_TIMER2_REG register. This time is spent
waiting for the 8 MHz clock to get stable.
4. After calling HALT instruction, the program is stopped. The FSM requires additional two clock cycles to
put the ULP to sleep.
1. Set the low and high SCL half-periods by using RTC_I2C_SCL_LOW_PERIOD_REG and
RTC_I2C_SCL_HIGH_PERIOD_REG in RTC_FAST_CLK cycles (e.g. RTC_I2C_SCL_LOW_PERIOD=40,
RTC_I2C_SCL_HIGH_PERIOD=40 for 100 kHz frequency).
2. Set the number of cycles between the SDA switch and the falling edge of SCL by using
RTC_I2C_SDA_DUTY_REG in RTC_FAST_CLK (e.g. RTC_I2C_SDA_DUTY=16).
3. Set the waiting time after the START condition by using RTC_I2C_SCL_START_PERIOD_REG (e.g.
RTC_I2C_SCL_START_PERIOD=30).
4. Set the waiting time before the END condition by using RTC_I2C_SCL_STOP_PERIOD_REG (e.g.
RTC_I2C_SCL_STOP_PERIOD=44).
7. Write the address(es) of external slave(s) to SENS_I2C_SLAVE_ADDRn (n: 0-7). Up to eight slave
addresses can be pre-programmed this way. One of these addresses can then be selected for each
transaction as part of the ULP I²C instruction.
Once RTC_I2C is configured, instructions ULP I2C_RD and I2C_WR can be used.
2. Master sends slave address, with r/w bit set to 0 (“write”). Slave address is obtained from
SENS_I2C_SLAVE_ADDRn, where n is given as an argument to the I2C_RD instruction.
4. Master sends slave register address (given as an argument to the I2C_RD instruction).
1 2 3 4 5 6 7 8 9 10
RSTRT
START
NACK
STOP
Master Slave Address W Reg Address Slave Address R
ACK
ACK
Slave Data
Note:
The RTC_I2C peripheral samples the SDA signals on the falling edge of SCL. If the slave changes SDA in less
than 0.38 microseconds, the master will receive incorrect data.
The byte received from the slave is stored into the R0 register.
2. Master sends slave address, with r/w bit set to 0 (“write”). Slave address is obtained from
SENS_I2C_SLAVE_ADDRn, where n is given as an argument to the I2C_WR instruction.
4. Master sends slave register address (given as an argument to the I2C_WR instruction).
1 2 3 4 5 6 7 8 9 10
RSTRT
START
STOP
ACK
ACK
Slave
Note:
Interrupts from RTC_I2C are not connected. The interrupt registers above are listed only for debugging
purposes.
30.8 Registers
30.8.1 SENS_ULP Address Space
The addresses in parenthesis besides register names are the register addresses relative to (the RTC base
address + 0x0800). The RTC base address is provided in Table 1-6 Peripheral Address Mapping in Chapter 1
System and Memory. The absolute register addresses are listed in Section 30.7.1 SENS_ULP Address
Space.
31 0
20 Reset
SENS_ULP_CP_SLEEP_CYCn_REG ULP timer cycles setting n; the ULP coprocessor can select one
of such registers by using the SLEEP instruction. (R/W)
P
TO
T_
AR
RC OP
ST
E_
FO T_T
P_ AR
_C ST
LP P_
T
NI
_U _C
I
C_
NS LP
)
NS d)
)
ed
ed
SE rve
SE _U
_P
rv
rv
NS
se
se
se
(re
(re
(re
SE
31 22 21 11 10 9 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SENS_ULP_CP_START_TOP Set this bit to start the ULP coprocessor; it is active only when
SENS_ULP_CP_FORCE_START_TOP = 1. (R/W)
R0
R1
DD
DD
_A
_A
E
E
AV
AV
L
L
_S
_S
)
2C
2C
ed
_I
_I
rv
NS
NS
se
(re
SE
SE
31 22 21 11 10 0
R2
R3
DD
DD
_A
_A
E
E
AV
AV
L
SL
_S
C_
)
2C
ed
2
_I
_I
rv
NS
NS
se
(re
SE
SE
31 22 21 11 10 0
R
DD
DD
_A
_A
E
E
AV
AV
L
L
_S
_S
)
2C
2C
ed
_I
rv
S_
NS
se
N
(re
SE
SE
31 22 21 11 10 0
R6
R7
DD
DD
_A
_A
TA
E
E
AV
AV
ON
DA
L
_D
_R
_S
_S
NS d)
2C
2C
2C
2C
SE rve
_I
_I
_I
_I
NS
NS
NS
se
(re
SE
SE
SE
31 30 29 22 21 11 10 0
RL
2C TA
T
_C
_I _S
AR 2C
2C
_S _I
I
R_
NS AR
NS )
ed
A
SE _S
_S
rv
NS
se
(re
SE
SE
31 30 29 28 27 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
OD
RI
E
_P
OW
_L
CL
_S
)
ed
2C
rv
I
se
C_
(re
RT
31 19 18 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
E_ T
OU
RC OU
(re C_ ANS FIR T
se MS _S ST
OD RT
I2 R B_ RS
FO E_
_M TA
C_ C_T LS FI
A_ RC
E
RT _I2 TX_ SB_
SD FO
C_ L_
C C_ L
RT _I2 RX_
I2 SC
)
RT ed)
C C_
C_ C_
ed
RT _I2
RT I2
rv
rv
se
C_
C
(re
RT
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
CH
AT
C C_ B_ SY M
RT _I2 AR BU DR_
RT _I2 BU E_A S
E
C C_ V AN
AC E_ T
AT
E
K_ RW
C_ C_ ED T
C C_ S_ D
C_ AV U
AT
L
ST
VA
_
N_
L_
C C_ E
RT _I2 BYT
AI
SC
I2 L
M
S
)
d)
C_
C_
C C_
ed
ve
I2
I2
RT _I2
rv
r
se
se
C_
C_
C
(re
(re
RT
RT
RT
31 30 28 27 25 24 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_I2C_ARB_LOST Indicates the loss of I2C bus control, when in master mode. (R/W)
RTC_I2C_SLAVE_RW Indicates the value of the received R/W bit, when in slave mode. (R/W)
2C
rv
I
se
C_
(re
RT
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_I2C_TIMEOUT Maximum number of RTC_FAST_CLK cycles that the transmission can take.
(R/W)
T
BI
0
_1
DR
R
DD
AD
_A
E_
E
AV
AV
L
L
_S
_S
d)
2C
2C
ve
r
I
I
se
C_
C_
(re
RT
RT
31 30 15 14 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LR
R
ET R _C
CL
PL L T
T_
M T_C _IN
IN
AN LO MP LR
CO IN TE
E_
TR _ O _C
S_ ST_ LE
E_ ION _C NT
AV AT NS _I
I2 AR ER MP LR
SL TR RA TE
C_ C_ ST O _C
C_ BI _T LE
RT _I2 MA S_C INT
C C_ N T_
RT _I2 TRA OU
C C_ E_
RT _I2 TIM
)
)
C C_
ed
ed
RT _I2
rv
rv
se
se
C
(re
(re
RT
31 9 8 7 6 5 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_E NA
NA
NT E
ST _IN A
_I T_
LO MP EN
N_ O T_
IO _C IN
AT AN E_
BI _T PLE A
AR TER M EN
TR R T
C_ S O _
I2 MA _C INT
C_ C_ NS T_
RT _I2 TRA OU
C C_ E_
RT _I2 TIM
d)
)
C C_
ed
ve
RT _I2
rv
r
se
se
C
(re
(re
RT
31 9 8 7 6 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_S T
NT S
_I T_
T
LO MP ST
ST _IN
N_ O T_
IO _C IN
AT AN E_
AR TER M ST
TR R T
BI _T PLE
C_ S O _
I2 MA _C INT
C_ C_ NS T_
RT _I2 TRA OU
C C_ E_
RT _I2 TIM
)
)
C C_
ed
ed
RT _I2
rv
rv
se
se
C
(re
(re
RT
31 8 7 6 5 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TY
_ DU
DA
_S
d)
2C
ver
I
se
C_
(re
RT
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_I2C_SDA_DUTY Number of RTC_FAST_CLK cycles between the SDA switch and the falling
edge of SCL. (R/W)
OD
RI
PE
_
GH
HI
C L_
_S
)
ed
2C
rv
I
se
C_
(re
31 20 19 RT 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
2C
rv
I
se
C_
(re
RT
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
IO
ER
_P
OP
ST
C L_
_S
)
ed
2C
rv
I
se
C_
(re
RT
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31.1 Introduction
ESP32 offers efficient and flexible power-management technology to achieve the best balance between power
consumption, wakeup latency and available wakeup sources. Users can select out of five predefined power
modes of the main processors to suit specific needs of the application. In addition, to save power in power-
sensitive applications, control may be executed by the Ultra-Low-Power coprocessor (ULP coprocessor), while
the main processors are in Deep-sleep mode.
31.2 Features
• Five predefined power modes to support various applications
• Up to 16 KB of retention memory
31.3.1 Overview
The low-power management unit includes voltage regulators, a power controller, power switch cells, power do-
main isolation cells, etc. Figure 31-1 shows the high-level architecture of ESP32’s low-power management.
1. When XPD_DIG_REG == 1, the regulator outputs a 1.1V voltage and the digital core is able to run; when
XPD_DIG_REG == 0, both the regulator and the digital core stop running.
3. The current to the digital core comes from pin VDD3P3_CPU and pin VDD3P3_RTC.
90
1. When the pin CHIP_PU is at a high level, the low-power voltage regulator cannot be turned off. It should
be switched only between normal-work mode and Deep-sleep mode.
3. In Deep-sleep mode, the output voltage of the regulator is fixed at about 0.75V.
90
1. When XPD_SDIO_VREG == 1, the regulator outputs a voltage of 3.3V or 1.8V; when XPD_SDIO_VREG == 0,
the output is high-impedance and, in this case, the voltage is provided by the external power supply.
2. When SDIO_TIEH == 1, the regulator shorts pin VDD_SDIO to pin VDD3P3_RTC. The regulator then outputs
a voltage of 3.3V which is the voltage of pin VDD3P3_RTC. When SDIO_TIEH == 0, the inner loop ties the
regulator output to the voltage of VREF, which is typically 1.8V.
3. DREFH_SDIO, DREFM_SDIO and DREFL_SDIO could be used to tune the reference voltage VREF slightly.
However, it is recommended that users do not change the value of these registers, since it may affect the
stability of the inner loop.
4. When the regulator output is 3.3V or 1.8V, the output current comes from the pin VDD3P3_RTC.
1. As the output of the brownout detector, RTC_CNTL_BROWN_OUT_DET goes high when the voltage of
pin VDD3P3_RTC is lower than the threshold value.
• Digital & analog power controller: generates actual power-gating/clock-gating signals for digital parts and
analog parts.
• Sleep & wakeup controller: handles the entry into & exit from the low-power mode.
• Timers: include RTC main timer, ULP coprocessor timer and touch timer.
• Low-Power processor and sensor controllers: include ULP coprocessor, touch controller, SAR ADC con-
troller, etc.
• Retention memory:
– RTC slow memory: an 8 KB SRAM, mostly used as retention memory or instruction & data memory
for the ULP coprocessor. The CPU accesses it through the APB, starting from address 0x50000000.
– RTC fast memory: an 8 KB SRAM, mostly used as retention memory. The CPU accesses it through
IRAM0/DRAM0. Fast RTC memory is about 10 times faster than the RTC slow memory.
For the RTC core, there are five possible clock sources:
• internal 31.25-kHz clock RC_FAST_DIV_CLK (derived from the internal 8-MHz oscillator divided by 256).
With these clocks, RTC_FAST_CLK and RTC_SLOW_CLK is derived. By default, RTC_FAST_CLK is RC_FAST_CLK
ESP32
while RTC_SLOW_CLK is RC_SLOW_CLK. For details, please see Figure 31-7.
Selection Signal
RTC Timer
RC_SLOW_CLK
0
XTL32K_CLK
RTC_SLOW_CLK
1 RTC Main State
RC_FAST_DIV_CLK
2
PMU
RTC Slow Clock
ULP Coprocessor
Selection Signal
XTAL_DIV_CLK
Sensor Controller
0
RTC_FAST_CLK
RC_FAST_CLK
1 RTC Memory
RTC Clock
For the digital core, LOW_POWERE_CLK is switched among four sources. For details, please see Figure 31-
8.
Selection Signals
RC_SLOW_CLK
RTC_SLOW_CLK
LP_MUX
LOW_POWER_CLK
Wireless
RC_FAST_CLK
XTL_CLK
Low-power Clock
31.3.8 Power-Gating Implementation
The switch among power-gating states can be see in Figure 31-9. The actual power-control signals could also
be set by software as force-power-up (FPU) or force-power-down (FPD). Since the power domains can be
power-gated independently, there are many combinations for different applications. Table 31-1 shows how the
power domains in ESP32 are controlled.
• Active mode
– The CPU is clocked at XTAL_DIV_N (40 MHz/26 MHz) or PLL (80 MHz/160 MHz/240 MHz).
• Modem-sleep mode
– The Wi-Fi/Bluetooth baseband is clock-gated or powered down. The radio is turned off.
– Immediate wake-up.
• Light-sleep mode
– The internal 8 MHz oscillator, 40 MHz high-speed crystal, PLL, and radio are disabled.
– The clock in the digital core is gated. The CPUs are stalled.
– The ULP coprocessor and touch controller can be periodically triggered by monitor sensors.
• Deep-sleep mode
– The internal 8 MHz oscillator, 40 MHz high-speed crystal, PLL and radio are disabled.
• Hibernatation mode
– The internal 8 MHz oscillator, 40 MHz high-speed crystal, PLL, and radio are disabled.
– The RTC memory and fast RTC memory are powered down.
By default, ESP32-S2 first enters the Modem-sleep mode after a system reset and can be configured to Active
mode when transmitting or receiving packets. After the CPU stalls for a while, the chip can enter several low-
power modes. It is up to the user to select the mode that best balances power consumption, wake-up latency
and available wake-up sources. For details, please see Figure 31-10.
Please note that the predefined power mode could be further optimized and adapted to any application.
All the wakeup sources specified in Table 31-2 (except UART) can also be configured as the causes to reject
sleep.
Users can configure the reject to sleep option via the following registers.
• Configure the RTC_CNTL_SLP_REJECT field to enable or disable the option to reject to sleep:
The RTC timer can be used to wake up the CPU at a designated time, and to wake up TOUCH or the ULP
coprocessor periodically.
3. When the CPU is powered up, the reset vector starts from 0x50000000, instead of 0x40000400. ROM
unpacking & SPI boot are not needed. The code in RTC memory has to do itself some initialization for the
C program environment.
2. Calculate CRC for the fast RTC memory, and save the result in register RTC_CNTL_RTC_STORE6_REG[31:0].
3. Input register RTC_CNTL_RTC_STORE7_REG[31:0] with the entry address in the fast RTC memory.
5. When the CPU is powered up, after ROM unpacking and some necessary initialization, the CRC is calcu-
lated again. If the result matches with register RTC_CNTL_RTC_STORE6_REG[31:0], the CPU will jump to
the entry address.
• The registers listed below have been grouped according to their functionality. This particular grouping
does not reflect the exact sequential order in which they are stored in memory.
• The base address for registers is 0x60008000 when accessed by AHB, and 0x3FF48000 when accessed
by DPORT bus.
31.5 Registers
The addresses in parenthesis besides register names are the register addresses relative to the Low-power
Management (RTC) base address provided in Table 1-6 Peripheral Address Mapping in Chapter 1 System and
Memory. The absolute register addresses are listed in Section 31.4 Register Summary.
RS T
E_ RS
C0
RT _CN L_B S_I RE_ ORC _PU
RT CN _B S_I _F OLW _PD
RT NTL W_ C_ RC CE_ U
CN SW RO RC PU D
RT _CN L_X _F EEP SLE EEP
_C
RT _CN L_B S_I _F CE 8M
RC NO
C _S I2 FO R _P
_ P FO E_ P
RT _CN L_B S_F _F CE U
RT CN _B S_F RCE W_ D
U_
C T IA O _ 8M
C T TL OR _F EP
PU
C T B OR _P W_
C T IA 2C OR _P
C_ TL IA O OL _P
PC U_ PD
C T TL L _ SL
C T IA O F E
C_ TL IA 2C F E
C T IA 2C OR _
C_ TL B_ C_ FO E
FO E_
C T B _I CE U
C T B _I F D
CP
RT _CN L_B S_C RE_ ORC
ST U_R T
ST
RT _CN L_B PLL OR _P
RT _CN L_B PLL 2C_ _P
OC
RT _CN L_B _F CE OL
RT _CN L_X S_S RCE NO
TL _AP CP E_
P RS
P_ RC
RT CN _B LL OR D
PP
C T B _F CE
C_ TL BP _F _P
R
C T IA O F
RA O
G_ RA T
_P
_A
RT _CN L_B S_C RE_
W P_F
_D W RS
LL
LL
TL G_ S_
C T IA O
TA
RT _CN L_B S_C
CN _D SY
_S
C_ TL W_
_
C T IA
W
RT _CN L_B
RT _CN L_S
_S
_S
TL
)
ed
C T
C T
RT _CN
RT _CN
CN
rv
se
C_
C_
C
C
(re
RT
RT
RT
31 30 29 28 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_DG_WRAP_FORCE_RST The digital core can force a reset in deep sleep. (R/W)
31 0
0x000000000 Reset
HI
M
L_
TI
VA
N_
P_
AI
SL
M
L_
L_
)
ed
NT
NT
rv
C
se
C_
C_
(re
RT
RT
31 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00000 Reset
VA TE
E_ DA
D
LI
IM UP
_T E_
TL IM
CN _T
C_ TL
d)
ve
RT _CN
r
se
C
(re
RT
31 30 29 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0x000000000 Reset
HI
E_
M
TI
L_
)
ed
NT
rv
C
se
C_
(re
RT
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00000 Reset
ER N
N
IM _E
_E
_T ER
ND
LP IM
_I
_S P_T
AC P
VE
DI AK T
O_ EU
_S _W EC
CH SL
TI
CN _S _R N
OU P_
C_ TL LP _E
TL LP EJ
_T _C
RT _CN L_S EP
TL LP
C T LE
CN _U
RT _CN L_S
C_ TL
)
d)
ed
C T
ve
RT _CN
RT N
rv
r
se
C_
se
C
(re
(re
RT
RT
31 30 29 28 27 25 24 23 22 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
N
_E
LL
A
ST
U_
CP
L_
)
ed
NT
rv
C
se
C_
(re
31 1
RT
0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
T
AI
_W
F
RT
F
_O
TA
_S
8M
H
CK
UC
E_
TO
M
P_
I
_T
PC
IN
UL
M
L_
L_
)
ed
NT
NT
rv
C
se
C_
C_
(re
RT
RT
31 24 23 15 14 0
L
VA
P_
L
_S
IN
M
L_
)
)
ed
ed
T
CN
rv
rv
se
se
C_
(re
(re
RT
31 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x080 0 0 0 0 0 0 0 0 Reset
RC PU
PD
M _P U
U
C d VT 2C _P
FO E_
E_
_P
ON U
U
EN PU
RT rve _P F_I US
A _ RC
_P
2C
C_ d) KG C_
se TL XR PB
LL FO
_I
RT rve L_C _I2
(re CN _T _
_P A _
X
C_ TL FR
se T LL
TL LL
(re _CN L_P
CN _P
RT _CN L_R
C_ TL
RT _CN )
d)
C T
C T
ve
RT _CN
RT CN
r
se
C
(re
RT
31 30 29 28 27 26 25 24 23 22 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
U
U
CP
CP
_V TO
RO
PP
AT C
ST _VE
_P
_A
U_ AT
SE
SE
CP _ST
AU
AU
_C
_C
PP PU
ET
ET
_A C
TL RO
ES
ES
CN _P
_R
_R
C_ TL
TL
TL
)
ed
RT _CN
CN
CN
rv
se
C_
C_
C
(re
RT
RT
RT
31 14 13 12 11 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 x x x x x x x x x x x x Reset
ER
ILT
F
E
P_
US
NA
EU
CA
E
AK
P_
P_
_W
EU
EU
IO
AK
AK
GP
W
L_
L_
L_
)
ed
NT
T
CN
CN
rv
C
se
C_
C_
C_
(re
RT
RT
RT
31 23 22 21 11 10 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0x000 Reset
A
RT _CN L_T _C NT_ INT NA
IN NA
EN
A
EU INT A
C T IM P_ E _E
TL LP IDL A EN
C T LP _I T_ _E
P_ _E
AK T_ EN
T_
RT _CN L_U CH OU INT
_W EC T_
C_ TL DI T_ IN
C T D AL _E
C T OU N_ _
LP EJ IN
RT _CN L_T W ER
_S _R E_
C T RO TIM
RT _CN L_B IN_
C T A
RT _CN L_M
)
ed
C T
RT _CN
rv
se
C
(re
RT
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_WDT_INT_ENA The interrupt enable bit for the RTC_CNTL_WDT_INT interrupt. (R/W)
W
RT _CN L_T _C NT_ INT AW
IN AW
W
RA
AK T_ RAW
C T IM P_ R _R
C T LP _I T_ _R
TL LP IDL W RA
P_ _R
T_
RT _CN L_S T_IN ID_ AW
RT _CN L_U CH OU INT
CN _S O_ RA T_
EU INT
_W EC T_
C_ TL DI T_ IN
C T D AL _R
C T OU N_ _
LP EJ IN
RT _CN L_T W ER
_S _R E_
C T RO TIM
RT _CN L_B IN_
C T A
RT _CN L_M
d)
C T
ve
RT _CN
r
se
C
(re
RT
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_TOUCH_INT_RAW The raw interrupt status bit for the RTC_CNTL_TOUCH_INT interrupt.
(RO)
RTC_CNTL_ULP_CP_INT_RAW The raw interrupt status bit for the RTC_CNTL_ULP_CP_INT interrupt.
(RO)
RTC_CNTL_WDT_INT_RAW The raw interrupt status bit for the RTC_CNTL_WDT_INT interrupt. (RO)
ST
RT _CN L_T _IN NT_ INT T
IN T
C T IM T_ S _S
C T AR _I T_ _S
ST
P_ _S
AK T_ ST
T_
RT _CN L_S CH OU INT
CN _S O_ ST T_
EU INT
_W EC T_
RT _CN L_W E_V ST T
C_ TL DI T_ IN
C T OU N_ _
LP J N
RT CN _S _IN ID_
RT _CN L_T W ER
I
_S _R E_
C T RO TIM
C_ TL D AL
TL LP IDL
E
RT _CN L_B IN_
T
C T A
RT _CN L_M
d)
C T
ve
RT _CN
r
se
C
(re
RT
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_TOUCH_INT_ST The masked interrupt status bit for the RTC_CNTL_TOUCH_INT inter-
rupt. (RO)
RTC_CNTL_SAR_INT_ST The masked interrupt status bit for the RTC_CNTL_SAR_INT interrupt.
(RO)
RTC_CNTL_WDT_INT_ST The masked interrupt status bit for the RTC_CNTL_WDT_INT interrupt.
(RO)
R
RT _CN L_T _IN NT_ INT LR
IN LR
CL
TL LP IDL R CLR
AK T_ CLR
C T IM T_ C _C
C T AR _I T_ _C
P_ _C
T_
RT _CN L_S CH OU INT
CN _S O_ CL T_
EU INT
_W EC T_
C_ TL DI T_ IN
C T OU N_ _
LP EJ IN
C T D AL R
RT _CN L_S T_IN ID_
RT _CN L_T W ER
_S _R E_
C T RO TIM
RT _CN L_B IN_
C T A
RT _CN L_M
)
ed
C T
RT _CN
rv
se
C
(re
RT
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
P
EU
L
DE
AK
I
N_
W
R_
I
E_
FO
AT
Y_
ST
RD
N_
C_
AI
RT
M
L_
L_
)
d)
d)
ed
NT
T
ve
ve
CN
rv
r
se
se
se
C_
C_
(re
(re
(re
RT
RT
31 28 27 26 20 19 18 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
– in sleep modes.
(RO)
)
ed
RT _CN
rv
se
C
(re
RT
31 30 29 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_XTL_EXT_CTR_LV 0: power down XTAL at high level, 1: power down XTAL at low level.
(R/W)
V
P0 V
_L
EU _L
AK P1
_W EU
XT AK
_E _W
T L XT
CN _E
C_ TL
d)
ve
RT _CN
r
se
C
(re
RT
31 30 29 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
N
_E
SE
TL DI SL REJ
AU
CN _S HT_ P_
_C
C_ TL IG SL
CT
RT CN _L P_
JE
C_ TL EE
RE
RT CN _D
L_
C_ TL
)
ed
NT
RT CN
rv
C
se
C_
C_
(re
RT
RT
31 28 27 26 25 24 23 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
NF EL
CO _S
L_ IOD
R
PU UPE
P
SE
_C
CN RTC
_C
_
RT NTL
TL
d)
ve
C
r
C_
se
C_
(re
RT
31 30 29 28 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_ M EN EN
_S SEL
CE U
D
AS C_S
_ _ 3 25
OR _P
_P
_
M IV
C _E _X 8M N
L
C_ TL C_C CLK
RT NTL NB TAL _D
EL
C_ TL IG LK _E
_C CK8 _D
SE
_F CE
EQ
T
TC K_R
RT _CN L_D _C 8M
IV_
M R
FR
_
V
T
K8 _FO
LK
DI
_D
_D
C T IG LK
L
_
RT NTL A_C
_F
RT CN _D _C
_C M
8M
M
TL K8
K8
K8
C_ TL IG
N
CK
RT CN _D
CN _C
_C
_A
_R
_S
L_
RT NTL
RT NTL
TL
C_ TL
TL
)
C_ d)
)
ed
ed
NT
RT rve
RT CN
CN
RT CN
rv
rv
C
C
se
C_
C_
se
se
C_
C_
C_
C_
C_
(re
(re
(re
RT
RT
RT
31 30 29 28 27 26 25 24 17 16 15 14 12 11 10 9 8 7 6 5 4 3 0
0 0 0 0 0 0 0 0 2 0 0 1 0 0 0 0 1 0 0 0 0 Reset
RTC_CNTL_DIG_CLK8M_EN Enable CK8M for digital core (no relation to RTC core). (R/W)
RTC_CNTL_DIG_XTAL32K_EN Enable XTL32K_CLK for digital core (no relation to RTC core). (R/W)
RTC_CNTL_CK8M_DIV RC_FAST_DIV_CLK divider. 00: div128, 01: div256, 10: div512, 11: div1024.
(R/W)
EN
D_
_S EG
_S O_ H Y
TL DI TIE AD
_P
R
O
O
VR E
O
RE O_V
DI
O_ RC
CN _S _ E
DI
DI
EG
R
_S
_S
C_ TL DI 8_
DI FO
_D SDI
FM
FH
C_ TL EFL
RT _CN L_S 1P
_
O
RE
C T EG
CN XPD
R
_D
C_ L_D
RT CN _R
_
RT NTL
TL
TL
)
ed
T
CN
CN
RT N
rv
C
C
C_
se
C_
C_
C_
(re
RT
RT
RT
RT
31 30 29 28 27 26 25 24 23 22 21 20 0
0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
AK
PL
RC PU
PD
_S
S_
_D O RC PU
FO E_
E_
OS FO PD
AS
IA
T_ RC
TL BO FO E_
BO ST_ E_
BI
B
_D
_D
CN _D G_ RC
LP
AP
A
EG
EG
C_ TL RE FO
_S
DC
S_
VR
VR
RT _CN L_P G_
AS
K_
G_
G_
A
C T RE
BI
BI
SC
DI
DI
_D
_D
RT _CN L_P
L_
L_
L_
TL
TL
d)
C T
NT
NT
ve
RT _CN
CN
CN
CN
C
r
se
C_
C_
C_
C_
C_
C
(re
RT
RT
RT
RT
RT
RT
31 30 29 28 27 25 24 22 21 14 13 11 10 8 7 0
1 0 1 0 4 4 0 4 4 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_VREG_FORCE_PD RTC voltage regulator - force power down (in this case power down
means decreasing the voltage to 0.8V or lower). (R/W)
CE SO O
SO
OR _I IS
C T AS EM FO E_ U
C T AS EM O _C D
EM FO CE_ O
RT _CN L_F CE _F RCE LPU
RT _CN L_S CE OI LW_ LPD
_F RCE NO
RT CN _F TM _P RC PU
OI
RT _CN L_F TM M_ RC LP
RT _CN L_F TM _F LW LP
RT CN _S WM M_ RCE PU
PU
RT _CN L_F WM M_ RC PD
TM _ R IS
_N
C_ TL AS EM FO E_
C T AS EM D E_
C T AS E FO E_
AS EM FO E_
C_ TL LO E O _
C T LO E FO _
C T OR EM O _
C T OR _N O _
C T LO _I SO C
C T AS E FO N
_F TM M_ RC
RT _CN L_F WM M_ _E
C T LO E PD
TL AS ME FO
C T LO EM O
RT _CN L_S WM M_
CN _F W M_
RT _CN L_S WM SO
RT CN _S CE U
RT _CN L_S WM D
C_ TL OR _P
C T LO _P
C T LO E
C_ TL LO E
RT _CN L_F EN
RT _CN L_F CE
C T D_
C T OR
RT _CN L_P
)
ed
C T
RT _CN
rv
se
C
(re
RT
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 1 Reset
C T NT R 1_ RC PU
TL SL _F CE RC PU
C T NT R 1_ C PD
SL ME CE U PD
C T NT R 2_ RC PU
C T NT R 3_ RC PU
C T NT R 2_ RC PD
C T NT R 3_ RC PD
C T O R 0_ C U
C_ TL OM _F 0_ RC D
CE U
D
RT _CN L_R ER_ AM FOR E_P
RT _CN L_R M0 AM FO E_P
RT _CN L_I ER_ AM FO E_
RT _CN L_I ER_ AM FOR E_
CN _L 0 OR FO E_
_L P_ OR _P E_
RT _CN L_I ER_ AM FO E_
RT _CN L_I ER_ AM FO E_
RT _CN L_I ER_ AM FO E_
RT _CN L_I ER_ AM FO E_
OR _P
_P
RT _CN L_I I_F CE RCE U
RT _CN L_I ER_ CE U D
0_ M D_ N
N
_R ER AM PD N
CN _I ER AM PD N
PD 0_ EN
C T IF OR O _P
C T NT OR _P _P
C T NT R 4_ RC
OM _R 1_ _E
N _E
TL NT _R 2_ _E
C_ TL NT R 3_ _E
_F RCE
M _F D
RT _CN L_I ER_ EN _EN
RT CN _W I_F P_F CE
_E PD
RT _CN L_I ER_ AM PD
P_ M _P
RT _CN L_I ER_ AM D
A P
EM O
C_ TL IF A OR
C T NT R _P
C T NT R 4_
C T NT R 4_
C T NT D_ D
RT CN _I I_P P_P
C T G A
RT _CN L_W _WR
C T G
RT CN _D
RT N _D
C_ TL
C_ TL
)
)
ed
ed
RT _CN
RT CN
rv
rv
C
se
se
C_
C
(re
(re
RT
RT
31 30 29 28 27 26 25 24 23 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0
x x x x x x x x 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 Reset
D
OH N
OL
UT _E
_ A LD
AD O
_P OH
LD DG UT
RT _CN L_I ER_ AM FOR E_ ISO
HO L _ _ A
TL LR TC RC IS LD
C T NT R 1_ C ISO
C T G D_ CE OI ISO
C T NT R 2_ RC ISO
C T NT R 3_ RC ISO
C T NT R 1_ RC NO
C T G _F CE RC NO
C T NT R 2_ RC NO
C T NT R 3_ RC NO
C_ TL NT OR _N _I SO
C T O _F 0_ RC SO
TO NT AD
C T O R 0_ C O
D_ TC DG O
RT _CN L_R ER_ AM FOR E_N
CN _C _R FO E_ HO
RT _CN L_R _PA FO E_ LD
AU _C _P
RT _CN L_I I_F CE RCE OI
RT _CN L_D M0 OR FO E_
RT _CN L_I ER_ AM FO E_
RT _CN L_I ER_ AM FO E_
PA _R L_ IS
RT CN _I ER_ CE OI SO
_D _R _C E_ O
G_ EG NT NO
C T G D_ RC HO
C T IF OR O _N
C_ TL EG D_ RC UN
C T NT R 4_ RC
C T NT R _I SO
C T G D_ RC O
RT _CN L_W I_F P_F RCE
)
ed
C T
RT _CN
rv
se
C
(re
RT
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 0
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SE _R ET_ EN
H
TH
_I ES EN
P N
GT
AU U ES D_
SL _E
NG
EN
_P CP R O
N_ ET
DT PP U_ M
LE
_L
_
T_
_W _A CP OT
ET
SE
ES
TL DT RO BO
RE
_R
CN _W T_P SH
0
_
1
PU
TG
TG
TG
TG
YS
C_ TL D LA
N
_C
_S
_S
_S
_S
_S
_E
RT CN _W _F
DT
DT
DT
DT
DT
DT
DT
T
C_ TL D
W
_W
_W
_W
_W
_W
_W
RT CN _W
L_
TL
TL
TL
TL
TL
TL
C_ TL
NT
se d
ed
ed
CN
CN
CN
CN
CN
CN
RT _CN
re rve
C
rv
rv
C_
C_
C_
C_
C_
C_
C_
se
se
C
RT
RT
RT
RT
RT
RT
RT
RT
re
re
31 30 28 27 25 24 22 21 19 18 17 16 14 13 11 10 9 8 7 6 0
0 0 0 0 0 0 0 1 1 1 0 0 1 0 Reset
RTC_CNTL_WDT_STG3 1: interrupt stage enable, 2: CPU reset stage enable, 3: system reset stage
enable, 4: RTC reset stage enable. (R/W)
RTC_CNTL_WDT_STG2 1: interrupt stage enable, 2: CPU reset stage enable, 3: system reset stage
enable, 4: RTC reset stage enable. (R/W)
RTC_CNTL_WDT_STG1 1: interrupt stage enable, 2: CPU reset stage enable, 3: system reset stage
enable, 4: RTC reset stage enable. (R/W)
RTC_CNTL_WDT_STG0 1: interrupt stage enable, 2: CPU reset stage enable, 3: system reset stage
enable, 4: RTC reset stage enable. (R/W)
31 0
0x000000FFF Reset
)
ed
NT
rv
C
se
C_
(re
RT
31 30 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0x050D83AA1 Reset
C1
1
_C
U_
PU
CP
PC
O
PR
AP
L_
L_
L
L
TA
TA
_S
_S
SW
SW
L_
L_
d)
NT
NT
ve
C
r
se
C_
C_
(re
RT
31 26 25
RT 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_SW_STALL_PROCPU_C1 reg_rtc_cntl_sw_stall_procpu_c1[5:0],
reg_rtc_cntl_sw_stall_procpu_c0[1:0] == 0x86 (100001 10) will stall PRO_CPU, see also
RTC_CNTL_OPTIONS0_REG. (R/W)
RTC_CNTL_SW_STALL_APPCPU_C1 reg_rtc_cntl_sw_stall_appcpu_c1[5:0],
reg_rtc_cntl_sw_stall_appcpu_c0[1:0] == 0x86 (100001 10) will stall APP_CPU, see also
RTC_CNTL_OPTIONS0_REG. (R/W)
31 0
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Reset
RT CN _T CH AD HO _F CE
RT _CN L_S SE HO HO _F CE
RT _CN L_P SE HO _F CE CE
RT _CN L_T CH AD HO _F CE
RT _CN L_S SE AD HO _F CE
RT _CN L_S CH AD HO _F CE
RT _CN L_S SE HO _F _F CE
RT _CN L_T CH AD HO _F CE
C_ TL OU _P 4_ LD OR
C T EN 4_ 0_ LD OR
C T EN 2_ LD OR OR
C T OU _P 3_ LD OR
C T EN _P 1_ LD OR
C T OU _P 2_ LD OR
C T EN 3_ LD LD OR
C T OU _P 5_ LD R
RT _CN L_T CH AD HO _FO
CN _A C1 O _F CE
RT _CN L_P C2 HO _F CE
_A 2_ OL FO CE
1_ OLD FO E
LD FO E
OR E
DC H D_ RC
C T OU _P _F CE
C_ TL DA _H LD OR
C T DA 1_ LD OR
CE
H O _ RC
C T OU _P 7_ CE
C T OU _P 6_ LD
TL DC _H LD_ OR
_F RC
RT CN _T CH LD OR
RT _CN L_T CH AD OR
RT _CN L_T CH AD HO
C_ TL OU HO _F
RT _CN L_T P_ LD
C T 32 HO
RT _CN L_X N_
C T 32
RT CN _X
C_ TL
d)
ve
RT _CN
r
se
C
(re
RT
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LR
C
S_
TU
L
TA
E
_S
_S
P1
P1
EU
EU
AK
AK
W
W
T_
T_
EX
EX
L_
L_
d)
T
ve
CN
CN
r
se
C_
C_
(re
RT
RT
31 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
S
TU
TA
_S
P1
EU
AK
W
T_
EX
L_
)
ed
NT
rv
C
se
C_
(re
RT
31 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
A
EN
H_
AS
E_ A
OS EN
FL
T
A
AI
S
CL F_
EN
W
RE
T_ _R
T_
T_
A
T_ T
TH
OU PD
EN
OU DE
RS
RS
T_
N_ T_
T_
T_
N_ T_
OU
W OU
OU
OU
W OU
N_
RO N_
N_
N_
RO N_
OW
_B W
_B W
TL RO
RO
RO
TL RO
BR
_D
CN _B
_B
_B
CN _B
C_ TL
TL
TL
TL
C_ TL
)
ed
RT _CN
CN
CN
CN
RT CN
rv
se
C_
C_
C_
C_
C
(re
RT
RT
RT
RT
RT
31 30 29 27 26 25 16 15 14 13 0
RTC_CNTL_DBROWN_OUT_THRES Brownout threshold. The brownout detector will reset the chip
when the supply voltage is approximately below this level. Note that there may be some variation
of brownout voltage level between each ESP32 chip. 0: 2.43 V ± 0.05; 1: 2.48 V ± 0.05; 2: 2.58
V ± 0.05; 3: 2.62 V ± 0.05; 4: 2.67 V ± 0.05; 5: 2.70 V ± 0.05; 6: 2.77 V ± 0.05; 7: 2.80 V ±
0.05. (R/W)
Glossary
Revision History
• Chapter 10 Ethernet Media Access Controller (MAC): Added a note about RMII ref-
erence clock in Section 10.6.2.1
• Chapter 17 Pulse Count Controller (PCNT): Corrected the address of
PCNT_Un_CNT_REG (n: 0-7)
• Chapter 14 LED PWM Controller (LEDC): Corrected the addresses of some registers
• Chapter 31 Low-Power Management (RTC_CNTL):
2024.08 v5.2 – Updated the description of predefined low-power modes
– Added a note about EXT1 under Table 31-2
• Chapter 4 IO_MUX and GPIO Matrix (GPIO, IO_MUX):
– Updated the description of register GPIO_STATUS_REG,
GPIO_STATUS_W1TS_REG, GPIO_STATUS_W1TC_REG, GPIO_STATUS1_REG,
GPIO_STATUS1_W1TS_REG, and GPIO_STATUS1_W1TC_REG.
– Updated the description of pad hold control in Section 4.7.
• Removed contents about hall sensor, including relevant registers, signals, etc, acc
to PCN20221202
• Renamed PLL_D2_CLK to PLL_F160M_CLK throughout the document
• Chapter 4 IO_MUX and GPIO Matrix (GPIO, IO_MUX): Added TWAI signals in Table
4-2
• Added descriptions about the break condition and updated the maximum length of
stop bits and related descriptions in Chapter 13 UART Controller (UART)
2023.04 v4.9 • Added the formula to calculate duty cycle resolution and updated Table Timers in
Chapter 14 LED PWM Controller (LEDC)
• Chapter 29 On-Chip Sensors and Analog Signal Processing:
– Added a note about limited applications of touch sensor in Section 29.2.2
Features
– Removed internal signals vdd33, pa_pkdet1, pa_pkdet2
• Added description about “reject sleep” in Chapter 31 Low-Power Management
(RTC_CNTL)