Esp32-S2 Technical Reference Manual en
Esp32-S2 Technical Reference Manual en
Version 1.1
Espressif Systems
Copyright © 2022
www.espressif.com
About This Manual
The ESP32S2 Technical Reference Manual is addressed to application developers. The manual provides
detailed and complete information on how to use the ESP32-S2 memory and peripherals.
For pin definition, electrical characteristics and package information, please see ESP32-S2 Datasheet.
Document Updates
Please always refer to the latest version on 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
Glossary 843
Abbreviations for Peripherals 843
Abbreviations for Registers 843
List of Tables
1 Comparison of the Two Coprocessors 28
2 ALU Operations Among Registers 33
3 ALU Operations with Immediate Value 34
4 ALU Operations with Stage Count Register 34
5 Data Storage Type - Automatic Storage Mode 36
6 Data Storage - Manual Storage Mode 37
7 Input Signals Measured Using the ADC Instruction 41
8 Instruction Efficiency 44
9 ULP-RISC-V Interrupt List 44
10 ULP Coprocessor Base Address 48
11 RTC I2C Base Address 48
12 Address Mapping 49
13 Description of Registers for Peripherals Accessible by ULP Coprocessors 49
18 Relationship Between Configuration Register, Block Size and Alignment 78
19 Copy DMA and Crypto DMA Base Address 82
22 Address Mapping 111
23 Internal Memory Address Mapping 111
24 External Memory Address Mapping 113
25 Peripherals with DMA Support 115
26 Module / Peripheral Address Mapping 116
27 Addresses with Restricted Access 118
28 Parameters in BLOCK0 119
29 Key Purpose Values 122
30 Parameters in BLOCK1-10 122
31 Registers for User Read Parameters 126
32 Configuration of eFuse-Programming Timing Parameters 128
33 Configuration of VDDQ Timing Parameters 129
34 Configuration of eFuse-Reading Parameters 129
35 eFuse Controller Base Address 130
37 Pin Function Register for IO MUX Light-sleep Mode 166
38 GPIO Matrix 167
39 IO MUX Pad List 171
40 RTC IO MUX Pin Summary 173
41 GPIO, IO MUX, GPIOSD, Dedicated GPIO, and RTCIO Base Addresses 174
47 Reset Source 218
48 CPU_CLK Source 220
49 CPU_CLK Selection 220
50 Peripheral Clock Usage 221
51 APB_CLK Source 221
52 REF_TICK Source 222
53 LEDC_PWM_CLK Source 222
54 Default Configuration of Strapping Pins 224
55 Boot Mode 224
168 Data Frames and Remote Frames in SFF and EFF 746
169 Error Frame 747
170 Overload Frame 748
171 Interframe Space 749
172 Segments of a Nominal Bit Time 751
173 Bit Information of TWAI_CLOCK_DIVIDER_REG; TWAI Address 0x18 755
174 Bit Information of TWAI_BUS_TIMING_1_REG; TWAI Address 0x1c 756
175 Buffer Layout for Standard Frame Format and Extended Frame Format 758
176 TX/RX Frame Information (SFF/EFF)�TWAI Address 0x40 759
177 TX/RX Identifier 1 (SFF); TWAI Address 0x44 759
178 TX/RX Identifier 2 (SFF); TWAI Address 0x48 760
179 TX/RX Identifier 1 (EFF); TWAI Address 0x44 760
180 TX/RX Identifier 2 (EFF); TWAI Address 0x48 760
181 TX/RX Identifier 3 (EFF); TWAI Address 0x4c 760
182 TX/RX Identifier 4 (EFF); TWAI Address 0x50 760
183 Bit Information of TWAI_ERR_CODE_CAP_REG; TWAI Address 0x30 765
184 Bit Information of Bits SEG.4 - SEG.0 765
185 Bit Information of TWAI_ARB LOST CAP_REG; TWAI Address 0x2c 766
186 TWAI Base Address 767
188 LED PWM Controller Base Address 784
190 RMT Base Address 797
192 SAR ADC Controllers 810
193 SAR ADC Input Signals 810
194 Fields of Pattern Table Register 813
195 DMA Data Format (Type I) 814
196 DMA Data Format (Type II) 814
197 Temperature Offset 820
198 On-Chip Sensor, SAR ADCs, and DACs Base Addresses 820
List of Figures
1-1 ULP Coprocessor Overview 27
1-2 ULP Coprocessor Diagram 28
1-3 Programing Workflow 29
1-4 Sample of a ULP Operation Sequence 30
1-5 Control of ULP Program Execution 31
1-6 ULP-FSM Instruction Format 32
1-7 Instruction Type — ALU for Operations Among Registers 32
1-8 Instruction Type — ALU for Operations with Immediate Value 33
1-9 Instruction Type — ALU for Operations with Stage Count Register 34
1-10 Instruction Type - ST 35
1-11 Instruction Type - Offset in Automatic Storage Mode (ST-OFFSET) 35
1-12 Instruction Type - Data Storage in Automatic Storage Mode (ST-AUTO-DATA) 35
1-13 Data Structure of RTC_SLOW_MEM[Rdst + Offset] 36
1-14 Instruction Type - Data Storage in Manual Storage Mode 37
1-15 Instruction Type - LD 37
1-16 Instruction Type- JUMP 38
1-17 Instruction Type - JUMPR 39
1-18 Instruction Type - JUMPS 39
1-19 Instruction Type- HALT 40
1-20 Instruction Type - WAKE 40
1-21 Instruction Type - WAIT 40
1-22 Instruction Type - TSENS 41
1-23 Instruction Type - ADC 41
1-24 Instruction Type - REG_RD 42
1-25 Instruction Type - REG_WR 43
1-26 I2C Read Operation 46
1-27 I2C Write Operation 47
2-1 Modules with DMA and Supported Data Transfers 73
2-2 DMA Engine Architecture 74
2-3 Structure of a Linked List 74
2-4 Relationship among Linked Lists 76
2-5 EDMA Receiving Data Frames in Internal 77
2-6 Copy DMA Engine Architecture 78
2-7 Data Transfer in UDMA Mode 79
2-8 SPI DMA 79
3-1 System Structure and Address Mapping 110
3-2 Cache Structure 114
4-1 Shift Register Circuit (first 32 output) 124
4-2 Shift Register Circuit (last 12 output) 125
4-3 eFuse-Programming Timing Diagram 128
4-4 Timing Diagram for Reading eFuse 129
5-1 IO MUX, RTC IO MUX and GPIO Matrix Overview 157
5-2 GPIO Input Synchronized on Clock Rising Edge or on Falling Edge 159
1.1 Overview
The ULP coprocessor is an ultra-low-power processor that remains powered on when the chip is in Deep-sleep
(see Chapter 9 Low-Power Management (RTC_CNTL)). Hence, users can store in RTC memory a program for the
ULP coprocessor to access peripheral devices, internal sensors and RTC registers during Deep-sleep.
In power-sensitive scenarios, the main CPU goes to sleep mode to lower power consumption. Meanwhile, the
coprocessor is woken up by ULP timer, and then monitors the external environment or interacts with the external
circuit by controlling peripheral devices such as RTCIO, RTC I2C, SAR ADC, or temperature sensor (TSENS). The
coprocessor wakes the main CPU up once a wakeup condition is reached.
ESP32-S2
Enable by ULP or Main CPU
RTC I2C
TOUCH
TSENS
ADC
Monitor / Control
ESP32-S2 has two ULP coprocessors, with one based on RISC-V instruction set architecture (ULP-RISC-V) and
the other on finite state machine (ULP-FSM). Users can choose between the two coprocessors depending on
their needs.
1.2 Features
• Access up to 8 KB of SRAM RTC slow memory for instructions and data
ULP-FSM and ULP-RISC-V can not be used simultaneously. Users can only choose one of them as the ULP
coprocessor of ESP32-S2. The differences between the two coprocessors are shown in the table below.
Coprocessors
Feature
ULP-FSM ULP-RISC-V
Memory (RTC Slow Memory) 8 KB
Work Clock Frequency 8 MHz
Wakeup Source ULP Timer
Assist the main CPU to complete some tasks
Normal Mode
after the system is woken up.
Work Mode
Control sensors to do tasks such as monitoring
Monitor Mode
environment, when the system is in sleep.
ADC0/ADC1
DAC0/DAC1
Control Low-Power Peripherals RTC I2C
RTC GPIO
Touch Sensor
Temperature Sensor
Architecture Programmable FSM RISC-V
Development Special instruction set Standard C compiler
ULP coprocessor can access the modules in RTC domain via RTC registers. In many cases the ULP
coprocessor can be a good supplement to, or replacement of, the main CPU, especially for power-sensitive
applications. Figure 1-2 shows the overall layout of ESP32-S2 coprocessor.
In a typical power-saving scenario, the chip goes to Deep-sleep mode to lower power consumption. Before
setting the chip to sleep mode, users should complete the following operations.
1. Flash the program to be executed by ULP coprocessor into RTC slow memory.
• 0: select ULP-RISC-V
• 1: select ULP-FSM
1. The timer periodically sets the low-power controller (see Chapter 9 Low-Power Management (RTC_CNTL))
to Monitor mode and then wakes up the coprocessor.
2. Coprocessor executes some necessary operations, such as monitoring external environment via
low-power sensors.
3. After the operations are finished, the system goes back to Deep-sleep mode.
4. ULP coprocessor goes back to halt mode and waits for next wakeup.
In monitor mode, ULP coprocessor is woken up and goes to halt as shown in Figure 1-4.
2. The timer expires and wakes up the ULP coprocessor. ULP coprocessor starts running and executes the
program flashed in RTC slow memory.
3. ULP coprocessor goes to halt and the timer starts counting again.
4. Disable the timer by ULP program or by software. The system exits from monitor mode.
• Disabled by RTC GPIO: clear the register RTC_CNTL_ULP_CP_GPIO_WAKEUP_ENA, and set the
register RTC_CNTL_ULP_CP_GPIO_WAKEUP_CLR.
Note:
• If the timer is enabled by software (RTC GPIO), it should be disabled by software (RTC GPIO).
• Before setting ULP-RISC-V to HALT, users should configure the register RTC_CNTL_COCPU_DONE first,
therefore, it is recommended to end the flashed program with the following pattern:
– Set the register RTC_CNTL_COCPU_DONE to end the operation of ULP-RISC-V and put it into halt;
Enough time is reserved for the ULP-RISC-V to complete the operations above before it goes to halt.
The relationship between the signals and registers is shown in Figure 1-5.
1.5 ULPFSM
1.5.1 Features
ULP-FSM is a programmable finite state machine that can work while the main CPU is in Deep-sleep. ULP-FSM
supports instructions for complex logic and arithmetic operations, and also provides dedicated instructions for
RTC controllers or peripherals. ULP-FSM can access up to 8 KB of SRAM RTC slow memory (accessible by the
CPU) for instructions and data. Hence, such memory is usually used to store instructions and share data
between the ULP coprocessor and the CPU. ULP-FSM can be stopped by running HALT instruction.
• Provide four 16-bit general-purpose registers (R0, R1, R2, and R3) for manipulating data and accessing
memory.
• Provide one 8-bit stage count register (Stage_cnt) which can be manipulated by ALU and used in JUMP
instructions.
• Support built-in instructions specially for direct control of low-power peripherals, such as SAR ADC and
temperature sensor.
s
nd
e
od
ra
pC
pe
O
O
31 28 27 0
An instruction, which has one OpCode, can perform various 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
coprocessor. The execution flow inside the program uses 32-bit addressing. The program is stored in a
dedicated region called Slow Memory, which is visible to the main CPU as one that has an address range of
0x5000_0000 to 0x5000_1FFF (8 KB).
The ALU instruction, which has one OpCode (7), can perform various arithmetic and logic operations, depending
on the setting of the instruction bits [27:21].
1
U_
st
rc
rc
Rd
Rs
Rs
AL
31 28 27 26 25 24 21 20 6 5 4 3 2 1 0
7 0
When bits [27:26] of the instruction in Figure 1-7 are set to 0, ALU performs operations on the data stored in
ULP-FSM registers R[0-3]. The types of operations depend on the setting of the instruction bits ALU_sel [24:21]
presented in Table 2.
Note:
• ADD or SUB operations can be used to set or clear the overflow flag in ALU.
• All ALU operations can be used to set or clear the zero flag in ALU.
1
U_
st
rc
m
AL
Rd
Rs
Im
31 28 27 26 25 24 21 20 19 4 3 2 1 0
7 1
Figure 18. Instruction Type — ALU for Operations with Immediate Value
When bits [27:26] of the instruction in Figure 1-8 are set to 1, ALU performs operations using register R[0-3] and
the immediate value stored in instruction bits [19:4]. The types of operations depend on the setting of the
instruction bits ALU_sel[24:21] presented in Table 3.
Operand Description - see Figure 1-8
Rdst Register R[0-3], destination
Rsrc1 Register R[0-3], source
Imm 16-bit signed immediate value
ALU_sel ALU Operation
Note:
• ADD or SUB operations can be used to set or clear the overflow flag in ALU.
• All ALU operations can be used to set or clear the zero flag in ALU.
m
AL
Im
31 28 27 26 25 24 21 20 12 11 4 3 0
7 2
Figure 19. Instruction Type — ALU for Operations with Stage Count Register
ALU is also able to increment or decrement by a given value, or reset the 8-bit register Stage_cnt. To do so, bits
[27:26] of instruction in Figure 1-9 should be set to 2. The type of operation depends on the setting of the
instruction bits ALU_sel[24:21] presented in Table 1-9. The Stage_cnt is a separate register and is not a part of
the instruction in Figure 1-9.
Operand Description - see Figure 1-9
Imm 8-bit signed immediate value
ALU_sel ALU Operation
Stage_cnt Stage count register, a 8-bit separate register used to store variables, such as loop index
Note: This instruction is mainly used with JUMPS instruction based on the stage count register to form a stage
count for-loop. For the usage, please refer to the following pseudocode:
to
ay
w t_s
au
r
w
pe
et
e
st
an
el
rc
r_
fs
up
lab
Rd
Rs
m
w
of
31 28 27 26 25 24 21 20 10 9 8 7 6 5 4 3 2 1 0
31 28 27 25 24 21 20 10 9 0
6 3
st
el
rc
r_
lab
Rd
Rs
w
31 28 27 25 24 9 8 7 6 5 4 3 2 1 0
6 1
Figure 112. Instruction Type Data Storage in Automatic Storage Mode (STAUTODATA)
This mode is used to access continuous addresses. Before using this mode for the first time, please configure
the initial address using ST-OFFSET instruction. Executing the instruction ST-AUTO-DATA will store the 16-bit
data in Rsrc into the memory address Rdst + Offset, see Table 5. Write_cnt here indicates the times of the
instruction ST-AUTO-DATA executed.
wr_way write_cnt Store Data Operation
0 * Mem [Rdst + Offset]{31:0} ={PC[10:0], 3’b0, Label[1:0], Rsrc[15:0]} Write full-word, including
the pointer and the data
1 odd Mem [Rdst + Offset]{15:0} = {Label[1:0],Rscr[13:0]} Store the data with label
in the low half-word
1 even Mem [Rdst + Offset]{31:16} = {Label[1:0],Rscr[13:0]} Store the data with label
in the high half-word
3 odd Mem [Rdst + Offset]{15:0} = Rscr[15:0]} Store the data without label
in the low half-word
3 even Mem [Rdst + Offset]{31:16} = Rscr[15:0] Store the data without label
in the high half-word
Rs
io
at
of
m
s
or
nt
f
e
in
el
nt
PC
lab
co
31 21 20 18 17 16 15 0
• When full-word is written, the offset will be automatically incremented by 1 after each ST-AUTO-DATA
execution.
• When half-word is written (low half-word first), the offset will be automatically incremented by 1 after twice
ST-AUTO-DATA execution.
• 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 CPU.
ay
r
w
pe
et
st
el
rc
r_
fs
up
lab
Rd
Rs
w
of
31 28 27 25 24 21 20 10 9 8 7 6 5 4 3 2 1 0
6 4
Manual storage mode is mainly used for storing data into discontinuous addresses. Each instruction needs a
storage address and offset. The detailed storage methods are shown in Table 6.
wr_way upper Data Operation
0 * Mem [Rdst + Offset]{31:0} ={PC[10:0], 3’b0, Label[1:0], Rsrc[15:0]} Write full-word, including
the pointer and the data
1 0 Mem [Rdst + Offset]{15:0} = {Label[1:0],Rscr[13:0]} Store the data with label
in the low half-word
1 1 Mem [Rdst + Offset]{31:16} = {Label[1:0],Rscr[13:0]} Store the data with label
in the high half-word
3 0 Mem [Rdst + Offset]{15:0} = Rsrc[15:0] Store the data without label
in the low half-word
3 1 Mem [Rdst + Offset]{31:16} = Rsrc[15:0] Store the data without label
in the high half-word
et
_u
st
rc
fs
Rd
Rs
rd
of
31 28 27 26 21 20 10 9 4 3 2 1 0
13
This instruction loads the low or high 16-bit half-word, depending on rd_upper, from memory with address Rsrc +
offset into the destination register Rdst:
Note:
• 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 CPU.
dr
Ad
pe
st
m
l
Rd
Se
Ty
Im
31 28 27 26 25 24 22 21 20 13 12 2 1 0
8 1
Description
The instruction executes a jump to a specified address. The jump can be either unconditional or based on the
ALU flag.
d
ol
sh
nd
ep
re
Co
St
Th
31 28 27 26 25 18 17 16 15 0
8 0
Description
The instruction executes a jump to a relative address, if the above-mentioned condition is true. The condition is
the result of comparing the R0 register value and the Threshold value.
1.5.2.6 JUMPS – Jump to a Relative Address (Conditional upon Stage Count Regis
ter)
d
ol
sh
nd
ep
re
Co
St
Th
31 28 27 26 25 18 17 16 15 0
8 2
• For more information about the stage count register, please refer to Section 1.5.2.1.
Description
The instruction executes 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.
31 28 27 0
11
Description
The instruction ends the operation of the ULP-FSM and puts it into power-down mode.
Note:
After executing this instruction, the ULP coprocessor wakeup timer gets started.
31 28 27 26 25 1 0
9 0 1’b1
Description
This instruction sends an interrupt from the ULP-FSM to the RTC controller.
• If the chip is in Deep-sleep mode, and the ULP wakeup timer is enabled, the above-mentioned interrupt will
wake up the chip.
• If the chip 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, an RTC interrupt will be triggered.
31 28 27 16 15 0
y
ela
_D
ait
ts
Rd
W
31 28 27 16 15 2 1 0
10
ux
rM
st
l
Rd
Se
Sa
31 28 27 7 6 5 2 1 0
dr
w
Ad
Lo
Hi
31 28 27 23 22 18 17 10 9 0
The instruction reads up to 16 bits from a peripheral register into a general-purpose register:
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. Address of
the register, as seen from the ULP coprocessor, can be calculated from the address of the same register on
PeriBUS1 (addr_peribus1), as follows:
• 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 CPU). 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.
gh
dr
a
w
t
Da
Ad
Lo
Hi
31 28 27 23 22 18 17 10 9 0
This instruction writes 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:
1.6 ULPRISCV
1.6.1 Features
• Support RV32IMC instruction set
Note:
• Besides the above-mentioned interrupts, ULP-RISC-V can also handle the interrupt from RTC_IO by simply
configuring RTC_IO as input mode. Users can configure RTCIO_GPIO_PINn_INT_TYPE to select the
interrupt trigger modes, but only level trigger modes are available. For more details about RTC_IO
configuration, see Chapter IO MUX and GPIO Matrix.
• The interrupt from RTC_IO can be cleared by releasing RTC_IO and its source can be read from the register
RTCIO_RTC_GPIO_STATUS_REG.
• For the information about RTC I2C interrupts, please refer to Section 1.7.4.
1. Set the low and high SCL half-periods by configuring 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_REG
= 40, RTC_I2C_SCL_HIGH_PERIOD_REG = 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_REG = 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).
6. Configure the RTC I2C controller into master mode by setting the RTC_I2C_MS_MODE bit in
RTC_I2C_CTRL_REG.
• If ULP-RISC-V or main CPU is used, then write the slave address to SENS_SAR_I2C_CTRL_REG[9:0].
• If ULP-FSM is used, then write the slave address to SENS_I2C_SLAVE_ADDRn (n: 0-7)
Up to eight slave addresses can be pre-programmed. One of these addresses can then be selected for
each transaction as part of the RTC I2C instruction.
Once RTC I2C is configured, the main CPU or the ULP coprocessor can communicate with the external I2C
devices.
• Configure the instruction list of RTC I2C (see Section CMD_Controller in Chapter 25 I2C Controller (I2C)),
including instruction order, instruction code, read data number (byte_num), and other information.
• When an RTC_I2C_RX_DATA_INT interrupt is received, transfer the read data stored in RTC_I2C_RDATA to
SRAM RTC slow memory, or use the data directly.
The I2C_RD instruction performs the following operations (see Figure 1-26):
2. Master sends slave address, with r/w bit set to 0 (“write”). Slave address is obtained from
SENS_I2C_SLAVE_ADDRn.
9. Master checks whether the number of transmitted bytes reaches the number set by the current instruction
(byte_num). If yes, master jumps out of the read instruction and sends an NACK signal. Otherwise master
repeats Step 8 and waits for the slave to send the next byte.
1 2 3 4 5 6 7 8 9 10
RSTRT
START
NACK
STOP
ACK
Slave Data(n)
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 microsecond, the master may receive incorrect data.
• Configure RTC I2C instruction list, including instruction order, instruction code, and the data to be written in
byte (byte_num). See the configuration of I2C0/I2C1 in Section CMD_Controller in Chapter 25 I2C
Controller (I2C).
• Configure the slave register address by setting the register SENS_SAR_I2C_CTRL[18:11], and the data to
be transmitted in SENS_SAR_I2C_CTRL[26:19].
• Update the next data to be transmitted in the register SENS_SAR_I2C_CTRL[26:19], each time when an
RTC_I2C_TX_DATA_INT interrupt is received.
The I2C_WR instruction performs the following operations, see Figure 1-27.
2. Master sends slave address, with r/w bit set to 0 (“write”). Slave address is obtained from
SENS_I2C_SLAVE_ADDRn.
9. Slave generates ACK. Master checks whether the number of transmitted bytes reaches the number set by
the current instruction (byte_num). If yes, master jumps out of the write instruction and starts the next
instruction. Otherwise the master repeats step 8 and sends the next byte.
1 2 3 4 5 6 7 8 9 10
RSTRT
START
STOP
Master Slave Address W Reg Address Slave Address W Data(n)
ACK
ACK
ACK
Slave
Wherein:
• ULP (ALWAYS_ON) represents the registers, which will not be reset due to the power down of RTC_PERI
domain. See Chapter 9 Low-Power Management (RTC_CNTL).
• ULP (RTC_PERI) represents the registers in RTC_PERI domain, which will be reset due to the power down
of RTC_PERI domain. See Chapter 9 Low-Power Management (RTC_CNTL).
Peripheral(s) Base Register Main Bus Address ULPFSM Base ULPRISCV Base
RTC Control DR_REG_RTCCNTL_BASE 0x60008000 0x8000 0x8000
RTC GPIO DR_REG_RTC_IO_BASE 0x60008400 0x8400 0xA400
ADC, Touch, TSENS DR_REG_SENS_BASE 0x60008800 0x8800 0xC800
RTC I2C DR_REG_RTC_I2C_BASE 0x60008C00 0x8C00 0xEC00
To find more information about registers for these peripherals, please check the following chapters.
1.11 Registers
The address in the following part represents the address offset (relative address) with respect to the base address,
not the absolute address. For detailed information about the base address, please refer to Section 1.8.
T
NI
LP P_ P_
_I
PI
PC
_U _C SL
TL LP P_
P_
CN L_U _C
_C
C_ NT LP
LP
RT C L_U
_U
TL
C_ NT
)
ed
CN
RT _C
rv
C_
se
C
RT
RT
(re
31 30 29 28 11 10 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
YC
_C
LP
_S
ER
M
TI
P_
_C
U LP
L_
T
)
ed
CN
rv
C_
se
RT
(re
31 8 7 0
200 0 0 0 0 0 0 0 0 Reset
FO
_U _C FO T_
TL LP P_ AR
K_
CN L_U _C ST
C_ NT LP P_
RT _C L_U P_C
C NT L
RT _C L_U
C NT
d)
ve
RT _C
r
se
C
RT
(re
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
S
DI
N
ER
T_
IS
N
_E
_E
_D
SE
G
TR
E
IG
ET
LK
RC
RE
IN
TL OC U_D NE _TR
ES
_C
2_
2_
U_ L O F
_R
FO
_2
CN L_C CP DO NT
T_
T_
CP S _
O U_ NE
UT
UT
AR
AR
K_
C_ NT O U_ _I
HU
RT _C L_C CP SW
_C P O
SH
SH
CL
E
ST
ST
_S
C NT O U_
U_
U_
U_
U_
U
RT _C L_C CP
CP
CP
CP
CP
CP
C NT O
O
RT _C L_C
_C
_C
_C
_C
_C
TL
TL
TL
TL
TL
C NT
)
ed
CN
CN
CN
CN
CN
RT _C
rv
C_
C_
C_
C_
C_
se
C
RT
RT
RT
RT
RT
RT
(re
31 27 26 25 24 23 22 21 14 13 12 7 6 1 0
0 0 0 0 0 0 0 0 1 0 40 0 16 8 0 Reset
RTC_CNTL_COCPU_DONE DONE signal. Write 1 to this bit, ULP-RISC-V will go to HALT and the
timer starts counting. (R/W)
A W
_I NT RA
RA W
NE E_I T_
U_ UC H_ INT AW
H_ ACT IVE W
W
NT _R
DO IV _IN
T A
_C PU TO D _IN W
NS CO U_ RA IN AW
R
TO H_ AC _R
_
O _T U C1 T_
N O U_ AR _R W
NS OC U_ RA 2 A
SE _C CP SA DC T_R
SE S_C CP TS T_ AW
SE S_ CP SA S_ _R
SE _C CP ST NT RA
CP O C _
N O U_ EN INT
NS O U_ _I T_
SE S_C CP SW _IN
UC IN
N O U_ D
SE S_C CP SW
N O U_
SE S_C CP
N O
d)
SE S_C
ve
er
N
s
SE
31
(re 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
N T _E A
_I NT EN
_E NA
T _
NA
U_ UC H_ NT NA
UC IN TIV NA
DO IV IN
H_ ACT E_
_I E
TO H_ AC _E
NS OC U_ RA 2_ NA
NS O U_ RA INT NA
NE _I
O _T UC 1 T_
N O U_ AR _E A
E
SE _C P SA DC _E
SE _C P SA S_ _E
SE S_C CP ST INT EN
SE S_C CP TS T_ NA
_C PU TO DC IN
NS O U_ EN INT
N O U _ _ T_
SE S_C CP SW _IN
N O U_ D
SE S_C CP SW
CP O
N O U_
SE _C CP
C
C
NS O
d)
SE S_C
ve
er
N
s
SE
(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
T
T _S
_I E_ ST
_S T
NE TIV T_
NT I N
DO AC IN
U_ OU H_ NT T
UC H_ TIV T
H_ IN E_
_I S
TO C AC _S
O U_ UC 1 T_
NS O U_ RA 2_ T
NS O U_ RA INT T
SE _C P SA DC _S
SE S_C CP SA S_ _S
_C P TO DC IN
SE _C CP ST NT ST
SE S_C CP TS T_ T
N O U_ EN INT
NS O U_ _I T_
N O U_ AR _S
SE S_C CP SW _IN
N O U_ D
SE S_C CP SW
CP T
N O U_
SE S_C CP
C
C
N O
d)
SE S_C
ve
er
N
s
SE
(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
N T _C R
_I NT CL
_C LR
T _
LR
U_ UC H_ NT LR
UC IN TIV LR
DO IV IN
_I C
TO H_ AC _C
H_ ACT E_
NS OC U_ RA 2_ LR
NS O U_ RA INT LR
NE _I
O _T UC 1 T_
N O U_ AR _C R
E
SE _C P SA DC _C
SE _C P SA S_ _C
SE _C CP ST NT CL
SE S_C CP TS T_ LR
_C PU TO DC IN
NS O U_ EN INT
NS O U_ _I T_
SE S_C CP SW _IN
N O U_ D
SE S_C CP SW
CP O
N O U_
SE _C CP
C
C
NS O
)
ed
SE S_C
rv
se
N
SE
(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
RL
2C A
T
_I _ST
_C
AR 2C
2C
_S _I
_I
NS AR
AR
)
ed
SE _S
_S
rv
NS
NS
se
SE
SE
(re
31 30 29 28 27 0
0 0 0 0 0 Reset
SENS_SAR_I2C_START_FORCE 0: RTC I2C started by FSM; 1: RTC I2C started by software. (R/W)
R0
R1
DD
DD
_A
_A
E
VE
AV
LA
L
_S
S
C_
2C
d)
2
ve
_I
_I
NS
NS
er
s
SE
SE
(re
31 22 21 11 10 0
R2
R3
DD
DD
_A
_A
E
E
AV
AV
SL
SL
C_
C_
d)
I2
ve
_I
S_
NS
r
se
N
SE
SE
(re
31 22 21 11 10 0
R5
DD
DD
_A
_A
E
VE
AV
LA
SL
_S
C_
2C
d)
2
e
_I
_I
rv
NS
NS
se
SE
SE
(re
31 22 21 11 10 0
R6
R7
DD
DD
_A
_A
E
VE
AV
LA
L
_S
S
C_
2C
d)
2
ve
_I
_I
NS
NS
er
s
SE
SE
(re
31 22 21 11 10 0
G
RE
D_
IO
ER
_P
W
O
_L
CL
_S
)
ed
C
I2
rv
C_
se
RT
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x100 Reset
RTC_I2C_SCL_LOW_PERIOD_REG This register is used to configure how many clock cycles SCL
remains low. (R/W)
I2
r
C_
se
RT
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x100 Reset
RTC_I2C_SCL_HIGH_PERIOD_REG This register is used to configure how many cycles SCL re-
mains high. (R/W)
UM
Y _N
UT
_D
S DA
C_
d)
ve
I2
er
C_
s
RT
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x010 Reset
RTC_I2C_SDA_DUTY_NUM The number of clock cycles between the SDA switch and the falling
edge of SCL. (R/W)
D
O
RI
PE
T_
R
TA
_S
CL
_S
)
ed
C
I2
rv
C_
se
RT
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 8 Reset
2C
e
rv
I
C_
se
RT
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 8 Reset
EN
E_
UT
E_ T
RC _OU
AT
O
C C_ AN FI T
C_ L_ E T
C_ C_ _M STA T
RT _I2 TR SB_ IRS
I2 SC OD R
G
RT _I2 MS S_ RS
FO E
K_
A_ RC
C C_ L F
L
SD FO
CT T
C_ SE
RL
C C_ _L
I2 RE
RT I2 RX
C_ C_
C_ C_
C d)
)
ed
RT rve
RT _I2
RT _I2
v
er
se
C
s
RT
(re
(re
31 30 29 28 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_TRANS_START Set this bit to 1, RTC I2C starts sending data. (R/W)
RTC_I2C_TX_LSB_FIRST This bit is used to control the sending mode. 0: send data from the most
significant bit; 1: send data from the least significant bit. (R/W)
RTC_I2C_RX_LSB_FIRST This bit is used to control the storage mode for received data. 0: receive
data from the most significant bit; 1: receive data from the least significant bit. (R/W)
D
SE
C_ C_ B_ SY ES
RT I2 BU _A S
RT _I2 AR BU DR
C_ C_ AVE AN
K_ RW
T
C C_ S_ D
C
C_ AV S
RT _I2 SL _TR
NT
I2 SL LO
RE
AC _ E
_C
C _ E T
C_ OP
RT I2 Y B
C_
C_ C_
d)
C
ve
I2
RT I2
er
C_
s
RT
RT
(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 Reset
RTC_I2C_ARB_LOST When the RTC I2C loses control of SCL line, the register changes to 1. (RO)
RTC_I2C_BUS_BUSY 0: RTC I2C bus is in idle state; 1: RTC I2C bus is busy transferring data. (RO)
RTC_I2C_SLAVE_ADDRESSED When the address sent by the master matches the address of the
slave, then this bit will be set. (RO)
C
I2
rv
C_
se
RT
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x10000 Reset
N
_E
T
BI
10
R_
DD
A
C_
)
ed
I2
rv
C_
se
RT
(re
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
RTC_I2C_ADDR_10BIT_EN This field is used to enable the slave 10-bit addressing mode. (R/W)
T_ C LR
P_ N _C
CL LR
_C OS P_ LR
M T_I NT
AN _L M _C
R
IN T_
R
I
RT _I2 TIM ER INT LR CL
TR N CO T
E_ TIO N_ _IN
C C_ K_ _ C T_
C_ RB R_ P LR
AV A A TE
RT I2C A S_C INT LR
RT _I2 AC ATA NT_ _IN
C_ _ ST O _C
SL ITR TR LE
C_ _ N T_ C
C C_ E R_ _C
C C_ _D _I T
O
RT _I2 RX ATA TAR
E M
C C_ D _S
RT _I2 TX_ CT
C C_ TE
A
RT I2 DE
M
A
C_ C_
)
ed
C
RT _I2
I2
v
er
C
s
RT
(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
T_ R AW
RA AW
_C OS P_ AW
P_ N _R
M T_I NT
W
AN _L M _R
W
IN T_
I
RT _I2 TIM ER INT AW RA
TR N CO T
E_ TIO N_ _IN
C C_ K_ _ R T_
C_ RB R_ P AW
RT I2C A S_C INT AW
AV A A TE
RT _I2 TR _OU INT AW
RT _I2 AC ATA NT_ _IN
C_ _ ST O _R
SL ITR TR LE
C_ _ N T_ R
C C_ E R_ _R
C C_ _D _I T
O
RT _I2 RX ATA TAR
E M
C C_ D _S
RT _I2 TX_ CT
C C_ TE
A
RT _I2 DE
M
A
C C_
)
ed
C
RT _I2
I2
rv
se
C
RT
(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
IN T_ T
P_ N _S
S T
_C OS P_ T
M T_I NT
T_ S
AN _L M _S
T
I
TR N CO T
RT _I2 TIM ER INT T ST
E_ TIO N_ _IN
C C_ K_ _ S T_
AV A A TE
RT _I2 AC ATA NT_ _IN
C_ RB R_ P T
RT I2C A S_C INT T
C_ _ ST O _S
RT _I2 TR _OU INT T
SL ITR TR LE
C_ C_ AN T_ _S
C C_ E R_ _S
C C_ _D _I T
O
RT _I2 RX ATA TAR
E M
C C_ D _S
RT _I2 TX_ CT
C C_ TE
RT I2 DE
M
A
C_ C_
d)
ve
RT _I2
I2
er
C
s
RT
(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
T_ EN A
IN T_ N
EN A
P_ N _E
_C OS P_ NA
M T_I NT
AN _L M _E
A
A
I
RT _I2 TIM ER INT NA EN
TR N CO T
E_ TIO N_ _IN
C C_ K_ _ E T_
A
AV A A TE
RT I2C A S_C INT NA
RT _I2 AC ATA NT_ _IN
E M N
C_ _ ST O _E
SL ITR TR LE
C_ _ N T_ E
C C_ E R_ _E
C C_ _D _I T
O
RT _I2 RX ATA TAR
C_ RB R_ P
C C_ D _S
RT _I2 TX_ CT
C C_ TE
A
RT _I2 DE
M
A
C C_
)
ed
C
RT _I2
I2
rv
se
C
RT
(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
A
E
NE
AT
AV
DO
RD
SL
C_
C_
C_
)
ed
I2
I2
I2
rv
C_
C_
C_
se
RT
RT
RT
(re
31 30 16 15 8 7 0
NE
O
_D
D0
D0
AN
AN
M
M
M
M
O
CO
_C
C_
)
ed
C
I2
I2
v
er
C_
C_
s
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x903 Reset
RTC_I2C_COMMAND0 Content of command 0. For more information, please refer to the register
I2C_COMD0_REG in Chapter I2C Controller. (R/W)
D1
AN
AN
M
M
M
M
CO
O
_C
C_
)
ed
C
I2
I2
rv
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1901 Reset
RTC_I2C_COMMAND1 Content of command 1. For more information, please refer to the register
I2C_COMD1_REG in Chapter I2C Controller. (R/W)
D2
AN
AN
M
M
M
M
O
CO
_C
C_
d )
2C
ve
I2
I
r
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x902 Reset
RTC_I2C_COMMAND2 Content of command 2. For more information, please refer to the register
I2C_COMD2_REG in Chapter I2C Controller. (R/W)
NE
O
_D
D3
D3
AN
AN
M
M
M
M
O
CO
_C
C_
)
ed
C
I2
I2
v
er
C_
C_
s
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x101 Reset
RTC_I2C_COMMAND3 Content of command 3. For more information, please refer to the register
I2C_COMD3_REG in Chapter I2C Controller. (R/W)
D4
AN
AN
M
M
M
M
CO
O
_C
C_
)
ed
C
I2
I2
rv
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x901 Reset
RTC_I2C_COMMAND4 Content of command 4. For more information, please refer to the register
I2C_COMD4_REG in Chapter I2C Controller. (R/W)
D5
AN
AN
M
M
M
M
O
CO
_C
C_
d )
2C
ve
I2
I
r
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1701 Reset
RTC_I2C_COMMAND5 Content of command 5. For more information, please refer to the register
I2C_COMD5_REG in Chapter I2C Controller. (R/W)
NE
O
_D
D6
D6
AN
AN
M
M
M
M
O
CO
_C
C_
)
ed
C
I2
I2
v
er
C_
C_
s
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1901 Reset
RTC_I2C_COMMAND6 Content of command 6. For more information, please refer to the register
I2C_COMD6_REG in Chapter I2C Controller. (R/W)
D7
AN
AN
M
M
M
M
CO
O
_C
C_
)
ed
C
I2
I2
rv
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x904 Reset
RTC_I2C_COMMAND7 Content of command 7. For more information, please refer to the register
I2C_COMD7_REG in Chapter I2C Controller. (R/W)
D8
AN
AN
M
M
M
M
O
CO
_C
C_
d )
2C
ve
I2
I
r
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1901 Reset
RTC_I2C_COMMAND8 Content of command 8. For more information, please refer to the register
I2C_COMD8_REG in Chapter I2C Controller. (R/W)
NE
O
_D
D9
D9
AN
AN
M
M
M
M
O
CO
_C
C_
)
ed
C
I2
I2
v
er
C_
C_
s
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x903 Reset
RTC_I2C_COMMAND9 Content of command 9. For more information, please refer to the register
I2C_COMD9_REG in Chapter I2C Controller. (R/W)
0
D1
D1
AN
AN
M
M
M
M
CO
O
_C
C_
)
ed
C
I2
I2
rv
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x101 Reset
RTC_I2C_COMMAND10 Content of command 10. For more information, please refer to the register
I2C_COMD10_REG in Chapter I2C Controller. (R/W)
1
D1
D1
AN
AN
M
M
M
M
CO
O
_C
C_
)
ed
2C
I2
rv
I
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x901 Reset
RTC_I2C_COMMAND11 Content of command 11. For more information, please refer to the register
I2C_COMD11_REG in Chapter I2C Controller. (R/W)
NE
DO
2_
2
D1
D1
AN
AN
M
M
M
M
O
CO
_C
C_
d)
C
ve
I2
I2
er
C_
C_
s
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1701 Reset
RTC_I2C_COMMAND12 Content of command 12. For more information, please refer to the register
I2C_COMD12_REG in Chapter I2C Controller. (R/W)
3
D1
D1
AN
AN
M
M
M
M
O
CO
_C
C_
)
ed
C
I2
I2
rv
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1901 Reset
RTC_I2C_COMMAND13 Content of command 13. For more information, please refer to the register
I2C_COMD13_REG in Chapter I2C Controller. (R/W)
4
D1
D1
AN
AN
M
M
M
M
O
CO
_C
C_
d)
2C
I2
rv
I
C_
C_
se
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
RTC_I2C_COMMAND14 Content of command 14. For more information, please refer to the register
I2C_COMD14_REG in Chapter I2C Controller. (R/W)
NE
DO
5_
5
D1
D1
AN
AN
M
M
M
M
O
CO
_C
C_
d)
C
ve
I2
I2
er
C_
C_
s
RT
RT
(re
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
RTC_I2C_COMMAND15 Content of command 15. For more information, please refer to the register
I2C_COMD15_REG in Chapter I2C Controller. (R/W)
TE
DA
C_
d)
ve
I2
r
C_
se
RT
(re
31 28 27 0
0 0 0 0 0x1905310 Reset
2.1 Overview
Direct Memory Access (DMA) is a feature that allows peripheral-to-memory and memory-to-memory data transfer
at a high speed. The CPU is not involved in the DMA transfer, and therefore it becomes more efficient.
ESP32-S2 has three types of DMA, namely Internal DMA, EDMA and Copy DMA. Internal DMA can only access
internal RAM and is used for data transfer between internal RAM and peripherals. EDMA can access both
internal RAM and external RAM and is used for data transfer between internal RAM, external RAM and
peripherals. Copy DMA can only access internal RAM and is used for data transfer from one location in internal
RAM to another.
Eight peripherals on ESP32-S2 have DMA features. As shown in Figure 2-1, UART0 and UART1 share one
Internal DMA; SPI3 and ADC Controller share one Internal DMA; AES Accelerator and SHA Accelerator share one
EDMA (i.e. Crypto DMA); SPI2 and I2S0 have their individual EDMA. Besides, the CPU Peripheral module on
ESP32-S2 also has one Copy DMA.
2.2 Features
The DMA controller has the following features:
A DMA engine reads/writes data to/from external RAM or internal RAM via the AHB_BUS. Figure 2-2 shows the
basic architecture of a DMA engine. For how to access RAM, please see Chapter 3 System and Memory.
Software can use the DMA engine through linked lists. The DMA_ENGINE transmits data in corresponding RAM
according to the outlink (i.e. a linked list of transmit descriptors), and stores received data into specific address
space in RAM according to the inlink (i.e. a linked list of receive descriptors).
Figure 2-3 shows the structure of a linked list. An outlink and an inlink have the same structure. A linked list is
formed by one or more descriptors, and each descriptor consists of three words. Linked lists should be in
internal RAM for the DMA engine to be able to use them. The meaning of each field is as follows:
• Owner (DW0) [31]: Specifies who is allowed to access the buffer that this descriptor points to.
1’b0: CPU can access the buffer;
1’b1: The DMA controller can access the buffer.
When the DMA controller stops using the buffer, this bit is cleared by hardware. You can set
PERI_IN_LOOP_TEST bit to disable automatic clearing by hardware. When software loads a linked list, this
• suc_eof (DW0) [30]: Specifies whether this descriptor is the last descriptor in the list.
1’b0: This descriptor is not the last one;
1’b1: This descriptor is the last one.
Software clears suc_eof bit in receive descriptors. When a packet has been received, this bit in the last
receive descriptor is set by hardware, and this bit in the last transmit descriptor is set by software.
• err_eof (DW0) [28]: Specifies whether the received data has errors.
This bit is used only when UART DMA receives data. When an error is detected in the received packet, this
bit in the receive descriptor is set to 1 by hardware.
• Length (DW0) [23:12]: Specifies the number of valid bytes in the buffer that this descriptor points to. This
field in a transmit descriptor is written by software and indicates how many bytes can be read from the
buffer; this field in a receive descriptor is written by hardware automatically and indicates how many bytes
have been stored into the buffer.
• Size (DW0) [11:0]: Specifies the size of the buffer that this descriptor points to.
When the DMA controller accesses external RAM, this field must be a multiple of 16/32/64 bytes. Please
see more details in Section 2.3.8 Accessing External RAM.
• Next descriptor address (DW2): Pointer to the next descriptor. If the current descriptor is the last one
(suc_eof = 1), this value is 0. This field can only point to internal RAM.
If the length of data received is smaller than the size of the buffer, the DMA controller will not use available space
of the buffer in the next transaction.
The DMA controller can be restarted. If you are not sure whether the loaded linked list has been used up or not
and want to load a new linked list, you can use this Restart function without affecting the loaded linked list. When
using the Restart function, software needs to rewrite address of the first descriptor in the new list to DW2 of the
last descriptor in the loaded list, loads the new list as shown in Figure 2-4, and set PERI_INLINK_RESTART bit or
PERI_OUTLINK_RESTART bit (these two bits are cleared automatically by hardware). By doing so, hardware can
obtain the address of the first descriptor in the new list when reading the last descriptor in the loaded list, and
then read the new list.
2.3.5 EOF
The DMA controller uses EOF (end of file) flags to indicate the completion of data transfer.
Before the DMA controller transmits data, PERI_OUT_TOTAL_EOF_INT_ENA bit should be set. If data in the
buffer pointed by the last descriptor has been transmitted, a PERI_OUT_TOTAL_EOF_INT interrupt is
generated.
Before the DMA controller receives data, PERI_IN_SUC_EOF_INT_ENA bit should be set. If data has been
received successfully, a PERI_IN_SUC_EOF_INT interrupt is generated. In addition to PERI_IN_SUC_EOF_INT
interrupt, UART DMA also supports UHCI_IN_ERR_EOF_INT. This interrupt is enabled by setting
UHCI_IN_ERR_EOF_INT_ENA bit, and it indicates that a data packet has been received with errors.
Note: In this chapter, EOF of transmit descriptors refers to suc_eof, EOF of receive descriptors refers to both
suc_eof and err_eof.
2.3.7 EDMA
EDMA is used by I2S0, SPI2, AES Accelerator, and SHA Accelerator. It can access both internal RAM and
external RAM.
EDMA can send data in burst mode to improve data transfer efficiency. To enable burst mode, please set
PERI_OUT_DATA_BURST_EN bit.
When EDMA accesses external RAM, fields in linked list descriptors should be aligned with block size.
Specifically, size and buffer address pointer in receive descriptors should be 16-byte, 32-byte or 64-byte aligned.
For data frame whose length is not a multiple of 16 bytes, 32 bytes, or 64 bytes, EDMA adds padding bytes to
the end. After PERI_DMA_IN_SUC_EOF_INT is detected, software can check the amount of valid data by reading
length field in receive descriptors. Size, length and buffer address pointer in transmit descriptors are not
necessarily aligned with block size. Table 18 illustrates the value of PERI_EXT_MEM_BK_SIZE bit when fields in
linked list descriptors are 16-byte, 32-byte and 64-byte aligned respectively.
Table 18: Relationship Between Configuration Register, Block Size and Alignment
2. Load an outlink, and configure CP_DMA_OUTLINK_ADDR with address of the first transmit descriptor;
3. Load an inlink, and configure CP_DMA_INLINK_ADDR with address of the first receive descriptor;
Figure 2-7 shows how data is transferred using UDMA. Before UDMA receives data, software prepares an inlink.
UHCI_INLINK_ADDR points to the first receive descriptor in the inlink. After UHCI_INLINK_START is set, UHCI
sends data that UART has received to the Decoder. The decoded data is then stored into the RAM pointed by
the inlink under the control of UDMA.
Before UDMA sends data, software prepares an outlink and data to be sent. UHCI_OUTLINK_ADDR points to
the first transmit descriptor in the outlink. After UHCI_OUTLINK_START is set, UDMA reads data from the RAM
pointed by outlink. The data is then encoded by the Encoder, and sent sequentially by the UART
transmitter.
Data packets of UDMA have separators at the beginning and the end, with data bits in the middle. The encoder
inserts separators in front of and after data bits, and replaces data bits identical to separators with special
characters. The decoder removes separators in front of and after data bits, and replaces special characters with
separators. There can be more than one continuous separator at the beginning and the end of a data packet.
The separator is configured by UHCI_SEPER_CHAR, 0xC0 by default. The special character is configured by
UHCI_ESC_SEQ0_CHAR0 (0xDB by default) and UHCI_ESC_SEQ0_CHAR1 (0xDD by default). When all data
has been sent, a UHCI_OUT_TOTAL_EOF_INT interrupt is generated. When all data has been received, a
UHCI_IN_SUC_EOF_INT is generated.
As shown in Figure 2-8, SPI2 and SPI3 have separate DMA controllers.
SPI DMA receives and transmits data through descriptors at least one byte at a time. The transmission of data
can be done in bursts.
1. Set SPI_IN_RST, SPI_AHBM_FIFO_RST and SPI_AHBM_RST bit first to 1 and then to 0, to reset DMA
state machine and FIFO pointer;
2. Load an inlink, and configure SPI_INLINK_ADDR with address of the first receive descriptor;
1. Set SPI_OUT_RST, SPI_AHBM_FIFO_RST and SPI_AHBM_RST bit first to 1 and then to 0, to reset RMA
state machine and FIFO pointer;
2. Load an outlink, and configure SPI_OUTLINK_ADDR with address of the first transmit descriptor;
Note: When SPI DMA transfers data between internal RAM and external RAM, SPI_MEM_TRANS_EN should be
set.
SPI DMA also supports data transfer in segments. For more details, please refer to Chapter 24 SPI Controller
(SPI).
1. Set I2S_IN_RST, I2S_AHBM_FIFO_RST and I2S_AHBM_RST bit first to 1 and then to 0, to reset DMA
state machine and FIFO pointer;
2. Load an inlink, and configure I2S_INLINK_ADDR with address of the first receive descriptor;
1. Set I2S_OUT_RST, I2S_AHBM_FIFO_RST and I2S_AHBM_RST bit first to 1 and then to 0, to reset DMA
state machine and FIFO pointer;
2. Load an outlink, and configure I2S_OUTLINK_ADDR with address of the first transmit descriptor;
Note: When I2S DMA transfers data between internal RAM and external RAM using I2S DMA,
I2S_MEM_TRANS_EN should be set.
For how data is stored in I2S mode, please refer to description about I2S mode in Chapter 26 I2S Controller (I2S);
for how data is stored in LED mode, please refer to Section 26.10 LCD Master Transmitting Mode in Chapter 26
I2S Controller (I2S).
For more information about I2S DMA interrupts, please refer to Section 26.12.2 DMA Interrupts in Chapter 26 I2S
Controller (I2S).
2. Load an inlink, and configure CRYPTO_DMA_INLINK_ADDR with address of the first receive descriptor;
2. Load an outlink, and configure CRYPTO_DMA_OUTLINK_ADDR with address of the first transmit
descriptor;
Note: When Crypto DMA is used for data transfer between internal RAM and external RAM, please set
CRYPTO_DMA_MEM_TRANS_EN.
• CP_DMA_IN_DSCR_EMPTY_INT: Triggered when the size of the buffer pointed by receive descriptors is
smaller than the length of data to be received.
• CP_DMA_OUT_EOF_INT: Triggered when EOF in a transmit descriptor is 1 and data corresponding to this
descriptor has been sent.
• CP_DMA_OUT_DONE_INT: Triggered when all data corresponding to a transmit descriptor has been sent.
• CP_DMA_IN_DONE_INT: Triggered when all data corresponding to a receive descriptor has been received.
• CRYPTO_DMA_OUT_DONE_INT: Triggered when all data corresponding to a transmit descriptor has been
sent.
• CRYPTO_DMA_IN_ERR_EOF_INT: Reserved.
• CRYPTO_DMA_IN_DONE_INT: Triggered when all data corresponding to a receive descriptor has been
sent.
The addresses in the following table are relative to the Crypto DMA base addresses provided in Section
2.11.
2.13 Registers
Register 2.1: CP_DMA_INT_RAW_REG (0x0000)
_D A_ T_ F_ _IN T_ AW
_ A_ T_ _ RR NT AW
A_ S N _R _R W
M IN_ DO INT T RA
IN UC E_ A AW
CP DM OU EO ERR _IN _R
CP DM OU SCR _E Y_I _R
AW W
_I INT W
_ A_ D CR PT NT
_R RA
_D _E IN W
NE F_ RA
CP DM IN_ DS EM F_I
NT _
O O T_
_ A_ T_ _ O
CP DM OU SCR L_E
_ A_ D TA
CP DM IN_ TO
_ A_ T_
CP DM OU
_ A_
d)
ve
CP DM
er
_
s
CP
(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
CP_DMA_IN_DONE_INT_RAW This is the interrupt raw bit. Triggered when the last data of frame is
received or the receive buffer is full indicated by receive descriptor. (RO)
CP_DMA_IN_SUC_EOF_INT_RAW This is the interrupt raw bit. Triggered when the last data of one
frame is received. (RO)
CP_DMA_OUT_DONE_INT_RAW This is the interrupt raw bit. Triggered when all data indicated by
one transmit descriptor has been pushed into TX FIFO. (RO)
CP_DMA_OUT_EOF_INT_RAW This is the interrupt raw bit. Triggered when the last data with EOF
flag has been pushed into TX FIFO. (RO)
CP_DMA_IN_DSCR_ERR_INT_RAW This is the interrupt raw bit. Triggered when detecting receive
descriptor error, including owner error, the second and third word error of receive descriptor. (RO)
CP_DMA_OUT_DSCR_ERR_INT_RAW This is the interrupt raw bit. Triggered when detecting trans-
mit descriptor error, including owner error, the second and third word error of transmit descriptor.
(RO)
CP_DMA_IN_DSCR_EMPTY_INT_RAW This is the interrupt raw bit. Triggered when receiving data
is completed and no more receive descriptor. (RO)
CP_DMA_OUT_TOTAL_EOF_INT_RAW This is the interrupt raw bit. Triggered when data corre-
sponding to all transmit descriptors and the last descriptor with valid EOF is transmitted out. (RO)
_D A_ T_ F_ _IN T_ T
_ A_ T_ _ RR NT T
M IN_ DO INT T ST
CP DM OU EO ERR _IN _S
CP DM OU SCR _E Y_I _S
IN UC E_ T T
_ A_ D CR PT NT
A_ S N _S _S
_S ST
NE F_ ST
CP DM IN_ DS EM F_I
NT _
T
_I INT
O O T_
_ A_ T_ _ O
_D _E IN
CP DM OU SCR L_E
_ A_ D TA
CP DM IN_ TO
_ A_ T_
CP DM OU
_ A_
d)
ve
CP DM
er
_
s
CP
(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
_D A_ T_ F_ _IN T_ NA
_ A_ T_ _ RR NT NA
A_ S N _E _E A
M IN_ DO INT T EN
IN UC E_ N NA
CP DM OU EO ERR _IN _E
CP DM OU SCR _E Y_I _E
NA A
_ A_ D CR PT NT
_I INT A
_E EN
NE F_ EN
_D _E IN A
CP DM IN_ DS EM F_I
NT _
O O T_
_ A_ T_ _ O
CP DM OU SCR L_E
_ A_ D TA
CP DM IN_ TO
_ A_ T_
CP DM OU
_ A_
d)
ve
CP DM
er
_
s
CP
(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
_D A_ T_ F_ _IN T_ LR
_ A_ T_ _ RR NT LR
A_ S N _C _C R
M IN_ DO INT T CL
CP DM OU EO ERR _IN _C
CP DM OU SCR _E Y_I _C
IN UC E_ L LR
LR R
_ A_ D CR PT NT
_I INT R
_C CL
NE F_ CL
_D _E IN R
CP DM IN_ DS EM F_I
NT _
O O T_
_ A_ T_ _ O
CP DM OU SCR L_E
_ A_ D TA
CP DM IN_ TO
_ A_ T_
CP DM OU
_ A_
)
ed
CP DM
rv
se
_
CP
(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
NK TA RT
LI _S TA
_S RT
DR
P
A_ TL _ K
TO
UT K S
M OU INK AR
AD
O IN RE
_D A_ TL _P
_
CP DM OU INK
NK
LI
_ A_ TL
UT
CP DM OU
O
_ A_
A_
)
ed
CP DM
DM
rv
se
_
_
CP
CP
(re
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
CP_DMA_OUTLINK_ADDR This register is used to specify the least significant 20 bits of the first
transmit descriptor’s address. (R/W)
CP_DMA_OUTLINK_STOP Set this bit to stop DMA from reading transmit descriptors after finishing
the current data transaction. (R/W)
CP_DMA_OUTLINK_RESTART Set this bit to restart the transmit descriptor from the last address.
(R/W)
CP_DMA_OUTLINK_PARK 1: the transmit descriptor’s FSM is in idle state. 0: the transmit descrip-
tor’s FSM is working. (RO)
DR
P
M INL _R K
IN K_ ST
TO
_D A_ INK PAR
AD
A_ IN E
CP DM INL K_
K_
_ A_ IN
IN
CP DM INL
L
IN
_ A_
A_
)
ed
CP M
DM
rv
_D
se
_
CP
CP
(re
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
CP_DMA_INLINK_ADDR This register is used to specify the least significant 20 bits of the first receive
descriptor’s address. (R/W)
CP_DMA_INLINK_STOP Set this bit to stop DMA from reading receive descriptors after finishing the
current data transaction. (R/W)
CP_DMA_INLINK_START Set this bit to enable DMA to read receive descriptors. (R/W)
CP_DMA_INLINK_PARK 1: the receive descriptor’s FSM is in idle state. 0: the receive descriptor’s
FSM is working. (RO)
K
AC
_ A_ T_ ER RB
_ A_ O TO ER
_R ST T
CP DM OU WN _W
CP DM IN_ AU WN
CP DM CM RS ER
IN R RS
_ A_ O_ N
A_ T_ _
_ A_ T_ O
_D A_ DF T
M OU IFO
CP DM FIF OW
CP DM OU K_
EN
ST
_ A_ EC
K_
CP DM CH
CL
A_
_ A_
d)
ve
M
CP DM
_D
er
_
s
CP
CP
(re
31 30 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
CP_DMA_CMDFIFO_RST Set this bit to reset in_cmd FIFO and out_cmd FIFO. (R/W)
CP_DMA_OUT_OWNER This is used to configure the owner bit in transmit descriptor. This is effective
only when you set CP_DMA_OUT_AUTO_WRBACK. (R/W)
CP_DMA_IN_OWNER This is used to configure the owner bit in receive descriptor. (R/W)
CP_DMA_OUT_AUTO_WRBACK This bit is used to write back out descriptor when hardware has
already used this descriptor. (R/W)
CP_DMA_CHECK_OWNER Set this bit to enable owner bit check in descriptor. (R/W)
CP_DMA_CLK_EN 1’b1: Force clock on for register. 1’b0: Support clock only when application
writes registers. (R/W)
31 0
0x000000 Reset
CP_DMA_OUT_EOF_DES_ADDR This register stores the address of the transmit descriptor when
the EOF bit in this descriptor is 1. (RO)
R
DD
_A
S
DE
F_
EO
C_
U
_S
IN
A_
M
_D
CP
31 0
0x000000 Reset
CP_DMA_IN_SUC_EOF_DES_ADDR This register stores the address of the receive descriptor when
received successful EOF. (RO)
DR
AD
S_
DE
R_
BF
F_
O
_E
UT
O
A_
M
_D
CP
31 0
0x000000 Reset
31 0
0 Reset
0
BF
R_
SC
_D
NK
LI
IN
A_
M
_D
CP
31 0
0 Reset
CR
S
_D
NK
LI
UT
O
A_
M
_D
CP
31 0
0 Reset
31 0
0 Reset
R
DD
TE
A
R_
TA
Y
SC
_S
PT
TE
_D
CR
M
TA
_E
NK
S
_D
_S
FO
LI
IN
IN
IN
FI
A_
A_
A_
A_
d)
ve
DM
DM
_D
_D
er
_
s
CP
CP
CP
CP
(re
31 24 23 22 20 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
CP_DMA_INLINK_DSCR_ADDR This register stores the current receive descriptor’s address. (RO)
D DR
E
_A
AT
CR
ST
DS
R_
TE
L
K_
SC
UL
TA
N
_D
_S
_F
LI
FO
UT
UT
UT
FI
O
A_
A_
A_
A_
ed)
M
rv
_D
_D
_D
_D
se
CP
CP
CP
CP
(re
31 24 23 22 20 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
TE
DA
A_
DM
A_
DM
_
CP
31 0
0x18082000 Reset
CR PT DM AH OO P_T BA LR
CR PT DM OU _EO _B _E N
CR PT DM OU _AU RES E N
Y O_ A_ L O R _C
YP O_D A_ BM P_T ES CK
Y O_ A_ T R ST _E
Y O_ A_ T _ D _E
Y O_ A_ T F_ UR N
CR PT DM IN_ _LO _W RT
CR PT DM OU DSC UR ST
CR PT DM OU _NO MO ST
TO M AH _R ES T
CR PT DM OU CR _B N
ST
Y O_ A_ T TO TA
Y O_ A_ T _B UR
Y O_ A_ S TA _E
_D A_ BM ST T
_R ST R
CR PT DM IND _DA NS
IN R O_
A_ T_ IF
Y O_ A_ T A
CR PT DM OU _TR
M OU _F
ST
Y O_ A_ M
CR PT DM ME
Y O_ A_
CR PT DM
Y O_
)
ed
CR PT
rv
se
Y
CR
31 (re 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 1 0 0 0 0 0 0 0 0 Reset
CRYPTO_DMA_IN_RST This bit is used to reset crypto DMA in FSM and RX FIFO pointer. (R/W)
CRYPTO_DMA_OUT_RST This bit is used to reset crypto DMA out FSM and TX FIFO pointer. (R/W)
CRYPTO_DMA_AHBM_FIFO_RST This bit is used to reset crypto DMA AHB master FIFO pointer.
(R/W)
CRYPTO_DMA_OUTDSCR_BURST_EN Set this bit to enable INCR burst transfer when TX FIFO
reads descriptor from internal RAM. (R/W)
CRYPTO_DMA_INDSCR_BURST_EN Set this bit to enable INCR burst transfer when RX FIFO reads
descriptor from internal RAM. (R/W)
CRYPTO_DMA_OUT_DATA_BURST_EN Set this bit to enable INCR burst transfer when TX FIFO
reads data from internal RAM. (R/W)
CRYPTO_DMA_MEM_TRANS_EN Set this bit to enable automatic transmitting data from memory
to memory via DMA. (R/W)
NK TA RT
LI _S TA
_S RT
DR
P
A_ TL _ K
TO
UT K S
M OU INK AR
AD
O IN RE
_D A_ TL _P
_
TO M OU INK
NK
LI
YP O_D A_ TL
UT
CR PT DM OU
O
Y O_ A_
A_
CR PT DM
M
_D
Y O_
)
ed
TO
CR PT
rv
YP
se
Y
CR
CR
(re
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
CRYPTO_DMA_OUTLINK_ADDR This register stores the 20 least significant bits of the first transmit
descriptor’s address. (R/W)
CRYPTO_DMA_OUTLINK_STOP Set this bit to stop DMA from reading transmit descriptors after
finishing the current data transaction. (R/W)
CRYPTO_DMA_OUTLINK_START Set this bit to enable DMA to read transmit descriptors. (R/W)
CRYPTO_DMA_OUTLINK_RESTART Set this bit to restart a new outlink from the last address. (R/W)
E T
NK TA RT
_R
LI S A
_S RT
R
TO
P
M INL _R K
IN K_ ST
DD
TO
_D A_ INK AR
U
A_ IN E
TO M INL K_P
_A
_A
NK
NK
YP O_D A_ IN
LI
LI
CR PT DM INL
IN
IN
Y O_ A_
A_
A_
CR PT DM
M
_D
_D
Y O_
)
ed
TO
TO
CR PT
rv
YP
YP
se
Y
CR
CR
CR
(re
31 30 29 28 27 21 20 19 0
0 0 0 0 0 0 0 0 0 0 0 1 0x000 Reset
CRYPTO_DMA_INLINK_ADDR This register stores the 20 least significant bits of the first receive
descriptor’s address. (R/W)
CRYPTO_DMA_INLINK_STOP Set this bit to stop DMA from reading receive descriptors after finish-
ing the current data transaction. (R/W)
CRYPTO_DMA_INLINK_START Set this bit to enable DMA to read receive descriptors. (R/W)
CRYPTO_DMA_INLINK_PARK 1: the receive descriptor’s FSM is in idle state. 0: the receive de-
scriptor’s FSM is working. (RO)
RS
IZ
H
R
_S
_T
NE
EC _BK
LL
W
U
O
CH EM
_F
K_
_M
OF
_D EXT
FI
IN
TO A_
A_
A_
YP DM
M
_D
CR O_
)
ed
TO
T
rv
YP
YP
se
CR
CR
(re
31 15 14 13 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
CRYPTO_DMA_CHECK_OWNER Set this bit to enable checking the owner attribute of the link de-
scriptor. (R/W)
DE
R
DD
O
M
TA
ST
ES
TE
_T
B_
HB
AH
ed A_A
A_
DM
M
_D
(re O_
)
)
ed
TO
T
v
rv
YP
YP
er
se
s
CR
CR
(re
31 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 0 0 Reset
CT
LE
SE
A_
SH
S_
AE
A_
M
_D
d)
TO
ve
YP
r
se
CR
(re
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
CRYPTO_DMA_AES_SHA_SELECT Select one between AES and SHA to use DMA. 0: AES. 1:SHA.
(R/W)
RC PU
PD
O E_
E_
RA _F _FO
_F C
M OR
A_ M K
M RA CL
_D A_ M_
TO M RA
YP O_D A_
CR PT DM
Y O_
)
)
ed
ed
CR PT
rv
rv
se
se
Y
CR
(re
(re
31 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 1 0 0 0 0 0 Reset
CRYPTO_DMA_RAM_FORCE_PD Force power down signal to RAM. 0: force RAM power up; 1:
only when CRYPTO_DMA_RAM_FORCE_PU is 0, power down RAM. (R/W)
CRYPTO_DMA_RAM_CLK_FO 1: Force to open the clock and bypass the gate-clock when access-
ing the RAM in DMA. 0: A gate-clock will be used when accessing the RAM in DMA. (R/W)
31 0
0x19050700 Reset
CR PT DM OU SC R_E Y_ _R W
_D A_ ER NE _R _RA W
Y O_ A_ D C PT INT A
TO M IN_ DO INT NT RA
M IN_ R_ _IN AW W
CR PT DM IN_ _DS EM F_ T_R
AW W
_I INT AW
O O T W
_R RA
Y O_ A_ T R_ EO IN
_D _E _IN A
NE F_ _R
CR PT DM OU SC L_ M_
IN UC OF T_R
NT _
Y O_ A_ D TA W
CR PT DM IN_ _TO LL_
Y O_ A_ T FU
A_ S E
CR PT DM OU O_
Y O_ A_ IF
CR PT DM INF
Y O_ A_
CR PT DM
Y O_
)
ed
CR PT
rv
se
Y
CR
(re
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
CRYPTO_DMA_IN_DONE_INT_RAW The raw interrupt status. Set when the last data of one frame
is received or the receive buffer is full indicated by receive descriptor. (RO)
CRYPTO_DMA_IN_SUC_EOF_INT_RAW The raw interrupt status. Set when the last data of one
frame is received by Crypto DMA RX FIFO. (RO)
CRYPTO_DMA_OUT_DONE_INT_RAW The raw interrupt status. Set when all data indicated by one
transmit descriptor has been pushed into TX FIFO. (RO)
CRYPTO_DMA_OUT_EOF_INT_RAW The raw interrupt status. Set when Out EOF flag is generated.
(RO)
Y O_ A_ D C PT INT T
TO M IN_ DO INT NT ST
CR PT DM IN_ _DS EM F_ T_S
_D A_ ER NE _S _ST
_S ST
Y O_ A_ T R_ EO IN
_I INT T
_D _E _IN T
NE F_ _S
CR PT DM OU SC L_ M_
IN UC OF T_S
NT _
M IN_ R_ _IN T
T
O O T
Y O_ A_ D TA W
CR PT DM IN_ _TO LL_
Y O_ A_ T FU
A_ S E
CR PT DM OU O_
Y O_ A_ IF
CR PT DM INF
Y O_ A_
CR PT DM
Y O_
d)
ve
CR PT
r
se
Y
CR
(re
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
CR PT DM OU SC R_E Y_ _E A
_D A_ ER NE _E _EN A
Y O_ A_ D C PT INT N
TO M IN_ DO INT NT EN
CR PT DM IN_ _DS EM F_ T_E
M IN_ R_ _IN NA A
CR PT DM OU _EO ER R_I T_E
NA A
_I INT NA
O O T A
_E EN
Y O_ A_ T R_ EO IN
_D _E _IN N
NE F_ _E
CR PT DM OU SC L_ M_
NT _
IN UC OF T_E
Y O_ A_ D TA W
CR PT DM IN_ _TO LL_
Y O_ A_ T FU
A_ S E
CR PT DM OU O_
Y O_ A_ IF
CR PT DM INF
Y O_ A_
CR PT DM
Y O_
)
ed
CR PT
rv
se
Y
CR
(re
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
CR PT DM OU SC R_E Y_ _C R
_D A_ ER NE _C _C R
Y O_ A_ D C PT INT L
TO M IN_ DO INT NT CL
CR PT DM IN_ _DS EM F_ T_C
M IN_ R_ _IN LR LR
LR R
_I INT LR
O O T R
_C CL
Y O_ A_ T R_ EO IN
_D _E _IN L
NE F_ _C
CR PT DM OU SC L_ M_
IN UC OF T_C
NT _
Y O_ A_ D TA W
CR PT DM IN_ _TO LL_
Y O_ A_ T FU
A_ S E
CR PT DM OU O_
Y O_ A_ IF
CR PT DM INF
Y O_ A_
CR PT DM
Y O_
)
ed
CR PT
rv
se
Y
CR
(re
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
_F PTY
L
UL
O EM
A_ T_
UT
M OU
_D A_
TO M
YP O_D
)
ed
CR PT
v
er
Y
s
CR
(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
_F TY
L
IN MP
UL
A_ E
M IN_
_D A_
TO M
YP O_D
ed)
CR PT
rv
se
Y
CR
(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
R
G
DD
BU
A
E
AT
R_
_D
ST
SC
NT
R_
E
_D
_C
AT
SC
NK
FO
ST
_D
FI
LI
_
IN
IN
IN
IN
A_
A_
A_
A_
M
M
_D
_D
_D
_D
)
ed
TO
TO
TO
TO
rv
YP
YP
YP
YP
se
CR
CR
CR
CR
(re
31 27 26 23 22 20 19 18 17 0
0 0 0 0 0 0 0 0 0 Reset
CRYPTO_DMA_INFIFO_CNT_DEBUG This register stores the byte number of the data in the receive
descriptor’s FIFO. (RO)
DR
D
E
_A
AT
CR
ST
NT
DS
R_
TE
_C
K_
SC
TA
O
N
F
_D
_S
FI
LI
UT
UT
UT
UT
O
O
A_
A_
A_
A_
M
M
_D
_D
_D
_D
)
ed
TO
TO
TO
TO
rv
YP
YP
YP
YP
se
CR
CR
CR
CR
(re
31 28 27 23 22 20 19 18 17 0
0 0 0 0 0 0 0 0 Reset
CRYPTO_DMA_OUTFIFO_CNT This register stores the byte number of the data in the transmit de-
scriptor’s FIFO. (RO)
DR
AD
S_
DE
F_
_ EO
UT
O
A_
M
_D
TO
YP
CR
31 0
0x000000 Reset
DR
AD
S_
DE
F_
O
_E
UC
_S
IN
A_
M
_D
TO
YP
CR
31 0
0x000000 Reset
31 0
0x000000 Reset
R
DD
_A
S
DE
R_
BF
F_
_ EO
UT
O
A_
M
_D
TO
YP
CR
31 0
0x000000 Reset
S CR
K_D
L IN
IN
A_
M
_D
TO
YP
CR
31 0
0 Reset
31 0
0 Reset
CR
DS
K_
LIN
UT
O
A_
M
_D
TO
YP
CR
31 0
0 Reset
F0
_B
CR
S
_D
NK
LI
UT
O
A_
M
_D
TO
YP
CR
31 0
0 Reset
3.1 Overview
The ESP32-S2 is a single-core system with one Harvard Architecture Xtensa® LX7 CPU. All internal memory,
external memory, and peripherals are located on the CPU buses.
3.2 Features
• Address Space
– 4 GB (32 bits wide) address space in total accessed from the data bus and instruction bus
– 464 KB internal memory address space accessed from the instruction bus
– 400 KB internal memory address space accessed from the data bus
– 7.5 MB external memory virtual address space accessed from the instruction bus
– 14.5 MB external memory virtual address space accessed from the data bus
• Internal Memory
• External Memory
• DMA
0x0000_0000
0x3EFF_FFFF
0x3F00_0000
0x3F3F_FFFF
0x3F40_0000
0x3F4F_FFFF
0x3F50_0000
0x3FF7_FFFF
0x3FF8_0000
0x3FF9_DFFF
0x3FF9_E000
Cache 0x3FFF_FFFF
0x4000_0000
0x4007_1FFF
0x4007_2000
0x4007_FFFF
Internal memory DMA
0x4008_0000
0x407F_FFFF
0x4080_0000
0x4FFF_FFFF
External memory MMU
0x5000_0000
0x5000_1FFF
0x5000_2000
0x5FFF_FFFF
0x6000_0000
DMA Peripheral
0x600B_FFFF
0x600C_0000
0x617F_FFFF
0x6180_0000
0x6180_3FFF
0x6180_4000
0xFFFF_FFFF
Note:
• The range of addresses available in the address space may be larger or smaller than the actual available memory
of a particular type.
Addresses below 0x4000_0000 are serviced using the data bus. Addresses in the range 0x4000_0000 ~
0x4FFF_FFFF are serviced using the instruction bus. Addresses over and including 0x5000_0000 are shared by
both data and instruction bus.
Both data bus and instruction bus are little-endian. The CPU can access data via the data bus in a byte-,
half-word-, or word-aligned manner. The CPU can also access data via the instruction bus, but only in a
word-aligned manner; non-word-aligned access will cause a CPU exception.
• directly access the internal memory via both data bus and instruction bus;
• access the external memory which is mapped into the address space via cache;
Table 22 lists the address ranges on the data bus and instruction bus and their corresponding target
memory.
Some internal and external memory can be accessed via both data bus and instruction bus. In such cases, the
same memory is available to the CPU at two address ranges.
Boundary Address
Bus Type Size Target
Low Address High Address
0x0000_0000 0x3EFF_FFFF Reserved
0x3F00_0000 0x3F3F_FFFF 4 MB External memory
Data bus 0x3F40_0000 0x3F4F_FFFF 1 MB Peripherals
0x3F50_0000 0x3FF7_FFFF 10.5 MB External memory
0x3FF8_0000 0x3FF9_DFFF Reserved
Data bus 0x3FF9_E000 0x3FFF_FFFF 392 KB Internal memory
Instruction bus 0x4000_0000 0x4007_1FFF 456 KB Internal memory
0x4007_2000 0x4007_FFFF Reserved
Instruction bus 0x4008_0000 0x407F_FFFF 7.5 MB External memory
0x4080_0000 0x4FFF_FFFF Reserved
Data / Instruction bus 0x5000_0000 0x5000_1FFF 8 KB Internal memory
0x5000_2000 0x5FFF_FFFF Reserved
Data / Instruction bus 0x6000_0000 0x600B_FFFF 768 KB Peripherals
0x600C_0000 0x617F_FFFF Reserved
Data / Instruction bus 0x6180_0000 0x6180_3FFF 16 KB Peripherals
0x6180_4000 0xFFFF_FFFF Reserved
The Internal ROM is broken down into two parts: Internal ROM 0 (64 KB) and Internal ROM 1 (64 KB).
The Internal SRAM is broken down into two parts: Internal SRAM 0 (32 KB) and Internal SRAM 1 (288 KB).
RTC FAST Memory and RTC SLOW Memory are both implemented as SRAM.
Table 23 lists all types of internal memory and their address ranges on the data bus and instruction bus.
Boundary Address
Bus Type Size Target Permission Control
Low Address High Address
0x3FF9_E000 0x3FF9_FFFF 8 KB RTC FAST Memory YES
0x3FFA_0000 0x3FFA_FFFF 64 KB Internal ROM 1 NO
Data bus
0x3FFB_0000 0x3FFB_7FFF 32 KB Internal SRAM 0 YES
0x3FFB_8000 0x3FFF_FFFF 288 KB Internal SRAM 1 YES
Boundary Address
Bus Type Size Target Permission Control
Low Address High Address
0x4000_0000 0x4000_FFFF 64 KB Internal ROM 0 NO
0x4001_0000 0x4001_FFFF 64 KB Internal ROM 1 NO
Instruction bus 0x4002_0000 0x4002_7FFF 32 KB Internal SRAM 0 YES
0x4002_8000 0x4006_FFFF 288 KB Internal SRAM 1 YES
0x4007_0000 0x4007_1FFF 8 KB RTC FAST Memory YES
Boundary Address
Bus Type Size Target Permission Control
Low Address High Address
Data / Instruction bus 0x5000_0000 0x5000_1FFF 8 KB RTC SLOW Memory YES
Note:
”YES” in the ”Permission Control” column indicates that a permission is required for memory access. Permission
Control registers can be used to limit Instruction or Data bus access to individual regions of these memory types.
The two address ranges access Internal ROM 1 in the same order, so, for example, addresses 0x3FFA_0000 and
0x4001_0000 access the same word, 0x3FFA_0004 and 0x4001_0004 access the same word, 0x3FFA_0008
and 0x4001_0008 access the same word, etc.
Hardware can be configured to use 8 KB, 16 KB, 24 KB, or the entire 32 KB space in this memory to cache
external memory. The space used as cache cannot be accessed by the CPU, while the remaining space can still
be accessed by the CPU.
Internal SRAM 1 comprises eighteen 16-KB (sub)memory blocks. One block can be used as Trace Memory, in
which case this block’s address range cannot be accessed by the CPU.
RTC SLOW Memory can also be used as a peripheral addressable to the CPU via either 0x3F42_1000 ~
0x3F42_2FFF or 0x6002_1000 ~ 0x6002_2FFF on the data bus.
Using the cache, ESP32-S2 can support the following address space mappings at the same time.
• Up to 7.5 MB instruction bus address space can be mapped into the external flash or RAM as individual 64
KB blocks, via the instruction cache (ICache). Byte (8-bit), half-word (16-bit) and word (32-bit) reads are
supported.
• Up to 4 MB read-only data bus address space can be mapped into the external flash or RAM as individual
64 KB blocks, via ICache. Byte (8-bit), half-word (16-bit) and word (32-bit) reads are supported.
• Up to 10.5 MB data bus address space can be mapped into the external RAM as individual 64 KB blocks,
via DCache. Byte (8-bit), half-word (16-bit) or word (32-bit) reads and writes are supported. Blocks from
this 10.5 MB space can also be mapped into the external flash or RAM, for read operations only.
Table 24 lists the mapping between the cache and the corresponding address ranges on the data bus and
instruction bus.
Boundary Address
Bus Type Size Target Permission Control
Low Address High Address
Data bus 0x3F00_0000 0x3F3F_FFFF 4 MB ICache YES
Data bus 0x3F50_0000 0x3FF7_FFFF 10.5 MB DCache YES
Instruction bus 0x4008_0000 0x407F_FFFF 7.5 MB ICache YES
Note:
”YES” in the ”Permission Control” column indicates that a permission is required for memory access. Permission
Control registers can be used to limit Instruction or Data bus access to individual regions of these memory types.
3.3.3.2 Cache
As shown in Figure 3-2, the caches on ESP32-S2 are separated and allow prompt response upon simultaneous
requests from the data bus and instruction bus. Some internal memory space can be used as cache (see
Section 3.3.2.3). When a cache miss occurs, the cache controller will initiate a request to the external memory.
When ICache and DCache simultaneously initiate a request, the arbiter determines which gets the access to the
external memory first. The cache size of ICache and DCache can be configured to 8 KB and 16 KB, respectively,
while their block size can be configured to 16 bytes and 32 bytes, respectively.
1. Invalidate: The cache clears the valid bit of a tag. The CPU needs to access the external memory in order
to read/write the data. There are two types of invalidation operations: manual invalidation and automatic
invalidation. Manual invalidation performs only on data in the specified area in the cache, while automatic
invalidation performs on all data in the cache. Both ICache and DCache have this function.
2. Clean: The cache clears the dirty bit of the tag and retains the valid bit. The CPU can then read/write the
data directly from the cache. Only DCache has this function.
3. Writeback: The cache clears the dirty block flag of the tag and retains the valid bit. It also forces the data
in the corresponding address to be written back to the external memory. The CPU can then read/write the
data directly from the cache. Only DCache has this function.
4. Preload: To preload a cache is to load instructions and data into the cache in advance. The minimum unit
of a preloading is one block. There are two types of preloading: manual preloading and automatic
preloading. Manual preloading means that the hardware prefetches a piece of continuous data according
to the virtual address specified by the software. Automatic preloading means the hardware prefetches a
piece of continuous data according to the current hit / miss address (depending on configuration).
5. Lock / Unlock: There are two types of lock: prelock and manual lock. When prelock is enabled, the cache
locks the data in the specified area when filling the missing data to cache memory. When manual lock is
enabled, the cache checks the data that has been filled into the cache memory and locks the data that falls
in the specified area. The data in the locked area is always stored in the cache and will not be replaced.
But when all the ways within the cache are locked, the cache will replace data, as if the ways were not
locked. Unlocking is the reverse of locking. The manual invalidation, clean, and write-back operations are
only available after unlocking.
3.3.4 DMA
With DMA, the ESP32-S2 can perform data transfers between:
DMA uses the same addressing as the data bus to read and write Internal SRAM 0 and Internal SRAM 1.
Specifically, DMA uses address range 0x3FFB_0000 ~ 0x3FFB_7FFF to access Internal SRAM 0, and
0x3FFB_8000 ~ 0x3FFF_FFFF to access Internal SRAM 1. Note that DMA cannot access the internal memory
occupied by the cache.
In addition, DMA addresses the external RAM from 0x3F50_0000 ~ 0x3FF7_FFFF, the same used by the CPU to
access DCache. When DCache and DMA access the external memory simultaneously, data consistency is
required.
Nine modules / peripherals on the ESP32-S2 support DMA, as shown in Table 25. With DMA, some of them can
only access internal memory, some can access both internal and external memory.
UART0 UART1
SPI2 SPI3
I2S0
ADC Controller
Copy DMA
AES Accelerator SHA Accelerator
• PeriBus1: Which refers to the address range 0x3F40_0000 ~ 0x3F4F_FFFF on the bus. 0x3F40_0000 is
the base address.
• PeriBus2: Which refers to the address ranges 0x6000_0000 ~ 0x600B_FFFF and 0x6180_0000 ~
0x6180_3FFF on the bus. 0x6000_0000 is the base address.
All references to “PeriBus1” and “PeriBus2” in this document indicate the corresponding address range(s).
In addition, PeriBus1 will upset the order of r/w operations on the bus to improve performance, which may cause
programs that have strict requirements on the r/w order to crash. In such cases, please add volatile before the
program statement, or use PeriBus2 instead.
Boundary Address
Target Size Notes
Low Address High Address
UART0 0x0000_0000 0x0000_0FFF 4 KB 1, 2, 3
Reserved 0x0000_1000 0x0000_1FFF
SPI1 0x0000_2000 0x0000_2FFF 4 KB 1, 2
SPI0 0x0000_3000 0x0000_3FFF 4 KB 1, 2
GPIO 0x0000_4000 0x0000_4FFF 4 KB 1, 2
Reserved 0x0000_5000 0x0000_6FFF
TIMER 0x0000_7000 0x0000_7FFF 4 KB 1, 2
RTC 0x0000_8000 0x0000_8FFF 4 KB 1, 2
IO MUX 0x0000_9000 0x0000_9FFF 4 KB 1, 2
Reserved 0x0000_A000 0x0000_EFFF
I2S0 0x0000_F000 0x0000_FFFF 4 KB 1, 2, 3
UART1 0x0001_0000 0x0001_0FFF 4 KB 1, 2, 3
Reserved 0x0001_1000 0x0001_2FFF
I2C0 0x0001_3000 0x0001_3FFF 4 KB 1, 2, 3
UHCI0 0x0001_4000 0x0001_4FFF 4 KB 1, 2
Reserved 0x0001_5000 0x0001_5FFF
RMT 0x0001_6000 0x0001_6FFF 4 KB 1, 2, 3
PCNT 0x0001_7000 0x0001_7FFF 4 KB 1, 2
Reserved 0x0001_8000 0x0001_8FFF
LED PWM Controller 0x0001_9000 0x0001_9FFF 4 KB 1, 2
eFuse Controller 0x0001_A000 0x0001_AFFF 4 KB 1, 2
Reserved 0x0001_B000 0x0001_EFFF
Timer Group 0 0x0001_F000 0x0001_FFFF 4 KB 1, 2
Timer Group 1 0x0002_0000 0x0002_0FFF 4 KB 1, 2
RTC SLOW Memory 0x0002_1000 0x0002_2FFF 8 KB 1, 2, 3
System Timer 0x0002_3000 0x0002_3FFF 4 KB 1, 2
SPI2 0x0002_4000 0x0002_4FFF 4 KB 1, 2
Boundary Address
Target Size Notes
Low Address High Address
SPI3 0x0002_5000 0x0002_5FFF 4 KB 1, 2
APB Controller 0x0002_6000 0x0002_6FFF 4 KB 1, 2
I2C1 0x0002_7000 0x0002_7FFF 4 KB 1, 2, 3
Reserved 0x0002_8000 0x0002_AFFF
TWAI Controller 0x0002_B000 0x0002_BFFF 4 KB 1, 2
Reserved 0x0002_C000 0x0003_8FFF
USB OTG 0x0003_9000 0x0003_9FFF 4 KB 1, 2, 3, 4
AES Accelerator 0x0003_A000 0x0003_AFFF 4 KB 1, 2
SHA Accelerator 0x0003_B000 0x0003_BFFF 4 KB 1, 2
RSA Accelerator 0x0003_C000 0x0003_CFFF 4 KB 1, 2
Digital Signature 0x0003_D000 0x0003_DFFF 4 KB 1, 2
HMAC 0x0003_E000 0x0003_EFFF 4 KB 1, 2
Crypto DMA 0x0003_F000 0x0003_FFFF 4 KB 1, 2
Reserved 0x0004_4000 0x000C_DFFF
ADC Controller 0x0004_0000 0x0004_0FFF 4 KB 1, 2
Reserved 0x0004_1000 0x0007_FFFF
USB OTG 0x0008_0000 0x000B_FFFF 256 KB 1, 2, 3, 4
System Registers 0x000C_0000 0x000C_0FFF 4 KB 1
Sensitive Register 0x000C_1000 0x000C_1FFF 4 KB 1
Interrupt Matrix 0x000C_2000 0x000C_2FFF 4 KB 1
Copy DMA 0x000C_3000 0x000C_3FFF 4 KB 1
Reserved 0x000C_4000 0x000C_EFFF
Dedicated GPIO 0x000C_F000 0x000C_FFFF 4 KB 1
Reserved 0x000D_1000 0x000F_FFFF
Configure Cache 0x0180_0000 0x0180_3FFF 16 KB 2
Note:
3. Some special addresses in this module / peripheral are not accessible from PeriBus1 (see Section 3.3.5.4).
There are four reserved user-defined registers that can be configured as needed to add more addresses with
restricted access. For more information, please refer to Chapter 14: Permission Control.
4.1 Overview
ESP32-S2 has a 4096-bit eFuse that stores parameters in the SoC. Once an eFuse bit is programmed to 1, it
can never be reverted to 0. Users can instruct the eFuse Controller to program individual bits for individual
parameters as needed. From outside the chip, eFuse data can only be read via the eFuse Controller. If
read-protection for some data is not enabled, that data is readable from outside the chip. If read-protection is
enabled, that data can not be read from outside the chip. In all cases, however, some keys stored in eFuse can
still be used internally by hardware cryptography modules such as Digital Signature, HMAC, etc., without
exposing this data to the outside world.
4.2 Features
• One-time programmable storage
BLOCK0 holds most core system parameters. Among these parameters, 24 bits are readable but useless to
users, 38 bits are reserved for future use.
Table 28 lists all the parameters accessible (readable and usable) to users in BLOCK0 and their offsets, bit
widths, functional description, as well as information about whether their configuration is directly accessible by
the hardware, and whether they are protected from programming.
The EFUSE_WR_DIS parameter is used to restrict the programming of other parameters, while EFUSE_RD_DIS
is used to restrict users from reading BLOCK4 ~ BLOCK10. More information on these two parameters can be
found in sections 4.3.1.1 and 4.3.1.2.
Programming-Protection
Bit Accessible
Parameters Offset by EFUSE_WR_DIS Description
Width by Hardware
Bit Number
Programming-Protection
Bit Accessible
Parameters Offset by EFUSE_WR_DIS Description
Width by Hardware
Bit Number
Programming-Protection
Bit Accessible
Parameters Offset by EFUSE_WR_DIS Description
Width by Hardware
Bit Number
Programming-Protection
Bit Accessible
Parameters Offset by EFUSE_WR_DIS Description
Width by Hardware
Bit Number
Table 29 lists all key purpose and their values. Setting the eFuse parameter EFUSE_KEY_PURPOSE_n programs
the purpose for eFuse block KEYn (n: 0 ~ 5).
Among these blocks, BLOCK4 ~ 9 stores KEY0 ~ 5, respectively. Up to six 256-bit keys can be programmed
into eFuse. Whenever a key is programmed, its purpose value should also be programmed (see table 29). For
example, a key for the JTAG function in HMAC Downstream mode is programmed to KEY3 (i.e., BLOCK7), then,
the key purpose value 6 should be programmed to EFUSE_KEY_PURPOSE_3.
BLOCK1 ~ BLOCK10 use the RS coding scheme, so there are some restrictions on writing to these parameters
(refer to Section 4.3.1.3: Data Storage and Section 4.3.2: User Programming of Parameters).
4.3.1.1 EFUSE_WR_DIS
Parameter EFUSE_WR_DIS determines whether individual eFuse parameters are write-protected. After burning
EFUSE_WR_DIS, execute an eFuse read operation so the new values will take effect (refer to Updating eFuse
read registers in Section 4.3.3).
The columns “Programming-Protected by EFUSE_WR_DIS” in Table 28 and Table 30 list the specific bits of
EFUSE_WR_DIS that determine the write protected status of each parameter.
When the corresponding bit is 0, the parameter is not write protected and can be programmed if the parameter
has not been programmed.
When the corresponding bit is 1, the parameter is write protected and none of its bits can be modified. The
non-programmed bits always remain 0, while programmed bits always remain 1.
4.3.1.2 EFUSE_RD_DIS
Only the eFuse blocks BLOCK4 ~ BLOCK10 can be individually read protected to prevent any access from
outside the chip. The corresponding bit in EFUSE_RD_DIS is shown in Table 30. After burning EFUSE_RD_DIS,
execute an eFuse read operation so the new values take effect (refer to Updating eFuse read registers in Section
4.3.3).
If the corresponding EFUSE_RD_DIS bit is 0, then the eFuse block can be read by users. If the corresponding
EFUSE_RD_DIS bit is 1, then the parameter controlled by this bit is user read protected.
Other parameters that are not in BLOCK4 ~ BLOCK10 can always be read by users.
When BLOCK4 ~ BLOCK10 are set to read-protected, the data in these blocks are not readable by users, but
they can still be used internally by hardware cryptography modules, if the EFUSE_KEY_PURPOSE_n bit is set
accordingly.
All BLOCK0 parameters except for EFUSE_WR_DIS are stored with four backups, meaning each bit is stored
four times. This backup scheme is hardwired to the chip.
BLOCK1 ~ BLOCK10 use RS (44, 32) coding scheme that supports up to 5 bytes of automatic error correction.
The primitive polynomial of RS (44, 32) is p(x) = x8 + x4 + x3 + x2 + 1.
The shift register circuit shown in Figure 4-1 and 4-2 processes 32 data bytes using RS (44, 32). This coding
scheme encodes 32 bytes of data into 44 bytes:
• Bytes [32:43] are the encoded parity bytes stored in 8-bit flip-flops DFF1, DFF2, ..., DFF12 (gf_mul_n,
where n is an integer, is the result of multiplying a byte of data ...)
After that, the hardware burns into eFuse the 44-byte codeword consisting of the data bytes followed by the
parity bytes.
When the eFuse block is read back, the eFuse controller automatically decodes the codeword and applies error
correction if needed.
Because the RS check codes are generated across the entire 256-bit eFuse block, each block can only be
written to one time.
Programming BLOCK0
• EFUSE_PGM_DATA1_REG[29:31]
• EFUSE_PGM_DATA1_REG[20:23]
• EFUSE_PGM_DATA2_REG[7:15]
• EFUSE_PGM_DATA2_REG[0:3]
• EFUSE_PGM_DATA3_REG[16:19]
Programming BLOCK1
Programming BLOCK2 ~ 10
Programming process
3. Ensure the eFuse clock registers are set correctly as described in Section 4.3.4.1: eFuse-Programming
Timing.
4. Ensure the eFuse programming voltage VDDQ is set correctly as described in Section 4.3.4.2: eFuse
VDDQ Setting.
7. Poll register EFUSE_CMD_REG until it is 0x0, or wait for a pgm_done interrupt. Information on how to
identify a pgm/read_done interrupt is provided at the end of Section 4.3.3.
9. Trigger an eFuse read operation (see Section 4.3.3: User Read of Parameters) to update eFuse registers
with the new values.
Limitations
For BLOCK0, the programming of different parameters and even the programming of different bits of the same
parameter does not need to be done at once. It is, however, recommended that users minimize programming
cycles and program all the bits of a parameter in one programming action. In addition, after all parameters
controlled by a certain bit of EFUSE_WR_DIS are programmed, that bit should be immediately programmed. The
programming of parameters controlled by a certain bit of EFUSE_WR_DIS, and the programming of the bit itself
can even be completed at the same time. Repeated programming of already programmed bits is strictly
forbidden, otherwise, programming errors will occur.
The eFuse Controller hardware populates the read registers from the internal eFuse storage. This read operation
takes place on system reset and can also be triggered manually by users as needed, for example if new eFuse
values have been programmed.
1. Configure the eFuse read timing registers as described in Section 4.3.4.3: eFuse-Read Timing.
4. Poll the EFUSE_CMD_REG register until it is 0x0, or wait for a read_done interrupt. Information on how to
identify a pgm/read_done interrupt is provided below.
The eFuse read registers will now hold updated values for all eFuse parameters.
Error detection
EFUSE_RD_REPEAT_ERR0 ~ 3_REG indicate inconsistencies in the stored backup copies of the parameters in
BLOCK0 (except for EFUSE_WR_DIS) . Value 1 indicates an error was detected, and the bit became invalid.
Value 0 indicates no error.
Registers EFUSE_RD_RS_ERR0 ~ 1_REG store the number of corrected bytes as well as the result of RS
decoding during eFuse reading BLOCK1 ~ BLOCK10.
Users can read the values of above registers only after the eFuse read registers have been updated.
The two methods to identify the completion of program/read operation are described below. Please note that bit
1 corresponds to program operation, and bit 0 corresponds to read operation.
• Method one:
1. Poll bit 1/0 in register EFUSE_INT_RAW_REG until it is 1, which represents the completion of a
program/read operation.
• Method two:
2. Configure Interrupt Matrix to enable the CPU to respond to eFuse interrupt signal.
4. Set the bit 1/0 in register EFUSE_INT_CLR_REG to 1 to clear the pgm/read_done interrupt.
4.3.4 Timing
4.3.4.1 eFuseProgramming Timing
Figure 4-3 shows the timing for programming eFuse. Four registers EFUSE_TSUP_A, EFUSE_TPGM,
EFUSE_THP_A, and EFUSE_TPGM_INACTIVE are used to configure the timing. Terms used in the timing
diagrams in this section are described as follows:
The eFuse block uses the CLK_APB clock, which is configurable. Therefore, the timing parameters should be
configured according to the specific clock frequency. After reset, the initial parameters are based on 20 MHz
clock frequency.
In Figure 4-3, Address A0 is programmed, then the corresponding eFuse bit is 1; Address A1 is not
programmed, then the corresponding eFuse bit is 0.
The parameters should be configured according to the specific APB clock frequency. Details can be found in the
table below.
4.3.6 Interrupts
• pgm_done interrupt: Triggered when eFuse programming has finished. To enable this interrupt, set
EFUSE_PGM_DONE_INT_ENA to 1.
• read_done interrupt: Triggered when eFuse reading has finished. To enable this interrupt, set
EFUSE_READ_DONE_INT_ENA to 1.
4.6 Registers
Register 4.1: EFUSE_PGM_DATAn_REG (n: 07) (0x0000+4*n)
n
A_
AT
_D
M
PG
E_
US
EF
31 0
0x000000 Reset
n
A_
AT
_D
S
_R
M
G
E_P
US
EF
31 0
0x000000 Reset
S
DI
R_
W
E_
US
EF
31 0
0x000000 Reset
PT
RY
NC
_E
AL
AC E
HE
T
IC H
E_ S_I AC OA DC D
G LE SIS
NU
DI CA HE D_ AC
US DI DC L D_ OA
T
EF SE_ PT4 IS TAG MA
CH AB ER
EF SE_ IS_ WN OA NL
O
AP
O
E_ _ RC D0
US DI A _R D5
S
EX EN OP
U R _D _J D_
U D DO L W
IN
_B
EF SE_ IS_ ES TAG
M
US EX FO RVE
EF E_ S_ OT VE
EF SE_ IS_ WN DO
EF SE_ OFT DIS OA
B_ Y_ _N
_P
M
E
US DI BO ER
U D DO E_
RA
US PH E
U S _ L
RT HE
U D _R _J
E
EF SE_ ARD WN
ES
EF SE_ IS_ RC
C_
S_ C
N
EF E_ S_ B
EF E_ 4_R
U H DO
IS
US DI US
U D FO
C
_D
EF SE_ SB_
EF SE_ IS_
EF E_ _
PT
RD
d)
)
U U
U D
_R
ed
EF SE_
E_
ve
SE
rv
US
US
er
se
U
U
s
EF
EF
EF
EF
(re
(re
31 29 28 27 26 25 24 23 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 0
EFUSE_DIS_FORCE_DOWNLOAD Represents whether the function that forces chip into download
mode is disabled. 1: Disabled. 0: Enabled. (RO)
EFUSE_DIS_USB Represents whether to disable USB OTG function. 1: Disabled. 0: Enabled. (RO)
EFUSE_DIS_CAN Represents whether to disable the TWAI Controller function. 1: Disabled. 0: En-
abled. (RO)
EFUSE_SOFT_DIS_JTAG Represents whether JTAG is disabled in the soft way. 1: Disabled. It still
can be restarted via HMAC. 0: Enabled. (RO)
Y_ VO E2
VO E1
0
KE
KE RE K
RE K
T_ _ O
O EY V
O _K RE
T
CN
_B OT EY_
T_
RE BO _K
_1
_0
EL
YP
SP TIE E
D_ I_ RC
CU E_ OT
SE
SE
_S
CR
I_ H
D
SE R O
VD SP O
O
XP
AY
T_
E_ CU _B
E_ D_ I_F
P
RP
EL
UR
O
E
US VD SP
PU
_D
US SE R
_P
B
EF SE_ ECU
EF SE_ D_
Y_
DT
I_
EY
U VD
SP
KE
)
K
U S
ed
ed
E_
E_
EF E_
E_
E_
EF SE_
rv
rv
US
US
US
US
US
se
se
U
EF
EF
EF
EF
EF
EF
(re
(re
31 28 27 24 23 22 21 20 18 17 16 15 7 6 5 4 3 0
EFUSE_KEY_PURPOSE_0 Represents purpose of Key0. Refer to Table 29�Key Purpose Values. (RO)
EFUSE_KEY_PURPOSE_1 Represents purpose of Key1. Refer to Table 29�Key Purpose Values. (RO)
KE
O
EV
_R
VE
SI
S
EN RE
T_ G
O G
D1
O _A
_5
_4
_3
_2
VE
_B OT
SE
SE
SE
SE
W
ER
RE BO
PO
O
PU
RP
RP
RP
ES
CU E_
UR
_T
PU
PU
PU
R
SE R
SH
_P
4_
E_ CU
Y_
Y_
Y_
PT
EY
A
KE
KE
US SE
FL
)
R
_K
_K
ed
E_
E_
EF E_
E_
E_
E
E
rv
US
US
US
US
US
US
US
se
EF
EF
EF
EF
EF
EF
EF
(re
31 28 27 22 21 20 19 16 15 12 11 8 7 4 3 0
EFUSE_KEY_PURPOSE_2 Represents purpose of Key2. Refer to Table 29�Key Purpose Values. (RO)
EFUSE_KEY_PURPOSE_3 Represents purpose of Key3. Refer to Table 29�Key Purpose Values. (RO)
EFUSE_KEY_PURPOSE_4 Represents purpose of Key4. Refer to Table 29�Key Purpose Values. (RO)
EFUSE_KEY_PURPOSE_5 Represents purpose of Key5. Refer to Table 29�Key Purpose Values. (RO)
EFUSE_FLASH_TPUW Represents flash waiting time after power-up. Measurement unit: ms. If the
value is less than 15, the waiting time is the configurable value. Otherwise, the waiting time is
always 30ms. (RO)
O D
M OA
DE
DI E NT D3 D_ L
E_ S_L RI VE OA WN
CO ION
_M OT
DE
L
O I_B L
E
US DI _P ER L O
RO
NL P NE
M
AD O
O
CT
SU
EF E_ RT ES WN Y_
W _S N
NT
N
2
LE
A
US UA _R DO IT
PO P RE
D
DO C H
EF SE_ PT4 B_ UR
SE
VE
SI
S_ GA _C
US N_ TY _
EF _PI H_ END
T_
ER
U R US EC
R_
ER
Y
N
_V
EF _UA WE
RI
E AS _S
E
_P
_R
UR
US FL E
U D L
EF E_ RC
EF E_ AB
RT
T4
EC
RP
US EN
US FO
_S
E_
EF SE_
EF E_
E
E
US
US
US
U
EF
EF
EF
31 27 26 11 10 9 8 7 6 5 4 3 2 1 0
EFUSE_UART_PRINT_CONTROL Represents the default UART boot message output mode. 00:
Enabled. 01: Enable when GPIO46 is low at reset. 10: Enable when GPIO46 is high at reset. 11:
Disabled. (RO)
EFUSE_FLASH_TYPE Represents the SPI flash type. 0: Maximum four data lines. 1: Eight data
lines. (RO)
EFUSE_SECURE_VERSION Represents the values of version control register (used by ESP-IDF anti-
rollback feature). (RO)
D4
VE
ER
ES
_R
T4
RP
)
ed
E_
rv
US
se
EF
(re
31 24 23 0
0 0 0 0 0 0 0 0 0x0000 Reset
_0
AC
M
E_
US
EF
31 0
0x000000 Reset
_1
PA
AC
I_
SP
M
E_
E_
US
US
EF
EF
31 16 15 0
_1
NF
O
_C
AD
_P
PI
E _S
US
EF
31 0
0x000000 Reset
_2
R
NF
PA
O
A_
_C
AT
D
PA
_D
I_
YS
SP
S
E_
E_
US
US
EF
EF
31 18 17 0
EFUSE_SYS_DATA_PART0_0 Stores the zeroth part of the zeroth part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART0_1 Stores the fist part of the zeroth part of system data. (RO)
_2
T0
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART0_2 Stores the second part of the zeroth part of system data. (RO)
_n
R T1
PA
_
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_n Stores the nth 32 bits of the first part of system data. (RO)
31 0
0x000000 Reset
An
AT
_D
Y0
KE
E_
US
EF
31 0
0x000000 Reset
An
AT
_D
Y1
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
An
AT
_D
Y4
KE
E_
US
EF
31 0
0x000000 Reset
An
AT
_D
Y5
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_n Stores the nth 32 bits of the 2nd part of system data. (RO)
RR
_E
PT
RY
NC
_E R
RR
S_ R RR
C_ _E R HE ER
S_ C _ IC H R
_E
DI CA HE D_ AC ER
IN R _E
RT HE ER AC E_
R
EF SE_ IS_ ES TAG ER UAL
E_ S_I AC OA DC D_
_P _E T
ER
G LE SIS
RR
RR
US DI US ER AP RR
R
US DI DC L D_ OA
U D _R _J _ N
T_
ER
U D BO ER _E R
EF SE_ IS_ OT VE RR
EF E_ S_ B_ R _E
EF SE_ PT4 IS TAG MA
_E
EF E_ _ _ M _E
CH AB ER
EF SE_ IS_ WN OA NL
O
O
E_ _ RC D0
US DI A _R D5
EX N P
U R _D _J D_
U D DO L W
RA RR
_B
O
US EX FO RVE
EF SE_ IS_ WN DO
EF SE_ OFT DIS OA
B_ Y_ _N
M
E
RR
US DI O R
U D DO E_
US PH E
U S _ L
E
E
EF SE_ ARD WN
ES
EF E_ _ C
_E
N
R
_R
U H DO
IS
C
_D
EF SE_ SB_
US PT4
EF E_ S_
T
RD
US DI
d)
)
U U
R
ed
E_
EF E_
EF E_
E_
ve
rv
US
US
US
er
se
s
EF
EF
EF
EF
(re
(re
31 29 28 27 26 25 24 23 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 0
VO E1_ R
0_ R
R
RE K ER
KE ER
ER
Y_ VO E2_
RR
KE RE K
T_ _ O
E
O EY V
T_
O _K RE
RR
RR
RR
CN
XP E R
_B OT EY_
I_ H_ ER
_E
_E
_E
D_ RR
T_
R
RE BO _K
SP TIE E_
ER
_1
_0
EL
YP
D_ I_ RC
CU E_ OT
SE
SE
_S
CR
SE R O
VD SP O
PO
PO
AY
T_
E_ CU _B
E_ D_ I_F
EL
UR
UR
O
E
US VD SP
O
_D
US SE R
_P
_P
B
EF E_ CU
EF SE_ D_
DT
I_
EY
EY
U VD
SP
US SE
)
_K
_K
ed
ed
EF E_
E_
E_
EF SE_
E
SE
rv
rv
US
US
US
US
se
se
U
U
EF
EF
EF
EF
EF
EF
(re
(re
31 28 27 24 23 22 21 20 18 17 16 15 7 6 5 4 3 0
R
_ ER
KE
O
EV
_R
RR IVE
_E SS
EN RE
RR
RR
RR
R
R
ER
T_ G
_E
_E
_E
_E
O G
RR
D1
_
O _A
_5
_4
_3
_2
_E
VE
_B OT
SE
SE
SE
SE
W
ER
RE BO
O
PU
RP
RP
RP
RP
ES
CU _
_T
PU
PU
PU
PU
R
SE R
SH
4_
E_ CU
Y_
Y_
Y_
Y_
PT
LA
KE
KE
US SE
)
_R
_K
_K
_F
ed
EF E_
E_
E_
E
E
rv
US
US
US
US
US
US
US
se
EF
EF
EF
EF
EF
EF
EF
(re
31 28 27 22 21 20 19 16 15 12 11 8 7 4 3 0
ER R
W Y_S AN R E_ _ER
R
DO C H ER OD D
S_ GA _C _ M OA
RO RR
DE R
RR
US DI _P ER L O R
_M OT RR
RR
DI E NT D3 D_ L
O _ER
ER
_E
E_ S_L RI VE OA WN
_E
AD O E
_E
L_
O I_B L_
CO ION
R
RR
R_ RR ME
NL P NE
ER
D
CT
E
EF _UA WE _E SU
EF SE_ ART ES WN Y_
NT
N_
2_
LE
U U _R DO IT
PO P RE
D
IO
EF E_ T4 B_ UR
SE
VE
RS
US N_ TY _
EF _PI H_ END
T_
US RP US EC
ER
E
VE
US EN PRI
E_
E AS _S
_R
UR
US FL E
U D L
_
EF E_ RC
EF E_ AB
RT
T4
EC
RP
US FO
_S
E_
EF SE_
EF E_
E
E
US
US
US
U
EF
EF
EF
31 27 26 11 10 9 8 7 6 5 4 3 2 1 0
RR
_E
D4
VE
ER
ES
_R
T4
RP
d)
E_
ve
US
ser
EF
(re
31 24 23 0
0 0 0 0 0 0 0 0 0x0000 Reset
U M
UM
_N
_N
RR
L
M
AI
L
UM
UM
UM
UM
UM
RR
NU
L
AI
_E
_F
AI
_F
_N
_N
_N
_N
_N
M
_E
_F
1_
T1
_8
_8
TA
TA
RR
RR
RR
RR
RR
RT
L
IL
IL
L
AI
AI
AI
PI
PI
A
DA
DA
PA
PA
_E
_E
_E
_E
_E
_F
_F
_F
_F
_F
_S
_S
R_
R_
Y4
Y4
Y3
Y3
Y2
Y2
Y1
Y1
Y0
Y0
S_
S_
AC
AC
US
US
KE
KE
KE
KE
KE
KE
KE
KE
KE
KE
SY
SY
M
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
US
US
US
US
US
US
US
US
US
US
US
US
US
US
US
US
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
31 30 28 27 26 24 23 22 20 19 18 16 15 14 12 11 10 8 7 6 4 3 2 0
EFUSE_MAC_SPI_8M_ERR_NUM The value of this signal means the number of error bytes in
BLOCK1. (RO)
EFUSE_MAC_SPI_8M_FAIL 0: Means no failure and that the data of BLOCK1 is reliable; 1: Means
that programming BLOCK1 data failed and the number of error bytes is over 5. (RO)
EFUSE_SYS_PART1_NUM The value of this signal means the number of error bytes in BLOCK2.
(RO)
EFUSE_SYS_PART1_FAIL 0: Means no failure and that the data of BLOCK2 is reliable; 1: Means
that programming BLOCK2 data failed and the number of error bytes is over 5. (RO)
EFUSE_USR_DATA_ERR_NUM The value of this signal means the number of error bytes in BLOCK3.
(RO)
EFUSE_USR_DATA_FAIL 0: Means no failure and that the data of BLOCK3 is reliable; 1: Means that
programming BLOCK3 data failed and the number of error bytes is over 5. (RO)
EFUSE_KEYn_ERR_NUM The value of this signal means the number of error bytes in KEYn. (RO)
EFUSE_KEYn_FAIL 0: Means no failure and that the data of KEYn is reliable; 1: Means that program-
ming KEYn failed and the number of error bytes is over 5. (RO)
UM
_N
RR
L
UM
AI
_E
_F
_N
T2
T2
RR
IL
AR
FA
PA
_E
_P
5_
Y5
S_
S
EY
SY
KE
d)
_K
_S
E_
E_
ve
SE
E
US
US
US
er
U
s
EF
EF
EF
EF
(re
31 8 7 6 4 3 2 0
EFUSE_KEY5_ERR_NUM The value of this signal means the number of error bytes in KEY5. (RO)
EFUSE_KEY5_FAIL 0: Means no failure and that the data of KEY5 is reliable; 1: Means that pro-
gramming user data failed and the number of error bytes is over 5. (RO)
EFUSE_SYS_PART2_ERR_NUM The value of this signal means the number of error bytes in
BLOCK10. (RO)
EFUSE_SYS_PART2_FAIL 0: Means no failure and that the data of BLOCK10 is reliable; 1: Means
that programming BLOCK10 data failed and the number of error bytes is over 5. (RO)
_F E_O PU
PD
O N
EM C _
E_
M OR CE
RC
E_ _F OR
US LK _F
EF _C M
E_ EM ME
EN
US M E_
EF E_ US
K_
CL
US EF
)
)
ed
ed
E_
EF SE_
rv
rv
US
se
se
U
EF
EF
(re
(re
31 17 16 15 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 0 Reset
DE
CO
P_
O
d)
E_
ve
US
r
se
EF
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
D
AD MD
M
M
_C
NU
RE _C
K_
E_ M
US PG
BL
d)
E_
EF E_
e
rv
US
US
se
EF
EF
(re
31 6 5 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 0x0 0 0 Reset
EFUSE_BLK_NUM The serial number of the block to be programmed. Value 0-10 corresponds to
block number 0-10, respectively. (R/W)
V
PA
DI
K_
K_
M
NU
CL
CL
R
CL
C_
C_
C_
E_
DA
DA
DA
_O
d)
E_
E_
E_
ve
SE
US
US
US
r
se
U
EF
EF
EF
EF
(re
31 18 17 16 9 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0 28 Reset
EFUSE_DAC_CLK_DIV Controls the division factor of the rising clock of the programming voltage.
(R/W)
NT
_C
RR
_E
AT
E
PE
AT
RE
ST
)
)
ed
ed
E_
E_
rv
rv
US
US
se
se
EF
EF
(re
(re
31 18 17 10 9 4 3 0
EFUSE_REPEAT_ERR_CNT Indicates the number of error bits during programming BLOCK0. (RO)
AW
NT W
_I RA
_R
NE _
O INT
_D E_
AD ON
RE _D
E_ M
US PG
d)
EF SE_
e
rv
se
U
EF
(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
T
_I ST
_S
NE _
NT
O INT
_D E_
AD ON
RE _D
E_ M
US PG
d)
EF SE_
ve
r
se
U
EF
(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
NA
NT A
_I EN
_E
NE _
O INT
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
v
er
U
s
EF
(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
LR
NT R
_I CL
_C
NE _
O INT
_D E_
AD ON
RE _D
E_ M
US PG
d)
EF SE_
e
rv
se
U
EF
(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
_A
_I
A
AD
UR
R_
D
RE
TH
TR
TS
E_
E_
E_
E_
US
US
US
US
EF
EF
EF
EF
31 24 23 16 15 8 7 0
E
IV
CT
NA
_I
A
M
_
PG
HP
TP
_T
_T
E_
E
E
US
US
US
EF
EF
EF
31 16 15 8 7 0
M
NU
N_
_A
O
R_
UP
PW
TS
d)
E_
E_
ve
US
US
r
se
EF
EF
(re
31 24 23 8 7 0
E_
e
rv
US
se
EF
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x190 Reset
TE
DA
E_
US
EF
31 0
0x19081100 Reset
5.1 Overview
The ESP32-S2 chip features 43 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 modules provide highly configurable I/O.
Note that the GPIO pads are numbered from 0 ~ 21 and 26 ~ 46, while GPIO46 is inputonly.
This chapter describes the selection and connection of the internal signals for the 43 digital pads and control
signals: FUN_SEL, IE, OE, WPU, WPD, etc. These internal signals include:
• 116 digital peripheral input signals, control signals: SIG_IN_SEL, SIG_OUT_SEL, IE, OE, etc.
• 182 digital peripheral output signals, control signals: SIG_IN_SEL, SIG_OUT_SEL, IE, OE, etc.
• fast peripheral input and output signals, control signals: IE, OE, etc.
Figure 5-1 shows the overview of IO MUX, RTC IO MUX and GPIO matrix.
1. IO MUX provides one configuration register IO_MUX_n_REG for each GPIO pad. The pad can be
configured to
Some high-speed digital signals (SPI, JTAG, UART) can bypass GPIO matrix for better high-frequency
digital performance. In this case, IO MUX is used to connect these pads directly to the peripheral.
See Section 5.11 for the IO MUX functions for each I/O pad.
2. GPIO matrix is a full-switching matrix between the peripheral input/output signals and the pads.
• For input to the chip: each of the 116 internal peripheral inputs can select any GPIO pad as their input
source.
• For output from the chip: each GPIO pad can select any of the 182 peripheral output signals for its
output.
See Section 5.10 for the list of peripheral signals via GPIO matrix.
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.
5.2.2 Synchronization
When signals are directed using the GPIO matrix, the signal will be synchronized to the APB bus clock by the
GPIO SYNC hardware. This synchronization applies to all GPIO matrix signals but does not apply when using the
IO MUX, see Figure 5-1.
Figure 5-2 shows the functionality of GPIO SYNC. In the figure, negative sync and positive sync mean GPIO input
is synchronized on APB clock falling edge and on APB clock rising edge, respectively.
Figure 52. GPIO Input Synchronized on Clock Rising Edge or on Falling Edge
Note that some peripheral signals have no valid GPIO_SIGy_IN_SEL bit, namely, there is no MUX module
in Figure 5-1 for these signals (see note 1 below Figure 5-1). These peripherals can only receive input
signals via GPIO matrix.
2. Enable the filter for pad input signals by setting the register IO_MUX_FILTER_EN. Only the signals with a
valid width of more than two clock cycles can be sampled, see Figure 5-3.
3. Synchronize GPIO input. To do so, please set GPIO_PINx_REG corresponding to GPIO pad X as follows:
• Set GPIO_PINx_SYNC1_BYPASS to enable input signal synchronized on rising edge or on falling edge
in the first clock, see Figure 5-2.
• Set GPIO_PINx_SYNC2_BYPASS to enable input signal synchronized on rising edge or on falling edge
in the second clock, see Figure 5-2.
4. Configure IO MUX register to enable pad input. For this end, please set IO_MUX_x_REG corresponding to
GPIO pad X as follows:
For example, to connect RMT channel 0 input signal (rmt_sig_in0, signal index 83) to GPIO40, please follow the
steps below. Note that GPIO40 is also named as MTDO pin.
Note:
• 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:
The output signal is routed from the peripheral into GPIO matrix and then into IO MUX. IO MUX must be
configured to set the chosen pad to GPIO function. This causes the output GPIO signal to be connected to the
pad.
Note:
There is a range of peripheral output signals (223 ~ 227) which are not connected to any peripheral. These can be used
to input a signal from one GPIO pad and output directly to another GPIO pad.
• If the signal should always be enabled as an output, set the GPIO_FUNCx_OEN_SEL bit in register
GPIO_FUNCx_OUT_SEL_CFG_REG and the bit in register GPIO_ENABLE_W1TS_REG or in register
GPIO_ENABLE1_W1TS_REG, corresponding to GPIO pad X. To have the output enable signal
decided by internal logic (see the column ”Output enable of output signals” in Table 38), clear
GPIO_FUNCx_OEN_SEL bit instead.
2. For an open drain output, set the GPIO_PINx_PAD_DRIVER bit in register GPIO_PINx_REG corresponding
to GPIO pad X.
3. Configure IO MUX register to enable output via GPIO matrix. Set the IO_MUX_x_REG corresponding to
GPIO pad X as follows:
• Set the field IO_MUX_MCU_SEL to IO_MUX function corresponding to GPIO pad X. This is Function
1, numeric value 1, for all pins.
• Set the IO_MUX_FUN_DRV field to the desired value for output strength (0 ~ 3). The higher the driver
strength, the more current can be sourced/sunk from the pin.
– 0: ~5 mA
– 1: ~10 mA
– 3: ~40 mA
• If using open drain mode, set/clear the IO_MUX_FUN_WPU and IO_MUX_FUN_WPD bits to
enable/disable the internal pull-up/down resistors.
Note:
• The output signal from a single peripheral can be sent to multiple pads simultaneously.
• Set GPIO matrix GPIO_FUNCn_OUT_SEL with a special peripheral index 256 (0x100);
• Set the corresponding bit in GPIO_OUT_REG[31:0] or GPIO_OUT1_REG[21:0] register to the desired GPIO
output value.
Note:
After scaling, the clock cycle is equal to one pulse output cycle from the modulator.
GPIOSD_SDn_IN is a signed number with a range of [-128, 127] and is used to control the duty cycle 1 of PDM
output signal.
• GPIOSD_SDn_IN = 127, the duty cycle of the output signal is close to 100%.
The formula for calculating PDM signal duty cycle is shown as below:
GP IOSD_SDn_IN + 128
Duty_Cycle =
256
Note:
For PDM signals, duty cycle refers to the percentage of high level cycles to the whole statistical period (several pulse
cycles, for example 256 pulse cycles).
• Route one of SDM outputs to a pad via GPIO matrix, see Section 5.3.2.
• Configure the duty cycle of SDM output signal by setting the register GPIOSD_SDn_IN.
Figure 5-4 shows the structure of dedicated GPIO module. Users can enable the clock of this module by setting
the bit SYSTEM_CLK_EN_DEDICATED_GPIO in register SYSTEM_CPU_PERI_CLK_EN_REG, and reset this
module by setting the bit SYSTEM_RST_EN_DEDICATED_GPIO in register SYSTEM_CPU_PERI_RST_EN_REG
first, and then clearing this bit. For more information, please refer to Table 89 Peripheral Clock Gating and Reset
Bits in Chapter 15 System Registers (SYSTEM).
5.4.2 Features
Dedicated GPIO module has the following features:
When accessing output channels, select between registers and CPU by configuring
DEDIC_GPIO_OUT_CPU_REG:
The dedicated GPIO module also provides two ways to read input channels:
• Write GPIO output value via masked access by configuring the register DEDIC_GPIO_OUT_MSK_REG.
• Write GPIO output value via individual bits by configuring the register DEDIC_GPIO_OUT_IDV_REG.
User can read the register DEDIC_GPIO_OUT_SCAN_REG to check GPIO status, i.e. gpio_out_status in Figure
5-4, via software.
Users can get a dedicated GPIO input value by reading the register DEDIC_GPIO_IN_SCAN_REG, i.e. the
gpio_in_status in Figure 5-4, via software.
The dedicated GPIO module supports for a delay of 1/2/3 clock cycle(s) for input signals, or with no delay, which
can be controlled by configuring the register DEDIC_GPIO_IN_DLY_REG for each individual channel. GPIO input
status is indicated by interrupts. Users can configure the register DEDIC_GPIO_INTR_RCGN_REG to set trigger
modes:
• 0/1: no interrupt
This option is less flexible than routing signals via GPIO matrix, as the IO MUX register for each GPIO pad can
only select from a limited number of functions, but high-frequency digital performance can be improved.
1. IO_MUX_MCU_SEL for the GPIO pad must be set to the required pad function. For the list of pad
functions, please refer to Section 5.11.
2. Set GPIO_SIGn_IN_SEL to low level to route the input directly to the peripheral.
To bypass GPIO matrix for peripheral output signals, IO_MUX_MCU_SEL for the GPIO pad must be set to the
required pad function. For the list of pad functions, please refer to Section 5.11.
Note:
For peripheral I/O signals, not all signals can be connected to peripheral via IO MUX. Some specific input signals
and some specific output signals can only be connected to peripheral via GPIO matrix.
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 RTCIO_TOUCH_PADn_MUX_SEL is set to 1, then input/output signals to and from that pad is routed to the
RTC subsystem. In this mode, RTCIO_TOUCH_PADn_REG is used for digital input/output and the analog
features of the pad are also available.
Please refer to Section 5.12 for the list of RTC pin functions and the mapping table of GPIO pads to their analog
functions. Note that RTCIO_TOUCH_PADn_REG applies the RTC GPIO pin numbering, not the GPIO pad
numbering.
If IO_MUX_SLP_SEL is set to 0, pin functions remain the same in both normal execution and Light-sleep
mode.
Note:
Please refer to Section 5.3.2 for how to enable output in normal execution (when IO_MUX_SLP_SEL = 0).
or how the IO MUX/GPIO configuration is modified. Users can use the hold function for the pads to retain the
pad state through a core reset and system reset triggered by watchdog time-out or Deep-sleep events.
Note:
• For digital pads, to maintain pad input/output status in Deep-sleep mode, users can set RTC_CNTL_DG_PAD_
FORCE_UNHOLD to 0 before powering down. For RTC pads, the input and output values are controlled by the
corresponding bits of register RTC_CNTL_PAD_HOLD_REG, and users can set it to 1 to hold the value or set it to
0 to unhold the value.
• For digital pads, to disable the hold function after the chip is woken up, users can set RTC_CNTL_DG_PAD_FORCE_
UNHOLD to 1. To maintain the hold function of the pad, users can change the corresponding bit in register
RTC_CNTL_PAD_HOLD_REG to 1.
• VDD3P3_RTC_IO: the input power supply for both RTC and CPU
VDD_SPI can be configured to use an internal LDO. The LDO input is VDD3P3_RTC_IO and the output is 1.8 V. If
the LDO is not enabled, VDD_SPI is connected directly to the same power supply as VDD3P3_RTC_IO.
The VDD_SPI configuration is determined by the value of strapping pin GPIO45, or can be overriden by eFuse
and/or register settings. See ESP32-S2 Datasheet sections Power Scheme and Strapping Pins for more
details.
GPIO Pad Name Function 0 Function 1 Function 2 Function 3 Function 4 Reset Notes
0 GPIO0 GPIO0 GPIO0 - - - 3 R
1 GPIO1 GPIO1 GPIO1 - - - 1 R
2 GPIO2 GPIO2 GPIO2 - - - 1 R
GPIO Pad Name Function 0 Function 1 Function 2 Function 3 Function 4 Reset Notes
3 GPIO3 GPIO3 GPIO3 - - - 0 R
4 GPIO4 GPIO4 GPIO4 - - - 0 R
5 GPIO5 GPIO5 GPIO5 - - - 0 R
6 GPIO6 GPIO6 GPIO6 - - - 0 R
7 GPIO7 GPIO7 GPIO7 - - - 0 R
8 GPIO8 GPIO8 GPIO8 - SUBSPICS1 - 0 R
9 GPIO9 GPIO9 GPIO9 - SUBSPIHD FSPIHD 1 R
10 GPIO10 GPIO10 GPIO10 FSPIIO4 SUBSPICS0 FSPICS0 1 R
11 GPIO11 GPIO11 GPIO11 FSPIIO5 SUBSPID FSPID 1 R
12 GPIO12 GPIO12 GPIO12 FSPIIO6 SUBSPICLK FSPICLK 1 R
13 GPIO13 GPIO13 GPIO13 FSPIIO7 SUBSPIQ FSPIQ 1 R
14 GPIO14 GPIO14 GPIO14 FSPIDQS SUBSPIWP FSPIWP 1 R
15 XTAL_32K_P XTAL_32K_P GPIO15 U0RTS - - 0 R
16 XTAL_32K_N XTAL_32K_N GPIO16 U0CTS - - 0 R
17 DAC_1 DAC_1 GPIO17 U1TXD - - 1 R
18 DAC_2 DAC_2 GPIO18 U1RXD CLK_OUT3 - 3 R
19 GPIO19 GPIO19 GPIO19 U1RTS CLK_OUT2 - 0 R
20 GPIO20 GPIO20 GPIO20 U1CTS CLK_OUT1 - 0 R
21 GPIO21 GPIO21 GPIO21 - - - 0 R
26 SPICS1 SPICS1 GPIO26 - - - 3 -
27 SPIHD SPIHD GPIO27 - - - 3 -
28 SPIWP SPIWP GPIO28 - - - 3 -
29 SPICS0 SPICS0 GPIO29 - - - 3 -
30 SPICLK SPICLK GPIO30 - - - 3 -
31 SPIQ SPIQ GPIO31 - - - 3 -
32 SPID SPID GPIO32 - - 3 -
33 GPIO33 GPIO33 GPIO33 FSPIHD SUBSPIHD SPIIO4 1 -
34 GPIO34 GPIO34 GPIO34 FSPICS0 SUBSPICS0 SPIIO5 1 -
35 GPIO35 GPIO35 GPIO35 FSPID SUBSPID SPIIO6 1 -
36 GPIO36 GPIO36 GPIO36 FSPICLK SUBSPICLK SPIIO7 1 -
37 GPIO37 GPIO37 GPIO37 FSPIQ SUBSPIQ SPIDQS 1 -
38 GPIO38 GPIO38 GPIO38 FSPIWP SUBSPIWP - 1 -
39 MTCK MTCK GPIO39 CLK_OUT3 SUBSPICS1 - 1 -
40 MTDO MTDO GPIO40 CLK_OUT2 - - 1 -
41 MTDI MTDI GPIO41 CLK_OUT1 - - 1 -
42 MTMS MTMS GPIO42 - - - 1 -
43 U0TXD U0TXD GPIO43 CLK_OUT1 - - 3 -
44 U0RXD U0RXD GPIO44 CLK_OUT2 - - 3 -
45 GPIO45 GPIO45 GPIO45 - - - 2 -
46 GPIO46 GPIO46 GPIO46 - - - 2 I
Reset Configurations
“Reset” column shows the default configuration of each pad after reset:
Note:
Please refer to Appendix A – ESP32-S2 Pin Lists in ESP32-S2 Datasheet for more details.
Analog Function
RTC GPIO Num GPIO Num Pad Name
0 1 2 3
1
0 0 TOUCH_PAD0 RTC_GPIO0 - - sar_i2c_scl_02
1 1 TOUCH_PAD1 RTC_GPIO1 - - sar_i2c_sda_02
2 2 TOUCH_PAD2 RTC_GPIO2 - - sar_i2c_scl_12
3 3 TOUCH_PAD3 RTC_GPIO3 - - sar_i2c_sda_12
4 4 TOUCH_PAD4 RTC_GPIO4 - - -
5 5 TOUCH_PAD5 RTC_GPIO5 - - -
6 6 TOUCH_PAD6 RTC_GPIO6 - - -
7 7 TOUCH_PAD7 RTC_GPIO7 - - -
8 8 TOUCH_PAD8 RTC_GPIO8 - - -
9 9 TOUCH_PAD9 RTC_GPIO9 - - -
10 10 TOUCH_PAD10 RTC_GPIO10 - - -
11 11 TOUCH_PAD11 RTC_GPIO11 - - -
12 12 TOUCH_PAD12 RTC_GPIO12 - - -
13 13 TOUCH_PAD13 RTC_GPIO13 - - -
14 14 TOUCH_PAD14 RTC_GPIO14 - - -
15 15 X32P RTC_GPIO15 - - -
16 16 X32N RTC_GPIO16 - - -
17 17 PDAC1 RTC_GPIO17 - - -
18 18 PDAC2 RTC_GPIO18 - - -
19 19 RTC_PAD19 RTC_GPIO19 - - -
20 20 RTC_PAD20 RTC_GPIO20 - - -
21 21 RTC_PAD21 RTC_GPIO21 - - -
Note:
1. TOUCH_PAD0 is an internal channel and its analog functions are not lead to a corresponding external GPIO.
2. For more information on the configuration of sar_i2c_xx, see Section RTC I2C Controller in Chapter 1 ULP Copro-
cessor (ULP).
Table 41: GPIO, IO MUX, GPIOSD, Dedicated GPIO, and RTCIO Base Addresses
5.15 Registers
The address in the following part represents the address offset (relative address) with respect to the peripheral
base address, not the absolute address. For detailed information about the base address, please refer to Section
5.13.
EL
T _S
_B
O
PI
G
31 0
0x000000 Reset
G
RI
O
A_
AT
_D
UT
_O
O
PI
G
31 0
0x000000 Reset
GPIO_OUT_DATA_ORIG GPIO0 ~ 31 output value in simple GPIO output mode. The values of bit0
~ bit31 correspond to the output value of GPIO0 ~ GPIO31 respectively. Bit22 ~ bit25 are invalid.
(R/W)
31 0
0x000000 Reset
GPIO_OUT_W1TS GPIO0 ~ 31 output set register. If the value 1 is written to a bit here, the corre-
sponding bit in GPIO_OUT_REG will be set to 1. Recommended operation: use this register to set
GPIO_OUT_REG. (WO)
C
1T
W_
UT
_O
O
PI
G
31 0
0x000000 Reset
GPIO_OUT_W1TC GPIO0 ~ 31 output clear register. If the value 1 is written to a bit here, the cor-
responding bit in GPIO_OUT_REG will be cleared. Recommended operation: use this register to
clear GPIO_OUT_REG. (WO)
G
RI
_ O
TA
DA
1_
UT
d )
_O
ve
r
O
se
PI
(re
G
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
GPIO_OUT1_DATA_ORIG GPIO32 ~ 53 output value in simple GPIO output mode. The values of
bit0 ~ bit13 correspond to GPIO32 ~ GPIO45. Bit14 ~ bit21 are invalid. (R/W)
_O
rv
O
se
PI
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
GPIO_OUT1_W1TS GPIO32 ~ 53 output value set register. If the value 1 is written to a bit here, the
corresponding bit in GPIO_OUT1_REG will be set to 1. Recommended operation: use this register
to set GPIO_OUT1_REG. (WO)
C
1T
1 _W
UT
)
ed
_O
rv
O
se
PI
(re
G
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
GPIO_OUT1_W1TC GPIO32 ~ 53 output value clear register. If the value 1 is written to a bit here, the
corresponding bit in GPIO_OUT1_REG will be cleared. Recommended operation: use this register
to clear GPIO_OUT1_REG. (WO)
EL
_S
O
DI
d)
_S
ve
r
O
se
PI
(re
G
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
31 0
0x000000 Reset
S
1T
_W
LE
N AB
_E
O
PI
G
31 0
0x000000 Reset
GPIO_ENABLE_W1TS GPIO0 ~ 31 output enable set register. If the value 1 is written to a bit here,
the corresponding bit in GPIO_ENABLE_REG will be set to 1. Recommended operation: use this
register to set GPIO_ENABLE_REG. (WO)
C
1T
W
E_
BL
NA
_E
O
PI
G
31 0
0x000000 Reset
GPIO_ENABLE_W1TC GPIO0 ~ 31 output enable clear register. If the value 1 is written to a bit here,
the corresponding bit in GPIO_ENABLE_REG will be cleared. Recommended operation: use this
register to clear GPIO_ENABLE_REG. (WO)
N
ed
_E
rv
O
se
PI
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
S
1T
W
1_
E
BL
NA
)d
_E
ve
er
O
s
PI
(re
G
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
GPIO_ENABLE1_W1TS GPIO32 ~ 53 output enable set register. If the value 1 is written to a bit here,
the corresponding bit in GPIO_ENABLE1_REG will be set to 1. Recommended operation: use this
register to set GPIO_ENABLE1_REG. (WO)
C
1T
_W
E1
BL
NA
d)
_E
r ve
O
se
PI
(re
G
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
GPIO_ENABLE1_W1TC GPIO32 ~ 53 output enable clear register. If the value 1 is written to a bit
here, the corresponding bit in GPIO_ENABLE1_REG will be cleared. Recommended operation:
use this register to clear GPIO_ENABLE1_REG. (WO)
_S
rv
O
se
PI
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
GPIO_STRAPPING GPIO strapping values: bit4 ~ bit2 correspond to stripping pins GPIO45, GPIO0,
and GPIO46 respectively. (RO)
XT
NE
A_
AT
D
N_
_I
O
PI
G
31 0
0 Reset
GPIO_IN_DATA_NEXT GPIO0 ~ 31 input value. Each bit represents a pad input value, 1 for high level
and 0 for low level. (RO)
E XT
_N
1
TA
DA
N_
d)
ve
_I
r
O
se
PI
(re
G
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0 Reset
GPIO_IN_DATA1_NEXT GPIO32 ~ 53 input value. Each bit represents a pad input value. (RO)
LE
SS
AB
_D PAS
PA
EN
NC ER
_P PAD BY
BY
P_
SY RIV
PE
NA
PI Nn_ C1_
2_
IG
EU
TY
NF
_E
AK
T_
_P SYN
NT
IN
W
_C
I
n_
n_
n_
PI Nn_
n_
n
IN
IN
IN
IN
IN
d)
)
ed
I
_P
_P
_P
_P
_P
ve
rv
er
O
se
s
PI
PI
PI
PI
PI
(re
(re
G
G
31 18 17 13 12 11 10 9 7 6 5 4 3 2 1 0
GPIO_PINn_SYNC2_BYPASS For the second stage synchronization, GPIO input data can be syn-
chronized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge;
2 and 3: synchronized on rising edge. (R/W)
GPIO_PINn_PAD_DRIVER Pad driver selection. 0: normal output; 1: open drain output. (R/W)
GPIO_PINn_SYNC1_BYPASS For the first stage synchronization, GPIO input data can be synchro-
nized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2
and 3: synchronized on rising edge. (R/W)
GPIO_PINn_INT_TYPE Interrupt type selection. 0: GPIO interrupt disabled; 1: rising edge trigger; 2:
falling edge trigger; 3: any edge trigger; 4: low level trigger; 5: high level trigger. (R/W)
GPIO_PINn_WAKEUP_ENABLE GPIO wake-up enable bit, only wakes up the CPU from Light-sleep
(R/W)
GPIO_PINn_INT_ENA Interrupt enable bits. bit13: CPU interrupt enabled; bit14: CPU non-maskable
interrupt enabled. (R/W)
L
SE
IN
_I L
Cn SE
N_
N_
UN N_
_I
Cn
_F _I
O n
UN
PI IG
)
ed
G _S
_F
rv
O
se
PI
PI
(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 0 0 0x0 Reset
GPIO_FUNCn_IN_SEL Selection control for peripheral input signal m, selects a pad from the 54 GPIO
matrix pads to connect this input signal. Or selects 0x38 for a constantly high input or 0x3C for a
constantly low input. (R/W)
GPIO_FUNCn_IN_INV_SEL Invert the input value. 1: invert enabled; 0: invert disabled. (R/W)
GPIO_SIGn_IN_SEL Bypass GPIO matrix. 1: route signals via GPIO matrix, 0: connect signals di-
rectly to peripheral configured in IO_MUX. (R/W)
UT EL EL
EL
_O _S _S
_S
EL
Cn EN INV
NV
_S
_I
UN _O _
_F Cn EN
UT
O N O
_O
PI U _
G _F C n
Cn
O N
UN
)
PI U
ed
G _F
_F
rv
O
se
PI
PI
(re
G
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 0 0 0 0x100 Reset
GPIO_FUNCn_OUT_INV_SEL 0: Do not invert the output value; 1: Invert the output value. (R/W)
GPIO_FUNCn_OEN_SEL 0: Use output enable signal from peripheral; 1: Force the output enable
signal to be sourced from bit n of GPIO_ENABLE_REG. (R/W)
GPIO_FUNCn_OEN_INV_SEL 0: Do not invert the output enable signal; 1: Invert the output enable
signal. (R/W)
N
_E
LK
d )
_C
ve
er
O
s
PI
(re
31 1
G
0
0 0 0 0 0 0 0 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
GPIO_CLK_EN Clock gating enable bit. If set to 1, the clock is free running. (R/W)
31 0
0x000000 Reset
GPIO_STATUS_W1TS GPIO0 ~ 31 interrupt status set register. If the value 1 is written to a bit here,
the corresponding bit in GPIO_STATUS_INTERRUPT will be set to 1. Recommended operation:
use this register to set GPIO_STATUS_INTERRUPT. (WO)
C
1T
W
S_
TU
TA
_S
O
PI
G
31 0
0x000000 Reset
GPIO_STATUS_W1TC GPIO0 ~ 31 interrupt status clear register. If the value 1 is written to a bit here,
the corresponding bit in GPIO_STATUS_INTERRUPT will be cleared. Recommended operation:
use this register to clear GPIO_STATUS_INTERRUPT. (WO)
S
1T
_W
S1
TU
TA
)
ed
_S
rv
O
se
PI
(re
G
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
GPIO_STATUS1_W1TS GPIO32 ~ 53 interrupt status set register. If the value 1 is written to a bit here,
the corresponding bit in GPIO_STATUS1_REG will be set to 1. Recommended operation: use this
register to set GPIO_STATUS1_REG. (WO)
_S
e
rv
O
se
PI
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
GPIO_STATUS1_W1TC GPIO32 ~ 53 interrupt status clear register. If the value 1 is written to a bit
here, the corresponding bit in GPIO_STATUS1_REG will be cleared. Recommended operation:
use this register to clear GPIO_STATUS1_REG. (WO)
T
EX
T_N
UP
RR
TE
IN
S_
TU
TA
_S
O
PI
G
31 0
0x000000 Reset
GPIO_STATUS_INTERRUPT_NEXT Interrupt source signal of GPIO0 ~ 31, could be rising edge in-
terrupt, falling edge interrupt, level sensitive interrupt and any edge interrupt. (RO)
XT
NE
T_
UP
RR
TE
N
_I
S1
TU
TA
d)
_S
e
rv
O
se
PI
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
31 0
0x000000 Reset
T
UP
RR
E
NT
_I
S1
TU
TA
)
ed
_S
rv
O
se
PI
(re
G
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
T
IN
U_
CP
R O
_P
O
PI
G
31 0
0x000000 Reset
31 0
0x000000 Reset
T
IN
U 1_
CP
RO
d)
_P
ve
er
O
s
PI
(re
G
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
T
N
_I
I1
NM
U_
CP
RO
)
d
_P
rve
O
se
PI
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
M
TR
NU
K3
K2
K1
_C
T_
CL
CL
CL
ER
L_
L_
L_
_P
W
TR
TR
TR
O
CH
_P
_C
_C
_C
IT
D
IN
IN
IN
W
PA
_S
_P
_P
_P
)
_
ed
UX
UX
UX
UX
UX
rv
_M
_M
_M
_M
_M
se
(re
IO
IO
IO
IO
IO
31 16 15 14 12 11 8 7 4 3 0
• 15: disabled.
• 15: disabled.
• 15: disabled.
Note:
Only the above mentioned combinations of clock source and clock output pins are possible.
The CLK_OUT1 ~ 3 can be found in IO_MUX Pad List.
IO_MUX_SWITCH_PRT_NUM IO pin power switch delay, delay unit is one APB clock. (R/W)
IO_MUX_PAD_POWER_CTRL Select power voltage for GPIO33 ~ 37. 1: select VDD_SPI 1.8 V; 0:
select VDD3P3_CPU 3.3 V. (R/W)
_M _S U_ U
_M _S D
N
U
PD
L
IO UX UN V
IO UX C WP
UX LP WP
E
CU EL
E
UN P
E
_M _F DR
IO UX C IE
R_
_O
_S
(re X_F _W
ed _W
U UN E
_M _M U_
_M _M U_
_ M _F _I
_
E
CU
UN
LT
IO UX C
_M
_ M _M
FI
_F
d)
)
_
UX
UX
UX
IO UX
IO UX
ve
rv
r
_M
_M
_M
_M
_M
se
se
(re
IO
IO
IO
IO
IO
31 16 15 14 12 11 10 9 8 7 6 5 4 3 2 1 0
IO_MUX_MCU_OE Output enable of the pin in sleep mode. 1: Output enabled; 0: Output disabled.
(R/W)
IO_MUX_SLP_SEL Sleep mode selection of this pin. Set to 1 to put the pin in sleep mode. (R/W)
IO_MUX_MCU_WPD Pull-down enable of the pin during sleep mode. 1: Internal pull-down enabled;
0: Internal pull-down disabled. (R/W)
IO_MUX_MCU_WPU Pull-up enable of the pin during sleep mode. 1: Internal pull-up enabled; 0:
Internal pull-up disabled.
IO_MUX_MCU_IE Input enable of the pin during sleep mode. 1: Input enabled; 0: Input disabled.
(R/W)
IO_MUX_FUN_WPU Pull-up enable of the pin. 1: Internal pull-up enabled; 0: Internal pull-up dis-
abled. (R/W)
IO_MUX_FUN_IE Input enable of the pin. 1: Input enabled; 0: Input disabled. (R/W)
IO_MUX_FUN_DRV Select the drive strength of the pin. 0: ~5 mA: 1: ~10 mA: 2: ~20 mA; 3: ~40
mA. (R/W)
IO_MUX_MCU_SEL Select IO MUX function for this signal. 0: Select Function 0; 1: Select Function
1, etc. (R/W)
IO_MUX_FILTER_EN Enable filter for pin input signals. 1: Filter enabled; 0: Filter disabled. (R/W)
E
AL
SC
RE
IN
_P
n_
Dn
D
_S
_S
)
ed
SD
SD
rv
O
se
PI
PI
(re
G
31 16 15 8 7 0
GPIOSD_SDn_IN This field is used to configure the duty cycle of sigma delta modulation output.
(R/W)
GPIOSD_SDn_PRESCALE This field is used to set a divider value to divide APB clock. (R/W)
d)
SD
e
rv
O
se
PI
(re
G
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
GPIOSD_CLK_EN Clock enable bit of configuration registers for sigma delta modulation. (R/W)
d)
PI _
G SD
e
rv
O
se
PI
(re
G
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
E
AT
D
D_
_S
O
PI
_G
)
ed
SD
rv
O
se
PI
(re
G
31 28 27 0
0 0 0 0 0x1802260 Reset
E
AU
L
_V
RT
_D
UT
_O
O
PI
)
G
d
ve
C_
er
DI
s
DE
(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
AL
_M
_V
UT
UT
_O
_O
O
O
PI
PI
)
_G
G
ed
C_
rv
C
DI
DI
se
DE
DE
(re
31 16 15 8 7 0
DEDIC_GPIO_OUT_VALUE This register is used to configure updated output value of 8-channel ded-
icated GPIO. (WO)
H7
H6
H5
H4
H3
H1
H0
CH
_C
_C
_C
_C
_C
_C
_C
V_
DV
DV
DV
DV
DV
DV
DV
D
_I
_I
_I
_I
_I
_I
_I
_I
UT
UT
UT
UT
UT
UT
UT
UT
_O
_O
_O
_O
_O
_O
_O
_O
O
O
PI
PI
PI
PI
PI
PI
PI
PI
d)
G
ve
C_
C_
C_
C_
C_
C_
C_
C_
er
DI
DI
DI
DI
DI
DI
DI
DI
s
DE
DE
DE
DE
DE
DE
DE
DE
(re
31 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DEDIC_GPIO_OUT_IDV_CH0 Configure channel 0 output value. 0: hold output value. 1: set output
value. 2: clear output value. 3: inverse output value. (WO)
DEDIC_GPIO_OUT_IDV_CH1 Configure channel 1 output value. 0: hold output value. 1: set output
value. 2: clear output value. 3: inverse output value. (WO)
DEDIC_GPIO_OUT_IDV_CH2 Configure channel 2 output value. 0: hold output value. 1: set output
value. 2: clear output value. 3: inverse output value. (WO)
DEDIC_GPIO_OUT_IDV_CH3 Configure channel 3 output value. 0: hold output value. 1: set output
value. 2: clear output value. 3: inverse output value. (WO)
DEDIC_GPIO_OUT_IDV_CH4 Configure channel 4 output value. 0: hold output value. 1: set output
value. 2: clear output value. 3: inverse output value. (WO)
DEDIC_GPIO_OUT_IDV_CH5 Configure channel 5 output value. 0: hold output value. 1: set output
value. 2: clear output value. 3: inverse output value. (WO)
DEDIC_GPIO_OUT_IDV_CH6 Configure channel 6 output value. 0: hold output value. 1: set output
value. 2: clear output value. 3: inverse output value. (WO)
DEDIC_GPIO_OUT_IDV_CH7 Configure channel 7 output value. 0: hold output value. 1: set output
value. 2: clear output value. 3: inverse output value. (WO)
D GP _O _C _S 7
D GP _O _C _S 6
DI GP _O _C _S 5
G _O _C _S 4
_O _C _S 3
_C _S 2
_S 1
0
DE IC_ IO UT PU EL
DE IC_ IO UT PU EL
DE IC_ IO UT PU EL
C_ IO UT PU EL
O T U L
UT PU EL
PU EL
EL
PI U P E
D GP _O _C _S
DE IC_ IO UT PU
D GP _O _C
DE IC_ IO UT
D GP _O
DE IC_ IO
D GP
d)
ve
DE IC_
er
D
s
DE
(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
H6
H5
H4
H3
H2
H1
0
CH
CH
_C
_C
_C
_C
_C
_C
Y_
Y_
LY
LY
LY
LY
LY
LY
DL
DL
D
_D
_D
_D
_D
N_
N_
N_
N_
IN
IN
IN
N
_I
_I
_I
_I
_I
_
_
O
O
PI
PI
PI
PI
PI
PI
PI
PI
d)
G
ve
C_
C_
C_
C_
C_
C_
C_
C_
er
DI
DI
DI
DI
DI
DI
DI
DI
s
DE
DE
DE
DE
DE
DE
DE
DE
(re
31 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DEDIC_GPIO_IN_DLY_CH0 Configure GPIO0 input delay. 0: no delay. 1: one clock delay. 2: two
clock delay. 3: three clock delay. (R/W)
DEDIC_GPIO_IN_DLY_CH1 Configure GPIO1 input delay. 0: no delay. 1: one clock delay. 2: two
clock delay. 3: three clock delay. (R/W)
DEDIC_GPIO_IN_DLY_CH2 Configure GPIO2 input delay. 0: no delay. 1: one clock delay. 2: two
clock delay. 3: three clock delay. (R/W)
DEDIC_GPIO_IN_DLY_CH3 Configure GPIO3 input delay. 0: no delay. 1: one clock delay. 2: two
clock delay. 3: three clock delay. (R/W)
DEDIC_GPIO_IN_DLY_CH4 Configure GPIO4 input delay. 0: no delay. 1: one clock delay. 2: two
clock delay. 3: three clock delay. (R/W)
DEDIC_GPIO_IN_DLY_CH5 Configure GPIO5 input delay. 0: no delay. 1: one clock delay. 2: two
clock delay. 3: three clock delay. (R/W)
DEDIC_GPIO_IN_DLY_CH6 Configure GPIO6 input delay. 0: no delay. 1: one clock delay. 2: two
clock delay. 3: three clock delay. (R/W)
DEDIC_GPIO_IN_DLY_CH7 Configure GPIO7 input delay. 0: no delay. 1: one clock delay. 2: two
clock delay. 3: three clock delay. (R/W)
H6
H5
H1
0
H
CH
CH
CH
CH
_C
_C
_C
_C
_
_
DE
DE
DE
DE
DE
DE
DE
DE
O
O
M
_M
_M
_M
M
R_
R_
R_
R_
R_
TR
TR
R
NT
NT
NT
NT
NT
NT
N
N
_I
_I
_I
_I
_I
_I
_I
_I
O
O
PI
PI
PI
PI
PI
PI
PI
PI
)
_G
_G
_G
G
ed
C_
C_
C_
C_
C_
rv
IC
IC
IC
DI
DI
DI
DI
DI
se
D
DE
DE
DE
DE
DE
DE
DE
DE
(re
31 24 23 21 20 18 17 15 14 12 11 9 8 6 5 3 2 0
US
AT
_ ST
UT
_O
O
PI
d)
G
ve
C_
er
DI
s
DE
(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
U S
AT
ST
N_
_I
O
PI
d)
G
e
C_
rv
DI
se
DE
(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
DE IC_ IO INT AW
DE IC_ IO INT AW
DE IC_ IO INT AW
DE IC_ IO INT AW
C_ IO NT AW
O T W
T_ W
W
PI IN A
IN A
RA
D GP 6_ _R
D G P 5_ _R
D G P 4_ _R
D GP 3_ _R
DI GP 2_I _R
G 1_ _R
0_ _R
DE IC_ IO INT
D GP 7_
DE IC_ IO
D GP
d)
ve
DE IC_
er
D
s
DE
(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
DEDIC_GPIO0_INT_RAW This interrupt raw bit turns to high level when dedicated GPIO0 has
level/edge change configured by DEDIC_GPIO_INTR_RCGN_REG. (RO)
DEDIC_GPIO1_INT_RAW This interrupt raw bit turns to high level when dedicated GPIO1 has
level/edge change configured by DEDIC_GPIO_INTR_RCGN_REG. (RO)
DEDIC_GPIO2_INT_RAW This interrupt raw bit turns to high level when dedicated GPIO2 has
level/edge change configured by DEDIC_GPIO_INTR_RCGN_REG. (RO)
DEDIC_GPIO3_INT_RAW This interrupt raw bit turns to high level when dedicated GPIO3 has
level/edge change configured by DEDIC_GPIO_INTR_RCGN_REG. (RO)
DEDIC_GPIO4_INT_RAW This interrupt raw bit turns to high level when dedicated GPIO4 has
level/edge change configured by DEDIC_GPIO_INTR_RCGN_REG. (RO)
DEDIC_GPIO5_INT_RAW This interrupt raw bit turns to high level when dedicated GPIO5 has
level/edge change configured by DEDIC_GPIO_INTR_RCGN_REG. (RO)
DEDIC_GPIO6_INT_RAW This interrupt raw bit turns to high level when dedicated GPIO6 has
level/edge change configured by DEDIC_GPIO_INTR_RCGN_REG. (RO)
DEDIC_GPIO7_INT_RAW This interrupt raw bit turns to high level when dedicated GPIO7 has
level/edge change configured by DEDIC_GPIO_INTR_RCGN_REG. (RO)
DE IC_ IO INT NA
DE IC_ IO INT NA
DE IC_ IO INT NA
DE IC_ IO INT NA
C_ IO NT NA
O T A
T_ A
A
PI IN N
IN N
EN
D GP 6_ _E
D G P 5_ _E
D G P 4_ _E
D GP 3_ _E
DI GP 2_I _E
G 1_ _E
0_ _E
DE IC_ IO INT
D GP 7_
DE IC_ IO
D GP
)
ed
DE IC_
rv
se
D
DE
(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
DE IC_ IO INT T
DE IC_ IO INT T
DE IC_ IO INT T
DE IC_ IO INT T
C_ IO NT T
PI IN T
IN T
ST
D GP 6_ _S
D G P 5_ _S
D G P 4_ _S
D GP 3_ _S
DI GP 2_I _S
G 1_ _S
0_ _S
T_
DE IC_ IO INT
O T
D GP 7_
DE IC_ IO
D GP
d)
ve
DE IC_
er
D
s
DE
(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
DE IC_ IO INT LR
DE IC_ IO INT LR
DE IC_ IO INT LR
DE IC_ IO INT LR
C_ IO NT LR
O T R
T_ R
R
PI IN L
IN L
CL
D GP 6_ _C
D G P 5_ _C
D G P 4_ _C
D GP 3_ _C
DI GP 2_I _C
G 1_ _C
0_ _C
DE IC_ IO INT
D GP 7_
DE IC_ IO
D GP
d)
ve
DE IC_
er
D
s
DE
(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
)
_G
ed
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
S
1T
W
A_
AT
_D
UT
_O
O
PI
)
_G
ed
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_GPIO_OUT_DATA_W1TS GPIO0 ~ 21 output set register. If the value 1 is written to a bit here,
the corresponding bit in RTCIO_RTC_GPIO_OUT_REG will be set to 1. Recommended operation:
use this register to set RTCIO_RTC_GPIO_OUT_REG. (WO)
)
_G
ed
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
d)
_G
e
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
S
1T
_W
LE
N AB
_E
O
PI
)
_G
ed
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_GPIO_ENABLE_W1TS GPIO0 ~ 21 output enable set register. If the value 1 is written to a bit
here, the corresponding bit in RTCIO_RTC_GPIO_ENABLE_REG will be set to 1. Recommended
operation: use this register to set RTCIO_RTC_GPIO_ENABLE_REG. (WO)
d)
_G
e
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
d)
_G
e
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
S
1T
W
T_
IN
S_
TU
TA
_S
O
PI
)
_G
ed
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
)
_G
ed
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
d)
_G
e
rv
O
CI
se
RT
(re
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 Reset
LE
AB
EN
R
VE
P_
PE
RI
EU
TY
_D
AK
T_
D
PA
IN
W
n_
n_
n_
IN
IN
IN
_P
_P
_P
O
se PIO
PI
PI
d)
)
_G
_G
_G
ed
ed
ve
rv
rv
O
O
er
CI
CI
CI
se
s
RT
RT
RT
(re
(re
(re
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 0 0 0 0 0 0 0 0 0 Reset
UN L
_T C A SL EL
H_ ADn LP EL
E
UC AD XPD PT
UN E
E
Dn X_S
PA _S _IE
S
_F _O
UC P _T T
UC P _S _S
_I
P _ O
_
O H_ Dn AR
AC
RV
n_ E
E
H_ ADn IE_
O H_ Dn P
Dn LP
U
AD RD
RU
_T C A ST
M
_D
_D
_F
_P n_
O U P _
n_
O U P _
(re IO_ UC ADn
Dn
CI TO H_ Dn
CI O H_ Dn
D
ed C A
PA
RT IO_ UC _PA
CI TO _PA
RT O_ UC PA
C O _P
rv U _P
H_
CI TO H_
RT IO_ CH
se TO H
H
C O H
H
UC
RT _ UC
RT O_ UC
U
O
CI TO
O
)
)
ed
ed
_T
_T
_T
T
RT O_
RT O_
rv
rv
O
O
CI
CI
CI
CI
CI
se
se
C
RT
RT
RT
RT
RT
RT
(re
(re
31 30 29 28 27 26 25 23 22 21 20 19 18 17 16 15 14 13 12 0
0 2 1 0 0 0x4 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_MUX_SEL Connect the RTC pad input to digital pad input. 0 is available.
(R/W)
RTCIO_TOUCH_PADn_TIE_OPT The tie option of touch sensor. 0: tie low; 1: tie high. (R/W)
RTCIO_TOUCH_PADn_DAC Touch sensor slope control. 3-bit for each touch pad, defaults to 0x4.
(R/W)
RTCIO_TOUCH_PADn_RUE Pull-up enable of the pad. 1: internal pull-up enabled, 0: internal pull-up
disabled. (R/W)
RTCIO_TOUCH_PADn_DRV Select the drive strength of the pad. 0: ~5 mA: 1: ~10 mA: 2: ~20 mA;
3: ~40 mA. (R/W)
FU EL
O 2P LP L
SE
FU O E
CI 3 S SE
IE
2P X_S
32 SL IE
N_
N_
_
_X _ _
P_ P_
O 2P V
P_ E
E
RT O_ 2P LP
U
DR
32 RD
RU
CI X3 _S
P_
_X _
_
2P
RT IO_ 2P
32
CI X3
C X3
)
d)
)
ed
ed
_X
_X
_X
X
ve
RT IO_
RT O_
rv
rv
O
O
er
CI
CI
CI
CI
se
se
C
s
RT
RT
RT
RT
RT
(re
(re
(re
31 30 29 28 27 26 20 19 18 17 16 15 14 13 12 0
0 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 Reset
RTCIO_X32P_RUE Pull-up enable of the pad. 1: internal pull-up enabled; 0: internal pull-up disabled.
(R/W)
RTCIO_X32P_RDE Pull-down enable of the pad. 1: internal pull-down enabled; 0: internal pull-down
disabled. (R/W)
RTCIO_X32P_DRV Select the drive strength of the pad. 0: ~5 mA: 1: ~10 mA: 2: ~20 mA; 3: ~40
mA. (R/W)
FU EL
O 2N LP L
SE
FU O E
CI 3 S SE
IE
N_ _S
32 SL IE
N_
N_
_
_X _ _
N_ P_
32 UX
O 2N V
N_ E
E
R T O _ 2N L P
DR
32 RD
RU
CI X3 _S
N_
_X _
N_
_
RT IO_ 2N
32
32
CI X3
C 3
d)
)
ed
ed
_X
_X
_X
X
ve
RT O_
RT O_
rv
rv
O
O
er
CI
CI
CI
CI
CI
se
se
s
RT
RT
RT
RT
RT
(re
(re
(re
31 30 29 28 27 26 20 19 18 17 16 15 14 13 12 0
0 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 Reset
RTCIO_X32N_RUE Pull-up enable of the pad. 1: internal pull-up enabled; 0: internal pull-up disabled.
(R/W)
RTCIO_X32N_RDE Pull-down enable of the pad. 1: internal pull-down enabled; 0: internal pull-down
disabled. (R/W)
RTCIO_X32N_DRV Select drive strength of the pad. 0: ~5 mA; 1: ~10 mA; 2: ~20 mA; 3: ~40 mA.
(R/W)
CE
AC OR
_D D_F
C PD _FU EL
C PD 1 P_ L
PD P
SE
O A FU OE
RT IO_ AC _SL SE
C1 AC E
S
RT IO_ AC _SL IE
_X _X
DA 1_D N_I
C1 X_
N_
CI PD 1_ P_
AC
V
C1 DE
UE
P
U
CI PD _DR
RT IO_ AC _SL
_P 1_M
_D
DA 1_R
_R
C1
C PD 1
C D 1
C1
_P C
RT IO_ AC
_P C
DA
O A
DA
DA
DA
d)
)
_P
_P
_P
ed
ed
ve
RT O_
RT IO_
rv
rv
O
O
er
CI
CI
CI
CI
CI
se
se
C
s
RT
RT
RT
RT
RT
RT
(re
(re
(re
31 30 29 28 27 26 20 19 18 17 16 15 14 13 12 11 10 3 2 0
0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_PDAC1_RUE Pull-up enable of the pad. 1: internal pull-up enabled, 0: internal pull-up dis-
abled. (R/W)
RTCIO_PDAC1_RDE Pull-down enable of the pad. 1: internal pull-down enabled; 0: internal pull-
down disabled. (R/W)
RTCIO_PDAC1_DRV Select drive strength of the pad. 0: ~5 mA; 1: ~10 mA; 2: ~20 mA; 3: ~40
mA. (R/W)
CE
AC OR
_D D_F
C PD _FU EL
C PD 2 P_ L
PD P
SE
O A FU OE
RT IO_ AC _SL SE
C2 AC E
S
RT IO_ AC _SL IE
_X _X
DA 2_D N_I
C2 X_
N_
CI PD 2_ P_
AC
V
C2 DE
UE
P
U
CI PD _DR
RT IO_ AC _SL
_P 2_M
_D
DA 2_R
_R
C2
C PD 2
C D 2
C2
_P C
RT IO_ AC
_P C
DA
O A
DA
DA
DA
d)
)
_P
_P
_P
ed
ed
ve
RT O_
RT IO_
rv
rv
O
O
er
CI
CI
CI
CI
CI
se
se
C
s
RT
RT
RT
RT
RT
RT
(re
(re
(re
31 30 29 28 27 26 20 19 18 17 16 15 14 13 12 11 10 3 2 0
0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTCIO_PDAC2_RUE Pull-up enable of the pad. 1: internal pull-up enabled, 0: internal pull-up dis-
abled. (R/W)
RTCIO_PDAC2_RDE Pull-down enable of the pad. 1: internal pull-down enabled; 0: internal pull-
down disabled. (R/W)
RTCIO_PDAC2_DRV Select drive strength of the pad. 0: ~5 mA; 1: ~10 mA; 2: ~20 mA; 3: ~40
mA. (R/W)
EL
_P 19 LP EL
9_ _SE
UN E
E
AD _S _IE
S
_F _O
TC D S S
_I
N_
_
UX
RV
19 DE
UE
_R _P 9 P
19 LP
FU
O C D1 SL
_M
_D
AD _R
_R
CI T A _
_
19
_P 19
TC D19
9
1
RT IO_ C_ D1
AD
TC AD
AD
A
C RT PA
A
_P
_R _P
_P
_P
P
RT O_ C_
TC
O C
TC
CI RT
CI RT
d)
)
_R
_R
_R
R
ed
ed
ve
RT O_
RT O_
rv
rv
O
O
er
CI
CI
CI
CI
CI
se
se
s
RT
RT
RT
RT
RT
(re
(re
(re
31 30 29 28 27 26 20 19 18 17 16 15 14 13 12 0
0 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 Reset
RTCIO_RTC_PAD19_RUE Pull-up enable of the pad. 1: internal pull-up enabled, 0: internal pull-up
disabled. (R/W)
RTCIO_RTC_PAD19_DRV Select drive strength of the pad. 0: ~5 mA; 1: ~10 mA; 2: ~20 mA; 3:
~40 mA. (R/W)
EL
_P 20 LP EL
0_ _SE
UN E
E
AD _S _IE
S
_F _O
TC D S S
_I
N_
_
UX
RV
20 DE
UE
_R _P 0 P
20 LP
FU
O C D2 SL
_M
_D
AD _R
_R
CI T A _
_
20
_P 20
TC D20
0
2
RT IO_ C_ D2
AD
TC AD
AD
A
C RT PA
A
_P
_R _P
_P
_P
P
RT O_ C_
TC
O C
TC
CI RT
CI RT
d)
)
_R
_R
_R
R
ed
ed
ve
RT O_
RT O_
rv
rv
O
O
er
CI
CI
CI
CI
CI
se
se
s
RT
RT
RT
RT
RT
(re
(re
(re
31 30 29 28 27 26 20 19 18 17 16 15 14 13 12 0
0 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 Reset
RTCIO_RTC_PAD20_RUE Pull-up enable of the pad. 1: internal pull-up enabled; 0: internal pull-up
disabled. (R/W)
RTCIO_RTC_PAD20_DRV Select drive strength of the pad. 0: ~5 mA; 1: ~10 mA; 2: ~20 mA; 3:
~40 mA. (R/W)
EL
_P 21 LP EL
1_ _SE
UN E
E
AD _S _IE
S
_F _O
TC D S S
_I
N_
_
UX
RV
21 DE
UE
_R _P 1 P
21 LP
FU
O C D2 SL
_M
_D
AD _R
_R
CI T A _
_
21
_P 21
TC D21
1
2
RT IO_ C_ D2
AD
TC AD
AD
A
C RT PA
A
_P
_R _P
_P
_P
P
RT O_ C_
TC
O C
TC
CI RT
CI RT
d)
)
_R
_R
_R
R
ed
ed
ve
RT O_
RT O_
rv
rv
O
O
er
CI
CI
CI
CI
CI
se
se
s
RT
RT
RT
RT
RT
(re
(re
(re
31 30 29 28 27 26 20 19 18 17 16 15 14 13 12 0
0 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 Reset
RTCIO_RTC_PAD21_RUE Pull-up enable of the pad. 1: internal pull-up enabled; 0: internal pull-up
disabled. (R/W)
RTCIO_RTC_PAD21_DRV Select drive strength of the pad. 0: ~5 mA; 1: ~10 mA; 2: ~20 mA; 3:
~40 mA. (R/W)
)
ed
_X
rv
O
CI
se
RT
(re
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 GPIO1, etc. The input value on this pin XOR
RTC_CNTL_EXT_XTL_CONF_REG[30] is the crystal power down enable signal. (R/W)
EL
EL
_S
_S
DA
CL
_S
_S
2C
2C
_I
_I
AR
AR
d)
_S
_S
ve
O
er
CI
CI
s
RT
RT
(re
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_SCL_SEL Selects a pad the RTC I2C SCL signal connects to. 0: use TOUCH
PAD0; 1: use TOUCH PAD2. (R/W)
RTCIO_SAR_I2C_SDA_SEL Selects a pad the RTC I2C SDA signal connects to. 0: use TOUCH
PAD1; 1: use TOUCH PAD3. (R/W)
6.1 Reset
6.1.1 Overview
ESP32-S2 provides four types of reset that occur at different levels, namely CPU Reset, Core Reset, System
Reset, and Chip Reset.
All reset types mentioned above (except Chip Reset) maintain the data stored in internal memory. Figure 6-1
shows the scopes of affected subsystems when different types of reset occur.
• CPU Reset: Only resets CPU core. Once such reset is released, programs will be executed from CPU reset
vector.
• Core Reset: Resets the whole digital system except RTC, including CPU, peripherals, Wi-Fi, and digital
GPIOs.
Table 47 lists different reset sources and the types of reset they trigger.
Note:
• Once brown-out status is detected, the detector will trigger System Reset or Chip Reset, depending on
register configuration. For more information, please see Chapter 9 Low-Power Management (RTC_CNTL).
6.2 Clock
6.2.1 Overview
ESP32-S2 provides multiple clock sources, which allow CPU, peripherals and RTC to work at different
frequencies, thus providing more flexibility in meeting the requirements of various application scenarios. Figure
6-2 shows the system clock structure.
• High speed clock for devices working at a higher frequency, such as CPU and digital peripherals
• Slow speed clock for low-power devices, such as power management unit and low-power peripherals
– RC_FAST_CLK (8 MHz by default): internal divide-by-N oscillator of 8 MHz, with adjustable frequency
– RC_FAST_DIV_CLK (31.250 kHz by default): internal clock derived from RC_FAST_CLK divided by
256
Users can set PLL_CLK, APLL_CLK, RC_FAST_CLK or XTAL_CLK as CPU_CLK clock source by configuring
register SYSTEM_SOC_CLK_SEL, see Table 48 and Table 49.
Note:
• When users select XTAL_CLK as CPU clock source and adjust the divider value by configuring register
SYSTEM_PRE_DIV_CNT, the rules below should be followed.
– If current divider value is 2 (SYSTEM_PRE_DIV_CNT = 1) and the target is x (x ≠ 1), users should set
the divider first to 1 (SYSTEM_PRE_DIV_CNT = 0) and then to x (SYSTEM_PRE_DIV_CNT = x - 1).
– If current divider value is x (SYSTEM_PRE_DIV_CNT = x - 1) and the target is 2, users should set the
divider first to 1 (SYSTEM_PRE_DIV_CNT = 0) and then to 2 (SYSTEM_PRE_DIV_CNT = 1).
– For other target divider value x, users can adjust the register directly (SYSTEM_PRE_DIV_CNT = x - 1).
Normally, one REF_TICK cycle lasts for 1 µs, so APB_CTRL_XTAL_TICK_NUM should be configured to 39
(default), and APB_CTRL_CK8M_TICK_NUM to 7 (default).
LED module uses RC_FAST_CLK as clock source when APB_CLK is disabled. In other words, when the system
is in low-power mode, most peripherals will be halted (APB_CLK is turned off), but LED can work normally via
RC_FAST_CLK.
RTC_FAST_CLK is used to clock On-chip Sensor module. It can be sourced from a divided XTAL_CLK or from
RC_FAST_CLK.
Providing an integrated precision clock source can minimize system cost. To this end, ESP32-S2 integrates an
audio PLL to clock I²S module.
• The operating frequency range of the numerator is 350 MHz ~ 500 MHz.
sdm1 sdm0
350M Hz < fxtal (sdm2 + + 16 + 4) < 500M Hz
28 2
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 follows the state of the system.
When the system enters sleep mode, PLL will be disabled automatically; when the system wakes up, PLL will be
enabled automatically.
7.1 Overview
ESP32-S2 has three strapping pins:
• GPIO0
• GPIO45
• GPIO46
Software can read the values of the three strapping pins from register GPIO_STRAPPING. During
power-on-reset, RTC watchdog reset, brownout reset, analog super watchdog reset, and crystal clock glitch
detection reset (see Chapter 6 Reset and Clock), hardware samples and stores the voltage level of strapping pins
as strapping bit of “0” or “1” in latches, and hold these bits until the chip is powered down or shut down.
By default, GPIO0, GPIO45 and GPIO46 are connected to internal pull-up/pull-down during chip reset.
Consequently, if the three GPIOs are unconnected or their connected external circuits are high-impedance, the
internal weak pull-up/pull-down will determine the default input level of the strapping pins (see Table 54).
To change the default configuration of strapping pins, users can apply external pull-down/pull-up resistors, or use
host MCU GPIOs to control the voltage level of these pins when powering on ESP32-S2. After the reset is
released, the strapping pins work as normal-function pins.
Note:
The following section provides description of the chip functions and the pattern of the strapping pins values to invoke
each function. Only documented patterns should be used. If some pattern is not documented, it may trigger unexpected
behavior.
Table 55 shows the strapping pin values and the associated boot modes. ”x” means that this value is ignored.
Currently only the two boot modes shown are supported. The strapping combination of GPIO0 = 0 and GPIO46
= 1 is not supported and will trigger unexpected behavior.
In SPI boot mode, the CPU boots the system by reading the program stored in SPI flash.
In download boot mode, users can download code to SRAM or Flash using UART0, UART1, QPI or USB
interface. It is also possible to load a program into SRAM and execute it in this mode.
• EFUSE_DIS_FORCE_DOWNLOAD. If this eFuse is 0 (default), software can switch the chip from SPI boot
mode to download boot mode by setting register RTC_CNTL_FORCE_DOWNLOAD_BOOT and triggering
a CPU reset. If this eFuse is 1, this register is disabled.
ROM code will print to pin U0TXD (default) or to pin DAC_1, depending on the eFuse bit
UART_PRINT_CHANNEL (0: UART0; 1: DAC_1).
• GPIO45 = 0, VDD_SPI pin is powered directly from VDD3P3_RTC_IO via resistor RSP I . Typically this
voltage is 3.3 V.
This functionality can be overridden by setting eFuse bit VDD_SPI_FORCE to 1, in which case the VDD_SPI_TIEH
eFuse value determines the VDD_SPI voltage:
8.1 Overview
The interrupt matrix embedded in ESP32-S2 independently allocates peripheral interrupt sources to the CPU
peripheral interrupts, so as to timely inform the CPU to process the interrupts once the interrupt signals are
generated. This flexible function is applicable to a variety of application scenarios.
8.2 Features
• Accept 95 peripheral interrupt sources as input
Status Register
No. Source Configuration Register
Bit Name
0 reserved reserved 0
1 reserved reserved 1
2 PWR_INTR INTERRUPT_PRO_PWR_INTR_MAP_REG 2
3 reserved reserved 3
4 reserved reserved 4
5 reserved reserved 5
6 reserved reserved 6
7 reserved reserved 7
8 reserved reserved 8
9 reserved reserved 9
10 reserved reserved 10
Submit Documentation Feedback
11 reserved reserved 11
12 reserved reserved 12
13 UHCI0_INTR INTERRUPT_PRO_UHCI0_INTR_MAP_REG 13
14 reserved reserved 14
227
15 TG_T0_LEVEL_INT INTERRUPT_PRO_TG_T0_LEVEL_INT_MAP_REG 15
INTERRUPT_PRO_INTR_STATUS_REG_0_REG
16 TG_T1_LEVEL_INT INTERRUPT_PRO_TG_T1_LEVEL_INT_MAP_REG 16
17 TG_WDT_LEVEL_INT INTERRUPT_PRO_TG_WDT_LEVEL_INT_MAP_REG 17
18 TG_LACT_LEVEL_INT INTERRUPT_PRO_TG_LACT_LEVEL_INT_MAP_REG 18
19 TG1_T0_LEVEL_INT INTERRUPT_PRO_TG1_T0_LEVEL_INT_MAP_REG 19
20 TG1_T1_LEVEL_INT INTERRUPT_PRO_TG1_T1_LEVEL_INT_MAP_REG 20
21 TG1_WDT_LEVEL_INT INTERRUPT_PRO_TG1_WDT_LEVEL_INT_MAP_REG 21
22 TG1_LACT_LEVEL_INT INTERRUPT_PRO_TG1_LACT_LEVEL_INT_MAP_REG 22
23 GPIO_INTERRUPT_PRO INTERRUPT_PRO_GPIO_INTERRUPT_PRO_MAP_REG 23
24 GPIO_INTERRUPT_PRO_NMI INTERRUPT_PRO_GPIO_INTERRUPT_PRO_NMI_MAP_REG 24
25 reserved reserved 25
26 reserved reserved 26
27 DEDICATED_GPIO_IN_INTR INTERRUPT_PRO_DEDICATED_GPIO_IN_INTR_MAP_REG 27
ESP32-S2 TRM (v1.1)
28 CPU_INTR_FROM_CPU_0 INTERRUPT_PRO_CPU_INTR_FROM_CPU_0_MAP_REG 28
29 CPU_INTR_FROM_CPU_1 INTERRUPT_PRO_CPU_INTR_FROM_CPU_1_MAP_REG 29
30 CPU_INTR_FROM_CPU_2 INTERRUPT_PRO_CPU_INTR_FROM_CPU_2_MAP_REG 30
31 CPU_INTR_FROM_CPU_3 INTERRUPT_PRO_CPU_INTR_FROM_CPU_3_MAP_REG 31
32 SPI_INTR_1 INTERRUPT_PRO_SPI_INTR_1_MAP_REG 0
33 SPI_INTR_2 INTERRUPT_PRO_SPI_INTR_2_MAP_REG 1 INTERRUPT_PRO_INTR_STATUS_REG_1_REG
34 SPI_INTR_3 INTERRUPT_PRO_SPI_INTR_3_MAP_REG 2
Espressif Systems
48 USB_INTR INTERRUPT_PRO_USB_INTR_MAP_REG 16
49 RTC_CORE_INTR INTERRUPT_PRO_RTC_CORE_INTR_MAP_REG 17
50 RMT_INTR INTERRUPT_PRO_RMT_INTR_MAP_REG 18
51 PCNT_INTR INTERRUPT_PRO_PCNT_INTR_MAP_REG 19 INTERRUPT_PRO_INTR_STATUS_REG_1_REG
228
52 I2C_EXT0_INTR INTERRUPT_PRO_I2C_EXT0_INTR_MAP_REG 20
53 I2C_EXT1_INTR INTERRUPT_PRO_I2C_EXT1_INTR_MAP_REG 21
54 RSA_INTR INTERRUPT_PRO_RSA_INTR_MAP_REG 22
55 SHA_INTR INTERRUPT_PRO_SHA_INTR_MAP_REG 23
56 AES_INTR INTERRUPT_PRO_AES_INTR_MAP_REG 24
57 SPI2_DMA_INT INTERRUPT_PRO_SPI2_DMA_INT_MAP_REG 25
58 SPI3_DMA_INT INTERRUPT_PRO_SPI3_DMA_INT_MAP_REG 26
59 reserved reserved 27
60 TIMER_INT INTERRUPT_PRO_TIMER_INT1_MAP_REG 28
61 TIMER_INT2 INTERRUPT_PRO_TIMER_INT2_MAP_REG 29
62 TG_T0_EDGE_INT INTERRUPT_PRO_TG_T0_EDGE_INT_MAP_REG 30
63 TG_T1_EDGE_INT INTERRUPT_PRO_TG_T1_EDGE_INT_MAP_REG 31
64 TG_WDT_EDGE_INT INTERRUPT_PRO_TG_WDT_EDGE_INT_MAP_REG 0
ESP32-S2 TRM (v1.1)
65 TG_LACT_EDGE_INT INTERRUPT_PRO_TG_LACT_EDGE_INT_MAP_REG 1
66 TG1_T0_EDGE_INT INTERRUPT_PRO_TG1_T0_EDGE_INT_MAP_REG 2
67 TG1_T1_EDGE_INT INTERRUPT_PRO_TG1_T1_EDGE_INT_MAP_REG 3
INTERRUPT_PRO_INTR_STATUS_REG_2_REG
68 TG1_WDT_EDGE_INT INTERRUPT_PRO_TG1_WDT_EDGE_INT_MAP_REG 4
69 TG1_LACT_EDGE_INT INTERRUPT_PRO_TG1_LACT_EDGE_INT_MAP_REG 5
70 CACHE_IA_INT INTERRUPT_PRO_CACHE_IA_INT_MAP_REG 6
71 SYSTIMER_TARGET0_INT INTERRUPT_PRO_SYSTIMER_TARGET0_INT_MAP_REG 7
Espressif Systems
85 reserved reserved 21
86 reserved reserved 22
87 DCACHE_PRELOAD_INT INTERRUPT_PRO_DCACHE_PRELOAD_INT_MAP_REG 23 INTERRUPT_PRO_INTR_STATUS_REG_2_REG
88 ICACHE_PRELOAD_INT INTERRUPT_PRO_ICACHE_PRELOAD_INT_MAP_REG 24
229
89 APB_ADC_INT INTERRUPT_PRO_APB_ADC_INT_MAP_REG 25
90 CRYPTO_DMA_INT INTERRUPT_PRO_CRYPTO_DMA_INT_MAP_REG 26
91 CPU_PERI_ERROR_INT INTERRUPT_PRO_CPU_PERI_ERROR_INT_MAP_REG 27
92 APB_PERI_ERROR_INT INTERRUPT_PRO_APB_PERI_ERROR_INT_MAP_REG 28
93 DCACHE_SYNC_INT INTERRUPT_PRO_DCACHE_SYNC_INT_MAP_REG 29
94 ICACHE_SYNC_INT INTERRUPT_PRO_ICACHE_SYNC_INT_MAP_REG 30
ESP32-S2 TRM (v1.1)
8. Interrupt Matrix (INTERRUPT)
• Peripheral Interrupts:
– Level-triggered interrupts: triggered by high level signal. The interrupt sources should hold the level till
the CPU handles the interrupts.
– Edge-triggered interrupts: triggered on rising edge. The CPU responds to this kind of interrupts
immediately.
– NMI interrupt: once triggered, the NMI interrupt can not be masked by software using the CPU
registers.
• Internal Interrupts:
– Timer interrupts: triggered by internal timers and are used to generate periodic interrupts.
ESP32-S2 supports the above-mentioned 32 interrupts at six levels as shown in the table below. A higher level
corresponds to a higher priority. NMI has the highest interrupt priority and once triggered, the CPU must handle
such interrupt.
• Source_X: stands for a particular peripheral interrupt source, wherein, X means the number of this interrupt
source in Table 57.
• Interrupt_P: stands for the CPU peripheral interrupt numbered as Num_P. The value of Num_P can be 0 ~
5, 8 ~ 10, 12 ~ 14, 17 ~ 28 and 30 ~ 31 (see Table 58).
• Interrupt_I: stands for the CPU internal interrupt numbered as Num_I. The value of Num_I can be 6, 7, 11,
15, 16 and 29 (see Table 58).
8.6 Registers
The address in the following part represents the address offset (relative address) with respect to the peripheral
base address, not the absolute address. For detailed information about the interrupt matrix base address, please
refer to Section 8.4.
AP
_M
TR
IN
R_
W
_P
RO
_P
T
UP
d)
ve
RR
er
TE
s
(re
IN
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 16 Reset
AP
M
R_
NT
_I
I0
HC
_U
O
PR
T_
UP
ed)
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
NT
_I
EL
EV
_L
0
_T
G
_T
RO
_P
T
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
NT
_I
EL
EV
_L
1
_T
G
_T
O
PR
T_
UP
d)
e
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
L_
VE
E
_L
DT
_W
G
_T
RO
_P
T
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
M
NT_
_I
EL
EV
_L
CT
A
_L
G
_T
O
PR
T_
UP
e d)
RR
rv
se
TE
(re
31 5 4
IN 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 Reset
AP
M
T_
_IN
EL
EV
_L
T0
1_
G
_T
RO
_P
T
UP
d)
ve
RR
er
TE
s
(re
IN
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 16 Reset
AP
M
T_
_IN
EL
EV
_L
T1
1_
G
_T
O
PR
T_
UP
ed)
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
L_
VE
E
_L
DT
W
1_
G
_T
RO
_P
T
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
NT
_I
EL
EV
_L
CT
LA
1_
G
_T
O
PR
T_
UP
d)
e
RR
rv
se
TE
(re
31 5 4
IN 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 Reset
AP
_M
RO
T _P
UP
E RR
NT
_I
O
PI
_G
RO
T _P
UP
d)
ve
RR
er
TE
s
(re
IN
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 16 Reset
AP
M
I_
M
_N
RO
_P
PT
RU
ER
NT
_I
O
PI
_G
O
PR
d)
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
T_
e
UP
rv
RR
se
TE
(re
IN
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 16 Reset
AP
_M
_0
PU
_C
M
FRO
R_
NT
_I
PU
_C
O
PR
)
ed
T_
UP
rv
RR
se
TE
(re
IN
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 16 Reset
AP
_M
_1
PU
_C
M
RO
R_F
NT
_I
PU
_C
O
PR
d)
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
_M
_2
PU
_C
M
O
FR
R_
NT
_I
PU
_C
O
PR
d )
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
_M
_3
PU
_C
M
RO
F
R_
NT
_I
PU
_C
O
PR
)
ed
T_
UP
rv
RR
se
TE
(re
IN
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 16 Reset
AP
M
1_
R_
NT
_I
PI
_S
RO
_P
PT
d)
RU
ve
ER
r
se
T
(re
IN
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 16 Reset
AP
_M
_2
TR
_ IN
PI
_S
O
PR
T_
UP
d)
e
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
3
R_
NT
_I
PI
_S
RO
_P
T
UP
d)
ve
RR
er
TE
s
(re
IN
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 16 Reset
AP
M
T_
IN
0_
2S
_I
O
PR
T_
UP
ed)
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
R_
I NT
T_
AR
_U
O
PR
T_
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
T1
AR
_U
RO
_P
T
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
T
IN
C_
ED
_L
O
PR
T_
UP
d)
e
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
NT
_I
SE
FU
_E
O
PR
T_
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_ M
NT
_I
AN
_C
RO
_P
T
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
SB
_U
O
PR
T_
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
_M
TR
N
_I
RE
O
_C
TC
_R
O
PR
T_
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
TR
IN
T_
M
_R
RO
_P
T
UP
d)
ve
RR
er
TE
s
(re
IN
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 16 Reset
AP
M
T R_
IN
T_
CN
_P
O
PR
T_
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
_M
TR
IN
0_
XT
_E
2C
_I
O
PR
T_
UP
ed)
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
TR
IN
1_
XT
_E
2C
_I
RO
_P
T
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
SA
_R
O
PR
T_
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
ES
_A
RO
_P
T
UP
d)
ve
RR
er
TE
s
(re
IN
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 16 Reset
AP
_M
T
IN
A_
DM
2_
PI
_S
O
PR
T_
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
A_
DM
3_
PI
_S
O
PR
T_
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
1 _M
NT
_I
ER
IM
_T
RO
T _P
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
_M
T2
N
_I
ER
IM
_T
RO
_P
PT
d)
RU
e
rv
ER
se
T
(re
IN
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 16 Reset
AP
M
T_
IN
E_
G
ED
0_
_T
G
_T
O
PR
T_
UP
d )
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
E_
DG
_E
1
_T
G
_T
RO
_P
T
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
E_
GD
_E
DT
_W
G
_T
O
PR
T_
UP
e d)
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
E_
G
_ED
CT
A
_L
G
_T
RO
_P
T
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
E_
DG
_E
T0
1_
G
_T
O
PR
T_
UP
d)
e
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
E_
DG
_E
T1
1_
G
_T
RO
_P
T
UP
d)
ve
RR
er
TE
s
(re
IN
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 16 Reset
AP
M
T_
IN
E_
DG
_E
DT
W
1_
G
_T
O
PR
T_
UP
ed)
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
E_
G
_ ED
CT
LA
1_
G
_T
RO
T _P
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
A_
_I
HE
AC
_C
O
PR
T_
UP
e d)
RR
rv
se
TE
(re
IN
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 16 Reset
T_
UP
rv
RR
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
1_
ET
G
AR
_T
ER
M
TI
YS
_S
O
PR
d)
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
2_
ET
G
AR
_T
ER
M
TI
YS
_S
O
PR
d)
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
_M
TR
N
_I
G
BU
DE
T_
IS
SS
_A
O
PR
T_
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
G
IL
0_
M
RA
_I
O
PR
S_
M
_P
O
PR
d)
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
_M
R
NT
_I
G
IL
0_
M
RA
_D
O
PR
S_
M
_P
O
PR
d)
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
LG
_I
RT
PO
_D
O
PR
S_
M
_P
O
PR
d )
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
LG
_I
HB
_A
O
PR
S_
M
_P
O
PR
)
ed
T_
UP
rv
RR
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
LG
_I
HE
AC
_C
O
PR
S_
M
_P
O
PR
d)
T_
e
UP
rv
RR
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
G
IL
I_
B_
AP
A_
DM
S_
M
_P
O
PR
d )
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
LG
_I
_I
RX
A_
DM
S_
M
_P
O
PR
d)
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
_M
R
NT
_I
LG
_I
_I
TX
A_
DM
S_
M
_P
O
PR
d)
T_
ve
UP
r
RR
se
TE
(re
IN
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 16 Reset
AP
M
R_
NTI
T_
EC
EJ
_R
EM
_M
PI
_S
O
PR
T_
UP
e d)
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
R_
NT
_I
PY
CO
A_
M
_D
RO
_P
T
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
NT
_I
AD
O
EL
PR
E_
CH
CA
_D
O
PR
T_
UP
d)
e
RR
rv
se
TE
(re
31 5 4 IN 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 Reset
AP
_M
NT
_I
AD
O
R EL
_P
HE
C
CA
_I
RO
_P
T
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
_M
NT
_I
DC
_A
PB
_A
O
PR
T_
UP
d)
e
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
A_
M
_D
P TO
RY
_C
RO
_P
T
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
AP
M
T_
IN
R_
RO
ER
I_
ER
_P
PU
_C
O
PR
T_
UP
d)
ve
RR
r
se
TE
(re
31 5 4 IN 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 Reset
AP
M
T_
IN
R_
O
ERR
I_
ER
_P
PB
_A
RO
_P
T
UP
d)
ve
RR
r
se
TE
(re
IN
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 16 Reset
AP
M
T_
N
_I
NC
SY
E_
CH
CA
_D
O
PR
T_
UP
d)
ve
RR
r
se
TE
(re
31 5 4 IN 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 Reset
AP
_M
NT
_I
NC
Y
_S
HE
C
CA
_I
RO
T _P
UP
)
ed
RR
rv
se
TE
(re
IN
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 16 Reset
W
_H
A SK
EN M
K_ MI_
CL N
T_ O_
UP _PR
RR PT
)
TE U
ed
IN R
rv
ER
se
T
(re
IN
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 1 Reset
INTERRUPT_CLK_EN This bit is used to enable or disable the clock of interrupt matrix. 1: enable
the clock; 0: disable the clock. (R/W)
INTERRUPT_PRO_NMI_MASK_HW This bit is used to disable all NMI interrupt signals to CPU. (R/W)
31 0
0x000000 Reset
INTERRUPT_PRO_INTR_STATUS_0 This register stores the status of the first 32 input interrupt
sources. (RO)
1
U S_
AT
ST
R_
NT
_I
O
PR
T_
UP
RR
TE
IN
31 0
0x000000 Reset
INTERRUPT_PRO_INTR_STATUS_1 This register stores the status of the second 32 input interrupt
sources. (RO)
2
S_
TU
TA
_S
TR
N
_I
R O
_P
PT
RU
ER
T
IN
31 0
0x000000 Reset
INTERRUPT_PRO_INTR_STATUS_2 This register stores the status of the last 31 input interrupt
sources. (RO)
U
e
RR
rv
se
TE
(re
IN
31 28 27 0
0 0 0 0 0x1904180 Reset
9.1 Introduction
ESP32-S2 has an advanced Power Management Unit (PMU), which can flexibly power up different power
domains of the chip, to achieve the best balance among chip performance, power consumption, and wakeup
latency. To simplify power management for typical scenarios, ESP32-S2 has predefined five power modes, which
are preset configurations that power up different combinations of power domains. On top of that, the chip also
allows the users to independently power up any particular power domain to meet more complex requirements.
ESP32-S2 has integrated two Ultra-Low-Power co-processors (ULP co-processors), which allow the chip to
work when most of the power domains are powered down, thus achieving extremely low-power
consumption.
9.2 Features
ESP32-S2’s low-power management supports the following features:
• Five predefined power modes to simplify power management for typical scenarios
• Up to 16 KB of retention memory
In this chapter, we first introduce the working process of ESP32-S2’s low-power management, then introduce
the predefined power modes of the chip, and at last, introduce the RTC boot of the chip.
• Power management unit: controls the power supply to Analog, RTC and Digital power domains.
• Power isolation unit: isolates different power domains, so any powered down power domain does not
affect the powered up ones.
• Timers:
– RTC timer: logs the status of the RTC main state machine in dedicated registers.
– ULP timer: wakes up the ULP co-processors at a predefined time. For details, please refer to Chapter
1 ULP Coprocessor (ULP).
– Touch sensor timer: wakes up the touch sensor at a predefined time. For details, please refer to
Chapter 32 On-Chip Sensor and Analog Signal Processing.
• 8 x 32-bit “always-on” retention registers: These registers are always powered up and can be used for
storing data that cannot be lost.
• 22 x “always-on” pins: These pins are always powered up and can be used as wakeup sources when the
chip is working in the low-power modes (for details, please refer to Section 9.4.4), or can be used as
regular GPIOs (for details, please refer to Chapter 5 IO MUX and GPIO Matrix (GPIO, IO_MUX)).
• RTC slow memory: supports 8 KB SRAM, which can be used as retention memory or to store ULP
directives and data.
• RTC fast memory: supports 8 KB SRAM, which can be used as retention memory.
• RTC main state machine: generates power gating, clock gating, and reset signals.
• Power controllers: power up and power down different power domains, according to the power gating
signals from the main state machine.
• Sleep / wakeup controllers: send sleep or wakeup requests to the RTC main state machine.
In ESP32-S2’s power management unit, the sleep / wakeup controllers send sleep or wakeup requests to the
RTC main state machine, which then generates power gating, clock gating, and reset signals. Then, the power
controller and clock controller power up and power down different power domains and clock sources, according
to the signals generated by the RTC main state machine, so that the chip enters or exits the low-power modes.
The main workflow is shown in Figure 9-2.
GPIO reject
sleep EN
done
state
state
state
main
main
main
state
main
wait
wakeup
Touch
done
done
CPU wakeup
wakeup
Wakeup Controller
wakeup
wakeup
RTC GPIO
Digital
MAC
wakeup
wakeup
GPIO
UART0
UART1
wakeup
EXT0
EXT1
wakeup
RTC Main
Timer
Note:
For more detailed description about power domains, please refer to 9.4.2.
Selection Signal
PMU
RC_SLOW_CLK
0
XTAL32K_CLK
RTC_SLOW_CLK
1 RTC Timer
RC_FAST_DIV_CLK
2
ULP Coprocessor
Selection Signal
XTAL_DIV_CLK
Sensor Controller
0
RTC_FAST_CLK
RC_FAST_CLK ESP32-S2
div n 1 RTC Slow Memory
RTC Clock
Selection Signals
XTAL32K_CLK
RC_FAST_CLK
LP_MUX
LOW_POWER_CLK
Wireless
RTC_SLOW_CLK
XTAL_CLK
Note:
1. The default RTC slow clock source.
For more detailed description about clocks, please refer to 6 Reset and Clock.
9.3.3 Timers
ESP32-S2’s low-power management uses 3 timers:
• RTC timer
• ULP timer
This section only introduces the RTC timer. For detailed description of ULP timer and touch sensor timer, please
refer to Chapters 1 ULP Coprocessor (ULP) and 32 On-Chip Sensor and Analog Signal Processing.
The readable 48-bit RTC timer is a real-time rr (using RTC slow clock) that can be configured to log the time
when one of the following events happens. For details, see Table 62.
The RTC timer updates two groups of registers upon any new trigger. The first group logs the information of the
current trigger, and the other logs the previous trigger. Detailed information about these two register groups is
shown below:
• Register group 0: logs the status of RTC timer at the current trigger.
– RTC_CNTL_TIME_HIGH0_REG
– RTC_CNTL_TIME_LOW0_REG
• Register group 1: logs the status of RTC timer at the previous trigger.
– RTC_CNTL_TIME_HIGH1_REG
– RTC_CNTL_TIME_LOW1_REG
On a new trigger, information on previous trigger is moved from register group 0 to register group 1 (and the
original trigger logged in register group 1 is overrode), and this new trigger is logged in register group 0.
Therefore, only the last two triggers can be logged at any time.
It should be noted that any reset / sleep other than power-up reset will not stop or reset the RTC timer.
Also, the RTC timer can be used as a wakeup source. For details, see Section 9.4.4.
9.3.4 Regulators
ESP32-S2 has three regulators to regulate the power supply to different power domains:
Note:
For more detailed description about power domains, please refer to Section 9.4.2.
VDD3P3_CPU
VDD3P3_RTC_IO
dbias[2:0]
VREF +
Digital System
ESP32-S2
1. When XPD_DIG_REG == 1, the regulator outputs a 1.1 V voltage and the power domains in digital system
are able to run; when XPD_DIG_REG == 0, both the regulator and the power domains in digital system
stop running.
3. The current to power domains in digital system comes from pin VDD3P3_CPU and pin VDD3P3_RTC_IO.
VDD3P3_RTC_IO
dbias[2:0]
VREF +
1.1V
RTC
ESP32-S2
1. When the pin CHIP_PU is at a high level, the low-power voltage regulator cannot be turned off, but only
switching between normal-work mode and Deep-sleep mode.
3. The current to the RTC power domains comes from pin VDD3P3_RTC_IO.
VDD3P3_RTC_IO
drefh, drefm, dre:
tieh
VREF +
VDD_SPI
Regulator
Output
1uF 500pF
ESP32-S2
1. When XPD_SDIO_VREG == 1, the regulator outputs a voltage of 3.3 V or 1.8 V; when XPD_SDIO_VREG
== 0, the output is high-impedance. 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, and outputs a voltage of
3.3 V, which is the voltage of pin VDD3P3_RTC. When SDIO_TIEH == 0, the regulator outputs the
reference voltage VREF, which is typically 1.8 V.
3. DREFH_SDIO, DREFM_SDIO and DREFL_SDIO could be used to fine tune the reference voltage VREF, but
are not recommended because this fine tuning may jeopardize the stability of the inner loop.
4. When the regulator output is 3.3 V or 1.8 V, the output current comes from the pin VDD3P3_RTC_IO.
The flash voltage regulator can be configured via RTC registers or eFuse controller registers.
The brownout detector has ultra-low power consumption and remains enabled whenever the chip is powered up.
For the architecture of the ESP32-S2 brownout detector, see Figure 9-8.
ESP32-S2
thres[2:0]
VREF +
1. RTC_CNTL_RTC_BROWN_OUT_DET indicates the output level of brown-out detector. This register is low
level by default, and outputs high level when the voltage of the detected pin drops below the predefined
threshold;
2. I2C register ULP_CAL_REG5[2:0] configures the trigger threshold of the brown-out detector;
Note:
For more information regarding chip reset and system reset, please refer to 6 Reset and Clock.
• RTC
– RTC peripherals
• Digital
– Digital core
• Analog
– 8 MHz crystals
– 40 MHz crystals
– PLL
– RF circuits
Active
Monitor Sleep
Under different RTC states, different power domains are powered up or down by default, but can also be
force-powered-up (FPU) or force-powered-down (FPD) individually based on actual requirements. For details,
please refer to Table 64.
Note:
1. ESP32-S2’s power management unit is specially designed to be “always-on”, which means it is always on when
the chip is powered up. Therefore, users cannot FPU or FPD the power management unit.
2. The RTC peripherals include 1 ULP Coprocessor (ULP) and 32 On-Chip Sensor and Analog Signal Processing (i.e.
temperature sensor controller, touch sensor, SAR ADC controller).
3. RTC slow memory supports 8 KB SRAM, which can be used to reserve memory or to store ULP instructions and
/ or data. This memory can be accessed by CPU via PeriBUS2 (starting address is 0x50000000), and should be
force-power-on.
4. RTC fast memory supports 8 KB SRAM, which can be used to reserve memory. This memory can be accessed
by CPU via IRAM0 / DRAM0, and should be forced-power-up.
5. When the digital core of the digital system is powered down, all components in the digital system are turned off.
It’s worth noting that, ESP32-S2’s ROM and SRAM are no longer controlled as independent power domains, thus
cannot be force-powered-up or force-powered-down when the digital core is powered down.
6. Power domain Wi-Fi digital circuits includes Wi-Fi MAC and BB (Base Band).
Note:
* Configurable
By default, ESP32-S2 first enters the Active mode after system resets, then enters different low-power modes
(including Modem-sleep, Light-sleep, Deep-sleep, and Hibernation) to save power after the CPU stalls for a
specific time (For example, when CPU is waiting to be wakened up by an external event). From modes Active to
Hibernation, the performance1 and power consumption2 decreases and wakeup latency increases. Also, the
supported wakeup sources for different power modes are different3 . Users can choose a power mode based on
their requirements of performance, power consumption, wakeup latency, and available wakeup sources.
Note:
2. For details on power consumption, please refer to the Current Consumption Characteristics in ESP32-S2 Datasheet.
3. For details on the supported wakeup sources, please refer to Section 9.4.4.
Note:
1. EXT0 can only wake up the chip from Light-sleep / Deep-sleep modes. If RTC_CNTL_EXT_WAKEUP0_LV is 1,
it’s triggered when the pin level is high. Otherwise, it’s triggered when the pin level is low. Users can configure
RTCIO_EXT_WAKEUP0_SEL to select an RTC pin as a wakeup source.
2. EXT1 is especially designed to wake up the chip from any sleep modes, and can be triggered by a combina-
tion of pins. Users should define the combination of wakeup sources by configuring RTC_CNTL_EXT_WAKEUP1
_SEL[17:0] according to the bitmap of selected wakeup source. When RTC_CNTL_EXT_WAKEUP1_LV == 1, the
chip is waken up if any pin in the combination is high level. When RTC_CNTL_EXT_WAKEUP1_LV == 0, the chip
is only waken up if any pins in the combination is low level.
3. In Deep-sleep mode, only the RTC GPIOs (not regular GPIOs) can work as a wakeup source.
4. To wake up the chip with a Wi-Fi source, the chip switches between the Active, Modem-sleep, and Light-sleep
modes. The CPU and RF modules are woken up at predetermined intervals to keep Wi-Fi connections active.
5. A wakeup is triggered when the number of RX pulses received exceeds the setting in the threshold register.
6. A wakeup is triggered when any touch event is detected by the touch sensor.
8. When the 32 kHz crystal is working as RTC slow clock, a wakeup is triggered upon any detection of any crystal
stops by the 32 kHz watchdog timer.
9. A wakeup is triggered when the ULP co-processor starts capturing exceptions (e.g., stack overflow).
10. A wakeup is triggered when the USB host sends USB into the RESUMING state.
1. Set RTC_CNTL_PROCPU_STAT_VECTOR_SEL to 0.
3. After the CPU is powered up, the reset vector starts resetting from 0x50000000 instead of 0x40000400,
which does not involve any ROM unpacking and SPI booting. The codes stored in RTC slow memory
starts running immediately after the CPU reset. However, note that the content in the RTC slow memory
should be initialized before sending the chip into sleep.
1. Set RTC_CNTL_PROCPU_STAT_VECTOR_SEL to 1.
2. Calculate CRC for the RTC fast memory, and save the result in RTC_CNTL_STORE6_REG[31:0].
5. ROM unpacking and some of the initialization starts after the CPU is powered up. After that, calculate the
CRC for the RTC fast memory again. If the result matches with register RTC_CNTL_STORE6_REG[31:0],
the CPU jumps to the entry address.
Power up
Running in ROM
reset_vector@ reset_vector@
0x40000400 0x50000000
Initialization
Yes No
CRC right
Jump to entry
point in SPI Boot
RTC fast mem
Run code in
CPU RAM
When working under low-power modes, ESP32-S2’s 40 MHz crystal oscillator and PLL are usually powered
down to reduce power consumption. However, the low-power clock remains on so the chip can operate properly
under low-power modes.
9.8 Registers
The addresses in this section are relative to the Low Power Management base addresses provided in Section
9.6.
RS ST
C0
E_ OR
T
ed S C R C U
PR OR _P PD
U_
rv L_ _I2 FO OR _P
RC _N
) W_ _F CE E_
O CE U
U_ PD
se NT B C_ _F CE
CP
C NT B _I C U
C NT B _I _F D
FO E
T
RT _C L_B PLL OR E_P
RT _C L_B PLL 2C E_P
P_ RC
RS
CP _
(re _C L_B _I2 2C OR
O
RT _C L_B PLL CE U
RT _C L_B PLL OR D
PR
RA _FO
C NT B OR _P
C NT B _F _P
G RA ST
C NT B _F C
RT _C L_B _F CE
L_
_D W R
_W P
TL G_ YS_
AL
C NT TL OR
T
RT _C L_X _F
CN L_D _S
_S
C NT TL
C_ NT W
W
RT C L_S
_S
RT _C L_X
TL
C_ NT
C NT
)
)
ed
ed
CN
R T _C
R T _C
rv
rv
C_
se
se
C
C
RT
RT
RT
(re
(re
31 30 29 28 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 1 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_DG_WRAP_FORCE_RST Set this bit to force reset the digital system in deep-sleep.
(R/W)
RTC_CNTL_DG_WRAP_FORCE_NORST Set this bit to disable force reset to digital system in deep-
sleep. (R/W)
RTC_CNTL_SW_SYS_RST Set this bit to reset the system via SW. (WO)
T
O
O
_B
AD
O
NL
W
DO
E_
RC
O
_F
TL
)
ed
CN
rv
C_
se
RT
(re
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
RTC_CNTL_FORCE_DOWNLOAD_BOOT Set this bit to force the chip to boot from the download
mode. (R/W)
O
_L
L
_ VA
LP
_S
TL
CN
C_
RT
31 0
0x000000 Reset
RTC_CNTL_SLP_VAL_LO Sets the lower 32 bits of the trigger threshold for the RTC timer. (R/W)
I
N_
_H
AI
AL
_M
_V
TC
LP
_R
_S
TL
TL
)
ed
CN
CN
rv
C_
C_
se
RT
RT
(re
31 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
RTC_CNTL_SLP_VAL_HI Sets the higher 16 bits of the trigger threshold for the RTC timer. (R/W)
TE
LL
DA
ER TL ST
TA
YS FF
UP
IM _X _R
_S
_S _O
_T R S
E_
Y
IM
TL IM _S
_T
CN L_T ER
E
C d) TC
C_ T IM
RT rve L_R
RT _C L_T
se NT
C NT
d)
N
ve
(re _C
R T _C
er
C
s
RT
(re
31 30 29 28 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 0 0 0 0 Reset
RTC_CNTL_TIMER_SYS_STALL Selects the triggering condition for the RTC timer. (R/W)
RTC_CNTL_TIMER_XTL_OFF Selects the triggering condition for the RTC timer. (R/W)
RTC_CNTL_TIMER_SYS_RST Selects the triggering condition for the RTC timer. (R/W)
RTC_CNTL_RTC_TIME_UPDATE Selects the triggering condition for the RTC timer. (WO)
Note:
For details, please refer to Table 62.
31 0
0x000000 Reset
H
IG
_H
0
UE
AL
_V
ER
IM
_T
TC
_R
TL
d)
CN
ve
er
C_
s
RT
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
LR
_CE
US
CA
T_
NT
EC
_I
EJ
PU
P
T
EU
_R
EC
_C
N
AK
LP
_E
EJ
W
W
_S
_S
EP
_R
P_
TC
TC
LP
LE
SL
_R
_R
_S
_S
L_
TL
TL
TL
TL
T
)
ed
ed
CN
CN
CN
CN
CN
rv
rv
C_
C_
C_
C_
C_
se
se
RT
RT
RT
RT
RT
(re
(re
31 30 29 28 27 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
AI
EN
T
W
AI
AI
L_
_
T
W
_W
LL
AI
L
F_
TA
TA
_W
UF
BU
_S
_S
_B
M
L_
PU
U
K8
TL
CP
PL
_C
_C
_X
_
L_
TL
TL
TL
TL
T
CN
CN
CN
CN
CN
C_
C_
C_
C_
C_
RT
RT
RT
RT
RT
31 24 23 14 13 6 5 1 0
40 80 0x10 1 1 Reset
RTC_CNTL_CPU_STALL_WAIT Sets the CPU stall waiting cycles (using the RTC fast clock). (R/W)
RTC_CNTL_CK8M_WAIT Sets the 8 MHz clock waiting cycles (using the RTC slow clock). (R/W)
RTC_CNTL_XTL_BUF_WAIT Sets the XTAL waiting cycles (using the RTC slow clock). (R/W)
RTC_CNTL_PLL_BUF_WAIT Sets the PLL waiting cycles (using the RTC slow clock). (R/W)
AR
_O
ST
8M
H_
UC
CK
O
E_
_T
M
CP
TI
_
LP
IN
_M
_U
TL
TL
)
ed
CN
CN
rv
C_
C_
se
RT
RT
(re
31 24 23 15 14 0
RTC_CNTL_ULPCP_TOUCH_START_WAIT Sets the waiting cycles (using the RTC slow clock) be-
fore the ULP co-processor or touch controller starts to work. (R/W)
RTC_CNTL_MIN_TIME_CK8M_OFF Sets the minimal cycles for 8 MHz clock (using the RTC slow
clock) when powered down. (R/W)
AL
_V
LP
_S
IN
_M
TL
d)
)
ed
CN
ve
rv
er
C_
se
s
RT
(re
(re
31 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x80 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_MIN_SLP_VAL Sets the minimal sleep cycles (using the RTC slow clock). (R/W)
W
LO
1_
UE
AL
_V
ER
M
TI
TC_
_R
TL
CN
C_
RT
31 0
0x000000 Reset
CN
rv
C_
se
RT
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
RS CE U
EN D
H_ OR _P
T_ _P
CN L_S _I RC PU
_G _I FO PD
TC _F CE
C_ NT AR FO E_
TL AR 2C_ E_
LI 2C R
RT _C L_S LA_ RC
C NT L FO
RT _C L_P LA_
C NT L
RT _C L_P
C NT
d)
)
ed
ve
RT _C
rv
er
se
C
s
RT
(re
(re
31 25 24 23 22 21 20 19 0
0 0 0 0 0 0 0 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
RTC_CNTL_GLITCH_RST_EN Set this bit to enable a reset when the system detects a glitch. (R/W)
RC _PU
PD
E_
FO E
R_ RC
O O
AT _F
UL OR
AK
AK
LP
P
EG LAT
L
_S
_W
_S
_
AS
AS
P
_R U
AS
AS
CA
ed TC EG
BI
BI
BI
BI
_D
_D
_D
R R
_D
_D
L_ _
CK
(re NT RTC
TC
TC
IG
G
DI
_D
_R
_R
_S
C L_
L_
TL
TL
TL
TL
C_ NT
T
)
)
ed
CN
CN
CN
CN
CN
RT _C
rv
rv
C_
C_
C_
C_
C_
se
se
C
RT
RT
RT
RT
RT
RT
(re
31 30 29 28 27 25 24 22 21 14 13 11 10 8 7 0
1 0 0 0 4 4 0 4 4 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_DIG_DBIAS_SLP Configures the regulation factor for the digital system voltage regulator
when the CPU is in sleep state. (R/W)
RTC_CNTL_DIG_DBIAS_WAK Configures the regulation factor for the digital system voltage regula-
tor when the CPU is in active status. (R/W)
RTC_CNTL_RTC_DBIAS_SLP Configures the regulation factor for the low-power voltage regulator
when the CPU is in sleep status. (R/W)
RTC_CNTL_RTC_DBIAS_WAK Configures the regulation factor for the low-power voltage regulator
when the CPU is in active status. (R/W)
O
IS
PU
PD
IS
RC O
PU
NO
PU
D
TM _FO _PU
PD
SO
PU
NO
S
U
LP
_L
_L
_I
_C
_P
_P
AS M_F E_L
E_
E_
_I
_C
EM RCE
EM RCE
EM RCE
EM RCE
E_
E_
LD
EM _EN
EM RCE
EM CE
EM RCE
LW
RC
EN
LW
C
RC
RC
HO
R
D
D_
O
O
O
O
RC _FO
O
_P
E_
_F
_F
_F
_F
_F
_F
IS
_P
_F
_F
AS M_F
AS M_F
_F
O
NO
EM
EM
PU
PD
RC
SL _IS
M
EM
M
E_
E_
E_
E
E
O
M
E
M
TM
TM
TM
TM
N
_F
W
RC
RC
RC
E
ST
ST
LO
LO
LO
LO
LO
AD
D_
AS
AS
AS
O
FO
O
SL
SL
FA
A
_P
_P
_S
_S
_S
_S
_S
_F
_F
_F
_F
_F
_F
_F
_F
_F
_F
_
C_
C_
C_
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
TC
T
T
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
_R
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
TL
)
ed
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
CN
rv
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
C_
se
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
RT
(re
31 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 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 1 Reset
RTC_CNTL_RTC_FASTMEM_FORCE_NOISO Set this bit to disable the force isolation of the RTC
fast memory. (R/W)
RTC_CNTL_RTC_FASTMEM_FORCE_ISO Set this bit to force isolation of the RTC fast memory.
(R/W)
RTC_CNTL_RTC_SLOWMEM_FORCE_NOISO Set this bit to disable the force isolation of the RTC
slow memory. (R/W)
RTC_CNTL_RTC_SLOWMEM_FORCE_ISO Set this bit to force isolation of the RTC slow memory.
(R/W)
RTC_CNTL_RTC_FORCE_ISO Set this bit to force isolation of the RTC peripherals. (R/W)
RTC_CNTL_RTC_FORCE_NOISO Set this bit to disable the force isolation of the RTC peripherals.
(R/W)
RTC_CNTL_RTC_FASTMEM_FOLW_CPU Set this bit to FPD the RTC fast memory when the CPU
is powered down. Reset this bit to FPD the RTC fast memory when the RTC main state machine
is powered down. (R/W)
RTC_CNTL_RTC_FASTMEM_FORCE_LPD Set this bit to force not retain the RTC fast memory.
(R/W)
RTC_CNTL_RTC_FASTMEM_FORCE_LPU Set this bit to force retain the RTC fast memory. (R/W)
RTC_CNTL_RTC_SLOWMEM_FOLW_CPU Set this bit to FPD the RTC slow memory when the CPU
is powered down. Reset this bit to FPD the RTC slow memory when the RTC main state machine
is powered down. (R/W)
RTC_CNTL_RTC_SLOWMEM_FORCE_LPD Set this bit to force not retain the RTC slow memory.
(R/W)
RTC_CNTL_RTC_SLOWMEM_FORCE_LPU Set this bit to force retain the RTC slow memory. (R/W)
RTC_CNTL_RTC_FASTMEM_FORCE_PD Set this bit to FPD the RTC fast memory. (R/W)
RTC_CNTL_RTC_FASTMEM_FORCE_PU Set this bit to FPU the RTC fast memory. (R/W)
RTC_CNTL_RTC_FASTMEM_PD_EN Set this bit to enable PD for the RTC fast memory in sleep.
(R/W)
RTC_CNTL_RTC_SLOWMEM_FORCE_PD Set this bit to FPD the RTC slow memory. (R/W)
RTC_CNTL_RTC_SLOWMEM_FORCE_PU Set this bit to FPU the RTC slow memory. (R/W)
RTC_CNTL_RTC_SLOWMEM_PD_EN Set this bit to enable PD for the RTC slow memory in sleep.
(R/W)
RTC_CNTL_RTC_PD_EN Set this bit to enable PD for the RTC peripherals in sleep. (R/W)
RTC_CNTL_RTC_PAD_FORCE_HOLD Set this bit the force hold the RTC GPIOs. (R/W)
RC PU
PD
I_ C RC PU
D
RC _PU E_P
O E_
E_
IF OR FO E_
N EN
_F RC
_W I_F P_ RC
PD
_E D_
EM O
TL IF RA FO
E_
M _F
PD P
FO E
I_ P_
CN L_W _W P_
P_ M
SL ME
IF RA
C_ NT G RA
_L P_
_W W
RT _C L_D _W
TL G_
TL SL
C NT G
CN L_D
RT _C L_D
CN L_L
C_ T
C NT
C_ NT
)
se d)
se d)
C d)
)
ed
ed
ed
RT _CN
(re rve
(re rve
RT rve
RT _C
RT _C
rv
rv
rv
se
se
se
se
C
C
RT
RT
(re
(re
(re
(re
31 30 29 24 23 22 21 20 19 18 17 16 5 4 3 2 0
0 0 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 1 0 0 0 0 Reset
RTC_CNTL_LSLP_MEM_FORCE_PD Set this bit to FPD the memories in the digital system in sleep.
(R/W)
RTC_CNTL_LSLP_MEM_FORCE_PU Set this bit to FPU the memories in the digital system. (R/W)
RTC_CNTL_WIFI_FORCE_PD Set this bit to FPD the Wi-Fi digital circuit in the digital system. (R/W)
RTC_CNTL_WIFI_FORCE_PU Set this bit to FPU the Wi-Fi digital circuit in the digital system. (R/W)
RTC_CNTL_WIFI_PD_EN Set this bit to enable PD for the Wi-Fi digital circuit in sleep. (R/W)
RTC_CNTL_DG_WRAP_PD_EN Set this bit to enable PD for the digital system in sleep. (R/W)
_D _D AU E O D
RC _N E_IS ISO
LD LD
TL LR D_ RC _IS OL
O O N
AD AD O ISO
HO HO
C_ NT G D R _U D
UT UT _E
E_ OIS O
O
_A _A LD
_P _P H O
IS O
IF OR FO E_
C NT G D R _H
G G T O _N
_W I_F P_ RC
C NT G D R
FO E
C NT G D
RT _C L_D _PA
RT _C L_D _W
C NT G
C NT G
RT _C L_D
RT C L_D
C NT
C_ NT
d)
)
ed
ve
R T _C
R T _C
rv
er
se
C
C
s
RT
RT
(re
(re
31 30 29 28 27 16 15 14 13 12 11 10 9 8 0
1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_CLR_DG_PAD_AUTOHOLD Set this bit to clear the auto-hold enabler for the digital
GPIOs. (WO)
RTC_CNTL_DG_PAD_AUTOHOLD_EN Set this bit to allow the digital GPIOs to enter the auto-hold
status. (R/W)
RTC_CNTL_DG_PAD_FORCE_NOISO Set this bit to disable the force isolation of the digital GPIOs.
(R/W)
RTC_CNTL_DG_PAD_FORCE_ISO Set this bit to force isolation of the digital GPIOs. (R/W)
RTC_CNTL_DG_PAD_FORCE_UNHOLD Set this bit the force unhold the digital GPIOs. (R/W)
RTC_CNTL_DG_PAD_FORCE_HOLD Set this bit the force hold the digital GPIOs. (R/W)
RTC_CNTL_WIFI_FORCE_ISO Set this bit to force isolation of the Wi-Fi digital circuits. (R/W)
RTC_CNTL_WIFI_FORCE_NOISO Set this bit to disable the force isolation of the Wi-Fi digital circuits.
(R/W)
RTC_CNTL_DG_WRAP_FORCE_ISO Set this bit to force isolation of the digital system. (R/W)
RTC_CNTL_DG_WRAP_FORCE_NOISO Set this bit to disable the force isolation of the digital sys-
tem. (R/W)
EL
P
ID
EU
N_
AK
_I
W
E
AT
R_
ST
O
_F
N_
DY
AI
M
_R
L_
TL
NT
)
d)
)
ed
ed
CN
ve
C
rv
rv
r
C_
C_
se
se
se
RT
RT
(re
(re
(re
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.
– entering sleep modes. In this case, wait until RTC_CNTL_RDY_FOR_WAKEUP bit is set,
then you can wake up the chip.
U
CP
T O
RO
EC
_P
_V
AT
SE
ST
AU
U_
_C
CP
ET
RO
ES
_R
_P
TL
TL
)
)
ed
d
CN
CN
ve
rv
r
C_
C_
se
se
RT
RT
(re
(re
31 14 13 12 6 5 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
A
EN
P_
EU
AK
W_
R TC
L_
NT
)
ed
C
rv
C_
se
RT
(re
31 15 14 0
12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_RTC_WAKEUP_ENA Selects the wakeup source. For details, please refer to Table 66.
(R/W)
)
ed
RT _C
rv
se
C
RT
(re
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
RTC_CNTL_GPIO_WAKEUP_FILTER Set this bit to enable the GPIO wakeup event filter. (R/W)
A
EN
EN
EC EN
T_
T_
EJ T_
C
_R EC
JE
E
LP EJ
_R
_S _R
EP
HT P
LE
IG SL
S
_L P_
C_
TL EE
T
CN L_D
_R
TL
C_ NT
)
ed
CN
RT _C
rv
C_
se
C
RT
RT
(re
31 30 29 13 12 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EL
TA
_S
_S
P1
P1
EU
EU
AK
AK
W
_W
T_
XT
X
_E
_E
TL
TL
d)
CN
CN
e
rv
C_
C_
se
RT
RT
(re
31 23 22 21 0
0 0 0 0 0 0 0 0 0 0 0 Reset
CN
ve
r
C_
se
RT
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0 Reset
E
US
CA
T_
EC
EJ
_R
TL
)
ed
CN
rv
C_
se
RT
31 (re 17 16 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
US
CA
P_
EU
AK
_W
TL
)
ed
CN
rv
C_
se
RT
(re
31 17 16 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
0
0
0
0
Espressif Systems
0
(re
s
0
er
ve
0
d)
0
19
RT
C
0
18
RT _C
C_ NT
0
17
RT C L_R
C NT T
0
16
RT _C L_R C_G
C NT T L
0
15
297
0
14
RT _C L_R C_C UC DE
C NT T O H_ T_
0
13
RT _C L_R C_S L3 TR OU NA
C NT T W 2K AP T_
0
11
RT C L_R _B IN_ 1_ A
RTC_CNTL_RTC_WDT_INT_ENA Enables the RTC watchdog interrupt. (R/W)
Register 9.28: RTC_CNTL_INT_ENA_RTC_REG (0x0040)
C NT T R TI INT
5
RT _C L_R C_T OW ME _E
C NT T O N R_ NA
4
C NT T O H_ T _E
3
RT _C _W C IN _IN _E NA
C_ NT
L DT H_S T_E T_ NA
RTC_CNTL_RTC_TOUCH_SCAN_DONE_INT_ENA Enables interrupts upon the completion of a
RTC_CNTL_SLP_REJECT_INT_ENA Enables interrupts when the chip rejects to go to sleep. (R/W)
RTC_CNTL_SLP_WAKEUP_INT_ENA Enables interrupts when the chip wakes up from sleep. (R/W)
CN _S _I CA NA EN
TL LP NT N A
0 Reset
_S _R _ E _D
LP EJ NA O
AW
_R
_W C IN _IN _R AW
RT _C L_R C_C RA T_R D_ _RA AW
DT H_S T_R T_ AW
AW
NT
W
C d) TC OU P_ NE INT _R
C NT T A IN EA T _R
C NT T O DC AW INT W
se NT T L H_ TI E_ W
_I
RT _C L_R C_S L3 TR OU AW
_I CA AW RA
_R
NE
C T T A _ _R W
C NT T O N R_ AW
C T T TA U_ E _R
C NT T O H_ T _R
C NT T O H_ C T_
W
C NT T W 2K AP T_
AW O
A
IN W
RT _C L_R C_M RA INT AW
RT _C L_R C_B IN_ 1_ AW
RT _CN L_R C_X CP TIM INT
_R _D
RA
RT C _R _S NS INT _R
RT _C L_R C_T OW ME _R
A
P_ _R
NT N
C_ NT TC SE U_ INT
C NT T R TI INT
T_
C NT T O H_ T_
C NT T A DC _R
EU INT
RT _C L_R C_C UC DE
RT _C L_R C_T CP 2_
AK T_
C NT T O H_
_W EC
RT _C L_R C_T ITC
LP EJ
C NT T L
RT _C L_R C_G
_S _R
TL LP
C NT T
RT C L_R
CN _S
L
L
C_ NT
C_ NT
d)
N
ve
RT _C
RT _C
er
C
s
RT
(re
31 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
RTC_CNTL_SLP_WAKEUP_INT_RAW Stores the raw interrupt triggered when the chip wakes up
from sleep. (RO)
RTC_CNTL_SLP_REJECT_INT_RAW Stores the raw interrupt triggered when the chip rejects to go
to sleep. (RO)
T
_S
_W C IN _IN _S T
NT
RT _C L_R C_C RA T_S D_ _ST T
C d) TC OU P_ NE INT _S
C NT T A IN EA T _S
DT H_S T_S T_ T
T
_I
_I CA T ST
_S
NE
RT _C L_R C_S L3 TR OU T
C NT T O H_ T _S
C NT T O H_ C T_
se NT T L H_ TI E_
C NT T W 2K AP T_
T O
T
C NT T O N R_ T
RT _C L_R C_X CP TIM INT
_ S _D
RT C _R _S NS INT _S
RT _C L_R C_T OW ME _S
ST
T
RT _C L_R C_M RA INT T
RT _C L_R C_B IN_ 1_ T
P_ _S
C T T A _ _S
NT N
C_ NT TC SE U_ INT
C NT T R TI INT
T_
C NT T O H_ T_
C NT T A DC _S
EU INT
IN
RT _C L_R C_C UC DE
RT _C L_R C_T CP 2_
AK T_
C NT T O H_
_W C
RT _C L_R C_T ITC
E
LP EJ
C NT T L
RT _C L_R C_G
_S _R
TL LP
C NT T
RT C L_R
CN _S
L
L
C_ NT
C_ NT
)
ed
N
RT _C
RT _C
rv
se
C
RT
(re
31 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
RTC_CNTL_SLP_WAKEUP_INT_ST Stores the status of the interrupt triggered when the chip wakes
up from sleep. (RO)
RTC_CNTL_SLP_REJECT_INT_ST Stores the status of the interrupt triggered when the chip rejects
to go to sleep. (RO)
RTC_CNTL_RTC_TOUCH_DONE_INT_ST Stores the status of the interrupt triggered upon the com-
pletion of a single touch. (RO)
RTC_CNTL_RTC_MAIN_TIMER_INT_ST Stores the status of the RTC main timer interrupt. (RO)
RTC_CNTL_RTC_COCPU_TRAP_INT_ST Stores the status of the interrupt triggered when the ULP-
RISCV is trapped. (RO)
LR
_C
_W C IN _IN _C LR
RT _C L_R C_C RA T_C D_ _CL LR
NT
DT H_S T_C T_ LR
LR
C d) TC OU P_ NE INT _C
C NT T A IN EA T _C
R
C NT T O DC LR INT R
se NT T L H_ TI E_ R
_I
_I CA LR CL
_C
RT _C L_R C_S L3 TR OU LR
NE
C NT T TA U_ E _C
C NT T O H_ T _C
C T T A _ _C R
C NT T O N R_ LR
C NT T O H_ C T_
C NT T W 2K AP T_
LR O
R
L
IN R
RT _C L_R C_M RA INT LR
RT _C L_R C_X CP TIM INT
_ C _D
RT C _R _S NS INT _C
RT _C L_R C_T OW ME _C
CL
RT C L_R _B IN_ 1_ LR
L
P_ _C
NT N
C_ NT TC SE U_ INT
C NT T R TI INT
T_
C NT T O H_ T_
C_ NT TC A DC _C
EU INT
RT _C L_R C_C UC DE
RT _C L_R C_T CP 2_
AK T_
C NT T O H_
_W EC
RT _C L_R C_T ITC
LP EJ
C NT T L
RT _C L_R C_G
_S _R
TL LP
C NT T
RT C L_R
CN _S
L
L
C_ NT
C_ NT
d)
N
ve
RT _C
RT _C
er
C
s
RT
(re
31 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
RTC_CNTL_SLP_WAKEUP_INT_CLR Clears the interrupt triggered when the chip wakes up from
sleep. (WO)
H0
TC
RA
SC
C_
T
_R
TL
CN
C_
RT
31 0
0 Reset
31 0
0 Reset
2
CH
AT
CR
_S
TC
R
T L_
CN
C_
RT
31 0
0 Reset
H3
TC
C RA
_S
TC
_R
TL
CN
C_
RT
31 0
0 Reset
31 0
0 Reset
5
CH
AT
CR
_S
TC
R
T L_
CN
C_
RT
31 0
0 Reset
H6
TC
C RA
_S
TC
_R
TL
CN
C_
RT
31 0
0 Reset
31 0
0 Reset
_X L3 _W CL CK T
TA 2K DT K UP
EL
C_ NT TA 2K UT RE RN
TL TA 2K XT_ BA AR
N O
_S
L3 _W _R _FO
DT CLK T
RT _C L_X L3 _A O_ CE
RT _C L_X L3 _A O_ TU
_E _F
CN L_X L3 _E O_ ST
_W T_ SE
RT _C L_X L3 _A _FO K
O
C NT TA 2K UT RE
C NT TA 2K UT R
C NT TA 2K PD 32
PI
2K D E
TR N
TE
V
_G
RT _C L_X L3 _X L_
_C _E
_L
TA
C NT TA 2K TA
2K
XT TR
_S
RT _C L_X L3 IT_X
L3
_E _C
DT
TA
TL XT
C NT TA IN
_W
_X
_X _E
RT _C L_X CK
TC
TC
TL TL
C NT N
_R
_R
RT C L_E
CN L_X
TL
TL
C_ NT
C_ NT
)
d)
ed
CN
CN
ve
R T _C
R T _C
rv
er
C_
C_
se
C
C
s
RT
RT
RT
RT
(re
(re
31 30 29 24 23 22 20 19 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0x0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Reset
RTC_CNTL_XTAL32K_WDT_EN Set this bit to enable the 32 kHz crystal watchdog. (R/W)
RTC_CNTL_XTAL32K_WDT_CLK_FO Set this bit to FPU the 32 kHz crystal watchdog clock. (R/W)
RTC_CNTL_XTAL32K_WDT_RESET Set this bit to reset the 32 kHz crystal watchdog by SW. (R/W)
RTC_CNTL_XTAL32K_EXT_CLK_FO Set this bit to FPU the external clock of 32 kHz crystal. (R/W)
RTC_CNTL_XTAL32K_AUTO_BACKUP Set this bit to switch to the backup clock when the 32 kHz
crystal is dead. (R/W)
RTC_CNTL_XTAL32K_AUTO_RESTART Set this bit to restart the 32 kHz crystal automatically when
the 32 kHz crystal is dead. (R/W)
RTC_CNTL_XTAL32K_AUTO_RETURN Set this bit to switch back to 32 kHz crystal when the 32
kHz crystal is restarted. (R/W)
RTC_CNTL_XTAL32K_XPD_FORCE Set this bit to allow the software to FPD the 32 kHz crystal;
Reset this bit to allow the FSM to FPD the 32 kHz crystal. (R/W)
RTC_CNTL_ENCKINIT_XTAL_32K Set this bit to apply an internal clock to help the 32 kHz crystal
to start. (R/W)
RTC_CNTL_XTL_EXT_CTR_LV 0: powers down XTAL at high level; 1: powers down XTAL at low
level. (R/W)
RTC_CNTL_XTL_EXT_CTR_EN Enables the GPIO to power down the crystal oscillator. (R/W)
AT G
G
G TIN
IN
_ 8M EN EN
NO A
EL
LD
E_ OG
_R EL
NB K K_ 6_
RC PU
PD
_S
_V
LK _S
C_ L_E _C L32 25
RC E_N
C L_ _X 8M N
M IV
TC
EL
O E_
E_
_C TC
RT NT ENB TA _D
C_ NT IG LK _E
SE
_C CK8 _D
_F C
FO C
_S
ST _R
RT _C L_D _C 8M
_
M R
L_ OR
K8 IV
IV
K8 _FO
_F CLK
DI
C NT IG LK
_D
TA _F
TL 8M_
RT C L_D _C
_C M
_X M
M
_
NA
TL K8
TL K8
K8
C_ NT IG
K
A
CN L_C
CN L_C
_C
_C
R T C _D
C_ L_A
TL
L
T
(re NT
C_ T
C_ NT
C_ NT
RT NT
)
C_ )
)
ed
ed
ed
CN
CN
CN
RT rve
C
RT C
RT _C
RT C
C
rv
rv
rv
C_
C_
C_
C_
se
se
se
se
C
RT
RT
RT
RT
RT
(re
(re
(re
31 30 29 28 27 26 25 24 17 16 15 14 12 11 10 9 8 7 6 5 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 1 0 0 0 1 1 0 0 0 Reset
RTC_CNTL_CK8M_DIV Set the CK8M_D256_OUT divider. 00: divided by 128, 01: divided by 256,
10: divided by 512, 11: divided by 1024. (R/W)
RTC_CNTL_DIG_XTAL32K_EN Set this bit to enable CK_XTAL_32K clock for the digital core. (R/W)
RTC_CNTL_DIG_CLK8M_D256_EN Set this bit to enable CK8M_D256_OUT clock for the digital
core. (R/W)
RTC_CNTL_DIG_CLK8M_EN Set this bit to enable 8 MHz clock for the digital core. (R/W)
RTC_CNTL_XTAL_FORCE_NOGATING Set this bit to force no gating to crystal during sleep. (R/W)
RTC_CNTL_CK8M_FORCE_NOGATING Set this bit to disable force gating to 8 MHz crystal during
sleep. (R/W)
RTC_CNTL_FAST_CLK_RTC_SEL Set this bit to select the RTC fast clock. 0: XTAL_DIV_CLK, 1:
RC_FAST_CLK. (R/W)
RTC_CNTL_ANA_CLK_RTC_SEL Set this bit to select the RTC slow clock. 0: RC_SLOW_CLK, 1:
XTAL32K_CLK, 2: RC_FAST_DIV_CLK. (R/W)
D
VL
_
V
IV
DI
_D
K_
LK
CL
_C
A_
NA
AN
A
C_
C_
RT
RT
_
_
TL
TL
d)
)
ed
CN
CN
ve
rv
er
C_
C_
se
s
RT
RT
(re
(re
31 30 23 22 21 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 Reset
R
C TO
FA
K_
CL
K_
2
L3
TA
_X
TL
CN
C_
RT
31 0
0x000000 Reset
RTC_CNTL_XTAL32K_CLK_FACTOR Configures the divider factor for the 32 kHz crystal oscillator.
(R/W)
ES
T
UT
T
AI
AI
HR
W
EO
W
T_
_T
N_
IM
R
LE
_T
UR
TA
AB
DT
T
RE
RE
ST
W
K_
K_
K_
K_
32
32
L3
L3
AL
L
TA
TA
TA
XT
_X
_X
_X
_
TL
TL
TL
NT
CN
CN
CN
C
C_
C_
C_
C_
RT
RT
RT
RT
31 28 27 20 19 4 3 0
RTC_CNTL_XTAL32K_RESTART_WAIT Defines the waiting cycles before restarting the 32 kHz crys-
tal oscillator. (R/W)
T_ EN
TH
TH
EN
SE D_
G
G
EN
RE O
EN
U_ _M
LP
_L
_L
_S
ET
ET
CP O
N
RO O
ES
_I
HB
RE
_R
SE
0
S_
T_ S
PU
TG
TG
TG
TG
AU
C_ d) D FLA
N
SY
_C
_S
_S
_S
_S
_P
_E
RT e _W _
DT
DT
DT
DT
DT
DT
DT
DT
se NT D
_W
_W
_W
_W
_W
_W
_W
(re C L_W
_W
TL
TL
TL
TL
TL
TL
TL
TL
C_ NT
)
ed
CN
CN
CN
CN
CN
CN
CN
CN
RT C
rv
r
C_
C_
C_
C_
C_
C_
C_
C_
se
RT
RT
RT
RT
RT
RT
RT
RT
(re
31 30 28 27 25 24 22 21 19 18 16 15 13 12 11 10 9 8 0
RTC_CNTL_WDT_PROCPU_RESET_EN Set this bit to allow the watchdog to be able to reset CPU.
(R/W)
RTC_CNTL_WDT_FLASHBOOT_MOD_EN Set this bit to enable watchdog when the chip boots
from flash. (R/W)
RTC_CNTL_WDT_STG3 1: enable at the interrupt stage, 2: enable at the CPU stage, 3: enable at
the system stage, 4: enable at the system and RTC stage. (R/W)
RTC_CNTL_WDT_STG2 1: enable at the interrupt stage, 2: enable at the CPU stage, 3: enable at
the system stage, 4: enable at the system and RTC stage. (R/W)
RTC_CNTL_WDT_STG1 1: enable at the interrupt stage, 2: enable at the CPU stage, 3: enable at
the system stage, 4: enable at the system and RTC stage. (R/W)
RTC_CNTL_WDT_STG0 1: enable at the interrupt stage, 2: enable at the CPU stage, 3: enable at
the system stage, 4: enable at the system and RTC stage. (R/W)
Note:
For details, please refer to Chapter 13 XTAL32K Watchdog Timer (XTWDT).
LD
HO
0_
G
ST
_
DT
W
TL_
CN
C_
RT
31 0
200000 Reset
LD
HO
1_
TG
_S
DT
_W
TL
CN
C_
RT
31 0
80000 Reset
31 0
0x000fff Reset
LD
HO
3_
G
_ ST
DT
W
T L_
CN
C_
RT
31 0
0x000fff Reset
d)
CN
e
rv
C_
se
RT
(re
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
0x50d83aa1 Reset
EN
LR
TH
W FE LE D_
_C
G
ID
A
W
_S _ AB E
AG
FL
SE T
TL WD DIS _FE
L_
RE _IN
T_
FL
NA
CN L_S D_ TO
D_ ED
D_ ED
T_
G
C_ NT W AU
RS
W FE
SI
RT _C L_S D_
D_
_S _
TL WD
C NT W
W
RT C L_S
_S
CN L_S
TL
C_ NT
C_ NT
)
ed
CN
R T _C
RT _C
rv
C_
se
C
C
RT
RT
RT
(re
31 30 29 28 27 18 17 2 1 0
0 0 0 0 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_SWD_FEED_INT Receiving this interrupt leads to feeding the super watchdog via SW.
(RO)
RTC_CNTL_SWD_SIGNAL_WIDTH Adjusts the signal width sent to the super watchdog. (R/W)
RTC_CNTL_SWD_AUTO_FEED_EN Set this bit to enable automatic watchdog feeding upon inter-
rupts. (R/W)
31 0
0x8f1d312a Reset
RTC_CNTL_SWD_WKEY Sets the write protection key of the super watchdog. (R/W)
C1
U_
CP
O
PR
L L_
TA
_S
W
_S
TL
)
ed
CN
rv
C_
se
RT
(re
31 26 25 0
0 0 0 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 _C L_T UC PA 3_H LD
RT _C L_T UC PA 2_H LD
RT _C L_T UC PA 1_H LD
RT _C L_T UC PA 0_H LD
RT _C L_T UC PA _H LD
RT _C L_T UC PA _H D
RT _C L_T UC PA _H D
RT _C L_T UC PA _H D
RT _C L_T UC PA _H D
CN L_T C PA _H D
TL OU H_P D3_ OLD
UC P _H D
PA _H LD
_H LD
LD
C NT O H_ D1 O
C NT O H_ D1 O
C NT O H_ D1 O
C NT O H_ D1 O
C NT O H_ D9 O
C NT O H_ D8 OL
C NT O H_ D7 OL
C NT O H_ D6 OL
C NT O H_ D5 OL
C_ NT OU H_ D4 OL
O H_ D2 OL
C NT D A _H D
C NT D 2_ _H D
C NT 32 1_ LD D
H_ AD1 O
D0 O
O
RT _C L_T UC PA 4_H
RT _C L_P C_P D20 OL
RT _C L_P AC D19 OL
RT _C L_X AC HO OL
_T C A H
C NT T A _H
C T 32 H LD
C NT O H_ D1
RT _C L_T P_ OLD
RT _C L_T UC LD
RT _C L_R C_P D21
RT _CN L_X N_ HO
RT _C L_T UC PA
C NT O HO
C NT O H_
C NT T A
RT _C L_R C_P
C NT T
RT _C L_R
C NT
d)
ve
R T _C
er
C
s
RT
(re
31 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
LD
O
_H
AD
_P
G
DI
T L_
CN
C_
RT
31 0
0 Reset
RTC_CNTL_DIG_PAD_HOLD Set GPIO 21 to GPIO 45 to the holding state. (See bitmap to locate
any GPIO). (R/W)
NA
_E
SH
SE NA
LA
T
LR
NA
T
UT A ET
_F
ST EL
LO _E
AI
AI
_W
_C
O _EN _D
_ C RF
_R _S
_E
_W
A
NT
N_ T T
UT ST
ST
EN
UT _
NT
W OU OU
O _PD
_C
O R
_R
2_
_I
_
C d) RO N_ N_
N_ T
UT
N_ T
UT
UT
W OU
W OU
RT rve L_B OW OW
O
RO N_
N_
RO N_
N_
N_
se NT R R
(re _C L_B C_B
_B W
_B W
W
TL RO
RO
TL RO
RO
RO
C NT T
RT C L_R
CN _B
_B
CN _B
_B
_B
L
TL
TL
TL
C_ NT
C_ NT
C_ T
)
ed
CN
CN
CN
RT _C
R T _C
RT C
rv
C_
C_
C_
C_
se
C
RT
RT
RT
RT
RT
(re
31 30 29 28 27 26 25 16 15 14 13 4 3 1 0
RTC_CNTL_BROWN_OUT_RST_WAIT Configures the waiting cycles before the reset after a brown-
out. (R/W)
10.1 Overview
System timer is a 64-bit timer specially for operating system. It can be used to schedule operating system tasks
by generating periodical system ticks or certain time delay interrupts. With the help of RTC timer, system timer
can keep updated after Light-sleep or Deep-sleep.
• Timer value increment step can be configured for each APB_CLK cycle.
• Support automatic time compensation in case of APB_CLK clock source switching between PLL_CLK and
XTAL_CLK, to improve timer accuracy.
• Generate three independent interrupts based on different alarm values or periods (targets).
• Load back sleep time recorded by RTC timer after Deep-sleep or Light-sleep by software.
Figure 10-1 shows the structure of system timer. The system timer can be enabled by setting the bit
SYSTEM_SYSTIMER_CLK_EN in register SYSTEM_PERIP_CLK_EN0_REG and be reset via software by setting
the bit SYSTEM_SYSTIMER_RST in register SYSTEM_PERIP_RST_EN0_REG. For more information, please refer
to Table 89 Peripheral Clock Gating and Reset Bits in Chapter 15 System Registers (SYSTEM).
2. Wait till SYSTIMER_TIMER_VALUE_VALID is set, which means users now can read the timer values from
registers.
3. Read the high 32 bits of the timer value from SYSTIMER_TIMER_VALUE_HI, and the low 32 bits from
SYSTIMER_TIMER_VALUE_LO.
3. Write the high 32 bits of the target (alarm value) to SYSTIMER_TIMER_TARGETx_HI, and the low 32 bits to
SYSTIMER_TIMER_TARGETx_LO.
5. Set SYSTIMER_INTx_ENA to enable timer interrupt. When the timer counts to the alarm value, an interrupt
will be triggered.
4. Set SYSTIMER_INTx_ENA to enable timer interrupt. An interrupt will be triggered when the timer counts to
the target value set in Step 2.
2. Read the sleep time from RTC timer when the chip is woken up from Deep-sleep or Light-sleep.
3. Read current value of the system timer. See Section 10.4.1 for how to read the timer value.
4. Add current value of the system timer to the time that RTC timer records in Deep-sleep mode or in
Light-sleep mode.
5. Write the result into SYSTIMER_TIMER_LOAD_HI (high 32 bits), and into SYSTIMER_TIMER_LOAD_LO
(low 32 bits).
Memory.
10.7 Registers
Register 10.1: SYSTIMER_CONF_REG (0x0000)
O
_E
_F
LK
LK
_C
_C
ER
ER
d)
IM
IM
ve
er
ST
ST
s
SY
SY
(re
31 30 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
d)
IM
e
rv
ST
se
SY
(re
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
0 Reset
SYSTIMER_TIMER_LOAD_HI The value to be loaded into system timer, high 32 bits. (R/W)
O
_L
AD
O
_L
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
SYSTIMER_TIMER_LOAD_LO The value to be loaded into system timer, low 32 bits. (R/W)
P
P
TE
TE
S
_S
L_
LL
TA
_P
_X
ER
ER
IM
IM
_T
_T
ER
ER
d)
IM
IM
ve
r
ST
ST
se
SY
SY
(re
31 20 19 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 1 80 Reset
SYSTIMER_TIMER_XTAL_STEP Set system timer increment step when using XTAL_CLK. (R/W)
SYSTIMER_TIMER_PLL_STEP Set system timer increment step when using PLL_CLK. (R/W)
31 0
0 Reset
LO
0_
ET
G
AR
_T
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
HI
1_
ET
G
AR
_T
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
31 0
0 Reset
HI
2_
ET
G
AR
_T
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
LO
2_
ET
G
AR
_T
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
D
PE K_
O
O
0_ R
RI
ET O
PE
G 0_W
0_
AR T
ET
_T GE
G
ER AR
AR
IM _T
_T
ST ER
ER
SY TIM
IM
ST
S
SY
SY
31 30 29 0
0 0 0x000000 Reset
SYSTIMER_TARGET0_PERIOD Set alarm period for system timer target 0, only valid in periodic
alarms mode. (R/W)
SYSTIMER_TARGET0_PERIOD_MODE Set work mode for system timer target 0. 0: work in a time-
delay alarm mode; 1: work in periodic alarms mode. (R/W)
DE
O
M
RI EN
D_
D
PE K_
O
O
1_ R
RI
ET O
PE
G 1_W
1_
AR T
ET
_T GE
G
ER AR
AR
IM _T
_T
ST ER
ER
SY TIM
IM
ST
S
SY
SY
31 30 29 0
0 0 0x000000 Reset
SYSTIMER_TARGET1_PERIOD Set alarm period for system timer target 1, only valid in periodic
alarms mode. (R/W)
SYSTIMER_TARGET1_PERIOD_MODE Set work mode for system timer target 1. 0: work in a time-
delay alarm mode; 1: work in periodic alarms mode. (R/W)
D
PE K_
O
O
2_ R
RI
ET O
PE
G 2_W
2_
AR T
ET
_T GE
G
ER AR
AR
IM _T
_T
ST ER
ER
SY TIM
IM
ST
S
SY
SY
31 30 29 0
0 0 0x000000 Reset
SYSTIMER_TARGET2_PERIOD Set alarm period for sytem timer target 2, only valid in periodic
alarms mode. (R/W)
SYSTIMER_TARGET2_PERIOD_MODE Set work mode for system timer target 2. 0: work in a time-
delay alarm mode; 1: work in periodic alarms mode. (R/W)
D
A LI
_V
AL E
_V AT
UE
ER PD
IM _U
_T ER
ER IM
IM _T
ST ER
d)
SY TIM
ve
r
se
S
SY
(re
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
SYSTIMER_TIMER_VALUE_VALID Check if it is valid to read out timer value from registers. 0: Not
ready to read timer value from registers; 1: Ready to read timer value from registers. (RO)
I
_H
UE
AL
_V
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
31 0
0 Reset
_I 1_E A
0_ A
A
ER T N
NT N
EN
IM _IN _E
ST ER T2
SY TIM _IN
S ER
d)
SY TIM
ve
er
S
s
SY
(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
_I 1_R W
0_ W
W
ER T A
NT A
RA
IM _IN _R
ST ER T2
SY TIM _IN
S ER
d)
SY IM
e
rv
ST
se
SY
(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
0_ R
R
NT L
CL
IM _IN _C
_I 1_C
ST ER T2
SY TIM _IN
S ER
d)
SY TIM
r ve
se
S
SY
(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
E
AT
_D
ER
IM
ST
SY
31 0
0x1807160 Reset
11.1 Overview
General purpose timers can be used to precisely time an interval, trigger an interrupt after a particular interval
(periodically and aperiodically), or act as a hardware clock. As shown in Figure 11-1, the ESP32-S2 chip contains
two timer groups, namely timer group 0 and timer group 1. Each timer group consists of two general purpose
timers referred to as Tx (where x is 0 or 1) and one Main System Watchdog Timer. All general purpose timers are
based on 16-bit prescalers and 64-bit auto-reload-capable up/down counters.
Note that while the Main System Watchdog Timer registers are described in this chapter, their functional
description is included in the Chapter 12: Watchdog Timers. Therefore, the term ‘timers’ within this chapter refers
to the general purpose timers.
The timer must be disabled (i.e. TIMG_Tx_EN should be cleared) before modifying the 16-bit prescaler. Modifying
the 16-bit prescaler whilst the timer is enabled can lead to unpredictable results.
To read the 64-bit current timer value of the time-base counter, the timer value must be latched to two registers
before being read by the CPU (due to the CPU being 32-bit). By writing any value to the TIMG_TxUPDATE_REG,
the current value of the 64-bit timer is instantly latched into the TIMG_TxLO_REG and TIMG_TxHI_REG registers
containing the lower and upper 32-bits respectively. TIMG_TxLO_REG and TIMG_TxHI_REG registers will remain
unchanged for the CPU to read in its own time until TIMG_TxUPDATE_REG is written to again.
When an alarm occurs, the TIMG_Tx_ALARM_EN field is automatically cleared and no alarm will occur again until
the TIMG_Tx_ALARM_EN is set.
A software instant reload is triggered by the CPU writing any value to TIMG_TxLOAD_REG causing the timer’s
current value to be instantly reloaded. If TIMG_Tx_EN is set, the timer will continue incrementing/decrementing
from the new value. If TIMG_Tx_EN is cleared, the timer will remain frozen at the new value until counting is
re-enabled.
An auto-reload at alarm will cause a timer reload when an alarm occurs thus allowing the timer to continue
incrementing/decrementing from the reload value. This is generally useful for resetting the timer’s value when
using periodic alarms. To enable auto-reload at alarm, the TIMG_Tx_AUTORELOAD field should be set. If not
enabled, the timer’s value will continue to increment/decrement past the alarm value after an alarm.
11.2.5 Interrupts
Each timer has its own pair of interrupt lines (for edge and level interrupts) that can be routed to the CPU. Thus,
there are a total of six interrupt lines per timer group and they are named as follows:
• TIMG_WDT_LEVEL_INT: Level interrupt line for the watchdog timer in the group, generated when a
watchdog timer interrupt stage times out.
• TIMG_WDT_EDGE_INT: Edge interrupt line for the watchdog timer in the group, generated when a
watchdog timer interrupt stage times out.
• TIMG_Tx_LEVEL_INT: Level interrupt for one of the general purpose timers, generated when an alarm event
happens.
• TIMG_Tx_EDGE_INT: Edge interrupt for one of the general purpose timer, generated when an alarm event
happens.
Interrupts are triggered after an alarm (or stage timeout for watchdog timers) occurs. Level interrupt lines will be
held high after an alarm (or stage timeout) occurs, and will remain so until manually cleared. Conversely, edge
interrupts will generate a short pulse after an alarm (or stage timeout) occurs. To enable a timer’s level or edge
interrupt lines, the TIMG_Tx_LEVEL_INT_EN or TIMG_Tx_EDGE_INT_EN bits should be set respectively.
The interrupts of each timer group are governed by a set of registers. Each timer within the group will have a
corresponding bit in each of these registers:
• TIMG_Tx_INT_RAW : An alarm event sets it to 1. The bit will remain set until writing to the timer’s
corresponding bit in TIMG_Tx_INT_CLR.
• TIMG_WDT_INT_RAW : A stage time out will set the timer’s bit to 1. The bit will remain set until writing to
the timer’s corresponding bit in TIMG_WDT_INT_CLR.
• TIMG_Tx_INT_ST : Reflects the status of each timer’s interrupt and is generated by masking the bits of
TIMG_Tx_INT_RAW with TIMG_Tx_INT_ENA. For level interrupts, these bits reflect the level on the
watchdog timer’s level interrupt line.
• TIMG_WDT_INT_ST : Reflects the status of each watchdog timer’s interrupt and is generated by masking
the bits of TIMG_WDT_INT_RAW with TIMG_WDT_INT_ENA. For level interrupts, these bits reflect the level
on the watchdog timer’s level interrupt line.
• TIMG_Tx_INT_ENA : Used to enable or mask the interrupt status bits of timers within the group.
• TIMG_WDT_INT_ENA : Used to enable or mask the interrupt status bits of watchdog timer within the group.
• TIMG_Tx_INT_CLR : Used to clear a timer’s interrupt by setting its corresponding bit to 1. The timer’s
corresponding bit in TIMG_Tx_INT_RAW and TIMG_Tx_INT_ST will be cleared as a result. Note that a
timer’s interrupt must be cleared before the next interrupt occurs when using level interrupts.
• TIMG_WDT_INT_CLR : Used to clear a timer’s interrupt by setting its corresponding bit to 1. The watchdog
timer’s corresponding bit in TIMG_WDT_INT_RAW and TIMG_WDT_INT_ST will be cleared as a result.
Note that a watchdog timer’s interrupt must be cleared before the next interrupt occurs when using level
interrupts.
• Set the timer’s starting value by writing the starting value to TIMG_Tx_LOAD_LO and
TIMG_Tx_LOAD_HI, then reloading it into the timer by writing any value to TIMG_TxLOAD_REG.
3. Enable auto reload by setting TIMG_Tx_AUTORELOAD and setting the reload value in TIMG_Tx_LOAD_LO
and TIMG_Tx_LOAD_HI.
• If the next alarm requires a new alarm value and reload value (i.e. different alarm interval per iteration),
then TIMG_TxALARMLO_REG, TIMG_TxALARMHI_REG, TIMG_Tx_LOAD_LO, and
TIMG_Tx_LOAD_HI should be reconfigured as needed. Otherwise, the aforementioned registers
should remain unchanged.
11.6 Registers
Register 11.1: TIMG_TxCONFIG_REG (x: 01) (0x0000+0x24*x)
E_ _EN N
AD
_T L _IN N
US M _E
G A L _E
LO
x_ AR T
TO SE
AL
M x_ E T
TI _T LEV _IN
RE
ER
XT
AU EA
E
ID
x_ R
M x_ G
_T C
IV
TI _T N
TI _T D
G IN
D
G E
G E
M x_
M x_
x_
M Tx_
)
ed
TI _T
_T
rv
_
G
se
M
(re
TI
TI
TI
TI
31 30 29 28 13 12 11 10 9 8 0
0 1 1 0x01 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TIMG_Tx_USE_XTAL 1: Use XTAL_CLK as the source clock of timer group. 0: Use APB_CLK as the
source clock of timer group. (R/W)
TIMG_Tx_ALARM_EN When set, the alarm is enabled. This bit is automatically cleared once an alarm
occurs. (R/W)
TIMG_Tx_LEVEL_INT_EN When set, an alarm will generate a level type interrupt. (R/W)
TIMG_Tx_EDGE_INT_EN When set, an alarm will generate an edge type interrupt. (R/W)
TIMG_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)
LO
x_
_T
G
M
TI
31 0
0x000000 Reset
TIMG_Tx_LO After writing to TIMG_TxUPDATE_REG, the low 32 bits of the time-base counter
H I
x_
_T
G
M
TI
31 0
0x000000 Reset
TIMG_Tx_HI After writing to TIMG_TxUPDATE_REG, the high 32 bits of the time-base counter
)
ed
_T
rv
G
se
M
(re
TI
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
0x000000 Reset
TIMG_Tx_ALARM_LO Timer x alarm trigger time-base counter value, low 32 bits. (R/W)
I
_H
RM
LA
A
x_
_T
G
M
TI
31 0
0x000000 Reset
TIMG_Tx_ALARM_HI Timer x alarm trigger time-base counter value, high 32 bits. (R/W)
O
_L
AD
OL
x_
_T
G
M
TI
31 0
0x000000 Reset
TIMG_Tx_LOAD_LO Low 32 bits of the value that a reload will load onto timer x time-base counter.
(R/W)
31 0
0x000000 Reset
TIMG_Tx_LOAD_HI High 32 bits of the value that a reload will load onto timer x time-base counter.
(R/W)
31 0
0x000000 Reset
TIMG_Tx_LOAD Write any value to trigger a timer x time-base counter reload. (WO)
RE ET EN
TH
TH
SE _EN
EN
U_ ES D_
G
T_
EN
CP _R MO
EN
N
_L
_L
_I EN
PP U _
_E
T
ET
ET
_A C O
EL T_
NT
DT O O
S
ES
EV IN
RE
B
P
_L E_
_R
_W _ SH
_
0
3
DT DG
PU
TG
TI _W STG
G DT LA
_W EN
R
Y
ST
ST
_C
_S
_S
P
E
TI _W _F
_
T_
_W _
DT
DT
DT
DT
G DT
DT
DT
G DT
D
d)
_W
_W
_W
_W
_W
_W
TI _W
ve
r
G
se
M
M
M
M
M
M
(re
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 13 12 11 0
TIMG_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 us, 7: 3.2 us. (R/W)
TIMG_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 us, 7: 3.2 us. (R/W)
TIMG_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)
TIMG_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)
TIMG_WDT_STG3 Stage 3 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMG_WDT_STG2 Stage 2 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMG_WDT_STG1 Stage 1 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMG_WDT_STG0 Stage 0 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
R
LE
CA
ES
PR
_
LK
_C
DT
)
ed
_W
rv
G
se
M
(re
31
TI 16 15 0
0x01 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LD
HO
0_
TG
_S
DT
_W
G
M
TI
31 0
0x18cba80 Reset
31 0
0x7ffffff Reset
LD
HO
2_
G
T
_S
DT
_W
G
M
TI
31 0
0x0fffff Reset
LD
HO
3_
TG
_S
DT
_W
G
M
TI
31 0
0x0fffff Reset
31 0
0x000000 Reset
31 0
0x50d83aa1 Reset
TIMG_WDT_WKEY If the register contains a different value than its reset value, write protection is
enabled. (R/W)
G
IN
CL
CY
ST EL
T_
AL K_S
T
AR
AR
AX
Y
_C RD
L
ST
_M
C
I_
TC LI_
TC LI_
I_
LI
AL
CA
A
_C
_C
_C
_
TC
TC
TC
)
ed
_R
_R
_R
_R
_R
rv
G
se
M
(re
TI
TI
TI
TI
TI
31 30 16 15 14 13 12 11 0
D
VL
A_
AT
_D
G
IN
E
CL
LU
CY
VA
_
I_
LI
AL
CA
_C
C_
TC
)
T
ed
_R
_R
rv
G
G
se
M
M
(re
TI
TI
31 7 6 1 0
0x00000 0 0 0 0 0 0 0 Reset
NT
S
_C
E
HR
ST
_R
_T
UT
UT
UT
EO
EO
EO
M
M
TI
TI
TI
I_
I_
I_
AL
AL
AL
_C
_C
_C
TC
TC
TC
)
ed
_R
_R
_R
rv
G
G
se
M
M
(re
TI
TI
TI
31 7 6 3 2 1 0
TIMG_RTC_CALI_TIMEOUT_THRES Threshold value for the RTC calibration timer. If the calibration
timer’s value exceeds this threshold, a timeout is triggered. (R/W)
TI _L T_ C_ _EN N
AD
G CT LA IN N
K
M A LA M _E
M A A L_ E
IC
LO
TI _L T_ VE NT_
E_ NLY
TI _L _ R T
FT
TO SE
T_ C_ N
RE
M A C EN
RE
AC RT _E
AU EA
US O
M A LE _
DE
TI _L T_ GE
_L _ T
T_ CR
G CT PS
VI
G CT N
G C D
AC IN
I
_D
M A E
M A E
TI _L T_
_L _
TI _L _
CT
G CT
G C
G C
G C
)
M A
M LA
ed
TI _L
_L
rv
_
G
se
M
(re
TI
TI
TI
TI
31 30 29 28 13 12 11 10 9 8 7 6 5 0
0 1 1 0x01 0 0 0 1 1 0 0 0 0 0 0 0 0 Reset
EN
_L
EP
ST
C_
RT
T_
AC
)
ed
_L
rv
G
se
M
(re
TI
31 6 5 0
0x00000 0 0 0 0 0 0 Reset
LO
T_
AC
_L
G
M
TI
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
O
_L
M
AR
AL
T_
AC
_L
G
M
TI
31 0
0x000000 Reset
I
_H
M
AR
AL
T_
AC
_L
G
M
TI
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
AD
LO
T_
AC
_L
G
M
TI
31 0
0x000000 Reset
G _IN T_ A
0_ _E NA
M 1 N N
T_ A
A
TI _T _I _E
_T T E
IN N
EN
G DT INT
TI _W T_
G C
)
M A
ed
TI _L
rv
G
se
M
(re
TI
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 0 Reset
TIMG_Tx_INT_ENA The interrupt enable bit for the TIMG_Tx_INT interrupt. (R/W)
TIMG_WDT_INT_ENA The interrupt enable bit for the TIMG_WDT_INT interrupt. (R/W)
TIMG_LACT_INT_ENA The interrupt enable bit for the TIMG_LACT_INT interrupt. (R/W)
G _IN T_ W
0_ _R AW
M 1 N A
T_ W
W
TI _T _I _R
_T T R
IN A
RA
G DT INT
TI _W T_
G C
d)
M A
ve
TI _L
r
G
se
M
(re
TI
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 0 Reset
TIMG_Tx_INT_RAW The raw interrupt status bit for the TIMG_Tx_INT interrupt. (RO)
TIMG_WDT_INT_RAW The raw interrupt status bit for the TIMG_WDT_INT interrupt. (RO)
TIMG_LACT_INT_RAW The raw interrupt status bit for the TIMG_LACT_INT interrupt. (RO)
M 1 N T
0_ _S T
TI _T T_I T_S
_T T S
IN T
ST
G _IN T_
G D IN
T_
TI _W T_
G C
)
M A
ed
TI _L
v
er
G
M
M
s
(re
TI
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 0 Reset
TIMG_Tx_INT_ST The masked interrupt status bit for the TIMG_Tx_INT interrupt. (RO)
TIMG_WDT_INT_ST The masked interrupt status bit for the TIMG_WDT_INT interrupt. (RO)
TIMG_LACT_INT_ST The masked interrupt status bit for the TIMG_LACT_INT interrupt. (RO)
G _IN T_ R
0_ _C LR
M 1 N L
TI _T _I _C
T_ R
R
_T T C
IN L
CL
G DT INT
TI _W T_
G C
)
M A
ed
TI _L
rv
G
se
M
(re
TI
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 0 Reset
I
ve
_T
r
G
se
M
(re
TI
31 28 27 0
0 0 0 0 0x1907261 Reset
N
_E
LK
)
ed
_C
rv
G
se
M
(re
TI
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
TIMG_CLK_EN Register clock gate signal. 1: Registers can be read and written to by software. 0:
Registers can not be read or written to by software. (R/W)
12.1 Overview
Watchdog timers are hardware timers used to detect and recover from malfunctions. They must be periodically
fed (reset) to prevent a timeout. A system/software that is behaving unexpectedly (e.g. is stuck in a software loop
or in overdue events) will fail to feed the watchdog thus trigger a watchdog time out. Therefore, watchdog timers
are useful for detecting and handling erroneous system/software behavior.
The ESP32-S2 contains three watchdog timers: one in each of the two timer groups (called Main System
Watchdog Timers, or MWDT) and one in the RTC Module (called the RTC Watchdog Timer, or RWDT). Each
watchdog timer allows for four separately configurable stages and each stage can be programmed to take one of
three (or four for RWDT) actions upon expiry, unless the watchdog is fed or disabled. The actions upon expiry
are: interrupt, CPU reset, core reset and system reset. Only RWDT can trigger a system reset that will reset the
entire digital circuits, which is the main system including the RTC itself. A timeout value can be set for each stage
individually.
In flash boot mode, RWDT and the first MWDT are enabled by default in order to detect and recover from booting
errors.
Note that while this chapter provides the functional descriptions of the watchdog timer’s, their register
descriptions are provided in Chapter 11: Timer Group (TIMG).
12.2 Features
Watchdog timers have the following features:
• Four stages, each with a programmable timeout value. Each stage can be configured and
enabled/disabled separately
• One of three/four (for MWDTs/ RWDT) possible actions (interrupt, CPU reset, core reset and system reset)
available upon expiry of each stage
• Write protection, to prevent RWDT and MWDT configuration from being altered inadvertently
MWDTs and RWDT are enabled by setting the TIMG_WDT_EN and RTC_CNTL_WDT_EN fields respectively.
When enabled, the 32-bit counters of each watchdog will increment on each source clock cycle until the timeout
value of the current stage is reached (i.e. expiry of the current stage). When this occurs, the current counter value
is reset to zero and the next stage will become active. If a watchdog timer is fed by software, the timer will return
to stage 0 and reset its counter value to zero. Software can feed a watchdog timer by writing any value to
TIMG_WDTFEED_REG for MDWTs and RTC_CNTL_RTC_WDT_FEED for RWDT.
Timeout values of each stage for MWDTs are configured in TIMG_WDTCONFIGi_REG (where i ranges from 2 to
5), whilst timeout values for RWDT are configured using RTC_CNTL_WDT_STGj_HOLD field (where j ranges from
0 to 3).
Please note that the timeout value of stage 0 for RWDT (Thold0 ) is determined together by
EFUSE_WDT_DELAY_SEL field of an eFuse register and RTC_CNTL_WDT_STG0_HOLD. The relationship is as
follows:
Upon the expiry of each stage, one of the following expiry actions will be executed:
• Trigger an interrupt
When the stage expires, an interrupt is triggered.
• CPU reset
When the stage expires, the CPU core will be reset.
• Core reset
When the stage expires, the main system (which includes MWDTs, CPU, and all peripherals) will be reset.
The RTC will not be reset.
• System reset
When the stage expires the main system and the RTC will both be reset. This action is only available in
RWDT.
• Disabled
This stage will have no effects on the system.
For MWDTs, the expiry action of all stages is configured in TIMG_WDTCONFIG0_REG. Likewise for RWDT, the
expiry action is configured in RTC_CNTL_WDTCONFIG0_REG.
1. Disable the write protection by writing the value 0x50D83AA1 to the timer’s write-key register.
2. Make the required modification of the watchdog such as feeding or changing its configuration.
3. Re-enable write protection by writing any value other than 0x50D83AA1 to the timer’s write-key register.
If the system doesn’t respond to SWD feed request and watchdog finally times out, SWD will generate a system
level signal SWD_RSTB to reset the whole digital circuits on chip.
12.4.1 Features
SWD has the following features:
• Various dedicated methods for software to feed SWD, which enables SWD to monitor the working state of
the whole operating system
12.4.2.1 Structure
12.4.2.2 Workflow
In normal state:
• Main CPU can decide whether to feed SWD directly by setting RTC_CNTL_SWD_FEED, or send an
interrupt to ULP-RISC-V and ask ULP-RISC-V to feed SWD by setting RTC_CNTL_SWD_FEED.
• When trying to feed SWD, CPU or the co-processor needs to disable SWD controller’s write protection by
writing 0x8F1D312A to RTC_CNTL_SWD_WKEY. This prevents SWD from being fed by mistake when the
system is operating in sub-optimal state.
• If setting RTC_CNTL_SWD_AUTO_FEED_EN to 1, SWD controller can also feed SWD itself without any
interaction with CPU or ULP-RISC-V.
After reset:
12.5 Registers
MWDT registers are part of the timer submodule and are described in the Chapter 11: Timer Group (TIMG) Timer
Registers section. RWDT and SWD registers are part of the RTC submodule and are described in Chapter 9:
Low-Power Management (RTC_CNTL) RTC Registers section.
13.1 Overview
The XTAL32K watchdog timer on ESP32-S2 is used to monitor the status of external crystal XTAL32K_CLK. This
Watchdog can detect the oscillation failure of XTAL32K_CLK, change the clock source of RTC, etc. When
XTAL32K_CLK works as the clock source of RTC SLOW_CLK and stops vibrating, the XTAL32K watchdog timer
first switches to BACKUP32K_CLK derived from RTC_CLK and generates an interrupt (if the chip is in
Deep-sleep mode, the CPU will be woken up), and then switches back to XTAL32K_CLK after it is restarted by
software.
13.2 Features
13.2.1 XTAL32K Watchdog Timer Interrupts and Wakeup
When the XTAL32K watchdog timer detects the oscillation failure of XTAL32K_CLK, an oscillation failure interrupt
is generated. At this point the CPU will be woken up if in hibernation.
13.2.2 BACKUP32K_CLK
Once the XTAL32K watchdog timer detects the oscillation failure of XTAL32K_CLK, it replaces XTAL32K_CLK
with BACKUP32K_CLK (with a frequency of 32 kHz) derived from RTC_CLK as RTC’s SLOW_CLK, so as to
ensure proper functioning of the system.
2. The XTAL32K watchdog timer automatically enables BACKUP32K_CLK as the alternative clock source of
RTC SLOW_CLK, to ensure the system’s proper functioning and the accuracy of timers running on RTC
SLOW_CLK (e.g. RTC_TIMER). For information about clock frequency configuration, please refer to
Section 13.3.2 Configuring the Divisor of BACKUP32K_CLK.
3. To restore the XTAL32K watchdog timer, software restarts XTAL32K_CLK by turning its XPD signal on and
on again via RTC_CNTL_XPD_XTAL_32K bit. Then, the XTAL32K watchdog timer switches back to
XTAL32K_CLK by setting RTC_CNTL_XTAL32K_WDT_EN bit to 0. If the chip is in Deep-sleep mode, the
XTAL32K watchdog timer will wake up the CPU to finish the above steps.
Define the frequency of RTC_CLK as f_rtc_clk (unit: kHz), and the eight divisor components as
x0 , x1 , x2 , x3 , x4 , x5 , x6 , and x7 , respectively. S = x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7 .
S = f _rtc_clk × (4/32)
M + 1 ≥ xn ≥ M (0 ≤ n ≤ 7)
M = f _rtc_clk/32/2
xn should be an integer. M and S are rounded up or down. Each divisor component (x0 ~x7 ) is 4-bit long, and
corresponds to the value of RTC_CNTL_XTAL32K_CLK_FACTOR (32-bit) in order.
For example, if the frequency of RTC_CLK is 163 kHz, then f _rtc_clk = 163, S = 20, M = 2, and
{x0 , x1 , x2 , x3 , x4 , x5 , x6 , x7 } = {2, 3, 2, 3, 2, 3, 2, 3}. As a result, the frequency of BACKUP32K_CLK is 32.6 kHz.
14.1 Overview
In ESP32-S2, different type of buses and modules can have different permissions to access the memory. The
permission control module is used to manage all the access permissions through corresponding permission
control registers.
14.2 Features
• Permission controls for the CPU buses to access the internal memory
– SRAM partially adopts unified permission control and partially adopts split permission control.
• Access to the external memory is managed by both the memory management unit (MMU) and the
permission control module.
• The total SRAM size is 320 KB and consists of four 8 KB blocks and eighteen 16 KB blocks, numbered
Block 0 ~ 21. The offset address range of each block is shown in Table 73. For the base addresses
accessed by different buses please refer to Section 14.3.1.1, 14.3.1.2, and 14.3.1.3. Each of the four 8 KB
blocks (Block 0 ~ 3) is equipped with an independent permission control register. The eighteen 16 KB
blocks (Block 4 ~ 21) are regarded as a large storage space as a whole, which is managed in split parts
(i.e., the storage space is split into high and low areas with separate permission controls). The split address
cannot fall within the address range of Block 4 ~ 5.
• RTC FAST Memory adopts split permission control. The high and low areas have independent permission
control registers.
• RTC SLOW Memory also adopts split permission control. The high and low areas have independent
permission control registers.
The following sections describe the buses and modules in ESP32-S2 that can access the above-mentioned
internal memory resources.
The permission control registers related to IBUS are also controlled by the PMS_PRO_IRAM0_LOCK signal.
When this signal is set to 1, the values configured in the permission control registers will be locked and cannot be
changed. At the same time, the value of the PMS_PRO_IRAM0_LOCK signal will also remain at 1 and cannot be
changed. The value of the PMS_PRO_IRAM0_LOCK signal is reset to 0 only when the CPU is reset.
Through IBUS, the CPU can Read (data) from SRAM, Write (data) to SRAM, and eXecute (an instruction),
indicated as R/W/X, respectively. The base address of SRAM accessed by the CPU is 0x4002_0000. Software
can configure valid access types to each SRAM block in advance. The configuration of the permission control
registers is shown in Table 74.
Note:
* Configuring split address:
Split address is 32 bits in width and equal to base address plus the configured field value multiplied by 4. For example,
if 0x10000 is written to PMS_PRO_IRAM0_2_REG [16:0], the split address of IBUS in the SRAM Block 4 ~ 21 address
range is equal to 0x4004_0000. Note that the split address on IBUS and DBUS0 cannot fall within the address range of
Block 0 ~ 5.
If the type of access initiated by the CPU to SRAM through IBUS does not match the configured access type, the
permission control module will directly deny this access. For example, if software allows the IBUS bus to only
read and write SRAM Block5, but the CPU initiates an instruction fetch, the permission control module will deny
this fetch access.
An access denial does not block the access initiated by the CPU, which means:
• The write operation will not take effect and will not change the data in the memory block.
If the interrupt that indicates an illegitimate access to SRAM via IBUS is enabled, the permission control module
will record the current access address and access type, and give an interrupt signal at the same time. If the
access is denied repeatedly, the hardware only records the first error message. The access error interrupt is a
level signal and needs to be cleared by software. When the interrupt is cleared, the related error record is also
cleared at the same time.
The CPU can perform R/W/X access to the RTC FAST Memory through IBUS. As RTC FAST Memory adopts
split permission control, software needs to configure access permissions for the high and low address ranges,
respectively. The configuration of the permission control registers is shown in Table 75.
Table 75: Permission Control for IBUS to Access RTC FAST Memory
If the type of access initiated by the CPU to RTC Fast Memory through IBUS does not match the configured
access type, the permission control module will directly deny this access. If the interrupt that indicates an
illegitimate access to the RTC Fast Memory via IBUS is enabled, the permission control module will record the
current access address and access type, and give an interrupt signal at the same time. If the access is denied
repeatedly, the hardware only records the first error message. The access error interrupt is a level signal and
needs to be cleared by software. When the interrupt is cleared, the related error record is also cleared at the
same time.
The permission control registers related to DBUS0 are also controlled by the PMS_PRO_DRAM0_LOCK signal.
When this signal is set to 1, the configured values of the permission control registers will be locked and cannot be
changed. The value of the PMS_PRO_DRAM0_LOCK signal will also remain at 1 and cannot be changed. The
value of the PMS_PRO_DRAM0_LOCK signal is reset to 0 only when the CPU is reset.
The CPU can perform R/W access to SRAM via DBUS0, with the based address 0x3FFB_0000. Software can
configure allowed access types initiated by DBUS0 to each SRAM block in advance. The configuration of the
permission control registers is shown in Table 76.
If the type of access initiated by the CPU to SRAM through DBUS0 does not match the configured access type,
the permission control module will directly deny this access. If the interrupt that indicates an illegitimate access to
SRAM via DBUS0 is enabled, the permission control module will record the current access address, access type,
and access size (in bytes, halfwords, or words), and give an interrupt signal at the same time. If the access is
denied repeatedly, the hardware only records the first error message. The access error interrupt is a level signal
and needs to be cleared by software. When the interrupt is cleared, the related error record is also cleared at the
same time.
The CPU can perform R/W access to RTC FAST Memory through DBUS0. As RTC FAST Memory adopts split
permission control, software needs to configure access permissions for the high and low address ranges,
respectively. The configuration of the permission control registers is shown in Table 77.
Table 77: Permission Control for DBUS0 to Access RTC FAST Memory
If the type of access initiated by the CPU to RTC FAST Memory through DBUS0 does not match the configured
access type, the permission control module will directly deny this access. If the interrupt that indicates an
illegitimate access to RTC FAST Memory via DBUS0 is enabled, the permission control module will record the
current access address, access type, and access size (in bytes, halfwords, or words), and give an interrupt signal
at the same time. If the access is denied repeatedly, the hardware only records the first error message. The
access error interrupt is a level signal and needs to be cleared by software. When the interrupt is cleared, the
related error record is also cleared at the same time.
The permission control registers related to DMA are also controlled by the PMS_DMA_XX_I_LOCK signal. When
this signal is set to 1, the configured values of the permission control registers will be locked and cannot be
changed. The value of the PMS_DMA_XX_I_LOCK signal will also remain at 1 and cannot be changed. The
PMS_DMA_XX_I_LOCK signal value is reset to 0 only when the CPU is reset.
If the type of access initiated by the on-chip DMA to SRAM does not match the configured access type, the
permission control module will directly deny this access. If the interrupt that indicates an illegitimate access to
SRAM via Internal DMA, TX Copy DMA, or RX Copy DMA is enabled, the permission control module will record
the current access address and access type, and give an interrupt signal at the same time. If the access is
denied repeatedly, the hardware only records the first error message. The access error interrupt is a level signal
and needs to be cleared by software. When the interrupt is cleared, the related error record is also cleared at the
same time.
Software can also configure whether PeriBus1 is allowed to access peripherals that are within the address range
0x3F40_0000 ~ 0x3F4B_FFFF.
As the CPU can initiate predictive read operations through PeriBus1, it may cause peripheral FIFO read errors. To
avoid FIFO read errors, the FIFO addresses of the corresponding peripherals have already been written in
hardware and can no longer be changed, as Table 79 shows. In addition, four software-configurable address
registers PMS_PRO_DPORT_2 ~ 5_REG are reserved for users to write into addresses read-protected from
PeriBus1 reading. The configuration of the permission control registers is shown in Table 80.
The permission control registers related to PeriBus1 are also controlled by the PMS_PRO_DPORT_LOCK signal.
When this signal is set to 1, the configured values of the permission registers will be locked and cannot be
changed. The value of the PMS_PRO_DPORT_LOCK signal will also remain at 1 and cannot be changed. The
value of the PMS_PRO_DPORT_LOCK signal is reset to 0 only when the CPU is reset.
If PeriBus1 initiates a read access to unreadable address, or if the type of the access to RTC SLOW Memory
does not match the configured type, the permission control module will directly deny this access. If the interrupt
that indicates an illegitimate access to RTC SLOW Memory by PeriBus1 is enabled, the permission control
module will record the current access address, access type, and access size (in bytes, halfwords, or words), and
give an interrupt signal at the same time. If the access is denied repeatedly, the hardware only records the first
error message. The access error interrupt is a level signal and needs to be cleared by software. When the
interrupt is cleared, the related error record is also cleared at the same time.
PeriBus2 supports R/W/X access to RTC SLOW Memory through two address ranges, namely RTCSlow_0 and
RTCSlow_1. Software can configure the allowed access types. The configuration of the permission control
registers is shown in Table 81.
PeriBus2 does not support fetch operations on peripherals. If a fetch operation is initiated on a peripheral, invalid
data will be obtained.
The permission control registers related to PeriBus2 are also controlled by the PMS_PRO_AHB_LOCK signal.
When this signal is configured to 1, the values of the permission control registers are locked and cannot be
changed. The value of the PMS_PRO_AHB_LOCK signal will also remain at 1 and cannot be changed. The value
of the PMS_PRO_AHB_LOCK signal is reset to 0 only when the CPU is reset.
Table 81: Permission Control for PeriBus2 to Access RTC SLOW Memory
If the type of the access to RTCSlow_0 or RTCSlow_1 made by the CPU through PeriBus2 does not match the
configured type, the permission control module will directly deny this access. If the interrupt that indicates an
illegitimate access by PeriBus2 is enabled, the permission control module will record the current access address
and access type, and give an interrupt signal at the same time. If the access is denied repeatedly, the hardware
only records the first error message. The access error interrupt is a level signal and needs to be cleared by
software. When the interrupt is cleared, the related error record is also cleared at the same time.
The user can allocate Block 0 ~ 3 to Icache_H, Icache_L, Dcache_H, or Dcache_L by configuring the field
PMS_PRO_CACHE_CONNECT in register PMS_PRO_CACHE_1_REG. The detailed configuration is shown in
Table 82, where FIELD indicates field PMS_PRO_CACHE_CONNECT.
Notes:
• One block can be assigned to only one of Dcache_H, Dcache_L, Icache_H, and Icache_L, which means
that one bit at most can be set to 1 in the same row in Table 82.
• One of Dcache_H, Dcache_L, Icache_H, and Icache_L can occupy only one block, which means that one
bit at most can be set to 1 in the same column in Table 82.
• SRAM memory occupied by the cache cannot be accessed by the CPU. Non-occupied SRAM memory
can still be accessed by the CPU.
After the Trace memory function is enabled, register PMS_OCCUPY_3 needs to be configured to select one
block from SRAM Block 4 ~ 21 as Trace memory. Only one block can be used as Trace memory, in which case, it
can no longer be accessed by the CPU. Register PMS_OCCUPY_3 is controlled by the PMS_OCCUPY_LOCK
signal. When this signal is configured as 1, the value configured in the register will be locked and cannot be
changed. At the same time, the value of the PMS_OCCUPY_LOCK signal will also remain at 1 and cannot be
changed. The PMS_OCCUPY_LOCK signal value is reset to 0 the CPU is reset.
When an SRAM block is selected as Trace Memory, neither IBUS, DBUS, nor DMA can access this block.
When cache or EDMA accesses an invalid MMU page or the external memory attribute is not specified in the
MMU, an MMU error interrupt will be triggered.
The eight areas correspond to eight sets of registers, and the flash and SRAM each has four sets. Each set of
registers contains three parts as follows:
1. Attribute list: APB_CTRL_X_ACE_n_ATTR_REG has 3 bits in total, which are W/R/X bits from high to low;
Wherein “X” represents flash or SRAM, “n” represents 0 ~ 3. Note that the total size of the four areas
corresponding to flash must be 1 GB, so is the total size of the four areas corresponding to SRAM.
When the CPU directly accesses external memory, the permission control module only monitors the CPU’s write
requests, not the read requests. The control module checks whether the access type matches the configured
type according to the accessed physical address. If the area does not allow write access, the permission module
directly rejects write access, records the information about the current access, and triggers an access error
interrupt.
Cache miss, cache write back, and cache prefetch operations will trigger W/R/X requests from the cache to the
external memory. The permission control module will query for the access attributes of the area according to the
accessed physical address, and compare the the cache request against the pre-configured attributes. Only
when the two match, the permission control module will pass the request to the external memory. If the cache
initiates an R/F request, the permission control module will send the access attributes of the area to the cache for
storage. When the access request is inconsistent with the current access attributes, the hardware records the
information about the current access and triggers an access error interrupt.
When the CPU accesses the cache, the permission control module must check the attributes of the CPU access
by comparing it with the local access attribute list. Only if the two match, the CPU access is allowed. When the
access request is inconsistent with the current access attributes, the hardware records the information about the
current access and triggers an access error interrupt.
If the access attribute check fails repeatedly, the hardware only records the first error message, and the
subsequent error messages will be discarded directly. The access error interrupt is a level signal. When software
clears the access error interrupt flag, the error record will be cleared at the same time.
14.6 Registers
Register 14.1: PMS_PRO_IRAM0_0_REG (0x0010)
CK
LO
0_
M
RA
_I
O
d)
PR
e
rv
S_
se
PM
(re
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
PMS_PRO_IRAM0_LOCK Lock register. Setting to 1 locks IBUS permission control registers. (R/W)
CK
LO
0_
M
RA
_D
O
d)
PR
ve
S_
ser
PM
(re
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
CK
O
_L
RT
PO
_D
O
d )
PR
ve
S_
ser
PM
(re
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
CK
O
_L
HB
_A
O
d)
PR
e
rv
S_
se
PM
(re
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
CK
_ LO
CE
RA
_T
O
d)
PR
ve
S_
r
se
PM
(re
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
PMS_PRO_TRACE_LOCK Lock register. Setting to 1 locks trace function permission control regis-
ters. (R/W)
CK
O
_L
HE
AC
_C
O
d )
PR
ve
S_
r
se
PM
(re
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
CK
LO
I_
B_
AP
A_
)
DM
ed
rv
S_
se
PM
(re
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
PMS_DMA_APB_I_LOCK Lock register. Setting to 1 locks internal DMA permission control registers.
(R/W)
CK
O
_L
_I
RX
A_
d)
DM
ve
S_
r
se
PM
(re
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
PMS_DMA_RX_I_LOCK Lock register. Setting to 1 locks RX Copy DMA permission control registers.
(R/W)
CK
O
_L
_I
TX
A_
d)
DM
ve
S_
r
se
PM
(re
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
PMS_DMA_TX_I_LOCK Lock register. Setting to 1 locks TX Copy DMA permission control registers.
(R/W)
CK
O
_L
CE
UR
SO
E_
CH
d)
CA
e
rv
S_
se
PM
(re
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
CK
O
_L
AL
ER
PH
RI
PE
B_
d)
AP
ve
S_
ser
PM
(re
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
CK
LO
Y_
UP
CC
d )
ve
O
S_
r
se
PM
(re
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
PMS_OCCUPY_LOCK Lock register. Setting to 1 locks occupy permission control registers. (R/W)
CK
LO
S_
ES
CC
_A
G
TA
E_
CH
d)
CA
e
rv
S_
se
PM
(re
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
CK
LO
S_
ES
CC
A
U_
M
M
E_
CH
)
ed
CA
rv
S_
se
PM
(re
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
EN
K_
d )
CL
ve
S_
ser
PM
(re
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
PMS_CLK_EN Enable the clock of permission control module when set to 1. (R/W)
_ M W
_ M W
_ M W
0_ AM _W
_ M R
_ M R
PR _IR 0_ AM _R
AM 0_R
_S M F
_ M F
RA 0_ AM _F
_F
PM _P _IR M0 RA 3_
PM P _IR 0 A _
PM _P _IR M0 RA 3_
PM _P _IR M0 RA 2_
PM P _IR 0 A _
PM _P _IR M0 RA 2_
PM P _IR 0 A _
S_ RO AM SR _3
S_ RO AM SR _2
S_ RO AM SR _1
S_ RO AM SR _1
O AM SR _1
M SR _0
_0
_
_
_
SR _
M
PM _P _IR M0 RA
S RO A S
S O A S
S RO A S
S RO A S
_
_
PM _P _IR M0
S RO A
A
PM P _IR
_I
S_ RO
S O
d)
R
ve
PM _P
r
se
S
PM
(re
31 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 1 1 1 1 1 1 1 1 1 1 1 1 Reset
R
DD
TA
S_ O AM SR _4 _W
S R _ _W
O AM SR _4 _R
PL
M SR _4 _F
_4 _R
_F
_ M H
PR _IR 0_ AM _H
RA 0_ AM _H
_S
0_ AM _L
AM 4_L
_L
PM _P _IR M0 RA 4_
_4
_
_ M
AM
PM _P _IR M0 RA
SR
S RO A S
S RO A S
_
0_
PM _P _IR M0
M
S RO A
RA
PM _P _IR
_I
_I
S RO
O
d)
PR
ve
PM _P
S_
er
S
s
PM
PM
(re
31 23 22 21 20 19 18 17 16 0
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 Reset
PMS_PRO_IRAM0_SRAM_4_SPLTADDR Configure the split address of SRAM Block 4-21 for IBUS
access. (R/W)
DR
AD
LT
PR _IR 0_ CF T_ W
CF T_ W
RA 0_ CF T_H R
M RTC AST _F
T_ R
F
SP
S_ RO AM RT AS H_
O AM RT AS H_
RT AS L_
AS L_
L_
PM _P _IR M0 TC ST_
0_ F _
T_
AS
S O A R FA
_ F
CF
PM _P _IR M0 TC
RT
S RO A R
_
_
0_
PM _P _IR M0
M
S RO A
RA
PM P _IR
_I
_I
S_ RO
O
)
ed
PR
PM _P
rv
S_
se
S
PM
PM
(re
31 17 16 15 14 13 12 11 10 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 Reset
PMS_PRO_IRAM0_RTCFAST_SPLTADDR Configure the split address of RTC FAST for IBUS ac-
cess. (R/W)
PMS_PRO_IRAM0_RTCFAST_L_F Setting to 1 grants IBUS permission to fetch RTC FAST low ad-
dress region. (R/W)
PMS_PRO_IRAM0_RTCFAST_L_R Setting to 1 grants IBUS permission to read RTC FAST low ad-
dress region. (R/W)
PMS_PRO_IRAM0_RTCFAST_L_W Setting to 1 grants IBUS permission to write RTC FAST low ad-
dress region. (R/W)
DR
AD
LT
M SR _4 _W
_4 _W
SR _ _R
_R
S RO RA _S M W
S_ RO RA _S M_ W
RA 0_ AM _W
AM 0_W
RA 0_ AM _H
0_ AM _H
S RO RA _S M R
O RA _S M_ R
0_ AM _R
_R
_S
AM 4_L
_L
PM _P _D M0 RA _3_
PM _P _D M0 RA _3_
PM _P _D M0 RA _2_
PR _D M0 RA 2_
_D M R 4
_4
_D M R 1
M SR _1
_0
O RA _S M_
SR _
AM
S RO RA _S M
PR _D M0 RA
PM _P _D M0 RA
SR
S_ RO RA _S
S RO RA _S
0_
PM _P _D M0
PM _P _D M0
M
S RO RA
RA
S RO RA
PM P _D
_D
PM _P _D
S_ RO
S RO
)
ed
PR
PM _P
PM _P
rv
S_
se
S
PM
PM
PM
(re
31 29 28 27 26 25 24 8 7 6 5 4 3 2 1 0
0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 Reset
R
A DD
LT
M RTC AST _W
T_ W
CF T_ R
SP
RT AS H_
AS L_
L_
RA 0_ CF T_H
0_ F _
T_
_D M T S
AS
O RA _R FA
CF
PR _D M0 TC
RT
S_ RO RA _R
0_
PM _P _D M0
M
S RO RA
RA
PM _P _D
_D
S RO
O
d)
PR
ve
PM _P
S_
r
se
S
PM
PM
(re
31 15 14 13 12 11 10 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 Reset
R
ID
DD
AL
L
TA
_V
RA
_R SL W_ W
W W
SL W_ R
PL
_R
O
HE
RT TC LO H_
TC O H_
O L_
IF
_S
_L
_F
PO T_R S W_
IP
W
VE
ER
_D R TC O
O
ER
O O R L
SL
_P
S
PR D RT C
TC
PB
ES
T
_R
S_ O PO _R
_R
_A
_
RT
PM _P _D RT
RT
RT
O
S O O
PO
PO
P
P
_D
PM P _D
_D
_D
_
O
S_ RO
O
d)
PR
R
R
PR
PR
ve
PM _P
S_
S_
S_
er
S
s
PM
PM
PM
PM
(re
31 20 19 16 15 14 13 12 11 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 Reset
PR
ve
S_
r
se
PM
(re
31 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
_1
O
IF
_F
VE
ER
ES
_R
RT
PO
_D
O
d)
PR
ve
S_
er
s
PM
(re
31 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
_2
O
IF
_F
VE
ER
ES
_R
RT
PO
_D
O
)
ed
PR
rv
S_
se
PM
(re
31 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
PR
e
rv
S_
se
PM
(re
31 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
R
DD
TA
PR _A _R SL _0 _W
SL W_ L_W
HB TC O 0_ R
PL
TC O 0_ F
_0 R
_F
_A _R SL _ _
_R SL W_ H_
W L_
S_ RO HB TC OW _H
O B TC OW _H
_S
_L
O 0_
0
_0
PM _P _A _R SL W_
W
S RO HB TC O
O
PM _P _A _R SL
SL
S RO HB TC
TC
PM _P _A _R
_R
S RO HB
HB
H
PM P _A
_A
S_ RO
O
d)
PR
ve
PM _P
S_
r
se
S
PM
PM
(re
31 17 16 15 14 13 12 11 10 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 Reset
R
DD
TA
PR _A _R SL _1 _W
SL W_ L_W
HB TC O 1_ R
PL
TC O 1_ F
_1 R
_F
_A _R SL _ _
_R SL W_ H_
W L_
S_ RO HB TC OW _H
O B TC OW _H
_S
_L
O 1_
1
_1
PM _P _A _R SL W_
W
S RO HB TC O
O
PM _P _A _R SL
SL
S RO HB TC
TC
PM _P _A _R
_R
S RO HB
HB
H
PM P _A
_A
S_ RO
O
d)
PR
ve
PM _P
S_
r
se
S
PM
PM
(re
31 17 16 15 14 13 12 11 10 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 Reset
PR
e
rv
S_
se
PM
(re
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
EC
NN
CO
_
HE
AC
_C
O
)
ed
PR
rv
S_
se
PM
31
(re 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DR
AD
LT
B_ SR _4 _W
_4 _W
SR _ _R
_R
AP I_ AM _W
AM 0_W
AP I_ AM _H
I_ AM _H
DM _A _I_ AM _R
I_ AM _R
_R
_S
AM 4_L
_L
A_ PB_ SR _4
_4
S_ MA PB SR _2
A_ PB_ SR _1
B_ SR _1
_0
_
_
_
SR _
DM _A _I_ AM
AM
PM _D _A _I_ RAM
S_ MA PB SR
SR
S MA PB S
S MA PB S
S
S
PM _D _A _I_
I_
PM _D _A _I_
B_
S MA PB
S MA PB
S A B
S A B
AP
P
P
PM D _A
PM _D _A
A_
S_ MA
S MA
)
DM
M
M
ed
PM _D
PM _D
rv
S_
se
S
PM
PM
PM
(re
31 29 28 27 26 25 24 8 7 6 5 4 3 2 1 0
0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 Reset
PMS_DMA_APB_I_SRAM_4_SPLTADDR Configure the split address of SRAM Block 4-21 for inter-
nal DMA access. (R/W)
DR
AD
LT
RX SR _ _W
_4 W
RA _4 _R
_R
P
M _L_
PM _D _R I_S M _W
PM _D _R I_S M _W
M _W
A_ X_I_ RAM 4_H
_I A 4_H
PM _D _R I_S M _R
DM _R _S M_ R
_I A 1_R
_R
_S
_L
S_ MA X_I RA 2_
_4
S MA X_ RA 3
S MA X_ RA 3
_2
RA _0
_0
DM _R _S M_
_
_
RX SR _
_S M
PM _D _R I_S M
_S M
S_ MA X_I RA
RA
S MA X_ RA
S A _ A R
PM _D _R I_S
_S
PM _D _R I_S
_I
S MA X_
S MA X_
RX
X
PM D _R
PM _D _R
A_
S_ MA
S MA
)
DM
M
ed
PM _D
PM _D
rv
S_
se
S
PM
PM
PM
(re
31 29 28 27 26 25 24 8 7 6 5 4 3 2 1 0
0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 Reset
DR
AD
LT
TX SR _ _W
_4 W
RA _4 _R
_R
P
M _L_
PM _D _T I_S M_ W
PM _D _T I_S M_ W
A_ _I_ AM 1_W
M _W
A_ _I_ AM 4_H
_I A 4_H
PM _D _T I_S M_ R
DM _T _S M_ R
_ I A 1_R
_R
_S
_L
S MA X_ RA 3_
S MA X_ RA 3_
S MA X_ RA 2_
S_ MA X_I RA 2_
_4
RA _0
_0
DM _T _S M_
PM _D _T I_S M_
TX SR _
_S M
AM
_S M
S_ MA X_I RA
S MA X_ RA
X R
SR
X R
PM _D _T I_S
PM _D _T I_S
_
_I
S MA X_
S MA X_
TX
PM _D _T
PM _D _T
A_
S MA
S MA
)
DM
ed
PM _D
PM _D
rv
S_
se
S
PM
PM
PM
(re
31 29 28 27 26 25 24 8 7 6 5 4 3 2 1 0
0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 Reset
PMS_DMA_TX_I_SRAM_4_SPLTADDR Configure the split address of SRAM Block 4-21 for TX Copy
DMA access. (R/W)
S
UR
_B
IT
PL
_S
AL
ER
PH
RI
PE
B_
d)
AP
ve
S_
ser
PM
(re
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
PMS_APB_PERIPHERAL_SPLIT_BURST Setting to 1 splits the data phase of the last access and
the address phase of following access. (R/W)
E
CH
CA
Y_
UP
CC
)
ed
O
rv
S_
se
PM
(re
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
PMS_OCCUPY_CACHE Configure whether SRAM Block 0-3 is used as cache memory. (R/W)
O
rv
S_
se
PM
(re
31 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_OCCUPY_PRO_TRACE Configure one block of Block 4-21 is used as trace memory. (R/W)
_T _W _A S
AG R CS
D_ CS
O TAG _RD AC
S
AC
_R _A
PR _I_ G R_
S_ RO _TA _W
PM _P _D AG
S RO _T
PM _P _D
_I
S RO
)
ed
PM _P
v
er
S
s
PM
(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 0 Reset
_A S
CS
RD AC
U_ _
M WR
_M _
O MU
PR _M
S_ RO
)
ed
PM _P
rv
se
S
PM
(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 1 Reset
LR
IL N
RA 0_ _IN
_C
0_ _E
O AM ILG
G
PR _IR 0_
S_ RO AM
PM _P _IR
_I
S RO
)
ed
PM _P
rv
se
S
PM
(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
T
_S
G
IL
0_
M
RA
_I
O
d)
PR
ve
S_
er
s
PM
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_PRO_IRAM0_ILG_ST Record the illegitimate information of IBUS. [21:2]: store the bits [21:2] of
IBUS address; [1]: 1 means data access, 0 means instruction access; [0]: 1 means write operation,
0 means read operation. (RO)
M ILG TR
LR
IL N
RA 0_ _IN
_C
0_ _E
_D M G
G
O RA _IL
PR _D M0
S_ RO RA
PM P _D
S_ RO
)
ed
PM _P
rv
se
S
PM
(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
PR
e
rv
S_
se
PM
(re
31 26 25 0
0 0 0 0 0 0 0 Reset
PMS_PRO_DRAM0_ILG_ST Record the illegitimate information of DBUS. [25:6]: store the bits [21:2]
of DBUS address; [5]: 1 means atomic access, 0 means nonatomic access; [4]: 1 means write
operation, 0 means read operation; [3:0]: DBUS0 bus byte enables. (RO)
R T LG TR
LR
_I _EN
PO T_I _IN
_C
_D R G
LG
O PO _IL
PR _D R T
S_ RO PO
PM P _D
S_ RO
d)
ve
PM _P
er
S
s
PM
(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
T
_S
LG
_I
RT
PO
_D
O
d)
PR
e
rv
S_
se
PM
(re
31 26 25 0
0 0 0 0 0 0 0 Reset
PMS_PRO_DPORT_ILG_ST Record the illegitimate information of PeriBus1. [25:6]: store the bits
[21:2] of PeriBus1 address; [5]: 1 means atomic access, 0 means nonatomic access; [4]: if bits
[31:22] of PeriBus1 address are 0xfd, then the bit value is 1, otherwise it is 0; [3:0]: PeriBus 1 byte
enables. (RO)
LR
_I _EN
_A _I IN
_C
O HB G_
LG
PR _A _IL
S_ RO HB
PM P _A
S_ RO
d)
ve
PM _P
r
se
S
PM
(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
T
_S
LG
_I
HB
_A
O
PR
S_
PM
31 0
0 Reset
PMS_PRO_AHB_ILG_ST Record the illegitimate information of PeriBus2. [31:2]: store the bits [31:2]
of PeriBus2 address; [1]: 1 means data access, 0 means instruction access; [0]: 1 means write
operation, 0 means read operation. (RO)
HE LG TR
LR
_I _EN
AC E_I _IN
_C
_C H G
LG
O AC _IL
PR _C HE
S_ RO AC
PM _P _C
S RO
)
ed
PM _P
rv
se
S
PM
(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
PR
ve
S_
r
se
PM
(re
31 17 16 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
T_
_S
G
L
_I
HE
AC
_C
O
)
ed
PR
rv
S_
se
PM
31 (re 17 16 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
B_ ILG TR
LR
IL N
AP I_ _IN
_C
I_ _E
A_ PB_ ILG
G
DM _A _I_
S_ MA PB
PM D _A
S_ MA
)
ed
PM _D
rv
se
S
PM
(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
PMS_DMA_APB_I_ILG_CLR The clear signal for internal DMA access interrupt. (R/W)
PMS_DMA_APB_I_ILG_EN The enable signal for internal DMA access interrupt. (R/W)
DM
e
rv
S_
se
PM
(re
31 23 22 0
0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_APB_I_ILG_ST Record the illegitimate information of Internal DMA. [22:6]: store the bits
[18:2] of address; [5]: if bits [31:19] of address are 0x7ff, then the bit value is 1, otherwise it is 0;
[4]: 1 means write operation, 0 means read operation; [3:0]: Internal DMA bus byte enables. (RO)
_I G_ R
LR
RX IL INT
_I EN
_C
A_ X_I_ G_
LG
DM _R _IL
S_ MA X_I
PM D _R
S_ MA
d)
ve
PM _D
er
S
s
PM
(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
PMS_DMA_RX_I_ILG_CLR The clear signal for RX Copy DMA access interrupt. (R/W)
PMS_DMA_RX_I_ILG_EN The enable signal for RX Copy DMA access interrupt. (R/W)
T
_S
LG
_I
_I
RX
A_
)
DM
ed
rv
S_
se
PM
(re
31 23 22 0
0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_RX_I_ILG_ST Record the illegitimate information of RX Copy DMA. [22:6]: store the bits
[18:2] of address; [5]: if bits [31:19] of address are 0x7ff, then the bit value is 1, otherwise it is 0; [4]:
1 means write operation, 0 means read operation; [3:0]: RX Copy DMA bus byte enables. (RO)
LR
TX ILG NT
_I EN
_C
A_ _I_ G_I
LG
DM _T _IL
S_ MA X_I
X
PM _D _T
S MA
d)
ve
PM _D
r
se
S
PM
(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
PMS_DMA_TX_I_ILG_CLR The clear signal for TX Copy DMA access interrupt. (R/W)
PMS_DMA_TX_I_ILG_EN The enable signal for TX Copy DMA access interrupt. (R/W)
T
_S
LG
_I
_I
TX
A_
d)
DM
ve
S_
ser
PM
(re
31 23 22 0
0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_TX_I_ILG_ST Record the illegitimate information of TX Copy DMA. [22:6]: store the bits
[18:2] of address; [5]: if bits [31:19] of address are 0x7ff, then the bit value is 1, otherwise it is 0;
[4]: 1 means write operation, 0 means read operation; [3:0]: TX Copy DMA bus byte enables. (RO)
ER R TR
R
R_ N
CL
E_ RO _IN
RO _E
YT ER R
_B E_ RO
RI YT R
PE _B E_E
B_ RI YT
AP PE _B
S_ PB_ ERI
PM _A _P
S PB
)
ed
PM _A
rv
se
S
PM
(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
PMS_APB_PERI_BYTE_ERROR_EN The enable signal for APB peripheral access interrupt. (R/W)
31 0
0 Reset
E R R TR
R
R_ N
CL
E_ RO _IN
RO _E
YT ER R
_B E_ RO
RI YT R
PE _B E_E
U_ ERI YT
CP _P _B
S_ PU ERI
PM C _P
S_ PU
d)
ve
PM _C
er
S
s
PM
(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
PMS_CPU_PERI_BYTE_ERROR_CLR The clear signal for CPU peripheral access interrupt. (R/W)
PMS_CPU_PERI_BYTE_ERROR_EN The enable signal for CPU peripheral access interrupt. (R/W)
DR
AD
R_
RO
R
_E
TE
Y
_B
RI
PE
U_
CP
S_
PM
31 0
0 Reset
DA
ve
S_
r
se
PM
(re
31 28 27 0
0 0 0 0 0x1905090 Reset
15.1 Overview
The ESP32-S2 integrates a large number of peripherals, and enables the control of individual peripherals to
achieve optimal characteristics in performance-vs-power-consumption scenarios. Specifically, ESP32-S2 has a
various of system configuration registers that can be used for the chip’s clock management (clock gating), power
management, and the configuration of peripherals and core-system modules. This chapter lists all these system
registers and their functions.
15.2 Features
ESP32-S2 system registers can be used to control the following peripheral blocks and core modules:
• Interrupt matrix
• eFuse controller
• Low-power management
• SYSTEM_ROM_CTRL_0_REG
• SYSTEM_ROM_CTRL_1_REG
• SYSTEM_SRAM_CTRL_0_REG
• SYSTEM_SRAM_CTRL_1_REG
• SYSTEM_SRAM_CTRL_2_REG
• SYSTEM_RSA_PD_CTRL_REG
• SYSTEM_MEM_PD_MASK_REG
• SYSTEM_CACHE_CONTROL_REG
• SYSTEM_BUSTOEXTMEM_ENA_REG
• SYSTEM_EXTERNAL_DEVICE_ENCRYPT_DECRYPT_CONTROL_REG
• Setting different bits of the SYSTEM_ROM_FO field in register SYSTEM_ROM_CTRL_0_REG forces on the
clock gates of different blocks of ROM.
For detailed information about the controlling bits of different blocks, please see Table 87 below.
ROM Lowest Address1 Highest Address1 Lowest Address2 Highest Address2 Controlling Bit
Block0 0x4000_0000 0x4000_FFFF - - Bit0
Block1 0x4001_2000 0x4001_FFFF 0x3FFA_0000 0x3FFA_FFFF Bit1
For detailed information about the controlling bits of different blocks, please see Table 88 below.
SRAM Lowest Address1 Highest Address1 Lowest Address2 Highest Address2 Controlling Bit
Block0 0x4002_0000 0x4002_1FFF 0x3FFB_0000 0x3FFB_1FFF Bit0
Block1 0x4002_2000 0x4002_3FFF 0x3FFB_2000 0x3FFB_3FFF Bit1
Block2 0x4002_4000 0x4002_5FFF 0x3FFB_4000 0x3FFB_5FFF Bit2
Block3 0x4002_6000 0x4002_7FFF 0x3FFB_6000 0x3FFB_7FFF Bit3
Block4 0x4002_8000 0x4002_BFFF 0x3FFB_8000 0x3FFB_BFFF Bit4
Block5 0x4002_C000 0x4002_FFFF 0x3FFB_C000 0x3FFB_FFFF Bit5
Block6 0x4003_0000 0x4003_3FFF 0x3FFC_0000 0x3FFC_3FFF Bit6
Block7 0x4003_4000 0x4003_7FFF 0x3FFC_4000 0x3FFC_7FFF Bit7
Block8 0x4003_8000 0x4003_BFFF 0x3FFC_8000 0x3FFC_BFFF Bit8
Block9 0x4003_C000 0x4003_FFFF 0x3FFC_C000 0x3FFC_FFFF Bit9
Block10 0x4004_0000 0x4004_3FFF 0x3FFD_0000 0x3FFD_3FFF Bit10
Block11 0x4004_4000 0x4004_7FFF 0x3FFD_4000 0x3FFD_7FFF Bit11
Block12 0x4004_8000 0x4004_BFFF 0x3FFD_8000 0x3FFD_BFFF Bit12
Block13 0x4004_C000 0x4004_FFFF 0x3FFD_C000 0x3FFD_FFFF Bit13
Block14 0x4005_0000 0x4005_3FFF 0x3FFE_0000 0x3FFE_3FFF Bit14
• SYSTEM_CPU_PER_CONF_REG
• SYSTEM_SYSCLK_CONF_REG
• SYSTEM_BT_LPCK_DIV_FRAC_REG
• SYSTEM_CPU_INTR_FROM_CPU_0_REG
• SYSTEM_CPU_INTR_FROM_CPU_1_REG
• SYSTEM_CPU_INTR_FROM_CPU_2_REG
• SYSTEM_CPU_INTR_FROM_CPU_3_REG
• SYSTEM_JTAG_CTRL_0_REG
• SYSTEM_JTAG_CTRL_1_REG
• SYSTEM_JTAG_CTRL_2_REG
• SYSTEM_JTAG_CTRL_3_REG
• SYSTEM_JTAG_CTRL_4_REG
• SYSTEM_JTAG_CTRL_5_REG
• SYSTEM_JTAG_CTRL_6_REG
• SYSTEM_JTAG_CTRL_7_REG
• SYSTEM_RTC_FASTMEM_CONFIG_REG
• SYSTEM_RTC_FASTMEM_CRC_REG
• SYSTEM_CPU_PERI_CLK_EN_REG
• SYSTEM_CPU_PERI_RST_EN_REG
• SYSTEM_PERIP_CLK_EN0_REG
• SYSTEM_PERIP_RST_EN0_REG
• SYSTEM_PERIP_CLK_EN1_REG
• SYSTEM_PERIP_RST_EN1_REG
Note:
1. Set the clock enable register to 1 to enable the clock, and to 0 to disable the clock;
2. Set the reset enabling register to 1 to reset a peripheral, and to 0 to disable the reset.
4. UART memory is shared by all UART peripherals, meaning having any active UART peripherals will prevent the
UART memory from entering the clock-gated state.
7. Resetting this bit also resets the AES, SHA, and RSA accelerators.
15.6 Registers
The addresses below are relative to the system registers base addresses provided in Section 15.4.
O
_F
M
O
_R
)
ed
EM
rv
ST
se
SY
(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 0x3 Reset
SYSTEM_ROM_FO This field is used to force on clock gate of internal ROM. For details, please refer
to Table 87. (R/W)
PU
PD
E_
E_
RC
RC
O
O
_F
_F
M
M
O
O
_R
_R
d)
EM
EM
ve
er
ST
ST
s
SY
SY
(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 3 0 Reset
SYSTEM_ROM_FORCE_PD This field is used to power down internal ROM. For details, please refer
to Table 87. (R/W)
SYSTEM_ROM_FORCE_PU This field is used to power up internal ROM. For details, please refer to
Table 87. (R/W)
O
_F
R AM
_S
)
ed
EM
rv
ST
se
SY
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x3fffff Reset
SYSTEM_SRAM_FO This field is used to force on clock gate of internal SRAM. For details, please
refer to Table 88. (R/W)
M
e
E
rv
ST
se
SY
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTEM_SRAM_FORCE_PD This field is used to power down internal SRAM. For details, please
refer to Table 88. (R/W)
O
PI
G
D_
TE
CA
DI
DE
N_
) _E
ed K
rv CL
se _
)
)
ed
ed
(re TEM
rv
rv
se
se
S
SY
(re
(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 0 0 0 0 0 0 0 0 Reset
O
PI
G
D_
TE
CA
DI
DE
N_
) _E
ed T
rv RS
se _
d)
d)
(re EM
e
e
rv
rv
ST
se
se
SY
(re
(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 1 1 0 0 0 0 0 0 Reset
N
O
E_
RC
UM
O
_N
PE SE E_F
AY
L
_ D
EL
SE
L
EQ MO
_D
D_
_F IT_
TI
O
AI
RI
LL A
_W
_P _W
R
PU
PU
EM P
_C
ST _C
_C
)
ed
EM
SY EM
EM
rv
ST
ST
ST
se
SY
SY
SY
(re
31 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 0x0 1 1 0 Reset
SYSTEM_CPUPERIOD_SEL This field is used to select the clock frequency of CPU or CPU period.
For details, please refer to Table 48 in Chapter 6 Reset and Clock. (R/W)
SYSTEM_PLL_FREQ_SEL This field is used to select the PLL clock frequency based on CPU period.
For details, please refer to Table 48 in Chapter 6 Reset and Clock. (R/W)
SYSTEM_CPU_WAIT_MODE_FORCE_ON Set this bit to force on CPU wait mode. In this mode,
the clock gate of CPU is turned off until any interrupts happen. This mode could also be force on
via WAITI instruction. (R/W)
SYSTEM_CPU_WAITI_DELAY_NUM Sets the number of delay cycles to enter CPU wait mode after
a WAITI instruction. (R/W)
31 0
0 Reset
_1
RY
RA
PO
M
E
_T
AG
JT
E_
BL
SA
DI
E_
S
FU
L _E
CE
AN
_C
EM
ST
SY
31 0
0 Reset
_2
RY
RA
PO
M
E
_T
AG
JT
E_
BL
SA
DI
E_
US
EF
L_
CE
AN
_C
EM
ST
SY
31 0
0 Reset
_3
RY
RA
PO
M
E
_T
AG
JT
E_
BL
SA
DI
E_
S
FU
L _E
CE
AN
_C
EM
ST
SY
31 0
0 Reset
_4
RY
RA
PO
M
E
_T
AG
JT
E_
BL
SA
DI
E_
US
EF
L_
CE
AN
_C
EM
ST
SY
31 0
0 Reset
_5
RY
RA
PO
M
E
_T
AG
JT
E_
BL
SA
DI
E_
S
FU
L _E
CE
AN
_C
EM
ST
SY
31 0
0 Reset
_6
RY
RA
PO
M
E
_T
AG
JT
E_
BL
SA
DI
E_
US
EF
L_
CE
AN
_C
EM
ST
SY
31 0
0 Reset
_7
RY
RA
PO
EM
_T
AG
JT
E_
BL
SA
DI
E_
S
FU
L _E
CE
AN
_C
EM
ST
SY
31 0
0 Reset
K
AS
M
D_
_P
EM
M
P_
SL
_L
d)
EM
r ve
ST
se
SY
(re
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
SYSTEM_LSLP_MEM_PD_MASK Set this bit to allow the memory to work as usual when the chip
enters light sleep. (R/W)
0
1
30
SY TEM
ST _S
0
1
29
SY EM P
S _ I4_
0
1
28
SY TEM AD CL
S _ C2 K_
0
1
27
SY TEM SY _A EN
Espressif Systems
S _ ST RB
0
0
26
SY TEM AP IME _C
S _ B_ R LK
0
0
25
SY TEM SP SA _CL _E
S _ I3_ RA K N
0
1
24
SY TEM PW DM DC _EN
S _ M A _C
0
1
23 SY TEM PW 3_C _CL LK
15. System Registers (SYSTEM)
ST _U M2 LK K_ _E
0
1
22
SY EM A _C _E EN N
S _ RT L N
0
0
21
SY TEM US _M K_E
S _ B_ EM N
0
0
20
SY TEM SP CL _C
S _ I2_ K_ LK
0
0
19
0
18
ve SY TEM PW CL _CL
d) ST _C M1 K_E K_
0
0
17
SY EM A _C N EN
S _ N_ L
1
0
16
0
15
SY TEM PW XT EN
S _ M 1_
410
1
14
0
SY TEM SP 0_C CLK
S _ I3_ L _
1
13
0
SY TEM TIM CL K_E EN
S _ ER K_ N
0
12
0
SY TEM EFU GR EN
S _ S O
0
11
0
SY TEM TIM E_C UP
ST _U ER LK 1_
0
SY EM H GR _E CL
S _ CI O N K_
9
EN
0
SY TEM LED 1_C UP
ST _P C LK _C
_
8
0
SY EM C C _E LK
S _ NT LK N _E
N
7
0
7
SY TEM RM _C _EN
ST _U T_ LK
6 C _
6
0
1
SY SY EM H L E
S S _ CI K_ N
Register 15.18: SYSTEM_PERIP_CLK_EN1_REG (0x0044)
Register 15.17: SYSTEM_PERIP_CLK_EN0_REG (0x0040)
5
5
0
1
0
0
SY EM R SY TEM SP XT _E
S _ YP ST _U I2_ 0_C N
3
3
0
1
SY TEM CR TO SY EM A CL LK
S _ YP _D S _ RT K_ _
2
2
0
1
0
1
SYSTEM_CRYPTO_DS_CLK_EN Set this bit to enable clock of cryptography digital signature. (R/W)
SYSTEM_CPU_PERI_CLK_EN0_REG Configures this register to enable different peripheral clocks.
rv CR TO SA K_ _E EM P _C EN
ed Y _ _ E N
) PT SH CL N _T I01_ LK_
0 Reset
1 Reset
O A K_ IM C EN
_A _C E ER LK
0
0
30
SY TEM
ST _S
0
0
29
SY EM P
S _ I4_
0
0
28
SY TEM AD RS
S _ C2 T
0
0
27
SY TEM SY _A
Espressif Systems
S _ ST RB
0
0
26
SY TEM AP IME _R
S _ B_ R ST
0
0
25
SY TEM SP SA _RS
S _ I3_ RA T
0
0
24
SY TEM PW DM DC
S _ M A _R
0
0
23
ST _U M2 ST T
0
0
22
0
0
21
SY TEM US _M T
S _ B_ EM
0
0
20
SY TEM SP RS _R
S _ I2_ T ST
0
0
19
0
18
ed SY TEM PW RS _RS
) ST _C M1 T T
0
0
17
SY EM A _R
S _ _ S N
0
0
16
SY TEM I2C RS T
ST _P _E T
0
0
15
SY EM W XT
S _ M 1_
411
0
14
0
SY TEM SP 0_R RST
S _ I3_ S
0
13
0
SY TEM TIM RS T
S _ ER T
0
12
0
SY TEM EFU GR
S _ S O
0
11
0
SY TEM TIM E_R UP
ST _U ER ST 1_
RS
0
SY EM H GR
ST _L CI1 O T
_ U
9
0
SY EM ED R P
S _ C S _R
8
ST
0
SY TEM PC _R T
S _ NT ST
7
0
7
SY TEM RM _R
S _ T_ ST
6
6
1
0
SY SY TEM UH RS
S S _ CI T
Register 15.19: SYSTEM_PERIP_RST_EN0_REG (0x0048)
5
5
1
0
1
0
SY EM R SY TEM SP XT T
S _ YP ST _U I2_ 0_R
3
3
1
0
SY TEM CR TO SY EM A RS ST
S _ YP _D S _ RT T
2
2
1
0
1
0
SY TEM CR TO MA ST SY TEM WD RS T
S _ YP _D C S _ G T
0
0
rv CR TO SA T EM P _R
ed Y _ _
) PT SH RS _T I01_ ST
0 Reset
0 Reset
O A T IM R
_A _R ER ST
W
LO
LK EL TA 2K
_S
PC _S _X L3
_S _8 L
TC
_L LK EL TA
ST _L LK EL N
EL M
SY TEM LPC K_S C_E
_R
EM PC _S _X
S _ L T
SY TEM LPC K_R
S _ L
SY TEM LPC
S _
)
d)
)
ed
ed
SY TEM
ve
rv
rv
er
se
se
S
s
SY
(re
(re
(re
31 29 28 27 26 25 24 23 12 11 0
0 0 0 0 0 0 1 0 1 1 Reset
SYSTEM_LPCLK_SEL_RTC_SLOW Set this bit to select RTC_SLOW_CLK as the low power clock.
(R/W)
SYSTEM_LPCLK_SEL_8M Set this bit to select RC_FAST_CLK as the low power clock. (R/W)
SYSTEM_LPCLK_SEL_XTAL Set this bit to select XTAL_CLK as the low power clock. (R/W)
SYSTEM_LPCLK_SEL_XTAL32K Set this bit to select XTAL32K_CLK as the low power clock. (R/W)
SYSTEM_LPCLK_RTC_EN Set this bit to enable the RTC low power clock. (R/W)
_0
PU
_C
M
O
FR
R_
NT
_I
d)
PU
ve
_C
r
EM
se
ST
(re
SY
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
SYSTEM_CPU_INTR_FROM_CPU_0 Set this bit to generate CPU interrupt 0. This bit needs to be
reset by software in the ISR process. (R/W)
PU
_C
rv
EM
se
ST
(re
SY
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
SYSTEM_CPU_INTR_FROM_CPU_1 Set this bit to generate CPU interrupt 1. This bit needs to be
reset by software in the ISR process. (R/W)
_2
PU
_C
M
O
FR
_
TR
IN
_
d)
PU
ve
_C
er
EM
s
ST
(re
SY
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
SYSTEM_CPU_INTR_FROM_CPU_2 Set this bit to generate CPU interrupt 2. This bit needs to be
reset by software in the ISR process. (R/W)
_3
PU
_C
M
O
FR
R_
NT
_I
d)
PU
ve
_C
r
EM
se
ST
(re
SY
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
SYSTEM_CPU_INTR_FROM_CPU_3 Set this bit to generate CPU interrupt 3. This bit needs to be
reset by software in the ISR process. (R/W)
_P RC PD
U
D E_P
EM FO E_
_M M_ RC
SA E FO
_R A_M M_
EM S E
ST _R A_M
SY TEM RS
S _
d)
SY TEM
e
rv
se
S
SY
(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 1 Reset
SYSTEM_RSA_MEM_PD Set this bit to power down RSA memory. This bit has the lowest priority.
When Digital Signature occupies the RSA, this bit is invalid. (R/W)
SYSTEM_RSA_MEM_FORCE_PU Set this bit to force power up RSA memory. This bit has the
second highest priority. (R/W)
SYSTEM_RSA_MEM_FORCE_PD Set this bit to force power down RSA memory. This bit has the
highest priority. (R/W)
NA
_E
EM
TM
EX
OT
US
_B
d)
EM
ve
er
ST
s
SY
(re
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
K_ N
N
CL _O
O
CH E_C T
E_ LK
CA H SE
_I AC RE
RO C E_
_P O_D CH
EM R CA
ST _P O_
SY TEM PR
S _
d)
SY TEM
e
rv
se
S
SY
(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 1 1 Reset
EC YPT
T
R
UA _EN RYP
CB ENC
CR PT
Y
T
_
CR
YP
AL
_D
AD NU
EN
A
AN DB
NL _G0
N L _M
L_
_
AD
AD
O
O
NL
M
W
I_
DO
DO
SP
_D
E_
E_
E_
E
EM ABL
EM ABL
BL
BL
d)
NA
NA
N
N
ve
_E
_E
_E
_E
er
EM
EM
s
ST
ST
ST
ST
(re
SY
SY
SY
SY
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 0 Reset
T
R
R
DD
N
TA
NI
E
FI
_A
_S
_L
C_
RC
RC
RC
R
_C
_C
_C
_C
EM
EM
EM
EM
M
_M
_M
_M
C_
TC
TC
TC
T
_R
_R
_R
_R
)
ed
EM
EM
EM
EM
rv
ST
ST
ST
ST
se
SY
SY
SY
SY
(re
31 30 20 19 9 8 7 0
SYSTEM_RTC_MEM_CRC_START Set this bit to start the CRC of RTC memory. (R/W)
SYSTEM_RTC_MEM_CRC_ADDR This field is used to set address of RTC memory for CRC. (R/W)
SYSTEM_RTC_MEM_CRC_LEN This field is used to set length of RTC memory for CRC based on
start address. (R/W)
SYSTEM_RTC_MEM_CRC_FINISH This bit stores the status of RTC memory CRC. High level means
finished while low level means not finished. (RO)
S
_ RE
RC
_C
EM
M
C_
T
_R
EM
ST
SY
31 0
0 Reset
SYSTEM_RTC_MEM_CRC_RES This field stores the CRC result of RTC memory. (RO)
PU
E_
RC
O
_F
M
RA
_S
d )
EM
rve
ST
se
SY
(re
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x3fffff Reset
SYSTEM_SRAM_FORCE_PU This field is used to power up internal SRAM. For details, please refer
to Table 88. (R/W)
T
SE
CN
F
L_
K_
V_
TA
CL
I
_D
_X
C_
LK
RE
O
_C
_S
_P
d)
EM
EM
EM
e
rv
ST
ST
ST
se
SY
SY
SY
(re
31 19 18 12 11 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1 Reset
SYSTEM_PRE_DIV_CNT This field is used to set the count of prescaler of XTAL_CLK. For details,
please refer to Table 50 in Chapter 6 Reset and Clock. (R/W)
SYSTEM_SOC_CLK_SEL This field is used to select SOC clock. For details, please refer to Table 48
in Chapter 6 Reset and Clock. (R/W)
E
AT
_D
EM
ST
Y
_S
d)
M
ve
E
er
ST
s
SY
(re
31 28 27 0
0 0 0 0 0x1908020 Reset
16.1 Introduction
ESP32-S2 integrates an SHA accelerator, which is a hardware device that speeds up SHA algorithm significantly,
compared to SHA algorithm implemented solely in software. The SHA accelerator integrated in ESP32-S2 has
two working modes, which are Typical SHA and DMA-SHA.
16.2 Features
The following functionality is supported:
– SHA-1
– SHA-224
– SHA-256
– SHA-384
– SHA-512
– SHA-512/224
– SHA-512/256
– SHA-512/t
– Typical SHA
– DMA-SHA
• Typical SHA Working Mode: all the data is written and read via CPU directly.
• DMA-SHA Working Mode: all the data is read via crypto DMA. That is, users can configure the DMA
controller to read all the data needed for hash operation, thus releasing CPU for completing other tasks.
Users can start the SHA accelerator with different working modes by configuring registers SHA_START_REG and
SHA_DMA_START_REG. For details, please see Table 92.
Users can choose hash algorithms by configuring the SHA_MODE_REG register. For details, please see Table
93.
Notice:
ESP32-S2’s Digital Signature (DS) and HMAC Accelerator (HMAC) modules also call the SHA accelerator.
Therefore, users cannot access the SHA accelerator when these modules are working.
16.4.1 Preprocessing
Preprocessing consists of three steps: padding the message, parsing the message into message blocks and
setting the initial hash value.
Suppose that the length of the message M is m bits. Then M shall be padded as introduced below:
2. Second, append k zero bits, where k is the smallest, non-negative solution to the equation
m + 1 + k ≡ 448 mod 512;
3. Last, append the 64-bit block that is equal to the number m expressed using a binary representation.
2. Second, append k zero bits, where k is the smallest, non-negative solution to the equation
m + 1 + k ≡ 896 mod 1024;
3. Last, append the 128-bit block that is equal to the number m expressed using a binary representation.
For more details, please refer to Section “5.1 Padding the Message” in FIPS PUB 180-4 Spec.
• For SHA1, SHA224 and SHA256: the message and its padding are parsed into N 512-bit blocks, M (1) ,
M (2) , …, M (N ) . Since the 512 bits of the input block may be expressed as sixteen 32-bit words, the first
(i) (i) (i)
32 bits of message block i are denoted M0 , the next 32 bits are M1 , and so on up to M15 .
• For SHA384, SHA512, SHA512/224, SHA512/256 and SHA512/t: the message and its padding are
parsed into N 1024-bit blocks. Since the 1024 bits of the input block may be expressed as sixteen 64-bit
(i) (i) (i)
words, the first 64 bits of message block i are denoted M0 , the next 64 bits are M1 , and so on up to M15 .
In Typical SHA working mode, all the message blocks are written into the SHA_M_n_REG, following the rules
below:
(i) (i)
• For SHA1, SHA224 and SHA256: M0 is stored in SHA_M_0_REG, M1 stored in SHA_M_1_REG, …,
(i)
and M15 stored in SHA_M_15_REG.
• For SHA384, SHA512, SHA512/224 and SHA512/256: the most significant 32 bits and the least
(i)
significant 32 bits of M0 are stored in SHA_M_0_REG and SHA_M_1_REG, respectively, …, the most
(i)
significant 32 bits and the least significant 32 bits of M15 are stored in SHA_M_30_REG and
SHA_M_31_REG, respectively.
Note:
For more information about “message block”, please refer to Section “2.1 Glossary of Terms and Acronyms” in FIPS PUB
180-4 Spec.
2. Configure this linked list based on the instruction described in Chapter 2 DMA Controller (DMA), including
but not limited to assigning the starting address of the input message to the buffer address pointer of the
linked list;
5. Write 1 to register CRYPTO_DMA_AES_SHA_SELECT_REG, so the SHA accelerator gets to use the DMA
resource shared by AES and SHA accelerators.
However, SHA-512/t requires a distinct initial hash value for each operation for a given value of t. Simply put,
SHA-512/t is the generic name for a t-bit hash function based on SHA-512 whose output is truncated to t bits. t
is any positive integer without a leading zero such that t<512, and t is not 384. The initial hash value for
SHA-512/t for a given value of t can be calculated by performing SHA-512 from hexadecimal representation of
the string “SHA-512/t”. It’s not hard to observe that when determining the initial hash values for SHA-512/t
algorithms with different t, the only difference lies in the value of t.
Therefore, we have specially developed the following simplified method to calculate the initial hash value for
SHA-512/t:
1. Generate t_string and t_length: t_string is a 32-bit data that stores the input message of t. t_length is a
7-bit data that stores the length of the input message. The t_string and t_length are generated in methods
described below, depending on the value of t:
• If 1 <= t <= 9, then t_length = 7′ h48 and t_string is padded in the following format:
8′ h3t0 1′ b1 23′ b0
where t0 = t.
• If 10 <= t <= 99, then t_length = 7′ h50 and t_string is padded in the following format:
8′ h3t1 8′ h3t0 1′ b1 15′ b0
• If 100 <= t < 512, then t_length = 7′ h58 and t_string is padded in the following format:
8′ h3t2 8′ h3t1 8′ h3t0 1′ b1 7′ b0
3. Obtain initial hash value: Set the SHA_MODE_REG register to 7. Set the SHA_START_REG register to 1
to start the SHA accelerator. Then poll register SHA_BUSY_REG until the content of this register becomes
0, indicating the calculation of initial hash value is completed.
Please note that the initial value for SHA-512/t can be also calculated according to the Section “5.3.6 SHA-512/t”
in FIPS PUB 180-4 Spec, that is performing SHA-512 operation (with its initial hash value set to the result of
8-bitwise XOR operation of C and 0xa5) from the hexadecimal representation of the string “SHA-512/t”.
• Type “alone”: Users do not insert any new computation before the SHA accelerator completes all the
message blocks.
• Type “interleave”: Users can insert new computations (both Typical SHA task and DMA-SHA task) every
time the SHA accelerator completes one message block. To be more specific, users can store the message
digest in registers SHA_H_n_REG after completing each message block, and assign the accelerator with
other higher priority tasks. After the inserted task completes, users can put the message digest stored
back to registers SHA_H_n_REG, and resume the accelerator with the previously paused computation.
• Select a hash algorithm by configuring the SHA_MODE_REG register. For details, please refer to Table
93.
• If this is the first time to execute this step, set the SHA_START_REG register to 1 to start the SHA
accelerator. In this case, the accelerator uses the initial hash value stored in hardware for a given
algorithm configured in Step 1 to start the computation;
• If this is not the first time to execute this step, set the SHA_CONTINUE_REG register to 1 to start
the SHA accelerator. In this case, the accelerator uses the hash value stored in the
SHA_H_n_REG register to start computation.
(c) Poll register SHA_BUSY_REG until the content of this register becomes 0, indicating the accelerator
has completed the computation for the current message block and now is in the “idle” status. Then,
go to step 3.
• If yes, please get ready for handing over the SHA accelerator to the new task:
(a) Read and store the hash algorithm selected for the current computation stored in the
SHA_MODE_REG register;
(b) Read and store the message digest stored in registers SHA_H_n_REG;
(c) Last, please go to perform the inserted computation. For the detailed process of the inserted
computation, please refer to Typical SHA or DMA-SHA, depending on the working mode.
4. Decide if you have more message blocks following the previous computation:
• Otherwise, go to Step 5.
5. Decide if you need to return the SHA accelerator to a previous computation (i.e., decide whether the
current task is an inserted task or not):
• If yes, please get ready to return the SHA accelerator for the previous computation:
(a) Write the previously stored hash algorithm back to register SHA_MODE_REG;
(b) Write the previously stored message digest back to registers SHA_H_n_REG;
• Otherwise, there is no need to return SHA Control. Therefore, please go to Step 6 directly.
(a) Calculate t_stiring and t_length and initialize SHA_T_STRING_REG and SHA_T_LENGTH_REG with
the generated t_string and t_length. For details, please refer to Section 16.4.1.3.
(c) Poll register SHA_BUSY_REG until the content of this register becomes 0, indicating the calculation of
initial hash value is completed.
• Set the SHA_CONTINUE_REG register to 1 to start the SHA accelerator. In this case, the
accelerator uses the hash value stored in the SHA_H_n_REG register to start computation.
(c) Poll register SHA_BUSY_REG until the content of this register becomes 0, indicating the accelerator
has completed the computation for the current message block and now is in the “idle” status. Then,
go to step 4.
• If yes, please get ready for handing over the SHA accelerator to the new task:
(a) Read and store the hash algorithm selected for the current computation stored in the
SHA_MODE_REG register;
(b) Read and store the message digest stored in registers SHA_H_n_REG;
(c) Last, please go to perform the inserted computation. For the detailed process of the inserted
computation, please refer to Typical SHA or DMA-SHA, depending on the working mode.
5. Decide if you have more message blocks following the previous computation:
• Otherwise, go to Step 6.
6. Decide if you need to return the SHA accelerator to a previous computation (i.e., decide whether the
current task is an inserted task or not):
• If yes, please get ready to return the SHA accelerator for the previous computation:
(a) Write the previously stored hash algorithm back to register SHA_MODE_REG;
(b) Write the previously stored message digest back to registers SHA_H_n_REG;
• Otherwise, there is no need to return SHA Control. Therefore, please go to Step 7 directly.
Note:
1. In Step 2b, the software can also write the next message block (to be processed) in registers SHA_M_n_REG, if
any, while the hardware starts SHA computation, to save time.
In contrast to the Typical SHA working mode, when the SHA accelerator is working under the DMA-SHA mode,
all data read are completed via crypto DMA.
Therefore, users are required to configure the DMA controller as instructed in Subsection 16.4.1.2. Please refer
to Chapter 2 DMA Controller (DMA) for more information.
• Select a hash algorithm by configuring the SHA_MODE_REG register. For details, please refer to Table
93.
• If the current DMA-SHA computation follows a previous computation, firstly write the message digest
from the previous computation to registers SHA_H_n_REG, then write 1 to register
SHA_DMA_CONTINUE_REG to start SHA accelerator;
5. Wait till the completion of the DMA-SHA computation, which happens when:
• An SHA interrupt occurs. In this case, please clear interrupt by writing 1 to the SHA_INT_CLEAR_REG
register.
(a) Calculate t_string and t_length and initialize SHA_T_STRING_REG and SHA_T_LENGTH_REG with
the generated t_string and t_length. For details, please refer to Section 16.4.1.3.
(c) Poll register SHA_BUSY_REG until the content of this register becomes 0, indicating the calculation of
initial hash value is completed.
6. Wait till the completion of the DMA-SHA computation, which happens when:
• An SHA interrupt occurs. In this case, please clear interrupt by writing 1 to the SHA_INT_CLEAR_REG
register.
Table 97: The Storage and Length of Message digest from Different Algorithms
Note:
1. The message digest are stored in registers from most significant bits to the least significant bits, with the first word
stored in register SHA_H_0_REG and the second word stored in register SHA_H_1_REG... For details, please see
subsection 16.4.1.2.
2. The registers used for SHA-512/t algorithm depend on the value of t. x+1 indicates the number of 32-bit registers
used to store t bits of message digest, so that x = roundup(t/32)-1. For example:
• When t = 8, then x = 0, indicating that the 8-bit long message digest is stored in the most significant 8 bits of
register SHA_H_0_REG;
• When t = 32, then x = 0, indicating that the 32-bit long message digest is stored in register SHA_H_0_REG;
• When t = 132, then x = 4, indicating that the 132-bit long message digest is stored in registers SHA_H_0_REG,
SHA_H_1_REG, SHA_H_2_REG, SHA_H_3_REG, and SHA_H_4_REG.
16.4.4 Interrupt
SHA accelerator supports interrupt on the completion of computation when working in the DMA-SHA mode. To
enable this function, write 1 to register SHA_INT_ENA_REG. Note that the interrupt should be cleared by
software after use via setting the SHA_INT_CLEAR_REG register to 1.
16.7 Registers
Register 16.1: SHA_START_REG (0x0010)
T
AR
d)
ST
ve
A_
ser
SH
(re
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
P
O
UE_
IN
NT
d )
CO
ve
A_
ser
SH
(re
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
TE
TA
_S
SY
d )
BU
ve
A_
ser
SH
(re
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
SHA_BUSY_STATE Indicates the states of SHA accelerator. (RO) 1’h0: idle 1’h1: busy
DM
rv
A_
se
SH
(re
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
UE
IN
NT
CO
A_
d)
DM
ve
A_
ser
SH
(re
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
IN
R_
EA
d )
CL
ve
A_
r
se
SH
(re
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
NA
_E
PT
RU
ER
d)
T
ve
IN
A_
r
se
SH
(re
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
_D
rv
se
A
SH
(re
31 30 29 0
0 0 0x20190402 Reset
DE
)
O
ed
M
rv
A_
se
SH
(re
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 0x0 Reset
SHA_MODE Defines the SHA algorithm. For details, please see Table 93. (R/W)
NG
RI
ST
T_
A_
SH
31 0
0x000000 Reset
SHA_T_STRING Defines t_string for calculating the initial Hash value for SHA-512/t. (R/W)
TH
NG
LE
)
ed
T_
rv
A_
se
SH
(re
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 0x0 Reset
SHA_T_LENGTH Defines t_length for calculating the initial Hash value for SHA-512/t. (R/W)
DM
e
rv
A_
se
SH
(re
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 0x0 Reset
n
H_
A_
SH
31 0
0x000000 Reset
SHA_H_n Stores the nth 32-bit piece of the Hash value. (R/W)
_n
M
A_
SH
31 0
0x000000 Reset
17.1 Introduction
ESP32-S2 integrates an Advanced Encryption Standard (AES) Accelerator, which is a hardware device that
speeds up AES Algorithm significantly, compared to AES algorithms implemented solely in software. The AES
Accelerator integrated in ESP32-S2 has two working modes, which are Typical AES and DMA-AES.
17.2 Features
The following functionality is supported:
– Block mode
* CTR (Counter)
• Typical AES Working Mode: supports AES-128/AES-192/AES-256 encryption and decryption under NIST
FIPS 197. In this working mode, the plaintext and ciphertext is written and read via CPU directly.
Users can choose the working mode for AES accelerator by configuring the AES_DMA_ENABLE_REG register
according to Table 100 below.
For detailed introduction on these two working modes, please refer to Section 17.4 and Section 17.5
below.
Notice:
ESP32-S2’s Digital Signature (DS) and External Memory Manual Encryption modules also call the AES accel-
erator. Therefore, users cannot access the AES accelerator when these modules are working.
Users can check the working status of the AES accelerator by inquiring the AES_STATE_REG register and
comparing the return value against the Table 102 below.
In the Typical AES working mode, the AES accelerator requires 11 ~ 15 clock cycles to encrypt a message block,
and 21 or 22 clock cycles to decrypt a message block.
The plaintext and ciphertext are stored in AES_TEXT_IN_m_REG and AES_TEXT_OUT_m_REG, which are two
sets of four 32-bit registers.
17.4.2 Endianness
Text Endianness
In Typical AES working mode, the AES Accelerator uses cryptograohic keys to encrypt and decrypt data in
blocks of 128 bits. The Bit 2 and Bit 3 of the AES_ENDIAN_REG register define the endianness of input text,
while the Bit 4 and Bit 5 define the endianness of output text. To be more specific, Bit 2 and Bit 4 control how the
four bytes are stored in each word, and Bit 3 and Bit 5 control how the four words are stored in each message
block.
Users can choose one of the four text endianness types provided by the AES Accelerator by configuring the
AES_ENDIAN_REG register. Details can been seen in Table 103.
Table 103: Text Endianness Types for Typical AES
Note:
1. The definition of “State” is described in Section 3.4 The State in NIST FIPS 197.
2. Where,
• When x = IN, the Word Endian and Byte Endian controlling bits of AES_TEXT_IN_m_REG are the Bit 2 and
Bit 3 of AES_ENDIAN_REG, respectively;
• When x = OUT, the Word Endian and Byte Endian controlling bits of AES_TEXT_OUT_m_REG are the Bit 4
and Bit 5 of AES_ENDIAN_REG, respectively.
Key Endianness
In Typical AES working mode, Bit 0 and bit 1 in AES_ENDIAN_REG define the key endianness.
Users can choose one of the four key endianness types provided by the AES accelerator by configuring the
AES_ENDIAN_REG register. Details can been seen in Table 104, Table 105, and Table 106.
Note:
1. w[0] ~ w[3] are “the first Nk words of the expanded key” as specified in Section 5.2 Key Expansion in NIST FIPS 197.
2. “Column Bit” specifies the bytes of each word stored in w[0] ~ w[3].
437
Table 105: Key Endianness Types for AES192 Encryption and Decryption
Note:
1. w[0] ~ w[5] are “the first Nk words of the expanded key” as specified in Chapter 5.2 Key Expansion in NIST FIPS 197.
2. “Column Bit” specifies the bytes of each word stored in w[0] ~ w[5].
Table 106: Key Endianness Types for AES256 Encryption and Decryption
Espressif Systems
Note:
1. w[0] ~ w[7] are “the first Nk words of the expanded key” as specified in Chapter 5.2 Key Expansion in NIST FIPS 197.
2. “Column Bit” specifies the bytes of each word stored in w[0] ~ w[7].
438
ESP32-S2 TRM (v1.1)
17. AES Accelerator (AES)
4. Wait till the content of the AES_STATE_REG register becomes 0, which indicates the operation is
completed.
Consecutive Operations
2. Initialize registers AES_MODE_REG, AES_KEY_n_REG, and AES_ENDIAN_REG before starting the first
operation.
5. Wait till the content of the AES_STATE_REG register becomes 0, which indicates the operation completes.
6. Read results from the AES_TEXT_OUT_m_REG register, and return to Step 3 to continue the next
operation.
Users can check the working status of the AES accelerator by inquiring the AES_STATE_REG register and
comparing the return value against the Table 108 below.
When working in the DMA-AES working mode, the AES accelerator supports interrupt on the completion of
computation. To enable this function, write 1 to the AES_INT_ENA_REG register. By default, the interrupt
function is enabled. Also, note that the interrupt should be cleared by software after use.
During the block operations, the AES Accelerator reads source data (in_stream) from DMA, and write result data
(out_stream) to DMA after the computation.
• For encryption, DMA reads plaintext from memory, then passes it to AES as source data. After
computation, AES passes ciphertext as result data back to DMA to write into memory.
• For decryption, DMA reads ciphertext from memory, then passes it to AES as source data. After
computation, AES passes plaintext as result data back to DMA to write into memory.
During block operations, the lengths of the source data and result data are the same. The total computation time
is reduced because the DMA data operation and AES computation can happen concurrently.
The length of source data for AES Accelerator under DMA-AES working mode must be 128 bits or the integral
multiples of 128 bits. Otherwise, trailing zeros will be added to the original source data, so the length of source
data equals to the nearest integral multiples of 128 bits. Please see details in Table 109 below.
Function : TEXTPADDING( )
Input : X, bit string.
Output : Y = TEXTPADDING(X), whose length is the nearest integral multiples of 128 bits.
Steps
Let us assume that X is a data-stream that can be split into n parts as following:
X = X1 ||X2 || · · · ||Xn−1 ||Xn
Here, the lengths of X1 , X2 , · · · , Xn−1 all equal to 128 bits, and the length of Xn is t
(0<=t<=127).
If t = 0, then
TEXTPADDING(X) = X;
If 0 < t <= 127, define a 128-bit block, Xn∗ , and let Xn∗ = Xn ||0128−t , then
TEXTPADDING(X) = X1 ||X2 || · · · ||Xn−1 ||Xn∗ = X||0128−t
17.5.2 Endianness
Under the DMA-AES working mode, the transmission of source data and result data for AES Accelerator is solely
controlled by DMA. Therefore, the AES Accelerator cannot control the Endianness of the source data and result
data, but does have requirement on how these data should be stored in memory and on the length of the
data.
For example, let us assume DMA needs to write the following data into memory at address 0x0280.
– 0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20
• Data Length:
– Equals to 2 blocks.
Then, this data will be stored in memory as shown in Table 110 below.
DMA can access both internal memory and PSRAM outside ESP32-S2. When you use DMA to access external
PSRAM, please use base addresses that meet the requirements for DMA. When you use DMA to access internal
memory, base addresses do not have such requirements. Details can be found in Chapter 2 DMA Controller
(DMA).
Both IV and ICB are 128-bit strings, which can be divided into Byte0, Byte1, Byte2 · · · Byte15 (from left to right).
AES_IV_MEM stores data following the Endianness pattern presented in Table 110, i.e. the most significant (i.e.,
left-most) byte Byte0 is stored at the lowest address while the least significant (i.e., right-most) byte Byte15 at the
highest address.
2. Configure Crypto DMA chained list and start DMA. For details, please refer to Chapter 2 DMA Controller
(DMA).
• Select operation type by configuring the AES_BLOCK_MODE_REG register. For details, see Table
107.
• Initialize the AES_INC_SEL_REG register (only needed when AES Accelerator is working under CTR
block operation).
• Initialize the AES_IV_MEM memory (This is always needed except for ECB block operation).
5. Wait for the completion of computation, which happens when the content of AES_STATE_REG becomes 2
or the AES interrupt occurs.
6. Check if DMA completes data transmission from AES to memory. At this time, DMA had already written the
result data in memory, which can be accessed directly. For details on DMA, please refer to Chapter 2 DMA
Controller (DMA).
7. Clear interrupt by writing 1 to the AES_INT_CLR_REG register, if any AES interrupt occured during the
computation.
8. Release the AES Accelerator by writing 0 to the AES_DMA_EXIT_REG register. After this, the content of the
AES_STATE_REG register becomes 0. Note that, you can release DMA earlier, but only after Step 5 is
completed.
2. Configure Crypto DMA chained list and start DMA. For details on DMA, please refer to Chapter 2 DMA
Controller (DMA).
• Initialize the AES_BLOCK_NUM_REG register. Details about this register are described in Section
17.5.4.
• Initialize the AES_AAD_BLOCK_NUM_REG register. Details about this register are described in
Section 17.6.4.
5. Wait for the completion of computation, which happens when the content of AES_STATE_REG becomes 2.
For details on the working status of AES Accelerator, please refer to Table 108. At this step, no interrupt
occurs.
9. Wait for the completion of computation, which happens when the content of AES_STATE_REG becomes 2
or the AES interrupt occurs. For details on the working status of AES Accelerator, please refer to Table 108.
11. Check if DMA completes data transmission from AES to memory. At this time, DMA had already written the
result data in memory, which can be accessed directly. For details on DMA, please refer to Chapter 2 DMA
Controller (DMA).
12. Clear interrupt by writting 1 to the AES_INT_CLR_REG register, if any AES interrupt occured during the
computation.
13. Exit DMA by writing 1 to the AES_DMA_EXIT_REG register. After this, the content of the AES_STATE_REG
becomes 0. Note that, you can exit DMA earlier, but only after Step 9 is completed.
1. Hardware executes the ECB Algorithm to obtain the Hash subkey H, which is needed in the Hash
computation.
2. Hardware executes the GHASH Algorithm to perform Hash computation with the padded AAD.
3. Hardware gets ready for CTR encryption by obtaining the result of applying Standard Incrementing
Function INC32 to J0 .
4. Hardware executes the GCTR Algorithm to encrypt the padded plaintext P , then executes the GHASH
Algorithm to perform Hash computation on the padded cipertext C.
5. Hardware executes the GHASH Algorithm to perform Hash computation on AAD Blocks, obtaining a
7. Software obtains the result T0 from hardware, and execute MSBt Algorithm to obtain the final result
Authenticated Tag T .
The only difference between GCM decryption and GCM encryption lies in Step 4 in Figure 17-1. To be more
specific, instead of executing GCTR Algorithm to encrypt the padded plaintext, the AES Accelerator executes the
same Algorithm to decrypt the padded cipertext in GCM decryption. For details, please see NIST SP
800-38D.
17.6.2 J0
The J0 is a 128-bit value computed by hardware, which is required during Step 3 and Step 6 of the GCM
process in Figure 17-1. For details on the generation of J0 , please see Chapter 7 GCM Specification in NIST SP
800-38D Specification.
The J0 is stored in the AES_J0_MEM memory as Endianness. Just like all other Endianness, its most significant
(i.e., left-most) byte Byte0 is stored at the lowest address in the memory while least significant (i.e., right-most)
byte Byte15 at the highest address. For details, see Table 110.
• When t = 128, the value of Tag equals to T0 , a 128-bit string that is stored in the AES_T0_MEM as
Endianness. Just like all other Endianness, its most significant (i.e., left-most) byte Byte0 is stored at the
lowest address in the memory while least significant (i.e., right-most) byte Byte15 at the highest address.
For details, see Table 110.
• When 1 <= t < 128, the value of Tag equals to the t most significant (i.e., left-most) bits of T0 . In this case,
Tag is represented as MSBt (T0 ), which returns the t most significant bits of T0 . For example,
MSB4 (111011010) = 1110 and MSB5 (11010011010) = 11010. For details on the MSBt ( ) function, please
refer to Chapter 6 Mathematical Components of GCM in the NIST SP 800-38D specification.
Register AES_REMAINDER_BIT_NUM_REG does not affect the results of plaintext or cipertext, but does impact
the value of T0 , therefore the Tag value too.
The GCM Algorithm can be viewed as the combination of GCTR operation and GHASH operation, among which,
the GCTR performs the encryption and decryption, while the GHASH sloves the Tag.
Note that the AES_REMAINDER_BIT_NUM_REG register is only effective for GCM encryption. To be more
specific:
• For GCM encryption, the Hardware firstly computes C, then passes it in the form of TEXTPADDING(C) as
the input of GHASH operation. In this case, hardware determines how many trailing “0” should be added
based on the content of AES_REMAINDER_BIT_NUM_REG.
• For GCM decrpytion, the padding is completed with the TEXTPADDING(C) function. In this case, the
AES_REMAINDER_BIT_NUM_REG register is not effective.
17.10 Registers
Register 17.1: AES_KEY_n_REG (n: 07) (0x0000+4*n)
31 0
0x000000000 Reset
31 0
0x000000000 Reset
AES_TEXT_IN_m_REG (m: 03) Stores the source data when the AES Accelerator operates in the
Typical AES working mode. (R/W)
31 0
0x000000000 Reset
AES_TEXT_OUT_m_REG (m: 03) Stores the result data when the AES Accelerator operates in the
Typical AES working mode. (RO)
O
e
_M
rv
se
S
AE
(re
31 3 2 0
0x00000000 0 Reset
AES_MODE Defines the operation type of the AES Accelerator operating under the Typical AES work-
ing mode. For details, see Table 101. (R/W)
AN
DI
)
ed
EN
rv
S_
se
AE
(re
31 6 5 0
0x0000000 0 0 0 0 0 0 Reset
AES_ENDIAN Defines the endianness of input and output texts. For details, please see Table 103.
(R/W)
LE
AB
EN
A_
d)
DM
e
rv
S_
se
AE
(re
31 1 0
0x00000000 0 Reset
AES_DMA_ENABLE Defines the working mode of the AES Accelerator. For details, see Table 100.
(R/W)
DE
O
_M
CK
O
)
ed
BL
rv
S_
se
AE
(re
31 3 2 0
0x00000000 0 Reset
AES_BLOCK_MODE Defines the operation type of the AES Accelerator operating under the DMA-
AES working mode. For details, see Table 107. (R/W)
31 0
0x00000000 Reset
AES_BLOCK_NUM Stores the Block Number of plaintext or cipertext when the AES Accelerator
operates under the DMA-AES working mode. For details, see Section 17.5.4. (R/W)
SEL
C_
d )
ve
IN
r
S_
se
AE
(re
31 1 0
0x00000000 0 Reset
AES_INC_SEL Defines the Standard Incrementing Function for CTR block operation. Set this bit to
0 or 1 to choose INC32 or INC128 . (R/W)
31 0
0x00000000 Reset
AES_AAD_BLOCK_NUM Stores the ADD Block Number for the GCM operation. (R/W) For details,
see Section 17.6.4.
M
NU
_
IT
_B
ER
ND
AI
M
d)
RE
e
rv
S_
se
AE
(re
31 7 6 0
0x0000000 0 Reset
AES_REMAINDER_BIT_NUM Stores the Remainder Bit Number for the GCM operation. For details,
see Section 17.6.5. (R/W)
I
TR
rv
S_
se
AE
(re
31 1 0
0x00000000 x Reset
E
AT
)
ed
ST
rv
S_
se
AE
(re
31 2 1 0
AES_STATE Stores the working status of the AES Accelerator. For details, see Table 102 for Typical
AES working mode and Table 108 for DMA AES working mode. (RO)
UE
IN
NT
d )
CO
ve
r
S_
se
AE
(re
31 1 0
0x00000000 x Reset
IT
EX
A_
d)
DM
rve
S_
se
AE
(re
31 1 0
0x00000000 x Reset
AES_DMA_EXIT Set this bit to 1 to exit AES operation. This register is only effective for DMA-AES
operation. (WO)
IN
rv
S_
se
AE
(re
31 1 0
0x00000000 0 Reset
A
EN
T_
d)
ve
IN
r
S_
se
AE
(re
31 1 0
0x00000000 0 Reset
AES_INT_ENA Set this bit to 1 to enable AES interrupt and 0 to disable interrupt. (R/W)
18.1 Introduction
The RSA Accelerator provides hardware support for high precision computation used in various RSA asymmetric
cipher algorithms by significantly reducing their software complexity. Compared with RSA algorithms
implemented solely in software, this hardware accelerator can speed up RSA algorithms significantly. Besides,
the RSA Accelerator also supports operands of different lengths, which provides more flexibility during the
computation.
18.2 Features
The following functionality is supported:
• Large-number multiplication
The RSA Accelerator is only available after the RSA-related memories are initialized. The content of the
RSA_CLEAN_REG register is 0 during initialization and will become 1 after the initialization is done. Therefore, it is
advised to wait until RSA_CLEAN_REG becomes 1 before using the RSA Accelerator.
Notice:
ESP32-S2’s Digital Signature (DS) module also calls the RSA accelerator. Therefore, users cannot access the
RSA accelerator when Digital Signature (DS) is working.
RSA Accelerator supports operands of length N = 32 × x, where x ∈ {1, 2, 3, . . . , 128}. The bit lengths of
arguments Z, X, Y , M , and r can be arbitrary N, but all numbers in a calculation must be of the same length.
The bit length of M ′ must be 32.
To represent the numbers used as operands, let us define a base-b positional notation, as follows:
b = 232
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.
The following equation in the form compatible with the extended binary GCD algorithm can be written as�
M −1 × M + 1 = R × R−1
M ′ = M −1 mod b
(c) Configure registers related to the acceleration options, which are described later in Section 18.3.4.
Users need to write data to each memory block only according to the length of the number; data beyond
this length are ignored.
5. Wait for the completion of computation, which happens when the content of RSA_IDLE_REG becomes 1
or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT_REG to clear the interrupt, if you have enabled the interrupt function.
After the computation, the RSA_MODE_REG register, memory blocks RSA_Y_MEM and RSA_M_MEM, as well
as the RSA_M_PRIME_REG remain unchanged. However, Xi in RSA_X_MEM and ri in RSA_Z_MEM
computation are overwritten, and only these overwritten memory blocks need to be re-initialized before starting
another computation.
The RSA Accelerator supports large-number modular multiplication with operands of 128 different lengths.
Users need to write data to each memory block only according to the length of the number; data beyond
this length are ignored.
5. Wait for the completion of computation, which happens when the content of RSA_IDLE_REG becomes 1
or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT_REG to clear the interrupt, if you have enabled the interrupt function.
After the computation, the length of operands in RSA_MODE_REG, the Xi in memory RSA_X_MEM, the Yi in
memory RSA_Y_MEM, the Mi in memory RSA_M_MEM, and the M ′ in memory RSA_M_PRIME_REG remain
unchanged. However, the ri in memory RSA_Z_MEM has already been overwritten, and only this overwritten
memory block needs to be re-initialized before starting another computation.
3. Write Xi and Yi for ∈ {0, 1, . . . , n} to registers RSA_X_MEM and RSA_Z_MEM. The capacity of each
memory block is 128 words. Each word of each memory block can store one base-b digit. The memory
blocks use the little endian format for storage, i.e. the least significant digit of each number is in the lowest
N
address. n is 32 .
Write Xi for i ∈ {0, 1, . . . , n} to the address of the i words of the RSA_X_MEM register. Note that Yi for
i ∈ {0, 1, . . . , n} will not be written to the address of the i words of the RSA_Z_MEM register, but the
address of the n + i words, i.e. the base address of the RSA_Z_MEM memory plus the address offset
4 × (n + i).
Users need to write data to each memory block only according to the length of the number; data beyond
this length are ignored.
5. Wait for the completion of computation, which happens when the content of RSA_IDLE_REG becomes 1
or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT_REG to clear the interrupt, if you have enabled the interrupt function.
After the computation, the length of operands in RSA_MODE_REG and the Xi in memory RSA_X_MEM remain
unchanged. However, the Yi in memory RSA_Z_MEM has already been overwritten, and only this overwritten
memory block needs to be re-initialized before starting another computation.
When neither of these two options are enabled, the time required to calculate Z = X Y mod M is solely
determined by the lengths of operands. However, when either one of these two options is enabled, the time
required is also correlated with the 0/1 distribution of Y .
where,
• N is the length of Y ,
• Yet is 1,
• and Yet−1 , Yet−2 , …, Ye0 are either 0 or 1 but exactly m bits should be equal to 0 and t-m bits 1, i.e. the
Hamming weight of Yet−1 Yet−2 , · · · , Ye0 is t − m.
• SEARCH Option
– The accelerator ignores the bit positions of Yei , where i > α. Search position α is set by configuring
the RSA_SEARCH_POS_REG register. The maximum value of α is N -1, which leads to the same
result when this accleration option is disabled. The best acceleration performance can be achieved by
setting α to t, in which case, all the YeN −1 , YeN −2 , …, Yet+1 of 0s are ignored during the calculation.
Note that if you set α to be less than t, then the result of the modular exponentiation Z = X Y mod M
will be incorrect.
• CONSTANT_TIME Option
– The accelerator speeds up the calculation by simplifying the calculation concerning the 0 bits of Y .
Therefore, the higher the proportion of bits 0 against bits 1, the better the acceleration performance is.
We provide an example to demonstrate the performance of the RSA Accelerator when different acceleration
options are enabled. Here we perform Z = X Y mod M with N = 3072 and Y = 65537. Table 114 below
demonstrates the time costs when different acceleration options are enabled. It’s obvious that the time cost can
be dramatically reduced when acceleration option(s) is enabled. Here, we should also mention that, α is set to 16
when the SEARCH option is enabled.
18.7 Registers
Register 18.1: RSA_M_PRIME_REG (0x800)
31 0
0x000000000 Reset
DE
d)
O
ve
M
r
A_
se
RS
(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 0 0 0 0 0 0 0 Reset
N
EA
d )
CL
ve
er
A_
s
RS
(re
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 The content of this bit is 1 when memories complete initialization. (RO)
O
ed
M
rv
A_
se
RS
(re
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
AR
ST
T_
UL
DM
d)
O
ve
M
er
A_
s
RS
(re
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
AR
ST
T_
UL
d )
ve
M
r
A_
se
RS
(re
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
d)
ve
ID
r
A_
se
RS
(re
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_IDLE The content of this bit is 1 when the RSA accelerator is idle. (RO)
CL
rv
A_
se
RS
(re
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
M
TI
_
NT
TA
NS
d)
CO
ve
er
A_
s
RS
(re
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
RSA_CONSTANT_TIME_REG Set this bit to 0 to enable the acceleration option of constant_time for
modular exponentiation. Set to 1 to disable the acceleration (by default). (R/W)
E
BL
NA
_E
CH
AR
d )
SE
ve
er
A_
s
RS
(re
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_SEARCH_ENABLE Set this bit to 1 to enable the acceleration option of search for modular
exponentiation. Set to 0 to disable the acceleration (by default). (R/W)
SE
rv
A_
se
RS
(re
31 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
RSA_SEARCH_POS Is used to configure the starting address when the acceleration option of search
is used. (R/W)
NA
_E
T
UP
RR
TE
d)
ve
IN
er
A_
s
RS
(re
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
RSA_INTERRUPT_ENA Set this bit to 1 to enable the RSA interrupt. This option is enabled by default.
(R/W)
TE
)
ed
DA
rv
A_
se
RS
(re
31 30 29 0
0 0 0x20190425 Reset
19.1 Overview
The Hash-based Message Authentication Code (HMAC) module computes Message Authentication Codes
(MACs) through Hash algorithms and keys as described in RFC 2104. The underlying hash algorithm is
SHA-256, and the 256-bit HMAC key is stored in an eFuse key block and can be configured as not readable by
users.
The HMAC module can be used in two modes - in ”upstream” mode the HMAC message is supplied by the user
and the calculation result is read back by the user. In ”downstream” mode the HMAC module is used as a Key
Derivation Function (KDF) for other internal hardwares.
• The hash result is only accessible by the configurable hardware peripheral (downstream mode)
This allows the key stored in eFuse (can be configured as not readable by users) to become a shared secret
between the user and another party. Any challenge-response protocol that supports HMAC-SHA-256 can be
used in this way.
• A sends M to B
1. A 256-bit HMAC key is randomly generated and is programmed to an eFuse key block with corresponding
purpose eFuse set to EFUSE_KEY_PURPOSE_HMAC_UP. See Chapter 4 for details.
2. Configure the eFuse key block to be read protected, so users cannot read back the value. A copy of this
secret key should be kept by any other party that wants to authenticate this device.
To calculate an HMAC:
2. User writes the correctly padded message to the peripheral, one block at a time.
The HMAC peripheral can be used to re-enable JTAG when EFUSE_SOFT_DIS_JTAG is programmed.
1. A 256-bit HMAC key is randomly generated and is programmed to an eFuse key block with purpose set to
either EFUSE_KEY_PURPOSE_HMAC_DOWN_JTAG or EFUSE_KEY_PURPOSE_HMAC_DOWN_ALL. In
the latter case, the same key can be used for both DS and JTAG re-enable functions.
2. Configure the eFuse key block to be read protected, so users cannot read back the value. User stores the
randomly generated HMAC key in the process securely elsewhere.
To re-enable JTAG:
1. User performs HMAC calculation on the 32-byte 0x00 locally using SHA-256 and the known random key,
and inputs this pre-calculated value into the registers
SYSTEM_CANCEL_EFUSE_DISABLE_JTAG_TEMPORARY_0 ~
SYSTEM_CANCEL_EFUSE_DISABLE_JTAG_TEMPORARY_7.
2. User enables the HMAC module, and enters downstream JTAG enable mode.
3. If the HMAC calculated result matches the value supplied in the registers
SYSTEM_CANCEL_EFUSE_DISABLE_JTAG_TEMPORARY_0 ~
SYSTEM_CANCEL_EFUSE_DISABLE_JTAG_TEMPORARY_7, JTAG is re-enabled. Otherwise, JTAG
remains disabled.
4. JTAG remains the status in step 3 until the user writes 1 in register HMAC_SET_INVALIDATE_JTAG_REG,
or restarts the system.
1. A 256-bit HMAC key is randomly generated and is programmed to an eFuse key block with purpose set to
either EFUSE_KEY_PURPOSE_HMAC_DOWN_DIGITAL_SIGNATURE or
EFUSE_KEY_PURPOSE_HMAC_DOWN_ALL. In the latter case, the same key can be used for both DS
and JTAG re-enable functions.
2. Configure the eFuse key block to be read protected, so users cannot read back the value. If necessary a
copy of the key can also be stored in a secure location.
Before using the DS module, users needs to enable the calculation task of HMAC module’s downstream DS
mode. The above calculation result will be used as the key when the DS mode performs the calculation task.
Consult the 20 chapter for details.
Currently, HMAC module supports three functions: JTAG re-enable in downstream mode, DS Key Derivation in
downstream mode, and HMAC calculation in upstream mode. Table 118 lists the configuration register value
corresponding to each function. The values corresponding to the function in use should be written into the
register HMAC_SET_PARA_PURPOSE_REG (see Section 19.3.5).
The eFuse controller provides six key blocks, KEY0 ~ 5. To select a particular KEYn for HMAC module use at
runtime, user writes the number n into register HMAC_SET_PARA_KEY_REG.
Note that the purpose of the key is also programmed into eFuse memory. Only when the configured HMAC
purpose matches the purpose defined in KEYn, will the HMAC module execute the configured
computation.
For example, suppose the user selects KEY3 for the computation, and the value programmed in
KEY_PURPOSE_3 is 6 (EFUSE_KEY_PURPOSE_HMAC_DOWN_JTAG). Based on Table 118, KEY3 is the key
used for JTAG restart. If the configured value of HMAC_SET_PARA_PURPOSE_REG is also 6, then the HMAC
peripheral will allow the JTAG start the computation of JTAG re-enable.
(a) Enable the peripheral clock bits for HMAC and SHA peripherals, and clear the corresponding
peripheral reset bits.
(b) Select KEYn of eFuse memory as the key by writing n into register HMAC_SET_PARA_KEY_REG (n in
the range of 0 to 5). Refer to Section 19.3.4.
(d) Read register HMAC_QUERY_ERROR_REG. Value of 1 means the selected key block does not
match the configured key purpose, and computation will not proceed. Value of 0 means the selected
key block matches the configured key purpose, and computation can proceed.
(e) Setting HMAC_SET_PARA_PURPOSE_REG to values other than 8 means HMAC module will operate
in downstream mode, proceed with Step 3. Setting value 8 means HMAC module will operate in
upstream mode, proceed with Step 4.
3. Downstream Mode
(a) Poll state register HMAC_QUERY_BUSY_REG. The register value of 0 means HMAC computation in
downstream mode is finished.
(b) In downstream mode, the result is used by JTAG module or DS module in the hardware. Users can
write 1 into register HMAC_SET_INVALIDATE_JTAG_REG to clean the result generated by JTAG key;
or can write 1 into register HMAC_SET_INVALIDATE_DS_REG to clean the result generated by digital
signature key.
(a) Poll state register HMAC_QUERY_BUSY_REG. Go to the next step when the value of the register is 0.
(b) Write 512-bit message block Block_n into register range HMAC_WDATA0~15_REG. Then write 1 in
register HMAC_SET_MESSAGE_ONE_REG, and HMAC module will compute this message block.
(c) Poll state register HMAC_QUERY_BUSY_REG. Go to the next step when the value of the register is 0.
(d) Subsequent message blocks are different, depending on whether the size of to-be-processed data is
a multiple of 512 bits.
• If the bit length of the message is a multiple of 512, there are three possible options:
ii. If Block_n is the last block of the message, and user wishes to apply SHA padding through
hardware, write 1 in register HMAC_SET_MESSAGE_END_REG, then jump to step 6.
iii. If Block_n is the last block of the padded message, and the user has applied SHA padding in
software, write 1 in register HMAC_SET_MESSAGE_PAD_REG, and jump to step 5.
• If the bit length of the message is not a multiple of 512, there are three possible options. Note that
in this case the user is required to apply SHA padding to the message, after which the padded
message length will be a multiple of 512 bits.
i. If Block_n is the only message block, n = 1, and Block_1 has included all padding bits, write
1 in register HMAC_ONE_BLOCK_REG, and then jump to step 6.
ii. If Block_n is the second last block of the padded message, write 1 in register
HMAC_SET_MESSAGE_PAD_REG, and jump to step 5.
iii. If Block_n is neither the last nor the second last message block, write 1 in register
HMAC_SET_MESSAGE_ING_REG and make n = n + 1, then jump to step 4.(b).
(a) Users apply SHA padding to the final message block as described in Section 19.4.1, Write this block
in register HMAC_WDATA0~15_REG, then write 1 in register HMAC_SET_MESSAGE_ONE_REG.
HMAC module will compute the message block.
(a) Poll state register HMAC_QUERY_BUSY_REG. Go to the next step when the value of the register is 0.
Note:
The SHA accelerator can be called directly, or used internally by the DS module and the HMAC module. However, they
can not share the hardware resources simultaneously. Therefore, SHA module can not be called by CPU or DS module
when HMAC module is in use.
As shown in Figure 19-1, suppose the length of the unpadded message is m bits. Padding steps are as
follows:
2. Append k bits of value “0”, where k is the smallest non-negative number which satisfies
m + 1 + k≡448(mod512);
3. Append a 64-bit integer value as a binary block. The content of this block is the length of the the unpadded
message as a big-endian binary integer value m.
In downstream mode, there is no need for users to input any message data or apply padding. In upstream
mode, if the total number of bits in the unpadded message is a multiple of 512, users can choose to configure
hardware to apply SHA padding. If the total number of bits in the unpadded message is not a multiple of 512,
SHA padding must be applied by the user. See Section 19.3.5 for the steps involved.
In Figure 19-2,
HMAC module appends 256-bit 0 sequence after the bit sequence of 256-bit key k, and gets 512-bit K0 .
Afterwards, HMAC module XORs K0 with ipad to get 512-bit S1. Then, HMAC module appends the input
message which is a multiple of 512 after 512-bit S1, and processes SHA-256 algorithm to get 256-bit H1.
HMAC module appends the 256-bit SHA-256 hash result to the 512-bit S2 value, which is calculated by XOR
between K0 and opad, this produces a 768-bit sequence. Then, HMAC module uses SHA padding algorithm
described in Section 19.4.1 to pad 768-bit sequence into 1024-bit sequence, and applies SHA-256 algorithm to
get the final hash result.
Memory.
19.7 Registers
Register 19.1: HMAC_SET_START_REG (0x0040)
RT
TA
_S
ET
d)
_S
e
rv
AC
se
HM
(re
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
rv
AC
se
HM
(re
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
NE
_O
XT
E
_T
ET
d)
_S
ve
AC
r
se
HM
(re
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
G
_IN
XT
E
_T
ET
d)
_S
ve
AC
r
se
HM
(re
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
HMAC_SET_TEXT_ING Set this bit to show there are still some message blocks to be processed.
(WO)
D
_EN
XT
E
_T
ET
)
_S
ed
rv
AC
se
HM
(re
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
D
_ EN
LT
ESU
_R
ET
d)
_S
ve
AC
r
se
HM
(re
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
HMAC_SET_RESULT_END Set this bit to end upstream and clear the calculation result. (WO)
G
TA
_J
E
AT
ID
AL
NV
_I
ET
)
_S
d
ve
AC
r
se
HM
(re
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
HMAC_SET_INVALIDATE_JTAG Set this bit to clear calculation results in JTAG re-enable function
under downstream mode. (WO)
S
E_D
AT
D
LI
VA
N
_I
ET
)
_S
ed
rv
AC
se
HM
(re
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
HMAC_SET_INVALIDATE_DS Set this bit to clear calculation results in DS function under down-
stream mode. (WO)
CK
HE
_C
EY
UR
)
_Q
ed
rv
AC
se
HM
(re
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
HMAC_QUREY_CHECK HMAC error status. 0: HMAC key and purpose match. 1: error. (RO)
E
AT
ST
Y_
US
)
_B
d
ve
AC
r
se
HM
(re
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
ET
_S
SE
PO
UR
d)
_P
e
rv
AC
se
HM
(re
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
_K
ed
rv
AC
se
HM
(re
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
0_
TA
DA
_W
AC
HM
31 0
0 Reset
_0
TA
DA
_R
AC
HM
31 0
0 Reset
D
_ PA
XT
E
_T
ET
d)
_S
ve
AC
r
se
HM
(re
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
ed
rv
AC
se
HM
(re
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
AT
d)
_D
ve
AC
r
se
HM
(re
31 30 29 0
0 0 0x20190402 Reset
20.1 Overview
Digital signatures provide a way to cryptographically authenticate a message using a private key, to be verified
using the corresponding public key. This can be used to validate a device’s identity to a server, or to authenticate
the integrity of a message has not been tampered with.
ESP32-S2 includes a digital signature (DS) peripheral which produces hardware accelerated RSA digital
signatures, while the RSA private key is not accessible by users.
20.2 Features
• RSA Digital Signatures with key lengths up to 4096 bits
• SHA-256 digest is used to protect private key data against tampering by an attacker
Private key parameters are stored in flash or another form of storage, in an encrypted form. They are encrypted
using a key which can only be read by the DS peripheral via the HMAC peripheral. The required inputs to
generate the key are stored in eFuse and can only be accessed by the HMAC peripheral. This means that only
the DS peripheral hardware can decrypt the private key, and the plaintext private key data is never accessible by
users.
The input message X is input directly to the DS peripheral by software, each time a signature is needed. After
the operation, the signature Z is read back by software.
Two additional private key operands are needed — r and M ′ . These two operands are derived from Y and M ,
but they are calculated in advance by software.
Operands Y , M , r, and M ′ are encrypted by the user along with an authentication digest and stored as a single
ciphertext C. C is input to the DS peripheral in this encrypted format, then the hardware decrypts C and uses the
key data to generate the signature. Detailed description of the encryption process to prepare C is provided in
Section 20.3.4.
The DS peripheral needs to activate RSA to perform Z = X Y mod M . For detailed information on the RSA
algorithm, please refer to Section 18.3.1 Large Number Modular Exponentiation in Chapter 18 RSA Accelerator
(RSA).
20.3.3 Conventions
The following sections of this chapter will use the following symbols and functions:
• [x]s A bit string of length s bits. If x is a number (x < 2s ), it is represented in little endian byte order in
the bit string. x may be a variable value such as [Y ]4096 or as a hexadecimal constant such as [0x0C]8 . If
necessary, the value [x] is right-padded with 0s to reach s bits in length. For example: [0x5]4 = 0101,
[0x5]8 = 00000101, [0x5]16 = 0000010100000000, [0x13]8 = 00010011, [0x13]16 = 0001001100000000.
• || A bit string concatenation operator for joining multiple bit strings into a longer bit string.
• Generate the RSA private key (Y , M ) and associated operands r and M ′ , as described in Section 20.3.2.
• Generate a 256-bit HMAC key ([HM AC_KEY ]256 ) that is stored in eFuse. This HMAC key is read by the
HMAC peripheral to derive a key, as DS_KEY = HMAC-SHA256([HM AC_KEY ]256 , 1256 ). This key is
used to securely encrypt and decrypt the stored RSA private key data. For more information, please refer
to Chapter 19 HMAC Accelerator (HMAC).
Figure 20-1 below describes the preparations at the software level (the left part) and the DS peripheral operation
at the hardware level (the right part).
Users need to follow the steps shown in the left part of Figure 20-1 to calculate C. Detailed instructions are as
follows:
N
• Step 1: Prepare Y and M whose lengths should meet the aforementioned requirements. Define [L]32 = 32
(i.e., for RSA 4096, [L]32 == [0x80]32 ). Prepare [DS_KEY ]256 and generate a random [IV ]128 which
should meet the requirements of the AES-CBC block encryption algorithm. For more information on AES,
please refer to Chapter 17 AES Accelerator (AES).
• Step 3: Extend Y , M , and r, in order to get [Y ]4096 , [M ]4096 , and [r]4096 , respectively. Since the largest
operand length for Y , M , and r is 4096 bits, this step is only required for lengths smaller than 4096 bits.
[M D]256 = SHA256 ( [Y ]4096 ||[M ]4096 ||[r]4096 ||[M ′ ]32 ||[L]32 ||[IV ]128 )
• Step 5: Build [P ]12672 = ( [Y ]4096 ||[M ]4096 ||[r]4096 ||[M D]256 ||[M ′ ]32 ||[L]32 ||[β]64 ), where [β]64 is a PKCS#7
padding value, i.e., a 64-bit string [0x0808080808080808]64 that is composed of eight bytes (value =
0x08). The purpose of [β]64 is to make the bit length of P a multiple of 128.
• Step 6: Calculate C = [C]12672 = AES-CBC-ENC ([P ]12672 , [DS_KEY ]256 , [IV ]128 ), where C is the
ciphertext that includes RSA operands Y , M , r, M ′ , and L as well as the MD authentication code and
[β]64 . DS_KEY is derived from the HM AC_KEY stored in eFuse, as described above in Section 20.3.4.
The DS operation at the hardware level is a reverse process of preparing C described in Section 20.3.4. The
hardware operation can be divided into the following three stages.
The decryption process is the reverse of Step 6. The DS peripheral will call AES accelerator to decrypt C in
CBC block mode and get the resulted plaintext. The decryption process can be represented by P =
AES-CBC-DEC (C, DS_KEY , IV ), where IV (i.e., [IV ]128 ) is defined by users. [DS_KEY ]256 is provided
by HMAC module, derived from HM AC_KEY stored in eFuse. [DS_KEY ]256 is not readable by
software. Please refer to Chapter 19 HMAC Accelerator (HMAC) for more information.
With P , the DS peripheral can work out [Y ]4096 , [M ]4096 , [r]4096 , [M ′ ]32 , [L]32 , MD authentication code,
and the padding value [β]64 . This process is the reverse of Step 5.
The DS peripheral will perform two check operations: MD check and padding check. Padding check is not
shown in Figure 20-1, as it happens at the same time with MD check.
• MD check: The DS peripheral calls SHA-256 to get the hash value [CALC_M D]256 . This step is the
reverse of Step 4. Then, [CALC_M D]256 is compared against [M D]256 . Only when the two match,
MD check passes.
• Padding check: The DS peripheral checks if [β]64 complies with the aforementioned PKCS#7 format.
Only when [β]64 complies with the format, padding check passes.
If MD check passes, the DS peripheral will perform subsequent operations, otherwise, it will not. If padding
check fails, an error bit is set in the query register, but it does not affect the subsequent operations.
The DS peripheral treats X, Y , M , and r as big numbers. With M ′ , all operands to perform X Y mod M
are in place. The operand length is defined by L. The DS peripheral will get the signed result Z by calling
RSA to perform Z = X Y mod M .
If DS_QUERY_BUSY_REG does not read 0 after approximately 1 ms, it indicates a problem with HMAC
initialization. In such case, software can read register DS_QUERY_KEY_WRONG_REG to get more
information.
• If DS_QUERY_KEY_WRONG_REG reads any value from 1 to 15, it indicates that HMAC was
activated, but the DS peripheral did not successfully receive the DS_KEY value from the HMAC
peripheral. This may indicate that the HMAC operation was interrupted due to a software concurrency
problem.
3. Configure register: Write IV block to register DS_IV_m_REG (m: 0-3). For more information on IV block,
please refer to Chapter 17 AES Accelerator (AES).
4. Write X to memory block DS_X_MEM: Write Xi (i ∈ [0, n) ∩ N) to memory block DS_X_MEM whose
capacity is 128 words. Each word can store one base-b digit. The memory block uses the little endian
format for storage, i.e., the least significant digit of the operand is in the lowest address. Words in
DS_X_MEM block after the configured length of X (N bits, as described in Section 20.3.2) are ignored.
5. Write C to memory block DS_C_MEM: Write Ci (i ∈ [0, 396) ∩ N) to memory block DS_C_MEM whose
capacity is 396 words. Each word can store one base-b digit.
7. Wait for the operation to be completed: Poll register DS_QUERY_BUSY_REG until it reads 0.
8. Query check result: Read register DS_QUERY_CHECK_REG and determine the subsequent operations
based on the return value.
• If the value is 0, it indicates that both padding check and MD check pass. Users can continue to get
the signed result Z.
• If the value is 1, it indicates that the padding check passes but MD check fails. The signed result Z is
invalid. The operation would resume directly from Step 10.
• If the value is 2, it indicates that the padding check fails but MD check passes. Users can continue to
get the signed result Z.
• If the value is 3, it indicates that both padding check and MD check fail. The signed result Z is invalid.
The operation would resume directly from Step 10.
9. Read the signed result: Read the signed result Zi (i ∈ {0, 1, 2..., n}) from memory block DS_Z_MEM. The
memory block stores Z in little-endian byte order.
10. Exit the operation: Write 1 to DS_SET_FINISH_REG, then poll DS_QUERY_BUSY_REG until it reads 0.
After the operation, all the input/output registers and memory blocks are cleared.
20.7 Registers
Register 20.1: DS_IV_m_REG (m: 03) (0x0630+4*m)
31 0
0x000000000 Reset
R T
TA
_S
d)
ET
e
rv
_S
se
DS
(re
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
_M
d)
ET
ve
_S
r
se
DS
(re
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
ET
rv
_S
se
DS
(re
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
SY
_ BU
RY
d)
UE
ve
Q
r
se
_
DS
(re
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
NG
RO
W
Y_
_ KE
RY
)
ed
UE
rv
_Q
se
DS
(re
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 0x0 Reset
DS_QUERY_KEY_WRONG 1-15: HMAC was activated, but the DS peripheral did not successfully
receive the DS_KEY value from the HMAC peripheral. The biggest value is 15. 0: HMAC is not
activated. (RO)
RO AD
ER _B
R
D_ NG
_M DI
d)
DS PAD
e
rv
se
_
DS
(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
DS_PADDING_BAD 1: The padding check fails; 0: The padding check passes. (RO)
E
ed
AT
rv
_D
se
DS
(re
31 30 29 0
0 0 0x20190418 Reset
21.1 Overview
The ESP32-S2 SoC implements an External Memory Encryption and Decryption module that secures users’
application code and data stored in the external memory (flash and external RAM). The encryption and
decryption algorithm complies with the XTS-AES standard specified in IEEE Std 1619-2007. Users can store
proprietary firmware and sensitive data (for example credentials for gaining access to a private network) to the
external flash, and general data to the external RAM.
21.2 Features
• General XTS-AES algorithm, compliant with IEEE Std 1619-2007
• Encryption and decryption functions jointly determined by register configuration, eFuse parameters, and
boot mode
Figure 211. Architecture of the External Memory Encryption and Decryption Module
The Manual Encryption block can encrypt instructions and data which will then be written to the external flash as
ciphertext through SPI1.
When the CPU writes the external RAM through cache, the Auto Encryption block automatically encrypts the
data first, and the data is written to the external RAM as ciphertext.
When the CPU reads the external flash or RAM through cache, the Auto Decryption block automatically decrypts
the ciphertext to retrieve instructions and data.
• SYSTEM_ENABLE_DOWNLOAD_MANUAL_ENCRYPT
• SYSTEM_ENABLE_DOWNLOAD_G0CB_DECRYPT
• SYSTEM_ENABLE_DOWNLOAD_DB_ENCRYPT
• SYSTEM_ENABLE_SPI_MANUAL_ENCRYPT
The External Memory Encryption and Decryption module fetches two parameters from the peripheral eFuse
Controller. These parameters are: EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT and
EFUSE_SPI_BOOT_CRYPT_CNT.
21.3.2 Key
The Manual Encryption block, Auto Encryption block, and Auto Decryption block share the same key to perform
XTS algorithm. The key is provided by the eFuse hardware and protected from user access.
The key can be either 256 bits or 512 bits long. The key is determined by the content in one or two eFuse blocks
from BLOCK4 ~ BLOCK9. For easy description, define:
• BlockA , which refers to the block that has the key purpose set to
EFUSE_KEY_PURPOSE_XTS_AES_256_KEY_1. BlockA contains 256-bit KeyA .
• BlockB , which refers to the block that has the key purpose set to
EFUSE_KEY_PURPOSE_XTS_AES_256_KEY_2. BlockB contains 256-bit KeyB .
• BlockC , which refers to the block that has the key purpose set to
EFUSE_KEY_PURPOSE_XTS_AES_128_KEY. BlockC contains 256-bit KeyC .
Table 124 shows how the Key is generated, depending on whether BlockA , BlockB , and BlockC exists or
not.
“Yes” indicates that the block exists; “No” indicates that the block does not exist; “0256 ” indicates a bit string that
consists of 256-bit zeros; “||” is a bonding operator for joining one key string to another.
For more information on setting of key purposes, please refer to Chapter 4 eFuse Controller (eFuse).
• type: the type of the external memory, either flash or external RAM. Value 0 indicates flash, 1 indicates
external RAM.
• size: the size of the target memory space, in unit of bytes. One single encryption operation supports either
16, 32, or 64 bytes of data.
• base_addr: the base address of the target memory space. It is a physical address aligned to size, i.e.,
base_addr%size == 0.
Assume encrypted 16 bytes written to address 0x130 ~ 0x13F in the external flash, then, the target memory
space is 0x130 ~ 0x13F, type is 0 (flash), size is 16 (bytes), and base_addr 0x130.
The encryption of any length (must be multiples of 16 bytes) of data can be completed separately in multiple
operations. Each operation can have individual target memory space and the relevant parameters.
For auto encryption and auto decryption, these parameters are automatically defined by hardware. For manual
encryption, these parameters should be configured manually by users.
Actually, the Manual Encryption block does not care where the plaintext comes from, but only where the
ciphertext is to be stored. Because of the strict correspondence between plaintext and ciphertext, in order to
better describe how the plaintext is stored in the register heap, it is assumed that the plaintext is stored in the
target memory space in the first place and replaced by ciphertext after encryption. Therefore, the following
description no longer has the concept of “plaintext”, but uses “target memory space” instead. However, users
should note that the plaintext can come from anywhere, and that they should understand how the plaintext is
stored in the register heap.
For example, if the size of the target memory space is 64, then all the 16 registers will be used for data storage.
The mapping between of f set and registers is shown in Table 125.
The manual encryption requires software participation. The steps are as follows:
1. Configure XTS_AES:
2. Fill registers XTS_AES_PLAIN_n_REG (n: 0-15) in with plaintext (refer to Section 21.3.4). Registers that are
not used can be written into any value.
3. Poll XTS_AES_STATE_REG until it reads 0 that indicates the Manual Encryption block is idle.
5. Wait for the encryption to complete. Poll register XTS_AES_STATE_REG until it reads 2.
Steps 1 ~ 5 complete the encryption operation, where Key is used.
7. Call SPI1 and write the encrypted result to the external flash.
The Manual Encryption block is operational only with granted permission. The operating conditions
are:
Note:
• Even though the CPU can skip cache and get the encrypted result directly by reading the external memory, users
can by no means access Key.
• The Manual Encryption block needs to call the AES accelerator to perform encryption. Therefore, users cannot
access AES accelerator during the process.
The Auto Encryption block is operational only with granted permission. The operating conditions are:
Note:
• When the Auto Encryption block is operational, the CPU will read data from the external RAM via the cache. The
Auto Encryption block automatically encrypts the data and writes it to the external RAM. The entire encryption
process does not need software participation and is transparent to the cache. Users cannot access the encryption
Key.
• When the Auto Encryption block is not operational, it will ignore the CPU’s request to access cache and do not
process the data. Therefore, data will be written to the external RAM as plaintext.
The Auto Decryption block is operational only with granted permission. The operating conditions are:
If the 3-bit parameter SPI_BOOT_CRYPT_CNT has 1 or 3 bits set to 1, then the Auto Decryption block is
granted permission. Otherwise, it is not operational.
Note:
• When the Auto Decryption block is operational, the CPU will read instructions and data from the external memory
via cache. The Auto Decryption block automatically decrypts and retrieves the instructions and data. The entire
decryption process does not need software participation and is transparent to the cache. Users cannot access the
decryption Key.
• When the Auto Decryption block is not operational, it does not have any effect on the contents stored in the external
memory, be they encrypted or unencrypted. What the CPU reads via cache is the original information stored in the
external memory.
21.6 Registers
Register 21.1: XTS_AES_PLAIN_n_REG (n: 015) (0x0100+4*n)
n
N_
AI
PL
S_
AE
S_
XT
31 0
0x000000 Reset
AE
e
rv
S_
se
XT
(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 0x0 Reset
XTS_AES_LINESIZE Configures the data size of a single encryption. 0: 128 bits; 1: 256 bits; 2: 512
bits. (R/W)
N
O
TI
NA
TI
S
DE
S_
d)
E
ve
_A
r
se
S
XT
(re
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
XTS_AES_DESTINATION Configures the type of the external memory. Currently, it must be set to 0,
as the Manual Encryption block only supports flash encryption. Errors may occur if users write 1.
0: flash; 1: external RAM. (R/W)
SS
RE
DD
_A
AL
IC
YS
PH
S_
d)
AE
e
rv
S_
se
XT
(re
31 30 29 0
0 0 0x000000 Reset
ER
G
G
RI
_T
d)
ES
e
rv
_A
se
S
XT
(re
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
SE
EA
L
RE
S_
)
ed
E
rv
_A
se
S
XT
(re
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
Y
RO
ST
DE
S_
d)
AE
r ve
S_
se
XT
(re
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
AT
ST
S_
)
ed
AE
rv
S_
se
XT
(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 0x0 Reset
• 0x2 (XTS_AES_DONE): encryption is completed, but the encrypted result is not accessible to
SPI;
TE
DA
S_
d)
AE
r ve
S_
se
XT
(re
31 30 29 0
0 0 0x20190514 Reset
22.1 Introduction
The ESP32-S2 contains a true random number generator, which generates 32-bit random numbers that can be
used for cryptographical operations, among other things.
22.2 Features
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.
When the RC_FAST_CLK clock is enabled for the digital core, the random number generator will also sample
RC_FAST_CLK (8 MHz) as a random bit seed. RC_FAST_CLK is an asynchronous clock source and it increases
the RNG entropy by introducing circuit metastability. However, to ensure maximum entropy, it’s recommended to
always enable an ADC source as well.
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 6 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.
• SAR ADC can be enabled by using the DIG ADC controller. For details, please refer to Chapter 32 On-Chip
Sensor and Analog Signal Processing.
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 22.3 above.
22.7 Register
The address in this section is relative to the random number generator base addresses provided in Section
22.5.
31 0
0x00000000 Reset
23.1 Overview
In embedded system applications, data is required to be transferred in a simple way with minimal system
resources. This can be achieved by a Universal Asynchronous Receiver/Transmitter (UART), which flexibly
exchanges data with other peripheral devices in full-duplex mode. ESP32-S2 has two UART controllers
compatible with various UART devices. They support Infrared Data Association (IrDA) and RS485
transmission.
ESP32-S2 has two UART controllers. Each has a group of registers that function identically. In this chapter, the
two UART controllers are referred to as UARTn, in which n denotes 0 or 1.
23.2 Features
Each UART controller has the following features:
• 512 x 8-bit RAM shared by TX FIFOs and RX FIFOs of two UART controllers
• Parity bits
• RS485 protocol
• IrDA protocol
A UART data packet usually begins with one start bit, followed by data bits, one parity bit (optional) and one or
more stop bits. UART controllers on ESP32-S2 support various lengths of data bits and stop bits. These
controllers also support software and hardware flow control as well as DMA for seamless high-speed data
transfer. This allows developers to use multiple UART ports at minimal software cost.
A UART controller is broken down into two parts according to functions: a transmitter and a receiver.
The transmitter contains a TX FIFO, which buffers data to be sent. Software can write data to Tx_FIFO via the
APB bus, or move data to Tx_FIFO using DMA. Tx_FIFO_Ctrl controls writing and reading Tx_FIFO. When
Tx_FIFO is not empty, Tx_FSM reads bytes via Tx_FIFO_Ctrl, and converts them into a bitstream. The levels of
output signal txd_out can be inverted by configuring UART_TXD_INV register.
The receiver contains a RX FIFO, which buffers data to be processed. Software can read data from Rx_FIFO via
the APB bus, or receive data using DMA. The levels of input signal rxd_in can be inverted by configuring
UART_RXD_INV register, and the signal is then input to the Rx components of the UART Controller:
Baudrate_Detect measures the baud rate of input signal rxd_in by detecting its minimum pulse width.
Start_Detect detects the start bit in a data frame. If the start bit is detected, Rx_FSM stores data bits in the data
frame into Rx_FIFO by Rx_FIFO_Ctrl.
HW_Flow_Ctrl controls rxd_in and txd_out data flows by standard UART RTS and CTS flow control signals
(rtsn_out and ctsn_in). SW_Flow_Ctrl controls data flows by automatically adding special characters to outgoing
data and detecting special characters in incoming data. When a UART controller is in Light-sleep mode (see
Chapter 9: Low-Power Management (RTC_CNTL) for more details), Wakeup_Ctrl counts up rising edges of rxd_in.
When the number reaches (UART_ACTIVE_THRESHOLD + 2), a wake_up signal is generated and sent to RTC,
The two UART controllers on ESP32-S2 share 512 × 8 bits of FIFO RAM. As figure 23-2 illustrates, RAM is
divided into 4 blocks, each has 128 × 8 bits. Figure 23-2 shows by default how many RAM blocks are allocated
to TX FIFOs and RX FIFOs of the two UART controllers. UARTn Tx_FIFO can be expanded by configuring
UART_TX_SIZE, while UARTn Rx_FIFO can be expanded by configuring UART_RX_SIZE. The size of UART0
Tx_FIFO can be increased to 4 blocks (the whole RAM), the size of UART1 Tx_FIFO can be increased to 3 blocks
(from offset 128 to the end address), the size of UART0 Rx_FIFO can be increased to 2 blocks (from offset 256 to
the end address), but the size of UART1 Rx_FIFO cannot be increased. Please note that expanding one FIFO
may take up the default space of other FIFOs. For example, by setting UART_TX_SIZE of UART0 to 2, the size of
UART0 Tx_FIFO is increased by 128 bytes (from offset 0 to offset 255). In this case, UART0 Tx_FIFO takes up
the default space for UART1 Tx_FIFO, and UART1’s transmitting function cannot be used as a result.
When neither of the two UART controllers is active, RAM could enter low-power mode by setting
UART_MEM_FORCE_PD.
UART0 Tx_FIFO and UART1 Tx_FIFO are reset by setting UART_TXFIFO_RST. UART0 Rx_FIFO and UART1
Rx_FIFO are reset by setting UART_RXFIFO_RST.
Data to be sent is written to TX FIFO via the APB bus or using DMA, read automatically and converted from a
frame into a bitstream by hardware Tx_FSM; data received is converted from a bitstream into a frame by
hardware Rx_FSM, written into RX FIFO, and then stored into RAM via the APB bus or using DMA. The two
UART controllers share one DMA controller.
The empty signal threshold for Tx_FIFO is configured by setting UART_TXFIFO_EMPTY_THRHD. When data
stored in Tx_FIFO is less than UART_TXFIFO_EMPTY_THRHD, a UART_TXFIFO_EMPTY_INT interrupt is
generated.
The full signal threshold for Rx_FIFO is configured by setting UART_RXFIFO_FULL_THRHD. When data stored in
Rx_FIFO is greater than UART_RXFIFO_FULL_THRHD, a UART_RXFIFO_FULL_INT interrupt is generated. In
addition, when Rx_FIFO receives more data than its capacity, a UART_RXFIFO_OVF_INT interrupt is
generated.
The divisor of the baud rate divider is equal to UART_CLKDIV + (UART_CLKDIV_FRAG / 16), meaning that the
final baud rate is equal to INPUT_FREQ / (UART_CLKDIV + (UART_CLKDIV_FRAG / 16)). For example, if
UART_CLKDIV = 694 and UART_CLKDIV_FRAG = 7 then the divisor value is (694 + 7/16) = 694.4375. If the
input clock frequency is 80MHz APB_CLK, the baud rate will be (80MHz / 69.4375) = 115201.
When UART_CLKDIV_FRAG is zero, the baud rate generator is an integer clock divider where an output pulse is
generated every UART_CLKDIV input pulses.
When UART_CLKDIV_FRAG is not zero, the divider is fractional and the output baud rate clock pulses are not
strictly uniform. As shown in figure 23-3, for every 16 output pulses, the generator divides either (UART_CLKDIV
+ 1) input pulses or UART_CLKDIV input pulses per output pulse. A total of UART_CLKDIV_FRAG output pulses
are generated by dividing (UART_CLKDIV + 1) input pulses, and the remaining (16 - UART_CLKDIV_FRAG)
output pulses are generated by dividing UART_CLKDIV input pulses.
The output pulses are interleaved as shown in figure 23-3 below, to make the output timing more uniform:
To support IrDA (see Section 23.3.7 IrDA for details), the fractional clock divider for IrDA data transmission
generates clock signals divided by 16× UART_CLKDIV_REG. This divider works similarly as the one elaborated
above: it takes UART_CLKDIV/16 as the integer value and the lowest four bits of UART_CLKDIV as the fractional
value.
Before communication starts, the transmitter could send random data to the receiver for baud rate detection.
UART_LOWPULSE_MIN_CNT stores the minimum low pulse width, UART_HIGHPULSE_MIN_CNT stores the
minimum high pulse width, UART_POSEDGE_MIN_CNT stores the minimum pulse width between two rising
edges, and UART_NEGEDGE_MIN_CNT stores the minimum pulse width between two falling edges. These four
Figure 234. The Timing Diagram of Weak UART Signals Along Falling Edges
1. Normally, to avoid sampling erroneous data along rising or falling edges in semi-stable state, which results
in inaccuracy of UART_LOWPULSE_MIN_CNT or UART_HIGHPULSE_MIN_CNT, use a weighted average
of these two values to eliminate errors. In this case, baud rate is calculated as follows:
fclk
Buart =
(UART_LOWPULSE_MIN_CNT + UART_HIGHPULSE_MIN_CNT +2)/2
2. If UART signals are weak along falling edges as shown in figure 23-4, which leads to inaccurate average of
UART_LOWPULSE_MIN_CNT and UART_HIGHPULSE_MIN_CNT, use UART_POSEDGE_MIN_CNT to
determine the transmitter’s baud rate as follows:
fclk
Buart =
(UART_POSEDGE_MIN_CNT + 1)/2
3. If UART signals are weak along rising edges, use UART_NEGEDGE_MIN_CNT to determine the
transmitter’s baud rate as follows:
fclk
Buart =
(UART_NEGEDGE_MIN_CNT + 1)/2
Figure 23-5 shows the basic structure of a data frame. A frame starts with one START bit, and ends with STOP
bits which can be 1, 1.5, 2 or 3 bits long, configured by UART_STOP_BIT_NUM, UART_DL1_EN and
UART_DL0_EN. The START bit is logical low, whereas STOP bits are logical high.
The actual data length can be anywhere between 5 ~ 8 bit, configured by UART_BIT_NUM. When
UART_PARITY_EN is set, a parity bit is added after data bits. UART_PARITY is used to choose even parity or
odd parity. When the receiver detects a parity bit error in data received, a UART_PARITY_ERR_INT interrupt is
generated and data received is still stored into RX FIFO. When the receiver detects a data frame error, a
UART_FRM_ERR_INT interrupt is generated, and data received by default is stored into RX FIFO.
If all data in Tx_FIFO has been sent, a UART_TX_DONE_INT interrupt is generated. After this, if the
UART_TXD_BRK bit is set then the transmitter will send several NULL characters in which the TX data line is
logical low. The number of NULL characters is configured by UART_TX_BRK_NUM. Once the transmitter has
sent all NULL characters, a UART_TX_BRK_DONE_INT interrupt is generated. The minimum interval between
data frames can be configured using UART_TX_IDLE_NUM. If the transmitter stays idle for UART_TX_IDLE_NUM
or more time, a UART_TX_BRK
_IDLE_DONE_INT interrupt is generated.
Figure 23-6 is the structure of a special character AT_CMD. If the receiver constantly receives AT_CMD_CHAR
and the following conditions are met, a UART_AT_CMD_CHAR_DET_INT interrupt is generated.
• The interval between the first AT_CMD_CHAR and the last non AT_CMD_CHAR character is at least UART
_PRE_IDLE_NUM single-bit cycles.
• The interval between two AT_CMD_CHAR characters is less than UART_RX_GAP_TOUT single-bit cycles.
• The interval between the last AT_CMD_CHAR character and next non AT_CMD_CHAR character is at least
UART_POST_IDLE_NUM single-bit cycles.
23.3.6 RS485
The two UART controllers support RS485 standard. This standard uses differential signals to transmit data, so it
can communicate over longer distances at higher bit rates than RS232. RS485 has two-wire half-duplex mode
and four-wire full-duplex mode. UART controllers support two-wire half-duplex transmission and bus snooping.
In a two-wire RS485 multidrop network, there can be 32 slaves at most.
The UART receiver converts differential signals to single-ended signals via an external receiver. RE is the enable
control signal for the receiver. When RE is 0, the receiver is enabled; when RE is 1, the receiver is disabled. If RE
is configured as 0, the UART controller is allowed to snoop data on the bus, including data sent by itself.
DE can be controlled by either software or hardware. To reduce cost of software, in our design DE is controlled
by hardware. As shown in figure 23-7, DE is connected to dtrn_out of UART (please refer to Section23.3.9.1
Hardware Flow Control for more details).
transceiver
The two UART controllers can snoop data sent by themselves. In transmitter mode, when a UART controller
monitors a collision between data sent and data received, a UART_RS485_CLASH_INT is generated; when a
UART controller monitor a data frame error, a UART_RS485_FRM_ERR_INT interrupt is generated; when a UART
controller monitors a polarity error, a UART_RS485_PARITY_ERR_INT is generated.
23.3.7 IrDA
IrDA protocol consists of three layers, namely the physical layer, the link access protocol and the link management
protocol. The two UART controllers implement IrDA physical layer. In IrDA encoding, a UART controller supports
data rates up to 115.2 kbit/s (SIR, or serial infrared mode). As shown in figure 23-8, the IrDA encoder converts a
NRZ (non-return to zero code) signal to a RZI (return to zero code) signal and sends it to the external driver and
infrared LED. This encoder uses modulated signals whose pulse width is 3/16 bits to indicate logic “0”, and low
levels to indicate logic “1”. The IrDA decoder receives signals from the infrared receiver and converts them to
NRZ signals. In most cases, the receiver is high when it is idle, and the encoder output polarity is the opposite of
the decoder input polarity. If a low pulse is detected, it indicates that a start bit has been received.
When IrDA function is enabled, one bit is divided into 16 clock cycles. If the bit to be sent is zero, then the 9th,
10th and 11th clock cycle is high.
Figure 238. The Timing Diagram of Encoding and Decoding in SIR mode
The IrDA transceiver is half-duplex, meaning that it cannot send and receive data simultaneously. As shown in
figure 23-9, IrDA function is enabled by setting UART_IRDA_EN. When UART_IRDA_TX_EN is set (high), the IrDA
transceiver is enabled to send data and not allowed to receive data; when UART_IRDA_TX_EN is reset (low), the
IrDA transceiver is enabled to receive data and not allowed to send data.
23.3.8 Wakeup
UART0 and UART1 can be set as wake-up source. When a UART controller is in Light-sleep mode, Wakeup_Ctrl
counts up the rising edges of rxd_in. When the number of rising edges is greater than
(UART_ACTIVE_THRESHOLD + 2), a wake_up signal is generated and sent to RTC, which then wakes up
ESP32-S2.
When rtsn_out of IU0 is low, EU0 is allowed to send data; when rtsn_out of IU0 is high, EU0 is notified to stop
sending data until rtsn_out of IU0 returns to low. Output signal rtsn_out can be controlled in two ways.
• Software control: Enter this mode by setting UART_RX_FLOW_EN to 0. In this mode, the level of rtsn_out
is changed by configuring UART_SW_RTS.
• Hardware control: Enter this mode by setting UART_RX_FLOW_EN to 1. In this mode, rtsn_out is pulled
high when data in Rx_FIFO exceeds UART_RX_FLOW_THRHD.
When ctsn_in of IU0 is low, IU0 is allowed to send data; when ctsn_in is high, IU0 is not allowed to send data.
When IU0 detects an edge change of ctsn_in, a UART_CTS_CHG_INT interrupt is generated.
If dtrn_out of IU0 is high, it indicates that IU0 is ready to transmit data. dtrn_out is generated by configuring
register UART_SW_DTR. When the IU0 transmitter detects a edge change of dsrn_in, a UART_DSR_CHG_INT
interrupt is generated. After this interrupt is detected, software can obtain the level of input signal dsrn_in by
reading UART_DSRN. If dsrn_in is high, it indicates that EU0 is ready to transmit data.
In a two-wire RS485 multidrop network enabled by setting UART_RS485_EN, dtrn_out is used for
transmit/receive turnaround. In this case, dtrn_out is generated by hardware. When data transmission starts,
dtrn_out is pulled high and the external driver is enabled; when data transmission completes, dtrn_out is pulled
low and the external driver is disabled. Please note that when there is turnaround delay of one cycle added after
the stop bit, dtrn_out is pulled low after the delay.
UART loopback test is enabled by setting UART_LOOPBACK. In the test, UART output signal txd_out is
connected to its input signal rxd_in, rtsn_out is connected to ctsn_in, and dtrn_out is connected to dsrn_out. If
data sent matches data received, it indicates that UART controllers are working properly.
When using software flow control, hardware automatically detects if there are XON/XOFF characters in data flow
received, and generate a UART_SW_XOFF_INT or a UART_SW_XON_INT interrupt accordingly. If an XOFF
character is detected, the transmitter stops data transmission once the current byte has been transmitted; if an
XON character is detected, the transmitter starts data transmission. In addition, software can force the
transmitter to stop sending data by setting UART_FORCE_XOFF, or to start sending data by setting
UART_FORCE_XON.
Software determines whether to insert flow control characters according to the remaining room in RX FIFO. When
UART_SEND_XOFF is set, the transmitter sends an XOFF character configured by UART_XOFF_CHAR after the
current byte in transmission; when UART_SEND_XON is set, the transmitter sends an XON character configured
by UART_XON_CHAR after the current byte in transmission. If the RX FIFO of a UART controller stores more data
than UART_XOFF_THRESHOLD, UART_SEND_XOFF is set by hardware. As a result, the transmitter sends an
XOFF character after the current byte in transmission. If the RX FIFO of a UART controller stores less data than
UART_XON_THRESHOLD, UART_SEND_XON is set by hardware. As a result, the transmitter sends an XON
character after the current byte in transmission.
23.3.10 UDMA
The two UART controllers on ESP32-S2 share one UDMA (UART DMA), which supports the decoding and
encoding of HCI data packets. For more information, please refer to Chapter 2: DMA Controller (DMA).
• UART_RS485_CLASH_INT: Triggered when a collision is detected between the transmitter and the receiver
in RS485 mode.
• UART_RS485_FRM_ERR_INT: Triggered when an error is detected in the data frame sent by the
transmitter in RS485 mode.
• UART_RS485_PARITY_ERR_INT: Triggered when an error is detected in the parity bit sent by the
transmitter in RS485 mode.
• UART_TX_DONE_INT: Triggered when all data in the transmitter’s TX FIFO has been sent.
• UART_TX_BRK_IDLE_DONE_INT: Triggered when the transmitter stays idle for the minimum interval
(threshold) after sending the last data bit.
• UART_TX_BRK_DONE_INT: Triggered when the transmitter sends a NULL character after all data in TX
FIFO has been sent.
• UART_GLITCH_DET_INT: Triggered when the receiver detects a glitch in the middle of the start bit.
• UART_SW_XOFF_INT: Triggered when UART_SW_FLOW_CON_EN is set and the receiver receives a XOFF
character.
• UART_SW_XON_INT: Triggered when UART_SW_FLOW_CON_EN is set and the receiver receives a XON
character.
• UART_RXFIFO_TOUT_INT: Triggered when the receiver takes more time than UART_RX_TOUT_THRHD to
receive one byte.
• UART_BRK_DET_INT: Triggered when the receiver detects a NULL character after stop bits.
• UART_CTS_CHG_INT: Triggered when the receiver detects an edge change of CTSn signals.
• UART_DSR_CHG_INT: Triggered when the receiver detects an edge change of DSRn signals.
• UART_RXFIFO_OVF_INT: Triggered when the receiver receives more data than the capacity of RX FIFO.
• UART_RXFIFO_FULL_INT: Triggered when the receiver receives more data than what
UART_RXFIFO_FULL_THRHD specifies.
• UHCI_SEND_A_REG_Q_INT: Triggered when DMA has sent a series of short packets using always_send.
• UHCI_SEND_S_REG_Q_INT: Triggered when DMA has sent a series of short packets using single_send.
• UHCI_IN_DSCR_EMPTY_INT: Triggered when there are not enough receive descriptors for DMA.
• UHCI_TX_HUNG_INT: Triggered when DMA spends too much time on reading RAM.
• UHCI_RX_HUNG_INT: Triggered when DMA spends too much time on receiving data.
23.6 Registers
Register 23.1: UART_FIFO_REG (0x0000)
T E
BY
D_
_R
FO
FI
RX
d)
ve
T_
er
R
s
UA
(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
HD
D
RC PU
PD
RH
HR
O E_
E_
_T
_F RC
_T
W
UT
EM FO
E
E
O
IZ
IZ
TO
L
_M M_
_S
_F
S
X_
X_
RT E
X
)
d)
ed
UA T_M
_R
_R
_R
_T
ve
rv
RT
RT
RT
RT
er
se
s
UA
UA
UA
UA
UA
(re
(re
31 28 27 26 25 16 15 7 6 4 3 1 0
UART_RX_SIZE This register is used to configure the amount of RAM allocated for RX FIFO. The
default number is 128 bytes. (R/W)
UART_TX_SIZE This register is used to configure the amount of RAM allocated for TX FIFO. The
default number is 128 bytes. (R/W)
UART_RX_FLOW_THRHD This register is used to configure the maximum amount of data bytes that
can be received when hardware flow control works. (R/W)
UART_RX_TOUT_THRHD This register is used to configure the threshold time that the receiver
takes to receive one byte, in the unit of bit time (the time it takes to transfer one bit). The
UART_RXFIFO_TOUT_INT interrupt will be triggered when the receiver takes more time to receive
one byte with UART RX_TOUT_EN set to 1. (R/W)
UART_MEM_FORCE_PD Set this bit to force power down UART RAM. (R/W)
R X N IT _ AW AW
RT XF ON NT _R AW AW
W
RA
UA T_G _BR _ID _R R_I AW
UA T_T _DO AR ERR _R _R
RA W
R X _P _ NT INT
R W F _ T T
R X K NT R _R
R X H IN AW W
N
W
T_ A
UA _B IF _IN _R AW
UL _I W
_R IFO RR _R AW
I
UA T_R R_C G_ _R RA
IN _R
UA T_T _BR E_I Y_E INT
UA T_T 485 RM H_I T_
UA T_S _X DE E_I E_
_F TY RA
UA T_T RIT R_ INT W
R R O_ IN AW
XF _E _I AW
R R O_ T AW
L_ NT
R S _F S DE
R S H NT T_
RT XF Y_E INT _R
R W H_ N N
R S _C HA W
R T E UT W
R A ER F_ A
N
O P _
UA T_S ITC _DO _DO
UA T_R 485 _C _RA
UA T_P M_ OV T_R
UA T_D S_C T_I _IN
IF M NT
UA T_R 485 LA R_
R S D T
T
UA _R CM _IN
RT T_ UP
O
UA T_A KE
R A
d)
UA T_W
ve
er
R
s
UA
(re
31 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
UART_RXFIFO_FULL_INT_RAW This interrupt raw bit turns to high level when the receiver receives
more data than what UART_RXFIFO_FULL_THRHD specifies. (RO)
UART_TXFIFO_EMPTY_INT_RAW This interrupt raw bit turns to high level when the amount of data
in TX FIFO is less than what UART_TXFIFO_EMPTY_THRHD specifies. (RO)
UART_PARITY_ERR_INT_RAW This interrupt raw bit turns to high level when the receiver detects a
parity error in the data. (RO)
UART_FRM_ERR_INT_RAW This interrupt raw bit turns to high level when the receiver detects a
data frame error. (RO)
UART_RXFIFO_OVF_INT_RAW This interrupt raw bit turns to high level when the receiver receives
more data than the capacity of RX FIFO. (RO)
UART_DSR_CHG_INT_RAW This interrupt raw bit turns to high level when the receiver detects the
edge change of DSRn signal. (RO)
UART_CTS_CHG_INT_RAW This interrupt raw bit turns to high level when the receiver detects the
edge change of CTSn signal. (RO)
UART_BRK_DET_INT_RAW This interrupt raw bit turns to high level when the receiver detects a 0
after the stop bit. (RO)
UART_RXFIFO_TOUT_INT_RAW This interrupt raw bit turns to high level when the receiver takes
more time than UART_RX_TOUT_THRHD to receive a byte. (RO)
UART_SW_XON_INT_RAW This interrupt raw bit turns to high level when the receiver receives an
XON character and UART_SW_FLOW_CON_EN is set to 1. (RO)
UART_SW_XOFF_INT_RAW This interrupt raw bit turns to high level when the receiver receives an
XOFF character and UART_SW_FLOW_CON_EN is set to 1. (RO)
UART_GLITCH_DET_INT_RAW This interrupt raw bit turns to high level when the receiver detects a
glitch in the middle of a start bit. (RO)
UART_TX_BRK_DONE_INT_RAW This interrupt raw bit turns to high level when the transmitter com-
pletes sending NULL characters, after all data in TX FIFO are sent. (RO)
UART_TX_BRK_IDLE_DONE_INT_RAW This interrupt raw bit turns to high level when the transmitter
has kept the shortest duration after sending the last data. (RO)
UART_TX_DONE_INT_RAW This interrupt raw bit turns to high level when the transmitter has sent
out all data in FIFO. (RO)
UART_RS485_PARITY_ERR_INT_RAW This interrupt raw bit turns to high level when the receiver
detects a parity error from the echo of the transmitter in RS485 mode. (RO)
UART_RS485_FRM_ERR_INT_RAW This interrupt raw bit turns to high level when the receiver de-
tects a data frame error from the echo of the transmitter in RS485 mode. (RO)
UART_RS485_CLASH_INT_RAW This interrupt raw bit turns to high level when a collision is detected
between the transmitter and the receiver in RS485 mode. (RO)
UART_AT_CMD_CHAR_DET_INT_RAW This interrupt raw bit turns to high level when the receiver
detects the configured UART_AT_CMD CHAR. (RO)
UART_WAKEUP_INT_RAW This interrupt raw bit turns to high level when input RXD edge changes
more times than what UART_ACTIVE_THRESHOLD specifies in Light-sleep mode. (RO)
R X ON NT _S T T
ST
UA T_T _DO AR ERR _ST _S
R W OF T_ NT INT
S
T_ T
_
I N _S
UA T_R R_C G_ _S ST
UA T_T _BR E_I Y_E INT
UA T_T 485 RM H_I T_
UA T_S _X DE E_I E_
ST
UA T_B FIF _IN _S T
_F TY ST
_R IFO RR _S T
L_ NT
R S _F S DE
R S H NT T_
R W H_ N N
RT XF Y_E INT _S
R
R X N IT _
R A E R F_ T
R R O_ IN T
O P _
XF _E _I T
R R O_ T T
UA _S TC DO DO
R X H INT T
UA T_R 485 _C _ST
UA T_P M_ OV T_S
UA T_D S_C T_I _IN
UA T_C K_D TO _ST
IF M NT
UA T_F FIF G_ _S
UL _I
UA T_R 485 LA R_
R S _C HA
R T E UT
R S D T
N
UA _R CM _IN
RT T_ UP
K
UA T_A KE
R A
d)
X
UA T_W
ve
er
R
s
UA
(re
31 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
R X N IT _ A NA
RT XF ON NT _E NA NA
A
EN
UA T_T _DO AR ERR _EN _E
R W F _ T T
EN A
R X K NT R _E
R X H IN NA A
T_ N
A
UA _B IF _IN _E NA
I
UA T_R R_C G_ _E EN
UL _I A
_R IFO RR _E NA
IN _E
UA T_T _BR E_I Y_E INT
UA T_T 485 RM H_I T_
UA T_S _X DE E_I E_
_F TY EN
UA T_T RIT R_ INT A
R R O_ IN NA
XF _E _I NA
L_ NT
R R O_ T NA
R S _F S DE
R S H NT T_
R W H_ N N
RT XF Y_E INT _E
R S _C HA A
R T E UT A
R A ER F_ N
N
O P _
UA T_S ITC _DO _DO
UA T_R 485 _C _EN
UA T_P M_ OV T_E
IF M NT
UA T_F FIF G_ T_E
UA T_R 485 LA R_
R S D T
T
UA _R CM _IN
RT T_ UP
O
UA T_A KE
R A
d)
UA T_W
ve
er
R
s
UA
(re
31 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
R X N IT _ LR LR
RT XF ON NT _C LR LR
R
CL
UA T_T _DO AR ERR _C _C
R W F _ T T
T_ LR
R X K NT R _C
R X H INT LR R
R
UA _B IF _IN _C LR
I
IN _C
UL _I LR
UA T_R R_C G_ _C CL
_R IFO RR _C LR
UA T_T _BR E_I Y_E INT
UA T_T 485 RM H_I T_
UA T_S _X DE E_I E_
CL
R A ER F_ LR
R R O_ IN LR
L_ NT
_F TY C
XF _E _I LR
RT XF Y_E INT _C
R S _ F S DE
R R O _ T LR
R S H NT T_
R W H_ N N
R S _C HA R
R T E UT R
N
O P _
UA T_S ITC _DO _DO
UA T_P M_ OV T_C
UA T_R 485 _C _CL
UA T_F FIF G_ _C
IF M NT
UA T_T RIT R_ INT
UA T_R 485 LA R_
R S D T
T
UA _R CM _IN
RT T_ UP
O
UA T_A KE
R A
d)
UA T_W
ve
er
R
s
UA
(re
31 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
IV
DI
D
LK
LK
d)
_C
_C
e
rv
RT
RT
se
UA
UA
(re
31 24 23 20 19 0
N
O
S_
AY
M
W
RE _EN
NU
R RD BA N
AL
R RD TX V
R RD W V
R X EN T
UA T_T A_ _EN
R RD O_ T
UA T_I OP _E
UA T_I A_ CTL
UA T_I A_ _IN
UA T_I A_ CK
UA T_I A_ _IN
UA T_S D_B LX
UA T_T A_ RS
IT EN
T_
UA T_I FIF RS
F_
K_ K
R O OW
RT W RK
M
R X DP
(re TIC CL
R T NV
R X NV
BI
R RD RX
UA SW TR
RT TS NV
R X NV
_S TS
R X NV
R S NV
R RD TX
AR _
R X _
NU
_P ITY
Y
UA T_R FIFO
P_
_ M_
_ _D
UA T_C R_I
UA T_L _FL
RT _R
UA T_T D_I
UA _R _I
UA T_R S_I
UA _T _I
UA T_D D_I
_
TO
RT TR
RT AR
IT
RT E
)
)
ed
ed
UA _M
UA _D
_B
UA _P
rv
rv
RT
RT
RT
RT
se
se
UA
UA
UA
UA
(re
31 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 1 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_PARITY This register is used to configure the parity check mode. 0: even. : odd. (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_STOP_BIT_NUM This register is used to set the length of stop bit. 1: 1 bit. 2: 1.5 bits. 3: 2
bits. (R/W)
UART_SW_RTS This register is used to configure the software RTS signal which is used in software
flow control. (R/W)
UART_SW_DTR This register is used to configure the software DTR signal which is used in software
flow control. (R/W)
UART_TXD_BRK Set this bit to enable the transmitter to send NULL characterswhen the process of
sending data is done. (R/W)
UART_IRDA_TX_EN This is the start enable bit for IrDA transmitter. (R/W)
UART_IRDA_WCTL 1: The IrDA transmitter’s 11th bit is the same as 10th bit. 0: Set IrDA transmitter’s
11th bit to 0. (R/W)
UART_IRDA_TX_INV Set this bit to invert the level of IrDA transmitter. (R/W)
UART_IRDA_RX_INV Set this bit to invert the level of IrDA receiver. (R/W)
UART_LOOPBACK Set this bit to enable UART loopback test mode. (R/W)
UART_TX_FLOW_EN Set this bit to enable flow control function for the transmitter. (R/W)
UART_RXD_INV Set this bit to invert the level of UART RXD signal. (R/W)
UART_CTS_INV Set this bit to invert the level of UART CTS signal. (R/W)
UART_DSR_INV Set this bit to invert the level of UART DSR signal. (R/W)
UART_TXD_INV Set this bit to invert the level of UART TXD signal. (R/W)
UART_RTS_INV Set this bit to invert the level of UART RTS signal. (R/W)
UART_DTR_INV Set this bit to invert the level of UART DTR signal. (R/W)
UART_MEM_CLK_EN The signal to enable UART RAM clock gating. 1: UART RAM powers on, the
data of which can be read and written. 0: UART RAM powers down. (R/W)
D
RH
D
IS
RH
_D
TH
TH
W
Y_
LO
L_
PT
UT EN
X_ OW N
UL
_R FL _E
_F
M
TO _
_F
RT X_ UT
_E
O
O
UA T_R _TO
IF
IF
XF
XF
R X
d)
UA T_R
_R
_T
e
rv
RT
RT
se
R
UA
UA
UA
(re
31 30 29 28 18 17 9 8 0
UART_RX_TOUT_FLOW_DIS Set this bit to stop accumulating idle_cnt when hardware flow control
works. (R/W)
UART_RX_FLOW_EN This is the flow enable bit for UART receiver. 1: Choose software flow control
with configuring sw_rts signal. 0: Disable software flow control. (R/W)
UART_RX_TOUT_EN This is the enable bit for UART receiver’s timeout function. (R/W)
EN
N_
O
LO EL
RT ON E_X FF
_C
_S O ON
R O _X F
UA T_F RC ON
UA T_X RC XO
_F _D
UA T_F ND OF
W
W FF
R O E_
R E _X
UA T_S ND
R E
)
ed
UA T_S
rv
se
R
UA
(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
UART_SW_FLOW_CON_EN Set this bit to enable software flow control. When UART receives
flow control characters XON or XOFF, which can be configured by UART_XON_CHAR or
UART_XOFF_CHAR respectively, UART_SW_XON_INT or UART_SW_XOFF_INT interrupts can be
triggered if enabled. (R/W)
UART_XONOFF_DEL Set this bit to remove flow control characters from the received data. (R/W)
UART_FORCE_XON Set this bit to force the transmitter to send data. (R/W)
UART_FORCE_XOFF Set this bit to stop the transmitter from sending data. (R/W)
UART_SEND_XON Set this bit to send an XON character. This bit is cleared by hardware automati-
cally. (R/W)
UART_SEND_XOFF Set this bit to send an XOFF character. This bit is cleared by hardware automat-
ically. (R/W)
LD
O
SH
RE
TH
E_
IV
CT
)
ed
_A
rv
RT
se
UA
(re
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 0xf0 Reset
UART_ACTIVE_THRESHOLD The UART is activated from Light-sleep mode when the input RXD
edge changes more times than this register’s value. (R/W)
LD
HO
ES
R
HA
HR
_C
_T
FF
FF
O
XO
)
ed
_X
T_
rv
RT
se
R
UA
UA
(re
31 17 16 9 8 0
UART_XOFF_THRESHOLD When the number of data bytes in RX FIFO is more than this register’s
value with UART_SW_FLOW_CON_EN set to 1, the transmitter sends an XOFF character. (R/W)
UART_XOFF_CHAR This register stores the XOFF flow control character. (R/W)
LD
O
SH
AR
RE
CH
TH
N_
N_
O
O
d )
_X
_X
ve
RT
RT
r
se
UA
UA
(re
31 17 16 9 8 0
UART_XON_THRESHOLD When the number of data bytes in RX FIFO is less than this register’s value
with UART_SW_FLOW_CON_EN set to 1, the transmitter sends an XON character. (R/W)
UART_XON_CHAR This register stores the XON flow control character. (R/W)
HD
UM
M
HR
NU
_N
_T
_
E
E
RK
DL
DL
_B
_I
_I
RX
d)
TX
_T
ve
T_
T_
RT
er
R
s
UA
UA
UA
(re
31 28 27 20 19 10 9 0
UART_RX_IDLE_THRHD A frame end signal is generated when the receiver takes more time to re-
ceive one byte data than this register’s value, in the unit of bit time (the time it takes to transfer one
bit). (R/W)
UART_TX_IDLE_NUM This register is used to configure the duration time between transfers, in the
unit of bit time (the time it takes to transfer one bit). (R/W)
UART_TX_BRK_NUM This register is used to configure the number of 0 to be sent after the process
of sending data is done. It is active when UART_TXD_BRK is set to 1. (R/W)
RT L0 N X_ EN
R L TX _ NU
NU
EN
UA T_D 485 XBY Y_
Y_
R S R DL
DL
UA _R 85 X_
X_
N
RT S4 _R
_E
_T
S4 N
85
UA _R 85
85
_R _E
S4
RT S4
d)
_R
UA _R
ve
RT
RT
r
se
UA
UA
(re
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 0x0 0 0 0 0 0 0 Reset
UART_DL0_EN Set this bit to delay the stop bit by 1 bit. (R/W)
UART_DL1_EN Set this bit to delay the stop bit by 1 bit. (R/W)
UART_RS485TX_RX_EN Set this bit to enable the receiver could receive data when the the trans-
mitter is transmitting data in RS485 mode. (R/W)
UART_RS485RXBY_TX_EN 1: enable RS485 transmitter to send data when RS485 receiver line is
busy. 0: RS485 transmitter should not send data when its the receiver is busy. (R/W)
UART_RS485_RX_DLY_NUM This register is used to delay the receiver’s internal data signal. (R/W)
UART_RS485_TX_DLY_NUM This register is used to delay the transmitter’s internal data signal.
(R/W)
EN
D_
LT
FI
U
H_
BA
TC
TO
LI
AU
)
)
ed
ed
_G
T_
rv
rv
RT
se
se
R
UA
UA
(re
(re
31 16 15 8 7 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x10 0 0 0 0 0 0 0 0 Reset
UART_AUTOBAUD_EN This is the enable bit for baud rate detection. (R/W)
UART_GLITCH_FILT When input pulse width is lower than this value, the pulse is ignored. This
register is used in autobaud detection. (R/W)
T
CN
_
IN
M
E_
LS
PU
W
O
d)
_L
ve
RT
r
se
UA
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0xfffff Reset
UART_LOWPULSE_MIN_CNT This register stores the value of the minimum duration time of the low
level pulse. It is used in baud rate detection. (RO)
_H
ve
RT
r
se
UA
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0xfffff Reset
UART_HIGHPULSE_MIN_CNT This register stores the value of the maximum duration time for the
high level pulse. It is used in baud rate detection. (RO)
T
CN
E_
DG
E
D_
RX
d)
ve
T_
er
R
s
UA
(re
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
UART_RXD_EDGE_CNT This register stores the count of RXD edge change. It is used
in baud rate detection. As baud rate registers UART_REG_LOWPULSE_MIN_CNT,
UART_REG_HIGHPULSE_MIN_CNT, UART_REG_POSEDGE_MIN_CNT,
and UART_REG_NEGEDGE_MIN_CNT always record the minimal value,
UART_REG_RXD_EDGE_CNT indicates the statistic number of RXD edge to find out the
minimal value for these baud rate registers. (RO)
T
CN
_
IN
M
E_
DG
SE
O
)
ed
_P
rv
RT
se
UA
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0xfffff Reset
UART_POSEDGE_MIN_CNT This register stores the minimal input clock count between two positive
edges. It is used in baud rate detection. (RO)
_N
rv
RT
se
UA
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0xfffff Reset
UART_NEGEDGE_MIN_CNT This register stores the minimal input clock count between two negative
edges. It is used in baud rate detection. (RO)
NT
NT
_C
_C
O
O
N
N
_D N
_D N
F
IF
FI
SR
RT XD
TR
R T TS
RT TS
UA T_R D
XF
RX
)
)
R X
ed
ed
UA _C
UA T_R
UA T_T
_T
T_
rv
rv
RT
se
se
R
R
UA
UA
UA
UA
(re
(re
31 30 29 28 26 25 16 15 14 13 12 10 9 0
UART_DSRN This register represents the level of the internal UART DSR signal. (RO)
UART_CTSN This register represents the level of the internal UART CTS signal. (RO)
UART_RXD This register represents the level of the internal UART RXD signal. (RO)
UART_DTRN This bit represents the level of the internal UART DTR signal. (RO)
UART_RTSN This bit represents the level of the internal UART RTS signal. (RO)
UART_TXD This bit represents the level of the internal UART TXD signal. (RO)
DR
AD
R
W
DD
X_
_T
RA
PB
X_
)
)
ed
ed
_A
_T
rv
rv
RT
RT
se
se
UA
UA
(re
(re
31 21 20 11 10 9 0
UART_APB_TX_WADDR This register stores the offset address in TX FIFO when software writes TX
FIFO via APB. (RO)
UART_TX_RADDR This register stores the offset address in TX FIFO when TX FSM reads data via
Tx_FIFO_Ctrl. (RO)
DR
AD
DR
_R
AD
RX
W
B_
X_
AP
)
)
d
ed
_R
ve
T_
rv
RT
er
se
R
s
UA
UA
(re
(re
31 21 20 11 10 9 0
UART_APB_RX_RADDR This register stores the offset address in RX_FIFO when software reads data
from RX FIFO via APB. (RO)
UART_RX_WADDR This register stores the offset address in RX FIFO when Rx_FIFO_Ctrl writes RX
FIFO. (RO)
UT
UT
O
O
X_
X_
UR
T
_U
T_
)
T
ed
_S
_S
rv
RT
RT
se
UA
UA
(re
31 8 7 4 3 0
_P
rv
RT
se
UA
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x901 Reset
UART_PRE_IDLE_NUM This register is used to configure the idle duration time before the first
AT_CMD is received by the receiver. It will not take the next data received as AT_CMD character
when the duration is less than this register’s value. (R/W)
UM
E _N
DL
_I
ST
O
d)
_P
ve
RT
er
s
UA
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x901 Reset
UART_POST_IDLE_NUM This register is used to configure the duration time between the last
AT_CMD and the next data. It will not take the previous data as AT_CMD character when the
duration is less than this register’s value. (R/W)
UT
O
_T
AP
_G
X
d)
_R
e
rv
RT
se
UA
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 Reset
UART_RX_GAP_TOUT This register is used to configure the duration time between the AT_CMD
characters. It will not take the data as continuous AT_CMD characters when the duration time is
less than this register’s value. (R/W)
D_
R_
CM
HA
T_
)
ed
_C
_A
rv
RT
RT
se
UA
UA
(re
31 16 15 8 7 0
UART_AT_CMD_CHAR This register is used to configure the content of AT_CMD character. (R/W)
UART_CHAR_NUM This register is used to configure the number of continuous AT_CMD characters
received by the receiver. (R/W)
E
AT
_D
RT
UA
31 0
0x18082800 Reset
C HB P TE AC R
EN
UH I_A M _TE ST K
F_
_E
C EP EN N EN
UR EN
C _ OO W T
O
C R ID N N
ST
_B T_
N
T
UH I_O T_A _RE DE
UH _C T_ _E _E
RS T RS
_E
C EA E EO
UH I_O M ST T
C NC N RK
C d) CR RS
CI R F C
C U O O
C HB _R S
C U U S
NS
R
N_ S _
UH I_O T_N F_M
UH I_H C_R LE_
UH rve TDS BU
UH I_E _E _B
_I _R O
UH _U E C
UH rve M_ N
UH I_O T0 E
UH _O _E E
CI UT _FIF
C d) TRA
CI EN E_
C R C
CI UT _C
C LK RX
se E _E
se U R_
C U O
O
_
UH I_L OD
T
(re I_M ER
UH _U T1
UH _C T_
(re _O C
_
CI DS
CI AR
CI AR
)
A
ed
UH I_IN
UH I_U
UH I_U
rv
se
C
UH
(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 1 1 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 Reset
UHCI_AHBM_FIFO_RST Set this bit to reset AHB interface cmdFIFO of DMA. (R/W)
UHCI_OUT_AUTO_WRBACK Set this bit to enable automatic outlink writeback when all the data in
TX FIFO has been transmitted. (R/W)
UHCI_INDSCR_BURST_EN This register is used to specify DMA receive descriptor transfer mode.
1: burst mode. 0: byte mode. (R/W)
UHCI_MEM_TRANS_EN 1: UHCI transmitted data would be write back into DMA INFIFO. (R/W)
UHCI_SEPER_EN Set this bit to separate the data frame using a special character. (R/W)
UHCI_HEAD_EN Set this bit to encode the data packet with a formatting header. (R/W)
UHCI_CRC_REC_EN Set this bit to enable UHCI to receive the 16 bit CRC. (R/W)
UHCI_UART_IDLE_EOF_EN If this bit is set to 1, UHCI will end the payload receiving process when
UART has been in idle state. (R/W)
UHCI_LEN_EOF_EN If this bit is set to 1, UHCI decoder stops receiving payload data when the num-
ber of received data bytes has reached the specified value. The value is payload length indicated
by UCHI packet header when UHCI_HEAD_EN is 1 or the value is a configuration value when
UHCI_HEAD_EN is 0. If this bit is set to 0, UHCI decoder stops receiving payload data upon
receiving 0xC0. (R/W)
UHCI_ENCODE_CRC_EN Set this bit to enable data integrity checking by appending a 16 bit CCITT-
CRC to the end of the payload. (R/W)
UHCI_CLK_EN 1: Force clock on for registers. 0: Support clock only when application writes regis-
ters. (R/W)
UHCI_UART_RX_BRK_EOF_EN If this bit is set to 1, UHCI stops receiving payload data when a
NULL frame is received by UART. (R/W)
RS
TH
E
L_
_R
UH I_C E_ K_ _RE
UL
UH I_T AC OW RT
N
UH I_C C_D AD M
UM N
UH I_S CH NU ER
_E
_ S _E
C R HE SU
_F
C X_ _ TA
HE K_ LE
C AV EC M
C X_ K_ N
CK EQ
FO
UH I_T ECK _S
_C C B
UH I_C IT_ RT
CI HE ISA
S
FI
C H SW
C A A
IN
UH _W ST
A_
CI W_
M
d )
_D
UH I_S
ve
er
CI
C
s
UH
UH
(re
31 21 20 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 1 0 0 1 1 Reset
UHCI_CHECK_SUM_EN This is the enable bit to check header checksum when UHCI receives a
data packet. (R/W)
UHCI_CHECK_SEQ_EN This is the enable bit to check sequence number when UHCI receives a data
packet. (R/W)
UHCI_CRC_DISABLE Set this bit to support CRC calculation. Data integrity check present bit in
UHCI packet frame should be 1. (R/W)
UHCI_SAVE_HEAD Set this bit to save the packet header when UHCI receives a data packet. (R/W)
UHCI_TX_CHECK_SUM_RE Set this bit to encode the data packet with a checksum. (R/W)
UHCI_TX_ACK_NUM_RE Set this bit to encode the data packet with an acknowledgement when a
reliable packet is to be transmit. (R/W)
UHCI_CHECK_OWNER 1: Check the link list descriptor when link list owner is DMA controller; 0:
Always check link list descriptor. (R/W)
UHCI_WAIT_SW_START The UHCI encoder will jump to ST_SW_WAIT status if this register is set to
1. (R/W)
UHCI_SW_START If current UHCI_ENCODE_STATE is ST_SW_WAIT, the UHCI will start to send data
packet out when this bit is set to 1. (R/W)
DE
DR
O
AD
TM
ed EST
ES
se B_T
_T
HB
)
)
H
ed
_A
_A
rv
rv
CI
CI
se
UH
UH
(re
(re
31 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 0 0 Reset
UH I_T 13_ SC N
UH I_T 11_ SC_ N
SC N
N
UH I_R DB SC N
UH I_T C0 SC N
CI X_D ES EN
C0 SC N
C X_ _E _E
C X_ E _E
_E _E
_E
C X_ _E _E
C X_ _E _E
X_ _E _E
UH I_R 11 SC
_T B C
C X_ _E
UH I_R 13
C X_
)
d
UH I_R
ve
er
C
s
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_TX_C0_ESC_EN Set this bit to decode character 0xC0 when DMA receives data. (R/W)
UHCI_TX_DB_ESC_EN Set this bit to decode character 0xDB when DMA receives data. (R/W)
UHCI_TX_11_ESC_EN Set this bit to decode flow control character 0x11 when DMA receives data.
(R/W)
UHCI_TX_13_ESC_EN Set this bit to decode flow control character 0x13 when DMA receives data.
(R/W)
UHCI_RX_C0_ESC_EN Set this bit to replace 0xC0 by special characters when DMA sends data.
(R/W)
UHCI_RX_DB_ESC_EN Set this bit to replace 0xDB by special characters when DMA sends data.
(R/W)
UHCI_RX_11_ESC_EN Set this bit to replace flow control character 0x11 by special characters when
DMA sends data. (R/W)
UHCI_RX_13_ESC_EN Set this bit to replace flow control character 0x13 by special characters when
DMA sends 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
IM
IM
IM
IM
IM
IM
_T
_T
_T
_T
_T
_T
FO
FO
FO
O
IF
IF
IF
FI
FI
FI
XF
XF
XF
)
RX
RX
X
ed
_R
_T
_T
_T
rv
_
CI
CI
CI
CI
CI
CI
se
UH
UH
UH
UH
UH
UH
(re
31 24 23 22 20 19 12 11 10 8 7 0
UHCI_TXFIFO_TIMEOUT This register stores the timeout value. UHCI will produce the
UHCI_TX_HUNG_INT interrupt when DMA takes more time to receive data. (R/W)
UHCI_TXFIFO_TIMEOUT_SHIFT This register is used to configure the maximum tick count. (R/W)
UHCI_TXFIFO_TIMEOUT_ENA This is the enable bit for TX FIFO receive timeout. (R/W)
UHCI_RXFIFO_TIMEOUT This register stores the timeout value. UHCI will produce the
UHCI_RX_HUNG_INT interrupt when DMA takes more time to read data from RAM. (R/W)
UHCI_RXFIFO_TIMEOUT_SHIFT This register is used to configure the maximum tick count. (R/W)
UHCI_RXFIFO_TIMEOUT_ENA This is the enable bit for DMA send timeout. (R/W)
UM
M
N
NU
N
_N
_E
_E
D_
ND
ND
D
EN
EN
SE
SE
_S
_S
S_
S_
LE
LE
AY
AY
G
LW
LW
IN
IN
)
ed
_A
_A
_S
_S
rv
CI
CI
CI
CI
se
UH
UH
UH
UH
(re
31 8 7 6 4 3 2 0
UHCI_SINGLE_SEND_EN Set this bit to enable single_send mode to send short packets. (R/W)
UHCI_ALWAYS_SEND_EN Set this bit to enable always_send mode to send short packets. (R/W)
0
RD
O
W
0_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
1
RD
O
W
0_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
1
RD
O
W
1_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
0
RD
O
W
2_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
0
RD
O
W
3_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
1
RD
O
W
3_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
1
RD
O
W
4_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
0
RD
O
W
5_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
0
RD
O
W
6_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
1
RD
O
W
6_
_Q
END
_S
CI
UH
31 0
0x000000 Reset
R0
HA
HA
_C
_C
AR
SC
SC
CH
_E
_E
R_
ER
ER
PE
EP
EP
)
SE
ed
_S
_S
rv
I_
CI
CI
se
C
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_SEPER_CHAR This register is used to define separators to encode data packets. The default
value is 0xC0. (R/W)
UHCI_SEPER_ESC_CHAR0 This register is used to define the first character of SLIP escape se-
quence. The default value is 0xDB. (R/W)
UHCI_SEPER_ESC_CHAR1 This register is used to define the second character of SLIP escape
sequence. The default value is 0xDC. (R/W)
R1
R0
HA
A
CH
C
0_
0_
0
Q
EQ
E
SE
_S
_S
C_
SC
SC
)
ES
ed
_E
_E
rv
_
CI
CI
CI
se
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_ESC_SEQ0 This register is used to define a character that need to be encoded. The default
value is 0xDB that used as the first character of SLIP escape sequence. (R/W)
UHCI_ESC_SEQ0_CHAR0 This register is used to define the first character of SLIP escape sequence.
The default value is 0xDB. (R/W)
UHCI_ESC_SEQ0_CHAR1 This register is used to define the second character of SLIP escape se-
quence. The default value is 0xDD. (R/W)
0
AR
AR
CH
CH
1_
1_
1
EQ
EQ
SE
_S
_S
C_
SC
SC
d)
S
e
_E
_E
_E
rv
CI
CI
CI
se
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_ESC_SEQ1 This register is used to define a character that need to be encoded. The default
value is 0x11 that used as a flow control character. (R/W)
UHCI_ESC_SEQ1_CHAR0 This register is used to define the first character of SLIP escape sequence.
The default value is 0xDB. (R/W)
UHCI_ESC_SEQ1_CHAR1 This register is used to define the second character of SLIP escape se-
quence. The default value is 0xDE. (R/W)
R1
R0
HA
A
CH
C
2_
2_
2
Q
EQ
E
SE
_S
_S
C_
SC
SC
)
ES
ed
_E
_E
rv
_
CI
CI
CI
se
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_ESC_SEQ2 This register is used to define a character that need to be decoded. The default
value is 0x13 that used as flow control character. (R/W)
UHCI_ESC_SEQ2_CHAR0 This register is used to define the first character of SLIP escape sequence.
The default value is 0xDB. (R/W)
UHCI_ESC_SEQ2_CHAR1 This register is used to define the second character of SLIP escape se-
quence. The default value is 0xDF. (R/W)
S
HR
_T
KT
)
ed
_P
rv
CI
se
UH
(re
31 13 12 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x80 Reset
UHCI_PKT_THRS This register is used to configure the maximum value of the packet length when
UHCI_HEAD_EN is 0. (R/W)
C U O RR IN RA W
UH I_O T_E _E RR_ T_ RA
UH I_IN TLIN TAL _Q_ T_R INT
C _ O T T_ RA
C U R OF _IN A
C _ _ _IN W W
C U O G IN _
UH I_O T_T RE _Q_ WM
UH I_T HU _I RA AW
UH I_R HU _IN INT AW
UH I_T DO EO INT W
W
T_ W
AR IN AW
X_ AR INT AW
C _ _ F_ RA
C X_ NG T_ _R
C U S_ G L_
C X_ NE F_ _R
CI X_S NG NT_ W
RA
IN A
UH I_O D_ RE UL
T_ T_R
ST T_ _R
UH I_IN SUC EO T_
_R T _ R
C EN A_ _F
UH I_S D_ IFO
C EN NF
UH _S _I
CI MA
d)
UH I_D
ve
r
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_RX_START_INT_RAW This is the interrupt raw bit for UHCI_RX_START_INT interrupt. The
interrupt is triggered when a separator has been sent. (RO)
UHCI_TX_START_INT_RAW This is the interrupt raw bit for UHCI_TX_START_INT interrupt. The
interrupt is triggered when DMA detects a separator. (RO)
UHCI_RX_HUNG_INT_RAW This is the interrupt raw bit for UHCI_RX_HUNG_INT interrupt. The in-
terrupt is triggered when DMA takes more time to receive data than the configure value. (RO)
UHCI_TX_HUNG_INT_RAW This is the interrupt raw bit for UHCI_TX_HUNG_INT interrupt. The in-
terrupt is triggered when DMA takes more time to read data from RAM than the configured value.
(RO)
UHCI_IN_DONE_INT_RAW This is the interrupt raw bit for UHCI_IN_DONE_INT interrupt. The inter-
rupt is triggered when an receive descriptor is completed. (RO)
UHCI_OUT_DONE_INT_RAW This is the interrupt raw bit for UHCI_OUT_DONE_INT interrupt. The
interrupt is triggered when an transmit descriptor is completed. (RO)
UHCI_OUT_EOF_INT_RAW This is the interrupt raw bit for UHCI_OUT_EOF_INT interrupt. The in-
terrupt is triggered when the current descriptor’s EOF bit is 1. (RO)
C _ K _E IN T _ST
UH I_IN TLIN TAL _Q_ T_S INT
C _ O T T_ ST
C U R OF _IN T
C U O G IN _
UH I_O T_T RE _Q_ WM
UH I_T HU _I ST T
UH I_R HU _IN INT T
C X_ NG T_ _S
C U S_ G L_
C _ _ F_ ST
C X_ NE F_ _S
ST
IN T
AR IN T
X_ AR INT T
UH I_O D_ RE UL
T_ T_S
UH I_T DO EO INT
UH I_IN SUC EO T_
ST T_ _S
_R T _ S
T_
CI X_S NG NT_
C EN A_ _F
C _ _ _IN
UH I_S D_ IFO
C EN NF
UH _S _I
CI MA
)
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_RX_START_INT_ST This is the masked interrupt bit for UHCI_RX_START_INT interrupt when
UHCI_RX_START_INT_ENA is set to 1. (RO)
UHCI_TX_START_INT_ST This is the masked interrupt bit for UHCI_TX_START_INT interrupt when
UHCI_TX_START_INT_ENA is set to 1. (RO)
UHCI_RX_HUNG_INT_ST This is the masked interrupt bit for UHCI_RX_HUNG_INT interrupt when
UHCI_RX_HUNG_INT_ENA is set to 1. (RO)
UHCI_TX_HUNG_INT_ST This is the masked interrupt bit for UHCI_TX_HUNG_INT interrupt when
UHCI_TX_HUNG_INT_ENA is set to 1. (RO)
UHCI_IN_DONE_INT_ST This is the masked interrupt bit for UHCI_IN_DONE_INT interrupt when
UHCI_IN_DONE_INT_ENA is set to 1. (RO)
UHCI_OUT_DONE_INT_ST This is the masked interrupt bit for UHCI_OUT_DONE_INT interrupt when
UHCI_OUT_DONE_INT_ENA is set to 1. (RO)
UHCI_OUT_EOF_INT_ST This is the masked interrupt bit for UHCI_OUT_EOF_INT interrupt when
UHCI_OUT_EOF_INT_ENA is set to 1. (RO)
C U O RR IN EN A
UH I_O T_E _E RR_ T_ EN
UH I_IN TLIN TAL _Q_ T_E INT
C _ O T T_ EN
C U R OF _IN N
C U O G IN _
C _ _ _IN A A
UH I_O T_T RE _Q_ WM
UH I_T HU _I EN NA
UH I_R HU _IN INT NA
UH I_T DO EO INT A
A
T_ A
C _ _ F_ EN
AR IN NA
C U S_ G L_
C X_ NG T_ _E
X_ AR INT NA
C X_ NE F_ _E
CI X_S NG NT_ A
EN
IN N
UH I_O D_ RE UL
UH I_IN SUC EO T_
T_ T_E
ST T_ _E
_R T _ E
C EN A_ _F
UH I_S D_ IFO
C EN NF
UH _S _I
CI MA
)
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_RX_START_INT_ENA This is the interrupt enable bit for UHCI_RX_START_INT interrupt. (R/W)
UHCI_TX_START_INT_ENA This is the interrupt enable bit for UHCI_TX_START_INT interrupt. (R/W)
UHCI_RX_HUNG_INT_ENA This is the interrupt enable bit for UHCI_RX_HUNG_INT interrupt. (R/W)
UHCI_TX_HUNG_INT_ENA This is the interrupt enable bit for UHCI_TX_HUNG_INT interrupt. (R/W)
UHCI_IN_DONE_INT_ENA This is the interrupt enable bit for UHCI_IN_DONE_INT interrupt. (R/W)
UHCI_OUT_EOF_INT_ENA This is the interrupt enable bit for UHCI_OUT_EOF_INT interrupt. (R/W)
C U O RR IN CL R
UH I_IN TLIN TAL _Q_ T_C INT
C _ O T T_ CL
C U R OF _IN L
C U O G IN _
C _ _ _IN R R
UH I_O T_T RE _Q_ WM
UH I_T HU _I CL LR
UH I_R HU _IN INT LR
UH I_T DO EO INT R
R
C X_ NG T_ _C
IN LR
AR IN LR
C _ _ F_ CL
C X_ NE F_ _C
C U S_ G L_
X_ AR INT LR
CI X_S NG NT_ R
CL
UH I_O D_ RE UL
T_ T_C
ST T_ _C
UH I_IN SUC EO T_
_R T _ C
T_
C EN A_ _F
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
_F PTY
L
UL
UT M
_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
E
A US
_C
FU TY
LL
RR
N_ P
_I M
_E
CI _E
d)
)
X
ed
UH I_IN
_R
e
rv
rv
CI
se
se
C
UH
UH
(re
(re
31 7 6 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 0x0 0 0 1 0 Reset
UHCI_RX_ERR_CAUSE This register indicates the error type when DMA has received a packet with
error. 3’b001: Checksum error in the HCI packet; 3’b010: Sequence number error in the HCI
packet; 3’b011: CRC bit error in the HCI packet; 3’b100: 0xC0 is found but the received HCI
packet is not end; 3’b101: 0xC0 is not found when the HCI packet has been received; 3’b110:
CRC check error. (RO)
R
G
DD
BU
TE
_A
TE
E
_D
TA
TA
CR
NT
_S
_S
S
E
_D
_C
CR
DE
AT
NK
FO
DS
O
ST
EC
FI
LI
_
_
d)
IN
IN
IN
IN
_D
ve
_
er
CI
CI
CI
CI
CI
s
UH
UH
UH
UH
UH
(re
31 30 28 27 23 22 20 19 18 17 0
0 0 0 0 0 0 Reset
UHCI_INLINK_DSCR_ADDR This register stores the current receive descriptor’s address. (RO)
UHCI_INFIFO_CNT_DEBUG This register stores the number of data bytes in RX FIFO. (RO)
DR
AD
TE
R_
TA
TE
SC
T
_S
TA
TE
_D
_C
CR
_S
TA
NK
DE
FO
S
_D
_S
O
FI
LI
NC
UT
UT
UT
UT
)
ed
_O
_O
_O
_O
_E
rv
CI
CI
CI
CI
CI
se
UH
UH
UH
UH
UH
(re
31 30 28 27 23 22 20 19 18 17 0
0 0 0 0 0 0 Reset
UHCI_OUTLINK_DSCR_ADDR This register stores the current transmit descriptor’s address. (RO)
UHCI_OUTFIFO_CNT This register stores the number of data bytes in the TX FIFO. (RO)
D DR
_A
S
DE
F_
_ EO
UT
O
_
CI
UH
31 0
0x000000 Reset
UHCI_OUT_EOF_DES_ADDR This register stores the address of the transmit descriptor when the
EOF bit in this descriptor is 1. (RO)
DR
AD
S_
DE
F_
EO
C_
SU
N_
_I
CI
UH
31 0
0x000000 Reset
UHCI_IN_SUC_EOF_DES_ADDR This register stores the address of the receive descriptor when
received successful EOF. (RO)
31 0
0x000000 Reset
UHCI_IN_ERR_EOF_DES_ADDR This register stores the address of the receive descriptor when
there are some errors in this descriptor. (RO)
R
DD
_A
S
DE
R_
BF
F_
_ EO
UT
_O
CI
UH
31 0
0x000000 Reset
UHCI_OUT_EOF_BFR_DES_ADDR This register stores the address of the transmit descriptor before
the last transmit descriptor. (RO)
CR
DS
K_
IN
NL
_I
CI
UH
31 0
0 Reset
UHCI_INLINK_DSCR This register stores the third word of the next receive descriptor. (RO)
31 0
0 Reset
UHCI_INLINK_DSCR_BF0 This register stores the third word of the current receive descriptor. (RO)
R
SC
_D
NK
LI
UT
_O
CI
UH
31 0
0 Reset
UHCI_OUTLINK_DSCR This register stores the third word of the next transmit descriptor. (RO)
F0
_B
CR
DS
K_
N
LI
UT
_O
CI
UH
31 0
0 Reset
UHCI_OUTLINK_DSCR_BF0 This register stores the third word of the current transmit descriptor.
(RO)
31 0
0x000000 Reset
UHCI_RX_HEAD This register stores the header of the current received packet. (RO)
TA
H
DA
US
_W
_P
FO
O
F
FI
FI
UT
UT
)
)
ed
ed
O
O
rv
rv
I_
_
CI
se
se
C
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 0x0 Reset
UHCI_OUTFIFO_WDATA This is the data that need to be pushed into TX FIFO. (R/W)
UHCI_OUTFIFO_PUSH Set this bit to push data into the TX FIFO. (R/W)
A
AT
P
O
D
_R
_P
O
O
IF
IF
NF
NF
d)
d)
ve
e
_I
_I
rv
r
CI
CI
se
se
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 0x0 Reset
UHCI_INFIFO_RDATA This register stores the data popping from RX FIFO. (RO)
DR
P
CI UT K_ RK
TO
UT NK ES
D
UH I_O TLIN _PA
_O LI R
_A
C U K
NK
UH I_O TLIN
LI
UT
C U
)
ed
UH I_O
_O
rv
CI
se
C
UH
UH
(re
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
UHCI_OUTLINK_ADDR This register is used to specify the least significant 20 bits of the first transmit
descriptor’s address. (R/W)
UHCI_OUTLINK_STOP Set this bit to stop dealing with the transmit descriptor. (R/W)
UHCI_OUTLINK_RESTART Set this bit to restart the transmit descriptor from the last address. (R/W)
UHCI_OUTLINK_PARK 1: the transmit descriptor’s FSM is in idle state. 0: the transmit descriptor’s
FSM is working. (RO)
T
E
K_ AR T
_R
IN ST AR
ST T
R
TO
P
CI LIN _R K
NL K_ ST
DD
O
UH I_IN INK AR
U
E
C L _P
_A
_A
UH I_IN INK
NK
NK
LI
LI
C L
)
ed
UH I_IN
IN
IN
_I
rv
_
CI
CI
se
C
UH
UH
UH
(re
31 30 29 28 27 21 20 19 0
0 0 0 0 0 0 0 0 0 0 0 1 0x000 Reset
UHCI_INLINK_ADDR This register is used to specify the least significant 20 bits of the first receive
descriptor’s address. (R/W)
UHCI_INLINK_AUTO_RET This is the enable bit to return to current receive descriptor’s address,
when there are some errors in current packet. (R/W)
UHCI_INLINK_STOP Set this bit to stop dealing with the receive descriptors. (R/W)
UHCI_INLINK_START Set this bit to start dealing with the receive descriptors. (R/W)
UHCI_INLINK_PARK 1: the receive descriptor’s FSM is in idle state. 0: the receive descriptor’s FSM
is working. (RO)
31 0
0x18073001 Reset
24.1 Overview
The ESP32-S2 chip integrates four SPI controllers SPI0, SPI1, General Purpose SPI2 (GP-SPI2), and GP-SPI3 as
shown in Figure 24-1.
All the four SPI controllers can be used to communicate with external SPI devices:
• SPI0 comes with two chip select (CS) lines: CS0 and CS1, CS0 for flash and CS1 for external RAM. SPI0 is
only used by ESP32-S2 cache or EDMA to:
• SPI1 also comes with two CS lines, CS0 and CS1. SPI1 can be used by the CPU to access various
external flash.
• GP-SPI2 is a general purpose SPI controller with its own DMA channel. GP-SPI2 works as either a master
or a slave. As a master, GP-SPI2 provides six CS lines, CS0 ~ CS5.
• GP-SPI3 is also a general purpose SPI controller, but shares a DMA channel with ADC and DAC modules.
GP-SPI3 works as either a master or a slave. As a master, GP-SPI3 provides three CS lines, CS0 ~ CS2.
SPI0 and SPI1 are used internally and share the same SPI signal bus via an arbiter. The name of signals shared
by SPI0 and SPI1 is prefixed with ”SPI”: SPICLK, SPICS0 ~ SPICS1, SPID, SPIQ, SPIWP, SPIHD, SPIIO4 ~
SPIIO7, and SPIDQS. The signal buses for GP-SPI2 and GP-SPI3 are prefixed with ”FSPI” and ”SPI3”,
respectively. The prefix FSPI (Fast SPI) indicates that the recommended usage of GP-SPI2 is to communicate
with external high-speed SPI devices.
The I/O lines of the SPI/FSPI/SPI3 buses can be mapped to physical GPIO pads by following ways:
• SPI bus signals are routed to GPIO pads via either GPIO Matrix or IO MUX.
• FSPI bus signals are routed to GPIO pads via either GPIO Matrix or IO MUX.
• SPI3 bus signals are routed to GPIO pads via GPIO Matrix only.
For more information, please see Chapter 5 IO MUX and GPIO Matrix (GPIO, IO_MUX).
24.2 Features
SPI0 and SPI1 controllers are primarily reserved for internal use. This section and the following sections mainly
focus on GP-SPI2 and GP-SPI3 controllers. For mapping between SPI signals and ESP32-S2 signals, see Table
144.
• Support accessing various SPI devices (such as flash, external RAM, LCD driver) working in different data
modes:
– 1-bit SPI mode, with signals FSPICLK, FSPICS0 ~ FSPICS5, FSPID and/or FSPIQ. In full-duplex
communication, 1-bit SPI is supported. In half-duplex communication, 3-line half-duplex SPI is
supported, and only one data line FSPID is used; 4-line half-duplex SPI is also supported, and one of
the data lines FSPID and FSPIQ is used.
– 2-bit Dual SPI mode, with signals FSPICLK, FSPICS0 ~ FSPICS5, FSPID, and FSPIQ. Note: in this
mode, two data lines, i.e. FSPID and FSPIQ, are used in parallel.
– 4-bit Quad SPI mode, with signals FSPICLK, FSPICS0 ~ FSPICS5, FSPID, FSPIQ, FSPIWP, and
FSPIHD. Note: in this mode, 4 data lines are used in parallel, i.e. FSPID, FSPIQ, FSPIWP, and FSPIHD.
– QPI mode, with signals FSPICLK, FSPICS0 ~ FSPICS5, FSPID, FSPIQ, FSPIWP, and FSPIHD.
– 8-bit Octal SPI mode, with signals FSPICLK, FSPICS0 ~ FSPICS5, FSPID, FSPIQ, FSPIWP, FSPIHD,
and FSPIIO4 ~ FSPIIO7. Note: in this mode, 8 data lines are used in parallel, i.e. FSPID, FSPIQ,
FSPIWP, FSPIHD, and FSPIIO4~FSPIIO7.
– OPI mode, with signals FSPICLK, FSPICS0 ~ FSPICS5, FSPID, FSPIQ, FSPIWP, FSPIHD, and
FSPIIO4 ~ FSPIIO7.
• Support the frequency of SPI clock: 1 ~ n division of APB clock, see the division formula.
• The level of SPI_CD pin can be set in CMD and ADDR phases.
• Provide six SPI_CS pins for connection with six independent SPI slaves. The master can communicate with
these devices with different configurations (data modes, full/half-duplex, command, address, dummy, etc.)
successively.
• Support single transfer and DMA segmented-configure-transfer (SCT). Have separated interrupts for both
of them.
– 1-bit SPI, with signals FSPICLK, FSPICS0, FSPID and/or FSPIQ. In full-duplex communication, 1-bit
SPI is supported. In half-duplex communication, 3-line half-duplex SPI is supported, and uses only
one data line: FSPID; 4-line half-duplex SPI is also supported, and uses one of the data lines FSPID
and FSPIQ.
– 2-bit Dual SPI, with signals FSPICLK, FSPICS0, FSPID and FSPIQ.
– 4-bit Qual SPI, with signals FSPICLK, FSPICS0, FSPID, FSPIQ, FSPIWP, and FSPIHD.
– QPI, with signals FSPICLK, FSPICS0, FSPID, FSPIQ, FSPIWP, and FSPIHD.
• Support single transfer and segmented-transfer. Have separated interrupts for both of them.
• Support configurable read and write data bit order: most-significant bit (MSB) first, or least-significant bit
(LSB) first.
• The level of SPI_CD pin can be set in CMD and ADDR phases.
• Provide three SPI_CS pins for connection of three SPI slaves. The master can communicate with these
devices with different configurations (data modes, full/half-duplex, command, address, dummy, etc.)
successively.
• Support single transfer and DMA segmented-configure-transfer (SCT). Have separated interrupts for both
of them.
• Support single transfer and segmented-transfer. Have separated interrupts for both of them.
• Data transmission length configurable. 1 ~ 64 bytes for CPU controlled mode, 1 ~ n(unlimited) bytes for
DMA controlled mode.
• Support configurable read and write data bit order: most-significant bit (MSB) first, or least-significant bit
(LSB) first.
Supported Mode CMD Phase Address Phase Data Phase GP-SPI2 GP-SPI3
1-bit SPI 1-bit 1-bit 1-bit Y Y
Dual Output Read 1-bit 1-bit 2-bit Y _
Dual SPI
Dual I/O Read 1-bit 2-bit 2-bit Y _
Quad Output Read 1-bit 1-bit 4-bit Y _
Quad SPI
Quad I/O Read 1-bit 4-bit 4-bit Y _
Octal Output Read 1-bit 1-bit 8-bit Y _
Octal SPI
Octal I/O Read 1-bit 8-bit 8-bit Y _
QPI 4-bit 4-bit 4-bit Y _
OPI 8-bit 8-bit 8-bit Y _
The functionalities of GP-SPI3 are nearly the same as those of GP-SPI2. GP-SPI2’s functionalities are depicted in
Section 24.4 and Section 24.5. The differences between GP-SPI2 and GP-SPI3 are described in Section 24.6.
GP-SPI2 supports the following settings:
• Choose between full-duplex and half-duplex communications, depending on the bit SPI_DOUTDIN in
register SPI_USER_REG:
– 0: choose half-duplex.
– 1: choose full-duplex.
• Choose between master and slave modes, depending on the bit SPI_SLAVE_MODE in register
SPI_SLAVE_REG:
• Set read/write data bit order by configuring SPI_RD_BIT_ORDER and SPI_WR_BIT_ORDER in register
SPI_CTRL_REG, respectively:
– 0: LSB first.
– 1: MSB first.
When working as master, GP-SPI2 supports single transfer and DMA segmented-configure-transfer. Every single
transfer needs to be triggered by ESP32-S2 CPU, after its related registers are configured. The
segmented-configure-transfer consist of several single SPI transfers but requires only one triggering from
ESP32-S2 CPU. The detailed description of segmented-configure-transfer can be seen in Subsection
24.4.7.
When working as slave, GP-SPI2 supports single transfer and segmented-transfer. GP-SPI2 should be
configured to slave segmented-transfer mode before the SPI master starts the transfer in segments.
Segmented-transfer will end when En_SEG_TRANS command is received correctly. The detailed description can
be seen in Subsection 24.5.4.
When GP-SPI2 is working as slave and in the half-duplex mode, the SPI master should communicate with the
slave by supported commands in Table 139 and Table 140 according to their format.
• Subsection 24.4.3 to Subsection 24.4.8: the functions of GP-SPI2 and its typical applications
Note:
• The length of transferred data must be in unit of bytes, otherwise the extra bits will be lost. The extra bits here
means the result of total data bits % 8.
• To transfer bits not in unit of bytes, consider implementing it in CMD state or ADDR state.
2. CONF: only used for segmented-configure-transfer function. Set the bits SPI_USR and SPI_USR_CONF to
enable this state. If this state is not enabled, it means this transfer now is in single transfer mode.
3. PREP: prepare an SPI transmission and control SPI CS setup time. Set the bits SPI_USR and
SPI_CS_SETUP to enable this state.
4. CMD: send command sequence. Set the bits SPI_USR and SPI_USR_COMMAND to enable this state.
5. ADDR: send address sequence. Set the bits SPI_USR and SPI_USR_ADDR to enable this state.
6. DUMMY (wait cycle): send dummy sequence. Set the bits SPI_USR and SPI_USR_DUMMY to enable this
state.
• DOUT: send data sequence. Set the bits SPI_USR and SPI_USR_MOSI to enable this state.
• DIN: receive data sequence. Set the bits SPI_USR and SPI_USR_MISO to enable this state.
8. DONE: control SPI CS hold time. Set SPI_USR to enable this state.
As shown in Figure 24-3, a counter (gpc[22:0]) is used in state machine to control the cycle length of each state.
The states CONF, PREP, CMD, ADDR, DUMMY, DOUT, and DIN can be enabled or disabled independently, of
which the cycle lengths can also be configured independently. With the combination of the enabled states and
their cycle lengths, the behavior of GP-SPI2’s state machine can be controlled flexibly.
Table 134: Register Configuration Rules for State Control in 1/2bit Modes
Table 135: Register Configuration Rules for State Control in 4/8bit Modes
SPI_USR_DUMMY_CYCLELEN SPI_USR_DUMMY_CYCLELEN
DUMMY
SPI_USR_DUMMY SPI_USR_DUMMY
SPI_USR_MISO SPI_USR_MISO
DIN SPI_USR_MISO_DBITLEN SPI_USR_MISO_DBITLEN
SPI_FREAD_QUAD SPI_FREAD_OCT
SPI_USR_MOSI SPI_USR_MOSI
DOUT SPI_USR_MOSI_DBITLEN SPI_USR_MOSI_DBITLEN
SPI_FWRITE_QUAD SPI_FWRITE_OCT
As shown in Table 134 and Table 135, the registers in each cell should be configured to set FSPI bus to
corresponding bit mode, i.e. the mode shown in table header, at a specific state phase (corresponding to the first
column).
• Set SPI_USR_DUMMY.
• Configure GP-SPI2 DMA in DMA controlled mode. In CPU controlled mode, no action is needed.
5. Clear SPI_USR_MOSI.
When write data (DOUT state), SPI_USR_MOSI and SPI_USR_MOSI_DBITLEN should be configured instead,
while SPI_USR_MISO should be cleared. The output data bit length is the value of SPI_USR_MOSI_DBITLEN
plus 1. Output data should be configured in GP-SPI2 data buffer (SPI_W0_REG ~ SPI_W17_REG) in CPU
controlled mode, or DMA TX buffer in DMA controlled mode. The data byte order is incremented from LSB (byte
0) to MSB.
Pay special attention to the command value in SPI_USR_COMMAND_VALUE and to address value in
SPI_USR_ADDR_VALUE.
• If 7< SPI_USR_ADDR_BITLEN < 16, the ADDR value is written to SPI_USR_ADDR_VALUE[15:0]. Address
value is sent as follows.
– If SPI_WR_BIT_ORDER is cleared, SPI_USR_ADDR_VALUE[7:0] is sent first, and then the low part of
SPI_USR_ADDR_VALUE[15:8] (SPI_USR_ADDR_VALUE[SPI_USR_ADDR_BITLEN:8]) is sent.
– If SPI_WR_BIT_ORDER is set, SPI_USR_ADDR_VALUE[7:0] is sent first, and then the higher part of
SPI_USR_ADDR_VALUE[15:8] (SPI_USR_ADDR_VALUE[15: 15-SPI_USR_ADDR_BITLEN]) is sent.
In summary, each state of GP-SPI2 can be configured to 1/2/4/8-bit mode independently. The register
configuration for other applications can be found in Table 134, Table 135, and the instance above.
In full-duplex communication, the behavior in states CMD, ADDR, DUMMY, DOUT and DIN can be configured.
Usually, the states of CMD, ADDR, DUMMY are not used in this communication. The bit length of transferred
data is configured in SPI_USR_MOSI_DBITLEN and in SPI_USR_MISO_DBITLEN. The actual bit length used in
communication = the value of SPI_USR_MOSI_DBITLEN or SPI_USR_MISO_DBITLEN + 1.
• Set the bit SPI_DOUTDIN and clear the bit SPI_SLAVE_MODE, see Section 24.3.
The read/write data byte order in CPU-controlled transfer can be configured in SPI_RD_BYTE_ORDER and
SPI_WR_BYTE_ORDER in SPI_USER_REG. The register configuration for DMA-controlled transfer is described
in Subsection 24.8.
As described in Subsection 24.4.2, the properties of GP-SPI2 states CMD, ADDR, DUMMY, DOUT and DIN,
such as cycle length, value, and parallel bus bit mode, can be set independently. For the register configuration,
see Table 134 and Table 135.
4. DOUT: 0 ~ 576 bits (72 bytes) in CPU controlled mode and 0 ~ 8 Mbits in DMA controlled mode, master
output, slave input.
5. DIN: 0 ~ 576 bits (72 bytes) in CPU controlled mode and 0 ~ 8 Mbits in DMA controlled mode, master
input, slave output.
2. Configure SPI CS setup time and hold time according to Subsection 24.4.9.
4. Prepare data in registers SPI_W0_REG ~ SPI_W17_REG in CPU-controlled MOSI mode. Or configure DMA
TX/RX link in DMA-controlled mode, as shown in Subsection 24.8.
7. Set SPI_USR in register SPI_CMD_REG to start the transfer and wait the interrupt set in Step 5.
The maximum frequency supported by GP-SPI2 is fapb . FSPICLK is divided from APB_CLK, see Section
24.9.
In addition, a timing module is provided for input and output data, to add extra delay to each I/O line in units of
Tapb /2. The timing module configuration is described in Subsection 24.9.4. Setting DUMMY length and delay
select function in GPIO Matrix, GP-SPI2 can meet the timing requirement in usage.
Figure 245. Connection of GPSPI2 to Flash and External RAM in 4bit Mode
Figure 24-6 indicates GP-SPI2 quad read sequence according to standard flash specification. Other GP-SPI2
command sequences can be implemented in accordance with the requirements of SPI slaves.
The 1/2/4/8-bit SPI Double Transfer Rate (DTR) modes, in which data is sent and received at the positive and the
negative edges of SPI clock, are also supported:
• If SPI_CMD_DTR_EN is set, the CMD value will be sent in DTR mode; otherwise CMD phase will be in
Single Transfer Rate (STR) mode.
Figure 246. SPI Quad Read Command Sequence Sent by GPSPI2 to Flash
• If SPI_ADDR_DTR_EN is set, the ADDR value will be sent in DTR mode; otherwise ADDR phase will be in
STR mode.
• If SPI_DATA_DTR_EN is set, the input data in state DIN or output data in state DOUT will be sent in DTR
mode; otherwise the data will be in STR mode.
GP-SPI2 can only output FSPIDQS signal, but can not receive the signal. Therefore, only flash or external RAM
working in fixed dummy mode (dummy cycles in a read sequence is fixed) are supported.
Figure 24-8 shows the sequence of GP-SPI2 writing to I8080 interface using 8-bit LCD driver. The register
configuration is as follows:
3. SPI_FWRITE_OCT =1, and SPI_USR_MOSI = 1, configure the output data bit length in
SPI_USR_MOSI_DBITLEN. SPI_USR_MOSI_DBITLEN = data bit length expected - 1.
4. Configure the SPI CS setup time and hold time according to Subsection 24.4.9.
5. Prepare the output data in registers SPI_W0_REG ~ SPI_W17_REG in CPU-controlled MOSI mode. Or
configure DMA TX link in DMA-controlled mode.
6. Set FSPICLK to SPI clock mode 3 according to Subsection 24.9. Configure the required frequency of
FSPICLK.
9. Set SPI_USR in register SPI_CMD_REG to start the transfer and wait the interrupt set in Step 7.
In I8080 LCD read operation, RDX pin is mapped to FSPICLK and WRX pin is set to high by a GPIO pin. For the
application of Moto6800 interface LCD mode, please refer to the I8080 mode example above.
As shown in Figure 24-9, GP-SPI2 registers can be reconfigured by GP-SPI2 hardware according to the content
in a Conf_bufi during CONF state, before one single segmented-configure-transfer, SCTi, begins.
It is recommended that each SCT CONF state has its own DMA CONF link and CONF buffer. A serial DMA TX
link is used to connect all the CONF buffer and TX data buffer into a chain, so that the behavior of FSPI bus in
each SCT can be controlled independently and can be any supported one.
Meanwhile, the state of GP-SPI2, the related value and cycle length of the FSPI bus, and the behavior of DMA,
can be configured independently for each SCT. When all the SCT are finished, a GP-SPI2 interrupt,
SPI_DMA_SEG_TRANS_DONE, is triggered.
For example, as shown in Figure 24-9, SCTi can be configured to DMA-controlled full-duplex communication;
SCTj can be configured to DMA-controlled half-duplex MISO mode; and SCTk can be configured to
DMA-controlled half-duplex MOSI mode. i, j, and k are integer variables, which can be any SCT number.
In addition, GP-SPI2 CS setup time and hold time are programmable independently in each SCT, see Subsection
24.4.9 for detailed configuration. The CS high time in CONF state is determined by the sum of
SPI_CONF_BITLEN[22:0] in SPI_CMD_REG and SPI_CONF_BASE_BITLEN[6:0] in
SPI_SLV_WRBUF_DLEN_REG. The CS high time in CONF state can be set from 2 µs to 0.2 s when fapb is 80
MHz and FSPICLK equals to APB_CLK (divided by 1). If the FSPICLK is slower (divided by n > 1), the CS high
time can be even longer.
1. Prepare descriptors for DMA CONF buffer and TX data (optional) for each segmented-configure-transfer.
Chain the descriptors of CONF buffer and TX buffers of several transfers into one linked list.
2. Similarly, prepare descriptors for RX buffers for each segmented-configure-transfer and chain them into a
linked list.
3. Configure the values in all the CONF buffers, TX buffers and RX buffers, respectively for each transfers of
segmented-configure-transfer before the segmented-configure-transfer begins.
4. Point SPI_OUTLINK_ADDR to the address of the head of the CONF and TX buffer descriptor linked list, and
then set SPI_OUTLINK_START bit in the register SPI_DMA_OUT_LINK_REG to start the TX DMA.
8. Wait for all the segmented-configure-transfer slaves to get ready for transfer.
10. Wait for SPI_DMA_SEG_TRANS_DONE interrupt, which means the DMA segmented-configure-transfer is
ended and the data has been stored into corresponding memory.
Only changed registers of GP-SPI2 (compared to last transmission) need to be configured to new values in
CONF state. The configuration of other registers can be skipped (and keep the same) to save time and chip
resources.
The first word in DMA CONF bufferi, called SPI_BIT_MAP_WORD, defines whether each SPI register is updated
or not in segmented-configure-transferi. The relation of SPI_BIT_MAP_WORD and GP-SPI2 registers to update
can be seen in Table 136 Bitmap (BM) Table. If a bit is 1 in the BM table, the register value of the corresponding
bit will be updated in the single transfer. Otherwise, if some registers should be kept from being changed, the
related bits should be set to 0.
Then new values of all the registers to modify should be placed right after the SPI_BIT_MAP_WORD, in
consecutive words in the CONF buffer.
To ensure the correctness of the content in each CONF buffer, the value in SPI_BIT_MAP_WORD[31:28] is used
as ”magic value”, and will be compared with SPI_DMA_SEG_MAGIC_VALUE[3:0] in the register
SPI_SLV_RD_BYTE_REG. The value of SPI_DMA_SEG_MAGIC_VALUE[3:0] should be configured before
segmented-configure-transfer starts, and can not be changed in the segmented-configure-transfers.
Table 137 and Table 138 provide an example to show how to configure a CONF buffer for a transfer whose
SPI_ADDR_REG, SPI_CTRL_REG, SPI_CLOCK_REG, SPI_USER_REG, SPI_USER1_REG need to be
updated.
When using DMA segmented-configure-transfer, please pay special attention to the following bits:
Set bit SPI_USR_CONF before SPI_USR is set to enable segmented-configure-transfer function. If the
segmented-configure-transfer corresponding to the CONF buffer is not the last transfer, the value of
SPI_USR_CONF_NXT should be set to 1; otherwise the SPI_USR_CONF_NXT will stop when the transfer
ends.
Figure 24-10 shows the video frame structure of a parallel 8-bit RGB mode LCD.
Figure 2410. Video Frame Structure in Parallel RGB 8bit LCD Mode
It can be seen from Figure 24-9, Figure 24-10, and Figure 24-11 that a good way for GP-SPI2 to output parallel
8-bit RGB frame data is as follows:
• Data is output in each frame line in a segmented-configure-transfer. One valid video line is transferred in
each single transfer (i.e. SCTi in Figure 24-9) of segmented-configure-transfer. There are
SPI_LCD_VA_HEIGHT[9:0] active video region lines in a frame, so that a frame data is sent in
SPI_LCD_VA_HEIGHT[9:0] times of SCTi.
• There is no TX buffer and just one CONF buffer in the SCTi corresponding to vertical blanking region.
GP-SPI2 sends frame format signals in FSPI_VSYNC, FSPI_HSYNC, FSPI_DE and/or FSPICLK if needed.
• Horizontal blanking period is equal to the sum of CS high time in a CONF state, CS setup time and CS hold
time, see Subsection 24.4.7 and Subsection 24.4.9.
GP-SPI2 can output the frame data automatically as shown in Figure 24-10 and Figure 24-11, which significantly
lowers the CPU time required to control the SPI transfer. The configuration flow is as follows:
2. Configure frame control registers, as shown in Figure 24-10 and Figure 24-11, in accordance with the
application. For example, in the application, if n active video lines are needed, then set
SPI_LCD_VA_HEIGHT[9:0] to n.
6. Configure DMA TX link and prepare data in TX buffer. A ring-buffer or a ping-pong buffer is recommended
in this application to reduce the time preparing the buffer before a transfer starts.
7. Set I/O path. Set SPI_INT_TRANS_DONE_EN bit or other related interrupt enable bits.
9. Set SPI_USR to start the transfer. Wait for the SPI_TRANS_DONE interrupt.
• If SPI_CS_SETUP = 0, the SPI CS setup time is 0.5 x T _SP I_CLK. T _SP I_CLK: one cycle of SPI_CLK.
Figure 24-12 and Figure 24-13 show the recommended CS timing and configuration register value for Flash and
External RAM.
Figure 2412. Recommended CS Timing and Settings When Access External RAM
GP-SPI2 can be configured as a master for many applications. The previous sections have shown how to
configure the peripheral. See Section 24.13 for more information and detailed register descriptions.
The CS signal should be held low during the transmission, and its falling/rising edges indicate the start/end of a
transmission. The active length of transferred data should be in unit of bytes, otherwise the extra bits will be
lost.
In full-duplex communication, input and output data are transmitted simultaneously from the beginning of the
transmission. All bits are treated as input/output data, which means no command, address or dummy phases
are expected. The interrupt SPI_TRANS_DONE will be triggered when the transmission ends.
In half-duplex communication, the format should be CMD+ADDR+DUMMY+DATA (Read or Write). The read data
phase means that an SPI master reads data from GP-SPI2, while the write data phase means that an SPI master
writes data to GP-SPI2, which is defined from the perspective of the master. The detailed properties of each
phase are as follows:
1. CMD: used to distinguish from different functions of SPI Slave; 1 byte from master to slave; only the values
in Table 139 and Table 140 are valid; can be sent in 1-bit mode or 4-bit QPI mode.
2. ADDR: used to address data in CPU-controlled mode for CMD1 and 2, or placeholder bits in other modes;
1 byte from master to slave; can be sent 1-bit, 2-bit or 4-bit mode (according to the command).
3. DUMMY: value not meaningful, SPI Slave prepare data in this phase; 1 or 2 bytes (according to the
command) from master to slave.
4. Read or write data: data length can be 0 ~ 72 bytes in CPU-controlled mode and 0 ~ 2 M-byte in
DMA-controlled mode; can be 1-bit, 2-bit or 4-bit mode according to the CMD value.
The phases of ADDR and DUMMY can never be omitted in half-duplex communications, even in modes like the
DMA-controlled slave mode.
When a half-duplex transmission is ended, the transferred CMD and ADDR values will be latched in
SPI_SLV_LAST_COMMAND and SPI_SLV_LAST_ADDR bits in SPI_SLAVE1_REG register respectively. The
SPI_SLV_CMD_ERR bit in SPI_SLAVE1_REG register will be set if the transferred CMD value is not supported by
slave mode of GP-SPI2. The SPI_SLV_CMD_ERR bit can only be cleared by software.
The CPU-controlled and DMA-controlled mode configuration can be found in Subsection 24.8 and Subsection
24.7.
1. 0x1 (Wr_BUF): CPU-controlled write mode. Master sends data and GP-SPI2 receives data. The data will
be stored in the related address of the registers SPI_W0_REG ~ SPI_W17_REG.
2. 0x2 (Rd_BUF): CPU-controlled read mode. Master receives the data sent by GP-SPI2. The data comes
from the related address of SPI_W0_REG ~ SPI_W17_REG.
3. 0x3 (Wr_DMA): DMA-controlled write mode. Master sends data and GP-SPI2 receives data. The data will
be stored in GP-SPI2 DMA RX buffer.
4. 0x4 (Rd_DMA): DMA-controlled read mode. Master receives the data sent by GP-SPI2. The data comes
from GP-SPI2 DMA TX buffer.
6. 0x8 (CMD8): only used to generate an SPI_SLV_CMD8_INT interrupt, which will not end GP-SPI2’s slave
mode segmented-transfer.
7. 0x9 (CMD9): only used to generate an SPI_SLV_CMD9_INT interrupt, which will not end GP-SPI2’s slave
mode segmented-transfer.
8. 0xA (CMDA): only used to generate an SPI_SLV_CMDA_INT interrupt, which will not end GP-SPI2’s slave
mode segmented-transfer.
1/2/4-bit modes in phases of CMD, ADDR, DATA are supported, which are determined by value of CMD[7:4].
The DUMMY phase is always 1-bit mode and lasts for 8 SPI cycles in 1-bit SPI mode and 4 SPI cycles in other
SPI modes. The definition is as follows:
1. 0x0: all the phases of CMD, ADDR, and DATA are in 1-bit mode.
2. 0x1: CMD and ADDR are in 1-bit mode. DATA is in 2-bit mode.
3. 0x2: CMD and ADDR are in 1-bit mode. DATA is in 4-bit mode.
4. 0x5: CMD is in 1-bit mode. ADDR and DATA are in 2-bit mode.
5. 0xA: CMD is in 1-bit mode, ADDR and DATA are in 4-bit mode. Or in QPI mode. Whereas, the CMD values
of 0xA7, 0xA8, 0xA9 and 0xAA are only valid in QPI mode.
In addition, for CMD[7:0] values of 0x05, 0xA5, 0x06, and 0xDD, the phases of ADDR, DUMMY, and DATA are
deleted. The definition is as follows:
1. 0x05 (End_SEG_TRANS): master sends 0x05 command to end the segmented-transfer in SPI mode.
2. 0xA5 (End_SEG_TRANS): master sends 0xA5 command to end the segmented-transfer in QPI mode.
3. 0x06 (En_QPI): GP-SPI2 enters QPI mode when receives the 0x06 command and the SPI_QPI_MODE bit
in SPI_USER_REG register will be set.
4. 0xDD (Ex_QPI): GP-SPI2 exits QPI mode when receives the 0xDD command and the SPI_QPI_MODE bit
will be cleared.
All the GP-SPI2 supported CMD values are given in Table 139 and Table 140.
ADDR DUMMY
Transfer Type CMD[7:0] CMD Phase DATA Phase
Phase Phase
0x01 1-bit mode 1-bit mode 8 cycles 1-bit mode
0x11 1-bit mode 1-bit mode 4 cycles 2-bit mode
0x21 1-bit mode 1-bit mode 4 cycles 4-bit mode
Wr_BUF
0x51 1-bit mode 2-bit mode 4 cycles 2-bit mode
0xA1 1-bit mode 4-bit mode 4 cycles 4-bit mode
ADDR DUMMY
Transfer Type CMD[7:0] CMD Phase DATA Phase
Phase Phase
0x02 1-bit mode 1-bit mode 8 cycles 1-bit mode
0x12 1-bit mode 1-bit mode 4 cycles 2-bit mode
0x22 1-bit mode 1-bit mode 4 cycles 4-bit mode
Rd_BUF
0x52 1-bit mode 2-bit mode 4 cycles 2-bit mode
0xA2 1-bit mode 4-bit mode 4 cycles 4-bit mode
0x03 1-bit mode 1-bit mode 8 cycles 1-bit mode
0x13 1-bit mode 1-bit mode 4 cycles 2-bit mode
0x23 1-bit mode 1-bit mode 4 cycles 4-bit mode
Wr_DMA
0x53 1-bit mode 2-bit mode 4 cycles 2-bit mode
0xA3 1-bit mode 4-bit mode 4 cycles 4-bit mode
0x04 1-bit mode 1-bit mode 8 cycles 1-bit mode
0x14 1-bit mode 1-bit mode 4 cycles 2-bit mode
0x24 1-bit mode 1-bit mode 4 cycles 4-bit mode
Rd_DMA
0x54 1-bit mode 2-bit mode 4 cycles 2-bit mode
0xA4 1-bit mode 4-bit mode 4 cycles 4-bit mode
0x07 1-bit mode - - -
0x17 1-bit mode - - -
0x27 1-bit mode - - -
CMD7
0x57 1-bit mode - - -
0x08 1-bit mode - - -
0x18 1-bit mode - - -
0x28 1-bit mode - - -
CMD8
0x58 1-bit mode - - -
0x09 1-bit mode - - -
0x19 1-bit mode - - -
0x29 1-bit mode - - -
CMD9
0x59 1-bit mode - - -
0x0A 1-bit mode - - -
0x1A 1-bit mode - - -
0x2A 1-bit mode - - -
CMDA
0x5A 1-bit mode - - -
End_SEG_TRANS 0x05 1-bit mode - - -
En_QPI 0x06 1-bit mode - - -
Master should send 0x06 CMD (En_QPI) to set GP-SPI2 slave to QPI mode and all the phases of supported
transfer will be in 4-bit mode afterwards. If 0xDD CMD (Ex_QPI) is received, GP-SPI2 slave will be back to SPI
mode.
The other transfer types will be ignored. If the transferred bit length is smaller than 8, there will be no effect on
GP-SPI2 as if it has not happened. However, if the bit length is larger than 8, SPI_TRANS_DONE will be triggered.
For more information on interrupts triggered at the end of transmission, please refer to Subsection 24.11.
3. If in DMA-controlled mode, configure DMA descriptors and start DMA, as shown in Subsection 24.8.
In GP-SPI2 slave segmented-transfer mode, master supports all transfer types given in Table 139 and Table 140,
in a segmented-transfer. It means that CPU-controlled transfer and DMA-controlled transfer can be mixed in one
segmented-transfer.
• CPU-controlled transfer is used in handshake communication and small-size data transfer, with related
interrupts shown in Subsection 24.11.
• DMA-controlled transfer is used for huge numbers of data transfer with related interrupts in Subsection
24.11.
When End_SEG_TRANS (0x05 in SPI mode, 0xA5 in QPI mode) is received by GP-SPI2, the segmented-transfer
will be ended and the interrupt SPI_DMA_SEG_TRANS_DONE will be triggered. The register configuration flow is
as follows:
3. Configure DMA descriptors and start DMA. Clear SPI_RX_EOF_EN bit in SPI_DMA_CONF_REG.
In DMA full-duplex segmented-transfer, the data should be transferred from and to the DMA buffer.
CPU-controlled mode is not supported in this segmented-transfer. The interrupt SPI_IN_SUC_EOF_INT_ST will
be triggered when the transfer ends. The configuration flow is as follows:
1. Set the bit SPI_DOUTDIN in register SPI_USER_REG and the bit SPI_SLAVE_MODE in register
SPI_SLAVE_REG.
• The communication mode for each GP-SPI2 state (CMD, ADDR, DOUT or DIN) can be configured
independently. Data can either be in 1/2/4/8-bit master mode or 1/2/4-bit slave mode. Whereas GP-SPI3
supports only 1-bit communication mode which does not allow for such flexibility.
• The supported CMD values of GP-SPI2 slave mode are shown in Table 139 and Table 140. While only
0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x09 and 0x0A of the CMD values are supported in GP-SPI3
slave mode.
• The I/O lines of GP-SPI2 can be mapped to physical GPIO pads either via GPIO Matrix or IO MUX.
However, GP-SPI3 lines can be configured only via GPIO Matrix.
• GP-SPI2 has six CS signals in master mode. GP-SPI3 only has three CS signals in master mode.
Apart from that, the functions of GP-SPI2 and GP-SPI3 are the same. GP-SPI2 can use all the GP-SPI registers,
while GP-SPI3 can only use some of the GP-SPI registers, see Table 141 for details.
GP-SPI3 has the same 1-bit mode functions and register configuration rules as to GP-SPI2. GP-SPI3 interface
can be seen as a 1-bit mode GP-SPI2 interface. By such way, the guidelines on how to use GP-SPI3 can be
deduced from the material provided in Section 24.4 and Section 24.5.
The bit SPI_DMA_RX_ENA in register SPI_DMA_IN_LINK_REG and the SPI_DMA_TX_ENA bit in register
SPI_DMA_OUT_LINK_REG should be cleared during the transmission:
• SPI_DMA_RX_ENA
• SPI_DMA_TX_ENA
In CPU-controlled slave half-duplex mode, the registers SPI_W0_REG ~ SPI_W17_REG are all 32-bit buffers and
byte addressable. The ADDR value in transmission format is the start address of the read or write data,
corresponding to the registers SPI_W0_REG ~ SPI_W17_REG. The read or write address increments by 1 on
every byte, corresponding to SPI_W0_REG ~ SPI_W17_REG. If the address is greater than 71, the highest byte
address of SPI_W17_REG[31:24], the address will always be 71 and only the content of SPI_W17_REG[31:24]
will be changed. Meanwhile, the SPI_SLV_ADDR_ERR bit in SPI_SLAVE1_REG register will be 1.
The registers SPI_W0_REG ~ SPI_W17_REG can all be used as data buffer, partial data buffer and partial status
buffer, or all status buffer according to the application. In addition, the bits SPI_DMA_RX_ENA and
SPI_DMA_TX_ENA can be 1 in the slave CPU-controlled mode.
DMA-controlled mode can be used together with full-duplex communication, half-duplex communication and
functions described in Subsection 24.4 and Subsection 24.5. Meanwhile, DMA RX module is independent from
DMA TX module, which means that there are four kinds of full-duplex communications:
In half-duplex communication, the transfers of Wr_BUF, Rd_BUF, Wr_DMA and Rd_DMA can be supported in a
slave segmented-transfer, see Subsection 24.5.4. GP-SPI master segmented-configure-transfer only supports
DMA-controlled transfer.
Both for the DMA-controlled master mode and slave mode, the main configuration flow is as follows:
• Configure a DMA TX descriptor and set the bit SPI_OUTLINK_START in register SPI_DMA_OUT_LINK_REG
to start a DMA TX engine. Before all the DMA TX buffer is used or the DMA TX engine is reset,
SPI_OUTLINK_RESTART bit can be set to add a new TX buffer to the end of last TX buffer in use.
• DMA RX buffer can be linked by setting bits SPI_INLINK_START and SPI_INLINK_RESTART in the same
way as the DMA TX buffer.
• The sent and received data lengths are determined by the configured DMA TX and RX buffer respectively,
both of which can be 0 ~ 2 M-byte.
• DMA inlink and outlink should be initialized before DMA starts. The bit SPI_DMA_RX_ENA in register
SPI_DMA_IN_LINK_REG and the bit SPI_DMA_TX_ENA in register SPI_DMA_OUT_LINK_REG should be
set during the transmission.
The only difference between DMA-controlled transfers in master mode and in slave mode is on the DMA RX
control:
– In master mode, the interrupt SPI_IN_SUC_EOF_INT can be triggered when a single transfer or a
DMA segmented-configure-transfer is ended;
– In slave mode, the interrupt SPI_IN_SUC_EOF_INT can be triggered when a single transfer is ended
and the SPI_DMA_SLV_SEG_TRANS_EN bit is 0. It can also be triggered when
SPI_DMA_SLV_SEG_TRANS_EN bit is 1 and a CMD7 or End_SEG_TRANS command is received
correctly in a slave segmented-transfer.
– In master mode, the interrupt SPI_IN_SUC_EOF_INT can be triggered when a single transfer or a
DMA segmented-configure-transfer is ended and the total DMA RX received data length is equal to
the value of SPI_MST_DMA_RD_BYTELEN.
– In slave mode, the total DMA RX received data length should be equal to the value of
SPI_SLV_DMA_RD_BYTELEN. The interrupt SPI_IN_SUC_EOF_INT can be triggered when a single
slave mode transfer is ended and the SPI_DMA_SLV_SEG_TRANS_EN bit is 0. It can also be
triggered when SPI_DMA_SLV_SEG_TRANS_EN bit is 1 and a CMD7 or End_SEG_TRANS command
is received correctly in a slave segmented-transfer.
In addition, if the configured DMA TX buffer length is smaller than the length of real transferred data, the extra
data will be the same as the last transferred data. SPI_OUTFIFO_EMPTY_ERR_INT_RAW and
SPI_OUT_EOF_INT_RAW in the register SPI_DMA_INT_RAW_REG will be set.
If the configured DMA TX buffer length is greater than the length of real transferred data, the TX buffer is not fully
used, and the rest of the buffer will be available for further usage even if a new TX buffer is linked later. Keep it in
mind or save the unused data and reset DMA.
If the configured DMA RX buffer length is smaller than the length of real transferred data, the extra data will be
lost. The bit SPI_INFIFO_FULL_ERR_INT_RAW in register SPI_DMA_INT_RAW_REG and SPI_TRANS_DONE will
be valid. But no valid SPI_IN_SUC_EOF_INT_RAW interrupt will be generated.
If the configured DMA RX buffer length is greater than the length of real transferred data, the RX buffer is not fully
used, and the rest of the buffer will be available for further usage even if a new RX buffer is linked later. Keep it in
mind or reset DMA.
fapb
fspi =
(SPI_CLKCNT_N+1)(SPI_CLKDIV_PRE+1)
The values of SPI_CLKCNT_N and SPI_CLKDIV_PRE in register SPI_CLOCK_REG can be configured to change
the frequency. When the bit SPI_CLK_EQU_SYSCLK in register SPI_CLOCK_REG is 1, the output clock
frequency of GP-SPI will be fapb . And for other integral clock divisions, SPI_CLK_EQU_SYSCLK should be
0.
In slave mode, the maximum supported input clock frequency of GP-SPI is fapb /2, and all the lower frequencies
are available.
1. Mode 0: CPOL = 0, CPHA = 0; SCK is 0 when the SPI is in idle state; data is changed on the negative
edge of SCK and sampled on the positive edge.
2. Mode 1: CPOL = 0, CPHA = 1; SCK is 0 when the SPI is in idle state; data is changed on the positive edge
of SCK and sampled on the negative edge.
3. Mode 2: CPOL = 1, CPHA = 0; SCK is 1 when the SPI is in idle state; data is changed on the positive edge
of SCK and sampled on the negative edge.
4. Mode 3: CPOL = 1, CPHA = 1; SCK is 1 when the SPI is in idle state; data is changed on the negative
edge of SCK and sampled on the positive edge.
SPI_CLK_MODE[1:0] in register SPI_CTRL1_REG can be used to select the number of positive edges of
FSPICLK, when CS raises high, to be 0, 1, 2 or FSPICLK always on.
In GP-SPI master mode, there are some timing adjustment modules for every input and output data, which can
be used to achieve integral numbers of T_APB_CLK (one cycle of APB_CLK) delay on positive or negative edge.
The registers SPI_DIN_MODE_REG and SPI_DIN_NUM_REG can be used to select the latch edge of input data.
SPI_DOUT_MODE_REG and SPI_DOUT_NUM_REG can be used to select the latch of output data. The detailed
description can be seen in Subsection 24.14. Meanwhile, the DUMMY cycle length can be changed to
compensate the real I/O line delays, so as to enhance the performance of GP-SPI.
In GP-SPI slave mode, if the bit SPI_RSCK_DATA_OUT in register SPI_CTRL1_REG is set to 1, the output data
will be sent at latch edge, which will be half an SPI clock cycle earlier. It can be used for slave mode timing
compensation.
The mapping between SPI/FSPI/SPI3 bus signals and GPIO pads in different communication modes is shown in
Table 144. The signals in a line corresponds to each other. For example, the signal FSPID is connected to MOSI
in GP-SPI2 full-duplex communication, and FSPIQ to MISO, see Figure 24-4. SPI3_Q will connect to MISO pin in
half-duplex communication for GP-SPI3.
The interrupt lists of GP-SPI are given in Table 145 and Table 146. Set the interrupt enable bit of SPI_INT_*_EN in
register SPI_SLAVE_REG or SPI_*_INT_ENA in SPI_DMA_INT_ENA_REG and wait for the SPI_INT or
SPI_DMA_INTR interrupt. When the transfer ends, the related interrupt will be triggered and should be cleared by
software before the next transfer.
Note:
1. If SPI_IN_SUC_EOF_INT is triggered, it means all the push data has been stored in RX buffer, and the pop data has been sent to the slave.
2. SPI_TRANS_DONE raises high when CS is high, which indicates that master has completed the data exchange in W0 ~ W17 with slave in this mode.
3. If SPI_DMA_SEG_TRANS_DONE is triggered, it means that the segmented-transfer ends, and the push data has been stored in RX buffer completely, which also indicates all
the pop data has been sent out.
ESP32-S2 TRM (v1.1)
Espressif Systems
Note:
1. If SPI_IN_SUC_EOF_INT is triggered, it means all the push data has been stored in RX buffer, and the pop data has been sent to slave.
2. SPI_TRANS_DONE raises high when CS is high, which indicates that master has completed the data exchange in W0 ~ W17 with slave in this mode.
3. SPI_SLV_WR_DMA_DONE just means that the transmission on the SPI bus is done, but can not ensure that all the push data has been stored in the RX buffer. For this reason,
SPI_IN_SUC_EOF_INT is recommended.
7. Slave should set the total read data byte length in SPI_SLV_DMA_RD_BYTELEN[19:0] before transmit begins. And set SPI_RX_EOF_EN 0->1 before the end of the interrupt
program.
8. Master and slave should define a segmented-transfer end method, such as through GPIO as interrupt and so on.
Espressif Systems
10. Half-duplex Wr_BUF single transfer can occur during DMA segmented-transfer.
12. Half-duplex Rd_BUF single transfer can occur during DMA segmented-transfer.
Submit Documentation Feedback
592
ESP32-S2 TRM (v1.1)
24. SPI Controller (SPI)
• SPI_TRANS_DONE: triggered at the end of SPI bus transfer in both master mode and slave mode.
• SPI_SEG_MAGIC_ERR_INT: triggered when a Magic error occurs in CONF buffer during master DMA
segmented-configure-transfer.
• SPI_SLV_CMDA_INT: triggered when CMDA is received correctly in GP-SPI slave mode and the SPI
transfer is ended.
• SPI_SLV_CMD9_INT: triggered when CMD9 is received correctly in GP-SPI slave mode and the SPI
transfer is ended.
• SPI_SLV_CMD8_INT: triggered when CMD8 is received correctly in GP-SPI slave mode and the SPI
transfer is ended.
• SPI_SLV_CMD7_INT: triggered when CMD7 is received correctly in GP-SPI slave mode and the SPI
transfer is ended.
• SPI_SLV_CMD6_INT: triggered when En_QPI or Ex_QPI is received correctly in GP-SPI slave mode and the
SPI transfer is ended.
• SPI_OUTFIFO_EMPTY_ERR_INT: triggered when DMA TX FIFO length is smaller than the real transferred
data length.
• SPI_INFIFO_FULL_ERR_INT: triggered when DMA RX FIFO length is smaller than the real transferred data
length.
• SPI_OUT_TOTAL_EOF_INT: triggered when all the data in out_link buffer has been sent out.
• SPI_OUT_EOF_INT: triggered when each out link buffer has been used up.
24.14 Registers
Register 24.1: SPI_CMD_REG (0x0000)
EN
TLI
_B
NF
d)
)
ed
se R
CO
ve
(re US
rv
er
I_
I_
s
SP
SP
(re
31 25 24 23 22 0
0 0 0 0 0 0 0 0 0 0 Reset
SPI_CONF_BITLEN Define the SPI_CLK cycles of SPI_CONF state. Can be configured in CONF
state. (R/W)
SPI_USR User-defined command enable. An operation will be triggered when the bit is set. The
bit will be cleared once the operation is done. 1: enable, 0: disable. Can not be changed by
CONF_buf. (R/W)
31 0
0x000000 Reset
SPI_USR_ADDR_VALUE [31:8]: the address to slave, [7:0]: Reserved. Can be configured in CONF
state. (R/W)
HP T
T
IG AR
AR
IS IG E
_H HP
SP RS UT OR ER
SP CS _I_ DG R
M I_H L
I_ R_ DR ND
L
R_ OS Y_ID
I_ RI O XT
I_ CK _E DE
I_ _O E_ D
O
I_ _S ED E
I_ _B D D
SP RD YT UAL
SP CS ET GE
SP CK YT OR
SP FW E_ _N
PI OD GE
_P
SP US AD MA
SP US MIS MY
SP WR E_ A
SP FW TE_ CT
I_ R_ MM
I_ RIT QU
I_ IT F
LD
I_ I_M ED
I_ _B E_
E
DE
I_ _H UP
I_ R_ O
SP US DU I
O
I_ R_ M
I_ R_ M
I_ R_ S
I_ CK D
N
SP US MO
SP US CO
SP SIO HO
SP W O
SP US DU
SP TS OL
SP OP _I_
se MO
DI
US M
UT
I_ R_
I_ R_
I_ R_
)
)
R
_
ed
ed
DO
SP US
SP US
SP US
rv
rv
Q
F
se
I_
I_
I_
I_
SP
SP
SP
(re
(re
31 30 29 28 27 26 25 24 23 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 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 1 1 0 0 0 0 0 0 Reset
SPI_DOUTDIN Set the bit to enable full-duplex communication. 1: enable, 0: disable. Can be con-
figured in CONF state. (R/W)
SPI_QPI_MODE Both for master mode and slave mode. 1: SPI controller is in QPI mode. 0: other
modes. Can be configured in CONF state. (R/W)
SPI_OPI_MODE Just for master mode. 1: SPI controller is in OPI mode (all in 8-bit mode). 0: other
modes. Can be configured in CONF state. (R/W)
SPI_TSCK_I_EDGE In slave mode, this bit can be used to change the polarity of tsck. 0: TSCK =
SPI_CK_I. 1: TSCK = !SPI_CK_I. (R/W)
SPI_CS_HOLD Keep SPI CS low when SPI is in DONE phase. 1: enable. 0: disable. Can be
configured in CONF state. (R/W)
SPI_CS_SETUP Enable SPI CS when SPI is in (PREP) prepare phase. 1: enable. 0: disable. Can be
configured in CONF state. (R/W)
SPI_RSCK_I_EDGE In slave mode, this bit can be used to change the polarity of rsck. 0: RSCK =
!SPI_CK_I. 1: RSCK = SPI_CK_I. (R/W)
SPI_CK_OUT_EDGE This bit together with SPI_DOUT_MODE is used to set MOSI signal delay mode.
Can be configured in CONF state. (R/W)
SPI_FWRITE_OCT In write operations, read-data phase is in 8-bit mode. Can be configured in CONF
state. (R/W)
SPI_USR_CONF_NXT 1: Enable the DMA CONF phase of next seg-trans operation, which means
seg-trans will continue. 0: The segmented-transfer will end after the current SPI segmented-
transfer or this is not segmented-transfer mode. Can be configured in CONF state. (R/W)
SPI_SIO Set the bit to enable 3-line half-duplex communication, where MOSI and MISO signals share
the same pin. 1: enable, 0: disable. Can be configured in CONF state. (R/W)
SPI_USR_HOLD_POL This bit together with the hold bits is used to set the polarity of SPI hold line.
1: SPI will be held when SPI hold line is high. 0: SPI will be held when SPI hold line is low. Can be
configured in CONF state. (R/W)
SPI_USR_DUMMY_IDLE When this bit is enabled, the SPI clock is disabled in DUMMY phase. Can
be configured in CONF state. (R/W)
SPI_USR_MOSI This bit enables the write-data phase of an operation. Can be configured in CONF
state. (R/W)
SPI_USR_MISO This bit enables the read-data phase of an operation. Can be configured in CONF
state. (R/W)
SPI_USR_DUMMY This bit enables the DUMMY phase of an operation. Can be configured in CONF
state. (R/W)
SPI_USR_ADDR This bit enables the address phase of an operation. Can be configured in CONF
state. (R/W)
SPI_USR_COMMAND This bit enables the command phase of an operation. Can be configured in
CONF state. (R/W)
N
E LE
CL
N
LE
CY
IT
Y_
_B
M
DR
UM
AD
_D
R_
d)
R
ve
US
US
er
I_
I_
s
SP
SP
(re
31 27 26 8 7 0
23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 Reset
SPI_USR_DUMMY_CYCLELEN The length in SPI_CLK cycles of dummy phase. The register value
shall be (cycle_num-1). Can be configured in CONF state. (R/W)
SPI_USR_ADDR_BITLEN The length in bits of address phase. The register value shall be (bit_num-
1). Can be configured in CONF state. (R/W)
UE
E
TL
L
VA
BI
D_
D_
AN
AN
M
M
M
M
CO
CO
R_
R_
)
ed
US
US
rv
se
I_
I_
SP
SP
(re
31 28 27 16 15 0
7 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_USR_COMMAND_BITLEN The length in bits of command phase. The register value shall be
(bit_num-1). Can be configured in CONF state. (R/W)
US
rv
se
I_
SP
(re
31 23 22 0
0 0 0 0 0 0 0 0 0 0x0000 Reset
SPI_USR_MOSI_DBITLEN The length in bits of write-data phase. The register value shall be
(bit_num-1). Can be configured in CONF state. (R/W)
EN
TL
BI
_D
O
IS
_M
)
ed
R
US
rv
se
I_
SP
(re
31 23 22 0
0 0 0 0 0 0 0 0 0 0x0000 Reset
SPI_USR_MISO_DBITLEN The length in bits of read-data phase. The register value shall be
(bit_num-1). Can be configured in CONF state. (R/W)
RD R
ER
_O E
SP rve R_ AD
DU D
AL
AL
UT
IT RD
SP FAD _D AD
SP FAD R_ AL
D_ UA
(re FAD R_ T
FR D_ T
SP FC _Q T
I_ D OC
se D QU
I_ EA OC
I_ d) DU
O
_B _O
I_ MD C
I_ MD U
I_ D U
EA Q
Y_
SP rve EG
SP FC _O
SP FR D_
RD IT
SP rve L
(re Q_ L
M
I_ MD
I_ _B
se _R
se PO
I_ PO
I_ EA
)
I_ d)
I_ d)
)
M
ed
ed
ed
ed
SP WR
(re WP
DU
SP FC
SP FR
SP D_
rv
rv
rv
rv
se
se
se
se
I_
I_
I_
SP
SP
SP
(re
(re
(re
(re
31 27 26 25 24 22 21 20 19 18 17 16 15 14 13 11 10 9 8 7 6 5 4 3 2 0
0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_DUMMY_OUT The signal level output by the SPI controller in the dummy phase. Can be con-
figured in CONF state. (R/W)
SPI_FADDR_DUAL Apply 2-bit mode during address phase. 1: enable, 0: disable. Can be config-
ured in CONF state. (R/W)
SPI_FADDR_QUAD Apply 4-bit mode during address phase. 1: enable, 0: disable. Can be config-
ured in CONF state. (R/W)
SPI_FADDR_OCT Apply 8-bit mode during address phase. 1: enable, 0: disable. Can be configured
in CONF state. (R/W)
SPI_FCMD_DUAL Apply 2-bit mode during command phase. 1: enable, 0: disable. Can be config-
ured in CONF state. (R/W)
SPI_FCMD_QUAD Apply 4-bit mode during command phase. 1: enable, 0: disable. Can be config-
ured in CONF state. (R/W)
SPI_FCMD_OCT Apply 8-bit mode during command phase. 1: enable, 0: disable. Can be config-
ured in CONF state. (R/W)
SPI_FREAD_DUAL In the read operations, read-data phase is in 2-bit mode. 1: enable, 0: disable.
Can be configured in CONF state. (R/W)
SPI_FREAD_QUAD In the read operations, read-data phase is in 4-bit mode. 1: enable, 0: disable.
Can be configured in CONF state. (R/W)
SPI_FREAD_OCT In the read operations, read-data phase is in 8-bit mode. 1: enable, 0: disable.
Can be configured in CONF state. (R/W)
SPI_Q_POL The bit is used to set MISO line polarity. 1: high, 0: low. Can be configured in CONF
state. (R/W)
SPI_D_POL The bit is used to set MOSI line polarity. 1: high, 0: low. Can be configured in CONF
state. (R/W)
SPI_WP_REG Write protect signal output when SPI is idle. 1: output high, 0: output low. Can be
configured in CONF state. (R/W)
SPI_RD_BIT_ORDER In read-data (MISO) phase, 1: LSB first, 0: MSB first. Can be configured in
CONF state. (R/W)
SPI_WR_BIT_ORDER In command, address, and write-data (MOSI) phases, 1: LSB first, 0: MSB
first. Can be configured in CONF state. (R/W)
M A_ A
E_ T
Y
SP K_ AT EN
LA
CL OD OU
13
E
D _
CL _ R
_D
DE
I_ CK _W
LD
O
SP RS 17
O
M
_H
I_ 6_
K_
d)
)
ed
SP W1
ve
CS
rv
er
se
I_
I_
I_
s
SP
SP
(re
(re
31 20 19 14 13 5 4 3 2 1 0
SPI_CLK_MODE SPI clock mode bits. 0: SPI clock is off when CS inactive. 1: SPI clock is delayed
one cycle after CS inactive. 2: SPI clock is delayed two cycles after CS inactive. 3: SPI clock is
always on. Can be configured in CONF state. (R/W)
SPI_CLK_MODE_13 CPOL, CPHA, 1: support SPI CLK mode 1 and 3, and output data B[0]/B[7] at
first edge. 0: support SPI CLK mode 0 and 2, and output data B[1]/B[6] at first edge. (R/W)
SPI_RSCK_DATA_OUT Save half a cycle when tsck is the same as rsck. 1: output data at rsck
positive edge. 0: output data at tsck positive edge. (R/W)
SPI_CS_HOLD_DELAY SPI CS signal is delayed by SPI clock cycles. Can be configured in CONF
state. (R/W)
E
M
M
O
U
TI
M
_N
I
_T
P_
Y_
AY
LD
TU
LA
EL
O
DE
SE
_H
_D
d)
S_
S_
e
CS
CS
rv
C
se
I_
I_
I_
I_
SP
SP
SP
SP
(re
31 30 29 28 26 25 13 12 0
SPI_CS_SETUP_TIME (cycles+1) of prepare phase by SPI clock. These bits are used together with
SPI_CS_SETUP bit. Can be configured in CONF state. (R/W)
SPI_CS_HOLD_TIME Delay cycles of CS pin by SPI clock. These bits are used together with
SPI_CS_HOLD bit. Can be configured in CONF state. (R/W)
SPI_CS_DELAY_NUM SPI_CS signal is delayed by system clock cycles. Can be configured in CONF
state. (R/W)
LK
SC
SY
E
PR
_H
U_
_L
T_
V_
NT
NT
EQ
CN
I
KC
KC
KD
_
LK
LK
CL
CL
CL
C
C
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
31 30 18 17 12 11 6 5 0
SPI_CLKCNT_L In the master mode it must be equal to SPI_CLKCNT_N. In the slave mode it must
be 0. Can be configured in CONF state. (R/W)
SPI_CLKDIV_PRE In the master mode it is pre-divider of SPI_CLK. Can be configured in CONF state.
(R/W)
ed _ED IVE AP
N
se DLE AC _SW
_E
L
SP AD _DT SET T
SP CD DD _PO E
O
I_ D A_ SE
I_ _D R_ L
TR
I_ _A S G
I_ S_ _ E
E
_I P_ IN
K_ TR EN
_P
I_ _D M T
T
TA N
SP DQ MD DG
SP DA _D _EN
G
SP SL IDL SET
SP CD E_C ED
SP CD UM SE
SP CM AT Y_
CK EE _P
_D
DA _E
CS
CL D _
I_ AV E_
I_ TA_ TR
I_ _C _E
I_ _K IN
I_ DR R
R_
SP CS _D
SP CD LE
SP CS DIS
SP CS DIS
SP CS DIS
SP CS DIS
0_ S
S
SP CS IS
CS I
DI
TE
I_ 1_D
I_ ID
I_ AD
I_ _D
I_ 5_
I_ 4_
I_ 3_
I_ 2_
)
AS
ed
_
SP QU
SP CD
SP CK
rv
rv
M
se
I_
I_
I_
I_
SP
SP
SP
SP
(re
(re
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 13 12 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 1 1 1 1 1 0 Reset
SPI_CS0_DIS SPI CS0 pin disable bit. 1: disable CS0, 0: SPI_CS0 signal is from/to CS0 pin. Can
be configured in CONF state. (R/W)
SPI_CS1_DIS SPI CS1 pin disable bit. 1: disable CS1, 0: SPI_CS1 signal is from/to CS1 pin. Can
be configured in CONF state. (R/W)
SPI_CS2_DIS SPI CS2 pin disable bit. 1: disable CS2, 0: SPI_CS2 signal is from/to CS2 pin. Can
be configured in CONF state. (R/W)
SPI_CS3_DIS SPI CS3 pin disable bit. 1: disable CS3, 0: SPI_CS3 signal is from/to CS3 pin. Can
be configured in CONF state. (R/W)
SPI_CS4_DIS SPI CS4 pin disable bit. 1: disable CS4, 0: SPI_CS4 signal is from/to CS4 pin. Can
be configured in CONF state. (R/W)
SPI_CS5_DIS SPI CS5 pin disable bit. 1: disable CS5, 0: SPI_CS5 signal is from/to CS5 pin. Can
be configured in CONF state. (R/W)
SPI_CK_DIS 1: SPI CLK output disable, 0: SPI CLK output enable. Can be configured in CONF
state. (R/W)
SPI_MASTER_CS_POL In master mode, the bits are the polarity of SPI CS line. The value is equiv-
alent to SPI_CS ^ SPI_MASTER_CS_POL. Can be configured in CONF state. (R/W)
SPI_CLK_DATA_DTR_EN 1: SPI master DTR mode is applied to SPI CLK, data and SPI_DQS. 0: SPI
master DTR mode is only applied to SPI_DQS. This bit should be used with bit 17/18/19. (R/W)
SPI_DATA_DTR_EN 1: SPI CLK and data of SPI_DOUT and SPI_DIN states are in DTR mode, in-
cluding master 1/2/4/8-bit mode. 0: SPI CLK and DATA of SPI_DOUT and SPI_DIN states are in
STR mode. Can be configured in CONF state. (R/W)
SPI_ADDR_DTR_EN 1: SPI CLK and data of SPI_SEND_ADDR state are in DTR mode, including
master 1/2/4/8-bit mode. 0: SPI CLK and data of SPI_SEND_ADDR state are in STR mode. Can
be configured in CONF state. (R/W)
SPI_CMD_DTR_EN 1: SPI CLK and data of SPI_SEND_CMD state are in DTR mode, including mas-
ter 1/2/4/8-bit mode. 0: SPI CLK and data of SPI_SEND_CMD state are in STR mode. Can be
configured in CONF state. (R/W)
SPI_SLAVE_CS_POL Select polarity of SPI slave input CS. 1: inverted, 0: not change. Can be
configured in CONF state. (R/W)
SPI_DQS_IDLE_EDGE The default value of SPI_DQS. Can be configured in CONF state. (R/W)
SPI_CD_IDLE_EDGE The default value of SPI_CD. Can be configured in CONF state. (R/W)
SPI_CK_IDLE_EDGE 1: SPI CLK line is high when idle. 0: SPI CLK line is low when idle. Can be
configured in CONF state. (R/W)
SPI_CS_KEEP_ACTIVE Set this bit to keep the SPI CS line low. Can be configured in CONF state.
(R/W)
SPI_QUAD_DIN_PIN_SWAP 1: SPI quad input swap enable. 0: SPI quad input swap disable. Can
be configured in CONF state. (R/W)
)
ST
ed
ST
rv
M
se
I_
I_
SP
SP
(re
31 12 11 4 3 0
0x000 0 0 0 0 0 0 0 0 0 Reset
SPI_ST The status of SPI state machine. 0: idle state, 1: preparation state, 2: send command state,
3: send data state, 4: read data state, 5: write data state, 6: wait state, 7: done state. (RO)
NE
O
_D
NS
EG
IM
RA
AL N
_ V T_E
_T
_R
_T
UT
G
LD U
_O
O
SE
HO _
LD
I_ LD
A_
d)
)
ed
DM
HO
SP HO
ve
rv
er
se
I_
I_
I_
s
SP
SP
SP
(re
(re
31 8 7 6 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 Reset
SPI_HOLD_VAL_REG SPI output hold value, which should be used with SPI_HOLD_OUT_EN. Can
be configured in CONF state. (R/W)
SPI_HOLD_OUT_EN Enable set SPI output hold value to SPI_HOLD_REG. It can be used to hold SPI
state machine with SPI_EXT_HOLD_EN and other user hold signals. Can be configured in CONF
state. (R/W)
SPI_HOLD_OUT_TIME Set the hold cycles of output SPI_HOLD signal when SPI_HOLD_OUT_EN is
enabled. Can be configured in CONF state. (R/W)
N
_E
I_ _W DM _D E N
LR
I_ _R D O N N
SP INT D_ MA NE_ S_E
AN _B _D E_ N
SP INT R_ _D TRA _E
S_ UF ON EN
NE ON EN
EN
_C
TR D F N E
SP INT R_ A_ ON N
I_ _W NS _ INT
I_ _R BU DO E_
DO _D E_
O
E_
UT
SP INT RA SEG R_
_A
I_ _T _ ER
NE
S_ DE
SP INT MA IC_
TR _ ET
T
DO
CN
(re AN MO
I_ AVE ES
I_ _D G
SP INT MA
S_
SP SL _R
AN
I_ FT
I_ G_
)
)
ed
ed
ed
SP SO
TR
SP SE
rv
rv
rv
se
se
se
I_
I_
I_
SP
SP
SP
(re
(re
31 30 29 28 27 26 23 22 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 1 0 0 0 0 0 0 0 0 0 Reset
SPI_TRANS_DONE The interrupt raw bit for the completion of any operation in both the master mode
and the slave mode. Can not be changed by CONF_buf. (R/W)
SPI_TRANS_CNT The operations counter in both the master mode and the slave mode. (RO)
SPI_SLAVE_MODE Set SPI work mode. 1: slave mode, 0: master mode. (R/W)
SPI_SOFT_RESET Software reset enable, to reset the SPI clock line, CS line and data lines. Can be
configured in CONF state. (R/W)
LR
E
AN
RR LR
SP SLV DD ER ON
_C
M
_E _C
DR
I_ _A D_ _D
AD _E N
M
I_ _C Q R
I_ _ R R
DR RR
V_ D _E
SP SLV NO _ER
O
SP SLV M MA
AD
_C
SL M PI
T_
I_ _C _D
ST
_
S
SP SLV R
LA
LA
I_ _W
)
_
ed
LV
LV
SP SLV
rv
S
se
I_
I_
I_
SP
SP
SP
(re
31 24 23 16 15 14 13 12 11 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_SLV_NO_QPI_EN 1: SPI slave QPI mode is not supported. 0: SPI slave QPI mode is supported.
(R/W)
SPI_SLV_ADDR_ERR 1: The address value of the last SPI transfer is not supported by SPI slave. 0:
The address value is supported or no address value is received. (RO)
SPI_SLV_CMD_ERR 1: The command value of the last SPI transfer is not supported by SPI slave.
0: The command value is supported or no command value is received. (RO)
SPI_SLV_WR_DMA_DONE The interrupt raw bit for the completion of DMA write operation in slave
mode. Can not be changed by CONF_buf. (R/W)
NE
LE
DO
T
BI
F_
E_
BU
AS
R_
_B
W
NF
d)
V_
CO
e
SL
rv
se
I_
I_
SP
SP
(re
31 25 24 23 0
108 0 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_BUF_DONE The interrupt raw bit for the completion of write-buffer operation in slave
mode. Can not be changed by CONF_buf. (R/W)
SPI_CONF_BASE_BITLEN The basic SPI_CLK cycles of CONF state. The real cycle length of CONF
state, if SPI_USR_CONF is enabled, is SPI_CONF_BASE_BITLEN[6:0] + SPI_CONF_BITLEN[23:0].
(R/W)
EN
EL
NE
YT
UF RR
O
_B
_D
_B _E
RD
RD IC
A_
V_ AG
DM
SL M
I_ G_
d)
V_
ed
ve
SP SE
SL
rv
er
se
I_
I_
s
SP
SP
(re
(re
31 26 25 24 23 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
SPI_SLV_DMA_RD_BYTELEN In slave mode, it is the length in bytes for read operations. The register
value shall be byte_num. (R/W)
SPI_SLV_RD_BUF_DONE The interrupt raw bit for the completion of read-buffer operation in slave
mode. Can not be changed by CONF_buf. (R/W)
SPI_SEG_MAGIC_ERR 1: The recent magic value in CONF buffer is not right in master DMA
segmented-configure-transfer mode. 0: others. (R/W)
N_ N
EN
DM _B ELE _EN
BY EL EN
LE _E
UE
A_ YT N_
TE EN
AL
RD MA T EN
NE
_V
EN
V_ D BY L
SL R F_ TE
IC
DO
EL
I_ _W U BY
AG
T
A_
BY
SP SLV DB F_
_M
ed DM
(re V_R NF
I_ _R BU
_
G
TA
D_
O
SE
SP SLV R
DA
SL C
I_ _W
A_
I_ R_
V_
SP LV
DM
SP US
SL
rv
S
se
I_
I_
I_
I_
SP
SP
SP
SP
31 30 29 28 27 24 23 22 21 20 19 0
0 0 0 0 10 0 0 0 0 0 Reset
SPI_SLV_DATA_BYTELEN The full-duplex or half-duplex data byte length of the last SPI transfer in
slave mode. In half-duplex mode, this value is controlled by bits [23:20]. (R/W)
SPI_SLV_RD_DMA_DONE The interrupt raw bit for the completion of Rd_DMA operation in slave
mode. Can not be changed by CONF_buf. (R/W)
SP DM TX TIN PO S_ _EN
SP DM CO SE TR _CL EN
R R
I_ A_ T_ G_ S R_
I_ A_ _S UE P_ EN
CL CL
I_ A_ N G_ AN R
R
CL
SP DM LAS SE AN CL
SP SLV TX_ N LL_ Y_
LR
_E R_ T_ EN
DE EN
I_ _ V_ TR S_
I_ _ _E FU PT
_B S_C
O BU EN
UT C RS ST_
O _
SP SLV SL G_ AN
ZE
SP SLV OF O_ EM
M ST
SP OU CR _B N
ST
EM AN
SI
I_ A_ SE R
I_ TD _BU UR
F_ R
I_ _E IF _
I_ S TA E
I_ T_ AN P
I_ M_ _S P
T
K_
SP RX INF IFO
_R ST _R
SP IND DA S_
R
SP U TR O
SP DM RX_ G_
SP ME RX TO
_T
I_ T_ IFO
SP OU _F T
I_ A_ TF
I_ _ SE
I_ BM S
G
SP DM OU
SP AH _R
SE
O S
se ST
IN R
M
I_ BM
A_
I_ A_
)
)
T_
ed
ed
ed
ed
DM
SP M
SP AH
EX
rv
rv
rv
rv
O
D
se
se
se
I_
I_
I_
I_
SP
SP
SP
SP
(re
(re
(re
(re
31 29 28 27 26 25 24 23 22 21 20 19 18 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 1 0 0 0 0 0 0 0 0 0 Reset
SPI_IN_RST The bit is used to reset in_DMA FSM and in_data FIFO pointer. (R/W)
SPI_OUT_RST The bit is used to reset out_DMA FSM and out_data FIFO pointer. (R/W)
SPI_OUT_EOF_MODE out_EOF flag generation mode. 1: when DMA pops all data from FIFO. 0:
when AHB pushes all data to FIFO. (R/W)
SPI_OUTDSCR_BURST_EN Read descriptor uses burst mode when read data from memory. (R/W)
SPI_INDSCR_BURST_EN Read descriptor uses burst mode when write data to memory. (R/W)
SPI_OUT_DATA_BURST_EN SPI DMA reads data from memory in burst mode. (R/W)
SPI_MEM_TRANS_EN 1: Internal memory data transfer enable bit. Send SPI DMA RX buffer data
to SPI DMA TX buffer. 0: Disable this function. (R/W)
SPI_DMA_RX_STOP SPI DMA read data stops when in continuous tx/rx mode. (R/W)
SPI_DMA_TX_STOP SPI DMA write data stops when in continuous tx/rx mode. (R/W)
SPI_SLV_LAST_SEG_POP_CLR Before slave segmented-transfer starts, set first and then clear this
bit, to clear the data not used in last transfer. (R/W)
SPI_DMA_SLV_SEG_TRANS_EN Enable DMA segment transfer in SPI DMA half slave mode. 1:
enable. 0: disable. (R/W)
SPI_RX_EOF_EN 1: SPI_IN_SUC_EOF_INT_RAW is set when the number of DMA pushed data bytes
is equal to the value of SPI_SLV_DMA_RD_BYTELEN[19:0]/ SPI_MST_DMA_RD_BYTELEN[19:0]
in SPI DMA transition. 0: SPI_IN_SUC_EOF_INT_RAW is set by SPI_TRANS_DONE in non-
segment-transfer or SPI_DMA_SEG_TRANS_DONE in segment-transfer. (R/W)
R
P
DD
TO
UT K S
SP OU INK NA
O IN E
I_ TL _R
_A
I_ TL _E
NK
SP OU TX
LI
I_ A_
)
ed
UT
SP DM
rv
O
se
I_
I_
SP
SP
(re
31 30 29 28 27 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
SPI_DMA_TX_ENA 1: enable DMA controlled TX mode. 0: enable CPU controlled TX mode. (R/W)
DR
AD
S_
DE
F_
O
_E
RR
_E
IN
A_
DM
I_
SP
31 0
0 Reset
SPI_DMA_IN_ERR_EOF_DES_ADDR The inlink descriptor address when SPI DMA generates re-
ceiving error. (RO)
DR
D
_A
DES
F_
EO
UC_
_S
IN
A_
DM
I_
SP
31 0
0 Reset
SPI_DMA_IN_SUC_EOF_DES_ADDR The last inlink descriptor address when SPI DMA generates
FROM_SUC_EOF. (RO)
31 0
0 Reset
F0
_B
S CR
_D
NK
LI
IN
A_
DM
I_
SP
31 0
0 Reset
DR
AD
S_
DE
R_
BF
F_
O
_E
UT
O
A_
DM
I_
SP
31 0
0 Reset
31 0
0 Reset
SPI_DMA_OUT_EOF_DES_ADDR The last outlink descriptor address when SPI DMA generates
TO_EOF. (RO)
CR
DS
K_
LIN
UT
O
A_
DM
I_
SP
31 0
0 Reset
F0
_B
CR
S
_D
NK
LI
UT
O
A_
DM
I_
SP
31 0
0 Reset
DR
_F PTY
TA
L
NT
AD
UL
FI _EM
_S
TE
_C
_
CR
CR
TA
UT O
FO
FO
DS
DS
O IF
_S
FI
A_ UTF
UT
UT
UT
UT
DM O
O
I_ A_
A_
A_
A_
A_
SP DM
DM
DM
DM
DM
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
31 30 29 23 22 20 19 18 17 0
1 0 0 0 0 0 Reset
TE
DR
_F PTY
TA
L
NT
AD
UL
FI EM
_S
TE
_C
_
CR
CR
IN O_
TA
FO
FO
DS
DS
A_ FIF
_S
FI
DM IN
IN
IN
IN
IN
I_ A_
A_
A_
A_
A_
SP DM
DM
DM
DM
DM
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
31 30 29 23 22 20 19 18 17 0
1 0 0 0 0 0 Reset
_R
LI S A
_S RT
SP INL K_R NA
DR
TO
P
IN _ T
TO
I_ INK ES
I_ IN _E
D
_A
_A
SP INL RX
NK
K
I_ A_
IN
)
ed
LI
SP DM
L
IN
IN
rv
se
I_
I_
I_
SP
SP
SP
(re
31 30 29 28 27 21 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
SPI_INLINK_AUTO_RET When the bit is set, the inlink descriptor returns to the first link node when
a packet is in error. (R/W)
SPI_DMA_RX_ENA 1: enable DMA controlled RX mode. 0: enable CPU controlled RX mode. (R/W)
(R/W)
EN A
T_ E N
I_ SU N _E NT N A
Y_ IN A
A
SP IN_ DO INT F_I T_E _EN
PT R_ EN
I N T_
SP IN_ C_ E_IN NA _E A
EM RO T_
NA
I_ T_ F_ O IN NT
R_ ER _IN
SP OU EO L_E R_ R_I
SC R_ OR
I_ DO EO IN A
I_ IN _ IN N
I_ T_ TA ER R
I_ _ D8 T_ A
I_ _ D7 T_ A
I_ TF D6 T_ A
I_ IF _E T_ A
I_ T_ U T A
SP IN_ R_ F_ _EN
SP INL NE F_ T_E
SP OU TO LL_ Y_E
SP SLV M _IN EN
SP SLV CM _IN EN
SP OU CM _IN EN
SP INF IFO _IN EN
SP OU O_F MP EN
_D SC RR
IN IN CR A
I_ _C D9 T_
NK _D _E
I_ ER EO T
SP SLV M _IN
I_ _C DA
LI K
SP SLV M
I_ _C
)
ed
SP SLV
rv
se
I_
SP
(re
31 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
SPI_INLINK_DSCR_EMPTY_INT_ENA The enable bit for not enough inlink descriptors. Can be con-
figured in CONF state. (R/W)
SPI_OUTLINK_DSCR_ERROR_INT_ENA The enable bit for outlink descriptor error. Can be config-
ured in CONF state. (R/W)
SPI_INLINK_DSCR_ERROR_INT_ENA The enable bit for inlink descriptor error. Can be configured
in CONF state. (R/W)
SPI_IN_DONE_INT_ENA The enable bit for completing usage of an inlink descriptor. Can be config-
ured in CONF state. (R/W)
SPI_IN_ERR_EOF_INT_ENA The enable bit for receiving error. Can be configured in CONF state.
(R/W)
SPI_IN_SUC_EOF_INT_ENA The enable bit for completing receiving all the packets from host. Can
be configured in CONF state. (R/W)
SPI_OUT_DONE_INT_ENA The enable bit for completing usage of an outlink descriptor. Can be
configured in CONF state. (R/W)
SPI_OUT_EOF_INT_ENA The enable bit for sending a packet to host done. Can be configured in
CONF state. (R/W)
SPI_OUT_TOTAL_EOF_INT_ENA The enable bit for sending all the packets to host done. Can be
configured in CONF state. (R/W)
SPI_INFIFO_FULL_ERR_INT_ENA The enable bit for inFIFO full error interrupt. (R/W)
SPI_OUTFIFO_EMPTY_ERR_INT_ENA The enable bit for outFIFO empty error interrupt. (R/W)
SPI_SLV_CMD6_INT_ENA The enable bit for SPI slave CMD6 interrupt. (R/W)
SPI_SLV_CMD7_INT_ENA The enable bit for SPI slave CMD7 interrupt. (R/W)
SPI_SLV_CMD8_INT_ENA The enable bit for SPI slave CMD8 interrupt. (R/W)
SPI_SLV_CMD9_INT_ENA The enable bit for SPI slave CMD9 interrupt. (R/W)
SPI_SLV_CMDA_INT_ENA The enable bit for SPI slave CMDA interrupt. (R/W)
RA W
T_ R A
I_ SU N _R NT A AW
Y_ IN W
W
PT R_ RA
IN T_
SP IN_ DO INT F_I T_R _R
SP IN_ C_ E_IN AW _R W
EM RO T_
AW
I_ T_ F_ O IN NT
R_ ER _IN
SP OU EO L_E R_ R_I
SC R_ OR
I_ DO EO IN W
I_ _ D8 T_ W
I_ _ D7 T_ W
I_ TF D6 T_ W
I_ IF _E T_ W
I_ T_ U T W
I_ IN _ IN A
I_ T_ TA ER R
SP IN_ R_ F_ _RA
SP INL NE F_ T_R
SP OU TO LL_ Y_E
IN IN CR AW
SP SLV M _IN RA
SP SLV CM _IN RA
SP OU CM _IN RA
SP INF IFO _IN RA
SP OU O_F MP RA
_D SC RR
I_ _C D9 T_
NK _D _E
I_ ER EO T
SP SLV M _IN
I_ _C DA
LI K
SP SLV M
I_ _C
)
ed
SP SLV
rv
se
I_
SP
(re
31 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
SPI_INLINK_DSCR_EMPTY_INT_RAW The raw bit for not enough inlink descriptors. Can be con-
figured in CONF state. (RO)
SPI_OUTLINK_DSCR_ERROR_INT_RAW The raw bit for outlink descriptor error. Can be configured
in CONF state. (RO)
SPI_INLINK_DSCR_ERROR_INT_RAW The raw bit for inlink descriptor error. Can be configured in
CONF state. (RO)
SPI_IN_DONE_INT_RAW The raw bit for completing usage of an inlink descriptor. Can be configured
in CONF state. (RO)
SPI_IN_ERR_EOF_INT_RAW The raw bit for receiving error. Can be configured in CONF state. (RO)
SPI_IN_SUC_EOF_INT_RAW The raw bit for completing receiving all the packets from host. Can be
configured in CONF state. (RO)
SPI_OUT_DONE_INT_RAW The raw bit for completing usage of an outlink descriptor. Can be con-
figured in CONF state. (RO)
SPI_OUT_EOF_INT_RAW The raw bit for sending a packet to host done. Can be configured in CONF
state. (RO)
SPI_OUT_TOTAL_EOF_INT_RAW The raw bit for sending all the packets to host done. Can be
configured in CONF state. (RO)
SPI_INFIFO_FULL_ERR_INT_RAW If the size of the DMA RX buffer is smaller than the size of the
transferred data, the interrupt SPI_INFIFO_FULL_ERR_INT will be triggered. Can not be configured
in CONF phase. (RO)
SPI_SLV_CMD6_INT_RAW The raw bit for SPI slave CMD6 interrupt. (R/W)
SPI_SLV_CMD7_INT_RAW The raw bit for SPI slave CMD7 interrupt. (R/W)
SPI_SLV_CMD8_INT_RAW The raw bit for SPI slave CMD8 interrupt. (R/W)
SPI_SLV_CMD9_INT_RAW The raw bit for SPI slave CMD9 interrupt. (R/W)
SPI_SLV_CMDA_INT_RAW The raw bit for SPI slave CMDA interrupt. (R/W)
T_ ST
SP IN_ DO INT F_I T_S _ST
PT R_ ST
ST
IN T_
EM RO T_
Y_ IN
I_ T_ F_ O IN NT
I_ SU N _S NT T
R_ ER _IN
T
SP IN_ C_ E_IN T _S
SP OU EO L_E R_ R_I
SC R_ OR
I_ T_ TA ER R
I_ IN _ IN T
I_ TL S _ST T
SP INL NE F_ T_S
SP IN_ R_ F_ _ST
SP OU TO LL_ Y_E
_D SC RR
SP SLV CM _IN ST
SP OU CM _IN ST
SP INF IFO _IN ST
SP OU O_F MP ST
I_ _C D9 T_
I_ _ D8 T_
I_ _ D7 T_
I_ TF D6 T_
I_ IF _E T_
NK _D _E
I_ DO EO IN
I_ ER EO T
I_ T_ U T
SP SLV M _IN
IN IN CR
I_ _C DA
LI K
SP SLV M
I_ _C
d)
SP SLV
e
rv
se
I_
SP
(re
31 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
SPI_INLINK_DSCR_EMPTY_INT_ST The status bit for not enough inlink descriptors. (RO)
SPI_IN_DONE_INT_ST The status bit for completing usage of a inlink descriptor. (RO)
SPI_IN_SUC_EOF_INT_ST The status bit for completing receiving all the packets from host. (RO)
SPI_OUT_DONE_INT_ST The status bit for completing usage of a outlink descriptor. (RO)
SPI_OUT_EOF_INT_ST The status bit for sending a packet to host done. (RO)
SPI_OUT_TOTAL_EOF_INT_ST The status bit for sending all the packets to host done. (RO)
SPI_SLV_CMD6_INT_ST The status bit for SPI slave CMD6 interrupt. (R/W)
SPI_SLV_CMD7_INT_ST The status bit for SPI slave CMD7 interrupt. (R/W)
SPI_SLV_CMD8_INT_ST The status bit for SPI slave CMD8 interrupt. (R/W)
SPI_SLV_CMD9_INT_ST The status bit for SPI slave CMD9 interrupt. (R/W)
SPI_SLV_CMDA_INT_ST The status bit for SPI slave CMDA interrupt. (R/W)
CL R
T_ C L
I_ SU N _C NT L LR
Y_ IN R
R
PT R_ CL
IN T_
SP IN_ DO INT F_I T_C _C
SP IN_ C_ E_IN LR _C R
EM RO T_
LR
I_ T_ F_ O IN NT
R_ ER _IN
SP OU EO L_E R_ R_I
SC R_ OR
I_ DO EO IN R
I_ IN _ IN L
I_ T_ TA ER R
I_ _ D8 T_ R
I_ _ D7 T_ R
I_ TF D6 T_ R
I_ IF _E T_ R
I_ T_ U T R
SP INL NE F_ T_C
SP IN_ R_ F_ _CL
SP OU TO LL_ Y_E
SP SLV M _IN CL
SP SLV CM _IN CL
SP OU CM _IN CL
SP INF IFO _IN CL
SP OU O_F MP CL
_D SC RR
IN IN CR LR
I_ _C D9 T_
NK _D _E
I_ ER EO T
SP SLV M _IN
I_ _C DA
LI K
SP SLV M
I_ _C
d)
SP SLV
ve
er
I_
s
SP
(re
31 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
SPI_INLINK_DSCR_EMPTY_INT_CLR The clear bit for lack of enough inlink descriptors. Can be
configured in CONF state. (R/W)
SPI_OUTLINK_DSCR_ERROR_INT_CLR The clear bit for outlink descriptor error. Can be configured
in CONF state. (R/W)
SPI_INLINK_DSCR_ERROR_INT_CLR The clear bit for inlink descriptor error. Can be configured in
CONF state. (R/W)
SPI_IN_DONE_INT_CLR The clear bit for completing usage of a inlink descriptor. Can be configured
in CONF state. (R/W)
SPI_IN_ERR_EOF_INT_CLR The clear bit for receiving error. Can be configured in CONF state. (R/W)
SPI_IN_SUC_EOF_INT_CLR The clear bit for completing receiving all the packets from host. Can be
configured in CONF state. (R/W)
SPI_OUT_DONE_INT_CLR The clear bit for completing usage of a outlink descriptor. Can be con-
figured in CONF state. (R/W)
SPI_OUT_EOF_INT_CLR The clear bit for sending a packet to host done. Can be configured in
CONF state. (R/W)
SPI_OUT_TOTAL_EOF_INT_CLR The clear bit for sending all the packets to host done. Can be
configured in CONF state. (R/W)
SPI_SLV_CMD6_INT_CLR The clear bit for SPI slave CMD6 interrupt. (R/W)
SPI_SLV_CMD7_INT_CLR The clear bit for SPI slave CMD7 interrupt. (R/W)
SPI_SLV_CMD8_INT_CLR The clear bit for SPI slave CMD8 interrupt. (R/W)
SPI_SLV_CMD9_INT_CLR The clear bit for SPI slave CMD9 interrupt. (R/W)
SPI_SLV_CMDA_INT_CLR The clear bit for SPI slave CMDA interrupt. (R/W)
F0
BU
I_
SP
31 0
0 Reset
SPI_BUF0 32 bits data buffer 0, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
F1
BU
I_
31 SP 0
0 Reset
SPI_BUF1 32 bits data buffer 1, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
31 0
0 Reset
SPI_BUF2 32 bits data buffer 2, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
31 0
0 Reset
SPI_BUF3 32 bits data buffer 3, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
F4
BU
I_
SP
31 0
0 Reset
SPI_BUF4 32 bits data buffer 4, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
F5
BU
I_
31 SP 0
0 Reset
SPI_BUF5 32 bits data buffer 5, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
31 0
0 Reset
SPI_BUF6 32 bits data buffer 6, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
31 0
0 Reset
SPI_BUF7 32 bits data buffer 7, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
F8
BU
I_
SP
31 0
0 Reset
SPI_BUF8 32 bits data buffer 8, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
F9
BU
I_
31 SP 0
0 Reset
SPI_BUF9 32 bits data buffer 9, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
31 0
0 Reset
SPI_BUF10 32 bits data buffer 10, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
31 0
0 Reset
SPI_BUF11 32 bits data buffer 11, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
2
F1
BU
I_
SP
31 0
0 Reset
SPI_BUF12 32 bits data buffer 12, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
3
F1
BU
I_
SP
31 0
0 Reset
SPI_BUF13 32 bits data buffer 13, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
31 0
0 Reset
SPI_BUF14 32 bits data buffer 14, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
31 0
0 Reset
SPI_BUF15 32 bits data buffer 15, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
6
F1
BU
I_
SP
31 0
0 Reset
SPI_BUF16 32 bits data buffer 16, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
7
F1
BU
I_
SP
31 0
0 Reset
SPI_BUF17 32 bits data buffer 17, transferred in the unit of byte. Byte addressable in slave half-duplex
mode. (R/W)
NA
_E
LK
DE
DE
DE
DE
DE
DE
DE
DE
_C
O
_M
_M
_M
_M
_M
_M
_M
_M
G
IN
)
N7
N6
N5
N4
N3
N2
N1
N0
ed
M
rv
DI
DI
DI
DI
DI
DI
DI
DI
TI
se
I_
I_
I_
I_
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
SP
SP
SP
SP
(re
31 25 24 23 21 20 18 17 15 14 12 11 9 8 6 5 3 2 0
SPI_DIN0_MODE Select clock source, and sample input signal FSPID from the master with delays.
0: input without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling edge of
APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK. Can be
configured in CONF state. (R/W)
SPI_DIN1_MODE Select clock source, and sample input signal FSPIQ from the master with delays.
0: input without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling edge of
APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK. Can be
configured in CONF state. (R/W)
SPI_DIN2_MODE Select clock source, and sample input signal FSPIWP from the master with delays.
0: input without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling edge of
APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK. Can be
configured in CONF state. (R/W)
SPI_DIN3_MODE Select clock source, and sample input signal FSPIHD from the master with delays.
0: input without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling edge of
APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK. Can be
configured in CONF state. (R/W)
SPI_DIN4_MODE Select clock source, and sample input signal FSPIIO4 from the master with delays.
0: input without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling edge of
APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK. Can be
configured in CONF state. (R/W)
SPI_DIN5_MODE Select clock source, and sample input signal FSPIIO5 from the master with delays.
0: input without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling edge of
APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK. Can be
configured in CONF state. (R/W)
SPI_DIN6_MODE Select clock source, and sample input signal FSPIIO6 from the master with delays.
0: input without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling edge of
APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK. Can be
configured in CONF state. (R/W)
SPI_DIN7_MODE Select clock source, and sample input signal FSPIIO7 from the master with delays.
0: input without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling edge of
APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK. Can be
configured in CONF state. (R/W)
SPI_TIMING_CLK_ENA 1: enable high-frequency clock: HCLK 160 MHz. 0: disable. Can be con-
figured in CONF state. (R/W)
UM
UM
UM
UM
UM
UM
UM
NU
_N
_N
_N
_N
_N
_N
_N
_
d)
N7
N6
N5
N4
N3
N2
N1
N0
ve
DI
DI
DI
DI
DI
DI
DI
DI
r
se
I_
I_
I_
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
SP
SP
SP
(re
31 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SPI_DIN0_NUM Configure the delays to input signal FSPID based on the setting of SPI_DIN0_MODE.
0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be configured in CONF state.
(R/W)
SPI_DIN1_NUM The Configure the delays to input signal FSPIQ based on the setting of
SPI_DIN1_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be configured
in CONF state. (R/W)
SPI_DIN2_NUM Configure the delays to input signal FSPIWP based on the setting of
SPI_DIN2_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be configured
in CONF state. (R/W)
SPI_DIN3_NUM Configure the delays to input signal FSPIHD based on the setting of
SPI_DIN3_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be configured
in CONF state. (R/W)
SPI_DIN4_NUM Configure the delays to input signal FSPIIO4 based on the setting of
SPI_DIN4_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be configured
in CONF state. (R/W)
SPI_DIN5_NUM Configure the delays to input signal FSPIIO5 based on the setting of
SPI_DIN5_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be configured
in CONF state. (R/W)
SPI_DIN6_NUM Configure the delays to input signal FSPIIO6 based on the setting of
SPI_DIN6_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be configured
in CONF state. (R/W)
SPI_DIN7_NUM Configure the delays to input signal FSPIIO7 based on the setting of
SPI_DIN7_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be configured
in CONF state. (R/W)
DE
DE
DE
DE
DE
DE
DE
DE
O
O
M
_M
_M
7_
6_
5_
4_
3_
1_
2
0
UT
UT
UT
UT
UT
UT
UT
UT
d)
ve
DO
DO
DO
DO
DO
DO
DO
DO
r
se
I_
I_
I_
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
SP
SP
SP
(re
31 24 23 21 20 18 17 15 14 12 11 9 8 6 5 3 2 0
SPI_DOUT0_MODE Select clock source, and sample output signal FSPID from the master with de-
lays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_DOUT1_MODE Select clock source, and sample output signal FSPIQ from the master with de-
lays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_DOUT2_MODE Select clock source, and sample output signal FSPIWP from the master with
delays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_DOUT3_MODE Select clock source, and sample output signal FSPIHD from the master with
delays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_DOUT4_MODE Select clock source, and sample output signal FSPIIO4 from the master with
delays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_DOUT5_MODE Select clock source, and sample output signal FSPIIO5 from the master with
delays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_DOUT6_MODE Select clock source, and sample output signal FSPIIO6 from the master with
delays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_DOUT7_MODE Select clock source, and sample output signal FSPIIO7 from the master with
delays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
UM
UM
UM
M
NU
NU
NU
NU
NU
_N
_N
_N
6_
4_
3_
1_
0_
7
2
UT
UT
UT
UT
UT
UT
UT
UT
d)
ve
DO
DO
DO
DO
DO
DO
DO
DO
r
se
I_
I_
I_
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
SP
SP
SP
(re
31 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SPI_DOUT0_NUM Configure the delays to output signal FSPID based on the setting of
SPI_DOUT0_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
SPI_DOUT1_NUM Configure the delays to output signal FSPIQ based on the setting of
SPI_DOUT1_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
SPI_DOUT2_NUM Configure the delays to output signal FSPIWP based on the setting of
SPI_DOUT2_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
SPI_DOUT3_NUM Configure the delays to output signal FSPIHD based on the setting of
SPI_DOUT3_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
SPI_DOUT4_NUM Configure the delays to output signal FSPIIO4 based on the setting of
SPI_DOUT4_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
SPI_DOUT5_NUM Configure the delays to output signal FSPIIO5 based on the setting of
SPI_DOUT5_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
SPI_DOUT6_NUM Configure the delays to output signal FSPIIO6 based on the setting of
SPI_DOUT6_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
SPI_DOUT7_NUM Configure the delays to output signal FSPIIO7 based on the setting of
SPI_DOUT7_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
HT
HT
NT
N
_E
G
IG
RO
EI
HE
DE
F
H
B_
A_
_
O
VT
_M
_H
_V
D_
CD
CD
LC
LC
L
L
I_
I_
I_
I_
SP
SP
SP
SP
31 30 21 20 11 10 0
0 0 0 0 Reset
SPI_LCD_HB_FRONT It is the horizontal blank front porch of a frame. Can be configured in CONF
state. (R/W)
SPI_LCD_VA_HEIGHT It is the vertical active height of a frame. Can be configured in CONF state.
(R/W)
SPI_LCD_VT_HEIGHT It is the vertical total height of a frame. Can be configured in CONF state.
(R/W)
SPI_LCD_MODE_EN 1: Enable LCD mode output vsync, hsync, de. 0: Disable. Can be configured
in CONF state. (R/W)
NT
H
TH
RO
ID
ID
_W
_W
_F
A
HT
B
_H
_V
D_
D
LC
LC
LC
I_
I_
I_
SP
SP
SP
31 20 19 8 7 0
0 0 0 Reset
SPI_LCD_VB_FRONT It is the vertical blank front porch of a frame. Can be configured in CONF state.
(R/W)
SPI_LCD_HA_WIDTH It is the horizontal active width of a frame. Can be configured in CONF state.
(R/W)
SPI_LCD_HT_WIDTH It is the horizontal total width of a frame. Can be configured in CONF state.
(R/W)
N
O
H
TI
TH
T
SI
L
ID
ID
PO
O
O
_W
_W
_P
_P
E_
NC
NC
NC
L
DL
ID
SY
SY
SY
_I
C_
NC
_H
_H
V
YN
D_
)
ed
D
SY
HS
LC
LC
LC
rv
V
se
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
(re
31 24 23 22 16 15 8 7 6 0
0 0 1 0 0 0 0 0 0 0 0 0 1 Reset
SPI_VSYNC_IDLE_POL It is the idle value of spi_vsync. Can be configured in CONF state. (R/W)
SPI_HSYNC_IDLE_POL It is the idle value of spi_hsync. Can be configured in CONF state. (R/W)
DE
DE
E_ EN
DE
O
L
DE
M
DE
M
PO
DL _
O
C_
_I NK
C_
M
O
_M
YN
_M
S_
YN
DE LA
DQ
CD
HS
I_ _B
DE
VS
d)
ve
SP HS
D_
D_
D_
D_
D_
r
se
I_
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
SP
(re
31 17 16 15 14 12 11 9 8 6 5 3 2 0
SPI_D_DQS_MODE Select clock source, and sample output signal FSPIDQS from the master with
delays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_D_CD_MODE Select clock source, and sample output signal FSPICD from the master with de-
lays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_D_DE_MODE Select clock source, and sample output signal FSPI_DE from the master with de-
lays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the falling
edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of HCLK.
Can be configured in CONF state. (R/W)
SPI_D_HSYNC_MODE SPI_HSYNC output mode. 0: output Select clock source, and sample output
signal FSPI_HSYNC from the master with delays. 0: output without delay. 1: sample at the rising
edge of APB_CLK. 2: sample at the falling edge of APB_CLK. 3: sample at the rising edge of
HCLK. 4: sample at the falling edge of HCLK. Can be configured in CONF state. (R/W)
SPI_D_VSYNC_MODE Select clock source, and sample output signal FSPI_VSYNC from the master
with delays. 0: output without delay. 1: sample at the rising edge of APB_CLK. 2: sample at the
falling edge of APB_CLK. 3: sample at the rising edge of HCLK. 4: sample at the falling edge of
HCLK. Can be configured in CONF state. (R/W)
SPI_HS_BLANK_EN 1: The pulse of SPI_HSYNC is out in vertical blanking lines in seg-trans or one
trans. 0: SPI_HSYNC pulse is valid only in active region lines in segment transfer. (R/W)
UM
M
NU
M
_N
UM
UM
NU
C_
NC
_N
S_
YN
_N
Y
DQ
CD
HS
DE
VS
d)
ve
D_
D_
D_
D_
D_
r
se
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
(re
31 10 9 8 7 6 5 4 3 2 1 0
SPI_D_DQS_NUM Configure the delays to output signal FSPIDQS based on the setting of
SPI_D_DQS_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be config-
ured in CONF state. (R/W)
SPI_D_CD_NUM Configure the delays to output signal FSPI_CD based on the setting of
SPI_D_CD_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be con-
figured in CONF state. (R/W)
SPI_D_DE_NUM Configure the delays to output signal FSPI_DE based on the setting of
SPI_D_DE_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be con-
figured in CONF state. (R/W)
SPI_D_HSYNC_NUM Configure the delays to output signal FSPI_HSYNC based on the setting of
SPI_D_HSYNC_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be
configured in CONF state. (R/W)
SPI_D_VSYNC_NUM Configure the delays to output signal FSPI_VSYNC based on the setting of
SPI_D_VSYNC_MODE. 0: delayed by 1 clock cycle, 1: delayed by 2 clock cycles,... Can be
configured in CONF state. (R/W)
DA
rv
se
I_
SP
(re
31 28 27 0
0 0 0 0 0x1907240 Reset
25.1 Overview
The I2C (Inter-Integrated Circuit) controller allows ESP32-S2 to communicate with multiple peripheral devices.
These peripheral devices can share one bus.
25.2 Features
The I2C controller has the following features:
The master initiates communication by generating a start condition: pulling the SDA line low while SCL is high,
and sending nine clock pulses via SCL. The first eight pulses are used to transmit a byte, which consists of a
7-bit address followed by a read/write (R/W ) bit. If the address of a slave matches the 7-bit address transmitted,
this matching slave can respond by pulling SDA low on the ninth clock pulse. The master and the slave can send
or receive data according to the R/W bit. Whether to terminate the data transfer or not is determined by the
logic level of the acknowledge (ACK) bit. During data transfer, SDA changes only when SCL is low. Once finishing
communication, the master sends a STOP condition: pulling SDA up while SCL is high. If a master both reads
and writes data in one transfer, then it should send a RESTART condition, a slave address and a R/W bit before
changing its operation.
The I2C controller runs either in master mode or slave mode, which is determined by I2C_MS_MODE bit. Figure
25-1 shows the architecture of a master, while Figure 25-2 shows that of a slave. The I2C controller has the
following main parts: transmit and receive memory (TX/RX RAM), command controller (CMD_Controller), SCL
clock controller (SCL_FSM), SDA data controller (SCL_MAIN_FSM), serial-to-parallel data converter
(DATA_Shifter), filter for SCL (SCL_Filter) and filter for SDA (SDA_Filter).
RX RAM stores data the I2C controller receives during communication. When the I2C controller works in slave
mode, neither slave addresses sent by the master nor register addresses (only in double addressing mode) will
be stored into RX RAM. Values of RX RAM can be read by software after I2C communication completes.
Both TX RAM and RX RAM can be accessed in FIFO or non-FIFO mode. The I2C_NONFIFO_EN bit sets FIFO or
non-FIFO mode.
TX RAM can be read and written by the CPU. The CPU writes to TX RAM either in FIFO mode or in non-FIFO
mode (direct address). In FIFO mode, the CPU writes to TX RAM via fixed address I2C_DATA_REG, with
addresses for writing in TX RAM incremented automatically by hardware. In non-FIFO mode, the CPU accesses
TX RAM directly via address fields (I2C Base Address + 0x100) ~(I2C Base Address + 0x17C). Each byte in TX
RAM occupies an entire word in the address space. Therefore, the address of the first byte is I2C Base Address
+ 0x100, the second byte I2C Base Address + 0x104, the third byte I2C Base Address + 0x108, and so on. The
CPU can only read TX RAM via direct addresses. Unlike addresses for writing, TX RAM must be read back from
addresses starting at I2C Base Address + 0x80.
RX RAM can only be read by the CPU. The CPU reads RX RAM either in FIFO mode or in non-FIFO mode (direct
address). In FIFO mode, the CPU reads RX RAM via fixed address I2C_DATA_REG, with addresses for reading
RX RAM incremented automatically by hardware. In non-FIFO mode, the CPU accesses TX RAM directly via
address fields (I2C Base Address + 0x100) ~(I2C Base Address + 0x17C). Each byte in RX RAM occupies an
entire word in the address space. Therefore, the address of the first byte is I2C Base Address + 0x100, the
second byte I2C Base Address + 0x104, the third byte I2C Base Address + 0x108 and so on.
Given that addresses for writing to TX RAM have an identical range with those for reading RX RAM, TX RAM and
RX RAM can be seen as a 32 x 8 RAM. In following sections TX RAM and RX RAM are referred to as RAM.
25.3.2.2 CMD_Controller
When the I2C controller works in master mode, the integrated CMD_Controller module reads commands from 16
sequential command registers and controls SCL_FSM and SDA_FSM accordingly.
Command registers, whose structure is illustrated in Figure 25-3, are active only when the I2C controller works in
1. CMD_DONE: Indicates that a command has been executed. After each command has been executed, the
corresponding CMD_DONE bit is set to 1 by hardware. By reading this bit, software can tell if the
command has been executed. When writing new commands, this bit must be cleared by software.
2. op_code: Indicates the command. The I2C controller supports five commands:
• RSTART: op_code = 0: The I2C controller sends a START bit and a RESTART bit defined by the I2C
protocol.
• WRITE: op_code = 1: The I2C controller sends a slave address, a register address (only in double
addressing mode) and data to the slave.
• READ: op_code = 2: The I2C controller reads data from the slave.
• STOP: op_code = 3: The I2C controller sends a STOP bit defined by the I2C protocol. This code also
indicates that the command sequence has been executed, and the CMD_Controller stops reading
commands. After restarted by software, the CMD_Controller resumes reading commands from
command register 0.
• END: op_code = 4: The I2C controller pulls the SCL line down and suspends I2C communication.
This code also indicates that the command sequence has completed, and the CMD_Controller stops
executing commands. Once software refreshes data in command registers and the RAM, the
CMD_Controller can be restarted to execute commands from command register 0 again.
3. ack_value: Used to configure the level of the ACK bit sent by the I2C controller during a read operation.
This bit is ignored during RSTART, STOP, END and WRITE conditions.
4. ack_exp: Used to configure the level of the ACK bit expected by the I2C controller during a write operation.
This bit is ignored during RSTART, STOP, END and READ conditions.
5. ack_check_en: Used to enable the I2C controller during a write operation to check whether ACK’s level
sent by the slave matches ack_exp in the command. If this bit is set and the level received does not match
ack_exp in the WRITE command, the master will generate an I2C_NACK_INT interrupt and a STOP
condition for data transfer. If this bit is cleared, the controller will not check the ACK level sent by the slave.
This bit is ignored during RSTART, STOP, END and READ conditions.
6. byte_num: Specifies the length of data (in bytes) to be read or written. Can range from 1 to 255 bytes. This
bit is ignored during RSTART, STOP and END conditions.
Each command sequence is executed starting from command register 0 and terminated by a STOP or an END.
Therefore, all 16 command registers must have a STOP or an END command.
A complete data transfer on the I2C bus should be initiated by a START and terminated by a STOP. The transfer
process may be completed using multiple sequences, separated by END commands. Each sequence may differ
in the direction of data transfer, clock frequency, slave addresses, data length, data to be transmitted, etc. This
allows efficient use of available peripheral RAM and also achieves more flexible I2C communication.
25.3.2.3 SCL_FSM
The integrated SCL_FSM module controls the SCL clock line. The frequency and duty cycle of SCL is configured
using I2C_SCL_LOW_PERIOD_REG, I2C_SCL_HIGH_PERIOD_REG and I2C_SCL_WAIT_HIGH_PERIOD. After
being in non-IDLE state for over I2C_SCL_ST_TO clock cycles, SCL_FSM triggers an I2C_SCL_ST_TO_INT
interrupt and returns to IDLE state.
25.3.2.4 SCL_MAIN_FSM
The integrated SCL_MAIN_FSM module controls the SDA data line and data storage. After being in non-IDLE
state for over I2C_SCL_MAIN_ST_TO clock cycles, SCL_MAIN_FSM triggers an I2C_SCL_MAIN_ST_TO_INT
interrupt and returns to IDLE state.
25.3.2.5 DATA_Shifter
The integrated DATA_Shifter module is used for serial/parallel conversion, converting TX RAM byte data to an
outgoing serial bitstream or an incoming serial bitstream to RX RAM byte data. I2C_RX_LSB_FIRST and
I2C_TX_LSB_FIRST can be used to select LSB- or MSB-first storage and transmission of data.
SCL_Filter samples input signals on the SCL line continuously. These input signals are valid only if they remain
unchanged for consecutive I2C_SCL_FILTER_THRES clock cycles. Given that only valid input signals can pass
through the filter, SCL_Filter can remove glitches whose pulse width is lower than I2C_SCL_FILTER_THRES APB
clock cycles.
SDA_Filter is identical to SCL_Filter, only applied to the SDA line. The threshold pulse width is provided in the
I2C_SDA_FILTER_THRES register.
Figure 25-4 shows the timing diagram of an I2C master. The unit of parameters in this figure is I2C_CLK
(TI2C_CLK ). Specifically, when I2C_REF_ALWAYS_ON = 1, TI2C_CLK is TAP B_CLK ; when
I2C_REF_ALWAYS_ON = 0, TI2C_CLK is TREF _T ICK . Figure 25-4 also specifies registers used to configure the
START bit, STOP bit, data hold time, data sample time, waiting time on the rising SCL edge, etc. Parameters in
Figure 25-4 are described as the following:
1. I2C_SCL_START_HOLD_TIME: Specifies the interval between pulling SDA low and pulling SCL low when
the master generates a START condition. This interval is (I2C_SCL_START_HOLD_TIME +1) × TI2C_CLK .
This register is active only when the I2C controller works in master mode.
2. I2C_SCL_LOW_PERIOD: Specifies the low period of SCL. This period lasts (I2C_SCL_START_HOLD_TIME
+1) × TI2C_CLK . However, it could be extended when SCL is pulled low by peripheral devices or by an
END command executed by the I2C controller, or when the clock is stretched. This register is active only
when the I2C controller works in master mode.
3. I2C_SCL_WAIT_HIGH_PERIOD: Specifies time for SCL to go high in TI2C_CLK . Please make sure that
SCL could be pulled high within this time period. Otherwise, the high period of SCL may be incorrect. This
register is active only when the I2C controller works in master mode.
4. I2C_SCL_HIGH_PERIOD: Specifies the high period of SCL in TI2C_CLK . This register is active only when
the I2C controller works in master mode. When SCL goes high within (I2C_SCL_WAIT_HIGH_PERIOD + 1)
× TI2C_CLK , its frequency is:
fI2C_CLK
fscl =
I2C_SCL_LOW_PERIOD + 1 + I2C_SCL_HIGH_PERIOD + I2C_SCL_WAIT_HIGH_PERIOD
5. I2C_SDA_SAMPLE_TIME: Specifies the interval between the rising edge of SCL and the level sampling
time of SDA. It is advised to set a value in the middle of SCL’s high period. This register is active both in
master mode and slave mode.
6. I2C_SDA_HOLD_TIME: Specifies the interval between changing the SDA output level and the falling edge
of SCL. This register is active both in master mode and slave mode.
SCL and SDA output drivers must be configured as open drain. There are two ways to achieve this:
Because these lines are configured as open-drain, the low to high transition time of each line is determined
together by the pull-up resistor and line capacitance. The output frequency of I2C is limited by the SDA and SCL
line’s pull-up speed, mainly SCL’s speed.
In addition, when I2C_SCL_FORCE_OUT and I2C_SCL_PD_EN are set to 1, SCL can be forced low; when
I2C_SDA_FORCE_OUT and I2C_SDA_PD_EN are set to 1, SDA can be forced low.
25.4.1 An I2C Master Writes to an I2C Slave with a 7bit Address in One Command
Sequence
Figure 255. An I2C Master Writing to an I2C Slave with a 7bit Address
Figure 25-5 shows how an I2C master writes N bytes of data using 7-bit addressing. As shown in figure 25-5,
the first byte in the master’s RAM is a 7-bit slave address followed by a R/W bit. When the R/W bit is zero, it
indicates a WRITE operation. The remaining bytes are used to store data ready for transfer. The cmd box
contains related command sequences.
After the command sequence is configured and data in RAM is ready, the master enables the controller and
initiates data transfer by setting I2C_TRANS_START bit. The controller has four steps to take:
1. Wait for SCL to go high, to avoid SCL used by other masters or slaves.
3. Execute a WRITE command by taking N+1 bytes from the RAM in order and send them to the slave in the
same order. The first byte is the address of the slave.
4. Send a STOP. Once the I2C master transfers a STOP bit, an I2C_TRANS_COMPLETE_INT interrupt is
generated.
If data to be transferred is larger than 32 bytes, the RAM access will wrap around. While the controller sends
data, software must replace data already sent in RAM. To assist with this process, the master will generate an
I2C_TXFIFO_WM_INT interrupt when less than I2C_TXFIFO_WM_THRHD bytes of data remain to be sent.
After detecting this interrupt, software can refresh data in RAM. When the RAM is accessed in non-FIFO mode, in
order to overwrite existing data in the RAM with new ones, software needs to first configure I2C_TX_UPDATE bit
to latch the start address and the end address of data sent in the RAM, and then read I2C_TXFIFO_START_ADDR
and I2C_TXFIFO_END_ADDR field in I2C_FIFO_ST_REG register to obtain these addresses. When the RAM is
accessed in FIFO mode, new data can be written to the RAM directly via I2C_DATA_REG register.
The controller stops executing the command sequence after a STOP command, or when one of the following
two events occurs:
1. When ack_check_en is set to 1, the I2C master checks 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, the master
generates an I2C_NACK_INT interrupt and stops the transmission.
2. During the high period of SCL, if the input value and the output value of SDA do not match, the I2C master
generates an I2C_ARBITRATION_LOST_INT interrupt, stops executing the command sequence, returns to
IDLE state and releases SCL and SDA.
Once detecting a START bit sent by the I2C master, the I2C slave receives the address and compares it with its
own address. If the received address does not match I2C_SLAVE_ADDR[6:0], the slave stops receiving data. If
the received address does match I2C_SLAVE_ADDR[6:0], the slave receives data and stores them into the RAM
in order.
If data to be transferred is larger than 32 bytes, the RAM may wrap around. While the controller receives data,
software reclaim data already received by the slave. To assist with this process, the master will generate an
I2C_RXFIFO_WM_INT after I2C_RXFIFO_WM_THRHD bytes are received in RAM.
Once detecting this interrupt, software can read data from the RAM registers. When the RAM is accessed in
non-FIFO mode, in order to read data, software needs to configure I2C_RX_UPDATE bit to latch the start
address and the end address of data to be reclaimed, and read I2C_RXFIFO_START_ADDR and
I2C_RXFIFO_END_ADDR fields in I2C_FIFO_ST_REG register to obtain these addresses. When the RAM is
accessed in FIFO mode, data can be read directly via I2C_DATA_REG register.
25.4.2 An I2C Master Writes to an I2C Slave with a 10bit Address in One Command
Sequence
Besides 7-bit addressing (SLV_ADDR[6:0]), the ESP32-S2 I2C controller also supports 10-bit addressing
(SLV_ADDR[9:0]). In the following text, the slave address is referred to as SLV_ADDR.
Figure 25-6 shows how an I2C master writes N-bytes of data using 10-bit addressing. Unlike a 7-bit address, a
10-bit slave address is formed from two bytes. In master mode, the first byte of the slave address, which
comprises slave_addr_first_7bits and a R/W bit, is stored into addr0 in the RAM. slave_addr_first_7bits should
be configured as (0x78 | SLV_ADDR[9:8]). The second byte slave_addr_second_byte is stored into addr1 in the
RAM. slave_addr_second_byte should be configured as SLV_ADDR[7:0].
In the slave, the 10-bit addressing mode is enabled by configuring I2C_ADDR_10BIT_EN bit. The address of the
I2C slave is configured using I2C_SLAVE_ADDR. I2C_SLAVE_ADDR[14:7] should be configured as
SLV_ADDR[7:0], and I2C_SLAVE_ADDR[6:0] should be configured as (0x78 | SLV_ADDR[9:8]). Since a 10-bit
slave address has one more byte than a 7-bit address, byte_num of the WRITE command and the number of
bytes in the RAM increase by one.
25.4.3 An I2C Master Writes to an I2C Slave with Two 7bit Addresses in One Command
Sequence
Figure 257. An I2C Master Writing Address M in the RAM to an I2C Slave with a 7bit Address
When working in slave mode, the controller supports double addressing, where the first address is the address of
an I2C slave, and the second one is the slave’s memory address. Double addressing is enabled by configuring
I2C_FIFO_ADDR_CFG_EN. When using double addressing, RAM must be accessed in non-FIFO mode. As
figure 25-7 illustrates, the I2C slave put received byte0 ~ byte(N-1) into its RAM in an order staring from addrM.
The RAM is overwritten every 32 bytes.
25.4.4 An I2C Master Writes to an I2C Slave with a 7bit Address in Multiple Command
Sequences
Figure 258. An I2C Master Writing to an I2C Slave with a 7bit Address in Multiple Sequences
Given that the I2C Controller RAM holds only 32 bytes, when data are too large to be processed even by the
wrapped RAM, it is advised to transmit them in multiple command sequences. At the end of every command
sequence is an END command. When the controller executes this END command to pull SCL low, software
refreshes command sequence registers and the RAM for next the transmission.
Figure 25-8 shows how an I2C master writes to an I2C slave in two or three segments. For the first segment, the
CMD_Controller registers are configured as shown in Segment0. Once data in the master’s RAM is ready and
I2C_TRANS_START is set, the master initiates data transfer. After executing the END command, the master
turns off the SCL clock and pulls the SCL low to reserve the bus. Meanwhile, the controller generates an
I2C_END_DETECT_INT interrupt.
For the second segment, after detecting the I2C_END_DETECT_INT interrupt, software refreshes the
CMD_Controller registers, reloads the RAM and clears this interrupt, as shown in Segment1. If cmd1 in the
second segment is a STOP, then data is transmitted to the slave in two segments. The master resumes data
transfer after I2C_TRANS_START is set, and terminates the transfer by sending a STOP bit.
For the third segment, after the second data transfer finishes and an I2C_END_DETECT_INT is detected, the
CMD_Controller registers of the master are configured as shown in Segment2. Once I2C_TRANS_START is set,
the master generates a STOP bit and terminates the transfer.
Please note that other I2C masters will not transact on the bus between two segments. The bus is only released
after a STOP signal is sent. To interrupt the transfer, the I2C controller can be reset by setting I2C_FSM_RST at
any time. This register will later be cleared automatically by hardware.
When the master is in IDLE state and I2C_SCL_RST_SLV_EN is set, hardware sends I2C_SCL_RST_SLV_NUM
SCL pulses. I2C_SCL_RST_SLV_EN will later be cleared automatically by hardware.
Note that the operation of other I2C masters and I2C slaves may differ from that of the ESP32-S2 I2C devices.
Please refer to datasheets of specific I2C devices.
25.4.5 An I2C Master Reads an I2C Slave with a 7bit Address in One Command Se
quence
Figure 259. An I2C Master Reading an I2C Slave with a 7bit Address
Figure 25-9 shows how an I2C master reads N bytes of data from an I2C slave using 7-bit addressing. cmd1 is a
WRITE command, and when this command is executed the master sends a slave address. The byte sent
comprises a 7-bit slave address and a R/W bit. When the R/W bit is 1, it indicates a READ operation. If the
address of an I2C slave matches the sent address, this matching slave starts sending data to the master. The
master generates acknowledgements according to ack_value defined in the READ command upon receiving
every byte.
As illustrated in Figure 25-9, the master executes two READ commands: it generates ACKs for (N-1) bytes of
data in cmd2, and a NACK for the last byte of data in cmd 3. This configuration may be changed as required.
The master writes received data into the controller RAM from addr0, whose original content (a slave address and
a R/W bit) is overwritten by byte0 marked red in Figure 25-9.
25.4.6 An I2C Master Reads an I2C Slave with a 10bit Address in One Command Se
quence
Figure 2510. An I2C Master Reading an I2C Slave with a 10bit Address
Figure 25-10 shows how an I2C master reads data from an I2C slave using 10-bit addressing. Unlike 7-bit
addressing, in 10-bit addressing the WRITE command of the I2C master is formed from two bytes, and
correspondingly the RAM of this master stores a 10-bit address of two bytes. I2C_ADDR_10BIT_EN and
I2C_SLAVE_ADDR[14:0] should be set. Please refer to 25.4.2 for how to set this register.
25.4.7 An I2C Master Reads an I2C Slave with Two 7bit Addresses in One Command
Sequence
Figure 2511. An I2C Master Reading N Bytes of Data from addrM of an I2C Slave with a 7bit Address
Figure 25-11 shows how an I2C master reads data from specified addresses in an I2C slave. This procedure is
as follows:
1. Set I2C_FIFO_ADDR_CFG_EN and prepare data to be sent in the RAM of the slave.
3. Set I2C_TRANS_START and start transferring N bytes of data in the slave’s RAM starting from address M
to the master.
25.4.8 An I2C Master Reads an I2C Slave with a 7bit Address in Multiple Command
Sequences
Figure 2512. An I2C Master Reading an I2C Slave with a 7bit Address in Segments
Figure 25-12 shows how an I2C master reads (N+M) bytes of data from an I2C slave in two/three segments
separated by END commands. Configuration procedures are described as follows:
2. Prepare data in the RAM of the slave, and set I2C_TRANS_START to start data transfer. After executing the
END command, the master refreshes command registers and the RAM as shown in Segment1, and clears
the corresponding I2C_END_DETECT_INT interrupt. If cmd2 in the second segment is a STOP, then data
is read from the slave in two segments. The master resumes data transfer by setting I2C_TRANS_START
and terminates the transfer by sending a STOP bit.
3. If cmd2 in Segment1 is an END, then data is read from the slave in three segments. After the second data
transfer finishes and an I2C_END_DETECT_INT interrupt is detected, the cmd box is configured as shown
in Segment2. Once I2C_TRANS_START is set, the master terminates the transfer by sending a STOP bit.
1. Finding a match: In slave mode, the address of the I2C controller matches the address sent via the SDA
line.
2. RAM being full: In slave mode, RX RAM of the I2C controller is full.
3. Data all sent: In slave mode, TX RAM of the I2C controller is empty.
After SCL has been stretched low, the cause of stretching can be read from I2C_STRETCH_CAUSE bit. Clock
stretching is disabled by setting I2C_SLAVE_SCL_STRETCH_CLR bit.
25.6 Interrupts
• I2C_SLAVE_STRETCH_INT: Generated when a slave holds SCL low.
• I2C_SCL_MAIN_ST_TO_INT: Triggered when main state machine SCL_MAIN_FSM remains unchanged for
over I2C_SCL_MAIN_ST_TO[23:0] clock cycles.
• I2C_SCL_ST_TO_INT: Triggered when state machine SCL_FSM remains unchanged for over
I2C_SCL_ST_TO[23:0] clock cycles.
• I2C_RXFIFO_UDF_INT: Triggered when the I2C controller receives I2C_NONFIFO_RX_THRES bytes of data
in non-FIFO mode.
• I2C_TXFIFO_OVF_INT: Triggered when the I2C controller sends I2C_NONFIFO_TX_THRES bytes of data.
• I2C_NACK_INT: Triggered when the ACK value received by the master is not as expected, or when the
ACK value received by the slave is 1.
• I2C_TIME_OUT_INT: Triggered when SCL stays high or low for more than I2C_TIME_OUT clock cycles
during data transfer.
• I2C_ARBITRATION_LOST_INT: Triggered when the SDA’s output value does not match its input value while
the master’s SCL is high.
• I2C_END_DETECT_INT: Triggered when op_code of the master indicates an END command and an END
condition is detected.
• I2C_TXFIFO_WM_INT: I2C TX FIFO watermark interrupt. Triggered when I2C_FIFO_PRT_EN is 1 and the
pointers of TX FIFO are less than I2C_TXFIFO_WM_THRHD[4:0].
• I2C_RXFIFO_WM_INT: I2C Rx FIFO watermark interrupt. Triggered when I2C_FIFO_PRT_EN is 1 and the
pointers of Rx FIFO are greater than I2C_RXFIFO_WM_THRHD[4:0].
25.9 Registers
Register 25.1: I2C_SCL_LOW_PERIOD_REG (0x0000)
D
IO
ER
_P
W
LO
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 0x00 Reset
I2C_SCL_LOW_PERIOD This register is used to configure for how long SCL remains low in master
mode, in I2C module clock cycles. (R/W)
E
IM
_T
LD
HO
A_
e d)
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 0x0 Reset
I2C_SDA_HOLD_TIME This register is used to configure the interval between changing the SDA out-
put level and the falling edge of SCL, in I2C module clock cycles. (R/W)
E
M
TI
E_
PL
M
SA
A_
d)
ve
D
_S
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 0x0 Reset
I2C_SDA_SAMPLE_TIME This register is used to configure the interval between the rising edge of
SCL and the level sampling time of SDA, in I2C module clock cycles. (R/W)
D
O
H_
RI
G
PE
HI
H_
T_
AI
G
HI
W
L_
L_
)
ed
SC
SC
rv
se
C_
C_
(re
I2
I2
31 28 27 14 13 0
I2C_SCL_HIGH_PERIOD This register is used to configure for how long SCL remains high in master
mode, in I2C module clock cycles. (R/W)
I2C_SCL_WAIT_HIGH_PERIOD This register is used to configure for the SCL_FSM’s waiting period
for SCL to go high in master mode, in I2C module clock cycles. (R/W)
E
M
_TI
LD
HO
T_
AR
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 8 Reset
I2C_SCL_START_HOLD_TIME This register is used to configure interval between pulling SDA low
and pulling SCL low when the master generates a START condition, in I2C module clock cycles.
(R/W)
E
M
TI
P_
TU
SE
R T_
TA
RS
L_
d)
ve
C
_S
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 8 Reset
I2C_SCL_RSTART_SETUP_TIME This register is used to configure the interval between the positive
edge of SCL and the negative edge of SDA for a RESTART condition, in I2C module clock cycles.
(R/W)
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 0x00 Reset
I2C_SCL_STOP_HOLD_TIME This register is used to configure the delay after the STOP condition,
in I2C module clock cycles. (R/W)
E
M
TI
P_
TU
SE
P_
O
ST
L_
d)
ve
SC
er
C_
s
(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 0x0 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 I2C module clock cycles. (R/W)
TO
T_
S
L_
)d
ve
SC
er
C_
s
(re
I2
31 24 23 0
0 0 0 0 0 0 0 0 0x0100 Reset
SC
rv
se
C_
(re
I2
31 24 23 0
0 0 0 0 0 0 0 0 0x0100 Reset
FO E EV L
RC _OU EL
A_ RC L_L VE
UT
SD FO C LE
E_ T
N
N
C_ B T _O
_E
C_ L_ _S _
O
C_ AN _F ST
C_ _F E T
C_ _ ST T
I2 SC LE CK
I2 X N N
I2 RX OD AR
I2 AR RS YS
I2 MS S_ RS
SB IR
IO
P A
_ A
I
C_ L F
C_ M _
C_ K_ T
I2 FS ALW
I2 TX_ SB_
I2 CL TRA
I2 SA ULL
E
M
C_ F_
C_ _L
)
I
ed
C_ M
I2 RE
I2 R
rv
T
se
C_
(re
I2
31 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 1 0 1 0 0 0 0 0 1 0 1 1 Reset
I2C_SAMPLE_SCL_LEVEL This register is used to select the sample mode. 1: sample SDA data on
the SCL low level. 0: sample SDA data on the SCL high level. (R/W)
I2C_RX_FULL_ACK_LEVEL This register is used to configure the ACK value that need to sent by
master when the rx_fifo_cnt has reached the threshold. (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_TRANS_START Set this bit to start sending the data in TX FIFO. (R/W)
I2C_TX_LSB_FIRST This bit is used to control the sending mode for data needing to be sent. 1:
send data from the least significant bit; 0: send data from the most significant bit. (R/W)
I2C_RX_LSB_FIRST This bit is used to control the storage mode for received data. 1: receive data
from the least significant bit; 0: receive data from the most significant bit. (R/W)
I2C_ARBITRATION_EN This is the enable bit for I2C bus arbitration function. (R/W)
UE
AL
N
_E
_V
UT
UT
O
O
E_
E_
)
ed
IM
IM
rv
T
se
C_
C_
(re
I2
I2
31 25 24 23 0
0 0 0 0 0 0 0 0 0x0000 Reset
I2C_TIME_OUT_VALUE This register is used to configure the timeout for receiving a data bit in APB
clock cycles. (R/W)
I2C_TIME_OUT_EN This is the enable bit for time out control. (R/W)
R
IT
DD
0B
_A
_1
E
DR
AV
d)
ve
AD
SL
er
C_
C_
s
(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 0x00 Reset
I2C_SLAVE_ADDR When configured as an I2C Slave, this field is used to configure the slave address.
(R/W)
I2C_ADDR_10BIT_EN This field is used to enable the slave 10-bit addressing mode in master mode.
(R/W)
ES
N
S
HD
HD
RE
N _E
HR
HR
HR
_E FG
TH
_T
_T
_T
IF _C
X_
N
T
I2 IF IFO ST
X
NO _A S
M
_E
M
_R
_T
NF DDR
C_ O _R
C_ _F _R
_W
_W
RT
O
I2 RX FO
IF
IF
FO
_P
FO
NF
NF
I
)
C_ F
O
ed
FI
FI
I2 X_
O
O
IF
RX
TX
rv
_N
_N
_T
F
F
se
C_
C_
C_
C
C
(re
I2
I2
I2
I2
I2
I2
31 27 26 25 20 19 14 13 12 11 10 9 5 4 0
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)
I2C_FIFO_PRT_EN The control enable bit of FIFO pointer in non-FIFO mode. This bit controls the
valid bits and the interrupts of TX/RX FIFO overflow, underflow, full and empty. (R/W)
M
NU
EN
V_
V_
SL
SL
PD N
N
L_ _E
_E
T_
T_
SC _PD
RS
RS
L_
L_
)
ed
C_ A
SC
SC
I2 SD
rv
se
C_
C_
C_
(re
I2
I2
I2
31 8 7 6 5 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 0x0 0 Reset
I2C_SCL_RST_SLV_EN When I2C master is IDLE, set this bit to send out SCL pulses. The number
of pulses equals to I2C_SCL_RST_SLV_NUM[4:0]. (R/W)
I2C_SCL_RST_SLV_NUM Configure the pulses of SCL generated in I2C master mode. Valid when
I2C_SCL_RST_SLV_EN is 1. (R/W)
I2C_SCL_PD_EN The power down enable bit for the I2C output SCL line. 1: Power down. 0: Not
power down. Set I2C_SCL_FORCE_OUT and I2C_SCL_PD_EN to 1 to stretch SCL low. (R/W)
I2C_SDA_PD_EN The power down enable bit for the I2C output SDA line. 1: Power down. 0: Not
power down. Set I2C_SDA_FORCE_OUT and I2C_SDA_PD_EN to 1 to stretch SDA low. (R/W)
H_ LR
UM
EN
TC _C
_N
RE H
ST TC
CT
L_ RE
TE
SC ST
O
PR
E_ L_
H_
AV SC
TC
SL E_
RE
C_ AV
d)
ve
ST
I2 SL
r
se
C_
C_
(re
I2
I2
31 12 11 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
I2C_STRETCH_PROTECT_NUM Configure the period of I2C slave stretching SCL line. (R/W)
I2C_SLAVE_SCL_STRETCH_EN The enable bit for slave SCL stretch function. 1: Enable. 0: Dis-
able. The SCL output line will be stretched low when I2C_SLAVE_SCL_STRETCH_EN is 1 and
stretch event happens. The stretch cause can be seen in I2C_STRETCH_CAUSE. (R/W)
I2C_SLAVE_SCL_STRETCH_CLR Set this bit to clear the I2C slave SCL stretch function. (WO)
T
AS
D
_L
SE
SE
E
T
AS
AT
C_ B S ES
AU
ST
_L
I2 BU E_A NS
I2 AR BU DR
NT
NT
_C
N_
TE
_ Y
SP RW
EC
T
C_ AV A
C_ S D
C_ AV T
_C
CH
_C
C_ E S
I2 SL _TR
I2 SL OU
TA
AI
I2 TIM LO
_R
RE E_
O
_M
O
_S
ET
_
IF
_
F
C_ TE
)
d)
)
ed
ed
C_ d
FI
CL
CL
TR
XF
ve
I2 rve
I2 BY
TX
rv
R
_S
S
er
er
se
se
C_
C_
C_
C_
s
s
C
(re
(re
(re
(re
I2
I2
I2
I2
I2
31 30 28 27 26 24 23 18 17 16 15 14 13 8 7 6 5 4 3 2 1 0
I2C_RESP_REC The received ACK value in master mode or slave mode. 0: ACK; 1: NACK. (RO)
I2C_SLAVE_RW When in slave mode, 1: master reads from slave; 0: master writes to slave. (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_ARB_LOST When the I2C controller loses control of SCL line, this register changes to 1. (RO)
I2C_BUS_BUSY 1: the I2C bus is busy transferring data; 0: the I2C bus is in idle state. (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_RXFIFO_CNT This field represents the amount of data needed to be sent. (RO)
I2C_STRETCH_CAUSE The cause of stretching SCL low in slave mode. 0: stretching SCL low at
the beginning of I2C read data state. 1: stretching SCL low when I2C TX FIFO is empty in slave
mode. 2: stretching SCL low when I2C RX FIFO is full in slave mode. (RO)
I2C_TXFIFO_CNT This field stores the amount of received data in RAM. (RO)
I2C_SCL_MAIN_STATE_LAST This field indicates the states of the I2C module state machine. 0:
Idle; 1: Address shift; 2: ACK address; 3: RX data; 4: TX data; 5: Send ACK; 6: Wait ACK. (RO)
I2C_SCL_STATE_LAST This field indicates the states of the state machine used to produce SCL. 0:
Idle; 1: Start; 2: Negative edge; 3: Low; 4: Positive edge; 5: High; 6: Stop. (RO)
DR
DR
R
DR
AD
AD
T
DD
IN
AD
T_
T_
_A
O
R
_
_P
ND
ND
TA
E
TA
PD E
W
AT
_U AT
_S
_E
_S
_E
_R
RX PD
FO
FO
O
VE
IF
IF
C_ U
)
ed
I
FI
LA
XF
XF
XF
I2 TX_
TX
rv
R
_S
T
se
C_
C_
C_
C_
C_
C
(re
I2
I2
I2
I2
I2
I2
31 30 29 22 21 20 19 15 14 10 9 5 4 0
I2C_RXFIFO_START_ADDR This is the offset address of the last received data, as described in
I2C_NONFIFO_RX_THRES. (RO)
I2C_RXFIFO_END_ADDR This is the offset address of the last received data, as de-
scribed in I2C_NONFIFO_RX_THRES. This value refreshes when an I2C_RXFIFO_UDF_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
I2C_NONFIFO_TX_THRES. (RO)
I2C_TXFIFO_END_ADDR This is the offset address of the last sent data, as described
in I2C_NONFIFO_TX_THRES. The value refreshes when an I2C_TXFIFO_OVF_INT or
I2C_TRANS_COMPLETE_INT interrupt is generated. (RO)
FO
ed
rv
FI
se
C_
(re
I2
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
I2C_FIFO_RDATA This field is used to read data from RX FIFO, or write data to TX FIFO. (R/W)
AW
FI _W _IN _R T_ W
I2 RX DE NS OS T_R AW
RX O VF NT _IN A
W
W
C_ FI T _ AW AW
FO M T AW R
C_ IF O _I E _R
C_ C O IN AW A
_L IN R
C_ FI TE _D T_ A
I2 NA O_ F_ _R T_R
I2 EN _TR ON F_ NT_
I2 AR TX MP RA AW
I2 TXF O_ CT ON INT
I2 RX ST_ _ST _R _R
M T_ W
W
AW
NT W
T
C_ T C T_ _R
C_ IF U NT IN
I D I
C_ AN T IN A
_W _IN _RA
C_ TE T U _
W
C_ E ST W A
C_ L_ IN NT N
_I RA
I2 BY TRA O_ ETE
I2 TR _IN F_ T_R
I2 TXF O_ O_I O_
I2 TIM S_ RA _R
_R
I2 MS S_ IN NT
I2 SC MA T_I H_I
T
T
I
C_ AN T T_
C_ L_ R C
F L
I2 SC STA RET
I2 TR _OU AR
_
_
D
_ O
K V
A
C_ T_ T
C_ B FI
I2 DE E_S
F
_
C_ AV
)
I
ed
C_ D
I2 SL
rv
se
C_
(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
I2C_END_DETECT_INT_RAW The raw interrupt bit for the I2C_END_DETECT_INT interrupt. (RO)
I2C_TIME_OUT_INT_RAW The raw interrupt bit for the I2C_TIME_OUT_INT interrupt. (RO)
I2C_TRANS_START_INT_RAW The raw interrupt bit for the I2C_TRANS_START_INT interrupt. (RO)
LR
FI _W _IN _C T_ R
I2 RX DE NS OS T_C LR
RX O VF NT _IN L
R
FO M T LR C
R
C_ IF O _I E _C
C_ FI T _ LR LR
_L IN C
C_ C O IN LR L
C_ FI TE _D T_ L
I2 NA O_ F_ _C T_C
I2 EN _TR ON F_ NT_
I2 TXF O_ CT ON INT
I2 AR TX MP CLR LR
I2 RX ST_ _ST _C _C
M T_ R
R
LR
C_ T C T_ _C
T
NT R
C_ IF U NT IN
I D I
C_ AN T IN L
C_ TE T U _
_W _IN _CL
C_ L_ IN NT N
C_ E ST R L
_I CL
I2 BY TRA O_ ETE
I2 TR _IN F_ T_C
I2 TXF O_ O_I O_
I2 TIM S_ CL _C
_C
I2 MS S_ IN NT
I2 SC MA T_I H_I
T
T
I
C_ AN T T_
C_ L_ R C
F L
I2 SC STA RET
I2 TR _OU AR
_
_
D
_ O
K V
A
C_ T_ T
C_ B FI
I2 DE E_S
F
_
C_ AV
d)
C_ D
ve
I2 SL
r
se
C_
(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
A
FI _W _IN _E T_ A
I2 RX DE NS OS T_E NA
FO M T NA EN
RX O VF NT _IN N
A
A
T A A
C_ IF O _I E _E
C_ C O IN A N
_L IN E
C_ FI TE _D T_ N
N
I2 EN _TR ON F_ NT_
I2 NA O_ F_ _EN T_E
I2 TXF O_ CT ON INT
I2 AR TX MP EN NA
I2 RX ST_ _ST _EN _E
M T_ A
A
NA
T
NT A
C_ T C T_ _E
C_ IF U NT IN
I D I
C_ AN T IN N
_W _IN _EN
C_ TE T U _
C_ E ST A N
C_ L_ IN NT N
_I EN
A
I2 BY TRA O_ ETE
I2 TR _IN F_ T_E
I2 TXF O_ O_I O_
I2 MS S_ IN NT
I2 TIM S_ EN _E
_E
I2 SC MA T_I H_I
I
C_ AN T T_
C_ L_ R C
F L
C_ FI T _
I2 SC STA RET
I2 TR _OU AR
_
_
D
_ O
K V
A
C_ T_ T
C_ B FI
I2 DE E_S
F
_
C_ AV
)
I
ed
C_ D
I2 SL
rv
se
C_
(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
I2C_END_DETECT_INT_ENA The raw interrupt bit for the I2C_END_DETECT_INT interrupt. (R/W)
I2C_TIME_OUT_INT_ENA The raw interrupt bit for the I2C_TIME_OUT_INT interrupt. (R/W)
I2C_TRANS_START_INT_ENA The raw interrupt bit for the I2C_TRANS_START_INT interrupt. (R/W)
T
RX O VF NT _IN T
I2 RX DE NS OS T_S T
FO M T T S
C_ IF O _I E _S
_L IN S
T
FI _W _IN _S T_
C_ FI TE _D T_ T
T
I2 NA O_ F_ _S T_S
I2 EN _TR ON F_ NT_
I2 TXF O_ CT ON INT
I2 RX ST_ _ST _ST _S
I2 AR TX MP ST T
T
C_ T C T_ _S
C_ IF U NT IN
I D I
C_ TE T U _
C_ AN T IN T
_W _IN _ST
C_ L_ IN NT N
T
_I ST
C_ C O IN T
I2 BY TRA O_ ETE
I2 TR _IN F_ T_S
I2 TXF O_ O_I O_
I2 TIM S_ _ST _S
I2 MS S_ _IN INT
_S
I2 SC MA T_I H_I
M T_
T
T
NT
C_ AN T T_
C_ L_ R C
F L
C_ FI T _
I2 SC STA RET
I2 TR _OU AR
D
_ O
K V
C_ E ST
A
C_ T_ T
C_ B FI
I2 DE E_S
F
_
C_ AV
d)
C_ D
ve
I2 SL
r
se
C_
(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
I2C_RXFIFO_WM_INT_ST The masked interrupt status bit for I2C_RXFIFO_WM_INT interrupt. (RO)
I2C_TXFIFO_WM_INT_ST The masked interrupt status bit for I2C_TXFIFO_WM_INT interrupt. (RO)
I2C_RXFIFO_OVF_INT_ST The masked interrupt status bit for I2C_RXFIFO_OVF_INT interrupt. (RO)
I2C_END_DETECT_INT_ST The masked interrupt status bit for the I2C_END_DETECT_INT interrupt.
(RO)
I2C_TIME_OUT_INT_ST The masked interrupt status bit for the I2C_TIME_OUT_INT interrupt. (RO)
I2C_TRANS_START_INT_ST The masked interrupt status bit for the I2C_TRANS_START_INT inter-
rupt. (RO)
I2C_NACK_INT_ST The masked interrupt status bit for I2C_SLAVE_STRETCH_INT interrupt. (RO)
I2C_TXFIFO_OVF_INT_ST The masked interrupt status bit for I2C_TXFIFO_OVF_INT interrupt. (RO)
I2C_RXFIFO_UDF_INT_ST The masked interrupt status bit for I2C_RXFIFO_UDF_INT interrupt. (RO)
I2C_SCL_ST_TO_INT_ST The masked interrupt status bit for I2C_SCL_ST_TO_INT interrupt. (RO)
I2C_DET_START_INT_ST The masked interrupt status bit for I2C_DET_START_INT interrupt. (RO)
ES
HR
N
_E
_T
ER
ER
LT
LT
FI
FI
_
_
d)
CL
CL
ve
_S
_S
ser
C
(re
I2
I2
31 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 1 0x0 Reset
I2C_SCL_FILTER_THRES When a pulse on the SCL input has smaller width than this register value
in I2C module clock cycles, the I2C controller will ignore that pulse. (R/W)
S
RE
EN
TH
R_
R_
E
E
ILT
ILT
_F
_F
d)
DA
DA
e
rv
_S
_S
se
C
(re
I2
I2
31 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 1 0x0 Reset
I2C_SDA_FILTER_THRES When a pulse on the SDA input has smaller width than this register value
in I2C module clock cycles, the I2C controller will ignore that pulse. (R/W)
D0
AN
AN
M
M
M
M
d )
CO
CO
r ve
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 0x00 Reset
I2C_COMMAND0 This is the content of command 0. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND0_DONE When command 0 is done in I2C Master mode, this bit changes to high
level. (R/W)
NE
O
_D
D1
D1
AN
AN
M
M
M
M
d)
CO
CO
ve
er
C_
C_
s
(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 0x00 Reset
I2C_COMMAND1 This is the content of command 1. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND1_DONE When command 1 is done in I2C Master mode, this bit changes to high
level. (R/W)
D2
AN
AN
M
M
M
M
)
ed
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 0x00 Reset
I2C_COMMAND2 This is the content of command 2. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND2_DONE When command 2 is done in I2C Master mode, this bit changes to high
level. (R/W)
NE
O
_D
D3
D3
AN
AN
M
M
M
M
d)
CO
CO
ve
er
C_
C_
s
(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 0x00 Reset
I2C_COMMAND3 This is the content of command 3. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND3_DONE When command 3 is done in I2C Master mode, this bit changes to high
level. (R/W)
D4
AN
AN
M
M
M
M
)
ed
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 0x00 Reset
I2C_COMMAND4 This is the content of command 4. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND4_DONE When command 4 is done in I2C Master mode, this bit changes to high
level. (R/W)
NE
O
_D
D5
D5
AN
AN
M
M
M
M
d)
CO
CO
ve
er
C_
C_
s
(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 0x00 Reset
I2C_COMMAND5 This is the content of command 5. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND5_DONE When command 5 is done in I2C Master mode, this bit changes to high
level. (R/W)
D6
AN
AN
M
M
M
M
)
ed
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 0x00 Reset
I2C_COMMAND6 This is the content of command 6. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND6_DONE When command 6 is done in I2C Master mode, this bit changes to high
level. (R/W)
NE
O
_D
D7
D7
AN
AN
M
M
M
M
d)
CO
CO
ve
er
C_
C_
s
(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 0x00 Reset
I2C_COMMAND7 This is the content of command 7. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND7_DONE When command 7 is done in I2C Master mode, this bit changes to high
level. (R/W)
D8
AN
AN
M
M
M
M
)
ed
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 0x00 Reset
I2C_COMMAND8 This is the content of command 8. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND8_DONE When command 8 is done in I2C Master mode, this bit changes to high
level. (R/W)
NE
O
_D
D9
D9
AN
AN
M
M
M
M
d)
CO
CO
ve
er
C_
C_
s
(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 0x00 Reset
I2C_COMMAND9 This is the content of command 9. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND9_DONE When command 9 is done in I2C Master mode, this bit changes to high
level. (R/W)
0
D1
D1
AN
AN
M
M
M
M
)
ed
O
CO
rv
_C
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 0x00 Reset
I2C_COMMAND10 This is the content of command 10. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND10_DONE When command 10 is done in I2C Master mode, this bit changes to high
level. (R/W)
NE
DO
1_
1
D1
D1
AN
AN
M
M
M
M
d)
CO
CO
ve
er
C_
C_
s
(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 0x00 Reset
I2C_COMMAND11 This is the content of command 11. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND11_DONE When command 11 is done in I2C Master mode, this bit changes to high
level. (R/W)
2
D1
D1
AN
AN
M
M
M
M
)
ed
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 0x00 Reset
I2C_COMMAND12 This is the content of command 12. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND12_DONE When command 12 is done in I2C Master mode, this bit changes to high
level. (R/W)
NE
DO
3_
3
D1
D1
AN
AN
M
M
M
M
d)
CO
CO
ve
er
C_
C_
s
(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 0x00 Reset
I2C_COMMAND13 This is the content of command 13. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND13_DONE When command 13 is done in I2C Master mode, this bit changes to high
level. (R/W)
4
D1
D1
AN
AN
M
M
M
M
)
ed
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 0x00 Reset
I2C_COMMAND14 This is the content of command 14. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND14_DONE When command 14 is done in I2C Master mode, this bit changes to high
level. (R/W)
NE
DO
5_
5
D1
D1
AN
AN
M
M
M
M
d)
CO
CO
ve
er
C_
C_
s
(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 0x00 Reset
I2C_COMMAND15 This is the content of command 15. It consists of three parts: op_code is the
command, 0: RSTART; 1: WRITE; 2: READ; 3: STOP; 4: END. byte_num represents the number
of bytes that need to be sent or received. ack_check_en, ack_exp and ack are used to control the
ACK bit. See I2C cmd structure for more information. (R/W)
I2C_COMMAND15_DONE When command 15 is done in I2C Master mode, this bit changes to high
level. (R/W)
31 0
0x19052000 Reset
26.1 Overview
I2S bus provides a flexible communication interface for streaming digital data in multimedia applications,
especially in digital audio applications. ESP32-S2 has a built-in I2S interface, i.e. I2S0.
I2S standard bus defines three signals: a bit clock signal (BCK), a channel/word select signal (WS), and a serial
data signal (SD). A basic I2S data bus has one master and one slave. The roles remain unchanged throughout
the communication. The I2S module on ESP32-S2 provides separate transmit (TX) and receive (RX) units for high
performance.
In addition to standard I2S, the I2S module supports LCD and camera operation modes which transfer data over
a parallel bus.
Figure 26-1 shows the structure of ESP32-S2 I2S module, consisting of a TX unit (TX control), an RX unit (RX
control), an input and output timing unit (I/O Timing), a clock divider (Clock Generator), a TX FIFO, and an RX
FIFO. Both the TX unit and the RX unit have a 64 x 32-bit FIFO. I2S module supports direct access (DMA) to
internal memory and external RAM, see Chapter DMA Controller. Please ensure the consistency between cache
and DMA when accessing external RAM. I2S module can work in multiple modes: I2S master/slave transmitter
and receiver, LCD master transmitter, and camera slave receiver.
In I2S mode, both the TX unit and the RX unit have a three-line interface, including a bit clock line (BCK), a word
select line (WS), and a serial data line (SD). The SD line of TX unit is fixed as output, and the SD line of RX unit as
input. BCK and WS signal lines for TX unit and RX unit can be configured as master output mode and slave input
mode.
In LCD master transmitting mode, I2S0O_BCK_out works as LCD pixel clock output, and I2S0O_Data_out [23:0]
as LCD parallel output data bus. A wide variety of LCD formats and bit widths are supported in this mode.
In camera slave receiving mode, the lines perform the following roles:
The signal bus of I2S module is shown at the right part of Figure 26-1. The naming of these signals in RX and TX
units follows the pattern: I2S0A_B_C, such as I2S0I_BCK_in.
– BCK
– WS
– SD
For a detailed description of I2S signal bus, please refer to Table 151.
Note:
1. All I2S signals must be mapped to the chip’s pad via GPIO matrix, see Chapter 5 IO MUX and GPIO Matrix (GPIO,
IO_MUX).
2. For input/output signal with a bit width of N in LCD/Camera mode, I2S0I_Data_in[N-1:0] is used as input signal, and
I2S0O_Data_out[23:23-N+1] as output signal. Generally, N is 8 ∼ 16 for input signals and 8 ∼ 24 for output signals.
26.3 Features
In I2S mode:
• TX unit and RX unit are independent of each other and can work independently or simultaneously.
– PCM standard
• High-precision sample clock supports the following frequencies: 8 kHz, 16 kHz, 32 kHz, 44.1 kHz, 48 kHz,
88.2 kHz, 96 kHz, 128 kHz, and 192 kHz. Note that 192 kHz is not supported in 32-bit slave mode.
• Support to connect to external LCD, and configured as 8- ~ 24-bit parallel output mode.
* Clock frequency should be less than 40 MHz when LCD data bus is configured as 8- ~ 16-bit
parallel output.
* Clock frequency should be less than 26.7 MHz when LCD data bus is configured as 17- ~ 24-bit
parallel output.
* Clock frequency should be less than 25 MHz when LCD data bus is configured as 8-bit parallel
output.
* Clock frequency should be less than 12.5 MHz when LCD data bus is configured as 9- ~ 16-bit
parallel output.
* Clock frequency should be less than 6.25 MHz when LCD data bus is configured as 17- ~ 24-bit
parallel output.
– Support for a variety of LCD modes, including MOTO6800, I8080, and etc.
• Support to connect to external camera (i.e. DVP image sensor), and configured as 8- ~ 16-bit parallel input
mode.
– I2S camera accesses internal memory via DMA. Clock frequency should be less than 40 MHz when
I2S camera is configured as 8- ~ 16-bit parallel input mode.
* Clock frequency should be less than 25 MHz when I2S camera is configured as 8-bit parallel input
mode.
* Clock frequency should be less than 12.5 MHz when I2S camera is configured as 9- ~ 16-bit
parallel input mode.
– When accessing internal memory, ensure that the maximum data throughput on the interface is less
than DMA total data bandwidth of 80 megabytes per second.
– When accessing external RAM, ensure that the maximum data throughput on the interface is less than
EDMA total data bandwidth of 25 megabytes per second.
I2S interrupts:
As shown in Figure 26-2, Philips specifications require that WS signal changes one BCK clock cycle earlier than
SD signal on BCK falling edge, which means that WS signal keeps valid from a clock cycle earlier before
transmitting the first bit of current channel and changes a clock earlier before the end of data transfer in current
channel. SD signal line transmits the most significant bit of audio data first. Users can set the bits
I2S_RX_MSB_SHIFT and I2S_TX_MSB_SHIFT in register I2S_CONF_REG, respectively, to enable Philips
standard when receiving and transmitting data.
As shown in Figure 26-3, MSB alignment specifications require WS and SD signals change simultaneously on the
falling edge of BCK. The WS signal keeps valid till the end of data transfer in current channel. The SD signal line
transmits the most significant bit of audio data first. Users can clear the bits I2S_RX_MSB_SHIFT and
I2S_TX_MSB_SHIFT in register I2S_CONF_REG, respectively, to enable MSB alignment standard when receiving
and transmitting data.
As shown in Figure 26-4, short frame synchronization under PCM standard requires WS signal changes one BCK
clock cycle earlier than SD signal on the falling edge of BCK, which means that the WS signal comes valid from a
clock cycle earlier before transferring the first bit of current channel and remains unchanged in this BCK clock
cycle. The SD signal line transmits the most significant bit of audio data first. Users can set the bits
I2S_RX_SHORT_SYNC and I2S_TX_SHORT_SYNC in register I2S_CONF_REG to 1, to enable short frame
synchronization mode when receiving and transmitting data.
The following formula shows the relation between I2S0_CLK frequency fi2s and the divider clock source
frequency fI2S_CLK_S :
fI2S_CLK_S
fi2s =
N + ba
N is an integer value between 2 and 256. The value of N corresponds to the value of I2S_CLKM_DIV_NUM[7:0]
in register I2S_CLKM_CONF_REG as follows:
• When I2S_CLKM_DIV_NUM[7:0] = 1, N = 2.
“b” corresponds to the value of I2S_CLKM_DIV_B[5:0], and “a” to the value of I2S_CLKM_DIV_A[5:0]. For integer
divider, I2S_CLKM_DIV_A[5:0] and I2S_CLKM_DIV_B[5:0] are cleared. For fractional divider, the value of
I2S_CLKM_DIV_B[5:0] should be less than that of I2S_CLKM_DIV_A[5:0].
In master transmitting mode, the serial clock BCK for I2S module is I2S0O_BCK_out, derived from I2S0_CLK.
That is:
fi2s
fI2S0O_BCK_out =
MO
“MO” is an integer value between 2 and 128. The value of “MO” corresponds to the value of
I2S_TX_BCK_DIV_NUM[5:0] in register I2S_SAMPLE_RATE_CONF_REG as follows:
In master receiving mode, the serial clock BCK for I2S module is I2S0I_BCK_out, derived from I2S0_CLK. That
is:
fi2s
fI2S0I_BCK_out =
MI
“MI” is an integer value between 2 and 128. “MI” corresponds to the value of I2S_RX_BCK_DIV_NUM[5:0] in
register I2S_SAMPLE_RATE_CONF_REG as follows:
Note:
• Using fractional divider may bring clock jitter. In case that I2S0_CLK and BCK can not be generated from
PLL_F160M_CLK by integer divider, APLL_CLK can be used as clock source. For more information, please
refer to Chapter 6 Reset and Clock.
• I2S module can output I2S0_CLK as the main clock for peripherals.
Their reset status are indicated by the status bits: I2S_TX_RESET_ST, I2S_RX_RESET_ST,
I2S_TX_FIFO_RESET_ST, and I2S_RX_FIFO_RESET_ST, respectively. Users can read from these status bits to
check reset status: 0: reset is completed; 1: reset is not completed.
Note: I2S module clock must be configured first before the module and FIFO are reset.
– If I2S_TX_STOP_EN is set, and all the data in FIFO is transmitted, the master will stop transmitting
data.
– If I2S_TX_STOP_EN is cleared, and all the data in FIFO is transmitted, meanwhile no new data is filled
in, the TX unit will keep sending the last data frame.
– If I2S_TX_STOP_EN is set, and all the data in FIFO is transmitted, the slave will keep sending 0, till the
master stops providing BCK signal.
– If I2S_TX_STOP_EN is cleared, TX unit will keep sending the last frame when all the data in FIFO is
sent and no new data is filled in.
– Slave stops sending data when the bit I2S_TX_START is cleared or there is no BCK clock in.
• Read data to send from TX FIFO and align the data to 64 bits to get prepared for the data transfer in left
and right channels.
– In LCD mode, convert the data to a bit-width fixed stream, and clock out the stream parallelly.
TX unit transmits data from left channel by default when WS = 0, and from right channel when WS = 1. For
subsequent description, suppose that the first four data to send are D0 (indicating low addresses or low bits), D1,
D2, and D3 (indicating high addresses or high bits). The left channel data is stored at low addresses or low bits
(e.g. D0, D2), and the right channel data at high addresses or high bits (e.g. D1, D3).
I2S_TX_BIG_ENDIAN is used to set the internal endianness of the data to send. Assume the bit width of the TX
data in Figure 26-6 is 32/24/16/8 bits, and their corresponding D0 is {B3, B2, B1, B0}, {B2, B1, B0}, {B1, B0},
′
and B0. “B” here means byte. The relation between Dn (n: 0∼3) and Dn (n: 0∼3) is shown in Table 152.
Users can configure I2S_TX_MSB_RIGHT to decide data of which channel will be stored in MSB of TX FIFO.
I2S_TX_MSB_RIGHT together with I2S_TX_CHAN_MOD[2:0] can configure multiple data formats for right and
left channels. I2S_TX_RIGHT_FIRST is used to configure data of which channel, right channel or left channel,
should be sent first.
When I2S_TX_DMA_EQUAL = 0, all supported TX channel mode are listed in Table 153. If
I2S_TX_CHAN_MOD[2:0] = 0 and I2S_TX_DMA_EQUAL = 0, the output data format is shown in Figure
26-7.
4. Configure the bit I2S_TX_SLAVE_MOD in register I2S_CONF_REG, to select the mode needed.
10. Set I2S_TX_STOP_EN bit if needed. For more information, please refer to Section 26.7.1.
• In master mode, wait till I2S slave gets ready, then set I2S_TX_START to start transmitting data.
• In slave mode, set the bit I2S_TX_START. When the I2S master supplies BCK and WS signals, start
transmitting data.
12. Wait for the interrupt signals set in Step 8, or check whether the transfer is completed by querying the
register I2S_TX_IDLE:
• 0: transmitter is working.
• 1: transmitter is in idle.
Suppose that the first four received data are D0 (low addresses or bits), D1, D2, and D3 (high addresses or bits).
RX unit receives data according to WS signal:
′′ ′
In Figure 26-9, Dn (n: 0 ∼3) is the result of Dn (n: 0∼3) after processed by I2S_RX_MSB_RIGHT. Dn (n: 0 ∼3) is
′′
the result of Dn (n: 0∼3) after processed by I2S_RX_BIG_ENDIAN. I2S_RX_BIG_ENDIAN is used to modify the
endianness of the RX data, see Table 152.
According to Figure 26-9, when I2S_RX_DMA_EQUAL is cleared, the waveform of I2S RX data is shown in Figure
26-10. For the specific control rules, please see Table 155.
3. Clear the bits I2S_LCD_EN and I2S_CAMERA_EN in register I2S_CONF2_REG, to enable I2S mode.
9. Configure DMA inlink, and set the length of RX data in register I2S_RXEOF_NUM_REG. Then set
I2S_INLINK_START to start DMA.
• In master mode, when the slave is ready, set I2S_RX_START to start receiving data.
• In slave mode, set I2S_RX_START to start receiving data when get BCK and WS signals from the
master.
11. Receive data and store the data to the specified address of ESP32-S2 memory. Then corresponding
interrupts set in Step 8 will be generated.
fi2s
fWS =
W∗2
3. Set the bit I2S_LCD_EN in register I2S_CONF2_REG, and clear the bit I2S_TX_SLAVE_MOD in register
I2S_CONF_REG, to enable LCD master transmitting mode.
11. Wait till LCD slave gets ready, then set I2S_TX_START to start transmitting data.
12. Wait for the interrupt signals set in Step 8, or check whether the transfer is completed by querying the
register I2S_TX_IDLE:
• 0: transmitter is working.
• 1: transmitter is in idle.
In LCD master transmitting mode, the data frame format shown in 26-14 is also supported. The only difference in
software configuration with the format as shown in Figure 26-13 is that I2S_LCD_TX_SDX2_EN is set.
Note:
The bit width of input data is N, which can be 8 ~ 16 bits.
1. Configure clock as described in Section 26.5. Note that the clock frequency of I2S module: fi2s should be
equal to or larger than twice of the frequency of PCLK clock (input from I2S0I_WS_in pin).
3. Set the bits I2S_LCD_EN and I2S_CAMERA_EN in register I2S_CONF2_REG, to enable camera mode.
7. Reset RX unit and its FIFO according to Section 26.6. Set I2S_CAM_SYNC_FIFO_RESET bit and then
clear it.
9. Configure DMA inlink, and set the length of RX data in register I2S_RXEOF_NUM_REG. Then set
I2S_INLINK_START to start DMA.
11. Receive data and store the data to the specified address of ESP32-S2 memory. Then corresponding
interrupts set in Step 8 will be generated.
When I2S0I_V_SYNC is detected on rising edge, I2S0I_H_SYNC, I2S0I_H_ENABLE are held high, and
I2S0I_V_SYNC is held low, I2S module starts receiving data:
In case that the signals do not satisfy the requirements defined above, users may reverse the signals through
GPIO matrix. For more information, please refer to 5 IO MUX and GPIO Matrix (GPIO, IO_MUX).
To avoid noise on I2S0I_V_SYNC signal, set I2S_VSYNC_FILTER_EN to enable filter for I2S0I_V_SYNC signal.
The filter samples input signals continuously, and will detect the signals which remain unchanged for a
continuous I2S_VSYNC_FILTER_THRES PCLK clock cycles as valid, otherwise the signals will be detected as
invalid. Only the valid signals can pass through this filter. Therefore, the filter will remove pulses with a length of
less than I2S_VSYNC_FILTER_THRES PCLK cycles from I2S0I_V_SYNC signal line.
Camera module provides at least 8 PCLK rising-edge clock signals when I2S0I_V_SYNC is held high, to ensure
that I2S samples the rising-edge of I2S0I_V_SYNC signal correctly.
• I2S_TX_PUT_DATA_INT: Triggered when the left and right channel data number in TX FIFO is smaller than
the value of I2S_TX_DATA_NUM[5:0]. (TX FIFO is almost empty.)
• I2S_RX_TAKE_DATA_INT: Triggered when the left and right channel data number in RX FIFO is larger than
the value of I2S_RX_DATA_NUM[5:0]. (RX FIFO is almost full.)
• I2S_V_SYNC_INT: Triggered when I2S camera transmission_start is valid and a new rising edge of
I2S0I_V_SYNC is detected.
• I2S_OUT_DONE_INT: Triggered when all transmitted and buffered data have been read.
26.15 Registers
Register 26.1: I2S_CONF_REG (0x0008)
CK T
BA _S
I2 TX_ SB _SY C
I2 RX SB HIF C
_F T
T
L
S_ _M RT YN
_ L
_M D
S_ E_ EN N
S_ M _S N
S_ S T D
se _L _R ET
S_ _R _R ET
S_ _D _ N
S_ _M _R T
se d) P T
_R ET ET
S_ _S T S
S_ M O T
S_ S E S
S_ R _E A
S_ _R _S T
S_ _F T A
S_ R T T
I2 RX LAV _MO
I2 PR IG_ DIA
I2 RX SB IGH
I2 X_ AR O
I2 RX REQ DIA
I2 TX_ ON IGH
I2 RX IGH FIR
I2 TX_ IG_ _ST
I2 X_ AV IR
I2 TX_ MA QU
I2 TX_ IFO ST
I2 RX HO _S
(re SIG FO ES
I2 RX FO ES
TX ES ES
N
_
T
S_ M _R
S_ D _E
S_ F _R
S_ F _R
S_ _B T
ET
S_ _S O
S_ _F T
S_ _S E
S_ S R
S_ B E
I2 RX ESE
I2 RX TAR
I2 RX ON
I2 TX_ SB
I2 TX_ HO
I2 TX_ IFO
ES
T
L
S_ _M
S_ _R
I
)
)
ed
S_ d
I2 rve
RX
I2 RX
rv
T
se
S_
(re
I2
I2
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 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 Reset
I2S_TX_RIGHT_FIRST Set this bit to transmit right channel data first. (R/W)
I2S_RX_RIGHT_FIRST Set this bit to receive right channel data first. (R/W)
I2S_TX_MSB_SHIFT Set this bit to enable transmitter in Phillips standard mode. (R/W)
I2S_RX_MSB_SHIFT Set this bit to enable receiver in Phillips standard mode. (R/W)
I2S_TX_SHORT_SYNC Set this bit to enable transmitter in PCM standard mode. (R/W)
I2S_RX_SHORT_SYNC Set this bit to enable receiver in PCM standard mode. (R/W)
I2S_TX_MSB_RIGHT Set this bit to place right channel data at the MSB in TX FIFO. (R/W)
I2S_RX_MSB_RIGHT Set this bit to place right channel data at the MSB in RX FIFO. (R/W)
I2S_SIG_LOOPBACK Enable signal loopback mode with transmitter module and receiver module
sharing the same WS and BCK signals. (R/W)
I2S_TX_DMA_EQUAL 1: Data in left channel is equal to data in right channel. 0: Data in left channel
is not equal to data in right channel. (R/W)
I2S_RX_DMA_EQUAL 1: Data in left channel is equal to data in right channel. 0: Data in left channel
is not equal to data in right channel. (R/W)
I2S_PRE_REQ_EN Set this bit to enable I2S to prepare data earlier. (R/W)
M
NU
NU
A_
A_
N
_E
AT
AT
CR
_D
_D
d )
ve
DS
RX
RX
r
se
S_
S_
S_
(re
I2
I2
I2
31 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
I2S_RX_DATA_NUM I2S_RX_TAKE_DATA_INT is triggered when the left and right channel data num-
ber in RX FIFO is larger than the value of I2S_RX_DATA_NUM[5:0]. (RX FIFO is almost full threshold.)
I2S_TX_DATA_NUM I2S_TX_PUT_DATA_INT is triggered when the left and right channel data num-
ber in TX FIFO is smaller than the value of I2S_TX_DATA_NUM[5:0]. (TX FIFO is almost empty
threshold.)
A
AT
_D
LE
IG
S _S
I2
31 0
0 Reset
I2S_SIGLE_DATA The right channel or left channel transmits constant value stored in this register
according to I2S_TX_CHAN_MOD and I2S_TX_MSB_RIGHT. (R/W)
D
O
O
M
_M
N_
AN
HA
H
_C
_C
d)
ve
RX
TX
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 Reset
HI
_S
_E
UT
UT
UT
EO
EO
EO
IM
IM
I
_T
_T
_T
FO
FO
FO
I
FI
d)
_F
_F
_
e
LC
LC
LC
rv
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 0x10 Reset
I2S_LC_FIFO_TIMEOUT_SHIFT The bits are used to set the tick counter threshold. The tick counter
is clocked by CLK_APB. The tick counter threshold is 88000/2I2S_LC_F IF O_T IM EOU T _SHIF T .
The tick counter is reset when it reaches the threshold. (R/W)
EN
P_
TO
d)
)
S
ed
X_
ve
rv
_T
r
se
se
S
(re
(re
I2
31 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
I2S_TX_STOP_EN Set this bit to stop the output of BCK signal and WS signal when TX FIFO is empty.
(R/W)
I2 FIF ME FO CE U
FI FO _F CE D
_F C RC PU
D
S_ _ M R _P
S_ O M R _P
RC PU P
I2 PLC RA _FO _FO
FO R O _
O E_ E_
I2 PLC ME _FO CE
PD
S_ _ M R
S_ A M K
I2 M A L
E_
_R _C
_
S_ A M
I2 DM RA
_
_
d)
S_ A
I2 DM
ve
D
r
se
S_
(re
I2
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 1 0 1 0 1 0 Reset
ET
ES
ID O_ K
N ES
S_ d AL IF C
HR
_E R
I2 rve _V _F BA
(re INT SY LO EN
N
ER R EN
EN _E
_T
se ER NC OP
S_ M K R_
M _W 2_
ER
A_ X2
I2 CA CL TE
CA TX DX
ILT
_ _
_ L
S_ D_ S
S_ M FI
_F
I2 LC TX_
I2 CA C_
N
NC
(re D_E
S_ N
S_ D_
d)
LC )
S_ )
ed
SY
I2 SY
ve
I2 LC
rv
_V
_V
er
se
s
S
(re
I2
I2
I2
31 14 13 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 Reset
I2S_LCD_TX_SDX2_EN Set this bit to duplicate data pairs (Frame Form 2) in LCD mode. (R/W)
I2S_INTER_VALID_EN Set this bit to enable camera VGA reducing-resolution mode: only receive two
consecutive cycle data in four consecutive clocks. (R/W)
I2S_VSYNC_FILTER_EN Set this bit to enable I2S VSYNC filter function. (R/W)
se T_ F_ _I T AW
S_ T_ _ R NT AW
S_ d N _R _R W
AW
I2 rve DO INT NT _RA
IN W W
NT W
(re OU EO RR _IN _R
I2 OU CR _E Y_I _R
I2 TX_ UN INT AW W
E_ A A
AK AT _R W
W
_I A
_R
W
S R T T
E_ A_ AW
S_ _H G _R A
S_ P LL IN W
TA T_R
_T _D NT RA
S_ _W P T_ A
I2 RX FU Y_I AW
N
I2 TX_ EM INT AW
RA
I2 RX UN NT T_R
I2 RX EM _IN _R
I2 TX_ FU Y_ RA
I2 IN_ DS MP F_I
I2 OU CR L_E W
RX UT _I T_
D A IN
R
T_
_ R
E R
A
T
S_ T_ _ O
S_ H _ IN
S_ W PT _
S_ R G _
S_ _R LL N
S_ D TA R
I2 X_ NE F_
I2 IN_ TO T_
O O
E
N
T
_
I
S_ D E
S_ D C
S_ T_ _I
I2 IN_ C_
I2 OU NC
U
S_ Y
d)
)
S_ S
I2 V_S
ve
I2 IN_
T
er
_
s
S
(re
I2
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
I2S_TX_PUT_DATA_INT_RAW The raw interrupt status bit for I2S_TX_PUT_DATA_INT interrupt. (RO)
I2S_RX_WFULL_INT_RAW The raw interrupt status bit for I2S_RX_WFULL_INT interrupt. (RO)
I2S_RX_REMPTY_INT_RAW The raw interrupt status bit for I2S_RX_REMPTY_INT interrupt (RO)
I2S_TX_WFULL_INT_RAW The raw interrupt status bit for I2S_TX_WFULL_INT interrupt. (RO)
I2S_TX_REMPTY_INT_RAW The raw interrupt status bit for I2S_TX_REMPTY_INT interrupt. (RO)
I2S_RX_HUNG_INT_RAW The raw interrupt status bit for I2S_RX_HUNG_INT interrupt. (RO)
I2S_TX_HUNG_INT_RAW The raw interrupt status bit for I2S_TX_HUNG_INT interrupt. (RO)
I2S_IN_DONE_INT_RAW The raw interrupt status bit for I2S_IN_DONE_INT interrupt. (RO)
I2S_IN_SUC_EOF_INT_RAW The raw interrupt status bit for I2S_IN_SUC_EOF_INT interrupt. (RO)
I2S_OUT_DONE_INT_RAW The raw interrupt status bit for I2S_OUT_DONE_INT interrupt. (RO)
I2S_OUT_EOF_INT_RAW The raw interrupt status bit for I2S_OUT_EOF_INT interrupt. (RO)
I2S_V_SYNC_INT_RAW The raw interrupt status bit for I2S_V_SYNC_INT interrupt. (RO)
se T_ F_ _I T T
I2 OU CR _E Y_I _ST
T
E_ T T
_S
_I T
S_ T_ _ R NT
T NT
S_ d N _S _S
S_ _H G _S T
TA T_S
_T _D NT ST
S_ _W P T_ T
NT
I2 RX UN NT T_S
ST
I2 RX EM _IN _S
E_ A_ T
I2 IN_ DS MP F_I
I2 TX_ FU Y_ ST
I2 RX FU Y_I T
I2 TX_ EM INT T
RX UT _I T_
AK AT _S
I2 TX_ UN INT T
D A IN
T_
S
E R
_ S
T
S_ D TA ST
S_ T_ _ O
S_ H _ IN
S_ W PT _
S _ P LL IN
S_ R G _
S_ _R LL N
IN
I2 OU CR L_E
I2 X_ NE F_
I2 IN_ TO T_
O O
E
N
T
_
I
S_ D E
S_ D C
S_ T_ _I
I2 IN_ C_
I2 OU NC
U
S_ Y
)
)
ed
S_ S
I2 V_S
I2 IN_
rv
T
se
S _
(re
I2
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
I2S_RX_WFULL_INT_ST The masked interrupt status bit for I2S_RX_WFULL_INT interrupt (RO)
I2S_RX_REMPTY_INT_ST The masked interrupt status bit for I2S_RX_REMPTY_INT interrupt. (RO)
I2S_TX_WFULL_INT_ST The masked interrupt status bit for I2S_TX_WFULL_INT interrupt. (RO)
I2S_TX_REMPTY_INT_ST The masked interrupt status bit for I2S_TX_REMPTY_INT interrupt. (RO)
I2S_RX_HUNG_INT_ST The masked interrupt status bit for I2S_RX_HUNG_INT interrupt. (RO)
I2S_TX_HUNG_INT_ST The masked interrupt status bit for I2S_TX_HUNG_INT interrupt. (RO)
I2S_IN_DONE_INT_ST The masked interrupt status bit for I2S_IN_DONE_INT interrupt. (RO)
I2S_IN_SUC_EOF_INT_ST The masked interrupt status bit for I2S_IN_SUC_EOF_INT interrupt. (RO)
I2S_OUT_DONE_INT_ST The masked interrupt status bit for I2S_OUT_DONE_INT interrupt. (RO)
I2S_OUT_EOF_INT_ST The masked interrupt status bit for I2S_OUT_EOF_INT interrupt. (RO)
I2S_V_SYNC_INT_ST The masked interrupt status bit for I2S_V_SYNC_INT interrupt. (RO)
se T_ F_ _I T A
S_ T_ _ R NT A
S_ d N _E _E A
(re OU EO RR _IN _EN
I2 OU CR _E Y_I _EN
NA
IN A A
NT A
E_ N N
I2 TX_ UN INT NA A
_I N
AK AT _E A
_E
A
T NT
S_ _H G _E N
TA T_E
_T _D NT EN
E_ A_ NA
S_ _W P T_ N
S_ P LL IN A
EN
I2 RX FU Y_I NA
I2 RX UN NT T_E
I2 TX_ EM INT NA
I2 TX_ FU Y_ EN
I2 RX EM _IN _E
I2 IN_ DS MP F_I
I2 OU CR L_E A
RX UT _I T_
D A IN
T_
E
E R
_ E
S_ D TA EN
T
S_ T_ _ O
S_ H _ IN
S_ W PT _
S_ R G _
S_ _R LL N
I2 X_ NE F_
I2 IN_ TO T_
O O
E
N
T
_
I
S_ D E
S_ D C
S_ T_ _I
I2 IN_ C_
I2 OU NC
U
S_ Y
d)
)
S_ S
I2 V_S
ve
I2 IN_
T
er
_
s
S
(re
I2
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
I2S_RX_WFULL_INT_ENA The interrupt enable bit for the I2S_RX_WFULL_INT interrupt. (R/W)
I2S_RX_HUNG_INT_ENA The interrupt enable bit for the I2S_RX_HUNG_INT interrupt. (R/W)
se T_ F_ _I T LR
S_ T_ _ R NT LR
S_ d N _C _C R
I2 rve DO INT NT _CL
(re OU EO RR _IN _C
I2 OU CR _E Y_I _C
IN R R
E_ L L
I2 TX_ UN INT LR R
_ D _IN _C R
S_ _W P T_ LR
S R T T
R
R
S_ _H G _C L
KE TA NT CL
AT T LR
N
S_ T_ LL IN R
IN LR
I2 RX UN NT T_C
I2 RX FU Y_I LR
CL
CL
I2 TX_ EM INT LR
I2 RX EM _IN _C
I2 PU FU Y_ CL
I2 IN_ DS MP F_I
I2 OU CR L_E R
TA DA _I T_
A_ _C
C
T_
T_
_ C
E R
T
L
S_ T_ _ O
S_ H _ IN
S_ W PT _
S_ R G _
S_ _R LL N
S_ D TA C
I2 X_ NE F_
I2 IN_ TO T_
O O
E
N
T
_
I
S_ D E
S_ D C
S_ T_ _I
I2 IN_ C_
I2 OU NC
U
S_ Y
d)
)
S_ S
I2 V_S
ve
I2 IN_
T
er
_
s
S
(re
I2
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
AY
AY
LA
AY
Y
Y
AY
LA
EL
Y
EL
LA
DE
Y
EL
LA
Y
LA
LA
EL
_D
DE
LA
_D
DE
N W
NV
TX SY LE_
_D
DE
DE
_D
DE
DE
UT
S
UT
_B C_S
T_
_I
UT
UT
SY C_
N_
AB
IN
N_
AT _IN
_O
_
_O
U
IN
O
IN
O
_D N
_I
K_
O
EN
_I
_
S_
CK
S_
K
CK
CK
D_
D_
S
S
C
BC
A_
_W
_W
_W
_W
S_ _D
_B
_S
)
_B
_B
_S
ed
I2 X
RX
RX
RX
RX
RX
TX
TX
TX
TX
TX
TX
rv
_D
_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 Reset
I2S_TX_BCK_IN_DELAY Number of delay cycles for BCK signal into the transmitter based on
I2S0_CLK. (R/W)
I2S_TX_WS_IN_DELAY Number of delay cycles for WS signal into the transmitter based on
I2S0_CLK. (R/W)
I2S_RX_BCK_IN_DELAY Number of delay cycles for BCK signal into the receiver based on
I2S0_CLK. (R/W)
I2S_RX_WS_IN_DELAY Number of delay cycles for WS signal into the receiver based on I2S0_CLK.
(R/W)
I2S_RX_SD_IN_DELAY Number of delay cycles for SD signal into the receiver based on I2S0_CLK.
(R/W)
I2S_TX_BCK_OUT_DELAY Number of delay cycles for BCK signal out of the transmitter based on
I2S0_CLK. (R/W)
• 0: delayed by 0 cycles
• 1: delayed by 1 cycles
• 2: delayed by 2 cycles
• 3: delayed by 3 cycles
I2S_TX_WS_OUT_DELAY Number of delay cycles for WS signal out of the transmitter based on
I2S0_CLK. (R/W)
• 0: delayed by 0 cycles
• 1: delayed by 1 cycles
• 2: delayed by 2 cycles
• 3: delayed by 3 cycles
I2S_TX_SD_OUT_DELAY Number of delay cycles for SD signal out of the transmitter based on
I2S0_CLK. (R/W)
• 0: delayed by 0 cycles
• 1: delayed by 1 cycles
• 2: delayed by 2 cycles
• 3: delayed by 3 cycles
I2S_RX_WS_OUT_DELAY Number of delay cycles for WS signal out of the receiver based on
I2S0_CLK. (R/W)
• 0: delayed by 0 cycles
• 1: delayed by 1 cycles
• 2: delayed by 2 cycles
• 3: delayed by 3 cycles
I2S_RX_BCK_OUT_DELAY Number of delay cycles for BCK signal out of the receiver based on
I2S0_CLK. (R/W)
• 0: delayed by 0 cycles
• 1: delayed by 1 cycles
• 2: delayed by 2 cycles
• 3: delayed by 3 cycles
I2S_TX_DSYNC_SW Set this bit to synchronize signals into the transmitter by two flip-flop synchro-
nizer. (R/W)
• 0: the signals will be firstly clocked by rising clock edge , then clocked by falling clock edge.
• 1: the signals will be firstly clocked by falling clock edge, then clocked by rising clock edge.
I2S_RX_DSYNC_SW Set this bit to synchronize signals into the receiver by two flip-flop synchronizer.
(R/W)
• 0: the signals will be clocked by rising clock edge firstly, then clocked by falling clock edge.
• 1: the signals will be clocked by falling clock edge firstly, then clocked by rising clock edge.
I2S_DATA_ENABLE_DELAY Number of delay cycles for data valid flag based on I2S0_CLK. (R/W)
I2S_TX_BCK_IN_INV Set this bit to invert BCK signal input to the slave transmitter. (R/W)
31 0
64 Reset
R
P
DD
TO
UT K S
O IN RE
_A
S_ TL _
I2 OU INK
NK
LI
S_ TL
)
)
S_ d
ed
UT
I2 rve
I2 OU
rv
O
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 0x000 Reset
NK TA RT
LI S A
_S RT
DR
P
IN K_ ST
TO
AD
S_ IN E
I2 INL K_R
K_
S_ IN
IN
)
d)
S_ d
I2 rve
ve
I2 INL
NL
er
_I
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 0x000 Reset
DR
AD
S_
DE
F_
O
_E
UT
_O
S
I2
31 0
0x000000 Reset
31 0
0x000000 Reset
DR
AD
S_
DE
R_
BF
F_
O
_E
UT
S _O
I2
31 0
0x000000 Reset
I2S_OUT_EOF_BFR_DES_ADDR The address of buffer relative to the outlink descriptor that pro-
duces EOF (RO)
CR
S
_D
NK
LI
IN
S_
I2
31 0
0 Reset
31 0
0 Reset
1
BF
R_
SC
_D
K
IN
NL
S _I
I2
31 0
0 Reset
R
SC
_D
NK
LI
UT
S _O
I2
31 0
0 Reset
31 0
0 Reset
31 0
0 Reset
I2 rve EO BU _EN N
DE EN
K
se T_ R_ ST _E
I2 AH LO ES BAC
O _
ZE
(re OU SC UR ST
M ST
T
W N
ST
SI
S_ S TA ER
S_ BM S ES
S_ TD B R
S_ d F_ R
S_ T_ _ R
S_ T_ O E
S_ BM O T
K_
I2 OU R_ _BU
_R ST R
I2 OU OP _W
I2 OU K_ S_
I2 IND DA N
I2 AH _R _T
IN R O_
_B
T
T
P
S_ LO TO
S_ T_ IF
S_ EC A
EM
I2 CH _TR
I2 OU _F
I2 IN_ AU
ST
M
S_ T_
)
)
S_ M
T_
ed
I2 ME
I2 OU
EX
rv
se
S_
S_
(re
I2
I2
31 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 1 0 0 0 0 0 0 0 0 Reset
I2S_IN_RST Set this bit to reset in-DMA FSM. Set this bit before the DMA configuration. (R/W)
I2S_OUT_RST Set this bit to reset out-DMA FSM. Set this bit before the DMA configuration. (R/W)
I2S_AHBM_FIFO_RST Set this bit to reset AHB interface cmdFIFO of DMA. Set this bit before the
DMA configuration. (R/W)
I2S_AHBM_RST Set this bit to reset AHB interface of DMA. Set this bit before the DMA configuration.
(R/W)
I2S_OUT_AUTO_WRBACK Set this bit to enable outlink-written-back automatically when out buffer
is transmitted done. (R/W)
I2S_OUT_EOF_MODE DMA out EOF flag generation mode. 1: When DMA has popped all data from
the FIFO. 0: When AHB has pushed all data to the FIFO. (R/W)
I2S_OUTDSCR_BURST_EN DMA outlink descriptor transfer mode configuration bit. 1: Prepare out-
link descriptor with burst mode. 0: Prepare outlink descriptor with byte mode. (R/W)
I2S_INDSCR_BURST_EN DMA inlink descriptor transfer mode configuration bit. 1: Prepare inlink
descriptor with burst mode. 0: Prepare inlink descriptor with byte mode. (R/W)
I2S_OUT_DATA_BURST_EN Transmitter data transfer mode configuration bit. 1: Prepare out data
with burst mode. 0: Prepare out data with byte mode. (R/W)
I2S_CHECK_OWNER Set this bit to enable check owner bit by hardware. (R/W)
R
DD
TE
_A
TA
CR
T
S
N
DS
_F PTY
R_
TE
_C
L
_
SC
UL
TA
NK
FO
O EM
_D
_S
FI
LI
S_ T_
UT
UT
UT
UT
UT
I2 OU
_O
O
_
S_
S_
S_
S
S
I2
I2
I2
I2
I2
31 30 29 23 22 20 19 18 17 0
0 0 0 0 0 0x000 Reset
DR
UG
AD
EB
E
AT
R_
_D
ST
SC
NT
_F TY
R_
E
_D
_C
L
AT
IN MP
SC
UL
NK
O
ST
IF
_D
S_ E
LI
F
I2 IN_
N_
IN
IN
IN
_I
_
S_
S_
S_
S
S
I2
I2
I2
I2
I2
31 30 29 23 22 20 19 18 17 0
0 0 0 0 0 0x000 Reset
E
DL
d)
_I
ve
X
_T
r
se
S
(re
I2
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
M
NU
B
_A
_
IV
IV
IV
L
_D
_D
_D
EN
S_ _SE
KM
KM
K_
)
ed
LK
CL
CL
CL
CL
rv
_C
se
S_
S_
S_
S
(re
I2
I2
I2
I2
I2
31 23 22 21 20 19 14 13 8 7 0
I2S_CLK_SEL Set this bit to select I2S module clock source. 0: No clock. 1: APLL_CLK. 2:
PLL_160M_CLK. 3: No clock. (R/W)
M
U
NU
_N
D
V_
O
IV
M
DI
M
_D
S_
S_
K_
CK
IT
IT
C
_B
_B
)
_B
_B
ed
RX
RX
TX
TX
rv
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_TX_BITS_MOD Set the bits to configure bit length of I2S transmitter channel, the value of which
can only be 8, 16, 24 and 32. (R/W)
I2S_RX_BITS_MOD Set the bits to configure bit length of I2S receiver channel, the value of which
can only be 8, 16, 24 and 32. (R/W)
E
AT
_D
S
I2
31 0
0x19052500 Reset
Each unit includes two channels (ch0 and ch1) which can independently increment or decrement its pulse
counter value. The remainder of the chapter will mostly focus on channel 0 (ch0) as the functionality of the two
channels is identical.
1. One control signal (e.g. ctrl_ch0_un, the control signal for ch0 of unit n)
2. One input pulse signal (e.g. sig_ch0_un, the input pulse signal for ch0 of unit n)
27.1 Features
A PCNT has the following features:
• Each unit consists of two independent channels sharing one pulse counter
• All channels have input pulse signals (e.g. sig_ch0_un) with their corresponding control signals (e.g.
ctrl_ch0_un)
• Independent filtering of input pulse signals (sig_ch0_un and sig_ch1_un) and control signals (ctrl_ch0_un
and ctrl_ch1_un) on each unit
1. Selection between counting on positive or negative edges of the input pulse signal
2. Configuration to Increment, Decrement, or Disable counter mode for control signal’s high and low
states
Figure 27-2 shows PCNT’s architecture. As stated above, ctrl_ch0_un is the control signal for ch0 of unit n. Its
high and low states can be assigned different counter modes and used for pulse counting of the channel’s input
pulse signal sig_ch0_un on negative or positive edges. The available counter modes are as follows:
• Increment mode: When a channel detects an active edge of sig_ch0_un (the one configured for counting),
the counter value pulse_cnt increases by 1. Upon reaching PCNT_CNT_H_LIM_Un, pulse_cnt is cleared. If
the channel’s counter mode is changed or if PCNT_CNT_PAUSE_Un is set before pulse_cnt reaches
PCNT_CNT_H_LIM_Un, then pulse_cnt freezes and its counter mode changes.
• Decrement mode: When a channel detects an active edge of sig_ch0_un (the one configured for counting),
the counter value pulse_cnt decreases by 1. Upon reaching PCNT_CNT_L_LIM_Un, pulse_cnt is cleared. If
the channel’s counter mode is changed or if PCNT_CNT_PAUSE_Un is set before pulse_cnt reaches
PCNT_CNT_H_LIM_Un, then pulse_cnt freezes and its counter mode changes.
• Disable mode: Counting is disabled, and the counter value pulse_cnt freezes.
Table 159 to Table 162 provide information on how to configure the counter mode for channel 0.
Table 159: Counter Mode. Positive Edge of Input Pulse Signal. Control Signal in Low State
Table 160: Counter Mode. Positive Edge of Input Pulse Signal. Control Signal in High State
Table 161: Counter Mode. Negative Edge of Input Pulse Signal. Control Signal in Low State
Table 162: Counter Mode. Negative Edge of Input Pulse Signal. Control Signal in High State
Each unit has one filter for all its control and input pulse signals. A filter can be enabled with the bit
PCNT_FILTER_EN_Un. The filter monitors the signals and ignores all the noise, i.e. the glitches with pulse widths
shorter than
PCNT_FILTER_THRES_Un APB clock cycles in length.
As previously mentioned, each unit has two channels which process different input pulse signals and increase or
decrease values via their respective inc_dec modules, then the two channels send these values to the adder
module that is 16-bit wide with a sign bit. This adder can be suspended by setting PCNT_CNT_PAUSE_Un, and
cleared by setting PCNT_PULSE_CNT_RST_Un.
The PCNT has five watchpoints that share one interrupt. The interrupt can be enabled or disabled by interrupt
enable signals of each individual watchpoint.
• Maximum count value: When pulse_cnt reaches PCNT_CNT_H_LIM_Un, an interrupt is triggered and
PCNT_CNT_THR_H_LIM_LAT_Un is high.
• Minimum count value: When pulse_cnt reaches PCNT_CNT_L_LIM_Un, an interrupt is triggered and
PCNT_CNT_THR_L_LIM_LAT_Un is high.
27.3 Applications
In each unit, channel 0 and channel 1 can be configured to work independently or together. The three
subsections below provide details of channel 0 incrementing independently, channel 0 decrementing
independently, and channel 0 and channel 1 incrementing together. For other working modes not elaborated in
this section (e.g. channel 1 incrementing/decremeting independently, or one channel incrementing while the
other decrementing), reference can be made to these three subsections.
Figure 27-3 illustrates how channel 0 is configured to increment independently on the positive edge of
sig_ch0_un while channel 1 is disabled (see subsection 27.2 for how to disable channel 1). The configuration of
channel 0 is shown below.
• PCNT_CH0_LCTRL_MODE_Un=0: When ctrl_ch0_un is low, the counter mode specified for the low state
turns on, in this case it is Increment mode.
• PCNT_CH0_HCTRL_MODE_Un=2: When ctrl_ch0_un is high, the counter mode specified for the low state
turns on, in this case it is Disable mode.
Figure 27-4 illustrates how channel 0 is configured to decrement independently on the positive edge of
sig_ch0_un while channel 1 is disabled. The configuration of channel 0 in this case differs from that in Figure 27-3
in the following aspects:
Figure 27-5 illustrates how channel 0 and channel 1 are configured to increment on the positive edge of
sig_ch0_un and sig_ch1_un respectively at the same time. It can be seen in Figure 27-5 that control signal
ctrl_ch0_un and ctrl_ch1_un have the same waveform, so as input pulse signal sig_ch0_un and sig_ch1_un. The
configuration procedure is shown below.
• For channel 0:
– PCNT_CH0_LCTRL_MODE_Un=0: When ctrl_ch0_un is low, the counter mode specified for the low
state turns on, in this case it is Increment mode.
– PCNT_CH0_HCTRL_MODE_Un=2: When ctrl_ch0_un is high, the counter mode specified for the low
state turns on, in this case it is Disable mode.
• For channel 1:
– PCNT_CH1_LCTRL_MODE_Un=0: When ctrl_ch1_un is low, the counter mode specified for the low
state turns on, in this case it is Increment mode.
– PCNT_CH1_HCTRL_MODE_Un=2: When ctrl_ch1_un is high, the counter mode specified for the low
state turns on, in this case it is Disable mode.
27.6 Registers
Register 27.1: PCNT_Un_CONF0_REG (n: 03) (0x0000+0xC*n)
Un
n
n
_U
_U
_U
Un
Un
n
E_
NT HR _L _EN _U
_U
_U
DE
DE
DE
_E _EN Un
ILT ER _E n
Un Un
N H _L S0 _
D
Un
E_
E_
PC _T _L E EN
DE
DE
O
O
O
ER O N_
N_ _
D
D
S_
_M
_M
_M
NT HR HR S1_
O
O
O
E
_
_M
NT HR G_M
M
M
RL
RL
RL
RL
HR
S_
S_
PC T_T R_T RE
EG
CT
CT
CT
CT
_T
O
N H H
_H
_N
_H
NT 0_N
_P
_P
ER
_L
_L
PC _T _T
H1
H1
H1
H1
H0
H0
H0
LT
PC CH
FI
_C
_C
_C
_C
_C
_C
_C
PC _T
_
_
NT
NT
NT
NT
NT
NT
NT
NT
NT
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
0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0 0 1 1 1 1 0x10 Reset
PCNT_FILTER_THRES_Un This sets the maximum threshold, in APB_CLK cycles, for the filter. Any
pulses with width less than this will be ignored when the filter is enabled. (R/W)
PCNT_FILTER_EN_Un This is the enable bit for unit n’s input filter. (R/W)
PCNT_THR_ZERO_EN_Un This is the enable bit for unit n’s zero 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_L_LIM_EN_Un This is the enable bit for unit n’s thr_l_lim comparator. (R/W)
PCNT_THR_THRES0_EN_Un This is the enable bit for unit n’s thres0 comparator. (R/W)
PCNT_THR_THRES1_EN_Un This is the enable bit for unit n’s thres1 comparator. (R/W)
PCNT_CH0_NEG_MODE_Un This register sets the behavior when the signal input of channel 0 de-
tects a negative edge. 1: Increase the counter. 2: Decrease the counter. 0, 3: No effect on
counter. (R/W)
PCNT_CH0_POS_MODE_Un This register sets the behavior when the signal input of channel 0 de-
tects a positive edge. 1: Increase the counter. 2: Decrease the counter. 0, 3: No effect on
counter. (R/W)
PCNT_CH1_NEG_MODE_Un This register sets the behavior when the signal input of channel 1 de-
tects a negative edge. 1: Increment the counter. 2: Decrement the counter. 0, 3: No effect on
counter. (R/W)
PCNT_CH1_POS_MODE_Un This register sets the behavior when the signal input of channel 1 de-
tects a positive edge. 1: Increment the counter. 2: Decrement the counter. 0, 3: No effect on
counter. (R/W)
Un
Un
1_
0_
S
ES
RE
HR
TH
T
T_
T_
CN
CN
_
_
NT
NT
PC
PC
31 16 15 0
PCNT_CNT_THRES0_Un This register is used to configure the thres0 value for unit n. (R/W)
PCNT_CNT_THRES1_Un This register is used to configure the thres1 value for unit n. (R/W)
n
n
_U
_U
IM
IM
_L
_L
_H
_L
NT
NT
_C
_C
NT
NT
PC
PC
31 16 15 0
PCNT_CNT_H_LIM_Un This register is used to configure the thr_h_lim value for unit n. (R/W)
PCNT_CNT_L_LIM_Un This register is used to configure the thr_l_lim value for unit n. (R/W)
_P T_P NT 1 2
NT 0 1
0
NT N E_C E_U T_U
_C _U _U
_U
N N E_ E_ T_
SE SE ST
ST
PC T_C LS US RS
PC T_C LS US RS
PC T_P T_P CN U3
UL AU _R
_R
N N E_ E_
N U A T_
N U A T_
PC _C S S
NT UL AU
N
PC T_P T_P
_E
LK
N N
)
)
d
ed
_C
PC _C
ve
rv
NT
NT
r
se
se
PC
PC
(re
(re
31 17 16 15 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
PCNT_CLK_EN The registers clock gate enable signal of PCNT module. 1: the registers can be read
and written by application. 0: the registers can not be read or written by application (R/W)
Un
_
NT
E _C
LS
PU
)
ed
_
rv
NT
se
PC
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
PCNT_PULSE_CNT_Un This register stores the current pulse count value for unit n. (RO)
n
LA Un
n
_U
_M _U
NT R_T RES AT_ n
HR RE _LA n
PC CN TH L_L _L _Un
_Z S1_ T_
H H _L U
H 0 U
DE
T
NT T_T R_T IM AT_
_ T_ _ IM T
O
NT N HR _L _LA
PC T_C T_T R_H RO
O
ER
N N H E
PC T_C T_T R_Z
N N H
PC T_C T_T
_T
N N
d)
PC _C
_C
ve
NT
r
se
PC
(re
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 0x0 Reset
PCNT_CNT_THR_L_LIM_LAT_Un The latched value of low limit event of PCNT_Un when threshold
event interrupt is valid. 1: the current pulse counter equals to thr_l_lim and low limit event is valid.
0: others. (RO)
PCNT_CNT_THR_H_LIM_LAT_Un The latched value of high limit event of PCNT_Un when threshold
event interrupt is valid. 1: the current pulse counter equals to thr_h_lim and high limit event is valid.
0: others. (RO)
VE _U IN AW
_U IN AW
T_ W
W
IN A
RA
_E NT 2_ T_R
NT 1_ T_R
0_ T_R
HR VE _U IN
_T _E NT 3_
NT HR VE _U
_C T_T _E NT
NT N HR VE
PC T_C T_T R_E
N N H
PC T_C T_T
N N
)
ed
PC T_C
v
er
N
s
PC
(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 0 Reset
VE _U IN T
_U IN T
IN T
ST
_E NT 2_ T_S
NT 1_ T_S
0_ T_S
T_
HR VE _U IN
_T _E NT 3_
NT HR VE _U
_C T_T _E NT
NT N HR VE
PC T_C T_T R_E
N N H
PC _C T_T
NT N
)
ed
PC T_C
rv
se
N
PC
(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 0 Reset
T_ A
A
IN N
EN
_E NT 2_ T_E
NT 1_ T_E
0_ T_E
HR VE _U IN
_T _E NT 3_
NT HR VE _U
_C T_T _E NT
NT N HR VE
PC T_C T_T R_E
N N H
PC _C T_T
NT N
)
ed
PC T_C
rv
se
N
PC
(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 0 Reset
VE _U IN LR
_U IN LR
T_ R
R
IN L
CL
_E NT 2_ T_C
NT 1_ T_C
0_ T_C
HR VE _U IN
_T _E NT 3_
NT HR VE _U
_C T_T _E NT
NT N HR VE
PC T_C T_T R_E
N N H
PC _C T_T
NT N
)
ed
PC T_C
rv
se
N
PC
(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 0 Reset
31 0
0x19072601 Reset
28.1 Overview
The ESP32-S2 features a USB On-The-Go peripheral (henceforth referred to as OTG_FS) along with an
integrated transceiver. The OTG_FS can operate as either a USB Host or Device and supports 12 Mbit/s
full-speed (FS) and 1.5 Mbit/s low-speed (LS) data rates of the USB 2.0 specification. The Host Negotiation
Protocol (HNP) and the Session Request Protocol (SRP) are also supported.
28.2 Features
28.2.1 General Features
• FS and LS data rates
– Slave mode
• Maximum of five IN endpoints concurrently active at any time (including EP0 IN)
– A control pipe consists of two channels (IN and OUT), as IN and OUT transactions must be handled
separately. Only Control transfer type is supported.
– Each of the other seven channels are dynamically configurable to be IN or OUT, and supports Bulk,
Isochronous, and Interrupt transfer types.
• All channels share an RX FIFO, non-periodic TX FIFO, and periodic TX FIFO. The size of each FIFO is
configurable.
The core part of the OTG_FS peripheral is the USB Controller Core. The controller core has the following
interfaces (see Figure 28-1):
• CPU Interface
Provides the CPU with read/write access to the controller core’s various registers and FIFOs. This interface
is internally implemented as an AHB Slave Interface. The way to access the FIFOs through the CPU
interface is called Slave mode.
• APB Interface
Allows the CPU to control the USB controller core via the USB external controller.
• DMA Interface
Provides the controller core’s internal DMA with read/write access to system memory (e.g., fetching and
writing data payloads when operating in DMA mode). This interface is internally implemented as an AHB
Master interface.
• Read access to any address in any one of the 4 KB push/pop regions will result in a pop from the shared
RX FIFO.
• Write access to a particular 4 KB push/pop region will result in a push to the corresponding endpoint or
channel’s TX FIFO given that the endpoint is an IN endpoint, or the channel is an OUT channel.
– In Host mode, data is pushed to the non-periodic TX FIFO or the periodic TX FIFO depending on
whether the channel is a non-periodic channel, or a periodic channel.
• Access to the 128 KB read/write region will result in direct read/write instead of a push/pop. This is
generally used for debugging purposes only.
Note that pushing and popping data to and from the FIFOs by the CPU is only required when operating in Slave
mode. When operating in DMA mode, the internal DMA will handle all pushing/popping of data to and from the
TX and RX FIFOs.
The portion of SPRAM that can be used for FIFO allocation has a depth of 256 and a width of 35 bits (32 data
bits plus 3 control bits). The multiple FIFOs used by each channel (in Host mode) or endpoint (in Device mode)
are allocated into the SPRAM and can be dynamically sized.
• Nonperiodic TX FIFO: Stores data payloads of bulk and control OUT transactions for all channels.
• Periodic TX FIFO: Stores data payloads of interrupt or isochronous OUT transactions for all channels.
• RX FIFO: Stores data payloads of all IN transactions, and status entries that are used to indicate size of
data payloads and transaction/channel events such as transfer complete or channel halted.
In addition to FIFOs, Host mode also contains two request queues used to queue up the various transaction
request from the multiple channels. Each entry in a request queue holds the IN/OUT channel number along with
other information to perform the transaction (such as transaction type). Request queues are also used to queue
other types of requests such as a channel halt request.
Unlike FIFOs, request queues are fixed in size and cannot be accessed directly by software. Rather, once a
channel is enabled, requests will be automatically written to the request queue by the Host core. The order in
which the requests are written into the queue determines the sequence of transactions on the USB.
• Nonperiodic request queue: Request queue for all non-periodic channels (bulk and control). The queue
has a depth of four entries.
• Periodic request queue: Request queue for all periodic channels (interrupt and isochronous). The queue
has a depth of eight entries.
When scheduling transactions, hardware will execute all requests on the periodic request queue first before
executing requests on the non-periodic request queue.
The following FIFOs are used when operating in Device mode (See Figure 28-4):
• RX FIFO: Stores data payloads received in Data packet, and status entries (used to indicate size of those
data payloads).
• Dedicated TX FIFO: Each active IN endpoint will have a dedicated TX FIFO used to store all IN data
payloads of that endpoint, regardless of the transaction type (both periodic and non-periodic IN
transactions).
Due to the dedicated FIFOs, Device mode does not use any request queues. Instead, the order of IN
transactions are determined by the Host.
The following bits of the USB_GINTSTS_REG register indicate an interrupt source lower in the hierarchy:
• USB_PRTINT indicates that the Host port has a pending interrupt. The USB_HPRT_REG register indicates
• USB_HCHINT indicates that one or more Host channels have a pending interrupt. Read the
USB_HAINT_REG register to determine which channel(s) have a pending interrupt, then read the pending
channel’s USB_HCINTn_REG register to determine the interrupt source.
• USB_OEPINT indicates that one or more OUT endpoints have a pending interrupt. Read the
USB_DAINT_REG register to determine which OUT endpoint(s) have a pending interrupt, then read the
USB_DOEPINTn_REG register to determine the interrupt source.
• USB_IEPINT indicates that one or more IN endpoints have a pending interrupt. Read the
USB_DAINT_REG register to determine which IN endpoint(s) are pending, then read the pending IN
endpoint’s USB_DIEPINTn_REG register to determine the interrupt source.
• USB_OTGINT indicates an OTG event has triggered an interrupt. Read the USB_GOTGINT_REG register
to determine which OTG event(s) triggered the interrupt.
• When transmitting a packet using IN endpoints or OUT channels, the data payload must be pushed into
the corresponding endpoint or channel’s TX FIFO.
• When receiving a packet, the packet’s status entry must first be popped off the RX FIFO by reading
USB_GRXSTSP_REG. The status entry should be used to determine the length of the packet’s payload (in
bytes). The corresponding number of bytes must then be manually popped off the RX FIFO by reading from
the RX FIFO’s memory region.
• When transmitting a packet using IN endpoints or OUT channels, the data payload’s address in memory
should be written to the USB_HCDMAn_REG (in Host mode) or USB_DIEPDMAn_REG (in Device mode)
registers. When the endpoint or channel is enabled, the internal DMA will push the data payload from
memory into the TX FIFO of the channel or endpoint.
• When receiving a packet using OUT endpoints or IN channels, the address of an empty buffer in memory
should be written to the USB_HCDMAn_REG (in Host mode) or USB_DOEPDMAn_REG (in Device mode)
registers. When the endpoint or channel is enabled, the internal DMA will pop the data payload from RX
FIFO into the buffer.
When operating in Scatter/Gather DMA mode, buffers containing data payloads can be scattered throughout
memory. Each endpoint or channel will have a contiguous DMA descriptor list, where each descriptor contains a
32-bit pointer to the data payload or buffer and a 32-bit buffer descriptor (BufferStatus Quadlet). The data
payloads and buffers can correspond to a single transaction (i.e., < 1 MPS bytes) or an entire transfer (> 1 MPS
bytes). (MPS: maximum packet size) The list is implemented as a ring buffer meaning that the DMA will return to
the first entry when it encounters the last entry on the list.
• When transmitting a transfer/transaction using IN endpoints or OUT channels, the DMA will gather the data
payloads from the multiple buffers and push them into a TX FIFO.
• When receiving a transfer/transaction using OUT endpoints or IN channels, the DMA will pop the received
data payloads from the RX FIFO and scatter them to the multiple buffers pointed to by the DMA list entries.
When operating at the transaction level in DMA mode, the transfer size is set to the size of one data packet
(either a maximum packet size or a short packet size).
The following table describes transaction level operation in Slave mode for both IN and OUT transactions.
1. Software specifies the size of the data packet 1. Software specifies the expected size of
and the number of data packets (1 data the data packet (1 MPS) and the num-
packet) in the USB_HCTSIZn_REG regis- ber of data packets (1 data packet) in the
ter, enables the channel, then copies the USB_DIEPTSIZn_REG register. Once the
packet’s data payload into the TX FIFO. endpoint is enabled, it will wait for the host
2. When the last DWORD of the data payload to transmit a packet to it.
has been pushed, the controller core will au- 2. The received packet will be pushed into the
tomatically write a request into the appropri- RX FIFO along with a packet status entry.
ate request queue. 3. If the transaction was unsuccessful (e.g., due
3. If the transaction was successful, the to a full RX FIFO), the endpoint will automat-
USB_XFERCOMPL interrupt will be gener- ically NAK the incoming packet.
ated. If the transaction was unsuccessful,
an error interrupt (e.g. USB_H_NACKn) will
occur.
IN Transactions
1. Software specifies the expected size of the 1. Software specifies the size of the data packet
data packet and the number of packets (1 and the number of data packets (1 data
data packet) in the USB_HCTSIZn_REG reg- packet) in the USB_DOEPTSIZn_REG regis-
ister, then enables the channel. ter. Once the endpoint is enabled, it will wait
2. The controller core will automatically write a for the host to read the packet.
request into the appropriate request queue. 2. When the packet has been transmitted, the
3. If the transaction was successful, the re- USB_XFERCOMPL interrupt will be gener-
ceived data along with a status entry should ated.
be written to the RX FIFO. If the transaction
was unsuccessful, an error interrupt (e.g.,
USB_H_NACKn) will occur.
When operating at the transfer level in Slave mode, one or more transaction-level operations can be pipelined
thus being analogous to transfer level operation in DMA mode. Within pipelined transactions, multiple packets of
the same transfer can be read/written from the FIFOs in single instance, thus preventing the need for interrupting
the software on a per-packet basis.
Operating on a transfer level in Slave mode is similar to operating on the transaction-level, except the transfer size
and packet count for each transfer in the USB_HCTSIZn_REG or USB_DOEPTSIZn_REG register will need to be
set to reflect the entire transfer. After the channel or endpoint is enabled, multiple data packets worth of payloads
should be written to or read from the TX or RX FIFOs respectively (given that there is enough space or enough
data).
28.4 OTG
USB OTG allows OTG devices to act in the USB Host role or the USB Device role. Thus, OTG devices will
typically have a Mini-AB or Micro-AB receptacle so that it can receive an A-plug or B-plug. OTG devices will
• A-device defaults to the Host role (A-Host) whilst B-device defaults to the Device role (B-Peripheral).
• A-device and B-device may exchange roles by using the Host Negotiation Protocol (HNP), thus becoming
A-peripheral and B-Host.
• A-device can turn off Vbus to save power. B-device can then wake up the A-device by requesting it to turn
on Vbus and start a new session. This mechanism is called session request protocol (SRP).
OTG devices are able to determine whether they are connected to an A plug or a B plug using the ID pin of the
plugs. The ID pin in A-plugs are pulled to ground whilst B-plugs have the ID pin left floating.
1. To save power, the application suspends and turns off port power when the bus is idle by writing to the
Port Suspend (USB_PRTSUSP to 1’b0) and Port Power (USB_PRTPWR to 1’b0) bits in the Host Port
Control and Status register.
3. The A-device must detect SE0 for at least 2 ms to start SRP when Vbus power is off.
4. To initiate SRP, the B-device turns on its data line pull-up resistor for 5 to 10 ms. The OTG_FS core detects
data-line pulsing.
5. The device drives Vbus above the A-device session valid (2.0 V minimum) for Vbus pulsing. The OTF_FS
core interrupts the application on detecting SRP. The Session Request Detected bit (USB_SESSREQINT) is
set in Global Interrupt Status register.
6. The application must service the Session Request Detected interrupt and turn on the Port Power bit by
writing the Port Power bit in the Host Port Control and Status register. The PHY indicates port power-on by
asserting usb_otg_vbusvalid_in signal.
7. When the USB is powered, the B-device connects, completing the SRP process.
1. To save power, the host (A-device) suspends and turns off port power when the bus is idle. PHY indicates
port power off by deasserting the usb_otg_vbusvalid_in signal. The OTG_FS core sets the Early Suspend
bit in the Core Interrupt register (USB_ERLYSUSP interrupt) after detecting 3 ms of bus idleness. Following
this, the OTF_FS core sets the USB Suspend bit (USB_USBSUSP) in the Core Interrupt register. The PHY
indicates the end of the B-device session by deasserting the usb_otg_bvalid_in signal.
2. The OTG_FS core asserts the usb_otg_dischrgvbus signal to indicate to the PHY to speed up Vbus
discharge.
3. The PHY indicates the session’s end by asserting the usb_otg_sessend_in signal. This is the initial condition
for SRP. The OTG_FS core requires 2 ms of SE0 before initiating SRP. For a USB 2.0 full-speed serial
transceiver, the application must wait until Vbus discharges to 0.2 V after USB_BSESVLD is deasserted.
4. The application waits for 1.5 seconds (TB_SE0_SRP time) before initiating SRP by writing the Session
Request bit (USB_SESREQ) in the OTG Control and Status register. The OTG_FS core performs data-line
pulsing followed by Vbus pulsing.
5. The host (A-device) detects SRP from either the data-line or Vbus pulsing, and turns on Vbus. The PHY
indicates Vbus power-on by asserting usb_otg_vbusvalid_in.
6. The OTG_FS core performs Vbus pulsing by asserting usb_srp_chrgvbus. The host (A-device) starts a new
session by turning on Vbus, indicating SRP success. The OTG_FS core interrupts the application by setting
the Session Request Success Status Change bit (USB_SESREQSC) in the OTG Interrupt Status register.
The application reads the Session Request Success bit in the OTG Control and Status register.
7. When the USB is powered, the OTG_FS core connects, completing the SRP process.
1. The OTG_FS core sends the B-device a SetFeature b_hnp_enable descriptor to enable HNP support. The
B-device’s ACK response indicates that the B-device supports HNP. The application must set Host Set
HNP Enable bit (USB_HSTSETHNPEN) in the OTG Control and Status register to indicate to the OTG_FS
core that the B-device supports HNP.
2. When it has finished using the bus, the application suspends by writing the Port Suspend bit
(USB_PRTSUSP) in the Host Port Control and Status register.
3. When the B-device observes a USB suspend, it disconnects, indicating the initial condition for HNP. The
B-device initiates HNP only when it must switch to the host role; otherwise, the bus continues to be
suspended. The OTG_FS core sets the Host Negotiation Detected interrupt (USB_HSTNEGDET) in the
OTG Interrupt Status register, indicating the start of HNP. The OTG_FS core deasserts the
usb_otg_dppulldown and usb_otg_dmpulldown signals to indicate a device role. The PHY enables the D+
pull-up resistor, thus indicates a connection for the B-device. The application must read the Current Mode
bit (USB_CURMOD_INT) in the OTG Control and Status register to determine Device mode operation.
4. The B-device detects the connection, issues a USB reset, and enumerates the OTG_FS core for data traffic.
5. The B-device continues the host role, initiating traffic, and suspends the bus when done. The OTG_FS core
sets the Early Suspend bit (USB_ERLYSUSP) in the Core Interrupt register after detecting 3 ms of bus
idleness. Following this, the OTG_FS core sets the USB Suspend bit (USB_USBSUSP) in the Core Interrupt
register.
6. In Negotiated mode, the OTG_FS core detects the suspend, disconnects, and switches back to the host
role. The OTG_FS core asserts the usb_otg_dppulldown and usb_otg_dmpulldown signals to indicate its
assumption of the host role.
7. The OTG_FS core sets the Connector ID Status Change interrupt (USB_CONIDSTS) in the OTG Interrupt
Status register. The application must read the connector ID status in the OTG Control and Status register to
determine the OTG_FS core’s operation as an A-device. This indicates the completion of HNP to the
application. The application must read the Current Mode bit in the OTG Control and Status register to
determine Host mode operation.
1. The A-device sends the SetFeature b_hnp_enable descriptor to enable HNP support. The OTG_FS core’s
ACK response indicates that it supports HNP. The application must set the Device HNP Enable bit
(USB_DEVHNPEN) in the OTG Control and Status register to indicate HNP support. The application sets
the HNP Request bit (USB_DEVHNPEN) in the OTG Control and Status register to indicate to the OTG_FS
core to initiate HNP.
2. When A-device has finished using the bus, it suspends the bus.
(a) The OTG_FS core sets the Early Suspend bit (USB_ERLYSUSP) in the Core Interrupt register after 3
ms of bus idleness. Following this, the OTG_FS core sets the USB Suspend bit (USB_USBSUSP) in
the Core Interrupt register. The OTG_FS core disconnects and the A-device detects SE0 on the bus,
indicating HNP.
(b) The OTG_FS core asserts the usb_otg_dppulldown and usb_otg_dmpulldown signals to indicate its
assumption of the host role.
(c) The A-device responds by activating its D+ pull-up resistor within 3 ms of detecting SE0. The
OTG_FS core detects this as a connect.
(d) The OTG_FS core sets the Host Negotiation Success Status Change interrupt in the OTG Interrupt
Status register (USB_CONIDSTS), indicating the HNP status. The application must read the Host
Negotiation Success bit (USB_HSTNEGSCS) in the OTG Control and Status register to determine
host negotiation success. The application must read the Current Mode bit (USB_CURMOD_INT) in
the Core Interrupt register to determine Host mode operation.
3. Program the USB_PRTPWR bit to 1’b1. This drives Vbus on the USB.
4. Wait for the USB_PRTCONNDET interrupt. This indicates that a device is connected to the port.
5. The application sets the reset bit (USB_PRTRST) and the OTG_FS core issues a USB reset and
enumerates the A-device for data traffic.
7. The OTG_FS core continues the host role of initiating traffic, and when done, suspends the bus by writing
the Port Suspend bit (USB_PRTSUSP) in the Host Port Control and Status register.
8. In Negotiated mode, when the A-device detects a suspend, it disconnects and switches back to the host
role. The OTG_FS core deasserts the usb_otg_dppulldown and usb_otg_dmpulldown signals to indicate
the assumption of the device role.
9. The application must read the Current Mode bit (USB_CURMOD_INT) in the Core Interrupt register to
determine the Host mode operation.
29.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-S2 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.
29.2 Features
ESP32-S2 TWAI controller supports the following features:
• Supports Standard Frame Format (11-bit ID) and Extended Frame Format (29-bit ID)
– Normal
• Special transmissions
– Self Reception (the TWAI controller transmits and receives messages simultaneously)
– Error counters
Single Channel and NonReturntoZero: 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).
BitStuffing: 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 29.3.2 for more details).
Multicast: 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 29.3.3).
Multimaster: 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.
MessagePriorities and Arbitration: If two or more nodes simultaneously initiate a transmission, the TWAI
protocol 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 291. 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
determine 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
Receiver.
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 168: 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 29.3.3). The following Figure 29-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 29-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 29.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
r0 fields must be Dominant.
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
Overload Flag. After detecting the 14th consecutive Dominant bit (when sending an Active Error Flag or
Overload 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 29-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.
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 shortened
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
Resynchronization. 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 29.5.1).
Command Register
The command register is used by the CPU to drive the TWAI controller to initiate certain actions such as
transmitting a message or clearing the Receive Buffer. The command register can only be modified when the
TWAI controller is in Operation Mode (see section 29.5.1).
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
consecutive Recessive bits to occur before being able to fully connect the TWAI bus (i.e., be able to transmit or
receive).
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
equation: (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.
– 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
threshold 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 175: Buffer Layout for Standard Frame Format and Extended Frame Format
Table 175 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 177-178.
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 179-182.
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.
Receive Buffer will then map to the next message in the Receive FIFO. A data overrun occurs 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).
• Whatever free space is left in the Receive FIFO is filled with the partial contents of the overrun message. If
the Receive FIFO is already full, then none of the overrun message’s contents will be stored.
• On the first message that causes the Receive FIFO to overrun, a Data Overrun Interrupt will be triggered.
• Each overrun message will still increment the TWAI_RX_MESSAGE_COUNTER up to a maximum of 64.
• The RX FIFO will internally mark overrun messages as invalid. The TWAI_MISS_ST bit can be used to
determine whether the message currently mapped to by the Receive Buffer is valid or overrun.
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 registers.
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 29-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 29-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 29-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 29.5.3). The following figure
29-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
Reserved ERRC.11 ERRC.01 DIR2 SEG.43 SEG.33 SEG.23 SEG.13 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 184 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
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
Bit SEG.4 Bit SEG.3 Bit SEG.2 Bit SEG.1 Bit SEG.0 Description
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 185 illustrates the bit fields of the TWAI_ERR_CODE_CAP_REG whilst Figure 29-11 illustrates the bit
positions of a TWAI message.
Table 185: 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.
DE
_M LY E
DE O
ES _O _M E
ET N OD
O _M
_R EN T D
AI IST ES MO
TW I_L F_ R_
A EL TE
T
TW I_S FIL
A 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)
C
P_
ES
UM
PR
_J
D_
NC
AU
)
SY
ed
_B
rv
_
AI
AI
se
TW
TW
(re
31 16 15 14 13 0
TWAI_BAUD_PRESC Baud Rate Prescaler, determines the frequency dividing ratio. (RO | R/W)
1
M
G
SA
SE
SE
E_
E_
E_
M
IM
IM
)
ed
I
_T
_T
_T
rv
AI
AI
AI
se
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
R_
d)
R
ve
_E
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 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
E_C
NC
TA
EP
CC
_A
AI
W
|T
0
E_
YT
_B
)
ed
X
_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_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
W
|T
1
E_
YT
_B
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_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
DE
O
E_C
NC
TA
EP
CC
_A
AI
W
|T
2
E_
YT
_B
)
ed
X
_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_
YT
_B
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_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
E_
YT
_B
d)
X
ve
_T
er
AI
s
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
E_
YT
_B
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_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
E_
YT
_B
d)
X
ve
_T
er
AI
s
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
E_
YT
_B
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_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
E_
YT
_B
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_8 Stored the 8th byte information of the data to be transmitted under operating
mode. (WO)
9
E_
YT
_B
d)
X
ve
_T
er
AI
s
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
E_
YT
_B
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_10 Stored the 10th byte information of the data to be transmitted under operating
mode. (WO)
11
E_
YT
_B
)
ed
X
_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_11 Stored the 11th byte information of the data to be transmitted under operating
mode. (WO)
12
E_
YT
_B
d)
X
e
_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_12 Stored the 12th byte information of the data to be transmitted under operating
mode. (WO)
D
L
_C
_C
ver
AI
AI
se
TW
TW
(re
31 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 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)
AI BO SE UN
X_ T_ UF
A L VE Q
E
TW I_A EA RR
_T R _B
TW I_R _O _R
RE TX
A LR X
Q
R
TW _C _
AI ELF
)
E
ed
TW I_S
rv
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_ ST
A X_ T T
TW I_O BU PLE
TW I_T _S _S
ST
_R RR T
BU N_
A RR FF
A US ST
X_ U
A X_ M
TW I_E _O
TW I_T CO
TW I_T ST
TW I_R ST
TW _B _
AI ISS
A X_
A X_
)
ed
TW I_M
rv
se
A
TW
(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 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)
TWAI_MISS_ST This bit reflects whether the data packet in the RX FIFO is complete. 1: The current
packet is missing; 0: The current packet is complete (RO)
AP
_C
ST
O
_L
RB
)
ed
_A
rv
AI
se
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)
T
O
EN
TI
EC
M
E
EG
_E TYP
IR
_D
_S
_
TW CC
CC
CC
d)
ve
_E
_E
r
AI
AI
AI
se
TW
TW
(re
31 8 7 6 5 4 0
TWAI_ECC_SEGMENT This register contains information about the location of errors, see Table 183
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)
_R
ve
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_RX_ERR_CNT The RX error counter register, reflects value changes under reception status.
(RO | R/W)
NT
_C
RR
_E
d)
X
ve
_T
er
AI
s
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
TE
UN
CO
E_
G
SA
ES
M
X_
d)
_R
e
rv
AI
se
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)
T
_S
ST
VE ST
X_ _S _IN T
NT
TW rve _P T_ _ST
IN T T_
_R T N S
SI _
AI X_I AR NT_
_I
A d) AS INT
se RR OS T
(re I_E _L _IN
TW _T _W _I
ST
AI RR UN
A RB RR
T_
TW _E RR
TW I_A _E
N
A US
AI VE
)
ed
TW I_O
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 a data overrun
interrupt is generated in the RX FIFO. (RO)
TWAI_ERR_PASSIVE_INT_ST Error passive interrupt. If this bit is set to 1, it indicates the TWAI
Controller is switched between error active status and error passive status due to the change of
error counters. (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)
NA
A
_E
_I A
EN
X_ _E _IN NA
A d) AS INT A
VE EN
NT
TW rve _P T_ _EN
IN N T_
_R T N E
SI _
AI X_I AR NT_
se RR OS T
(re I_E _L _IN
A
T_ A
TW _T _W _I
EN
AI RR UN
A RB RR
TW _E RR
TW I_A _E
N
A US
AI VE
d)
TW I_O
TW I_B
ve
er
A
s
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
30.1 Overview
The LED PWM controller is primarily designed to control LED devices, as well as generate PWM signals. It has
14-bit timers and waveform generators.
30.2 Features
The LED PWM controller has the following features:
• Fading duty cycle of PWM signals without interference from any processors. An interrupt can be generated
after the fade has completed
For the convenience of description, in the following sections the eight waveform generators are collectively
referred to as PWMn, and the four timers are collectively referred to as Timerx.
30.3 Functional Description
30.3.1 Architecture
Figure 30-1 shows the architecture of the LED PWM controller. Figure 30-2 illustrates a PWM generator with its
selected timer and a counter.
30.3.2 Timers
The clock of the LED PWM controller, LEDC_PWM_CLK, has three clock sources: APB_CLK, RTC8M_CLK and
XTAL_CLK, selected by configuring LEDC_APB_CLK_SEL[1:0]. The clock of each LED PWM timer, LEDC_CLKx,
has two clock sources: LEDC_PWM_CLK or REF_TICK. When REF_TICK is used as the clock source of a timer,
LEDC_APB_CLK_SEL[1:0] should be set 1 and the cycle of REF_TICK should be an integral multiple of
APB_CLK cycles. Otherwise this clock will be not accurate. For more information on the clock sources, please
see Chapter Reset and Clock.
The output clock derived from LEDC_CLKx is used as the base clock for the counter. The divider’s divisor is
configured by LEDC_CLK_DIV_TIMERx. It is a fixed-point number: the highest 10 bits is the integer part
represented as A, while the lowest eight bits is the fractional part represented as B. This divisor LEDC_CLK_DIVx
is calculated as:
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 30-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 LED PWM controller has a 14-bit counter that counts up to 2LEDC_T IM ERx_DU T Y _RES − 1. If the counting
value reaches 2LEDC_T IM ERx_DU T Y _RES − 1, the counter will overflow and restart counting from 0. The
counting value can be reset, suspended or read by software. A LEDC_TIMERx_OVF_INT interrupt can be
generated every time when the counter overflows or when it overflows for (LEDC_OVF_NUM_CHn + 1) times.
The interrupt configuration is as follows:
1. Set LEDC_OVF_CNT_EN_CHn
3. Set LEDC_OVF_CNT_CHn_INT_ENA
4. Set LEDC_TIMERx_DUTY_RES to enable the timer and wait for a LEDC_OVF_CNT_CHn_INT interrupt
The frequency of a PWM generator output signal, sig_outn, depends on both the divisor of the divider, as well as
the range of the counter:
fLEDC_CLKx
fsig_outn =
LEDC_CLK_DIVx · 2LEDC_TIMERx_DUTY_RES
To change the divisor and times of overflow, you should configure LEDC_CLK_DIV_TIMERx and
LEDC_TIMERx_DUTY_RES respectively, and then set LEDC_TIMERx_PARA_UP; otherwise this change is not
valid. The newly configured value is updated upon next overflow of the counter.
Hpointn is updated by LEDC_HPOINT_CHn when the counter overflows. The initial value of Lpointn is the sum of
LEDC_DUTY_CHn[18..4] and LEDC_HPOINT_CHn when the counter overflows. By configuring these two fields,
the relative phase and the duty cycle of the PWM output can be set.
Figure 30-4 illustrates PWM’s waveform when the duty cycle is fixed.
LEDC_DUTY_CHn is a fixed-point register with four fractional bits. LEDC_DUTY_CHn[18..4] is the integral part
used directly for PWM calculation. LEDC_DUTY_CHn[3..0] is the fractional part used to dither the output. If
LEDC_DUTY_CHn[3..0] is non-zero, then among every 16 cycles of sig_outn, LEDC_DUTY_CHn[3..0] have PWM
pulses with width one timer cycle longer than that of (16-LEDC_DUTY_CHn[3..0]). This feature effectively
increases the resolution of the PWM generator to 18 bits.
LEDC_DUTY_START_CHn is used to update the value of Lpointn. When this bit is set and the counter overflows,
Lpointn increments or decrements automatically, depending on whether the bit LEDC_DUTY_INC_CHn is set or
cleared.
The duty cycle of sig_outn changes every LEDC_DUTY_CYCLE_CHn PWM pulse cycles by adding or
subtracting the value of LEDC_DUTY_SCALE_CHn.
Figure 30-5 is a diagram of fading duty cycle. Upon reaching LEDC_DUTY_NUM_CHn, the fade stops and
a
LEDC_DUTY_CHNG_END_CHn_INT interrupt is generated. When configured like this, the duty cycle of sig_outn
increases by LEDC_DUTY_SCALE_CHn every LEDC_DUTY_CYCLE_CHn PWM pulse cycles.
30.3.5 Interrupts
• LEDC_OVF_CNT_CHn_INT: Triggered when the timer counter overflows for (LEDC_OVF_NUM_CHn + 1)
times and register LEDC_OVF_CNT_EN_CHn is set to 1.
• LEDC_TIMERx_OVF_INT: Triggered when a LED PWM timer has reached its maximum counter value.
30.6 Registers
Register 30.1: LEDC_CHn_CONF0_REG (n: 07) (0x0000+0x14*n)
CH H n
N_ _C CH
n n
_E ET T_
NT ES _S
n
_C _R ET
_S _CH
Hn
Hn
VF NT ES
DC _O CH n
_C
LE SIG LV_ CH
U n
N
_C
_O F_C T_R
IM T_E
EL
_ E_ _
UM
DC DL UP
DC V N
LE _O F_C
_N
LE C_I RA_
ER
VF
DC V
d)
D A
LE C_O
_O
LE C_P
_T
ve
DC
er
D
s
LE
LE
LE
(re
31 18 17 16 15 14 5 4 3 2 1 0
0: select timer 0.
1: select timer 1.
2: select timer 2.
LEDC_IDLE_LV_CHn This bit is used to control the output value when channel n is inactive. (R/W)
LEDC_OVF_NUM_CHn This register is used to configure the maximum times of overflow minus
1. The LEDC_OVF_CNT_CHn_INT interrupt will be triggered when channel n overflows for
(LEDC_OVF_NUM_CHn + 1) times. (R/W)
Hn
n
CH Hn
CH
Hn
_C
C_ C
n
_
IN T_
_C
LE
CL
Y_ AR
UM
CA
CY
UT ST
_N
_S
_D TY_
Y_
TY
Y
UT
UT
DC U
DU
LE C_D
_D
_D
_
DC
DC
DC
D
LE
LE
LE
LE
31 30 29 20 19 10 9 0
LEDC_DUTY_SCALE_CHn This register is used to configure the changing step scale of duty on chan-
nel n. (R/W)
LEDC_DUTY_NUM_CHn This register is used to control the number of times the duty cycle will be
changed. (R/W)
LEDC_DUTY_INC_CHn This register is used to increase or decrease the duty of output signal on
channel n. 1: Increase;0: Decrease. (R/W)
L
SE
_
LK
N
_C
_E
PB
LK
d )
_C
_A
ve
DC
DC
ser
LE
LE
(re
31 30 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 0x0 Reset
LEDC_APB_CLK_SEL This bit is used to select clock source for the 4 timers. 1: APB_CLK; 2:
RTC8M_CLK; 3: XTAL_CLK. (R/W)
LEDC_CLK_EN This bit is used to control clock. 1: Force clock on for register. 0: Support clock only
when application writes registers. (R/W)
n
CH
T_
IN
PO
)
ed
_H
rv
DC
se
LE
(re
31 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
LEDC_HPOINT_CHn The output value changes to high when the selected timers has reached the
value specified by this register. (R/W)
Hn
_C
TY
U
d)
_D
e
rv
DC
se
LE
(re
31 19 18 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
LEDC_DUTY_CHn This register is used to change the output duty by controlling the Lpoint. The
output value turns to low when the selected timers has reached the Lpoint. (R/W)
_D
rv
DC
se
LE
(re
31 19 18 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
LEDC_DUTY_R_CHn This register stores the current duty of output signal on channel n. (RO)
ES
x_ T x
_T ER L_T _UP
ER RS ER
_R
ER
E
IM x_ IM
TY
US
DC IM SE RA
IM
DU
LE C_T K_ PA
PA
_T
IV
D IC x_
x_
_D
LE C_T ER
ER
LK
D IM
IM
)
ed
_C
LE C_T
T
C_
rv
DC
se
D
LE
LE
LE
(re
31 26 25 24 23 22 21 4 3 0
LEDC_TIMERx_DUTY_RES This register is used to control the range of the counter in timer x. (R/W)
LEDC_CLK_DIV_TIMERx This register is used to configure the divisor for the divider in timer x. The
least significant eight bits represent the fractional part. (R/W)
LEDC_TIMERx_RST This bit is used to reset timer x. The counter will show 0 after reset. (R/W)
LEDC_TICK_SEL_TIMERx This bit is used to select clock for timer x. When this bit is set to 1
LEDC_APB_CLK_SEL[1:0] should be 1, otherwise the timer clock may be not accurate. 0:
LEDC_PWM_CLK; 1: REF_TICK. (R/W)
_T
e
rv
DC
se
LE
(re
31 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
LEDC_TIMERx_CNT This register stores the current counter value of timer x. (RO)
31
31
0
0
0
0
0
0
(RO)
0
0
Espressif Systems
0
0
(re (re
set to 1. (RO)
0
0
se se
rve rv
ed
0
0
d) )
0
0
30. LED PWM Controller (LEDC)
0
0
0
0
0
20
0
20
0
0
19
19
LE LE
LEDC_OVF_CNT_CHn_INT_ST This
DC D
0
0
18
18
is
0
0
17
17
0
0
16
16
the
0
0
15
15
791
0
0
14
14
0
0
13
13
0
0
12
12
masked
D V N H NT T D V N H NT AW
0
0
11
11
9
9
0
0
8
8
0
0
interrupt
LE C_D TY_ HN 0_I _S LE C_D TY_ HN 0_I _R
D U C G_ NT T D U C G_ NT AW
Register 30.10: LEDC_INT_ST_REG (0x00C4)
Register 30.9: LEDC_INT_RAW_REG (0x00C0)
7
7
0
0
6
6
0
0
5
5
0
0
status
LE C_D TY_ HN EN CH IN LE C_D TY_ HN EN CH IN
D U C G_ D_ 6_ T_ D U C G_ D_ 6_ T_
4
4
0
0
3
3
bit
0
0
2
2
0
0
for
1
1
0
0
0
0
the
LEDC_DUTY_CHNG_END_CHn_INT interrupt when LEDC_DUTY_CHNG_END_CHn_INT_ENAIS
LEDC_DUTY_CHNG_END_CHn_INT_ST This is the masked interrupt status bit for the
LEDC_TIMERx_OVF_INT_ST This is the masked interrupt status bit for the LEDC_TIMERx_OVF_INT
LEDC_OVF_CNT_CHn_INT_RAW Interrupt raw bit for channel n. Triggered when the ovf_cnt has
LEDC_DUTY_CHNG_END_CHn_INT_RAW Interrupt raw bit for channel n. Triggered when the grad-
LEDC_TIMERx_OVF_INT_RAW Triggered when the timerx has reached its maximum counter value.
ER OV IN T IN T ER OV IN AW IN A
0_ F_ T_S T_ 0_ F_ T_R T_ W
31
31
0
0
0
0
0
0
(R/W)
0
0
Espressif Systems
0
0
rupt. (R/W)
(re (re
s
0
0
se er
rv ve
ed
0
0
) d)
0
0
30. LED PWM Controller (LEDC)
0
0
0
0
0
20
0
20
0
0
19
19
LE LE
DC D
0
0
18
18
LE _O LE C_O
D V DC V
0
0
17
17
0
0
16
16
LEDC_DUTY_CHNG_END_CHn_INT_CLR Set
DC V N H
LEDC_DUTY_CHNG_END_CHn_INT_ENA The
0
0
15
15
792
0
0
14
14
13
13
0
0
this
12
12
0
0
11
11
interrupt
10
10
9
9
0
0
bit
LE C_D TY_ T_C 1_I _C LE C_D TY_ T_C 1_I _E
D U C H NT LR D U C H NT NA
8
8
0
0
7
7
0
0
enable
to
6
6
0
0
5
5
0
0
D U C G_ D_ 6_ T_ D U C G_ D_ 6_ T_
4
4
0
0
3
3
0
0
clear
2
2
0
0
for
1
1
0
0
0
0
0 Reset
0 Reset
ER OV IN LR IN L ER OV IN NA IN N
0_ F_ T_C T_ R 0_ F_ T_E T_ A
TE
DA
C_
D
LE
31 0
0x19072601 Reset
31.1 Introduction
The RMT (Remote Control) module is designed to send/receive infrared remote control signals that support for a
variety of remote control protocols. The RMT module converts pulse codes stored in the module’s built-in RAM
into output signals, or converts input signals into pulse codes and stores them back in RAM. In addition, the RMT
module optionally modulates its output signals with a carrier wave, or optionally filters its input signals.
Each channel has a clock divider, counter, transmitter, and receiver. In each channel, only its transmitter or
receiver can be active at the same time. The four channels share a 256 x 32-bit RAM.
The format of pulse code in RAM is shown in Figure 31-3. Each pulse code contains a 16-bit entry with two
fields, level and period. Level (0 or 1) indicates a high-/low-level value was received or is going to be sent, while
”period” points out the clock cycles (see Figure 31-1 clk_div) for which the level lasts. A zero period is interpreted
as a transmission end-marker.
The RAM is divided into four 64 x 32-bit blocks. By default, each channel uses one block (block zero for channel
zero, block one for channel one, and so on). Usually, only one block of 64 x 32-bit worth of data can be sent or
received in channel n. If the data size is larger than this block size, users can configure the channel to enable
wrap mode or to use more blocks by setting RMT_MEM_SIZE_CHn. Setting RMT_MEM_SIZE_CHn > 1 will
prompt channel n to use the memory of subsequent channels, block (n) ~ block (n + RMT_MEM_SIZE_CHn -1). If
so, the subsequent channels n +1 ~ n + RMT_MEM_SIZE_CHn - 1 cannot be used once their RAM blocks are
occupied. Note that the RAM used by each channel is mapped from low address to high address. In such mode,
channel 0 is able to use the RAM blocks for channels 1, 2 and 3 by setting RMT_MEM_SIZE_CHn, but channel 3
cannot use the blocks for channels 0, 1, or 2.
The RMT RAM can be accessed via APB bus, or read by the transmitter and written by the receiver. To protect a
receiver from overwriting the blocks a transmitter is about to transmit, RMT_MEM_OWNER_CHn can be
configured to designate the block’s owner, be it a transmitter or receiver. This way, if this ownership is violated, an
RMT_MEM_OWNER_ERR_CHn flag will be generated.
When the RMT module is inactive, the RAM can be put into low-power mode by setting
RMT_MEM_FORCE_PD.
31.2.3 Clock
The drive clock of a divider is generated by taking either the APB_CLK or REF_TICK according to the state of
RMT_REF_ALWAYS_ON_CHn. (For more information on clock sources, please see Chapter Reset and Clock).
Divider value is normally equal to the value of RMT_DIV_CNT_CHn, except value 0 that represents divider 256.
The clock divider can be reset to zero by clearing RMT_REF_CNT_RST_CHn. The clock generated from the
divider can be used by the clock counter (see Figure 31-3).
31.2.4 Transmitter
When RMT_TX_START_CHn is set to 1, the transmitter of channel n will start reading and sending pulse codes
from the starting address of its RAM block. The codes are sent starting from low-address entry. The transmitter
will stop the transmission, return to idle state and generate an RMT_CHn_TX_END_INT interrupt, when an
end-marker (a zero period) is encountered. Also, setting RMT_TX_STOP_CHn to 1 stops the transmission and
immediately sets the transmitter back to idle. The output level of a transmitter in idle state is determined by the
”level” field of the end-marker or by the content of RMT_IDLE_OUT_LV_CHn, depending on the configuration of
RMT_IDLE_OUT_EN_CHn.
To transmit more pulse codes than can be fitted in the channel’s RAM, users can enable wrap mode by
configuring RMT_MEM_TX_WRAP_EN. In this mode, when the transmitter has reached the end-marker in the
channel’s memory, it will loop back to the first byte. For example, if RMT_MEM_SIZE_CHn is set to 1, the
transmitter will start sending data from the address 64 * n, and then the data from higher RAM address. Once the
transmitter finishes sending the data from (64 * (n +1) - 1), it will continue sending data from 64 * n till encounters
an end-marker. Wrap mode is also applicable for RMT_MEM_SIZE_CHn > 1.
An RMT_CHn_TX_THR_EVENT_INT interrupt will be generated whenever the size of transmitted pulse codes is
larger than or equal to the value set by RMT_TX_LIM_CHn. In wrap mode, RMT_TX_LIM_CHn can be set to a
half or a fraction of the size of the channel’s RAM block. When an RMT_CHn_TX_THR_EVENT_INT interrupt is
detected, the already used RAM region should be updated by subsequent user defined events. Therefore, when
the wrap mode happens the transmitter will seamlessly continue sending the new events.
The output of the transmitter can be modulated using a carrier wave by setting RMT_CARRIER_EN_CHn. The
carrier waveform is configurable. In a carrier cycle, the high level lasts for (RMT_CARRIER_HIGH_CHn +1) clock
cycles of APB_CLK or REF_TICK, while the low level lasts for (RMT_CARRIER_LOW_CHn +1) clock cycles of
APB_CLK or REF_TICK. When RMT_CARRIER_OUT_LV_CHn is set to 1, carrier wave will be added on high-level
output signals; while RMT_CARRIER_OUT_LV_CHn is set to 0, carrier wave will be added on low-level output
signals. Carrier wave can be added on output signals during modulation, or just added on valid pulse codes (the
data stored in RAM), which can be set by configuring RMT_CARRIER_EFF_EN_CHn.
The continuous transmission of the transmitter can be enabled by setting RMT_TX_CONTI_MODE_CHn. When
this register is set, the transmitter will send the pulse codes from RAM in loops. If RMT_TX_LOOP_CNT_EN_CHn
is set to 1, the transmitter will start counting loop times. Once the counting reaches the value of register
RMT_TX_LOOP_NUM_CHn, an RMT_CHn_TX_LOOP_INT interrupt will be generated.
Setting RMT_TX_SIM_EN to 1 will enable multiple channels to start sending data simultaneously.
RMT_TX_SIM_CHn will choose which multiple channels are enabled to send data simultaneously.
31.2.5 Receiver
When RMT_RX_EN_CHn is set to 1, the receiver in channel n becomes active, detecting signal levels and
measuring clock cycles the signals lasts for. These data will be written in RAM in the form of pulse codes.
Receiving ends, when the receiver detects no change in a signal level for a number of clock cycles more than the
value set by RMT_IDLE_THRES_CHn. The receiver will return to idle state and generate an
RMT_CHn_RX_END_INT interrupt.
The receiver has an input signal filter which can be enabled by configuring RMT_RX_FILTER_EN_CHn. The filter
samples input signals continuously, and will detect the signals which remain unchanged for a continuous
RMT_RX_FILTER_THRES_CHn APB clock cycles as valid, otherwise, the signals will be detected as invalid. Only
the valid signals can pass through this filter. The filter will remove pulses with a length of less than
RMT_RX_FILTER_THRES_CHn APB clock cycles.
31.2.6 Interrupts
• RMT_CHn_ERR_INT: Triggered when channel n does not read or write data correctly. For example, if the
transmitter still tries to read data from RAM when the RAM is empty, or the receiver still tries to write data
into RAM when the RAM is full, this interrupt will be triggered.
• RMT_CHn_TX_THR_EVENT_INT: Triggered when the amount of data the transmitter has sent matches the
value of RMT_TX_LIM_CHn.
• RMT_CHn_TX_LOOP_INT: Triggered when the loop counting reaches the value set by
RMT_TX_LOOP_NUM_CHn.
31.5 Registers
Register 31.1: RMT_CHnCONF0_REG (n: 03) (0x0010+8*n)
EF H Hn
Hn
R_ _C C
_C
IE EN LV_
F_ n
EN
n
CH
n
RR R_ T_
CH
n
S_
CA IE OU
CH
E_
RE
T_ ARR R_
T_
IZ
TH
RM _C RIE
CN
_S
_
EM
LE
T AR
V_
d)
ID
DI
e
M
RM C
rv
T_
T_
T_
T_
se
RM
RM
RM
RM
(re
31 30 29 28 27 26 24 23 8 7 0
RMT_DIV_CNT_CHn This field is used to configure clock divider for channel n. (R/W)
RMT_IDLE_THRES_CHn Receiving ends when no edge is detected on input signals for continuous
clock cycles larger than this register value. (R/W)
RMT_MEM_SIZE_CHn This field is used to configure the maximum blocks allocated to channel n.
The valid range is from 1 ~ 4-n. (R/W)
RMT_CARRIER_EN_CHn This bit is used to enable carrier modulation for channel n. 1: Add carrier
modulation on output signals. 0: No carrier modulation is added on output signals. (R/W)
RMT_CARRIER_OUT_LV_CHn This bit is used to configure the position of carrier wave for channel
n. 1’h0: Add carrier wave on low-level output signals. 1’h1: Add carrier wave on high-level output
signals. (R/W)
n
CH
Hn
N_
ER n
RM _M _R _R CH Hn
RI CH
_C
_E
T_ _E R_ T_ Hn
T EM EM R_ C
Hn
PB W O n
_ S C H T_ n
n
K_ WA _C n
AR N_
RX YS Hn
RM _A _O I_M _CH
ES
TX N_ RS CH
RM _R _W _RS T_C
CH AL _LV H
RM _M _M NE DE
TA n C
T_ EF_ UT N_C
_ C _O
HR
Hn
T LE UT n
T EM T N
S
RM _ID _O _CH
RM _M CO R_E
_T
_C
RM _R _O _E
ER
RT
T LE P
D
T _ E
N
RM _ID STO
ILT
RM _TX FILT
_F
T M
T _
d)
T _
E
RX
X
RM _TX
ve
RM R
T_
T_
er
T
s
RM
RM
RM
(re
31 21 20 19 18 17 16 15 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 0xf 0 0 1 0 0 0 0 0 Reset
RMT_RX_EN_CHn Set this bit to enable receiver to receive data on channel n. (R/W)
RMT_MEM_WR_RST_CHn Set this bit to reset RAM write address accessed by the receiver for chan-
nel n. (WO)
RMT_MEM_RD_RST_CHn Set this bit to reset RAM read address accessed by the transmitter for
channel n. (WO)
RMT_MEM_OWNER_CHn This bit marks the ownership of channel n’s RAM block. 1’h1: Receiver
is using the RAM. 1’h0: Transmitter is using the RAM. (R/W)
RMT_TX_CONTI_MODE_CHn Set this bit to restart transmission in continuous mode from the first
data in channel n. (R/W)
RMT_RX_FILTER_EN_CHn Set this bit to enable the receiver’s filter for channel n. (R/W)
RMT_RX_FILTER_THRES_CHn Set this field to ignore the input pulse when its width is less than
RMT_RX_FILTER_THRES_CHn APB clock cycles in receive mode. (R/W)
RMT_CHK_RX_CARRIER_EN_CHn Set this bit to enable memory loop read mode when carrier
modulation is enabled for channel n. (R/W)
RMT_REF_ALWAYS_ON_CHn Set this bit to select a base clock for channel n. 1’h1: APB_CLK;
1’h0: REF_TICK (R/W)
RMT_IDLE_OUT_LV_CHn This bit configures the level of output signals in channel n when the trans-
mitter is in idle state. (R/W)
RMT_IDLE_OUT_EN_CHn This is the output enable bit for channel n in idle state. (R/W)
RMT_TX_STOP_CHn Set this bit to stop the transmitter of channel n sending data out. (R/W)
_M P_ ON
AS EN
FO A _
FI R CE
RM _M _C RCE PU
AP _T _F D
K
T_ EM LK _P
B_ X_W OR
T EM O _
RM _M _F RCE
T EM O
N
RM M _F
_E
T_ EM
K
d)
CL
ve
RM _M
T_
er
T
s
RM
RM
(re
31 30 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 1 0 0 Reset
RMT_APB_FIFO_MASK 1’h1: Access memory directly; 1’h0: Access memory via APB FIFO. (R/W)
RMT_MEM_CLK_FORCE_ON Set this bit to enable the clock for RAM when RMT module starts
working; disable this clock when RMT stops working, to achieve low-power scheme. (R/W)
RMT_MEM_FORCE_PU 1: Disable RAM’s Light-sleep power down function. 0: power down RMT
RAM when RMT is in Light-sleep mode. (R/W)
RMT_CLK_EN Clock gating enable bit for RMT registers to achieve low-power scheme. 1: Power up
drive clock for RMT registers. 0: Power down drive clock for RMT registers. (R/W)
F_ T_ T_ 3
T_ T_ 2
T_ 1
0
RE CN RS CH
CN RS CH
RS CH
CH
T_ EF_ T_ T_
RM _R _CN _RS
T EF T
RM _R _CN
T EF
)
ed
RM _R
rv
se
T
RM
(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 0 Reset
RMT_REF_CNT_RST_CHn This bit is used to reset the clock divider of channel n. (R/W)
Hn
H
_C
_C
S
ES
RE
HR
TH
_T
H_
W
IG
LO
_H
R_
ER
IE
RI
RR
AR
CA
C
T_
T_
RM
RM
31 16 15 0
Hn
CH
_C
H_
W
IG
LO
_H
R_
R
IE
IE
RR
RR
CA
CA
T_
T_
RM
RM
31 16 15 0
RMT_CARRIER_LOW_CHn This field is used to configure the clock cycles of carrier wave at low level
for channel n. (R/W)
RMT_CARRIER_HIGH_CHn This field is used to configure the clock cycles of carrier wave at high
level for channel n. (R/W)
Hn n
_C CH
EN T_
T_ SE
Hn
CN RE
_C
P_ T_
M
NU
O UN
Hn
P_
_L CO
_C
O
IM
TX _
O
T_ OP
_L
_L
d )
RM _LO
TX
TX
ve
T_
T_
er
T
s
RM
RM
RM
(re
31 21 20 19 18 9 8 0
RMT_TX_LIM_CHn This field is used to configure the maximum entries channel n can send out.
When RMT_MEM_SIZE_CHn = 1, this field can be set to any value among 0 ~ 128 (64 * 32/16
= 128); when RMT_MEM_SIZE_CHn > 1, this field can be set to any value among (0 ~ 128) *
RMT_MEM_SIZE_CHn. (R/W)
RMT_TX_LOOP_NUM_CHn This field is used to configure the maximum loop times when continuous
transmission mode is enabled. (R/W)
RMT_LOOP_COUNT_RESET_CHn This bit is used to reset loop counting when continuous trans-
mission mode is valid. (WO)
RM _TX SIM H3
TX IM H2
IM H1
H0
RM _TX SIM N
T _ _C
T_ _S _C
_S _C
_C
T _ _E
RM TX IM
T_ _S
d)
RM _TX
ver
se
T
RM
(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
RMT_TX_SIM_CHn Set this bit to enable channel n to start sending data simultaneously with other
enabled channels. (R/W)
RMT_TX_SIM_EN This bit is used to enable multiple channels to start sending data simultaneously.
(R/W)
W CH n Hn
EM U _ R n
n
M _F TY ER CH
CH
n
_O LL_ CH _C
CH
CH
T_ EM MP R_ R_
R_
X_
RM _M _E _W _ER
X_
ER
NE n
_E
E
R_
R_
T EM EM D
DR
RM _M _M _R
DD
n
AD
CH
T B EM
_W
_R
E_
RM A M
T_ B_
EM
EM
AT
d)
)
ed
ed
P
P
ST
ve
M
RM _A
rv
rv
T_
T_
T_
er
se
se
T
s
RM
RM
RM
RM
(re
(re
(re
31 28 27 26 25 24 23 22 20 19 18 10 9 8 0
RMT_MEM_WADDR_EX_CHn This field records the memory address offset when receiver of channel
n is using the RAM. (RO)
RMT_MEM_RADDR_EX_CHn This field records the memory address offset when transmitter of
channel n is using the RAM. (RO)
RMT_MEM_OWNER_ERR_CHn This status bit will be set when the ownership of memory block is
violated. (RO)
RMT_MEM_FULL_CHn This status bit will be set if the receiver receives more data than the memory
allows. (RO)
RMT_MEM_EMPTY_CHn This status bit will be set when the data to be sent is more than the memory
allows and the wrap mode is disabled. (RO)
RMT_APB_MEM_WR_ERR_CHn This status bit will be set if the offset address is out of memory size
when channel n writes RAM via APB bus. (RO)
RMT_APB_MEM_RD_ERR_CHn This status bit will be set if the offset address is out of memory size
when channel n reads RAM via APB bus. (RO)
_C
_C
DR
DR
AD
AD
_W
_R
EM
EM
M
M
B_
B_
)
)
ed
d
AP
AP
ve
rv
T_
T_
r
se
se
RM
RM
(re
(re
31 19 18 10 9 8 0
RMT_APB_MEM_WADDR_CHn This field records the memory address offset when channel n writes
RAM via APB bus. (RO)
RMT_APB_MEM_RADDR_CHn This field records the memory address offset when channel n reads
RAM via APB bus. (RO)
TE
DA
T_
RM
31 0
0x19072601 Reset
TA
DA
n_
CH
T_
RM
31 0
0x000000 Reset
RMT_CHn_DATA This register is used to read and write data for channel n via APB FIFO. (RO)
T_ H2_ _T P_ T_R W
T H1 _ _ T_ W
T H0 _ _ N W
RM _C _T THR EVE T_IN
RM _C _R _IN INT AW
RM _C _R _IN INT AW
CH RX IN T W
_R W
RM C T N A W
RM _C _T EN RA AW
TX ND A W
AW
RM _C _T LOO _IN RA
RM _C _T LOO _IN RA
RM C T HR IN A
RM _C _T THR EVE RA
T_ 0_ R_ _IN _RA
NT A
T_ H2_ X_E T_R _RA
0_ _E T_R _RA
T H2 R _ _R
T 1 R _ _R
_I _R
_
_
T H1 X_ T_ _R
T H1 _ _ W
T H0 _ _ W
_E _I W
X_ P T
RM _C _T LOO _IN
RM _C _E END INT
RM _C _E END INT
RM _C _E END INT
ND NT
T H1 _ P
X D
X D
X D
RM _C _T LOO
T H2 _
R
X
X
X
X
X
RM _C _T
T H3
T 0
T 3
T 3
d)
H
H
H
e
RM _C
rv
se
T
RM
(re
31 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
RMT_CHn_TX_END_INT_RAW The interrupt raw bit for channel n. Triggered when transmitting ends.
(RO)
RMT_CHn_RX_END_INT_RAW The interrupt raw bit for channel n. Triggered when receiving ends.
(RO)
RMT_CHn_ERR_INT_RAW The interrupt raw bit for channel n. Triggered when error occurs. (RO)
RMT_CHn_TX_THR_EVENT_INT_RAW The interrupt raw bit for channel n. Triggered when trans-
mitter sends more data than configured value. (RO)
RMT_CHn_TX_LOOP_INT_RAW The interrupt raw bit for channel n. Triggered when loop counting
reaches the configured threshold value. (RO)
31
31
0
0
0
0
0
0
(R/W)
0
0
Espressif Systems
0
0
(re (re
s
0
0
se er
rv ve
ed
0
0
) d)
0
0
0
0
0
0
31. Remote Control Peripheral (RMT)
0
20
0
20
0
0
19
19
RM RM
T T
0
0
18
18
RM _C RM _C
T H3 T H3
RMT_CHn_TX_THR_EVENT_INT. (RO)
RMT_CHn_TX_THR_EVENT_INT_ST The
0
0
17
17
RM _C _T RM _C _T
X X
T H2 _ T H2 _
0
0
16
16
RM _C _T LOO RM _C _T LOO
X X
T H1 _ P T H1 _ P
0
0
15
15
806
0
0
14
14
0
0
13
13
0
0
12
12
RM C T HR IN N RM C T HR IN T
X X
T H1 _ _ T_ A T H1 _ _ T_
0
0
11
11
10
10
9
9
0
0
8
8
0
0
T 3 X_ T_ N T A T 3 X_ T_ N T
Register 31.15: RMT_INT_ENA_REG (0x0058)
7
7
0
0
6
6
0
0
5
5
0
0
4
4
0
0
RM C T N N A RM _C _T EN ST T
X D X D
T H1 _ _ A T H1 _ _
0
0
0
0
T H1 X_ T_ _E T H1 X_ T_ _S
1
1
0
0
RM _C _T EN EN NA RM _C _T EN ST T
X D X D
T H0 _ _ A T H0 _ _
RMT_CHn_TX_END_INT_ST The masked interrupt status bit for RMT_CHn_TX_END_INT. (RO)
0
0
CH RX IN T A CH RX IN T
0_ _E T_E _EN 0_ _E T_S _ST
0 Reset
0 Reset
TX ND N A TX ND T
0
0
0
0
Espressif Systems
rupt. (WO)
0
(re
0
se
rv
ed
0
)
0
0
0
31. Remote Control Peripheral (RMT)
0
20
0
19
RM
T
0
18
RM _C
T H3
0
17
RM _C _T
X
T H2 _
0
16
RM _C _T LOO
X
T H1 _ P
0
15
RM _C _T LOO _IN
T 0H X_ P T
_
807
0
14
RM _C _T LOO _IN CL
T 3H X_ P T R
_
0
13
RM _C _T LOO _IN CL
X
T_ H2_ _T P_ T_C R
0
12
RM C T HR IN L
X
T H1 _ _ T_ R
0
11
RM _C _T THR EVE CL
X
T H0 _ _ N R
RM _C _T EN CL T_IN _C
X D L
T H2 _ _ R T_ R
6
RM _C _E END INT CL
T 2 H RR _ _
C R
5
RM _C _R _IN INT LR
RMT_CHn_ERR_INT_CLR Set this bit to clear RMT_CHn_ERR_INT interrupt. (WO)
RM C T N L R
X D
T H1 _ _ R
3
RM _C _E END INT
H R
T 1 R _ _C
2
RM _C _R _IN INT LR
RMT_CHn_TX_END_INT_CLR Set this bit to clear RMT_CHn_TX_END_INT interrupt. (WO)
T H1 X_ T_ _C
1
RM _C _T EN CL LR
RMT_CHn_TX_LOOP_INT_CLR Set this bit to clear RMT_CHn_TX_LOOP_INT interrupt. (WO)
X D
T H0 _ _ R
0
RM _C _E END INT
H R
T_ 0_ R_ _IN _C
RMT_CHn_TX_THR_EVENT_INT_CLR Set this bit to clear RMT_CHn_TX_THR_EVENT_INT inter-
CH RX IN T LR
0_ _E T_C _CL
0 Reset
TX ND L R
32.1 Overview
ESP32-S2 provides the following on-chip sensor and signal processing peripherals:
• One temperature sensor for measuring the internal temperature of the ESP32-S2 chip.
• Two 12-bit* Successive Approximation ADCs (SAR ADCs) controlled by five dedicated controllers that can
input analog signals from total of 20 channels. The SAR ADCs can operate in a high-performance mode or
a low-power mode.
• Two 8-bit independent DACs to generate analog signals. The DACs also support a cosine wave output
mode.
Note:
SAR ADC in chip revision v0.0 has a resolution of 13 bits. For more information about chip revisions, please refer to
ESP32-S2 Series SoC Errata.
• Two digital controllers: DIG ADC1 CTRL and DIG ADC2 CTRL, designed for high-performance
multi-channel scanning and DMA continuous conversion.
• Two RTC controllers: RTC ADC1 CTRL and RTC ADC2 CTRL, designed for single conversion mode and
low power mode.
• One internal controller: PWDET/PKDET CTRL, for power and peak detection (only used by Wi-Fi).
32.2.2 Features
• Two SAR ADCs that can operate separately (i.e., convert data simultaneously)
– Threshold monitoring. An interrupt will be triggered when the value is greater or less than the
threshold.
– Monitor power
The differences between the five ADC controllers are summarized in Table 192.
Feature RTC ADC1 RTC ADC2 DIG ADC1 DIG ADC2 PWDET
Control DAC Y - - - -
Support Deep-sleep mode Y Y - - -
Controlled by ULP coprocessor Y Y - - -
Support vdd33 detection - Y - Y -
Support PWDET/PKDET detection - - - - Y
Support DMA continuous conversion - - Y Y -
SENS_SAR1_DIG_FORCE
RTC
en_pad[9:0] 0
ADC1 CTRL
pad_in[9:0] SARADC1
1 DIG
ADC1 CTRL
SENS_SAR2_RTC_FORCE
internal_mux DIG
internal_signal ADC2 CTRL
0 SAR2ARB
PWDET
SARADC2 CTRL
RTC
1
ADC2 CTRL
en_pad[9:0]
pad_in[9:0]
In order to convert voltages larger than Vref , input signals can be attenuated before being input into the SAR
ADCs.The attenuation can be configured to 0 dB, 2.5 dB, 6 dB, and 11 dB.
The RTC ADC controllers can be triggered to start a conversion by software or by the ULP coprocessor
(ULP-FSM). SENS_MEASn_START_FORCE will select whether an RTC ADC controller is triggered by software or
by the ULP-FSM.
To trigger the RTC ADC controller to start a conversion by software, set SENS_MEASn_START_SAR. When the
conversion is complete, SENS_MEASn_DONE_SAR will be set and the conversion result will be stored in
SENS_MEASn_DATA_SAR.
The RTC ADC controllers are intertwined with the ULP coprocessor, as the ULP coprocessor has a built-in
instruction to start an ADC conversion. In many cases, the controllers need to cooperate with the ULP
coprocessor, e.g.:
• When the controllers periodically monitor a channel during Deep-sleep, ULP coprocessor is the only source
to trigger ADC sampling by configuring RTC registers.
• Continuous scanning or DMA is not supported by the controllers. However, it is possible with the help of
ULP coprocessor to scan channels continuously in a sequence.
• High performance: The clock of the DIG ADC controller is much faster, thus the sample rate is much higher.
• Scanning can be started by software or by DIG ADC timer, depending on the configuration of
APB_SARADC_START_FORCE. Note that DIG ADC timer is enabled by APB_SARADC_TIMER_EN and its
trigger period can be configured by APB_SARADC_TIMER_TARGET.
A measurement rule instructs an ADC to sample a channel (and optionally attenuate the signal of the sampled
channel). Each of the DIG ADC controllers has a rules table, and each table can store 16 rules. When scanning
starts, the controller reads the measurement rules one-by-one from their pattern table. For each controller, a
scanning sequence can include 16 different rules at most, before repeating itself.
The 8-bit item (pattern table register) is composed of three fields that contain channel and attenuation
information, as shown in Table 194.
The scanning mode configured in APB_SARADC_WORK_MODE determines whether the DIG ADC controllers
operate completely independently, or in an alternating or synchronized manner. The following scanning modes
are supported:
• Single-channel scanning: SAR ADC1 and SAR ADC2 will operate independently according to their own
respective pattern tables.
• Double-channel scanning: SAR ADC1 and SAR ADC2 will sample simultaneously (i.e., the two DIG ADC
controllers will progress down their own pattern tables in a synchronized manner).
• Alternate-channel scanning: SAR ADC1 and SAR ADC2 will sample alternately (i.e., the two DIG ADC
controllers will take turns when progressing down their own pattern tables).
The final data sent to the DMA by each conversion is 16-bit. This data is composed of the 12/11-bit ADC result
and some additional information related to the scanning mode:
Two DMA data formats, Type I and Type II, are used to store the data for the above-mentioned two situations, see
Table 195 and Table 196.
32.2.5.2 DMA
DIG ADC controllers support direct memory access via the SPI3 DMA and is triggered by DIG ADC dedicated
timer. Therefore, the DIG ADC controllers should not be used when SPI3 DMA is already being used. Users can
switch the DMA data path to DIG ADC by configuring APB_SARADC_APB_ADC_TRANS via software. For
specific DMA configuration, please refer to SPI3 DMA control.
(k − 1)dataprev datain
datacur = + − 0.5
k k
• datacur is the filtered data value.
To configure the filter, set the filter coefficient using APB_SARADC_ADCn_FILTER_FACTOR then set
APB_SARADC_ADCn_FILTER_EN to enable the filter. The filter is applied to each DIG ADC controller. However,
due to the filter being dependent on previous filtered values (dataprev ), only one channel on each DIG ADC
controller should be scanned when filters are used so that data of different channels are not mixed by the
filter.
Note: Threshold monitoring checks the ADC values on all the channels selected by SAR ADC1 or SAR ADC2,
respectively.
• In fixed priority arbitration, users can set the bits in register APB_SARADC_ARB_CTRL_REG, including
APB_SARADC_ADC_ARB_RTC_PRIORITY (for RTC ADC2 CTRL),
APB_SARADC_ADC_ARB_APB_PRIORITY (for DIG ADC2 CTRL), and
APB_SARADC_ADC_ARB_WIFI_PRIORITY (for PWDET CTRL), to configure the priorities for these
controllers. A larger value indicates a higher priority.
The arbiter ensures that a higher priority controller can always start a conversion (sample) when required,
regardless of whether a lower priority controller already has a conversion in progress. If a higher priority controller
starts a conversion whilst the ADC already has a conversion in progress from a lower priority controller, the
conversion in progress will be interrupted (stopped). The higher priority controller will then start its
conversion.
If a lower priority controller attempts to start a conversion whilst the ADC has a conversion in progress from a
higher priority controller, the lower priority controller will not start the conversion.
The value returned by a conversion that is interrupted or not started will be invalid. Therefore, certain data flags
are embedded into the output data value to indicate whether the conversion is valid or not.
Note:
• The data flag for RTC ADC2 CTRL is the two higher bits of SENS_MEAS2_DATA_SAR.
• The data flag for DIG ADC2 CTRL is the ch_sel[3:0] bits in DMA data.
• The data flag for PWDET/PKDET CTRL is the two higher bits of the sampling result.
Users can configure APB_SARADC_ADC_ARB_GRANT_FORCE to mask the arbiter, and set the bits
APB_SARADC_ADC_ARB_RTC_FORCE, APB_SARADC_ADC_ARB_WIFI_FORCE, and
APB_SARADC_ADC_ARB_APB_FORCE to authorize corresponding controllers.
Note:
• When the arbiter is masked, only one of the above APB_SARADC_ADC_ARB_XXX_FORCE bits can be set
to 1.
• The arbiter uses APB_CLK as its clock source. When the clock frequency is 8 MHz or lower, the arbiter
must be masked.
32.3 DACs
32.3.1 Overview
ESP32-S2 comes with two built-in 8-bit DACs used to convert digital values into analog output signals (up to two
of them). The DACs also support to output cosine waves.
32.3.2 Features
• Two 8-bit DAC converters
• DMA capability
• Fully controlled by ULP coprocessor via registers. See Chapter 1 ULP Coprocessor (ULP).
SENS_DAC_DIG_FORCE
SENS_DAC_CW_ENn
DMA
1
CW generator
1
0
RTCIO_PDACn_DAC[7:0]
0 pdacn_dac[7:0]
RTCIO_PDACn_XPD_DAC
1 pdacn_xpd_dac dacn_out
DACn
0
SAR ADC FSM
pdac_clk
RTCIO_PDACn_DAC_XPD_FORCE
• PDACn_DAC carries the digital value to be converted into an analog voltage and comes from multiple
sources: cosine waveform generator, the register RTCIO_PAD_DACn_REG, or DMA.
The conversion can be started by the register RTCIO_PDACn_XPD_DAC, and controlled by the software or SAR
ADC FSM. For more information, please see Figure 32-5.
CW generator features:
• Adjustable frequency
The frequency of CW can be adjusted by register SENS_SW_FSTEP:
• Scaling
The waveform amplitude can be scaled by 1, 1/2, 1/4, or 1/8 by configuring the register
SENS_DAC_SCALEn.
• DC offset
The register SENS_DAC_DCn may introduce DC offset, leading to a saturated result.
• Phase shift
A phase-shift of 0° or 180° can be added by setting register SENS_DAC_INVn.
– 2: 0°
– 3: 180°
32.4.2 Features
• Monitored in real time by ULP coprocessor when in low-power mode
ANALOG RTC
SENS_TSENS_OUT[7:0]
SENS_TSENS_READY
SENS_TSENS_POWER_UP_FORCE
dump_out_fsm
power_up_fsm
ULP
Tsensor 0
Tsensor_cntl
parameter 1
tsens_data
RTC_REG_
XPD_SAR_ SENS_TSENS_POWER_UP FILE
POWER_DOMAIN SENS_TSENS_DUMP_OUT
SENS_TSENS_IN_INV
As shown in Figure 32-7, the temperature sensor can be started by software or by ULP coprocessor:
– Wait for a while and then configure the register SENS_TSENS_DUMP_OUT. The output value
gradually approaches the actual temperature linearly as the measurement time increases.
– Wait for SENS_TSENS_READY and read the conversion result from SENS_TSENS_OUT.
• Started by ULP-FSM:
– ULP-FSM has a built-in instruction for temperature sampling. Executing the instruction can easily
complete temperature sampling, see Section 1.5 ULP-FSM.
VALUE in the formula is the output of the temperature sensor, and the offset is determined by the temperature
offset TSENS_DAC. Users can set I²C register I2C_SARADC_TSENS_ADC to configure TSENS_DAC according
to the actual environment (the temperature range).
32.5 Interrupts
• APB_SARADC_ADC1_THRES_INT: Triggered when ADC1_DATA reaches the condition set in
APB_SARADC_ADC1_THRES.
For the interrupts routed to ULP-RISC-V, please refer to Section 1.6.3 ULP-RISC-V Interrupts in Chapter 1 ULP
Coprocessor (ULP).
Table 198: OnChip Sensor, SAR ADCs, and DACs Base Addresses
Wherein:
• SENSOR (RTC_PERI) represents the registers, which will be reset due to the power down of RTC_PERI
domain. See Chapter 9 Low-Power Management (RTC_CNTL).
• SENSOR (DIG_PERI) represents the registers, which will be reset due to the power down of digital domain.
See Chapter 9 Low-Power Management (RTC_CNTL).
32.8 Register
32.8.1 SENSOR (RTC_PERI) Registers
Register 32.1: SENS_SAR_READER1_CTRL_REG (0x0000)
NV
V
DI
DA N
_I
1_ T_E
K_
TA
CL
AR IN
_S 1_
1_
NS AR
AR
d)
)
ed
SE _S
_S
ve
rv
NS
NS
r
se
se
SE
SE
(re
(re
31 30 29 28 27 8 7 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 2 Reset
T EN
SE TE_
RE A
C_ LKG
AD _C
AR C
_S AD
TC AR
_R _S
NS TC
d)
)
ed
SE S_R
ve
rv
er
se
N
s
SE
(re
(re
31 24 23 22 21 0
0 0 0 0 0 0 0 0 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 RT OR
_S R
AR
R
NE A
O
SA
S1 TA _F
_F
EA 1_S RT
AD
A_
PA
AT
_M AS STA
_P
N_
_D
EN
NS E 1_
_E
S1
1_
SE S_M AS
R1
EA
AR
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 Reset
SENS_MEAS1_START_SAR SAR ADC1 controller (in RTC) starts conversion, active only when
SENS_MEAS1_START_FORCE = 1. (R/W)
E
RC
O
_F
IG
_D
R1
SA
d)
ve
_
NS
s er
SE
(re
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
EN
TT
_A
AR1
_S
NS
SE
31 0
0xffffffff Reset
SENS_SAR1_ATTEN 2-bit attenuation for each pad. [1:0] is used for channel 0, [3:2] is used for
channel 1, etc. (R/W)
31 0
0xffffffff Reset
SENS_SAR2_ATTEN 2-bit attenuation for each pad. [1:0] is used for channel 0, [3:2] is used for
channel 1, etc. (R/W)
SM
_F
PD
_X
AC
_D
R1
SA
)
ed
_
v
NS
ser
SE
(re
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 3 Reset
E
CL
CY
B_
NV
AR
V
DI
DA N
_I
T_
2_ T_E
K_
TA
AI
CL
AR IN
W
_S 2_
2_
2_
NS AR
AR
AR
N d)
d)
ed
SE S_S
_S
_S
SE rve
e
rv
rv
NS
NS
se
se
se
SE
SE
(re
(re
(re
31 30 29 28 18 17 16 15 8 7 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 Reset
O _S CE
E
RC
_D RT OR
_S R
AR
R
NE A
O
SA
S2 TA _F
_F
EA 2_S RT
D
A_
PA
PA
AT
_M AS STA
N_
N_
_D
NS E 2_
_E
_E
S2
SE S_M AS
R2
R2
EA
N E
SA
SA
SE S_M
M
_
_
NS
NS
NS
N
SE
SE
SE
SE
31 30 19 18 17 16 15 0
0 0 0 0 0 0 Reset
SENS_MEAS2_START_SAR SAR ADC2 controller (in RTC) starts conversion, active only when
SENS_MEAS2_START_FORCE = 1. (R/W)
CC
RC
T_
FO
DE
C_
PW
RT
2_
2_
AR
AR
)
ed
_S
_S
rv
NS
NS
se
SE
SE
(re
31 30 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
E
P RC
_U FO
ER P_
_P WE UT
W U
NS O _O
O R_
IV
DY
_D
_I INV
SE _P P
_E
_T NS UM
UT
LK
EA
NT
NS N_
_O
_C
NS SE _D
_R
SE _I
SE _T NS
NS
_T NS
NS
NS
NS SE
SE
NS SE
SE
SE
)
)
ed
ed
SE S_T
_T
SE S_T
_T
_T
rv
rv
NS
NS
NS
se
se
N
N
SE
SE
SE
SE
SE
(re
(re
31 25 24 23 22 21 14 13 12 11 9 8 7 0
0 0 0 0 0 0 0 0 0 0 6 0 1 0 0 0 0 0x0 Reset
)
d
ed
SE S_T
ve
rv
r
se
se
N
SE
(re
(re
31 17 16 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
O E_ H
E OW
_F C IG
IG OR _H
RC L
N
_D _F CE
SE S_D C_ SE E_E
AC LK OR
NS A L V
N
N A RE AT
_E
N A CL T
_D C_C K_F
SE S_D C_ KG
SE S_D C_ K_I
EP
NE
N A CL
ST
O
C
_T
_F
SE _D C_
SW
SW
NS A
d)
)
ed
SE S_D
ve
_
rv
NS
NS
er
se
N
s
SE
SE
SE
(re
(re
31 28 27 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 Reset
SENS_SW_FSTEP Frequency step for CW generator can be used to adjust the frequency. (R/W)
SENS_DAC_DIG_FORCE 0: DAC1 and DAC2 do not use DMA. 1: DAC1 and DAC2 use DMA. (R/W)
_D CW N2
NV 1
1
N
LE
LE
NS C_ _E
AC _E
CA
CA
C1
SE DA CW
NV
DC
D
_S
_S
_I
_I
_ C_
C_
C_
AC
AC
AC
NS A
DA
DA
d)
SE S_D
_D
_D
_D
e
_
rv
NS
NS
NS
NS
NS
se
N
SE
SE
SE
SE
SE
SE
(re
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 Reset
SENS_DAC_SCALE1 DAC1 scaling. 00: no scale. 01: scale to 1/2. 10: scale to 1/4. 11: scale to
1/8. (R/W)
SENS_DAC_SCALE2 DAC2 scaling. 00: no scale. 01: scale to 1/2. 10: scale to 1/4. 11: scale to
1/8. (R/W)
SENS_DAC_INV1 Invert DAC1. 00: do not invert any bits. 01: invert all bits. 10: invert MSB. 11:
invert all bits except MSB. (R/W)
SENS_DAC_INV2 Invert DAC2. 00: do not invert any bits. 01: invert all bits. 10: invert MSB. 11:
invert all bits except MSB. (R/W)
)
ed
SE S_I
rv
se
N
SE
(re
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
_C AR
AR
_ P LE
LE
E
ED
CL
TT _C
EN
EN
RC
1_ TT L
E
EL AT
CY
AR PA SE
PA _P
IV
DE
_L
_L
RC
O
DC R_S K_G
_D
_F
_S R2_ R_
B_
TT
TT
O
AR
LK
_M
PA
PA
DC SA SA
AR
_F
SA CL
_C
_S
2_
1_
_S R T
RT
RK
RA _ A_
T_
C_ R_
AR
AR
AR
PD
DC STA
TA
AI
O
SA D DA
B_ AD SA
W
_W
_S
_S
_S
_X
_
B_ RA C_
AP AR C_
RA C_
DC
DC
DC
DC
DC
AP SA D
S D
SA D
RA
RA
B_ RA
RA
RA
RA
B_ RA
B_ RA
(re AR
d)
B )
B d)
d
SA
SA
AP _SA
SA
SA
SA
AP _SA
AP _SA
ve
AP ve
AP ve
S
er
r
B_
B_
B_
B_
B_
se
se
B
s
AP
AP
AP
AP
AP
AP
(re
(re
31 30 29 28 27 26 25 24 23 22 19 18 15 14 7 6 5 4 3 2 1 0
1 0 0 0 0 0 0 15 15 4 1 0 0 0 0 0 Reset
APB_SARADC_START_FORCE 0: select FSM to start SAR ADC. 1: select software to start SAR
ADC. (R/W)
APB_SARADC_SAR_SEL 0: select SAR ADC1. 1: select SAR ADC2, only work for single-channel
scan mode. (R/W)
APB_SARADC_SAR1_PATT_P_CLEAR Clear the pointer of pattern table for DIG ADC1 CTRL. (R/W)
APB_SARADC_SAR2_PATT_P_CLEAR Clear the pointer of pattern table for DIG ADC2 CTRL. (R/W)
APB_SARADC_DATA_SAR_SEL 1: sar_sel will be coded to the MSB of the 16-bit output data, in
this case the resolution should not be larger than 11 bits. (R/W)
IT
M
IM
NU
ET
_L
G
S_
M
AR
N
EA
NU
1_ V
V
_E
_T
AR IN
IN
_M
S_
_S R2_
ER
ER
EA
AX
M
IM
DC SA
_M
_M
TI
_T
_
RA C_
DC
DC
DC
DC
SA D
RA
RA
B_ RA
RA
RA
d)
B d)
SA
SA
AP _SA
SA
SA
ve
AP rve
er
B_
B_
B_
B_
se
s
AP
AP
AP
AP
(re
(re
31 25 24 23 12 11 10 9 8 1 0
0 0 0 0 0 0 0 0 10 0 0 0 255 0 Reset
UM
_N
_B
_A
IV
IV
IV
EL
_D
_D
_D
_S
KM
LK
LK
LK
L
_C
_C
_C
_C
DC
DC
DC
DC
RA
RA
RA
RA
)
)
ed
ed
SA
SA
SA
SA
rv
rv
B_
B_
B_
B_
se
se
AP
AP
AP
AP
(re
(re
31 23 22 21 20 19 14 13 8 7 0
APB_SARADC_CLK_SEL 1: select APLL. 2: select APB_CLK. Other values: disable clock. (R/W)
1
AB
_T
T
AT
1_P
AR
_S
DC
RA
SA
B_
AP
31 0
0xf0f0f0f Reset
APB_SARADC_SAR1_PATT_TAB1 Item 0 ~ 3 for pattern table 1 (each item one byte). (R/W)
2
AB
_T
TT
PA
1_
AR
_S
DC
RA
SA
B_
AP
31 0
0xf0f0f0f Reset
APB_SARADC_SAR1_PATT_TAB2 Item 4 ~ 7 for pattern table 1 (each item one byte). (R/W)
31 0
0xf0f0f0f Reset
APB_SARADC_SAR1_PATT_TAB3 Item 8 ~ 11 for pattern table 1 (each item one byte). (R/W)
4
AB
_T
T
AT
1_P
AR
_S
DC
RA
SA
B_
AP
31 0
0xf0f0f0f Reset
APB_SARADC_SAR1_PATT_TAB4 Item 12 ~ 15 for pattern table 1 (each item one byte). (R/W)
1
AB
_T
TT
PA
2_
AR
_S
DC
RA
SA
B_
AP
31 0
0xf0f0f0f Reset
APB_SARADC_SAR2_PATT_TAB1 Item 0 ~ 3 for pattern table 2 (each item one byte). (R/W)
31 0
0xf0f0f0f Reset
APB_SARADC_SAR2_PATT_TAB2 Item 4 ~ 7 for pattern table 2 (each item one byte). (R/W)
3
AB
_T
T
AT
2_P
AR
_S
DC
RA
SA
B_
AP
31 0
0xf0f0f0f Reset
APB_SARADC_SAR2_PATT_TAB3 Item 8 ~ 11 for pattern table 2 (each item one byte). (R/W)
4
AB
_T
TT
PA
2_
AR
_S
DC
RA
SA
B_
AP
31 0
0xf0f0f0f Reset
APB_SARADC_SAR2_PATT_TAB4 Item 12 ~ 15 for pattern table 2 (each item one byte). (R/W)
_A _F CE E
TY
TY
TY
RB TC OR RC
_P TY
O E
E
RI
RI
RI
_F C
_A B_R I_F FO
RC
RI
IO
IO
IO
PB OR
_W RIO
D C R IF T _
R
R
R
_A C_A B_W AN
P
C_
B_
FI
_A FIX_
DC AD AR GR
AP
RT
I
_
B_
B_
RA _ _ _
_A ARB
RB
B
R
SA D D R
_A
A
DC C_
C_
B_ RA C_ C_
DC
DC
C
RA AD
B_ RA AD
AP SA D AD
_A
A
_
AP SA C_
B_ RA _
DC
DC
C
B_ AD
AP SA D
RA
RA
R
)
)
ed
ed
SA
SA
SA
SA
rv
rv
B_
B_
B_
B_
se
se
AP
AP
AP
AP
AP
(re
(re
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 2 1 0 0 0 0 0 0 0 Reset
R
TO
TO
_R ET
ET
ER ES
ES
AC
AC
ER N
N
LT R
LT E
_E
_F
_F
FI R_
FI R _
ER
ER
2_ LTE
2_ LTE
LT
LT
DC FI
FI
FI
DC FI
_A C1_
1_
2_
_A C1_
DC
DC
DC AD
DC AD
_A
_A
RA C_
RA C_
DC
DC
SA D
SA D
B_ RA
RA
RA
B_ RA
)
ed
AP _SA
SA
SA
AP _SA
rv
B_
B_
se
B
B
AP
AP
AP
AP
(re
31 30 29 23 22 16 15 2 1 0
0 0 64 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
A
AT
AT
_D
_D
ER
ER
LT
LT
FI
FI
1_
2_
DC
DC
_A
_A
DC
DC
RA
RA
SA
SA
B_
B_
AP
AP
31 16 15 0
0 0 Reset
_M DE
DE
ES O
O
RE _EN
EN
HR _M
S_
TH S
ES
_T ES
2_ RE
RE
HR
C2 HR
DC TH
TH
N
_T
AD _T
_A C1_
2_
_E
1
B_ d) C_ C1
DC
DC
LK
DC AD
AP rve AD AD
_C
_A
_A
RA C_
se R C_
DC
DC
DC
SA D
(re _SA AD
B_ RA
RA
RA
RA
B R
AP _SA
SA
SA
AP _SA
SA
B_
B_
B
B
AP
AP
AP
AP
31 30 29 17 16 4 3 2 1 0
0 0 0 0 0 0 0 0 Reset
T_ A
A
2_ RE INT NA
RE _IN NA
IN N
EN
S_ T_E
DC TH E_ _E
TH S _E
_A C1_ ON INT
DC AD _D E_
RA C_ C2 ON
SA D AD _D
B_ RA C_ C1
AP _SA AD AD
B R C_
AP SA D
B_ RA
d)
AP _SA
ve
er
B
s
AP
(re
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
d)
AP SA
e
rv
B_
se
AP
(re
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
IN T
ST
2_ RE INT T
RE _IN T
S_ T_S
DC TH E_ _S
TH S _S
T_
_A C1_ ON INT
DC AD _D E_
RA C_ C2 ON
SA D AD _D
B_ RA C_ C1
AP _SA AD AD
B R C_
AP SA D
B_ RA
d)
AP _SA
ve
er
B
s
AP
(re
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
)d
AP SA
ve
er
B_
s
AP
(re
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
SM
M
_F
NU
_R NS
ET
F_
ES
DC RA
EO
_A _T
C_
PB DC
D
_A B_A
_A
PB
DC AP
_A
RA C_
DC
SA D
B_ RA
RA
d)
AP _SA
SA
ve
er
B_
B
s
AP
AP
(re
31 30 29 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 Reset
APB_SARADC_APB_ADC_TRANS Set this bit, DIG ADC CTRL uses SPI DMA. (R/W)
DE
N O
ET
_E _M
G
_T _A NS
_D B_D C_T IFO
ER ER
AR
RA C_ B_ SE T
AC AC RA
DC AP DA T_F
IM LT
_T
SA D AP RE RS
ER
B_ RA C_ C_ C_
M
AP _SA AD DA DA
TI
C_
B R C_ B_
A
AP SA D AP
_D
B_ RA C_
DC
AP _SA AD
RA
B R
)
ed
AP _SA
SA
rv
B_
se
B
AP
AP
(re
31 17 16 15 14 13 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 100 Reset
TE
DA
L_
TR
_C
PB
_A
DC
RA
SA
B_
AP
31 0
0x1907162 Reset
Developer Zone
• ESP-IDF Programming Guide for ESP32-S2 – Extensive documentation for the ESP-IDF development framework.
• ESP-IDF and other development frameworks on GitHub.
https://github.com/espressif
• ESP32 BBS Forum – Engineer-to-Engineer (E2E) Community for Espressif products where you can post questions,
share knowledge, explore ideas, and help solve problems with fellow engineers.
https://esp32.com/
• The ESP Journal – Best Practices, Articles, and Notes from Espressif folks.
https://blog.espressif.com/
• See the tabs SDKs and Demos, Apps, Tools, AT Firmware.
https://espressif.com/en/support/download/sdks-demos
Products
• ESP32-S2 Series SoCs – Browse through all ESP32-S2 SoCs.
https://espressif.com/en/products/socs?id=ESP32-S2
• ESP32-S2 Series Modules – Browse through all ESP32-S2-based modules.
https://espressif.com/en/products/modules?id=ESP32-S2
• ESP32-S2 Series DevKits – Browse through all ESP32-S2-based devkits.
https://espressif.com/en/products/devkits?id=ESP32-S2
• ESP Product Selector – Find an Espressif hardware product suitable for your needs by comparing or applying filters.
https://products.espressif.com/#/product-selector?language=en
Contact Us
• See the tabs Sales Questions, Technical Enquiries, Circuit Schematic & PCB Design Review, Get Samples
(Online stores), Become Our Supplier, Comments & Suggestions.
https://espressif.com/en/contact-us/sales-questions
Glossary
Revision History
Added Glossary
Optimized chapter order
Updated the following chapters:
• Updated the description of EFUSE_DIS_RTC_RAM_BOOT in Chapter 4
eFuse Controller (eFuse)
2021-06-11 v1.0 • Fixed two typos in Chapter 9 Low-Power Management (RTC_CNTL)
• Fixed a typo in register naming in Section 14.3.2.2 External Memory
Permission Controls
• Fixed a typo in the description LEDC_TIMERx_CONF_REG (x: 0-3) in
Chapter 23 UART Controller (UART);
• Updated the base address of USB OTG in Section 28.5 Base Address