Esp32-H2 Technical Reference Manual en
Esp32-H2 Technical Reference Manual en
A RY
IN
IM
EL
PR
Pre-release v0.4
Espressif Systems
Copyright © 2023
www.espressif.com
About This Document
The ESP32H2 Technical Reference Manual is targeted at developers working on low level software projects
that use the ESP32-H2 SoC. It describes the hardware modules listed below for the ESP32-H2 SoC and other
products in ESP32-H2 series. The modules detailed in this document provide an overview, list of features,
hardware architecture details, any necessary programming procedures, as well as register descriptions.
• Release Status at a Glance on the very next page is a minimal list of all chapters from where you can
directly jump to a specific chapter.
• Use the Bookmarks on the side bar to jump to any specific chapters or sections from anywhere in the
document. Note this PDF document is configured to automatically display Bookmarks when open, which
is necessary for an extensive document like this one. However, some PDF viewers or browsers ignore this
setting, so if you don’t see the Bookmarks by default, try one or more of the following methods:
– Download this document, and view it with your local PDF viewer;
– Set your PDF viewer to always automatically display the Bookmarks on the left side bar when open.
• Use the native Navigation function of your PDF viewer to navigate through the documents. Most PDF
viewers support to go Up, Down, Previous, Next, Back, Forward and Page with buttons, menu, or hot
keys.
• You can also use the built-in GoBack button on the upper right corner on each and every page to go back
to the previous place before you click a link within the document. Note this feature may only work with
some Acrobat-specific PDF viewers (for example, Acrobat Reader and Adobe DC) and browsers with
built-in Acrobat-specific PDF viewers or extensions (for example, Firefox).
Release Status at a Glance
Note that this manual in still work in progress. See our release progress below:
PRELIMINARY
GoBack
Note:
Check the link or the QR code to make sure that you use the latest version of this document:
https://www.espressif.com/documentation/esp32-h2_technical_reference_manual_en.pdf
PRELIMINARY
Espressif Systems 4 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
Contents
1 ESPRISCV CPU 34
1.1 Overview 34
1.2 Features 34
1.3 Terminology 35
1.4 Address Map 35
1.5 Configuration and Status Registers (CSRs) 35
1.5.1 Register Summary 35
1.5.2 Register Description 37
1.6 Interrupt Controller 50
1.6.1 Features 50
1.6.2 Functional Description 50
1.6.3 Suggested Operation 52
1.6.3.1 Latency Aspects 52
1.6.3.2 Configuration Procedure 53
1.6.4 Registers 54
1.7 Core Local Interrupts (CLINT) 55
1.7.1 Overview 55
1.7.2 Features 55
1.7.3 Software Interrupt 55
1.7.4 Timer Counter and Interrupt 55
1.7.5 Register Summary 56
1.7.6 Register Description 56
1.8 Physical Memory Protection 60
1.8.1 Overview 60
1.8.2 Features 60
1.8.3 Functional Description 60
1.8.4 Register Summary 61
1.8.5 Register Description 61
1.9 Physical Memory Attribute Checker (PMAC) 62
1.9.1 Overview 62
1.9.2 Features 62
1.9.3 Functional Description 62
1.9.4 Register Summary 63
1.9.5 Register Description 64
1.10 Debug 65
1.10.1 Overview 65
1.10.2 Features 66
1.10.3 Functional Description 66
1.10.4 JTAG Control 66
1.10.5 Register Summary 67
1.10.6 Register Description 67
1.11 Hardware Trigger 70
PRELIMINARY
Espressif Systems 5 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
1.11.1 Features 70
1.11.2 Functional Description 70
1.11.3 Trigger Execution Flow 71
1.11.4 Register Summary 71
1.11.5 Register Description 72
1.12 Trace 76
1.12.1 Overview 76
1.12.2 Features 76
1.12.3 Functional Description 76
1.13 Dedicated IO 77
1.13.1 Overview 77
1.13.2 Features 77
1.13.3 Functional Description 77
1.13.4 Register Summary 78
1.13.5 Register Description 78
1.14 Atomic (A) Extension 80
1.14.1 Overview 80
1.14.2 Functional Description 80
1.14.2.1 Load Reserve (LR.W) Instruction 80
1.14.2.2 Store Conditional (SC.W) Instruction 80
1.14.2.3 AMO Instructions 81
PRELIMINARY
Espressif Systems 6 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 7 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 8 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 9 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 10 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 11 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 12 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 13 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 14 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 15 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 16 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 17 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 19 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 20 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 21 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 22 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 23 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
Glossary 1153
PRELIMINARY
Espressif Systems 24 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Contents GoBack
PRELIMINARY
Espressif Systems 25 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
List of Tables GoBack
List of Tables
1-2 CPU Address Map 35
1-4 Core Local Interrupt (CLINT) Sources 55
1-10 NAPOT encoding for maddress 71
2-2 Trace Encoder Parameters 84
2-3 Header Format 86
2-4 Index Format 86
2-5 Packet format 3 subformat 0 87
2-6 Packet format 3 subformat 1 87
2-7 Packet format 3 subformat 3 88
2-8 Packet format 2 88
2-9 Packet format 1 with address 89
2-10 Packet format 1 without address 90
3-1 Selecting Peripherals via Register Configuration 101
3-2 Descriptor Field Alignment Requirements 103
4-1 Memory Address Mapping 138
4-2 Module/Peripheral Address Mapping 141
5-1 Parameters in eFuse BLOCK0 146
5-2 Secure Key Purpose Values 149
5-3 Parameters in BLOCK1 to BLOCK10 150
5-4 Registers Information 155
5-5 Configuration of Default VDDQ Timing Parameters 156
6-1 Bit Used to Control IO MUX Functions in Light-sleep Mode 219
6-2 Peripheral Signals via GPIO Matrix 222
6-3 IO MUX Functions List 227
6-4 Analog Functions of IO MUX Pins 228
7-1 Reset Source 264
7-2 CPU_CLK Clock Source 266
7-3 Frequency of CPU_CLK, AHB_CLK and HP_ROOT_CLK 266
7-4 Derived HP Clock Source 268
7-5 HP Clocks Used by Each Peripheral 268
7-6 Derived LP Clock Source 269
7-7 LP Clocks Used by Each Peripheral 269
8-1 Default Configuration of Strapping Pins 336
8-2 Boot Mode Control 336
8-3 ROM Message Printing Control 338
8-4 JTAG Signal Source Control 339
9-1 CPU Peripheral Interrupt Source Mapping/Status Registers and Peripheral Interrupt Sources 343
10-1 Selectable Events for ETM Channeln 360
10-2 Mappable Tasks for ETM Channeln 363
11-1 UNITn Configuration Bits 378
11-2 Trigger Point 379
11-3 Synchronization Operation for Configuration Registers 380
12-1 Alarm Generation When Up-Down Counter Increments 402
PRELIMINARY
Espressif Systems 26 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
List of Tables GoBack
PRELIMINARY
Espressif Systems 27 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
List of Tables GoBack
PRELIMINARY
Espressif Systems 28 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
List of Tables GoBack
PRELIMINARY
Espressif Systems 29 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
List of Figures GoBack
List of Figures
1-1 CPU Block Diagram 34
1-2 Debug System Overview 65
2-1 Trace Encoder Overview 82
2-2 Trace Overview 83
2-3 Trace packet Format 86
3-1 Modules with GDMA Feature and GDMA Channels 98
3-2 GDMA controller Architecture 99
3-3 Structure of a Linked List 100
3-4 Relationship among Linked Lists 102
4-1 System Structure and Address Mapping 137
4-2 Cache Structure 139
4-3 Modules/peripherals that can work with GDMA 141
5-1 Data Flow in eFuse 144
5-2 Shift Register Circuit (first 32 output) 152
5-3 Shift Register Circuit (last 12 output) 152
6-1 Architecture of IO MUX and GPIO Matrix 211
6-2 Internal Structure of a Pad 212
6-3 GPIO Input Synchronized on Rising Edge or on Falling Edge of IO MUX Operating Clock 213
6-4 GPIO Filter Timing of GPIO Input Signals 214
6-5 Glitch Filter Timing Example 214
6-6 Example of level flip on the chip pad when the hysteresis function is not enabled 220
6-7 Example of level flip on the chip pad when the hysteresis function is enabled 221
7-1 Reset Types 262
7-2 System Clock 265
7-3 Clock Configuration Example 271
8-1 Chip Boot Flow 337
9-1 Interrupt Flow in ESP32-H2 341
9-2 Interrupt Matrix Structure 341
10-1 Event Task Matrix Architecture 359
10-2 ETM Channeln Architecture 360
10-3 Event Task Matrix Clock Architecture 367
11-1 System Timer Structure 376
11-2 System Timer Alarm Generation 377
12-1 Timer Group Overview 400
12-2 Timer Group Architecture 401
13-1 Watchdog Timers Overview 424
13-2 Digital Watchdog Timers in ESP32-H2 426
13-3 Super Watchdog Controller Structure 429
14-1 PMP-APM Management Relation 440
14-2 APM Controller Architecture 443
19-1 HMAC SHA-256 Padding Diagram 538
19-2 HMAC Structure Schematic Diagram 538
22-1 Software Preparations and Hardware Working Process 571
PRELIMINARY
Espressif Systems 30 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
List of Figures GoBack
PRELIMINARY
Espressif Systems 31 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
List of Figures GoBack
PRELIMINARY
Espressif Systems 32 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
List of Figures GoBack
33-17 Count-Up, Single Edge Asymmetric Waveform, with Independent Modulation on PWMxA and
PWMxB — Active High 975
33-18 Count-Up, Pulse Placement Asymmetric Waveform with Independent Modulation on PWMxA 976
33-19 Count-Up-Down, Dual Edge Symmetric Waveform, with Independent Modulation on PWMxA and
PWMxB — Active High 977
33-20 Count-Up-Down, Dual Edge Symmetric Waveform, with Independent Modulation on PWMxA and
PWMxB — Complementary 978
33-21 Count-Up-Down, Fault or Synchronization Events, with Same Modulation on PWMxA and PWMxB 979
33-22 Example of an NCI Software-Force Event on PWMxA 980
33-23 Example of a CNTU Software-Force Event on PWMxB 981
33-24 Options for Setting up the Dead Time Generator Module 983
33-25 Active High Complementary (AHC) Dead Time Waveforms 984
33-26 Active Low Complementary (ALC) Dead Time Waveforms 985
33-27 Active High (AH) Dead Time Waveforms 985
33-28 Active Low (AL) Dead Time Waveforms 986
33-29 Example of Waveforms Showing PWM Carrier Action 986
33-30 Example of the First Pulse and the Subsequent Sustaining Pulses of the PWM Carrier Submodule 987
33-31 Possible Duty Cycle Settings for Sustaining Pulses in the PWM Carrier Submodule 988
34-1 RMT Architecture 1073
34-2 Format of Pulse Code in RAM 1074
35-1 PARLIO Architecture 1098
35-2 PARLIO Clock Generation 1099
35-3 Positive Waveform 1101
35-4 Negative Waveform 1101
35-5 Sub-Modes of Level Enable Mode for RX Unit 1102
35-6 Sub-Modes of Pulse Enable Mode for RX Unit 1103
35-7 Sub-Mode of Software Enable Mode for RX Unit 1103
36-1 SAR ADC Architecture 1122
36-2 SAR ADC Clock Structure 1123
36-3 DIG ADC FSM Block Diagram 1125
36-4 APB_SARADC_SAR_PATT_TAB1_REG Contains Patterns 0 - 3 1126
36-5 APB_SARADC_SAR_PATT_TAB2_REG Contains Patterns 4 - 7 1126
36-6 Pattern Structure 1126
36-7 cmd0 configuration 1127
36-8 cmd1 Configuration 1127
36-9 DMA Data Format 1128
36-10 Temperature Sensor Architecture 1130
PRELIMINARY
Espressif Systems 33 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
1 ESPRISCV CPU
1.1 Overview
ESP-RISC-V CPU is a 32-bit core based upon RISC-V instruction set architecture (ISA) comprising base integer
(I), multiplication/division (M), atomic (A) and compressed (C) standard extensions. The core has 4-stage,
in-order, scalar pipeline optimized for area, power and performance. CPU core complex has a debug module
(DM), interrupt-controller (INTC), core local interrupts (CLINT) and system bus (SYS BUS) interfaces for memory
and peripheral access.
ESP-RISC-V CPU
INTC IRQ
RV32IMAC
CORE
DM JTAG
IBUS DBUS
SBA
SYS BUS
1.2 Features
• RISC-V RV32IMAC ISA with four-stage pipeline that supports an operating clock frequency up to 96 MHz
• Compatible with RISC-V ISA Manual Volume I: Unprivileged ISA Version 2.2 and RISC-V ISA Manual,
Volume II: Privileged Architecture, Version 1.10
• Zero wait cycle access to on-chip SRAM and Cache for program and data access over IRAM/DRAM
interface
• Interrupt controller with up to 28 external vectored interrupts for both M and U modes with 16
programmable priority and threshold levels
PRELIMINARY
Espressif Systems 34 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
• Debug module (DM) compliant with the specification RISC-V External Debug Support Version 0.13 with
external debugger support over an industry-standard JTAG/USB port
• Debugger with a direct system bus access (SBA) to memory and peripherals
• Hardware trigger compliant to the specification RISC-V External Debug Support Version 0.13 with up to 4
breakpoints/watchpoints
• Physical memory protection (PMP) and attributes (PMA) for up to 16 configurable regions
1.3 Terminology
*default: Address not matching any of the specified ranges (IRAM, DRAM, CPU) are accessed using AHB
bus.
PRELIMINARY
Espressif Systems 35 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
1 Although misa is specified as having both read and write access (R/W), its fields are hardwired and thus write has no effect. This is what
would be termed WARL (Write Any Read Legal) in RISC-V terminology
2 mtvec only provides configuration for trap handling in vectored mode with the base address aligned to 256 bytes
3 External interrupt IDs reflected in mcause include even those IDs which have been reserved by RISC-V standard for core internal sources.
PRELIMINARY
Espressif Systems 36 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
Note that if write/set/clear operation is attempted on any of the CSRs which are read-only (RO), as indicated in
the above table, the CPU will generate illegal instruction exception.
31 0
0x00000612 Reset
4 These custom CSRs have been implemented in the address space reserved by RISC-V standard for custom use
PRELIMINARY
Espressif Systems 37 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
ID
CH
AR
M
31 0
0x80000002 Reset
D
PI
IM
M
31 0
0x00000002 Reset
31 0
0x00000000 Reset
PRELIMINARY
Espressif Systems 38 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
d)
d)
ed
ed
ed
ve
e
rv
rv
rv
rv
r
E
se
se
se
se
se
IE
PP
PI
IE
E
TW
UP
(re
(re
(re
(re
(re
UI
M
M
31 22 21 20 13 12 11 10 8 7 6 5 4 3 2 1 0
UPIE Write 1 to enable the user previous interrupt (before trap). (R/W)
MPIE Write 1 to enable the machine previous interrupt (before trap). (R/W)
TW Configures whether to cause illegal instruction exception when WFI (Wait-for-Interrupt) instruction
is executed in U mode.
0: Executing WFI instruction will not cause illegal exception in U mode
1: Executing WFI instruction in U mode will cause illegal instruction exception
(R/W)
PRELIMINARY
Espressif Systems 39 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
d)
ve
r
se
XL
(re
W
M
M
Q
C
N
H
U
D
R
B
K
S
A
Y
E
Z
F
J
I
31 30 29 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
Z Reserved = 0. (RO)
Y Reserved = 0. (RO)
W Reserved = 0. (RO)
V Reserved = 0. (RO)
T Reserved = 0. (RO)
R Reserved = 0. (RO)
P Reserved = 0. (RO)
O Reserved = 0. (RO)
L Reserved = 0. (RO)
K Reserved = 0. (RO)
J Reserved = 0. (RO)
B Reserved = 0. (RO)
G
LE
E
ID
M
31 0
0x00000111 Reset
MIDELEG Configures the U mode delegation state for each interrupt ID. Below interrupts are dele-
gated to U mode by default:
Bit 0: User software interrupt (CLINT)
Bit 4: User timer interrupt (CLINT)
Bit 8: User external interrupt
The default delegation can be modified at run-time if required.
(R/W)
5]
US :1]
31
6:
2
E[
E[
E[
E
E
IE
IE
XI
XI
XI
SI
TI
UT
M
M
M
M
31 8 7 6 5 4 3 2 1 0
DE
SE
se
O
BA
(re
31 8 7 2 1 0
MODE Represents whether machine mode interrupts are vectored. Only vectored mode 0x1 is avail-
able. (RO)
BASE Configures the higher 24 bits of trap vector base address aligned to 256 bytes. (R/W)
PRELIMINARY
Espressif Systems 41 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
H
TC
RA
SC
M
31 0
0x00000000 Reset
C
EP
M
31 0
0x00000000 Reset
MEPC Configures the machine trap/exception program counter. This is automatically updated with
address of the instruction which was about to be executed while CPU encountered the most recent
trap. (R/W)
PRELIMINARY
Espressif Systems 42 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
de
Co
F lag
n
)
ed
io
pt
pt
rv
rru
ce
se
te
Ex
(re
In
31 30 5 4 0
Exception Code This field is automatically updated with unique ID of the most recent exception or
interrupt due to which CPU entered trap. Possible exception IDs are:
0x1: PMP instruction access fault
0x2: Illegal instruction
0x3: Hardware breakpoint/watchpoint or EBREAK
0x5: PMP load access fault
0x6: Misaligned store address or AMO address
0x7: PMP store access or AMO access fault
0x8: ECALL from U mode
0xb: ECALL from M mode
Other values: reserved
Note: Exception ID 0x0 (instruction access misaligned) is not present because CPU always masks
the lowest bit of the address during instruction fetch.
(R/W)
Interrupt Flag This flag is automatically updated when CPU enters trap.
If this is found to be set, indicates that the latest trap occurred due to an interrupt. For exceptions
it remains unset.
Note: The interrupt controller is using up IDs in range 1-2, 5-6 and 8-31 for all external interrupt
sources. This is different from the RISC-V standard which has reserved IDs in range 0-15 for core
local interrupts only. Although local interrupt sources (CLINT) do use the reserved IDs 0, 3, 4 and
7.
(R/W)
PRELIMINARY
Espressif Systems 43 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
AL
TV
M
31 0
0x00000000 Reset
MTVAL Configures machine trap value. This is automatically updated with an exception dependent
data which may be useful for handling that exception.
Data is to be interpreted depending upon exception IDs:
0x1: Faulting virtual address of instruction
0x2: Faulting instruction opcode
0x5: Faulting data address of load operation
0x7: Faulting data address of store operation
Note: The value of this register is not valid for other exception IDs and interrupts.
(R/W)
PRELIMINARY
Espressif Systems 44 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
]
:8
UT :5]
US :1]
31
2
P[
P[
P[
P
P
IP
IP
XI
XI
XI
SI
TI
M
M
M
M
31 8 7 6 5 4 3 2 1 0
d)
d
ve
e
rv
r
se
se
IE
E
UP
(re
(re
UI
31 5 4 3 1 0
UPIE Write 1 to enable the user previous interrupt (before trap). (R/W)
PRELIMINARY
Espressif Systems 45 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
]
:8
UX d)
UX d)
UT 5]
US 1]
31
e
:
:
[6
[2
rv
rv
[
IE
IE
IE
se
se
IE
IE
UX
(re
(re
31 8 7 6 5 4 3 2 1 0
)
ed
rv
DE
SE
se
O
BA
(re
M
31 8 7 2 1 0
MODE Represents if user mode interrupts are vectored. Only vectored mode 0x1 is available. (RO)
BASE Configures the higher 24 bits of trap vector base address aligned to 256 bytes. (R/W)
31 0
0x00000000 Reset
31 0
0x00000000 Reset
UEPC Configures the user trap program counter. This is automatically updated with address of the
instruction which was about to be executed in User mode while CPU encountered the most recent
user mode interrupt. (R/W)
PRELIMINARY
Espressif Systems 46 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
de
Co
F lag
n
)
ed
io
pt
pt
rv
rru
ce
se
te
Ex
(re
In
31 30 5 4 0
Interrupt ID This field is automatically updated with the unique ID of the most recent user mode in-
terrupt due to which CPU entered trap. (R/W)
Interrupt Flag This flag would always be set because CPU can only enter trap due to user mode
interrupts as exception delegation is unsupported. (R/W)
UX d)
4]
US 1]
ed
31
e
5:
:
[2
rv
rv
[
[
IP
IP
IP
se
se
IP
IP
UX
UX
UT
(re
(re
31 8 7 6 5 4 3 2 1 0
UXIP Configures the pending status of the 28 external interrupts delegated to user mode.
0: Not pending
1: Pending
(R/W)
PRELIMINARY
Espressif Systems 47 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
N
P H KE
ST A D
JM C TA
LO RE ON
IN AZ AR
RD
BR NC P
M
AN H_
O NC
_H AZ
)
RA O
ed
(B _C
LD _H
ST _U
E
rv
ID D
CL
se
ST
P
LE
A
JM
CY
(re
IN
31 11 10 9 8 7 6 5 4 3 2 1 0
0x000 0 0 0 0 0 0 0 0 0 0 0 Reset
CYCLE Count Clock Cycles. Cycle count does not increment during WFI mode.
Note: Each bit selects a specific event for counter to increment. If more than one event is selected
and occurs simultaneously, then counter increments by one only.
(R/W)
CO NT
rv
U
se
CO
(re
31 2 1 0
0 1 1 Reset
PRELIMINARY
Espressif Systems 48 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
CR
PC
M
31 0
0x00000000 Reset
PRELIMINARY
Espressif Systems 49 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
• Up to 28 external asynchronous interrupts and 4 core local interrupt sources (CLINT) with unique IDs (0-31)
For the complete list of interrupt registers and detailed configuration information, please refer to Chapter 9
Interrupt Matrix (INTMTX) > Section 9.6.2.
1. Mode (M/U):
• If the bit is cleared for an interrupt in mideleg CSR, then that interrupt will be captured in M mode.
• If the bit is set for an interrupt in mideleg CSR, then it will be delegated to U mode.
• Local CLINT interrupts have the corresponding bits reserved in the memory mapped registers thus
they are always enabled at the INTC level.
• An M mode interrupt (external or local) further needs to be unmasked at core level by setting the
corresponding bit in mie CSR.
• A U mode interrupt (external or local) further needs to be unmasked at core level by setting the
corresponding bits in uie CSR.
3. Type (0-1):
PRELIMINARY
Espressif Systems 50 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
• Local CLINT interrupts are always ’level’ type and thus have the corresponding bits reserved in the
above register.
4. Priority (0-15):
• Determines which interrupt, among multiple pending interrupts, the CPU will service first.
• Enabled external interrupts with priorities less than the threshold value in
INTPRI_CORE0_CPU_INT_THRESH_REG are masked.
• Interrupts with the same priority are statically prioritized by their IDs, lowest ID having the highest
priority.
• Local CLINT interrupts have static priorities associated with them, and thus have the corresponding
priority registers to be reserved.
• Local CLINT interrupts cannot be masked using the threshold values for either mode.
• Reflects the captured state of an enabled and unmasked external interrupt signal.
• For each interrupt ID (local or external), the corresponding bit in the mip CSR for M mode interrupts or
uip CSR for U mode interrupts, also gives its pending state.
• A pending interrupt will cause CPU to enter trap if no other pending interrupt has higher priority.
• A pending interrupt is said to be ’claimed’ if it preempts the CPU and causes it to jump to the
corresponding trap vector address.
• All pending interrupts which are yet to be serviced are termed as ’unclaimed’.
• Toggling this will clear the pending state of claimed edge-type interrupts only.
• Pending state of a level type interrupt is unaffected by this and must be cleared from source.
• Pending state of an unclaimed edge type interrupt can be flushed, if required, by first clearing the
corresponding bit in INTPRI_CORE0_CPU_INT_ENABLE_REG and then toggling same bit in
INTPRI_CORE0_CPU_INT_CLEAR_REG.
For a detailed description of the core local interrupt sources, please refer to Section 1.7.
PRELIMINARY
Espressif Systems 51 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
• saves the address of the current un-executed instruction in mepc/uepc for resuming execution later.
• updates the value of mcause/ucause with the ID of the interrupt being serviced.
• copies the state of MIE/UIE into MPIE/UPIE, and subsequently clears MIE/UIE, thereby disabling interrupts
globally.
The word aligned trap address for an M mode interrupt with a certain ID = i can be calculated as (mtvec + 4i).
Similarly, the word aligned trap address for a U mode interrupt can be calculated as (utvec + 4i).
After jumping to the trap vector for the corresponding mode, the execution flow is dependent on software
implementation, although it can be presumed that the interrupt will get handled (and cleared) in some interrupt
service routine (ISR) and later the normal execution will resume once the CPU encounters MRET/URET
instruction for that mode.
• copies the state of MPIE/UPIE back into MIE/UIE, and subsequently clears MPIE/UPIE. This means that if
previously MPIE/UPIE was set, then, after MRET/URET, MIE/UIE will be set, thereby enabling interrupts
globally.
It is possible to perform software assisted nesting of interrupts inside an ISR as explained in Section 1.6.3.
The below listed points outline the functional behavior of the controller:
• Only if an interrupt has priority higher or equal to the value in the threshold register, will it be reflected in
INTPRI_CORE0_CPU_INT_EIP_STATUS_REG.
In steady state operation, the Interrupt Controller has a fixed latency of 4 cycles. Steady state means that no
changes have been made to the Interrupt Controller registers recently. This implies that any interrupt that is
asserted to the controller will take exactly 4 cycles before the CPU starts processing the interrupt. This further
implies that CPU may execute up to 5 instructions before the preemption happens.
Whenever any of its registers are modified, the Interrupt Controller enters into transient state, which may take up
to 4 cycles for it to settle down into steady state again. During this transient state, the ordering of interrupts may
not be predictable, and therefore, a few safety measures need to be taken in software to avoid any
synchronization issues.
PRELIMINARY
Espressif Systems 52 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
Also, it must be noted that the Interrupt Controller configuration registers lie in the APB address range, hence any
R/W access to these registers may take multiple cycles to complete.
In consideration of above mentioned characteristics, users are advised to follow the sequence described below,
whenever modifying any of the Interrupt Controller registers:
3. execute FENCE instruction to wait for any pending write operations to complete
Due to its critical nature, it is recommended to disable interrupts globally (MIE=0) beforehand, whenever
configuring interrupt controller registers, and then restore MIE right after, as shown in the sequence above.
After execution of the sequence above, the Interrupt Controller will resume operation in steady state.
By default, interrupts are disabled globally, since the reset value of MIE bit in mstatus is 0. Software must set
MIE=1 after initialization of the interrupt stack (including setting mtvec to the interrupt vector address) is
done.
During normal execution, if an external interrupt n is to be enabled, the below sequence may be followed:
2. depending upon the type of the interrupt (edge/level), set/unset the nth bit of
INTPRI_CORE0_CPU_INT_TYPE_REG
When one or more interrupts become pending, the CPU acknowledges (claims) the interrupt with the highest
priority and jumps to the trap vector address corresponding to the interrupt’s ID. Software implementation may
read mcause to infer the type of trap (mcause (31) is 1 for interrupts and 0 for exceptions) and then the ID of the
interrupt (mcause (4-0) gives ID of interrupt or exception). This inference may not be necessary if each entry in
the trap vector is a jump instruction to different trap handlers. Ultimately, the trap handler(s) will redirect execution
to the appropriate ISR for this interrupt.
Upon entering into an ISR, software must toggle the nth bit of INTPRI_CORE0_CPU_INT_CLEAR_REG if the
interrupt is of edge type, or clear the source of the interrupt if it is of level type.
Software may also update the value of INTPRI_CORE0_CPU_INT_THRESH_REG and program MIE=1 for
allowing higher priority interrupts to preempt the current ISR (nesting), however, before doing so, all the state
PRELIMINARY
Espressif Systems 53 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
CSRs must be saved (mepc, mstatus, mcause, etc.) since they will get overwritten due to occurrence of such an
interrupt. Later, when exiting the ISR, the values of these CSRs must be restored.
Finally, after the execution returns from the ISR back to the trap handler, MRET instruction is used to resume
normal execution.
Later, if the n interrupt is no longer needed and needs to be disabled, the following sequence may be
followed:
4. if the interrupt is of edge type and was found to be pending in step 2 above, nth bit of
INTPRI_CORE0_CPU_INT_CLEAR_REG must be toggled, so that its pending status gets flushed
Above is only a suggested scheme of operation. Actual software implementation may vary.
1.6.4 Registers
For the complete list of interrupt registers and configuration information, please refer to Section 9.6.2 and Section
9.7.2 respectively.
PRELIMINARY
Espressif Systems 54 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
ID Description Priority
0 U mode software interrupt 1
3 M mode software interrupt 3
4 U mode timer interrupt 0
7 M mode timer interrupt 2
These interrupt sources have reserved IDs and fixed priorities which cannot be masked via the interrupt controller
threshold registers for either mode.
Two of these interrupts (0 and 4) are by-default delegated to U mode as per the reset values of corresponding
bits in mideleg CSR.
It must be noted that regardless of the fixed priority of CLINT interrupts, pending external interrupt sources
always have higher priority over CLINT sources.
1.7.2 Features
• 4 local level-type interrupt sources with static priorities and IDs
• Software interrupts
The MSIE/USIE bit must be set in mie/uie CSR for enabling the interrupt at core level for a particular mode.
Pending state of this interrupt can be checked for either mode by reading the corresponding bit MSIP/USIP in
mip/uip CSR.
Note that by default U mode software interrupt with ID 0 has the corresponding bit set in mideleg CSR. This bit
can be toggled for using the interrupt in M mode instead. Similarly the bit corresponding to M mode software
interrupt can be set for using it in U mode.
PRELIMINARY
Espressif Systems 55 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
A read-only memory mapped UTIME is also provided for reading the timer counter from U mode, although it
always reflects the same value as in the corresponding M mode counter MTIME register.
Timer interrupt for M/U mode is enabled by setting the MTIE/UTIE bit in MTIMECTL/UTIMECTL. Also, the
MTIE/UTIE bit must be set in mie CSR for enabling the interrupt at core level for a particular mode.
Interrupt for M/U mode is asserted when the 64-bit timer value exceeds the 64-bit timer-compare value
programmed in MTIMECMP/UTIMECMP.
Pending state of M/U mode timer interrupt is reflected as the read-only MTIP/UTIP bit in
MTIMECTL/UTIMECTL.
For de-asserting the pending timer interrupt in M/U mode, either the MTIE/UTIE bit has to be cleared or the value
of the MTIMECMP/UTIMECMP register needs to be updated.
Pending state of this interrupt can be checked at core level for either mode by reading the corresponding bit
MTIP/UTIP in mip/uip.
Upon overflow of the 64-bit timer counter, the MTOF/UTOF bit in MTIMECTL/UTIMECTL gets set. It can be
cleared after appropriate handling of the overflow situation.
Note that by default U mode timer interrupt with ID 4 has the corresponding bit set in mideleg CSR. This bit can
be toggled for using the interrupt in M mode instead. Similarly the bit corresponding to M mode timer interrupt
can be set for using it in U mode.
PRELIMINARY
Espressif Systems 56 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
d)
ver
P
se
SI
(re
M
31 1 0
0x00000000 0 Reset
E
M F
se
P
E
TO
TC
TI
TI
(re
M
M
31 4 3 2 1 0
0x0000000 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 57 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
2]
:3
63
E[
M
TI
M
63 32
0 Reset
]
:0
31
E[
M
TI
M
31 0
0 Reset
2]
:3
63
P[
M
EC
M
TI
M
63 32
0 Reset
]
:0
31
P[
M
EC
M
TI
M
31 0
0 Reset
IP
US
(re
31 1 0
0x00000000 0 Reset
PRELIMINARY
Espressif Systems 58 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
)
ed
ed
rv
rv
UT F
se
se
IP
IE
O
UT
UT
(re
(re
31 4 3 2 1 0
0x0000000 0 0 0 0 Reset
UTIP Represents the pending status of the user timer interrupt. (RO)
63 32
0 Reset
:0]
31
E[
IM
UT
31 0
0 Reset
UTIME Represents the read-only 64-bit CLINT timer counter value. (RO)
63 32
0 Reset
]
:0
31
P[
M
EC
IM
UT
31 0
0 Reset
PRELIMINARY
Espressif Systems 59 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
1.8.2 Features
The PMP unit can be used to restrict access to physical memory. It supports 16 regions and a minimum
granularity of 4 bytes. The maximum supported NAPOT range is 4 GB.
By default, PMP grants permission to all accesses in machine mode and revokes permission of all access in user
mode. This implies that it is mandatory to program the address range and valid permissions in pmpcfg and
pmpaddr registers (refer to the Register Summary) for any valid access to pass through in user mode. However, it
is not required for machine mode as PMP permits all accesses to go through by default. In cases where PMP
checks are also required in machine mode, the software can set the lock bit of the required PMP entry to enable
permission checks on it. Once the lock bit is set, it can only be cleared through CPU reset.
When any instruction is being fetched from a memory region without execute permissions, an exception is
generated at the processor level and the exception cause is set as instruction access fault in mcause CSR.
Similarly, any load/store access without valid read/write permissions, will result in an exception generation with
mcause updated as load access and store access fault respectively. In case of load/store access faults, violating
address is captured in mtval CSR.
PRELIMINARY
Espressif Systems 60 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
PRELIMINARY
Espressif Systems 61 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
1.9.2 Features
PMAC supports below features:
Exception generation and handling for PMAC related faults will be handled in a similar way to PMP checks. When
any instruction is being fetched from a memory region configured as null or invalid memory region, an exception
is generated at the processor level and the exception cause is set as instruction access fault in mcause CSR.
Similarly, any load/store access to null or invalid memory region, will result in an exception generation with
mcause updated as load access and store access fault respectively. In case of load/store access faults, violating
address is captured in mtval CSR. For the PMAC entries configured as valid memory, the handling is same as for
PMP checks.
A lock bit per entry is also provided in case the software wants to disable programming of PMAC registers. Once
the lock bit in any pma_cfgX register is set, respective pma_cfgX and pma_addrX registers can not be
programmed further, unless a CPU reset cycle is applied.
A 4-bit field in PMAC CSRs is also provided to define attributes for memory regions. These bits are not used
internally by CPU core for any purpose. Based on address match, these attributes are provided on load/store
interface as side-band signals and are used by cache controller block for its internal operation.
PRELIMINARY
Espressif Systems 62 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
PRELIMINARY
Espressif Systems 63 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
ed
Ty rved
te
ss
ve
bu
rv
ce
pe
er
ck
se
se
tri
Ac
Lo
At
re
re
re
A
31 30 29 28 27 24 23 6 5 2 1 0
2 0 0 0 0 0 0 0 Reset
A Configures address type. The functionality is the same as pmpcfg register’s A field.
0x0: OFF
0x1: TOR
0x2: NA4
0x3: NAPOT
(R/W)
31 0
0 Reset
PRELIMINARY
Espressif Systems 64 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
1.10 Debug
1.10.1 Overview
This section describes how to debug and test software running on ESP-RISC-V core. Debug support is provided
through standard JTAG pins and complies to RISC-V External Debug Support Specification version 0.13.
Figure 1-2 below shows the main components of External Debug Support.
The user interacts with the Debug Host (e.g. laptop), which is running a debugger (e.g. gdb). The debugger
communicates with a Debug Translator (e.g. OpenOCD, which may include a hardware driver) to communicate
with Debug Transport Hardware (e.g. ESP-Prog adapter). The Debug Transport Hardware connects the Debug
Host to the ESP-RISC-V Core’s Debug Transport Module (DTM) through a standard JTAG interface. The DTM
provides access to the Debug Module (DM) using the Debug Module Interface (DMI).
The DM allows the debugger to halt selected cores. Abstract commands provide access to GPRs (general
purpose registers). The Program Buffer allows the debugger to execute arbitrary code on the core, which allows
access to additional CPU core state. Alternatively, additional abstract commands can provide access to
additional CPU core state. ESP-RISC-V core contains Trigger Module supporting 4 triggers. When trigger
conditions are met, core will halt spontaneously and inform the debug module that they have halted.
PRELIMINARY
Espressif Systems 65 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
System bus access block allows memory and peripheral register access without using the core.
1.10.2 Features
Basic debug functionality supports below features:
• CPU can be debugged from the first instruction executed after reset.
• Hardware single-stepping.
• Execute arbitrary instructions in the halted CPU by means of the program buffer. 16-word program buffer is
supported.
• Supports four Hardware Triggers (can be used as breakpoints/watchpoints) as described in Section 1.11.
• PAD_to_JTAG : means that the JTAG’s signal source comes from IO.
• USB_to_JTAG : means that the JTAG’s signal source comes from USB_Serial_JTAG controller.
Which JTAG method to use depends on many factors. The following table shows the configuration
method.
PRELIMINARY
Espressif Systems 66 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
Note:
2. x: do not care.
3. ”Temporary disable JTAG” means that if there are an even number of bits ”1” in EFUSE_SOFT_DIS_JTAG[2:0], the
JTAG function is turned on (the corresponding value in the table is 1), otherwise it is turned off (the corresponding
value in the table is 0). However, under certain special conditions of the HMAC Accelerator in ESP32-H2, the
JTAG function may be turned on even if there is an odd number of bits ”1” in EFUSE_SOFT_DIS_JTAG[2:0]. For
information on how HMAC affects JTAG functionality, please refer to Chapter HMAC Accelerator.
4. Please refer to Chapter eFuse Controller to get more information about eFuse.
5. Please refer to Chip Boot Control to get more information about the strapping pin GPIO25.
All the debug module registers are implemented in conformance to the specification RISC-V External Debug
Support Version 0.13. Please refer to it for more details.
PRELIMINARY
Espressif Systems 67 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
tim t
ve
op n
e
m
st cou
d
eb d
st rved
ed
re aku
ug
ve
e
ak
rv
rv
e
eb
op
us
ep
re
re
se
se
se
se
v
xd
eb
pr
ca
st
re
re
re
31 28 27 16 15 14 13 12 11 10 9 8 6 5 3 2 1 0
4 0 0 0 0 0 0 0 0 0 0 0 Reset
ebreakm When 1, ebreak instructions in Machine Mode enter Debug Mode. (R/W)
ebreaku When 1, ebreak instructions in User/Application Mode enter Debug Mode. (R/W)
stopcount This feature is not implemented. Debugger will always read this bit as 0. (RO)
stoptime This feature is not implemented. Debugger will always read this bit as 0. (RO)
cause Explains why Debug Mode was entered. When there are multiple reasons to enter Debug Mode
in a single cycle, the cause with the highest priority number is the one written.
1: An ebreak instruction was executed. (priority 3)
2: The Trigger Module caused a halt. (priority 4)
3: haltreq was set. (priority 2)
4: The CPU core single stepped because step was set. (priority 1)
Other values are reserved for future use.
(RO)
step When set and not in Debug Mode, the core will only execute a single instruction and then enter
Debug Mode. Interrupts are enabled* when this bit is set. If the instruction does not complete due
to an exception, the core will immediately enter Debug Mode before executing the trap handler,
with appropriate exception registers set. (R/W)
prv Contains the privilege level the core was operating in when Debug Mode was entered. A debugger
can change this value to change the core’s privilege level when exiting Debug Mode. Only 0x3
(machine mode) and 0x0 (user mode) are supported. (R/W)
31 0
0 Reset
dpc Upon entry to debug mode, dpc is written with the virtual address of the instruction that encoun-
tered the exception. When resuming, the CPU core’s PC is updated to the virtual address stored
in dpc. A debugger may write dpc to change where the CPU resumes. (R/W)
PRELIMINARY
Espressif Systems 68 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
h0
c
at
cr
ds
31 0
0 Reset
1
ch
at
cr
ds
31 0
0 Reset
PRELIMINARY
Espressif Systems 69 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
• each unit can be configured for matching the address of the program counter or load-store accesses
To choose a particular trigger unit write the index (0-3) of that unit into tselect CSR. When tselect is written with a
valid index, the abstract CSRs tdata1 and tdata2 are automatically mapped to reflect internal registers of that
trigger unit. Each trigger unit has two internal registers, namely mcontrol and maddress, which are mapped to
tdata1 and tdata2, respectively.
Writing larger than allowed indexes to tselect will clip the written value to the largest valid index, which can be
read back. This property may be used for enumerating the number of available triggers during initialization or
when using a debugger.
Since software or debugger may need to know the type of the selected trigger to correctly interpret tdata1 and
tdata2, the 4 bits (31-28) of tdata1 encodes the type of the selected trigger. This type field is read-only and
always provides a value of 0x2 for every trigger, which stands for match type trigger, hence, it is inferred that
tdata1 and tdata2 are to be interpreted as mcontrol and maddress. The information regarding other possible
values can be found in the specification RISC-V External Debug Support Version 0.13, but this trigger module
only supports type 0x2.
Once a trigger unit has been chosen by writing its index to tselect, it will become possible to configure it by setting
the appropriate bits in mcontrol CSR (tdata1) and writing the target address to maddress CSR (tdata2).
Each trigger unit can be configured to either cause breakpoint exception or enter debug mode, by writing to the
action field of mcontrol. This bit can only be written from debugger, thus by default a trigger, if enabled, will cause
breakpoint exception.
mcontrol for each trigger unit has a hit bit which may be read, after CPU halts or enters exception, to find out if
this was the trigger unit that fired. This bit is set as soon as the corresponding trigger fires, but it has to be
manually cleared before resuming operation. Although, failing to clear it does not affect normal execution in any
way.
Each trigger unit only supports match on address, although this address could either be that of a load/store
access or the virtual address of an instruction. The address and size of a region are specified by writing to
maddress (tdata2) CSR for the selected trigger unit. Larger than 1 byte region sizes are specified through NAPOT
PRELIMINARY
Espressif Systems 70 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
(naturally aligned power-of-two) encoding (see Table 1-10) and enabled by setting match bit in mcontrol. Note
that for NAPOT encoded addresses, by definition, the start address is constrained to be aligned to (i.e. an integer
multiple of) the region size.
tcontrol CSR is common to all trigger units. It is used for preventing triggers from causing repeated exceptions in
machine mode while execution is happening inside a trap handler. This also disables breakpoint exceptions
inside ISRs by default, although, it is possible to manually enable this right before entering an ISR, for debugging
purposes. This CSR is not relevant if a trigger is configured to enter debug mode.
When hart goes into trap due to the firing of a trigger (action = 0) :
• mte is set to 0
Note: If two different triggers fire at the same time, one with action = 0 and another with action = 1, then hart is halted
and enters debug mode.
d)
ve
t
er
c
ele
s
(re
ts
30 2 1 0
tselect Configures the index (0-3) of the selected trigger unit. (R/W)
ta
dm
da
ty
31 28 27 26 0
type Represents the trigger type. This field is reserved since only match type (0x2) triggers are sup-
ported. (RO)
data Configures the abstract tdata1 content. This will always be interpreted as fields of mcontrol since
only match type (0x2) triggers are supported. (R/W)
31 0
0x00000000 Reset
tdata2 Configures the abstract tdata2 content. This will always be interpreted as maddress since only
match type (0x2) triggers are supported. (R/W)
PRELIMINARY
Espressif Systems 72 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
)
ed
ed
rv
rv
e
se
se
pt
te
(re
(re
m
m
31 8 7 6 1 0
PRELIMINARY
Espressif Systems 73 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
)
ed
ed
ed
ed
ed
st ute
e
rv
rv
rv
rv
rv
ch
n
od
se
se
se
se
se
e
io
ec
ad
at
or
dm
t
(re
(re
(re
(re
(re
ac
t
ex
m
lo
hi
u
31 28 27 26 21 20 19 16 15 12 11 10 7 6 5 4 3 2 1 0
hit This is found to be 1 if the selected trigger had fired previously. This bit is to be cleared manually.
(R/W)
action Configures the selected trigger to perform one of the available actions when firing. Valid options
are:
0x0: cause breakpoint exception.
0x1: enter debug mode (only valid when dmode = 1)
Note: Writing an invalid value will set this to the default value 0x0.
(R/W)
match Configures the selected trigger to perform one of the available matching operations on a
data/instruction address. Valid options are:
0x0: exact byte match, i.e. address corresponding to one of the bytes in an access must match
the value of maddress exactly.
0x1: NAPOT match, i.e. at least one of the bytes of an access must lie in the NAPOT region
specified in maddress.
Note: Writing a larger value will clip it to the largest possible value 0x1.
(R/W)
m Set this for enabling selected trigger to operate in machine mode. (R/W)
u Set this for enabling selected trigger to operate in user mode. (R/W)
execute Set this for configuring the selected trigger to fire right before an instruction with matching
virtual address is executed by the CPU. (R/W)
store Set this for configuring the selected trigger to fire right before a store operation with matching
data address is executed by the CPU. (R/W)
load Set this for configuring the selected trigger to fire right before a load operation with matching
data address is executed by the CPU. (R/W)
PRELIMINARY
Espressif Systems 74 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
ss
re
d
ad
m
31 0
0x00000000 Reset
maddress Configures the address used by the selected trigger when performing match operation.
This is decoded as NAPOT when match=1 in mcontrol. (R/W)
PRELIMINARY
Espressif Systems 75 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
1.12 Trace
1.12.1 Overview
In order to support non-intrusive software debug, the CPU core provides an instruction trace interface which
provides relevant information for offline debug purpose. This interface provides relevant information to Trace
Encoder block, which compresses the information and stores in memory allocated for it. Software decoders can
read this information from trace memory without interrupting the CPU core and re-generate the actual program
execution by the CPU core.
1.12.2 Features
The CPU core supports instruction trace feature and provides below information to Trace Encoder as mandated
in RISC-V Processor Trace Version 1.0:
• Occurrence of exception and interrupt along with cause and trap values.
• Instruction address for instructions retired before and after program counter changes.
The core does not have any internal registers to provide control over instruction trace interface. All register
controls are available in 2 RISC-V Trace Encoder (TRACE) block.
PRELIMINARY
Espressif Systems 76 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
1.13 Dedicated IO
1.13.1 Overview
Normally, GPIOs are an APB peripheral, which means that changes to outputs and reads from inputs can get
stuck in write buffers or behind other transfers, and in general are slower because generally the APB bus runs at
a lower speed than the CPU. As an alternative, the CPU core implements I/O processors specific CPU registers
(CSRs) which are directly connected to the GPIO matrix or IO pads. As these registers can get accessed in one
instruction, speed is fast.
1.13.2 Features
• 8 dedicated IOs directly mapped on GPIOs
• GPIO_OUT is R/W and reflects the output value for the GPIOs.
• GPIO_OEN is R/W and reflects the output enable state for the GPIOs. It controls the pad direction.
Programming high would mean the pad should be configured in output mode. Programming low means it
should be configured in input mode.
PRELIMINARY
Espressif Systems 77 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
U PIO E ]
U PIO E ]
U PIO E ]
U PIO E ]
U_ PIO EN ]
PI E ]
EN ]
]
CP _G _O N[7
CP _G _O N[6
CP _G _O N[5
CP _G _O N[4
CP _G _O N[3
G _O [2
_O [1
[0
O N
U PIO E
CP _G _O
U PIO
d)
e
CP _G
rv
se
U
CP
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 Reset
CPU_GPIO_OEN Configures whether to enable GPIOn (n=0 ~ 21) output. CPU_GPIO_OEN[7:0] cor-
respond to output enable signals cpu_gpio_out_oen[7:0] in Table 6-2 Peripheral Signals via GPIO
Matrix. CPU_GPIO_OEN value matches that of cpu_gpio_out_oen. CPU_GPIO_OEN is the enable
signal of CPU_GPIO_OUT.
0: Disable GPIO output
1: Enable GPIO output
(R/W)
N[
CP _G _I
_I
U PIO
)
PI
ed
CP _G
rv
se
U
CP
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 Reset
CPU_GPIO_IN Represents GPIOn (n=0 ~ 21) input value. It is a CPU CSR to read input value (1=high,
0=low) from SoC GPIO pin.
CPU_GPIO_IN[7:0] correspond to input signals cpu_gpio_in[7:0] in Table 6-2 Peripheral Signals via
GPIO Matrix.
CPU_GPIO_IN[7:0] can only be mapped to GPIO pins through GPIO matrix. For details please
refer to Section 6.4 in Chapter IO MUX and GPIO Matrix (GPIO, IO MUX).
(RO)
PRELIMINARY
Espressif Systems 78 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
U PIO U ]
U PIO U ]
U PIO U ]
U PIO U ]
U_ PIO UT ]
PI U ]
UT ]
]
CP _G _O T[7
CP _G _O T[6
CP _G _O T[5
CP _G _O T[4
CP _G _O T[3
G _O [2
_O [1
[0
O T
U PIO U
CP _G _O
U PIO
)
ed
CP _G
rv
se
U
CP
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 Reset
CPU_GPIO_OUT Configures GPIOn (n=0 ~ 21) output value. It is a CPU CSR to write value (1=high,
0=low) to SoC GPIO pin. The value takes effect only when CPU_GPIO_OEN is set.
CPU_GPIO_OUT[7:0] correspond to output signals cpu_gpio_out[7:0] in Table 6-2 Peripheral Sig-
nals via GPIO Matrix.
CPU_GPIO_OUT[7:0] can only be mapped to GPIO pins through GPIO matrix. For details please
refer to Section 6.5 in Chapter IO MUX and GPIO Matrix (GPIO, IO MUX).
(R/W)
PRELIMINARY
Espressif Systems 79 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
The atomic instructions currently ignore the aq (acquire) and rl (release) bits as they are irrelevant to the current
architecture in which memory ordering is always guaranteed.
The LR.W instruction simply locks a 32-bit aligned memory address to which the load access is being performed.
Once a 4-byte memory region is locked, it will remain locked, i.e. other harts won’t be able to access this same
memory location, until any of the following scenarios is encountered during execution:
• any interrupts/exceptions
• JALR
• ECALL/EBREAK/MRET/URET
• FENCE/FENCE.I
• debug mode
If any of the above happens, except SC.W, the memory lock will be released immediately. If an SC.W instruction
is encountered instead, the lock will be released eventually (not immediately) in the manner described in Section
1.14.2.2.
The SC.W instruction first checks if the memory lock is still valid, and the address is the same as specified during
the last LR.W instruction. If so, only then will it perform the store to memory, and later release the lock as soon as
it gets an acknowledgment of operation completion from the memory.
On the other hand, if the lock is found to have been invalidated (due to any of the situations as described in
section 1.14.2.1), it will set a fail code (currently always 1) in the destination register rd.
PRELIMINARY
Espressif Systems 80 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
1 ESP-RISC-V CPU GoBack
1. Read data from the memory address given by rs1, and save it to destination register rd.
2. Combine the data in rd and rs2 according to the operation type and keep the result for Step 3 below.
3. Write the result obtained in Step 2 above to the memory address given by rs1.
There are 9 different AMO operations: SWAP, ADD, AND, OR, XOR, MAX, MIN, MAXU and MINU.
During this whole process, the memory address is kept locked from being accessed by other harts. If a
misaligned address is encountered, it will cause an exception with mcause = 6.
For AMO operations both load and store access faults (PMP/PMA) are checked in the 1st step itself. For such
cases mcause = 7.
PRELIMINARY
Espressif Systems 81 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
CPU
APB AHB
Transmission
Config
Control
2.1 Terminology
To better illustrate the functions of the RISC-V Trace Encoder, the following terms are used in this chapter.
2.2 Introduction
In complex systems, understanding program execution flow is not straightforward. This may be due to a number
of factors, such as interactions with other cores, peripherals, real-time events, poor implementations, or some
combination of all of the above.
It is hard to use a debugger to monitor the program execution flow of a running system in real-time, as this is
intrusive and might affect the running state. But providing visibility of program execution is important.
That is where instruction trace comes in, which provides trace of the program execution.
PRELIMINARY
Espressif Systems 82 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
ESP Chip
Debug Host
Instruction Trace
Interface
Trace
Decoder System
DM Memory
• The CPU core provides an instruction trace interface that outputs the instruction information executed by
the CPU, such as instruction address, instruction type, etc. For more details about ESP32-H2 CPU’s
instruction trace interface, please refer to Chapter 1 ESP-RISC-V CPU.
• The trace encoder connects to the CPU’s instruction trace interface and compresses the information into
smaller packets, and then stores the packets in system memory.
• The debugger can dump the trace packets from the system memory via JTAG or USB Serial/JTAG, and
use a decoder to decompress and reconstruct the program execution flow. The Trace Decoder, usually
software on an external PC, takes in the trace packets and reconstructs the program instruction flow with
the program binary that runs on the originating hart. This decoding step can be done offline or in real-time
while the hart is executing.
This chapter mainly introduces the implementation details of ESP32-H2’s trace encoder.
2.3 Features
• Compatible with RISC-V Processor Trace Version 1.0. See Table 2-2 for the implemented parameters
• Two interrupts:
PRELIMINARY
Espressif Systems 83 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
– Triggered when the packet size exceeds the configured memory space
For detailed descriptions of the above parameters, please refer to the RISC-V Processor Trace Version 1.0 >
Chapter Parameters and Discovery.
The encoder receives the CPU’s instruction information via the instruction trace interface, compresses it into
different packets, and writes it to the internal FIFO.
The transmission control module writes the data in the FIFO to the internal SRAM through the AHB bus.
The FIFO is 128 deep and 8-bit wide. When the memory write bandwidth is insufficient, the FIFO may overflow
PRELIMINARY
Espressif Systems 84 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
and packet loss occurs. If a packet is lost, the encoder will send a packet to tell that a packet is lost, and will
stop working until the FIFO is empty.
You can adjust the trace bandwidth by increasing the value of TRACE_RESYNC_PROLONGED_REG to reduce
the frequency of sending synchronization packets, thereby reducing the bandwidth occupied by packets.
• The maximum packet length is 13 bytes, so a sequence of at least 14 zero bytes cannot occur within a
packet. Therefore, the first non-zero byte seen after a sequence of at least 14 zero bytes must be the first
byte of a packet.
• Every time when 128 packets are transmitted, the encoder writes 14 zero bytes to the memory partition
boundary as anchor tags.
• Loop mode: When the size of the trace packets exceeds the capacity of the trace memory (namely when
TRACE_MEM_CURRENT_ADDR_REG reaches the value of TRACE_MEM_END_ADDR_REG), the trace
memory is wrapped around, so that the encoder loops back to the memory’s starting address
TRACE_MEM_START_ADDR_REG, and old data in the memory will be overwritten by new data.
• Non-loop mode: When the size of the trace packets exceeds the capacity of the trace memory, the trace
memory is not wrapped around. The encoder stops at TRACE_MEM_END_ADDR_REG, and old data will
be retained.
PRELIMINARY
Espressif Systems 85 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
If the automatic restart feature is enabled, the encoder will be restarted in any case. Therefore, to disable the
encoder, the automatic restart feature must be disabled first by clearing the TRACE_RESTART_ENA bit of the
TRACE_TRIGGER_REG register.
For details about the above features, please refer RISC-V Processor Trace Version 1.0 (referred to below as the
specification).
A packet includes header, index, and payload. Header, index, and payload are transmitted sequentially in bit
stream form, from the fields listed at the top of the tables below to the fields listed at the bottom. If a field
consists of multiple bits, then the least significant bit is transmitted first.
2.6.1 Header
The header is 1-byte long. The format of the header is shown in Table 2-3.
2.6.2 Index
The index has 2 bytes. The format of the index is shown in Table 2-4.
PRELIMINARY
Espressif Systems 86 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
2.6.3 Payload
The length of payload ranges from 1 byte to 10 bytes.
Format 3 packets are used for synchronization, and report supporting information. There are 4 subformats
defined in the specification. ESP32-H2 only supports 3 of them.
This packet contains all the information the decoder needs to fully identify an instruction. It is sent for the first
traced instruction (unless that instruction also happens to be a first in an exception handler), and when
synchronization has been scheduled by the expiry of the synchronization timer. The payload length is 5
bytes.
0: The address points to a branch instruction, and the branch was taken.
branch 1
1: The instruction is not a branch or if the branch is not taken.
This packet also contains all the information the decoder needs to fully identify an instruction. It is sent following
an exception or interrupt, and includes the cause, the ’trap value’ (for exceptions), and the address of the trap
handler or of the exception itself. The length is 10 bytes.
0: The address points to a branch instruction, and the branch was taken.
branch 1
1: The instruction is not a branch or if the branch is not taken.
This packet provides supporting information to aid the decoder. It is issued when the trace is ended. The length
is 1 byte.
This packet contains only an instruction address, and is used when the address of an instruction must be
reported, and there is no reported branch information. The length is 5 bytes.
PRELIMINARY
Espressif Systems 88 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
This packet includes branch information, and is used when either the branch information must be reported (for
example because the branch map is full), or when the address of instruction must be reported, and there has
must been at least one branch since the previous packet. This packet only supports full address mode.
PRELIMINARY
Espressif Systems 89 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
2.7 Interrupt
• TRACE_MEM_FULL_INTR: Triggered when the packet size exceeds the capacity of the trace memory,
namely when TRACE_MEM_CURRENT_ADDR_REG reaches the value of
TRACE_MEM_END_ADDR_REG. If necessary, this interrupt can be enabled to notify the CPU for
processing, such as applying for a new memory space again.
• TRACE_FIFO_OVERFLOW_INTR: Triggered when the internal FIFO overflows and one or more packets
have been lost.
After enabling the trace encoder interrupts, map them to numbered CPU interrupts through the Interrupt Matrix,
so that the CPU can respond to these trace encoder interrupts. For details, please refer to Chapter 9 Interrupt
Matrix (INTMTX).
• (Optional) Configure the memory writing mode via the TRACE_MEM_LOOP bit of TRACE_TRIGGER_REG
– 0: Non-loop mode
– 1: count by packet
• (Optional) Configures the threshold for the synchronization counter (default value is 128) via
TRACE_RESYNC_PROLONGED_REG
PRELIMINARY
Espressif Systems 90 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
Once the encoder is enabled, it will keep tracing the CPU’s instruction trace interface and writing packets to the
trace memory.
• Confirm whether all data in the FIFO have been written into the memory by reading the
TRACE_FIFO_EMPTY bit
* if read 0, and the loop mode is enabled, then the old trace packets are overwritten. In this case,
read the TRACE_MEM_CURRENT_ADDR_REG to know the last writing address, and use this
address as the first address to decode
– The decoder reads all data packets starting from the first address, and reconstructs the data stream
with the binary file
– As mentioned in 2.6, the encoder writes 14 zero bytes to the memory partition boundary every time
when 128 packets are transmitted. Given this fact, the first non-zero byte after 14 zero bytes should
be the header of a new packet
PRELIMINARY
Espressif Systems 91 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 92 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
2.10 Registers
The addresses in this section are relative to RISC-V Trace Encoder base address provided in Table 4-2 in Chapter
4 System and Memory.
DR
AD
RT_
TA
_S
EM
_ M
A CE
TR
31 0
0x000000 Reset
31 0
0xffffffff Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 93 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
DA
UP
_
DR
AD
T_
EN
R
UR
_C
EM
M
d)
E_
ve
AC
ser
TR
(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
PT S
M U
Y
_E TAT
FO S
FI K_
E_ OR
AC _W
)
ed
TR CE
rv
se
A
TR
(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 1 Reset
PRELIMINARY
Espressif Systems 94 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
NA
E
R_
W A
NT
LO _EN
_I
RF TR
VE IN
_O LL_
FO U
FI _F
E_ EM
AC _M
d)
ve
TR CE
er
A
s
TR
(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
W
RA
R_
W AW
NT
LO _R
_I
RF TR
VE IN
_O LL_
FO U
FI _F
E_ EM
AC _M
e d)
TR CE
rv
se
A
TR
(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
R
CL
R_
W LR
NT
LO _C
_I
RF TR
VE IN
_O LL_
FO U
FI _F
E_ EM
AC _M
d)
ve
TR CE
r
se
A
TR
(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
PRELIMINARY
Espressif Systems 95 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
E_ IG OO A
ER FF
N
AC _TR _L EN
G O
_O
TR G E P
TR CE EM RT_
IG R_
A _M A
TR E ST
AC _RE
d)
ve
TR CE
er
A
s
TR
(re
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 Reset
TRACE_RESTART_ENA Configures whether or not to enable the automatic restart function for the
encoder.
0: Disable
1: Enable
(R/W)
O
O
R
_M
_P
NC
NC
SY
SY
RE
RE
d)
E_
E_
e
rv
AC
AC
se
TR
TR
(re
31 25 24 23 0
0 0 0 0 0 0 0 0 128 Reset
PRELIMINARY
Espressif Systems 96 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
2 RISC-V Trace Encoder (TRACE) GoBack
EN
K_
CL
d)
E_
ve
AC
r
se
TR
(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
TRACE_CLK_EN Configures register clock gating. 0: Support clock only when the application writes
registers to save power
1: Always force the clock on for registers
This bit doesn’t affect register access
(R/W)
TE
DA
d)
E_
ve
AC
r
se
TR
(re
31 28 27 0
0 0 0 0 0x2203030 Reset
PRELIMINARY
Espressif Systems 97 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
3.1 Overview
General Direct Memory Access (GDMA) is a feature that allows peripheral-to-memory, memory-to-peripheral, and
memory-to-memory data transfer at high speed. The CPU is not involved in the GDMA transfer and therefore is
more efficient with less workload.
The GDMA controller in ESP32-H2 has six independent channels, i.e. three transmit channels and three receive
channels. These six channels are shared by peripherals with the GDMA feature, and can be assigned to any of
such peripherals, including SPI2, UHCI (UART0/UART1), I2S, AES, SHA, ADC, and PARLIO. UART0 and UART1
use UHCI together.
The GDMA controller uses fixed-priority and round-robin channel arbitration schemes to manage peripherals’
needs for bandwidth.
Rx channel 0 SPI2
I2S
Rx channel 1
AES
Tx channel 1
SHA
Rx channel 2
ADC
Tx channel 2 PARLIO
3.2 Features
The GDMA controller has the following features:
• Access to an address space of 324 KB at most in internal RAM (320 KB HP SRAM, 4 KB LP SRAM)
PRELIMINARY
Espressif Systems 98 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
3.3 Architecture
In ESP32-H2, all modules that need high-speed data transfer support GDMA. The GDMA controller and CPU
data bus have access to the same address space in internal RAM. Figure 3-2 shows the basic architecture of the
GDMA controller.
GDMA Controller
Rx Channel 0 Peri 0
Tx Channel 0 Peri 1
Internal Rx Channel 1
RAM Peri Peri 2
Arbiter
Select
Tx Channel 1
Rx Channel 2
Tx Channel 2 Peri n
The GDMA controller has six independent channels, i.e. three transmit channels and three receive channels.
Every channel can be connected to different peripherals. In other words, channels are general-purpose, shared
by peripherals.
The GDMA controller reads data from or writes data to internal RAM via AHB_BUS. Before this, the GDMA
controller uses a fixed-priority arbitration scheme for channels requesting read or write access. For the available
address range of Internal RAM, please see Chapter 4 System and Memory.
Software can use the GDMA controller through linked lists. These linked lists, stored in internal RAM, consist of
outlinkn and inlinkn, where n indicates the channel number (ranging from 0 to 2). The GDMA controller reads an
outlinkn (i.e. a linked list of transmit descriptors) from internal RAM and transmits data in corresponding RAM
according to the outlinkn, or reads an inlinkn (i.e. a linked list of receive descriptors) and stores received data into
specific address space in RAM according to the inlinkn.
PRELIMINARY
Espressif Systems 99 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
Figure 3-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 stored in
internal RAM for the GDMA controller to use. The meanings of a descriptor’s fields are as follows:
• owner (DW0) [31]: Specifies who is allowed to access the buffer that this descriptor points to.
0: CPU can access the buffer.
1: The GDMA controller can access the buffer.
When the GDMA controller stops using the buffer, this bit in a receive descriptor is automatically cleared by
hardware, and this bit in a transmit descriptor can only be automatically cleared by hardware if
GDMA_OUT_AUTO_WRBACK_CHn is set to 1. Software can disable automatic clearing by hardware by
setting GDMA_OUT_LOOP_TEST_CHn or GDMA_IN_LOOP_TEST_CHn. When software loads a linked
list, this bit should be set to 1.
Note: GDMA_OUT is the prefix of transmit channel registers, and GDMA_IN is the prefix of receive channel
registers.
• suc_eof (DW0) [30]: Specifies whether this descriptor is the last descriptor of a data frame or packet.
0: This descriptor is not the last one.
1: This descriptor is the last one.
Software clears the suc_eof bit in receive descriptors. When a frame or packet has been received, this bit in
the last receive descriptor is set by hardware, while this bit in the last transmit descriptor is set by software.
• reserved (DW0) [29]: Reserved. The value of this bit does not matter.
• err_eof (DW0) [28]: Specifies whether the received data has errors.
0: The received data does not have errors.
1: The received data has errors.
This bit is used only when UHCI or PARLIO uses GDMA to receive data. When an error is detected in the
received frame or packet, this bit in the receive descriptor is set to 1 by hardware.
PRELIMINARY
Espressif Systems 100 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
• 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 valid
bytes have been stored into the buffer.
• size (DW0) [11:0]: Specifies the size of the buffer that this descriptor points to.
• buffer address pointer (DW1): Address of the buffer. This field can only point to internal RAM.
• next descriptor address (DW2): Address of the next descriptor. If the current descriptor is the last one
(suc_eof = 1), this value could be 0. This field can only point to internal RAM.
If the length of data received is smaller than the size of the buffer, the GDMA controller will not use the available
space of the buffer in the next transaction.
Every transmit and receive channel can be connected to any peripheral with the GDMA feature. Table 3-1
illustrates how to select the peripheral to be connected via registers. “Dummy-n” corresponds to register values
for memory-to-memory data transfer. When a channel is connected to a peripheral, the rest channels cannot be
connected to that peripheral.
GDMA_PERI_IN_SEL_CHn
Peripheral
GDMA_PERI_OUT_SEL_CHn
0 SPI2
1 Dummy-1
2 UHCI
3 I2S
4 Dummy-4
5 Dummy-5
6 AES
7 SHA
8 ADC
9 PARLIO
10 ~ 15 Dummy-10 ~ 15
16 ~ 63 Invalid
In some cases, you may want to append more descriptors to a DMA transfer that is already started. Naively, it
would seem to be possible to do this by clearing the EOF bit of the final descriptor in the existing list and setting
its next descriptor address pointer field (DW2) to the first descriptor of the to-be-added list. However, this
strategy fails if the existing DMA transfer is almost or entirely finished. Instead, the GDMA controller has
specialized logic to make sure a DMA transfer can be continued or restarted: if the transfer is ongoing, the
controller will make sure to take the appended descriptors into account; if the transfer has already finished, the
controller will restart with the new descriptors. This is implemented by the Restart function.
When using the Restart function, software needs to rewrite the address of the first descriptor in the new list to
DW2 of the last descriptor in the loaded list, and set the GDMA_INLINK_RESTART_CHn bit or the
GDMA_OUTLINK_RESTART_CHn bit (these two bits are cleared automatically by hardware). As shown in Figure
3-4, 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.
PRELIMINARY
Espressif Systems 102 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
• Buffer address pointer (DW1) check. If the buffer address pointer points to 0x40800000 ~ 0x4084FFFF
(please refer to Section 3.4.7), it passes the check. Otherwise, it fails the check.
After software detects a descriptor error interrupt, it must reset the corresponding channel, and enable GDMA by
setting GDMA_OUTLINK_START_CHn or GDMA_INLINK_START_CHn bit.
Note: The third word (DW2) in a descriptor can only point to a location in internal RAM, given that the third word
points to the next descriptor to use and that all descriptors must be in internal memory.
3.4.6 EOF
The GDMA controller uses EOF (end of frame) flags to indicate the end of the data frame or packet
transmission.
Before the GDMA controller transmits data, the GDMA_OUT_TOTAL_EOF_CHn_INT_ENA bit should be set to
enable the GDMA_OUT_TOTAL_EOF_CHn_INT interrupt. If data in the buffer pointed by the last descriptor (with
EOF) has been transmitted, a GDMA_OUT_TOTAL_EOF_CHn_INT interrupt is generated.
Before the GDMA controller receives data, the GDMA_IN_SUC_EOF_CHn_INT_ENA bit should be set to enable
the GDMA_IN_SUC_EOF_CHn_INT interrupt. If a data frame or packet has been received successfully, a
GDMA_IN_SUC_EOF_CHn_INT interrupt is generated. In addition, when the GDMA channel is connected to
UHCI or PARLIO, the GDMA controller also supports the GDMA_IN_ERR_CHn_EOF_INT interrupt. This interrupt
is enabled by setting the GDMA_IN_ERR_EOF_CHn_INT_ENA bit, and it indicates that a data frame or packet
has been received with errors.
Note: In this chapter, EOF of transmit descriptors refers to suc_eof, while EOF of receive descriptors refers to
both suc_eof and err_eof.
PRELIMINARY
Espressif Systems 103 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
0 — — —
Outlink
1 — — —
Table 3-2 lists the requirements for descriptor field alignment when accessing internal RAM.
When the burst mode is disabled, size, length, and buffer address pointer in both transmit and receive
descriptors do not need to be word-aligned. That is, for a descriptor, GDMA can read data of specified length (1
~ 4095 bytes) from any start addresses in the accessible address range, or write received data of the specified
length (1 ~ 4095 bytes) to any contiguous addresses in the accessible address range.
When the burst mode is enabled, size, length, and buffer address pointer in transmit descriptors are also not
necessarily word-aligned. However, size and buffer address pointer in receive descriptors except length should
be word-aligned.
3.4.8 Arbitration
To ensure timely response to peripherals running at a high speed with low latency (such as SPI), the GDMA
controller implements a fixed-priority channel arbitration scheme. That is to say, each channel can be assigned a
priority from 0 ~ 5 (in total 6 levels). The larger the number, the higher the priority, and the more timely the
response. When several channels are assigned the same priority, the GDMA controller adopts a round-robin
arbitration scheme.
Note:
Above ETM tasks can achieve the same functions as CPU configuring GDMA_INLNIK_START_CHn and
GDMA_OUTLINK_START_CHn. When GDMA_IN_ETM_EN_CHn or GDMA_OUT_ETM_EN_CHn is 1, only ETM tasks can
be used to configure the transfer direction and enable the corresponding GDMA channel. When GDMA_IN_ETM_EN_CHn
or GDMA_OUT_ETM_EN_CHn is 0, only CPU can be used to enable the corresponding GDMA channel.
• GDMA_EVT_IN_DONE_CHn: Indicates that the data has been received according to the receive descriptor
via channel n.
• GDMA_EVT_IN_SUC_EOF_CHn: Indicates that the data corresponding to a receive descriptor has been
received via channel n and the EOF bit of this descriptor is 1.
PRELIMINARY
Espressif Systems 104 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
• GDMA_EVT_OUT_DONE_CHn: Indicates that the data has been transmitted according to the transmit
descriptor via channel n.
• GDMA_EVT_OUT_TOTAL_EOF_CHn: Indicates that the data corresponding to the last transmit descriptors
has been sent via transmit channel n and the EOF bit of this descriptor is 1.
In practical applications, GDMA’s ETM events can trigger its own ETM tasks. For example, the
GDMA_EVT_OUT_TOTAL_EOF_CH0 event can trigger the GDMA_TASK_IN_START_CH1 task, and in this way
trigger a new round of GDMA operations.
• GDMA_IN_CH0_INTR
• GDMA_IN_CH1_INTR
• GDMA_IN_CH2_INTR
• GDMA_OUT_CH0_INTR
• GDMA_OUT_CH1_INTR
• GDMA_OUT_CH2_INTR
• GDMA_IN_DSCR_EMPTY_CHn_INT: Triggered when the size of the buffer pointed by receive descriptors is
smaller than the length of data to be received via receive channel n.
• GDMA_IN_ERR_EOF_CHn_INT: Triggered when an error is detected in the data frame or packet received
via receive channel n. This interrupt is used only for UHCI peripheral (UART0 or UART1) or PARLIO.
• GDMA_IN_SUC_EOF_CHn_INT: Triggered when the suc_eof bit in a receive descriptor is 1 and the data
corresponding to this receive descriptor has been received (i.e. when the data frame or packet
corresponding to an inlink has beeen received) via receive channel n.
• GDMA_IN_DONE_CHn_INT: Triggered when all data corresponding to a receive descriptor has been
received via receive channel n.
PRELIMINARY
Espressif Systems 105 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
• GDMA_OUT_DONE_CHn_INT: Triggered when all data corresponding to a transmit descriptor has been
sent via transmit channel n.
1. Set GDMA_OUT_RST_CHn first to 1 and then to 0, to reset the state machine of GDMA’s transmit channel
and FIFO pointer.
2. Load an outlink, and configure GDMA_OUTLINK_ADDR_CHn with address of the first transmit descriptor.
5. Configure and enable the corresponding peripheral. See details in individual chapters of these peripherals.
6. Wait for the GDMA_OUT_EOF_CHn_INT interrupt, which indicates the completion of data transfer.
1. Set GDMA_IN_RST_CHn first to 1 and then to 0, to reset the state machine of GDMA’s receive channel and
FIFO pointer.
2. Load an inlink, and configure GDMA_INLINK_ADDR_CHn with address of the first receive descriptor.
5. Configure and enable the corresponding peripheral. See details in individual chapters of these peripherals.
6. Wait for the GDMA_IN_SUC_EOF_CHn_INT interrupt, which indicates that a data frame or packet has been
received.
PRELIMINARY
Espressif Systems 106 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
1. Set GDMA_OUT_RST_CHn first to 1 and then to 0, to reset the state machine of GDMA’s transmit channel
and FIFO pointer.
2. Set GDMA_IN_RST_CHn first to 1 and then to 0, to reset the state machine of GDMA’s receive channel and
FIFO pointer.
3. Load an outlink, and configure GDMA_OUTLINK_ADDR_CHn with address of the first transmit descriptor.
4. Load an inlink, and configure GDMA_INLINK_ADDR_CHn with address of the first receive descriptor.
8. Wait for the GDMA_IN_SUC_EOF_CHn_INT interrupt, which indicates that a data transaction has been
completed.
PRELIMINARY
Espressif Systems 107 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 108 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
PRELIMINARY
Espressif Systems 109 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
PRELIMINARY
Espressif Systems 110 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
PRELIMINARY
Espressif Systems 111 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
3.8 Registers
The addresses in this section are relative to GDMA base address provided in Table 4-2 in Chapter 4 System and
Memory.
_C CH INT _R AW
H0 0_ _R AW
NE F_ _ T R
AW W
_I INT AW
O O H0 _IN T_
G A_ _ER R_ PT INT AW
A_ _S _E R_ CH AW
_R RA
_D _E _C 0 IN
R
R
IN UC OF CH 0_
NT _
DM IN C EM 0 _
DM IN R ER Y _
G A_ _DS R_ CH INT
_
_
_
DM IN C F_ 0
G A_ _DS OV CH
_
DM IN O F
G A_ IF UD
_
_
DM _IN FO
FI
F
DM _IN
)
ed
rv
A
A
DM
se
(re
G
G
G
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 0 0 Reset
PRELIMINARY
Espressif Systems 112 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
_C CH INT _ST T
NE F_ _ T S
O O H0 _IN T_
_S ST
_I INT T
_D _E _C 0 IN
G A_ _ER R_ PT INT T
A_ _S _E R_ CH T
H0 0_ _S
S
S
IN UC OF CH 0_
NT _
DM IN C EM 0 _
DM IN R ER Y _
T
G A_ _DS R_ CH INT
_
_
_
DM IN C F_ 0
G A_ _DS OV CH
_ _
DM IN O F
G A_ FIF UD
_
DM IN O
G A_ FIF
DM IN
)
ed
G A_
rv
DM
se
(re
G
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 0 0 Reset
PRELIMINARY
Espressif Systems 113 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
_C CH INT _EN NA
H0 0_ _E A
NE F_ _ T E
O O H0 _IN T_
NA A
_I INT NA
G A_ _ER R_ PT INT NA
A_ _S _E R_ CH NA
_E EN
_D _E _C 0 IN
E
E
IN UC OF CH 0_
NT _
DM IN C EM 0 _
DM IN R ER Y _
G A_ _DS R_ CH INT
_
_
_
DM IN C F_ 0
G A_ _DS OV CH
_
DM IN O F
G A_ IF UD
_
_
DM _IN FO
FI
F
DM _IN
d)
ve
A
A
er
DM
s
(re
G
G
G
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 0 0 Reset
PRELIMINARY
Espressif Systems 114 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
_C CH INT _C LR
NE F_ _ T C
H0 0_ _C LR
O O H0 _IN T_
LR R
_I INT LR
G A_ _ER R_ PT INT LR
A_ _S _E R_ CH LR
_C CL
_D _E _C 0 IN
C
C
IN UC OF CH 0_
NT _
DM IN C EM 0 _
DM IN R ER Y _
G A_ _DS R_ CH INT
_
_
_
DM IN C F_ 0
G A_ _DS OV CH
_
DM IN O F
G A_ IF UD
_
_
DM _IN FO
FI
F
DM _IN
)
ed
rv
A
A
DM
se
(re
G
G
G
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 0 0 Reset
PRELIMINARY
Espressif Systems 115 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
H0 _R NT AW
W
_I AW _RA
O EO R_ F_ INT AW
O H0 _C _IN W
_C INT 0_I _R
_D _C R H0 RA
AW
T
A_ UT_ SC EO 0_ T_R
UT F ER C _
_R
_ H N
NT
G A_ T_ TA F_C 0_I
NE _ H
U O V H
G A_ T_ O_O F_C
DM O IF D
DM O D L
G A_ TF O_U
DM O IF
DM O T
G A_ TF
U
U
U
)
DM O
ed
G A_
v
er
DM
s
(re
G
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
PRELIMINARY
Espressif Systems 116 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
H0 _S NT T
_I T _ST
_C INT 0_I _S
O EO R_ F_ INT T
_D _C R H0 ST
T
A_ UT_ SC EO 0_ T_S
O H0 _C _IN
UT F ER C _
T
_S
_ H N
NT
G A_ T_ TA F_C 0_I
NE _ H
U O V H
G A_ T_ O_O F_C
DM O IF D
DM O D L
G A_ TF O_U
DM O IF
DM O T
G A_ TF
U
U
U
)
DM O
ed
G A_
rv
DM
se
(re
G
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
PRELIMINARY
Espressif Systems 117 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
H0 _E NT NA
A
_I NA _EN
_C INT 0_I _E
O EO R_ F_ INT NA
O H0 _C _IN A
_D _C R H0 EN
T
NA
A_ UT_ SC EO 0_ T_E
UT F ER C _
_E
_ H N
NT
G A_ T_ TA F_C 0_I
NE _ H
U O V H
G A_ T_ O_O F_C
DM O IF D
DM O D L
G A_ TF O_U
DM O IF
DM O T
G A_ TF
U
U
U
)
DM O
ed
G A_
v
er
DM
s
(re
G
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
PRELIMINARY
Espressif Systems 118 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
H0 _C NT LR
LR
_C INT 0_I _C
O EO R_ F_ INT LR
O H0 _C _IN R
_I LR _C
_D _C R H0 CL
T
A_ UT_ SC EO 0_ T_C
LR
UT F ER C _
_C
_ H N
NT
G A_ T_ TA F_C 0_I
NE _ H
O V H
G A_ T_ O_O F_C
DM O IF D
DM O D L
G A_ TF O_U
DM O IF
DM O T
G A_ TF
U
U
U
U
)
DM O
ed
G A_
rv
DM
se
(re
G
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
DE
DR
O
AD
M
ST
ST
ve _TE
TE
B_
B
AH
AH
d)
d)
e
A_
A_
rv
r
DM
DM
se
se
(re
(re
G
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
PRELIMINARY
Espressif Systems 119 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
ER
NT
IS
_I
ST
_D
_R
RI
se AR EN
DM d P
BM
G rve B_
(re A_ K_
AH
L
d)
)
DM _C
ve
A_
A
er
DM
s
(re
G
G
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
GDMA_AHBM_RST_INTER Write 1 and then 0 to reset the internal AHB FSM. (R/W)
PRELIMINARY
Espressif Systems 120 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
_C ST EN H0
H0 H0
ST _TE T_ _C
H0 _C _C
IN O UR T_ 0
A_ _LO _B RS CH
_R P S EN
DM IN C U N_
DM IN T NS 0
G A_ _DA RA CH
G A_ DS _B _E
DM IN _T _
G A_ EM _EN
A
R
DM M M
G A_ _ET
DM IN
)
ed
G A_
rv
DM
se
(re
G
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
GDMA_IN_RST_CHn Write 1 and then 0 to reset GDMA channel 0 RX FSM and RX FIFO pointer.(R/W)
PRELIMINARY
Espressif Systems 121 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
0
CH
R_
NE
W
_O
CK
HE
_C
IN
)
)
ed
ed
A_
rv
rv
DM
se
se
(re
(re
G
31 13 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
GDMA_IN_CHECK_OWNER_CHn Configures whether or not to enable owner bit check for RX chan-
nel n.
0: Disable
1: Enable
(R/W)
0
H
0
_C
CH
TA
P_
DA
O
_R
_P
O
FO
IF
FI
F
IN
IN
)
ed
A_
A_
rv
DM
DM
se
(re
G
31 13 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x800 Reset
PRELIMINARY
Espressif Systems 122 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
H0
_A P_ H0 0
NK TO _C H
_C
LI S T C
0
O 0
A_ LIN ST AR 0
ET
IN K_ AR T_
CH
UT CH
DM IN K S H
_R
G A_ LIN RE _C
R_
_ K
T
DD
DM IN K R
G A_ LIN PA
_A
_
_
DM IN K
NK
G A_ LIN
LI
DM _IN
IN
)
ed
A_
rv
A
DM
DM
se
(re
G
G
G
31 25 24 23 22 21 20 19 0
0 0 0 0 0 0 0 1 0 0 0 1 0x000 Reset
GDMA_INLINK_ADDR_CHn Represents the lower 20 bits of the first receive descriptor’s address.
(R/W)
PRELIMINARY
Espressif Systems 123 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
O LO _ E_ N_ n
_R P RB Hn Hn
A_ UT_ UTO OD _E _CH
Hn n
Hn _C CH
UT O W C C
DM O A M S N
_C ST K_
G A_ T_ F_ UR _E
ST _TE AC
G A_ T_ CR UR n
T
T
DM O S _ H
DM O E _B S
G A_ TD TA _C
A N
B
DM O D E
G A_ T_ M_
O
T
DM _O _E
UT
U
U
U
U
)
DM _O
ed
rv
A
A
DM
se
(re
G
G
G
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 1 0 0 0 Reset
GDMA_OUT_RST_CHn Configures the reset state of GDMA channel n TX FSM and TX FIFO pointer.
0: Release reset
1: Reset
(R/W)
PRELIMINARY
Espressif Systems 124 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
0
CH
R_
NE
W
_O
CK
HE
_C
UT
d)
)
O
ed
ve
A_
rv
er
DM
se
s
(re
(re
G
31 13 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
H0
H 0
_C
_C
TA
SH
DA
U
_W
_P
O
O
F
F
FI
FI
UT
UT
d)
O
ve
A_
A_
r
DM
DM
se
(re
G
31 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 0x0 Reset
GDMA_OUTFIFO_WDATA_CHn Represents the data that need to be pushed into GDMA FIFO. (R/W)
PRELIMINARY
Espressif Systems 125 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
TO _C H0
_S RT _C
P_ H0
0
0
LI _S TA 0
CH
CH
UT K S H
NK TA RT
O IN RE _C
R_
A_ TL K_ RK
DD
DM O IN A
G A_ TL K_P
A
K_
DM O IN
IN
G A_ TL
L
UT
U
U
U
)
DM _O
O
ed
A_
rv
A
DM
DM
se
(re
G
G
G
31 24 23 22 21 20 19 0
0 0 0 0 0 0 0 0 1 0 0 0 0x000 Reset
GDMA_OUTLINK_ADDR_CHn Represents the lower 20 bits of the first transmit descriptor’s address.
(R/W)
31 0
0x2202250 Reset
PRELIMINARY
Espressif Systems 126 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
UN ER B_C 0
R_ _C 0
1B H0
H0
N_ D 3 H
DE _2B H
AI UN R_ _C
_C
EM IN_ DE 4B
IN EM _ DE 0
A_ _R AIN UN _CH
_R A UN R_
CH 0
L_ CH
0
DM IN M _ Y
0
CH
G A_ _RE AIN GR
UL _
_F PTY
_
DM IN M N
NT
G A_ _RE _HU
FI EM
_C
IN O_
DM IN F
FO
FO
G A_ _BU
A_ IF
FI
F
DM IN
IN
DM IN
d)
d)
ve
ve
G A_
A_
G A_
er
er
DM
DM
DM
s
s
(re
(re
G
G
31 28 27 26 25 24 23 22 8 7 2 1 0
0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 Reset
PRELIMINARY
Espressif Systems 127 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
0
CH
H0
R_
DD
E_C
_A
AT
0
CR
H
ST
_C
DS
R_
E
AT
_
C
NK
DS
ST
LI
_
_
IN
IN
IN
d)
ve
A_
A_
A_
er
DM
DM
DM
s
(re
G
31 23 22 20 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
GDMA_INLINK_DSCR_ADDR_CHn Represents the lower 18 bits of the address of the next receive
descriptor that is pre-read (but not processed yet). If the current receive descriptor is the last
descriptor, then this field represents the address of the current receive descriptor. (RO)
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 128 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
H0
_C
DR
D
S _A
DE
F_
EO
R_
_ER
IN
A_
DM
G
31 0
0x000000 Reset
H0
_C
CR
DS
NK_
LI
IN
A_
DM
G
31 0
0 Reset
GDMA_INLINK_DSCR_CHn Represents the address of the next receive descriptor x+1 pointed by
the current receive descriptor that is pre-read. (RO)
31 0
0 Reset
PRELIMINARY
Espressif Systems 129 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
0
CH
F1_
_B
CR
_DS
NK
LI
IN
A_
DM
G
31 0
0 Reset
GDMA_INLINK_DSCR_BF1_CHn Represents the address of the previous receive descriptor x-1 that
is pre-read. (RO)
_C
EM IN_ DE 4B
_R A UN R_
CH 0
L_ CH
UT EM _ DE
0
0
CH
UL _
O R AIN N
_F PTY
A_ T_ EM _U
T_
N
FI _EM
N
DM O R I
_C
G A_ T_ MA
FO
UT O
FO
U E
O IF
DM O R
FI
A_ TF
G A_ T_
UT
U
U
d)
)
DM _O
DM _O
ed
ve
A_
rv
A
A
r
DM
DM
DM
se
se
(re
(re
G
G
G
G
31 27 26 25 24 23 22 8 7 2 1 0
0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 Reset
PRELIMINARY
Espressif Systems 130 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
H0
_C
H0
DR
_C
D
E
_A
AT
0
CR
H
ST
_C
DS
R_
E
AT
K_
SC
ST
IN
_D
L
_
UT
UT
UT
)
O
ed
A_
A_
A_
rv
DM
DM
DM
se
(re
G
31 23 22 20 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
GDMA_OUTLINK_DSCR_ADDR_CHn Represents the lower 18 bits of the address of the next trans-
mit descriptor that is pre-read (but not processed yet). If the current transmit descriptor is the last
descriptor, then this field represents the address of the current transmit descriptor. (RO)
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 131 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
0
CH
R_
DD
_A
ES
_D
B FR
F_
EO
_
UT
O
A_
DM
G
31 0
0x000000 Reset
H0
_C
CR
DS
N K_
LI
UT
O
A_
DM
G
31 0
0 Reset
GDMA_OUTLINK_DSCR_CHn Represents the address of the next transmit descriptor y+1 pointed
by the current transmit descriptor that is pre-read. (RO)
31 0
0 Reset
PRELIMINARY
Espressif Systems 132 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
H0
_C
F1
_B
CR
_DS
NK
LI
UT
O
A_
DM
G
31 0
0 Reset
H0
_C
RI
_P
RX
)
ed
A_
rv
DM
se
(re
G
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
A_
rv
DM
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 0 Reset
PRELIMINARY
Espressif Systems 133 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
0
CH
EL_
_S
_IN
RI
PE
)
ed
A_
rv
DM
se
(re
G
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 0x3f Reset
PRELIMINARY
Espressif Systems 134 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
3 GDMA Controller (GDMA) GoBack
0
CH
L_
_ SE
UT
_O
RI
PE
)
ed
A_
rv
DM
se
(re
G
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 0x3f Reset
PRELIMINARY
Espressif Systems 135 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
4 System and Memory GoBack
4.1 Overview
ESP32-H2 is an ultra-low power and highly-integrated system that integrates a high-performance 32-bit RISC-V
single-core processor (CPU), four-stage pipeline, clock frequency up to 96 MHz. All internal memory, external
memory, and peripherals are located on the CPU bus.
4.2 Features
• Address Space
– 452 KB of internal memory address space accessed from the instruction bus or data bus
– 16 MB of external memory virtual address space accessed from the instruction bus or data bus
• Internal Memory
– 320 KB HP SRAM
– 4 KB LP SRAM
• External Memory
– 16 KB of Cache
• Peripheral Space
– 46 modules/peripherals in total
• GDMA
– 8 GDMA-supported modules/peripherals
PRELIMINARY
Espressif Systems 136 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
4 System and Memory GoBack
Note:
• The range of addresses available in the address space may be larger than the actual available memory of a particular
type.
CPU can access data via the data bus using single-byte, double-byte, and 4-byte alignment.
• directly access the internal memory via both data bus and instruction bus.
• directly access the external memory which is mapped into the address space via cache.
PRELIMINARY
Espressif Systems 137 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
4 System and Memory GoBack
Table 4-1 lists the address ranges on the data bus and instruction bus and their corresponding target
memories.
Boundary Address
Bus Type Size Target
Low Address High Address
0x0000_0000 0x1FFF_FFFF Reserved
Data/Instruction bus 0x2000_0000 0x2FFF_FFFF 256 MB CPU Sub-system
0x3000_0000 0x3FFF_FFFF Reserved
Data/Instruction bus 0x4000_0000 0x4001_FFFF 128 KB ROM*
0x4002_0000 0x407F_FFFF Reserved
Data/Instruction bus 0x4080_0000 0x4084_FFFF 320 KB HP SRAM*
0x4085_0000 0x41FF_FFFF Reserved
Data/Instruction bus 0x4200_0000 0x42FF_FFFF 16 MB External memory
0x4300_0000 0x4FFF_FFFF Reserved
Data/Instruction bus 0x5000_0000 0x5000_0FFF 4 KB LP SRAM*
0x5000_1000 0x5FFF_FFFF Reserved
Data/Instruction bus 0x6000_0000 0x600C_FFFF 832 KB Peripherals
0x600D_0000 0xFFFF_FFFF Reserved
*
All of the internal memories are managed by Permission Control module. An internal mem-
ory can only be accessed when it is allowed by Permission Control, then the internal mem-
ory can be available to CPU. For more information about Permission Control, please refer
to Chapter 14 Access Permission Management (APM).
• ROM (128 KB): The ROM is a read-only memory and can not be programmed. It contains the ROM code
of some low-level system software and read-only data.
• HP SRAM (320 KB): The HP SRAM is a volatile memory that can be quickly accessed by CPU (generally
within a single clock cycle).
• LP SRAM (4 KB): LP SRAM is also a volatile memory, however, in Deep-sleep mode, data stored in the LP
SRAM will not be lost. The LP SRAM can be accessed by CPU and is usually used to store program
instructions and data that need to be kept in sleep mode.
1. ROM
This 128 KB ROM is a read-only memory, addressed by CPU through the instruction bus or through the data bus
via 0x4000_0000 ~ 0x4001_FFFF in the same order, as shown in Table 4-1.
This means, for example, address 0x4001_0000 can be accessed by the instruction bus or the data bus.
2. HP SRAM
This 320 KB HP SRAM is a read-and-write memory, accessed by the CPU through the instruction bus or data
bus in the same order as shown in Table 4-1.
PRELIMINARY
Espressif Systems 138 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
4 System and Memory GoBack
3. LP SRAM
This 4 KB LP SRAM is a read-and-write memory, accessed by the CPU through the instruction bus or through
the data bus via their shared address 0x5000_0000 ~ 0x5000_0FFF as shown in Table 4-1.
The CPU accesses the external memory via the cache. According to information inside the MMU (Memory
Management Unit), the cache maps the CPU’s address (0x4200_0000 ~ 0x42FF_FFFF) into a physical address
of the external memory. Due to this address mapping, ESP32-H2 can address up to 16 MB external flash. Note
that the instruction bus shares the same address space (16 MB) with the data bus to access the external
memory.
4.3.3.2 Cache
As shown in Figure 4-2, ESP32-H2 has a read-only uniform cache which is eight-way set-associative. Its size is
16 KB and its block size is 32 bytes.
The instruction bus and data bus can access the Cache simultaneously, but the Cache can only respond to one
of them at a time through arbitration. When a cache miss occurs, the cache controller will initiate a request to the
external memory.
PRELIMINARY
Espressif Systems 139 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
4 System and Memory GoBack
1. Invalidate: This operation is used to remove valid data in the cache. Once this operation is done, the
deleted data is stored only in the external memory. If the CPU wants to access the data again, it needs to
access the external memory. There are two types of invalidate operation: Invalidate-All and
Manual-Invalidate. Manual-Invalidate is performed only on data in the specified area in the cache, while
Invalidate-All is performed on all data in the cache.
2. Preload: This operation is to load instructions and data into the cache in advance. The minimum unit of
preload-operation is one block. There are two types of preload-operation: manual preload
(Manual-Preload) and automatic preload (Auto-Preload). Manual-Preload means that the hardware
prefetches a piece of continuous data according to the virtual address specified by the software.
Auto-Preload means the hardware prefetches a piece of continuous data according to the current address
where the cache hits or misses (depending on configuration).
3. Lock/Unlock: The lock operation is used to prevent the data in the cache from being easily replaced.
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, while the data outside the specified
area will not be locked. When manual lock is enabled, the cache checks the data that is already in the
cache memory and locks the data only if it falls in the specified area, and leaves the data outside the
specified area unlocked. When there are missing data, the cache will replace the data in the unlocked way
first, so the data in the locked way is always stored in the cache and will not be replaced. But when all
ways within the cache are locked, the cache will replace data, as if it was not locked. Unlocking is the
reverse of locking, except that it only can be done manually.
Please note that Invalidate-All operation only works on the unlocked data. If you expect to perform such
operation on the locked data, please unlock them first.
GDMA uses the same addresses as the data bus to access HP SRAM, i.e., GDMA uses address range
0x4080_0000 ~ 0x4084_FFFF to access HP SRAM.
Eight modules/peripherals in ESP32-H2 work together with GDMA. As shown in Figure 4-3, eight vertical lines
correspond to these eight modules/peripherals with GDMA function. The horizontal line represents a certain
channel of GDMA (can be any channel), and the intersection of the vertical line and the horizontal line indicates
that a module/peripheral has the ability to access the corresponding channel of GDMA. If there are multiple
intersections on the same line, it means that these peripherals/modules can not enable the GDMA function at the
same time.
PRELIMINARY
Espressif Systems 140 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
4 System and Memory GoBack
These modules/peripherals can access any memory available to GDMA. For more information, please refer to
Chapter 3 GDMA Controller (GDMA).
Note:
When accessing a memory via GDMA, a corresponding access permission is needed, otherwise this access may fail. For
more information about permission control, please refer to Chapter 14 Access Permission Management (APM).
Boundary Address
Target Size (KB)
Low Address High Address
UART Controller 0 (UART0) 0x6000_0000 0x6000_0FFF 4
UART Controller 1 (UART1) 0x6000_1000 0x6000_1FFF 4
External Memory Encryption and Decryption 0x6000_2000 0x6000_2FFF 4
(XTS_AES)
Reserved 0x6000_3000 0x6000_3FFF
I2C Controller 0 (I2C0) 0x6000_4000 0x6000_4FFF 4
I2C Controller 1 (I2C1) 0x6000_5000 0x6000_5FFF 4
UHCI Controller (UHCI) 0x6000_6000 0x6000_6FFF 4
Remote Control Peripheral (RMT) 0x6000_7000 0x6000_7FFF 4
Cont’d on next page
PRELIMINARY
Espressif Systems 141 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
4 System and Memory GoBack
PRELIMINARY
Espressif Systems 142 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
4 System and Memory GoBack
PRELIMINARY
Espressif Systems 143 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
5.1 Overview
ESP32-H2 contains a 4096-bit eFuse memory to store user data and hardware parameters, including control
parameters for hardware modules, calibration parameters, the MAC address, and keys used for the encryption
and decryption module. Once an eFuse bit is programmed to 1, it can never be reverted to 0. Users cannot
directly access the eFuse memory. They can only use the eFuse controller to read and write eFuse memory bits.
For confidential data in eFuse memory, read protection can be enabled by programming the corresponding read
protection bit. So, the data cannot be accessed via the controller.
5.2 Features
• 4096-bit one-time-programmable memory including 1792 bits reserved for custom use
To program data to the eFuse memory, write the data to the programming register first and then execute the
programming instruction. For detailed programming steps, please refer to Section 5.3.2.
Users cannot directly read data from the eFuse memory. They need to use the eFuse controller to take the data
into the reading data register of the corresponding address segment. During the reading process, if the data is
inconsistent with that in the eFuse memory, the eFuse controller can automatically correct it through the
hardware encoding mechanism (see Section 5.3.1.4 for details), and send the error message to the error report
register. For detailed steps to read parameters, please refer to Section 5.3.3.
PRELIMINARY
Espressif Systems 144 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
Table 5-1 lists all the parameters accessible (readable and usable) to users in BLOCK0, their offsets, bit widths,
whether they directly drive hardware modules, write protection, and brief function description. For more
description on the parameters, please click the corresponding link in the table.
The EFUSE_WR_DIS parameter is used to disable write protection of other parameters. EFUSE_RD_DIS is
used to disable read protection of BLOCK4 ~ BLOCK10. For more information, please see Section 5.3.1.2 and
Section 5.3.1.3.
PRELIMINARY
Espressif Systems 145 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
Write Protection
Bit
Parameters Hardware Use by EFUSE_WR_DIS Description
Width
Bit Number
are configured to 0.
EFUSE_SOFT_DIS_JTAG 3 Y 31 Represents whether JTAG is disabled in the soft way.
Represents whether JTAG is disabled in the hard way (per-
EFUSE_DIS_PAD_JTAG 1 Y 2
manently).
Represents whether flash encryption is disabled (except in
EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT 1 Y 2
PRELIMINARY
GoBack
Cont’d on next page
Espressif Systems
enabled.
EFUSE_KEY_PURPOSE_0 4 Y 8 Represents Key0 purpose. See Table 5-2.
EFUSE_KEY_PURPOSE_1 4 Y 9 Represents Key1 purpose. See Table 5-2.
EFUSE_KEY_PURPOSE_2 4 Y 10 Represents Key2 purpose. See Table 5-2.
EFUSE_KEY_PURPOSE_3 4 Y 11 Represents Key3 purpose. See Table 5-2.
EFUSE_KEY_PURPOSE_4 4 Y 12 Represents Key4 purpose. See Table 5-2.
EFUSE_KEY_PURPOSE_5 4 Y 13 Represents Key5 purpose. See Table 5-2.
ESP32-H2 TRM (Pre-release v0.4)
GoBack
EFUSE_SECURE_BOOT_AGGRESSIVE_REVOKE 1 N 16
enabled.
Cont’d on next page
Espressif Systems
EFUSE_HYS_EN_PAD1 22 Y 19
6-27
PRELIMINARY
GoBack
5 eFuse Controller (EFUSE) GoBack
Table 5-2 lists all key purposes and their values. Set EFUSE_KEY_PURPOSE_n to declare the purpose of KEYn
(n: 0 ~ 5).
Key
Purpose Purposes
Values
0 User purposes
1 ECDSA_KEY
2 Reserved
3 Reserved
4 XTS_AES_128_KEY (flash/SRAM encryption and decryption)
5 HMAC Downstream mode (both JTAG and DSA)
6 JTAG in HMAC Downstream mode
7 Digital Signature Algorithm peripheral in HMAC Downstream mode
8 HMAC Upstream mode
9 SECURE_BOOT_DIGEST0 (secure boot key digest)
10 SECURE_BOOT_DIGEST1 (secure boot key digest)
11 SECURE_BOOT_DIGEST2 (secure boot key digest)
PRELIMINARY
Espressif Systems 149 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
GoBack
5 eFuse Controller (EFUSE) GoBack
Among these blocks, BLOCK4 ~ 9 can be used to store KEY0 ~ 5. Up to six 256-bit keys can be written into
eFuse. Whenever a key is written, its purpose value should also be written (see table 5-2). For example, when a
key for the JTAG function in HMAC Downstream mode is written to KEY3 (i.e., BLOCK7), its key purpose value 6
should also be written to EFUSE_KEY_PURPOSE_3.
Note:
Do not program the XTS-AES key or ECDSA key into the KEY5 block, i.e., BLOCK9. Otherwise, the key may be unread-
able. Instead, program them into the preceding blocks, i.e., BLOCK4 ~ BLOCK8. The last block, BLOCK9, is used to
program other keys.
BLOCK1 ~ BLOCK10 use the RS coding scheme, so there are some limitations on writing to these parameters.
For more detailed information, please refer to Section 5.3.1.4 and Section 5.3.2.
Parameters used by hardware modules are marked with “Y” in Table 5-3 > Column “Accessible by Hardware”.
They are used by hardware modules through circuit connections. That is to say, changes to the parameter value
will directly affect how the peripheral controlled by it behaves, and this process cannot be intervened by the
user.
5.3.1.2 EFUSE_WR_DIS
Parameter EFUSE_WR_DIS determines whether individual eFuse parameters are write-protected. After
EFUSE_WR_DIS has been programmed, execute an eFuse read operation to make the new values take
effect.
Column “Write Protection by EFUSE_WR_DIS Bit Number” in Table 5-1 and Table 5-3 list the specific bits in
EFUSE_WR_DIS that disable writing.
When a write protection bit is set to 0, the corresponding parameter is not write-protected and can be
programmed, unless it has been programmed before.
When the write protection bit is set to 1, the corresponding parameter is write-protected and none of its bits can
be modified, with non-programmed bits always remaining 0 and programmed bits always remaining 1. That is to
say, if a parameter is write-protected, it will always remain in this state and cannot be changed.
5.3.1.3 EFUSE_RD_DIS
Only the parameters in BLOCK4 ~ BLOCK10 can be set to be read-protected from users, as shown in column
“Read Protection by EFUSE_RD_DIS Bit Number” of Table 5-3. After EFUSE_RD_DIS has been programmed,
execute an eFuse read operation to make the new values take effect.
If an EFUSE_RD_DIS bit is 0, the corresponding parameter is not read-protected from users. If it is 1, the
parameter is read-protected.
Other parameters that are not in BLOCK4 ~ BLOCK10 can always be read by users.
When BLOCK4 ~ BLOCK10 are set to be read-protected, the data in them can still be read by hardware
cryptography modules if the EFUSE_KEY_PURPOSE_n bit is set accordingly.
PRELIMINARY
Espressif Systems 151 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
Internally, eFuse uses the hardware encoding scheme to protect data from corruption. The scheme and the
encoding process are invisible to users.
All BLOCK0 parameters except for EFUSE_WR_DIS are stored with four backups, meaning each bit is stored
four times. This backup scheme is not visible to users.
In BLOCK0, EFUSE_WR_DIS occupies 32 bits, and other parameters takes 152 bits each. So, the total eFuse
memory space occupied by BLOCK0 is 32 + 152 * 4 = 640 bits.
In BLOCK1 ~ BLOCK10, data are coded using Reed-Solomon’s RS (44, 32) coding scheme that supports up to
6 bytes of automatic error correction. The primitive polynomial of RS (44, 32) is
p(x) = x8 + x4 + x3 + x2 + 1.
As shown in Figure 5-2 and 5-3, the shift register circuit processes the 32-byte parameters using RS (44, 32) and
encodes them into 44 bytes:
• Bytes [32:43] are the encoded parity bytes stored in 8-bit flip-flops DFF1, DFF2, ..., DFF12 (gf_mul_n is the
result of multiplying a byte of data in GF (28 ) by αn , where n is an integer).
After that, the hardware programs into eFuse the 44-byte codeword consisting of the data bytes and the parity
PRELIMINARY
Espressif Systems 152 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
bytes. When the eFuse block is read, the eFuse controller automatically decodes the codeword and applies error
correction if needed.
Because the RS check codes are generated on the entire 32-byte eFuse block, each block can only be written
once.
Since the size of BLOCK1 is less than 32 bytes, the unused bits will be treated as 0 by hardware during the RS
(44, 32) encoding. Thus, the final coding result will not be affected.
Among blocks using the RS (44, 32) coding scheme, the parameters in BLOCK1 is 24 bytes, and the RS check
code is 12 bytes, so BLOCK1 occupies 24 + 12 = 36 bytes in eFuse memory.
The parameter in other blocks (Block2 ~ 10) is 32 bytes respectively, and the RS check code is 12 bytes, so they
occupy (32 + 12) * 9 = 396 bytes in eFuse memory.
Since there is a one-to-one correspondence between the reading data registers and the programming data
registers (see table 5-4 for details), users can find out where the data to be programmed is located in
programming registers by checking the parameter description and the parameter location in the corresponding
reading data registers.
For example, if the user wants to program the parameter EFUSE_DIS_ICACHE in BLOCK0 to 1, they can first
search the reading data registers EFUSE_RD_REPEAT_DATA0 ~ 4_REG in BLOCK0 for where the parameter is
located, namely, the 8th bit in EFUSE_RD_REPEAT_DATA0_REG. So, the user can set the 8th bit of
EFUSE_PGM_DATA1_REG to 1 and follow the programming steps below. After the steps are completed, the
corresponding bit in the eFuse memory will be programmed to 1.
Programming preparation
• Programming BLOCK0
1. Set EFUSE_BLK_NUM to 0.
• Programming BLOCK1
1. Set EFUSE_BLK_NUM to 1.
• Programming BLOCK2 ~ 10
PRELIMINARY
Espressif Systems 153 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
Programming process
3. Make sure the eFuse programming voltage VDDQ is configured correctly as described in Section 5.3.4.
6. Poll register EFUSE_CMD_REG until it is 0x0, or wait for a PGM_DONE interrupt. For more information on
how to identify a PGM_DONE or READ_DONE interrupt, please see the end of Section 5.3.3.
8. Trigger an eFuse read operation (see Section 5.3.3) to update eFuse registers with the new values.
9. Check error record registers. If the values read in error record registers are not 0, the programming process
should be performed again following above steps 1 ~ 7. Please check the following error record registers
for different eFuse blocks:
Limitations
In BLOCK0, each bit can be programmed separately. However, we recommend to 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
PRELIMINARY
Espressif Systems 154 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
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 in one programming action.
The eFuse controller reads eFuse memory to update corresponding registers. This read operation happens at
system reset and can also be triggered manually by users as needed (e.g., if new eFuse values have been
programmed). The process of triggering a read operation by users is as follows:
3. Poll register EFUSE_CMD_REG until it is 0x0, or wait for a READ_DONE interrupt. Information on how to
identify a PGM_DONE or READ_DONE interrupt is provided below in this section.
The eFuse reading data registers will hold all values until the next read operation.
Error detection
Error record registers allow users to detect if there is any inconsistency between the parameter read by eFuse
controller and that in eFuse memory.
Registers EFUSE_RD_REPEAT_ERR0 ~ 3_REG indicate if there are any errors in programming parameters
(except EFUSE_WR_DIS) to BLOCK0. The value 1 indicates an error is detected in programming the
corresponding bit. The 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 when eFuse controller reads BLOCK1 ~ BLOCK10.
The values of the above registers will be updated every time the reading data registers of eFuse controller have
been updated.
PRELIMINARY
Espressif Systems 155 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
The methods to identify the completion of a program/read operation are described below. Please note that bit 1
corresponds to a program operation, and bit 0 corresponds to a read operation.
• Method one: Poll bit 1/0 in register EFUSE_INT_RAW_REG until it becomes 1, which represents the
completion of a program/read operation.
• Method two:
1. Set bit 1/0 in register EFUSE_INT_ENA_REG to 1 to enable the eFuse controller to post a
PGM_DONE or READ_DONE interrupt.
2. Configure the Interrupt Matrix to enable the CPU to respond to eFuse interrupt signals. See Chapter 9
Interrupt Matrix (INTMTX).
4. Set bit 1/0 in register EFUSE_INT_CLR_REG to 1 to clear the PGM_DONE or READ_DONE interrupt.
Note
When eFuse controller is updating its registers, it will use EFUSE_PGM_DATAn_REG (n=0, 1, ... ,7) again to store
data. So please do not write important data into these registers before this updating process is initiated.
During the chip boot process, eFuse controller will automatically update data from eFuse memory into the
registers that can be accessed by users. Users can get programmed eFuse data by reading corresponding
registers. Thus, there is no need to update the reading data registers in such case.
• EFUSE_DAC_NUM (the rising period of VDDQ): The default value of VDDQ is 2.5 V and the voltage
increases by 0.01 V in each clock cycle. The default value of this parameter is 255.
• EFUSE_DAC_CLK_DIV (the clock divisor of VDDQ): The clock period to program VDDQ should be larger
than 1 µs.
• EFUSE_PWR_ON_NUM (the power-up time for VDDQ): The programming voltage should be stabilized after
this time, which means the value of this parameter should be configured to exceed the result of
EFUSE_DAC_CLK_DIV times EFUSE_DAC_NUM.
• EFUSE_PWR_OFF_NUM (the power-out time for VDDQ): The value of this parameter should be larger than
10 µs.
PRELIMINARY
Espressif Systems 156 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
5.3.6 Interrupts
• PGM_DONE interrupt: Triggered when eFuse programming has finished. To enable this interrupt, set the
EFUSE_PGM_DONE_INT_ENA field of register EFUSE_INT_ENA_REG to 1.
• READ_DONE interrupt: Triggered when eFuse reading has finished. To enable this interrupt, set the
EFUSE_READ_DONE_INT_ENA field of register EFUSE_INT_ENA_REG to 1.
PRELIMINARY
Espressif Systems 157 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 158 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
PRELIMINARY
Espressif Systems 159 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
PRELIMINARY
Espressif Systems 160 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
PRELIMINARY
Espressif Systems 161 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
5.5 Registers
The addresses in this section are relative to eFuse controller base address provided in Table 4-2 in Chapter 4
System and Memory.
0
A_
AT
_D
M
PG
E_
US
EF
31 0
0x000000 Reset
1
A_
AT
_D
M
PG
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 162 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
3
A_
AT
_D
M
PG
E_
US
EF
31 0
0x000000 Reset
4
A_
AT
_D
M
PG
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 163 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
7
A_
AT
_D
M
PG
E_
US
EF
31 0
0x000000 Reset
_0
TA
DA
S_
_R
M
PG
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 164 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
2
A_
AT
_D
S
_R
M
PG
E_
US
EF
31 0
0x000000 Reset
S
DI
R_
W
E_
US
EF
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 165 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
T
YP
CR
EN
L_
O IS
UA
NL _D
AD
W I
AN
O SP
R V _0
ER 0_1
_2
_4
AG _M
_D _M
E
T4 CH G N
G IO
0
D0
D0
S
BL
RP CA JTA _E
RE VED
IN
JT D
CE AD
P
AG
E
VE
VE
(re E_ I_D AI NA
E_ _I _ H
D_ OA
CH G
_P
US ) O LO
C
_
ER
ER
JT
US SP W E
EX S
PA NL
US DI S IT
_R E
SE
_
B_ I_A
EF rve IS_ WN
_
EF E_ S_ GL
ES
ES
ES
EF E_ S_ EL
IS
S_ W
B
R
US SP
_D
_R
EF SE_ 4_R
US DI ER
US DI _S
DI O
se D O
IS
_
E_ S_D
U
T
_D
E_ D_
FT
T4
T4
EF E_ AG
EF SE_ OW
T
S
SO
RD
EF _RP
EF _RP
EF _RP
US VD
US JT
US DI
)
U P
ed
d
EF E_
E_
EF E_
EF E_
E_
E
rv
US
US
US
US
US
US
US
se
U
EF
EF
EF
EF
EF
(re
31 30 29 28 27 26 25 24 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 0
EFUSE_RD_DIS Represents whether reading of individual eFuse block (BLOCK4 ~ BLOCK10) is dis-
abled.
1: Disabled
0: Enabled
(RO)
EFUSE_DIS_FORCE_DOWNLOAD Represents whether the function that forces chip into download
mode is disabled.
1: Disabled
0: Enabled
(RO)
PRELIMINARY
Espressif Systems 166 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
EFUSE_SOFT_DIS_JTAG Represents whether JTAG is disabled in the soft way. It can be restarted
via HMAC.
Odd count of bits with a value of 1: Disabled
Even count of bits with a value of 1: Enabled
(RO)
PRELIMINARY
Espressif Systems 167 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
PRELIMINARY
Espressif Systems 168 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
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_
1
1_
T_
RE BO _K
_1
_0
ED
EL
YP
CU E_ OT
SE
SE
_S
RV
CR
SE R O
O
AY
SE
T_
E_ CU _B
P
RP
EL
UR
E
O
E
PU
_R
O
_D
US SE R
_P
B
EF SE_ ECU
T4
Y_
DT
I_
EY
RP
SP
KE
W
K
U S
E_
E_
EF E_
E_
E_
E_
US
US
US
US
US
US
EF
EF
EF
EF
EF
EF
31 28 27 24 23 22 21 20 18 17 16 15 0
PRELIMINARY
Espressif Systems 169 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
KE
VO
K
E_
RE
AR
E_
W
IV
RD
F E N SS
HA
E_ SA_ PA_ _E RE
E_
DP CE LE
D D OT GG
_0
S
C_ OR NAB
D2
EF _EC PT_ BO _A
_U
_5
_4
_3
_2
L
VE
VE
E Y E_ OT
SE
SE
SE
SE
W
ER
LE
US CR R O
O
PU
RP
RP
RP
RP
ES
A_
_T
PU
PU
PU
PU
R
U S R
SH
4_
EF E_ CU
Y_
Y_
Y_
Y_
PT
A
KE
KE
KE
KE
US SE
SE
FL
R
E_
E_
EF E_
E_
E_
E_
E_
US
US
US
US
US
US
US
US
EF
EF
EF
EF
EF
EF
EF
31 28 27 22 21 20 19 18 17 16 15 12 11 8 7 4 3 0
EFUSE_FLASH_TPUW Represents the flash waiting time after power-up. Measurement unit: ms.
When the value is less than 15, the waiting time is the programmed value. Otherwise, the waiting
time is a fixed value, i.e. 30 ms. (RO)
PRELIMINARY
Espressif Systems 171 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
DE
O
_M
E
AK
AD
NT
W
RI
O D
T_
NL
_P
S_ E RI _ _D OA
S
M
FA
DI IR SE D3 G L
O
E_ S_D B_ VE JTA WN
E_
O T _R
DE
L
BL
US DI S ER L_ O
NL OO AG
RO
UM
D
SA
O
DO CT AL 5
EF E_ S_ ES RIA Y_
W _B _JT
NT
_M
ES
N
DI
US DI _R SE IT
IO
AD
T_
_R
EF E_ T4 B_ UR
US DI LE _C
RS
0
ND
US RP US EC
AD
EF E_ AB NT
O
VE
_B
EF _UA _SE
_P
EF E_ S_ _S
US EN PRI
E_
E
EN
UR
UR
U
RC
RT
S_
EC
EC
HY
EF _FO
_S
_S
E_
EF E_
E
E
US
US
US
US
US
US
EF
EF
EF
EF
31 26 25 24 9 8 7 6 5 4 3 2 1 0
PRELIMINARY
Espressif Systems 172 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
PRELIMINARY
Espressif Systems 173 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_1
4_
D4
ED
VE
1
RV
D
ER
PA
SE
N_
RE
RE
_E
_
_
T4
T4
YS
RP
RP
_H
E_
E_
E
US
US
US
EF
EF
EF
31 24 23 22 21 0
31 0
0x000000 Reset
_1
AC
AC
_M
M
E_
E
US
US
EF
EF
31 16 15 0
PRELIMINARY
Espressif Systems 174 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_1
D_
ED
VE
RV
ER
SE
ES
E
_R
_R
AC
AC
M
M
E_
E_
US
US
EF
EF
31 14 13 0
_2
T0
ED
AR
RV
_P
SE
TA
RE
DA
_
S_
AC
SY
M
E_
E_
US
US
EF
EF
31 16 15 0
EFUSE_SYS_DATA_PART0_0 Represents the 1st 16 bits of the zeroth part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART0_1 Represents the 1st 32 bits of the zeroth part of system data. (RO)
PRELIMINARY
Espressif Systems 175 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_2
T0
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART0_2 Represents the 2nd 32 bits of the zeroth part of system data. (RO)
_0
RT1
PA
A_
AT
D
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_0 Represents the zeroth 32 bits of the 1st part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_1 Represents the 1st 32 bits of the 1st part of system data. (RO)
PRELIMINARY
Espressif Systems 176 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_2
T1
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_2 Represents the 2nd 32 bits of the 1st part of system data. (RO)
_3
RT1
PA
A_
AT
D
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_3 Represents the 3rd 32 bits of the 1st part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_4 Represents the 4th 32 bits of the 1st part of system data. (RO)
PRELIMINARY
Espressif Systems 177 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_5
T1
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_5 Represents the 5th 32 bits of the 1st part of system data. (RO)
_6
RT1
PA
A_
AT
D
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_6 Represents the 6th 32 bits of the 1st part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_7 Represents the 7th 32 bits of the 1st part of system data. (RO)
PRELIMINARY
Espressif Systems 178 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
0
TA
DA
R_
US
E_
US
EF
31 0
0x000000 Reset
1
TA
DA
R_
US
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 179 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
4
TA
DA
R_
US
E_
US
EF
31 0
0x000000 Reset
5
TA
DA
R_
US
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 180 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A0
AT
_D
Y0
KE
E_
US
EF
31 0
0x000000 Reset
A1
AT
_D
Y0
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 181 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A4
AT
_D
Y0
KE
E_
US
EF
31 0
0x000000 Reset
A5
AT
_D
Y0
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 182 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A0
AT
_D
Y1
KE
E_
US
EF
31 0
0x000000 Reset
A1
AT
_D
Y1
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 183 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A4
AT
_D
Y1
KE
E_
US
EF
31 0
0x000000 Reset
A5
AT
_D
Y1
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 184 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A0
AT
_D
Y2
KE
E_
US
EF
31 0
0x000000 Reset
A1
AT
_D
Y2
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 185 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A4
AT
_D
Y2
KE
E_
US
EF
31 0
0x000000 Reset
A5
AT
_D
Y2
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 186 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A0
AT
_D
Y3
KE
E_
US
EF
31 0
0x000000 Reset
A1
AT
_D
Y3
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 187 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A4
AT
_D
Y3
KE
E_
US
EF
31 0
0x000000 Reset
A5
AT
_D
Y3
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 188 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A0
AT
_D
Y4
KE
E_
US
EF
31 0
0x000000 Reset
A1
AT
_D
Y4
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 189 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A4
AT
_D
Y4
KE
E_
US
EF
31 0
0x000000 Reset
A5
AT
_D
Y4
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 190 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A0
AT
_D
Y5
KE
E_
US
EF
31 0
0x000000 Reset
A1
AT
_D
Y5
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 191 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
A4
AT
_D
Y5
KE
E_
US
EF
31 0
0x000000 Reset
A5
AT
_D
Y5
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 192 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_0
T2
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_0 Represents the 0th 32 bits of the 2nd part of system data. (RO)
_1
RT2
PA
A_
AT
D
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_1 Represents the 1st 32 bits of the 2nd part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_2 Represents the 2nd 32 bits of the 2nd part of system data. (RO)
PRELIMINARY
Espressif Systems 193 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_3
T2
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_3 Represents the 3rd 32 bits of the 2nd part of system data. (RO)
_4
RT2
PA
A_
AT
D
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_4 Represents the 4th 32 bits of the 2nd part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_5 Represents the 5th 32 bits of the 2nd part of system data. (RO)
PRELIMINARY
Espressif Systems 194 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_6
T2
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_6 Represents the 6th 32 bits of the 2nd part of system data. (RO)
_7
T2
R
PA
A_
AT
D
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_7 Represents the 7th 32 bits of the 2nd part of system data. (RO)
PRELIMINARY
Espressif Systems 195 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
RR
_E
PT
RY
_E RR
NC
RR
AD E
_E
O IS_
AL
ER 0_E 0
D0 R_1
_2
_4
NL _D
R_
ES _ER R R
RR U
_E R
RR
RR
RR
ER
_R E _ER ER
W I
_E AN
NS R
RV _ER
O SP
RR
PI E
_E
_E
EF rve IS_ WN R E_
T4 CH G N_
_
AG _M
M
G PIO
0
D0
_E
se D O ER BL
E_ D_
RP CA JTA _E
ER R
RE VED
JT D
AG
E
VE
VE
(re E_ I_D I_ A
E_ _I _ H
D_ OA
CH _G
RC A
D
N
_
U d) FO LO
C
ER
JT
RR
US SP TW _E
EX S
PA NL
US DI S IT
SE
B_ I_A
EF SE_ IS_ GL
ES
ES
EF E_ S_ EL
IS
_E
S_ W
B
US SP
_D
_R
EF SE_ 4_R
U D ER
US DI _S
DI O
IS
_
E_ S_D
_D
E_ D_
FT
T4
T4
EF E_ G
EF E_ W
T
S
SO
US PO
RD
EF _RP
EF _RP
EF _RP
US VD
US JT
US DI
)
ed
EF E_
E_
EF E_
EF SE_
E_
E
rv
US
US
US
US
US
US
US
se
U
EF
EF
EF
EF
EF
(re
31 30 29 28 27 26 25 24 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 0
EFUSE_RD_DIS_ERR Any bit of this field being 1 represents a programming error of RD_DIS. (RO)
PRELIMINARY
Espressif Systems 196 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
PRELIMINARY
Espressif Systems 197 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
VO E1_ R
0_ R
R
RE K ER
KE ER
ER
Y_ VO E2_
RR
KE RE K
T_ _ O
0
E
O EY V
R_
T_
O _K RE
RR
RR
RR
CN
ER
_B OT EY_
_E
_E
1_
_E
T_
RE BO _K
_1
_0
ED
EL
YP
CU E_ OT
SE
SE
_S
RV
CR
SE R O
PO
PO
AY
SE
T_
E_ CU _B
EL
UR
UR
E
O
E
_R
O
_D
US SE R
_P
_P
B
EF E_ CU
T4
DT
I_
EY
EY
RP
SP
US SE
W
_K
_K
EF E_
E_
E_
E_
E
SE
US
US
US
US
US
U
EF
EF
EF
EF
EF
EF
31 28 27 24 23 22 21 20 18 17 16 15 0
PRELIMINARY
Espressif Systems 198 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
RR
_E
R
ER
KE
K_
VO
E_
RE
AR
DP CE LE R E_
W
C_ OR NAB ER SIV
D
_H R
_0
AR
F E N_ S
SE ER
E_ SA_ PA_ _E RE
RR
RR
RR
RR
_U _
RR
R
D D OT GG
_E
_E
_E
_E
_E
E
RR
D2
EF _EC PT_ BO _A
L_
_5
_4
_3
_2
_E
VE
VE
E Y E_ OT
SE
SE
SE
SE
W
ER
LE
US CR R O
O
PU
EF E_ CU _B
RP
RP
RP
RP
ES
A_
_T
PU
PU
PU
PU
R
US SE R
SH
4_
EF E_ CU
Y_
Y_
Y_
Y_
PT
LA
KE
KE
KE
KE
US SE
SE
_R
_F
EF E_
E_
E_
E_
E_
E
E
US
US
US
US
US
US
US
US
EF
EF
EF
EF
EF
EF
EF
31 28 27 22 21 20 19 18 17 16 15 12 11 8 7 4 3 0
PRELIMINARY
Espressif Systems 199 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
RR
_E
DE
R
ER
O
_M
E_
O R
AK
AD
NL R
W _E
W
O D
T_
_D A
S
G LO
RR
AL _D RR
R
FA
NT _ER
TA N
_E
E
E_
_J OW
L_
_M RR
DE
BL
RR
E
RO
UM
AD E
A
O
E
O T_
IS
R
N_
RI Y
ES
ER
T
D
NL OO
IO
SE RI
DO CT R
T_
_R
_
_C
S_ E ER
RS
B_ U
D0
W _B
O
ND
US d) US EC
(re E_ AB NT
O
DI IR T_
VE
PA
_B
EF _UA _SE
E_ _D IN
US EN PRI
E_
_
RE
US DI PR
EN
UR
se D L
_
RC
CU
RT
EF E_ B_
S_
EC
S
HY
US US
EF _FO
SE
_S
E_
E_
EF E_
EF E_
E
E
US
US
US
US
US
US
EF
EF
EF
EF
31 26 25 24 9 8 7 6 5 4 3 2 1 0
PRELIMINARY
Espressif Systems 200 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
_0
_1
RR
RR
_E
_E
R
D4
D4
ER
VE
VE
1_
D
R
ER
PA
SE
ES
N_
RE
_R
_E
_
T4
T4
YS
RP
RP
_H
E_
E_
E
US
US
US
EF
EF
EF
31 24 23 22 21 0
PRELIMINARY
Espressif Systems 201 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
M
UM
UM
NU
_N
R_
_N
L
UM
UM
UM
UM
UM
RR
L
AI
ER
RR
IL
AI
_F
FA
_N
_N
_N
_N
_E
_F
1_
_E
T1
R_
_
TA
TA
RR
RR
RR
RR
RT
L
IL
YS
YS
I
AI
AI
AI
R
ER
FA
DA
DA
PA
PA
_E
_E
_E
_E
_F
_F
_F
_F
_S
_S
4_
3_
R_
R_
Y4
Y3
Y2
Y1
Y1
Y0
Y0
S_
S_
AC
AC
EY
EY
EY
US
US
KE
KE
KE
KE
KE
KE
KE
SY
SY
M
_K
_K
_K
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
SE
SE
E
US
US
US
US
US
US
US
US
US
US
US
US
US
US
U
U
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
UM
_N
RR
L
UM
AI
_E
_F
_N
T2
T2
RR
L
AI
AR
R
PA
_E
_F
_P
Y5
Y5
S_
S
SY
KE
KE
)
_S
ed
E_
E_
E_
SE
rv
US
US
US
se
U
EF
EF
EF
EF
(re
31 8 7 6 4 3 2 0
PRELIMINARY
Espressif Systems 203 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
PD ON
E_ E_
_F K_F PU
RC C
O OR
EM L _
M _C CE
E_ EM OR
EN
US M _F
K_
EF SE_ EM
CL
U M
)
)
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
EFUSE_CLK_EN Configures whether to force enable eFuse register configuration clock signal.
1: Force
0: The clock is enabled only during the reading and writing of registers
(R/W)
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 0x00 Reset
PRELIMINARY
Espressif Systems 204 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
NT
_C
IT
_B
ID
AL
_V
E
K0
AT
BL
ST
d)
)
ed
E_
E_
ve
rv
US
US
er
se
s
EF
EF
(re
(re
31 20 19 10 9 4 3 0
D
AD MD
M
M
_C
NU
RE _C
K_
E_ M
US PG
BL
)
ed
E_
EF 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 Represents the serial number of the block to be programmed. Value 0-10 corre-
sponds to block number 0-10, respectively. (R/W)
PRELIMINARY
Espressif Systems 205 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
AW
NT W
_I RA
_R
NE _
O INT
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
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_
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
NA
NT A
_I EN
_E
NE _
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
PRELIMINARY
Espressif Systems 206 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
LR
NT R
_I CL
_C
NE _
O INT
_D E_
AD ON
RE _D
E_ M
US PG
d)
EF SE_
ve
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
EL
_S
AD
V
DI
_P
K_
M
LK
NU
CL
R
C
CL
C_
C_
C_
E_
DA
DA
DA
O
d)
E_
E_
E_
E_
e
rv
US
US
US
US
se
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 Configures the division factor of the rising clock of the programming voltage.
(R/W)
EFUSE_DAC_NUM Configures the rising period of the programming voltage. Measurement unit:
Divided clock frequency by EFUSE_DAC_CLK_DIV. (R/W)
PRELIMINARY
Espressif Systems 207 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
M
NU
T_
NI
_A
_I
_A
AD
UR
HR
RD
RE
TS
_T
_T
E_
E_
E
US
US
US
US
EF
EF
EF
EF
31 24 23 16 15 8 7 0
EFUSE_THR_A Configures the read hold time. Measurement unit: One cycle of the eFuse core clock.
(R/W)
EFUSE_TRD Configures the read time. Measurement unit: One cycle of the eFuse core clock. (R/W)
EFUSE_TSUR_A Configures the read setup time. Measurement unit: One cycle of the eFuse core
clock. (R/W)
EFUSE_READ_INIT_NUM Configures the waiting time of reading eFuse memory. Measurement unit:
One cycle of the eFuse core clock. (R/W)
_A
O
A
R_
UP
P_
PW
H
TS
_T
E_
E_
SE
US
US
U
EF
EF
EF
31 24 23 8 7 0
EFUSE_TSUP_A Configures the programming setup time. Measurement unit: One cycle of the eFuse
core clock. (R/W)
EFUSE_PWR_ON_NUM Configures the power up time for VDDQ. Measurement unit: One cycle of
the eFuse core clock. (R/W)
EFUSE_THP_A Configures the programming hold time. Measurement unit: One cycle of the eFuse
core clock. (R/W)
PRELIMINARY
Espressif Systems 208 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
5 eFuse Controller (EFUSE) GoBack
UM
_N
FF
O
M
R_
G
PW
TP
E_
E_
US
US
EF
EF
31 16 15 0
EFUSE_PWR_OFF_NUM Configures the power outage time for VDDQ. Measurement unit: One cycle
of the eFuse core clock. (R/W)
EFUSE_TPGM Configures the active programming time. Measurement unit: One cycle of the eFuse
core clock. (R/W)
E
IV
CT
NA
TE
_I
M
DA
G
UP
TP
d)
)
ed
ed
E_
E_
e
rv
rv
rv
US
US
se
se
se
EF
EF
(re
(re
(re
31 21 20 13 12 11 1 0
EFUSE_TPGM_INACTIVE Configures the inactive programming time. Measurement unit: One cycle
of the eFuse core clock. (R/W)
E_
rv
US
se
EF
(re
31 28 27 0
0 0 0 0 0x2206300 Reset
PRELIMINARY
Espressif Systems 209 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
6.1 Overview
The ESP32-H2 chip features 19 GPIO pins. Each pin can be used as a general-purpose I/O, or be connected to
an internal peripheral signal. Through GPIO matrix and IO MUX, peripheral input signals can be from any IO pins,
and peripheral output signals can be routed to any IO pins. Together these modules provide highly configurable
I/O.
Note that the GPIO pins are numbered from GPIO0 ~ GPIO5, GPIO8 ~ GPIO14, and GPIO22 ~
GPIO27.
6.2 Features
GPIO matrix has the following features:
• A full-switching matrix between the peripheral input/output signals and the GPIO pins.
• 78 peripheral input signals sourced from the input of any GPIO pins.
• Signal synchronization for peripheral inputs based on IO MUX operating clock. For more information
about the operating clock of IO MUX, please refer to Section 7 Reset and Clock.
• Glitch Filter hardware for second time filtering on the input signal.
• Better high-frequency digital performance achieved by some digital signals (SPI, JTAG, UART) bypassing
GPIO matrix. In this case, IO MUX is used to connect these pins directly to peripherals.
• A configuration register IO_MUX_GPIOn_REG provided for each GPIO pin. The pin can be configured to
PRELIMINARY
Espressif Systems 210 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
1. Only part of peripheral input signals (marked “yes” in column “Direct input through IO MUX” in Table 6-2)
can bypass GPIO matrix. The other input signals can only be routed to peripherals via GPIO matrix.
2. There are only 19 inputs from GPIO SYNC to GPIO matrix, since ESP32-H2 provides 19 GPIO pins in total.
3. GPIO pins are controlled by the signals: IE, OE, WPU, and WPD.
4. Only part of peripheral outputs (marked “yes” in column “Direct output through IO MUX” in Table 6-2) can be
routed to pins bypassing GPIO matrix. The other output signals can only be routed to pins via GPIO matrix.
5. There are 19 outputs (corresponding to GPIO pin X: 0 ~ 5, 8 ~ 14, 22 ~ 27) from GPIO matrix to IO MUX.
Figure 6-2 shows the internal structure of a pad, which is an electrical interface between the chip logic and the
GPIO pin. The structure is applicable to all 19 GPIO pins and can be controlled using IE, OE, WPU, and WPD
signals.
PRELIMINARY
Espressif Systems 211 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
• Bonding pad: a terminal point of the chip logic used to make a physical connection from the chip die to
GPIO pin in the chip package
As shown in Figure 6-1, when GPIO matrix is used to input a signal from the pin, all external input signals are
sourced from the GPIO pins and then filtered by the GPIO Filter, as shown in Step 2 in Section 6.4.3.
The Glitch Filter hardware can filter eight of the output signals from the GPIO Filter, and the other unselected
signals go directly to the GPIO SYNC hardware, as shown in Step 3 in Section 6.4.3.
All signals filtered by the GPIO Filter hardware or the Glitch Filter hardware are synchronized by the GPIO SYNC
hardware to IO MUX operating clock and then enter the GPIO matrix, see Section 6.4.2. Such signal filtering and
synchronization features apply to all GPIO matrix signals but do not apply when using the IO MUX.
PRELIMINARY
Espressif Systems 212 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
GPIO_PINx_SYNC1_BYPASS[0]
GPIO_PINx_SYNC1_BYPASS[1]
GPIO Input
0
GPIO_PINx_SYNC2_BYPASS[0]
0
negative GPIO_PINx_SYNC2_BYPASS[1]
1
sync
0
positive 1 0
sync
negative 1
sync
positive 1
sync
First-level synchronizer
Second-level synchronizer
Figure 63. GPIO Input Synchronized on Rising Edge or on Falling Edge of IO MUX Operating Clock
Figure 6-3 shows the functionality of GPIO SYNC. In the figure, negative sync and positive sync mean GPIO input
is synchronized on falling edge and on rising edge of IO MUX operating clock respectively.
The synchronization function is disabled by default by the synchronizer, i.e., GPIO_PINx_SYNC1/2_BYPASS [1:0]
= 0. But when an asynchronous peripheral signal is connected to the pin, the signal should be synchronized by
the two-level synchronizer (i.e., the first-level synchronizer and the second-level synchronizer as shown in Figure
6-3) to lower the probability of causing metastability. For more information, see Step 4 in the following
section.
Note that some peripheral signals have no valid GPIO_SIGy_IN_SEL bit, namely, these peripherals can only
receive input signals via GPIO matrix.
2. Optionally enable the GPIO Filter for pin input signals by setting IO_MUX_GPIOx_FILTER_EN. Only the
signals with a valid width of more than two clock cycles can be sampled, see Figure 6-4.
PRELIMINARY
Espressif Systems 213 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
3. Glitch filter hardware supports eight channels, each of which selects one signal from the 19 (0 ~ 5, 8 ~ 14,
22 ~ 27) output signals from the GPIO Filter hardware and conducts the second-time filtering on the
selected signal. This Glitch Filter hardware can be used to filter slow-speed signals. To enable this feature,
follow the steps below:
4. Synchronize GPIO input signals. To do so, please set GPIO_PINx_REG corresponding to GPIO pin X as
follows:
• Set GPIO_PINx_SYNC1_BYPASS to enable input signal synchronized on rising edge or on falling edge
in the first-level synchronization, see Figure 6-3.
• Set GPIO_PINx_SYNC2_BYPASS to enable input signal synchronized on rising edge or on falling edge
in the second-level synchronization, see Figure 6-3.
PRELIMINARY
Espressif Systems 214 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
5. Configure IO MUX register to enable pin input. For this end, please set IO_MUX_GPIOx_REG
corresponding to GPIO pin X as follows:
For example, to connect I2S MSCK input signal 3 (I2S_MCLK_in, signal index 12) to GPIO3, please follow the
steps below. Note that GPIO3 is also named as MTDO pin.
Note:
3. It is possible to have a peripheral read a constantly low or constantly high input value without connecting this input
to a pin. This can be done by selecting a special GPIO_FUNCy_IN_SEL input, instead of a GPIO number:
• When GPIO_FUNCy_IN_SEL is set to 0x3C, input signal is always 0.
• When GPIO_FUNCy_IN_SEL is set to 0x38, input signal is always 1.
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 pin to GPIO function. This enables the GPIO output signal to be connected to the
pin.
PRELIMINARY
Espressif Systems 215 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
Note:
There is a range of peripheral output signals (97 ~ 100 in Table 6-2) which are not connected to any peripheral, but to the
input signals (97 ~ 100) directly.
To output peripheral signal Y to a particular GPIO pin X1 , follow the steps below:
• 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,
corresponding to GPIO pin X. To have the output enable signal decided by internal logic (for example,
the SPIQ_oe in column “Output enable signal when GPIO_FUNCn_OEN_SEL = 0” in Table 6-2), clear
the GPIO_FUNCx_OEN_SEL bit instead.
• Set the corresponding bit in register GPIO_ENABLE_W1TC_REG to disable the output from the GPIO
pin.
2. For an open drain output, set the GPIO_PINx_PAD_DRIVER bit in register GPIO_PINx_REG corresponding
to GPIO pin X.
3. Configure IO MUX register to enable output via GPIO matrix. Set IO_MUX_GPIOx_REG corresponding to
GPIO pin X as follows:
• Set the field IO_MUX_GPIOx_MCU_SEL to desired IO MUX function corresponding to GPIO pin X.
This is Function 1 (GPIO function), numeric value 1, for all pins.
• Set the IO_MUX_GPIOx_FUN_DRV field to the desired value for output strength (0 ~ 3). The higher the
drive strength, the more current can be sourced/sunk from the pin.
– 0: ~5 mA
– 1: ~10 mA
– 2: ~20 mA (default)
– 3: ~40 mA
Note:
1. The output signal from a single peripheral can be sent to multiple pins simultaneously.
PRELIMINARY
Espressif Systems 216 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
• Set GPIO matrix GPIO_FUNCn_OUT_SEL with a special peripheral index 128 (0x80);
• Set the corresponding bit in GPIO_OUT_REG register to the desired GPIO output value.
Note:
Four out of the 99 peripheral output signals (index: 83 ~ 86 in Table 6-2 support 1-bit second-order sigma delta
modulation. By default the output is enabled for these four channels. This Sigma Delta modulator can also
output PDM (pulse density modulation) signal with configurable duty cycle. The transfer function is:
After scaling, the clock cycle is equal to one pulse output cycle from the modulator.
GPIO_EXT_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.
• GPIO_EXT_SDn_IN = 127, the duty cycle of the output signal is near 100%.
The formula for calculating PDM signal duty cycle is shown as below:
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).
PRELIMINARY
Espressif Systems 217 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
• Route one of SDM outputs to a pin via GPIO matrix, see Section 6.5.2.
This option is less flexible than routing signals via GPIO matrix, as the IO MUX register for each GPIO pin can only
select from a limited number of functions, but high-frequency digital performance can be improved.
1. IO_MUX_GPIOn_MCU_SEL for the GPIO pin must be set to the required pin function. For the list of pin
functions, please refer to Section 6.13.
To bypass GPIO matrix for peripheral output signals, IO_MUX_GPIOn_MCU_SEL for the GPIO pin must be set to
the required pin function.
Note:
Not all signals can be directly connected to peripheral via IO MUX. Some input/output signals can only be connected to
the peripheral via GPIO matrix.
PRELIMINARY
Espressif Systems 218 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
Note:
If IO_MUX_GPIOn_SLP_SEL is set to 0, pin functions remain the same in both normal execution and in Light-sleep mode.
Please refer to Section 6.5.2 for how to enable output in normal execution.
– Or users can set PMU_TIE_HIGH_HP_PAD_HOLD_ALL to maintain the input/output status of all digital
pins, and set PMU_TIE_LOW_HP_PAD_HOLD_ALL to disable the hold function of all digital pins.
– The input and output values of LP GPIO pins are controlled by LP_AON_GPIO_HOLD0_REG[n],
PMU_TIE_HIGH_LP_PAD_HOLD_ALL, and PMU_TIE_LOW_LP_PAD_HOLD_ALL. Users can set
LP_AON_GPIO_HOLD0_REG[n] to 1 to hold the value of GPIOn, or set
LP_AON_GPIO_HOLD0_REG[n] to 0 to disable the hold function of GPIOn.
– Or users can set PMU_TIE_HIGH_LP_PAD_HOLD_ALL to hold the values of all LP pins, and set
PMU_TIE_LOW_LP_PAD_HOLD_ALL to disable the hold function of all LP pins.
– When the LP pin is held in the input state, it can serve as a wake-up source to wake up the chip from
Deep-sleep mode.
PRELIMINARY
Espressif Systems 219 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
Figure 66. Example of level flip on the chip pad when the hysteresis function is not enabled
When hysteresis is enabled, as shown in Figure 6-7, the level flip of C has two thresholds, high-level threshold
(Vth, about 1.7 V) and low-level threshold (Vtl, about 1.4 V). When the voltage of pad goes from low to high, if the
voltage is higher than Vth, the level of C is high. When the voltage of PAD goes from high to low, if the voltage is
lower than Vtl, the level of C is low. When the voltage of PAD is between Vth and Vtl, the level of C does not
change. The hysteresis function can reduce the impact of noise, play an anti-interference role, and reduce the
level flip times of C.
– The hysteresis function for GPIO0 +~+GPIO5 is enabled when the corresponding bit in
EFUSE_HYS_EN_PAD0[0:5] is 1. The hysteresis function for GPIO0 +~+GPIO5 is disabled when the
corresponding bit in EFUSE_HYS_EN_PAD0[0:5] is 0.
– The hysteresis function for GPIO8 ~ GPIO14 and GPIO22 ~ GPIO27 is enabled when the
corresponding bit in EFUSE_HYS_EN_PAD1[2:8] and EFUSE_HYS_EN_PAD1[16:21] is 1. The
hysteresis function for GPIO8 ~ GPIO14 and GPIO22 ~ GPIO27 is disabled when the corresponding
bit in EFUSE_HYS_EN_PAD1[2:8] and EFUSE_HYS_EN_PAD1[16:21] is 0.
PRELIMINARY
Espressif Systems 220 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
Figure 67. Example of level flip on the chip pad when the hysteresis function is enabled
• VDDPST1: the input power supply for some digital GPIOs and some LP GPIOs
• GPIO_FUNCn_OEN_SEL = 0: use the output enable signal from peripheral, for example SPIQ_oe in the
column “Output enable signal when GPIO_FUNCn_OEN_SEL = 0” of Table 6-2. Note that the signals such
as SPIQ_oe can be 1 (1’d1) or 0 (1’d0), depending on the configuration of corresponding peripherals. If it’s
1’d1 in column “Output enable signal when GPIO_FUNCn_OEN_SEL = 0”, it indicates that once
GPIO_FUNCn_OEN_SEL is cleared, the output signal is always enabled by default.
Note:
Signals are numbered consecutively, but not all signals are valid.
• Only the signals with a name assigned in the column “Input signal” in Table 6-2 are valid input signals.
• Only the signals with a name assigned in the column “Output signal” in Table 6-2 are valid output signals.
PRELIMINARY
Espressif Systems 221 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
22 - - - - - -
23 - - - - - -
GoBack
24 - - - - - -
Espressif Systems
37 - - - - - -
38 - - - - - -
39 - - - - - -
40 - - - - - -
41 - - - - - -
42 - - - - - -
ESP32-H2 TRM (Pre-release v0.4)
43 - - - - - -
44 - - - - - -
45 I2CEXT0_SCL_in 1 no I2CEXT0_SCL_out I2CEXT0_SCL_oe no
46 I2CEXT0_SDA_in 1 no I2CEXT0_SDA_out I2CEXT0_SDA_oe no
47 parl_rx_data0 0 no parl_tx_data0 1’d1 no
PRELIMINARY
GoBack
50 parl_rx_data3 0 no parl_tx_data3 1’d1 no
51 parl_rx_data4 0 no parl_tx_data4 1’d1 no
Espressif Systems
60 - - cte_ant3 1’d1 no
61 - - cte_ant4 1’d1 no
62 - - cte_ant5 1’d1 no
63 FSPICLK_in 0 yes FSPICLK_out_mux FSPICLK_oe yes
224
75 - - - twai0_clkout 1’d1 no
76 - - - twai0_standby 1’d1 no
GoBack
77 - - cte_ant6 1’d1 no
78 - - - cte_ant7 1’d1 no
Espressif Systems
GoBack
104 pcnt_ctrl_ch1_in0 0 no FSPICS4_out FSPICS4_oe yes
105 pcnt_sig_ch0_in1 0 no FSPICS5_out FSPICS5_oe yes
Espressif Systems
118 - - - - - -
119 - - - - - -
120 - - - - - -
121 SPIQ_in 0 yes SPIQ_out SPIQ_oe yes
122 SPID_in 0 yes SPID_out SPID_oe yes
123 SPIHD_in 0 yes SPIHD_out SPIHD_oe yes
ESP32-H2 TRM (Pre-release v0.4)
GoBack
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
GPIO Pin Name Function 0 Function 1 Function 2 Function 3 DRV Reset Notes
0 GPIO0 GPIO0 GPIO0 FSPIQ — 2 0 —
1 GPIO1 GPIO1 GPIO1 FSPICS0 — 2 0 —
2 MTMS MTMS GPIO2 FSPIWP — 2 1 —
3 MTDO MTDO GPIO3 FSPIHD — 2 1 —
4 MTCK MTCK GPIO4 FSPICLK — 2 1* —
5 MTDI MTDI GPIO5 FSPID — 2 1 —
8 GPIO8 GPIO8 GPIO8 — — 2 1 R
9 GPIO9 GPIO9 GPIO9 — — 2 3 R
10 GPIO10 GPIO10 GPIO10 — — 2 0 R
11 GPIO11 GPIO11 GPIO11 — — 2 0 R
12 GPIO12 GPIO12 GPIO12 — — 2 0 R
13 XTAL_32K_P GPIO13 GPIO13 — — 2 0 R
14 XTAL_32K_N GPIO14 GPIO14 — — 2 0 R
22 GPIO22 GPIO22 GPIO22 — — 2 0 —
23 U0RXD U0RXD GPIO23 FSPICS1 — 2 3 —
24 U0TXD U0TXD GPIO24 FSPICS2 — 2 4 —
25 GPIO25 GPIO25 GPIO25 FSPICS3 — 2 1 —
26 GPIO26 GPIO26 GPIO26 FSPICS4 — 3 1 USB
27 GPIO27 GPIO27 GPIO27 FSPICS5 — 3 3* USB
Drive Strength
“DRV” column shows the drive strength of each pin after reset:
• 0 - Drive current = ~5 mA
Reset Configurations
“Reset” column shows the default configuration of each pin after reset:
• 0 - IE = 0 (input disabled)
• 1 - IE = 1 (input enabled)
PRELIMINARY
Espressif Systems 227 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
• 3* - IE = 1, WPU = 0. The default value of GPIO27’s USB pull-up is 1, which means the pull-up resistor is
enabled. For details, please refer to the note below.
• Hysteresis mode: In the hysteresis mode, the threshold voltage for flipping between high and low levels of
GPIO input depends on the direction of level flipping. Specifically, the voltage threshold for flipping from
high to low level is slightly lower than the voltage threshold for flipping from low to high level. For details,
see Chapter 6.10.
• Normal mode: Disable hysteresis for GPIO pins, and the threshold voltage for flipping between high and low
levels of GPIO input is independent of the direction of level flipping. In other words, the voltage threshold for
flipping from high to low level is the same as the voltage threshold for flipping from low to high level.
Note:
• R - LP pins. Some LP pins have analog functions. For details, see 6-4.
– By default, the USB function is enabled for USB pins (i.e., GPIO26 and GPIO27), and the pin pull-up is
decided by the USB pull-up. The USB pull-up is controlled by USB_SERIAL_JTAG_DP/DM_PULLUP
and the pull-up resistor value is controlled by USB_SERIAL_JTAG_PULLUP_VALUE. For details, see
ESP32-H2 Technical Reference Manual > Chapter USB Serial/JTAG Controller.
– When the USB function is disabled, USB pins are used as regular GPIOs and the pin’s internal weak
pull-up and pull-down resistors are disabled by default (configurable by
IO_MUX_GPIOn_MCU_WPU/WPD).
PRELIMINARY
Espressif Systems 228 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
1
ZCD0 and ZCD1 are analog PAD voltage comparator functions. See subsection
6.15 for details.
The PAD_COMP_OUT signal will be synchronized to the operating clock of the IO MUX to generate the
PAD_COMP_OUT_sync signal, which will be used as the interrupt source GPIO_EXT_PAD_COMP_INT.
• 1, 2: reserved
• 3: enable interrupt source and set any edge of PAD_COMP_OUT_sync signal as interrupt source.
Meanwhile, after generating an interrupt source, new interrupt sources will be masked within
GPIO_EXT_ZERO_DET_FILTER_CNT IO MUX operating clock cycles.
The GPIO ETM provides eight task channels x (0 ~ 7). The ETM tasks that each task channel can receive
are:
• Configure GPIO_ENABLE_REG[y] to 1;
• Configure GPIO_EXT_ETM_TASK_GPIOy_SEL to x;
PRELIMINARY
Espressif Systems 229 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
Note:
• When GPIOy is controlled by ETM task channel, the values of GPIO_OUT_REG, GPIO_FUNCn_OUT_INV_SEL, and
GPIO_FUNCn_OUT_SEL may be modified by the hardware. For such reason, it’s recommended to reconfigure
these registers when the GPIO is free from the control of ETM task channel.
GPIO has eight event channels, and the ETM events that each event channel can generate are:
• GPIO_EVT_CHx_RISE_EDGE: Indicates that the output signal of the corresponding GPIO filter (see Figure
6-1) has a rising edge;
• GPIO_EVT_CHx_FALL_EDGE: Indicates that the output signal of the corresponding GPIO filter (see Figure
6-1) has a falling edge;
• GPIO_EVT_CHx_ANY_EDGE: Indicates that the output signal of the corresponding GPIO filter (see Figure
6-1) is reversed.
Note:
One GPIO can be selected by one or more event channels.
In specific applications, GPIO ETM events can be used to trigger GPIO ETM tasks. For example, event channel 0
selects GPIO0, GPIO1 selects task channel 0, and the GPIO_EVT_CH0_RISE_EDGE event is used to trigger the
GPIO_TASK_CH0_TOGGLE task. When a square wave signal is input to the chip through GPIO0, the chip
outputs a square wave signal with a frequency divided by 2 through GPIO1.
PRELIMINARY
Espressif Systems 230 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
For ESP32-H2, 19 GPIO pins are available, i.e., GPIO0 ~ GPIO5, GPIO8 ~ GPIO14, and GPIO22 ~ GPIO27. For
this case:
• Configuration Registers: can only be configured for GPIO0 ~ GPIO5, GPIO8 ~ GPIO14 and GPIO22 ~
GPIO27.
• Input Configuration Registers: can only be configured for GPIO0 ~ GPIO5, GPIO8 ~ GPIO14 and
GPIO22 ~ GPIO27.
PRELIMINARY
Espressif Systems 231 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
For ESP32-H2, 19 GPIO pins are available, i.e., GPIO0 ~ GPIO5, GPIO8 ~ GPIO14 and GPIO22 ~ GPIO27. For
this case, Configuration Registers of IO_MUX_GPIO6_REG ~ IO_MUX_GPIO7_REG and
IO_MUX_GPIO15_REG ~ IO_MUX_GPIO21_REG are not configurable.
PRELIMINARY
Espressif Systems 232 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
The addresses in this section are relative to (GPIO base address + 0x0F00). GPIO base address is provided in
Table 4-2 in Chapter 4 System and Memory.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 233 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
PRELIMINARY
Espressif Systems 234 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
6.18 Registers
6.18.1 GPIO Matrix Registers
The addresses in this section are relative to GPIO base address provided in Table 4-2 in Chapter 4 System and
Memory.
G
RI
_O
A
AT
_D
UT
_O
O
PI
G
31 0
0x000000 Reset
GPIO_OUT_DATA_ORIG Configures the output value of GPIO0 ~ GPIO27 output in simple GPIO
output mode.
0: Low level
1: High level
The value of bit0 ~ bit27 correspond to the output value of GPIO0 ~ GPIO27 respectively. Bit28 ~
bit31 are invalid.
(R/W/SC/WTC)
31 0
0x000000 Reset
GPIO_OUT_W1TS Configures whether or not to set the output register GPIO_OUT_REG of GPIO0 ~
GPIO27.
0: Not set
1: The corresponding bit in GPIO_OUT_REG will be set to 1
Bit0 ~ bit27 are corresponding to GPIO0 ~ GPIO27. Bit28 ~ bit31 are invalid. Recommended
operation: use this register to set GPIO_OUT_REG.
(WT)
PRELIMINARY
Espressif Systems 235 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
C
1T
W
_
UT
_O
O
PI
G
31 0
0x000000 Reset
GPIO_OUT_W1TC Configures whether or not to clear the output register GPIO_OUT_REG of GPIO0
~ GPIO27 output.
0: Not clear
1: The corresponding bit in GPIO_OUT_REG will be cleared.
bit0 ~ bit27 are corresponding to GPIO0 ~ GPIO27. Bit28 ~ bit31 are invalid. Recommended
operation: use this register to clear GPIO_OUT_REG.
(WT)
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 236 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
S
1T
_W
LE
N AB
_E
O
PI
G
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 237 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
G
IN
P
AP
TR
d)
_S
ve
er
O
s
PI
(re
G
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
• bit0: GPIO2 (GPIO2 should be reserved as a Strapping pin only when using SPI Download
Boot mode.)
• bit1: GPIO3 (GPIO3 should be reserved as a Strapping pin only when using SPI Download
Boot mode.)
• bit4: GPIO25
For more details about GPIO Strapping pins, please refer to the Chapter 8 Chip Boot Control.
(RO)
31 0
0x000000 Reset
GPIO_IN_DATA_NEXT Represents the input value of GPIO0 ~ GPIO27. Each bit represents a pin
input value:
0: Low level
1: High level
bit0 ~ bit27 are corresponding to GPIO0 ~ GPIO27. Bit28 ~ bit31 are invalid.
(RO)
PRELIMINARY
Espressif Systems 238 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
T
UP
RR
TE
IN
S_
TU
TA
_S
O
PI
G
31 0
0x000000 Reset
• Bit0 ~ bit27 are corresponding to GPIO0 ~ GPIO27. Bit28 ~ bit31 are invalid.
(R/W/WTC)
31 0
0x000000 Reset
• Bit0 ~ bit27 are corresponding to GPIO0 ~ GPIO27. Bit28 ~ bit31 are invalid.
• If the value 1 is written to a bit here, the corresponding bit in GPIO_STATUS_INTERRUPT will
be set to 1.
(WT)
PRELIMINARY
Espressif Systems 239 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
C
1T
W
S_
TU
TA
_S
O
PI
G
31 0
0x000000 Reset
• bit0 ~ bit27 are corresponding to GPIO0 ~ GPIO27. Bit28 ~ bit31 are invalid.
• If the value 1 is written to a bit here, the corresponding bit in GPIO_STATUS_INTERRUPT will
be cleared.
(WT)
31 0
0x000000 Reset
• bit0 ~ bit27 are corresponding to GPIO0 ~ GPIO27. Bit28 ~ bit31 are invalid.
• This interrupt status is corresponding to the bit in GPIO_STATUS_REG when assert (high)
enable signal (bit13 of GPIO_PINn_REG). Each bit represents:
– 0: Represents CPU interrupt is not enabled, or the GPIO does not generate the interrupt
configured by GPIO_PINn_INT_TYPE.
(RO)
PRELIMINARY
Espressif Systems 240 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
LE
SS
AB
_D PAS
PA
EN
NC ER
_P PAD BY
BY
P_
SY RIV
PE
NA
PI Nn_ C1_
2_
EU
TY
_E
AK
T_
_P SYN
NT
IN
W
I
n_
n_
n_
PI Nn_
n_
IN
IN
IN
IN
d)
)
ed
ed
I
_P
_P
_P
_P
ve
rv
rv
er
O
se
se
s
PI
PI
PI
PI
(re
(re
(re
G
G
31 18 17 13 12 11 10 9 7 6 5 4 3 2 1 0
PRELIMINARY
Espressif Systems 241 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
GPIO_PINn_INT_ENA Configures whether or not to enable CPU interrupt or CPU non-maskable in-
terrupt.
(R/W)
31 0
0x000000 Reset
The interrupt could be rising edge interrupt, falling edge interrupt, level sensitive interrupt and any
edge interrupt.
(RO)
PRELIMINARY
Espressif Systems 242 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
L
SE
V_
L
SE
IN
_I L
Cn SE
N_
N_
UN N_
_I
Cn
_F _I
O n
UN
PI SIG
d)
ve
_F
_
er
O
s
PI
PI
(re
G
G
G
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 Configures to select a pin from the 28 GPIO pins to connect the input signal
n.
0: Select GPIO0
1: Select GPIO1
......
26: Select GPIO26
27: Select GPIO27
Or
0x38: A constantly high input
0x3C: A constantly low input
(R/W)
PRELIMINARY
Espressif Systems 243 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
UT EL EL
EL
_O _S _S
_S
EL
C0 OEN INV
NV
_S
_I
UN _ _
_F C0 EN
UT
O N O
_O
PI U _
G _F C0
C0
O N
UN
)
PI FU
ed
_F
rv
_
O
O
se
PI
PI
(re
G
G
G
31 11 10 9 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x80 Reset
GPIO_FUNCn_OUT_SEL Configures to select a signal Y (0 <= Y < 128) from 128 peripheral signals
to be output from GPIOn.
0: Select signal 0
1: Select signal 1
......
126: Select signal 126
127: Select signal 127
Or
128: Bit n of GPIO_OUT_REG and GPIO_ENABLE_REG are selected as the output value and
output enable.
(R/W/SC)
PRELIMINARY
Espressif Systems 244 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
N
_E
LK
d)
_C
ve
r
O
se
PI
(re
G
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
E
AT
)
ed
_D
rv
O
se
PI
(re
31 28 27 0
0 0 0 0 0x2201120 Reset
1
UT
UT
UT
_O
_O
_O
LK
LK
LK
_C
_C
_C
)
ed
UX
UX
UX
rv
_M
_M
_M
se
(re
IO
IO
IO
31 15 14 10 9 5 4 0
PRELIMINARY
Espressif Systems 245 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
PI _S _W U
n_ _ D
N
_M _G On CU V
_W U
CU D
EL
RV
_G On CU P
O LP P
O YS EL
_E
CU L
E
UN P
P
FI EN
UX PI _M _W
IO UX PI _M _IE
M SE
_O
_D
_S
_F _W
P _F _IE
_D
PI _H _S
ER
n_ _
_M _G On CU
_G On YS
UN
IO X_G IOn UN
UX IOn UN
LT
C
_M
_M _G n_M
IO UX PI _M
UX PI _H
_M _G n_F
U P F _
_M _G On
_M _G O n
_M _G O n
O
O
IO UX PI
PI
IO UX PI
IO UX PI
_M GP
_M GP
_M _G
_G
d)
_
IO UX
UX
UX
IO UX
IO UX
ve
er
_M
_M
_M
_M
s
(re
IO
IO
IO
IO
IO
31 18 17 16 15 14 12 11 10 9 8 7 6 5 4 3 2 1 0
IO_MUX_GPIOn_MCU_OE Configures whether or not to enable the output of GPIOn in sleep mode.
0: Disable
1: Enable
(R/W)
IO_MUX_GPIOn_MCU_IE Configures whether or not to enable the input of GPIOn during sleep mode.
0: Disable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 246 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
IO_MUX_GPIOn_FILTER_EN Configures whether or not to enable filter for pin input signals.
0: Disable
1: Enable
(R/W)
IO_MUX_GPIOn_HYS_EN Configures whether or not to enable the hysteresis function of the pin
when IO_MUX_GPIOn_HYS_SEL is set to 1.
0: Disable
1: Enable
(R/W)
IO_MUX_GPIOn_HYS_SEL Configures to choose the signal for enabling the hysteresis function for
GPIOn.
0�Choose the output enable signal of eFuse
1: Choose the output enable signal of IO_MUX_GPIOn_HYS_EN.
(R/W)
PRELIMINARY
Espressif Systems 247 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
EG
_R
E
AT
_D
)
ed
UX
rv
_M
se
(re
IO
31 28 27 0
0 0 0 0 0x2207270 Reset
E
AL
SC
RE
IN
_P
0_
D0
D
_S
_S
XT
XT
d)
_E
_E
rve
O
se
PI
PI
(re
G
31 16 15 8 7 0
GPIO_EXT_SD0_IN Configures the duty cycle of sigma delta modulation output. (R/W)
GPIO_EXT_SD0_PRESCALE Configures the divider value to divide IO MUX operating clock. (R/W)
)
PI d
ed
_E
G rve
rv
se
se
(re
(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
GPIO_EXT_FUNCTION_CLK_EN Configures whether or not to enable the clock for sigma delta mod-
ulation.
0: Not enable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 248 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
DE
O
O P
_M
P
_C OM
P
M
ET
M
O
PD _C
_D
_C
_X DE
RO
F
RE
XT O
ZE
_E M
_D
T_
O T_
XT
)
PI X
ed
_E
_E
G _E
rv
O
se
PI
PI
PI
(re
G
31 7 6 5 3 2 1 0
GPIO_EXT_ZERO_DET_MODE Configures the mode of generating interrupt sources for analog PAD
voltage comparator.
0: Disable interrupt source generation.
1: Reserved.
2: Reserved.
3: Enable interrupt source generated by any edge of the PAD_COMP_OUT_sync signal.
(R/W)
GPIO_EXT_DREF_COMP Configures the internal reference voltage for analog PAD voltage compara-
tor.
0: Internal reference voltage is 0 * VDDPST2
1: Internal reference voltage is 0.1 * VDDPST2
......
6: Internal reference voltage is 0.6 * VDDPST2
7: Internal reference voltage is 0.7 * VDDPST2
(R/W)
GPIO_EXT_MODE_COMP Configures the reference voltage for analog PAD voltage comparator.
0: Reference voltage is the internal reference voltage.
1: Reference voltage is the voltage on the GPIO10 PAD.
(R/W)
GPIO_EXT_XPD_COMP Configures whether to enable the function of analog PAD voltage compara-
tor.
0: Disable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 249 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
NT
_C
ER
ILT
_F
ET
_D
O
ER
_Z
XT
_E
O
PI
G
31 0
0x0 Reset
PRELIMINARY
Espressif Systems 250 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
ES
TH
UM
HR
ID
_W
_N
_T
IO
W
T_
DO
DO
PU
IN
IN
EN
IN
W
W
n_
n_
n_
Hn
CH
CH
CH
_C
R_
R_
R_
ER
E
E
LT
ILT
LT
LT
FI
FI
_F
_F
T_
_
XT
XT
XT
d)
X
_E
_E
_E
_E
ve
er
O
s
PI
PI
PI
PI
(re
G
31 19 18 13 12 7 6 1 0
GPIO_EXT_FILTER_CHn_WINDOW_WIDTH Configures the window width for Glitch Filter. The valid
range for the window width is 0 +~+62, and 63 is a reserved value that cannot be used.
Measurement unit: IO MUX operating clock cycle
(R/W)
PRELIMINARY
Espressif Systems 251 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
L
EN
SE
T_
_
NT
EN
VE
EV
_E
_
Hn
Hn
_C
_C
TM
TM
se T_E
_E
XT
d)
)
X
ed
_E
_E
ve
rv
er
O
s
PI
PI
(re
(re
G
G
31 8 7 6 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
PRELIMINARY
Espressif Systems 252 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
L
EN
EN
EN
EN
SE
SE
SE
SE
3_
3_
2_
2_
1_
1_
0_
0_
O
O
PI
PI
PI
PI
PI
PI
PI
PI
G
G
K_
K_
K_
K_
K_
K_
K_
K_
AS
AS
AS
AS
AS
AS
AS
AS
_T
_T
_T
_T
_T
_T
_T
_T
TM
TM
TM
TM
M
ET
ET
ET
_E
_E
_E
_E
_E
_
_
XT
XT
XT
XT
XT
XT
XT
XT
d)
d)
)
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
ve
ve
rv
rv
er
er
O
O
se
se
s
s
PI
PI
PI
PI
PI
PI
PI
PI
(re
(re
(re
(re
G
G
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
PRELIMINARY
Espressif Systems 253 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
L
EN
EN
EN
EN
SE
SE
SE
SE
7_
7_
6_
6_
5_
5_
4_
4_
O
O
PI
PI
PI
PI
PI
PI
PI
PI
G
G
K_
K_
K_
K_
K_
K_
K_
K_
AS
AS
AS
AS
AS
AS
AS
AS
_T
_T
_T
_T
_T
_T
_T
_T
TM
TM
TM
TM
M
ET
ET
ET
_E
_E
_E
_E
_E
_
_
XT
XT
XT
XT
XT
XT
XT
XT
d)
d)
)
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
ve
ve
rv
rv
er
er
O
O
se
se
s
s
PI
PI
PI
PI
PI
PI
PI
PI
(re
(re
(re
(re
G
G
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
PRELIMINARY
Espressif Systems 254 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
EL
EL
N
L
EN
EN
SE
SE
_S
_S
_E
_E
11
11
10
10
9_
9_
8_
8_
O
O
PI
PI
PI
PI
PI
PI
PI
PI
G
G
K_
K_
K_
K_
K_
K_
K_
K_
AS
AS
AS
AS
AS
AS
AS
AS
_T
_T
_T
_T
_T
_T
_T
_
TM
TM
TM
TM
TM
TM
TM
T
_E
_E
_E
_E
_E
_E
_E
_E
XT
XT
XT
XT
XT
XT
XT
XT
d)
)
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
ve
rv
rv
rv
er
O
se
se
se
s
PI
PI
PI
PI
PI
PI
PI
PI
(re
(re
(re
(re
G
G
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
PRELIMINARY
Espressif Systems 255 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
EL
EL
EL
EL
N
N
_S
_S
_S
_S
_E
_E
_E
_E
15
15
14
14
13
13
12
12
O
O
PI
PI
PI
PI
PI
PI
PI
PI
G
G
K_
K_
K_
K_
K_
K_
K_
K_
AS
AS
AS
AS
AS
AS
AS
AS
_T
_T
_T
_T
_T
_T
_T
_
TM
TM
TM
TM
TM
TM
TM
T
_E
_E
_E
_E
_E
_E
_E
_E
XT
XT
XT
XT
XT
XT
XT
XT
d)
)
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
ve
rv
rv
rv
er
O
se
se
se
s
PI
PI
PI
PI
PI
PI
PI
PI
(re
(re
(re
(re
G
G
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
PRELIMINARY
Espressif Systems 256 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
EL
EL
EL
EL
N
N
_S
_S
_S
_S
_E
_E
_E
_E
19
19
18
18
17
17
16
16
O
O
PI
PI
PI
PI
PI
PI
PI
PI
G
G
K_
K_
K_
K_
K_
K_
K_
K_
AS
AS
AS
AS
AS
AS
AS
AS
_T
_T
_T
_T
_T
_T
_T
_
TM
TM
TM
TM
TM
TM
TM
T
_E
_E
_E
_E
_E
_E
_E
_E
XT
XT
XT
XT
XT
XT
XT
XT
d)
)
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
ve
rv
rv
rv
er
O
se
se
se
s
PI
PI
PI
PI
PI
PI
PI
PI
(re
(re
(re
(re
G
G
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
PRELIMINARY
Espressif Systems 257 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
EL
EL
EL
EL
N
N
_S
_S
_S
_S
_E
_E
_E
_E
23
23
22
22
21
21
20
20
O
O
PI
PI
PI
PI
PI
PI
PI
PI
G
G
K_
K_
K_
K_
K_
K_
K_
K_
AS
AS
AS
AS
AS
AS
AS
AS
_T
_T
_T
_T
_T
_T
_T
_
TM
TM
TM
TM
TM
TM
TM
T
_E
_E
_E
_E
_E
_E
_E
_E
XT
XT
XT
XT
XT
XT
XT
XT
d)
)
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
ve
rv
rv
rv
er
O
se
se
se
s
PI
PI
PI
PI
PI
PI
PI
PI
(re
(re
(re
(re
G
G
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
PRELIMINARY
Espressif Systems 258 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
EL
EL
EL
EL
N
N
_S
_S
_S
_S
_E
_E
_E
_E
27
27
26
26
25
25
24
24
O
O
PI
PI
PI
PI
PI
PI
PI
PI
G
G
K_
K_
K_
K_
K_
K_
K_
K_
AS
AS
AS
AS
AS
AS
AS
AS
_T
_T
_T
_T
_T
_T
_T
_
TM
TM
TM
TM
TM
TM
TM
T
_E
_E
_E
_E
_E
_E
_E
_E
XT
XT
XT
XT
XT
XT
XT
XT
d)
)
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
ve
rv
rv
rv
er
O
se
se
se
s
PI
PI
PI
PI
PI
PI
PI
PI
(re
(re
(re
(re
G
G
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
AW
_R
NT
I
P_
M
O
_C
AD
_P
XT
)
ed
_E
rv
O
se
PI
(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
PRELIMINARY
Espressif Systems 259 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
ST
T_
IN
P_
M
O
D _C
PA
_
XT
d)
_E
ve
er
O
s
PI
(re
G
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
A
EN
T_
IN
P_
M
O
D _C
PA
_
XT
d )
_E
ve
er
O
s
PI
(re
G
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
LR
_C
NT
I
P_
M
O
_C
AD
_P
XT
)
ed
_E
rv
O
se
PI
(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
PRELIMINARY
Espressif Systems 260 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
6 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
TE
DA
D_
_S
O
PI
G
T_
)
X
ed
_E
rv
O
se
PI
(re
G
31 28 27 0
0 0 0 0 0x2208120 Reset
PRELIMINARY
Espressif Systems 261 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
7.1 Reset
7.1.1 Overview
ESP32-H2 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) preserve the data stored in internal
memory. Figure 7-1 shows the scopes of affected subsystems by each type of reset.
ESP32-H2
Digital System
Digital Core Low Power
System
CPU Reset CPU
802.15.4
ESP32-H2’s Digital System can be divided into two parts: High Performance System (HP system) that includes
Digital Core, Wireless Circuit, and HP SRAM, and Low Power System (LP system) that only includes some
low-power peripherals and LP SRAM. See Figure 7-1 for details (note that HP SRAM and LP SRAM would not be
reset, so they are not shown in the figure).
7.1.3 Features
• Four reset types:
– CPU Reset: resets CPU core. Once such a reset is released, the instructions from the CPU reset
vector (0x40000000) will be executed.
– Core Reset: resets the whole digital system except LP system, including CPU, peripherals, digital
GPIOs, Bluetooth® LE, and 802.15.4.
PRELIMINARY
Espressif Systems 262 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
– Software Reset: triggered via software by configuring the corresponding registers of CPU, see
Chapter 2 Low-power Management (RTC_CNTL) [to be added later].
PRELIMINARY
Espressif Systems 263 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
The reset registers of ESP32-H2 peripherals are controlled by the Power/Clock/Reset (PCR) module. For reset
registers of peripherals, see Section 7.4 Register Summary.
PRELIMINARY
Espressif Systems 264 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
7.2 Clock
7.2.1 Overview
ESP32-H2 clocks are mainly sourced from oscillator (OSC), RC, and PLL circuits, and then processed by the
dividers or selectors, which allows most functional modules to select their working clock according to their power
consumption and performance requirements. Figure 7-2 shows the system clock structure.
PLL_F96M_CLK CLK_MANAGEMENT
PLL
HP_ROOT_CLK
PLL_F64M_CLK (max 96M) CPU_CLK
PLL DIV CPU
MUX
RC RC_FAST_CLK
8 MHz
PLL_F96M_CLK
PLL_F64M_CLK CRYPTO_CLK
MUX
RC_FAST_CLK DIV
XTAL_CLK
PLL_F48M_CLK
DIV UART0/1_CLK PERI
MUX
RC_FAST_CLK DIV
XTAL_CLK
PLL_F96M_CLK
LEDC_SCLK
RC_FAST_CLK
MUX
XTAL_CLK
PLL_F96M_CLK MCPWM_CLK
RC_FAST_CLK
MUX
XTAL_CLK
LP_FAST_CLK
MUX
XTAL_D2_CLK
DIV LP_DYN_FAST_CLK
MUX
PLL_LP_CLK
PLL
LP
SYSTEM
XTAL32K_CLK
XTAL_32K_N XTAL
XTAL_32K_P 32kHz
RC_SLOW_CLK LP_SLOW_CLK LP_DYN_SLOW_CLK
MUX
RC
130 kHz
OSC_SLOW_CLK
OSC
32 kHz
7.2.3 Features
ESP32-H2 clocks can be classified into two types depending on their frequencies:
• High-performance (HP) clocks for devices working at a higher frequency, such as CPU and digital
peripherals
– PLL_F96M_CLK (96 MHz): internal PLL clock. Its reference clock is XTAL_CLK.
– PLL_F64M_CLK (64 MHz): internal PLL clock. Its reference clock is XTAL_CLK.
PRELIMINARY
Espressif Systems 265 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
• Low-power (LP) clocks for low-power system and some peripherals working in low-power mode
– RC_SLOW_CLK (130 kHz by default): internal slow RC oscillator with adjustable frequency
– OSC_SLOW_CLK (32 kHz by default): external slow clock input through XTAL_32K_P and
XTAL_32K_N. After configuring these two GPIOs, also configure the Hold function (see Chapter 6 IO
MUX and GPIO Matrix (GPIO, IO MUX) > 6.9 Pin Hold Feature)
As Figure 7-2 shows, CPU_CLK is the master clock for CPU and its frequency can be as high as 96 MHz.
Alternatively, CPU can run at lower frequencies, such as at 2 MHz, to achieve lower power consumption.
CPU_CLK shares the same clock sources with AHB_CLK and APB_CLK. Users can select from XTAL_CLK,
PLL_96M_CLK, PLL_64M_CLK, or RC_FAST_CLK as the clock source of CPU_CLK by configuring
PCR_SOC_CLK_SEL. For details, see Table 7-2 and Table 7-3. By default, the CPU clock is sourced from
XTAL_CLK with a divider of 1, i.e., the CPU clock frequency is 32 MHz.
PRELIMINARY
Espressif Systems 266 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
Note:
When selecting the clock source of HP_ROOT_CLK, or configuring the clock divisor for CPU_CLK and AHB_CLK, please
also set PCR_BUS_CLOCK_UPDATE to apply the new configuration, and read PCR_BUS_CLOCK_UPDATE to see if
new configuration takes effect.
As shown in 7-2, to generate APB_CLK, AHB_CLK might be divided twice. The first division is compulsory. That
is, AHB_CLK is always divided by the divisor (PCR_APB_DIV_NUM + 1). The second division (also called
automatic frequency reduction) is optional. When there is no request from the host in the chip to access
peripheral registers, AHB_CLK will be further divided by (APB_DECREASE_DIV_NUM + 1) to lower power
consumption. If the host initiates a request to access peripheral registers, APB_CLK will be restored to the
frequency after the first division.
Note that the chip’s performance will degrade due to the automatic frequency reduction. This function can be
disabled (already disabled by default) by configuring APB_DECREASE_DIV_NUM to 0.
The LP system can operate when most other clocks are disabled. LP system clocks include LP_SLOW_CLK and
LP_FAST_CLK.
The clock sources for LP_SLOW_CLK and LP_FAST_CLK are low-frequency clocks:
– RC_SLOW_CLK
– XTAL32K_CLK
– OSC_SLOW_CLK
– RC_FAST_CLK
– PLL_LP_CLK
The clock source of LP_DYN_SLOW_CLK is LP_SLOW_CLK. There is no frequency change from the clock
source.
The clock source of LP_DYN_FAST_CLK depends on the chip’s power mode (see Chapter 2 Low-power
Management (RTC_CNTL) [to be added later]).
Table 7-4, Table 7-5, Table 7-6, and Table 7-7 list the derived HP/LP clocks sources and HP/LP clocks for each
peripheral.
PRELIMINARY
Espressif Systems 267 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Table 74. Derived HP Clock Source
Espressif Systems
Source Clock Derived Clock Source Clock Derived Clock Source Clock
PLL_CLK HP_ROOT_CLK
Peripheral XTAL_CLK RC_FAST_CLK RC_SLOW_CLK OSC_SLOW_CLK XTAL32K_CLK PLL_LP_CLK 96 MHz/64 LP_DYN_ LP_DYN_ XTAL_D2_CLK Clock
PLL_F96M_CLK PLL_F64M_CLK PLL_F48M_CLK CRYPTO_CLK APB_CLK AHB_CLK CPU_CLK LP_FAST_CLK
Submit Documentation Feedback
32 MHz 8 MHz 130 kHz 32 kHz 32 kHz 8 MHz MHz/32 MHz/8 FAST_CLK SLOW_CLK 16 MHz from IO
96 MHz 64 MHz 48 MHz
MHz
Timer Group (TIMG) Y Y Y
Main System Watchdog
Y Y Y
Timers (MWDT)
I2S Controller (I2S) Y Y Y I2S_MCLK_in
UART Controller (UART) Y Y Y
268
GoBack
Event Task Matrix
Y
(SOC_ETM)
GDMA Controller (GDMA) Y
UHCI Y
Continued on the next page...
Espressif Systems
Source Clock Derived Clock Source Clock Derived Clock Source Clock
PLL_CLK HP_ROOT_CLK
Derived Clock XTAL_CLK RC_FAST_CLK RC_SLOW_CLK OSC_SLOW_CLK XTAL32K_CLK PLL_LP_CLK 96 MHz/64 LP_DYN_ LP_DYN_ XTAL_D2_CLK Clock
PLL_F96M_CLK PLL_F64M_CLK PLL_F48M_CLK CRYPTO_CLK APB_CLK AHB_CLK CPU_CLK LP_FAST_CLK
32 MHz 8 MHz 130 kHz 32 kHz 32 kHz 8 MHz MHz/32 MHz/8 FAST_CLK SLOW_CLK 16 MHz from IO
96 MHz 64 MHz 48 MHz
MHz
Submit Documentation Feedback
LP_DYN_FAST_CLK Y Y Y Y
LP_DYN_SLOW_CLK Y Y Y
XTAL_D2_CLK Y
LP_fAST_CLK Y Y Y
269
Source Clock Derived Clock Source Clock Derived Clock Source Clock
PLL_CLK HP_ROOT_CLK
Peripheral XTAL_CLK RC_FAST_CLK RC_SLOW_CLK OSC_SLOW_CLK XTAL32K_CLK PLL_LP_CLK 96 MHz/64 LP_DYN_ LP_DYN_ XTAL_D2_CLK Clock
PLL_F96M_CLK PLL_F64M_CLK PLL_F48M_CLK CRYPTO_CLK APB_CLK AHB_CLK CPU_CLK LP_FAST_CLK
32 MHz 8 MHz 130 kHz 32 kHz 32 kHz 8 MHz MHz/32 MHz/8 FAST_CLK SLOW_CLK 16 MHz from IO
96 MHz 64 MHz 48 MHz
MHz
eFuse Controller (eFuse) Y
RTC Watchdog Timer
Y Y
(RWDT)
RTC Timer (RTC Timer) Y Y
Brownout Detector Y
ESP32-H2 TRM (Pre-release v0.4)
GoBack
7 Reset and Clock GoBack
PLL_F96M_CLK
CRYPTO_CLK
As shown in Figure 7-4, CRYPTO_CLK can be derived from XTAL_CLK, PLL_96M_CLK, PLL_64M_CLK, or
RC_FAST_CLK, and its frequency is up to 96 MHz.
To protect encryption and decryption peripherals from DPA (Differential Power Analysis) attacks, a random divider
strategy is implemented for the functional clock of encryption and decryption peripherals. Three security levels
are available, depending on the range of random divider. Users can select the security level by configuring
HP_SYSTEM_SEC_DPA_CONF_REG. If HP_SYSTEM_SEC_DPA_CFG_SEL is set to 1, the security level is
determined by the configuration of EFUSE_SEC_DPA_LEVEL, otherwise, by the value of
HP_SYSTEM_SEC_DPA_LEVEL.
LED_PWM Clock
LEDC module uses PLL_F96M_CLK, RC_FAST_CLK or XTAL_CLK as its clock source. When the system is in
low-power mode (APB_CLK is disabled), most peripherals are halted, but LEDC can still work via
RC_FAST_CLK.
The functional clock of most peripherals can be selected from multiple clock sources. For clock gating registers,
whether they are used to gate the bus clock (AHB_CLK, APB_CLK) or the functional clock will be stated in the
corresponding register descriptions.
Bus clock switches, functional clock switches, and configuration registers for clock source selection and clock
frequency division are grouped into the PCR module. For more information, see Section 7.4 Register
Summary.
When a peripheral is not working, users can turn off its functional clock by configuring related PCR registers.
Turning off the peripheral’s functional clock does not affect the rest of the system.
PRELIMINARY
Espressif Systems 270 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
Figure 7-3 shows the clock structure of I2C. The clock structure of other peripherals is similar to this one.
CLK_SWITCH is used to select a clock output and CLK_GATE to turn on/off the clock.
In scenarios that require low power consumption, when the peripheral is not in use, in addition to turning off the
functional clock, the bus clock of the peripheral can also be turned off to further lower the power
consumption.
Note that if you turn off the bus clock first, the functional clock may continue working. Therefore, when turning off
clocks, it is recommended to turn off the functional clock first and then the bus clock; when turning on clocks, it
is recommended to turn on the bus clock first and then the functional clock.
Note:
In this chapter, all divisor configuration registers are configured with the actual divisor minus 1.
PRELIMINARY
Espressif Systems 271 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 272 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
PRELIMINARY
Espressif Systems 273 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 274 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
PRELIMINARY
Espressif Systems 275 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
7.5 Registers
7.5.1 PCR Registers
The addresses in this section are relative to the Power/Clock/Reset (PCR) Register base address provided in
Table 4-2 in Chapter 4 System and Memory.
EN
CL EN
R T RS Y
UA T0_ AD
K_
0_ T_
R_ AR _RE
PC _U T0
R AR
d)
ve
PC _U
er
R
s
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 276 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
UM
_N
_B
A_
EL
IV
IV
IV
SC EN
_D
_D
_D
_S
K_
LK
LK
LK
LK
CL
SC
SC
SC
_S
0_
0_
0_
0_
T0
RT
RT
RT
RT
AR
)
ed
UA
UA
UA
UA
_U
rv
R_
R_
R_
R_
se
R
PC
PC
PC
PC
PC
(re
31 23 22 21 20 19 12 11 6 5 0
0 0 0 0 0 0 0 0 0 1 3 0 0 0 Reset
PCR_UART0_SCLK_DIV_A Configures the denominator of the divisor’s fractional part’s fractional part
for UART0 functional clock. (R/W)
PCR_UART0_SCLK_DIV_B Configures the numerator of the divisor’s fractional part for UART0 func-
tional clock. (R/W)
PCR_UART0_SCLK_DIV_NUM Configures the integral part of the divisor for UART0 functional clock.
(R/W)
PRELIMINARY
Espressif Systems 277 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
RC PD
PU
O E_
E_
_F C
M R
) M E _FO
rv T0 EM
se AR _M
ed _
(re _U T0
R AR
d)
ve
PC _U
er
R
s
PC
(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 0 Reset
EN
CL EN
R T RS Y
UA T1_ AD
K_
1_ T_
R_ AR _RE
PC _U T1
R AR
ed)
PC U
rv
R_
se
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 278 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
UM
_N
_B
A_
EL
IV
IV
IV
SC EN
_D
_D
_D
_S
K_
LK
LK
LK
LK
CL
SC
SC
SC
_S
1_
1_
1_
1_
T1
RT
RT
RT
RT
AR
)
ed
UA
UA
UA
UA
_U
rv
R_
R_
R_
R_
se
R
PC
PC
PC
PC
PC
(re
31 23 22 21 20 19 12 11 6 5 0
0 0 0 0 0 0 0 0 0 1 3 0 0 0 Reset
PCR_UART1_SCLK_DIV_A Configures the denominator of the divisor’s fractional part for UART1
functional clock. (R/W)
PCR_UART1_SCLK_DIV_B Configures the numerator of the divisor’s fractional part for UART1 func-
tional clock. (R/W)
PCR_UART1_SCLK_DIV_NUM Configures the integral part of the divisor for UART1 functional clock.
(R/W)
PRELIMINARY
Espressif Systems 279 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
RC PD
PU
O E_
E_
_F C
M R
) M E _FO
rv T1 EM
se AR _M
ed _
(re _U T1
R AR
d)
ve
PC _U
er
R
s
PC
(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 0 Reset
N
LK N
I2 _R DY
_E
_C _E
R_ C0 EA
C0 ST
PC _I2 _R
R C0
ed)
PC I2
rv
R_
se
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 280 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
M
NU
_B
_A
V_
L
IV
IV
EN
SE
DI
_D
_D
K_
K_
K_
LK
LK
R_ d) CL
CL
CL
SC
SC
PC rve _S
_S
_S
0_
_
se C0
C0
C0
C0
)
ed
C
(re _I2
I2
I2
I2
I2
rv
R_
R_
R_
se
R
PC
PC
PC
PC
(re
31 23 22 21 20 19 12 11 6 5 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 Reset
PCR_I2C0_SCLK_DIV_A Configures the denominator of the divisor’s fractional part for I2C0 func-
tional clock. (R/W)
PCR_I2C0_SCLK_DIV_B Configures the numerator of the divisor’s fractional part for I2C0 functional
clock. (R/W)
PCR_I2C0_SCLK_DIV_NUM Configures the integral part of the divisor for I2C0 functional clock.
(R/W)
PRELIMINARY
Espressif Systems 281 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
I2 _R DY
_E
_C _E
R_ C1 EA
C1 ST
PC _I2 _R
R C1
)
ed
PC _I2
v
er
R
s
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 282 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
M
NU
_B
_A
V_
L
IV
IV
EN
SE
DI
_D
_D
K_
K_
K_
LK
LK
R_ d) CL
CL
CL
SC
SC
PC rve _S
_S
_S
1_
_
se C1
C1
C1
C1
)
ed
C
(re _I2
I2
I2
I2
I2
rv
R_
R_
R_
se
R
PC
PC
PC
PC
(re
31 23 22 21 20 19 12 11 6 5 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 Reset
PCR_I2C1_SCLK_DIV_A Configures the denominator of the divisor’s fractional part for I2C1 func-
tional clock. (R/W)
PCR_I2C1_SCLK_DIV_B Configures the numerator of the divisor’s fractional part for I2C1 functional
clock. (R/W)
PCR_I2C1_SCLK_DIV_NUM Configures the integral part of the divisor for I2C1 functional clock.
(R/W)
PRELIMINARY
Espressif Systems 283 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
UH I_R DY
_E
_C _E
R_ HC EA
CI ST
PC _U I_R
R HC
)
ed
PC _U
v
er
R
s
PC
(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 1 0 1 Reset
EN
CL EN
RM _R DY
K_
T_ ST_
R_ MT EA
PC _R _R
R MT
d)
e
PC R
rv
R_
se
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 284 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
UM
_N
_A
V_
EL
IV
IV
LK N
DI
_D
_D
_S
SC _E
_
T_ LK
LK
LK
LK
C
SC
SC
SC
RM _S
T_
T_
T_
R_ MT
d)
RM
RM
RM
ve
PC _R
R_
R_
R_
er
R
s
PC
PC
PC
PC
(re
31 22 21 20 19 12 11 6 5 0
0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 Reset
PCR_RMT_SCLK_DIV_A Configures the denominator of the divisor’s fractional part for RMT func-
tional clock. (R/W)
PCR_RMT_SCLK_DIV_B Configures the numerator of the divisor’s fractional part for RMT functional
clock. (R/W)
PCR_RMT_SCLK_DIV_NUM Configures the integral part of the divisor for RMT functional clock.
(R/W)
PRELIMINARY
Espressif Systems 285 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
DC S Y
_E
_C T_E
LE _R D
R_ DC EA
PC _LE C_R
R D
)
ed
PC _LE
v
er
R
s
PC
(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 1 0 1 Reset
SE
K_
DC LK
CL
C
R_ C_S
ED
)
d)
ed
LE
e
_L
rv
rv
se
se
R
PC
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 286 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
R_ 0_ DT _R DY
0_ T_ EA DY
CL EN DY
PC _TG _W R0 EA
TG RS _R EA
R 0 ME _R
EN
PC _TG _TI R1
K_
R 0 ME
PC TG TI
R_ 0_
d)
PC _TG
ver
se
R
PC
(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 1 1 1 0 1 Reset
PCR_TG0_WDT_READY Represents whether or not the WDT in Timer Group 0 is released from
reset.
0: Not released
1: Released
(RO)
PRELIMINARY
Espressif Systems 287 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EL
N
_S
E R K_E
LK
CL
_C
R_
TG ME
M
TI
TI
0_
0_
d)
)
ed
TG
ve
rv
R_
R_
er
se
s
PC
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_S
K_
LK
L
_C
_C
DT
DT
W
W
0_
0_
)
d)
ed
TG
e
T
rv
rv
R_
R_
se
se
PC
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PCR_TG0_WDT_CLK_EN Configures whether or not to enable the clock of WDT in Timer Group 0.
0: Not enable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 288 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
R_ 1_ DT _R DY
1_ T_ EA DY
CL EN DY
PC _TG _W R0 EA
TG RS _R EA
R 1 ME _R
EN
PC _TG _TI R1
K_
R 1 ME
PC TG TI
R_ 1_
d)
PC _TG
ver
se
R
PC
(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 1 1 1 0 1 Reset
PCR_TG1_WDT_READY Represents whether or not the WDT in Timer Group 1 is released from
reset.
0: Not released
1: Released
(RO)
PRELIMINARY
Espressif Systems 289 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EL
N
_S
E R K_E
LK
CL
_C
R_
TG ME
M
TI
TI
1_
1_
d)
)
ed
TG
ve
rv
R_
R_
er
se
s
PC
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_S
K_
LK
L
_C
_C
DT
DT
W
W
1_
1_
)
d)
ed
TG
e
T
rv
rv
R_
R_
se
se
PC
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PCR_TG1_WDT_CLK_EN Configures whether or not to enable the clock for WDT in Timer Group 1.
0: Not enable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 290 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
IM _R DY
_E
_C _E
ST ER EA
ER ST
SY IM _R
R_ ST ER
PC _SY TIM
R S
)
ed
PC _SY
v
er
R
s
PC
(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 1 0 1 Reset
PCR_SYSTIMER_READY Represents whether or not the System Timer is released from reset.
0: Not released
1: Released
(RO)
SE
K_
K_
CL
CL
C_
C_
UN
UN
_F
_F
R_ d) ER
ER
PC rve TIM
IM
ST
se S
)
)
ed
ed
(re _SY
SY
rv
rv
se
se
R
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 291 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EN
CL EN
AI RS Y
TW I0_ AD
K_
0_ T_
R_ A RE
PC _TW I0_
R A
)
ed
PC _TW
v
er
R
s
PC
(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 1 0 1 Reset
_S
_E
LK
LK
_C
_C
NC
NC
R_ d) FU
FU
PC rve I0_
0_
AI
se A
d)
)
ed
(re _TW
TW
e
rv
rv
se
se
R
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 292 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
S_ T_ Y
R_ S_R _RE Y
I2 S AD
PC _I2 RX EAD
EN
CL EN
K_
R S_ R
PC I2 X_
R_ S_T
)
ed
PC _I2
v
er
R
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 1 1 0 1 Reset
PRELIMINARY
Espressif Systems 293 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
M
_NU
EL
IV
_C _EN
_D
_S
KM
KM
LK
CL
CL
R_ TX_
_
TX
TX
PC S_
S_
S_
d)
d)
ve
ve
I2
I2
I2
R_
R_
er
r
se
s
PC
PC
(re
(re
31 23 22 21 20 19 12 11 0
0 0 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 294 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
1
YN
Y
_X
Z
V_
_
IV
IV
IV
I
_D
_D
_D
_D
KM
KM
KM
LK
L
CL
CL
_C
_C
X_
X_
TX
TX
_T
_T
S_
S_
d)
S
ve
I2
I2
I2
I2
R_
R_
R_
R_
er
s
PC
PC
PC
PC
(re
31 28 27 26 18 17 9 8 0
0 0 0 0 0 0 1 0 Reset
PCR_I2S_TX_CLKM_DIV_Z For b <= a/2, the value of I2S_TX_CLKM_DIV_Z is b. For b > a/2, the
value of I2S_TX_CLKM_DIV_Z is (a - b). (R/W)
PCR_I2S_TX_CLKM_DIV_Y For b <= a/2, the value of I2S_TX_CLKM_DIV_Y is (a%b). For b > a/2,
the value of I2S_TX_CLKM_DIV_Y is (a%(a - b)). (R/W)
PCR_I2S_TX_CLKM_DIV_YN1 For b <= a/2, the value of I2S_TX_CLKM_DIV_YN1 is 0. For b > a/2,
the value of I2S_TX_CLKM_DIV_YN1 is 1. (R/W)
Note:
“a” and “b” represent the denominator and the numerator of the fractional divisor, respectively. For more information, see
Section 28.6 in Chapter I2S Controller (I2S).
PRELIMINARY
Espressif Systems 295 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
M
NU
_
EL
IV
_C _EN
_D
_S
CL EL
RX KM
KM
R_ RX_ _S
LK
L
PC S_ LK
_C
I2 C
RX
R_ S_M
S_
S_
d)
)
ed
ve
PC _I2
I2
I2
rv
R_
er
se
R
s
PC
PC
(re
(re
31 24 23 22 21 20 19 12 11 0
0 0 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 296 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N 1
_Y
Y
X
Z
_
_
IV
IV
IV
IV
_D
_D
_D
_D
KM
KM
KM
KM
CL
CL
CL
_C
X_
X_
X_
RX
_R
_R
_R
_
)
ed
2S
S
I2
I2
I2
rv
_I
R_
R_
R_
se
R
PC
PC
PC
PC
(re
31 28 27 26 18 17 9 8 0
0 0 0 0 0 0 1 0 Reset
PCR_I2S_RX_CLKM_DIV_Z For b <= a/2, the value of I2S_RX_CLKM_DIV_Z is b. For b > a/2, the
value of I2S_RX_CLKM_DIV_Z is (a - b). (R/W)
PCR_I2S_RX_CLKM_DIV_Y For b <= a/2, the value of I2S_RX_CLKM_DIV_Y is (a%b). For b > a/2,
the value of I2S_RX_CLKM_DIV_Y is (a%(a - b)). (R/W)
PCR_I2S_RX_CLKM_DIV_YN1 For b <= a/2, the value of I2S_RX_CLKM_DIV_YN1 is 0. For b > a/2,
the value of I2S_RX_CLKM_DIV_YN1 is 1. (R/W)
Note:
“a” and “b” represent the denominator and the numerator of the fractional divisor, respectively. For more information, see
Section 28.6.
PRELIMINARY
Espressif Systems 297 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N N
ST LK N
_E _E
_R _C _E
ed C G ST
rv AD RE R
se R C _ G_
(re _SA AD RE
R R C_
PC SA D
R_ RA
)
)
ed
PC _SA
v
er
R
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 1 0 0 Reset
PRELIMINARY
Espressif Systems 298 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
UM
_N
_B
_A
EL
IV
IV
IV
_C _EN
_D
_D
_D
_S
DC KM
M
LK
LK
LK
LK
RA CL
_C
_C
_C
SA C_
DC
DC
DC
R_ AD
RA
RA
RA
PC AR
)
ed
SA
SA
SA
S
rv
R_
R_
R_
R_
se
PC
PC
PC
PC
(re
31 23 22 21 20 19 12 11 6 5 0
0 0 0 0 0 0 0 0 0 1 0 4 0 0 Reset
PCR_SARADC_CLKM_DIV_A Configures the denominator of the divisor’s fractional part for SAR
ADC functional clock. (R/W)
PCR_SARADC_CLKM_DIV_B Configures the numerator of the divisor’s fractional part for SAR ADC
functional clock. (R/W)
PCR_SARADC_CLKM_DIV_NUM Configures the integral part of the divisor for SAR ADC functional
clock. (R/W)
PRELIMINARY
Espressif Systems 299 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
L
EN
R_ d) _CL EN
SE
K_
K_
PC rve NS ST_
CL
se E _R
S_
(re _TS NS
EN
R E
)
)
ed
ed
PC _TS
TS
rv
rv
se
se
R
PC
(re
(re
31 24 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PCR_TSENS_CLK_EN Configures whether or not to enable the clock of the temperature sensor.
0: Not enable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 300 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
TA RS Y
_E
_C E
_J G_ AD
G T_
AL A E
RI _JT _R
SE AL AG
B_ RI _JT
US _SE AL
R_ SB ERI
PC _U _S
R SB
d)
ve
PC _U
er
R
s
PC
(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 0 1 Reset
PRELIMINARY
Espressif Systems 301 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
TX ST Y
_E
_C _E
TM _R D
IN TX EA
R_ TM _R
PC _IN TX
R TM
d)
PC _IN
ve
er
R
s
PC
(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 1 0 1 Reset
N
LK N
NT ST Y
_E
_C _E
PC T_R D
R_ N REA
PC _PC T_
R N
d)
PC _PC
e
rv
se
R
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 302 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
ET _R Y
_E
_C _E
R_ M EAD
M ST
PC _ET _R
R M
)
ed
PC _ET
v
er
R
s
PC
(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 1 0 1 Reset
N
LK N
PW _R DY
_E
_C _E
R_ M EA
M ST
PC _PW _R
R M
)
PC PW
ed
rv
R_
se
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 303 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EL
_C _EN
M
_S
NU
M
_
PW LK
LK
IV
_C
_D
M
M
d)
d)
W
PW
ve
ve
_P
R_
R_
er
r
se
R
s
PC
PC
PC
(re
(re
31 23 22 21 20 19 12 11 0
0 0 0 0 0 0 0 0 0 1 0 4 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PCR_PWM_DIV_NUM Configures the integral part of the divisor for MCPWM functional clock. (R/W)
N
LK N
PA _R DY
_E
_C _E
R_ RL EA
RL ST
PC _PA L_R
R R
d)
PC _PA
e
rv
se
R
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 304 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
UM
_N
L
IV
EN
RL K_R EN
SE
_D
X_
X_
L T_
RX
_R
R_ L_C RS
K_
LK
PC AR RX_
CL
_C
P _
L_
R_ RL
R
)
ed
PC _PA
PA
PA
rv
R_
se
R
PC
PC
(re
31 20 19 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 Reset
PRELIMINARY
Espressif Systems 305 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
UM
_N
L
V
EN
RL K_T EN
SE
DI
X_
X_
X_
L T_
_T
T
R_ L_C RS
K_
LK
PC AR TX_
CL
_C
P _
L_
R_ RL
R
d)
PC _PA
PA
PA
ve
R_
er
R
s
PC
PC
(re
31 20 19 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 Reset
EN
CL EN
K_
A_ ST_
DM R
G A_
R_ DM
e d)
PC _G
rv
se
R
PC
(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 1 Reset
PRELIMINARY
Espressif Systems 306 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
SP _R DY
_E
_C E
I2 ST_
R_ I2 EA
PC _SP _R
R I2
)
ed
PC _SP
v
er
R
s
PC
(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 1 0 1 Reset
_S
KM
M
LK
CL
2_
I2
)
d)
ed
PI
SP
e
_S
rv
rv
R_
se
se
R
PC
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 307 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EN
CL EN
AE RS Y
R_ S_ AD
K_
S_ T_
PC _AE _RE
R S
)
ed
PC _AE
v
er
R
s
PC
(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 1 0 1 Reset
EN
CL EN
SH RS Y
R_ A_ EAD
K_
A_ T_
PC _SH _R
R A
)
ed
PC SH
rv
R_
se
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 308 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EN
CL EN
RS RS Y
R_ SA_ EAD
K_
A_ T_
PC _R _R
R SA
)
ed
PC _R
v
er
R
s
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 309 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
_P RC PD
U
D E_P
EM O _
M _F CE
A_ EM OR
RS M _F
R_ SA_ EM
PC _R _M
R SA
d)
ve
PC _R
er
R
s
PC
(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 0 Reset
PCR_RSA_MEM_FORCE_PD Configures whether or not to force power down RSA internal memory.
0: Not force power down
1: Force power down
(R/W)
PRELIMINARY
Espressif Systems 310 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EN
CL EN
EC _R Y
R_ C EAD
K_
C_ ST_
PC _EC _R
R C
)
ed
PC _EC
rv
se
R
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 311 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
_P RC PD
U
D E_P
EM O _
M _F CE
C_ EM OR
EC _M _F
R_ C EM
PC _EC _M
R C
d)
PC _EC
ve
er
R
s
PC
(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 0 Reset
PCR_ECC_MEM_FORCE_PD Configures whether or not to force power down ECC internal memory.
0: Not force power down
1: Force power down
(R/W)
PRELIMINARY
Espressif Systems 312 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
R_ S_R ADY
_E
_C _E
DS ST
PC _D RE
R S_
)
ed
PC _D
rv
se
R
PC
(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 1 0 1 Reset
N
LK N
AC RST Y
_E
_C _E
HM C_ AD
R_ MA RE
PC _H C_
R MA
d)
e
PC H
rv
R_
se
PC
(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 1 0 1 Reset
PRELIMINARY
Espressif Systems 313 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EN
CL EN
DS _RS DY
K_
A_ T_
EC SA EA
R_ D _R
PC _EC SA
R D
d)
PC _EC
ve
er
R
s
PC
(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 1 0 1 Reset
N
LK N
_E
_C _E
UX ST
M R
IO X_
R_ MU
)
ed
PC _IO
rv
se
R
PC
(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 1 Reset
PRELIMINARY
Espressif Systems 314 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
L
C_ _EN
SE
K_
K
_F _CL
CL
UX NC
UN
FU
R_ UX_
M
M
d)
)
ed
IO
IO
ve
rv
R_
er
se
s
PC
PC
(re
(re
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 315 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EN
CL EN
TO RS Y
NI _ D
K_
R_ T_
O OR EA
_M NIT R_R
EM O O
M _M IT
R_ EM ON
PC _M _M
R EM
d)
ve
PC _M
er
R
s
PC
(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 1 0 1 Reset
EN
CL EN
K_
E_ T_
AC _RS
TR E
R_ AC
d)
PC _TR
e
rv
se
R
PC
(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 1 Reset
PCR_TRACE_CLK_EN Configures whether or not to enable the clock of RISC-V Trace Encoder.
0: Not enable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 316 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
LK N
_E
_C _E
ST ST
SI _R
AS ST
R_ SI
d)
PC _AS
ve
er
R
s
PC
(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 1 Reset
EN
CL EN
K_
E_ ST_
CH _R
CA HE
R_ AC
)
ed
PC _C
rv
se
R
PC
(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 1 Reset
PRELIMINARY
Espressif Systems 317 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
_R EN
_E
ST
UT T_
EO _RS
ed IM T
rv _T U
se PU EO
(re _C TIM
R P_
d)
)
ve
PC _H
er
R
s
PC
(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
L
R
SE
_F
K_
AL
CL
XT
C_
K_
)
d)
)
ed
ed
SO
CL
ve
rv
rv
R_
R_
r
se
se
se
PC
PC
(re
(re
(re
31 30 24 23 18 17 16 15 0
0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 318 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
_O
E
RC
UM
O
_N
_F
AY
DE
EL
O
_D
M
T_
TI
AI
AI
_W
W
U_
U
)
)
ed
ed
CP
CP
rv
rv
R_
R_
se
se
PC
PC
(re
(re
31 8 7 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 1 0 0 0 Reset
PCR_CPU_WAITI_DELAY_NUM Configures the number of delay cycles to turn off the CPU clock
after the CPU enters the WFI mode because of WFI instruction.
Measurement unit: CPU_CLK cycles.
(R/W)
UM
_N
D IV
U_
d)
CP
e
rv
R_
se
PC
(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 0 Reset
PRELIMINARY
Espressif Systems 319 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
UM
_N
IV
_D
HB
)
ed
A
rv
R_
se
PC
(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 0 Reset
M
NU
_
IV
_D
SE
M
EA
NU
CR
V_
DE
DI
B_
B_
)
ed
AP
AP
rv
R_
R_
se
PC
PC
(re
31 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PCR_APB_DIV_NUM Configures the divisor of AHB_CLK to generate APB_CLK during the second
division.
(R/W)
PRELIMINARY
Espressif Systems 320 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
M LK N
LK N
N
96 C _E
_C _E
_E
L_ M_ LK
PL 64 _C
R_ L_ 0M
PC _PL _48
)
R L
ed
PC _PL
v
er
R
s
PC
(re
28 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 Reset
)
ed
FO
e
rv
rv
R_
se
se
PC
(re
(re
31 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 Reset
PCR_FOSC_TICK_NUM Configures the clock divisor for RC_FAST_CLK before it enters the calibra-
tion module. (R/W)
PRELIMINARY
Espressif Systems 321 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
LE
_S
M
DE
EL
O
M
S
K_
K_
)
ed
32
32
v
R_
R_
s er
PC
PC
(re
29 2 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
N
O
E_
RC
O
_F
PD
PU
E
AT
E_
E_
RC
RC
G
LK
O
_C
_F
_F
M
M
d)
d)
RO
RO
RO
ve
e
rv
R_
R_
R_
r
se
se
PC
PC
PC
(re
(re
31 19 18 17 16 15 14 13 12 0
PRELIMINARY
Espressif Systems 322 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
N
E _O
RC
O
_F
PD
PU
E
AT
E_
E_
RC
RC
G
LK
O
_C
_F
_F
AM
AM
AM
d)
d)
)
ed
SR
SR
SR
ve
ve
rv
R_
R_
R_
er
er
se
s
s
PC
PC
PC
(re
(re
(re
31 30 29 25 24 15 14 10 9 5 4 0
L
SE
K_
CL
C_
d)
SE
ve
R_
r
se
PC
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PCR_SEC_CLK_SEL Configures the clock source for the External Memory Encryption and Decryp-
tion module.
0 (default): XTAL_CLK
1: RC_FAST_CLK
2: PLL_F64M_CLK
3: PLL_F96M_CLK
(R/W)
PRELIMINARY
Espressif Systems 323 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
TE
DA
P
_U
CK
O
CL
S_
d)
BU
ve
R_
s er
PC
(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
M
NU
V_
I
_D
LK
_C
R1
d)
d)
SA
ve
e
rv
R_
er
se
s
PC
(re
(re
31 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 Reset
PCR_SAR1_CLK_DIV_NUM Configures the divisor for SAR ADC clock to generate ADC analog con-
trol signals. (R/W)
_F
FR
SC
L_
)
ed
FO
PL
rv
R_
R_
se
PC
PC
(re
31 18 17 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 96 8 Reset
PRELIMINARY
Espressif Systems 324 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
TE
)
ed
DA
rv
R_
se
PC
(re
31 28 27 0
0 0 0 0 0x2210080 Reset
EL
L
SE
_S
LK
K_
CL
_C
W
T_
O
AS
SL
_F
T_
ST
RS
)
KR
ed
LK
L
rv
_C
_C
se
LP
LP
(re
23 4 3 2 1 0
PRELIMINARY
Espressif Systems 325 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EN N
O OE
EN
O EN
K_ E_
_O
SL _O
_C RS FA _O N
32 US
W
_C d) XT E_E N
AO FA N
LK T_ SC EN
LP LK ST_ G _OE
N_ ST
(re LK ST_ OW EN
LP LK T_ ST EN
LP rve ST_ R OE
T_ N_ E
AL F
RS AO _O
_C RS SO _O
_C R SL _O
se R CO _
_C R RN S
LP LK T_ SC
LP LK ST_ BU
_C RS FO
_C R LP
LP LK T_
LP LK T_
_C RS
_C RS
LP LK )
d)
LP LK
ve
er
_C
s
LP
(re
31 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 Reset
PRELIMINARY
Espressif Systems 326 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
)
ed
LK
rv
_C
se
LP
(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
PRELIMINARY
Espressif Systems 327 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
EN
T_
E SE
_R
N_ ER _EN _EN
CO EN
RE
E_ ET_
AO IM ET ET
T_ _T ES ES
US S
EF _RE
RS LP _R _R
LK T_ DT RI
_C RS W PE
LP LK ST_ A_
_C R AN
LP LK T_
_C RS
d)
LP LK
ver
_C
se
LP
(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
PRELIMINARY
Espressif Systems 328 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
R
CL
T_ AG LR
US ET
E_
SE FL _C
CA _S
RE T_ AG
AG
0_ SE FL
FL
RE _RE ET_
T_
E
SE
US
CO E0 S
T_ R _RE
RE
CA
0_
T_
RS CO E0
RE
SE
LK T_ R
_C RS CO
CO
E
_R
LP LK T_
T_
ST
_C RS
RS
)
R
ed
LP LK
LK
CL
v
er
_C
_C
_
s
LP
LP
LP
(re
31 30 29 28 6 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 Reset
PRELIMINARY
Espressif Systems 329 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
TH
G
EN
N
_E
_L
ET
ET
ES
ES
_R
_R
T
AI
EN
PU
PU
_W
L_
_C
_C
LL
L
DT
DT
TA
TA
_W
_S
_S
C_
U
PU
TC
CP
RT
_C
_R
T_
T_
ST
ST
RS
RS
)
R
ed
LK
LK
LK
LK
rv
_C
_C
_C
_C
se
LP
LP
LP
LP
(re
31 30 26 25 24 22 21 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 0 Reset
LP_CLKRST_CPU_STALL_WAIT Configure the time interval between CPU stall and reset.
Measurement unit: LP_DYN_FAST_CLK clock cycles.
(R/W)
LP_CLKRST_CPU_STALL_EN Configures whether or not CPU will stall before RWDT and software
reset CPU.
0: CPU will not stall.
1: CPU will stall.
(R/W)
)
ed
LK
rv
_C
se
LP
(re
31 22 21 0
0xac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 330 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
3 2K
P_ SC
SC
AL
_H O
FO
XT
G _S
P_
IC HP
_H
T_ G_
G
_C d) IC
RS IC
LP rve ST_
LK T_
_C RS
LP LK )
d)
se R
(re LK
ve
er
_C
s
LP
(re
31 30 29 28 27 0
1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
d)
LK
e
rv
_C
se
LP
(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
PRELIMINARY
Espressif Systems 331 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
M
NU
W
V_
_S T
LO
SC S
ed LP_ EL_ AL K
I
O FA
_D
se ST P_S _X L32
L_ C_
ER
R L EL TA
SE OS
IM
T
LK T_ _S _X
ET
_C RS LP EL
BL
LP LK ST_ _S
_
_C R LP
LP
LP LK ST_
T_
RS
))
d)
)
_C R
ed
LP K
LK
ve
rv
rv
er
_C
_C
se
s
LP
LP
(re
(re
(re
31 30 29 28 27 26 25 24 23 12 11 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LP_CLKRST_LP_BLETIMER_DIV_NUM Configures the divisor of the clock divider for RTC BLE
Timer. The working clock frequency of RTC BLE Timer is equal to the source clock frequency
divided by ((LP_CLKRST_LP_BLETIMER_DIV_NUM - 1) / 2). (R/W)
2K
K
K
32
32
L3
L3
AL
TA
TA
AL
T
XT
_X
_X
_X
UF
ES
C_
M
DG
DB
DR
DA
T_
T_
T_
T_
RS
RS
RS
RS
d)
LK
LK
LK
LK
r ve
_C
_C
_C
_C
se
LP
LP
LP
LP
(re
31 29 28 27 25 24 22 21 0
3 0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 332 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
E
AT
_D
ST
N
_E
KR
LK
CL
_C
T_
ST
RS
KR
LK
CL
_C
_
LP
LP
31 30 0
0 0x2207280 Reset
LP_CLKRST_CLK_EN Configures whether to force enable the clock gate for header registers.
0: Invalid
1: Force enable
(R/W)
)
ed
O
rv
_A
se
LP
(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
PRELIMINARY
Espressif Systems 333 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
7 Reset and Clock GoBack
ET
ES
_R
S W
0_
RE
CO
U_
CP
N_
d)
)
ed
ve
rv
er
_A
se
s
LP
(re
(re
31 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
d)
LP rve
e
RI
rv
se
se
(re
(re
31 30 29 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
)
ed
LP rve
RI
rv
se
se
(re
(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
PRELIMINARY
Espressif Systems 334 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
8 Chip Boot Control GoBack
8.1 Overview
Chip boot process and some chip functions are determined on power-on or hardware reset by strapping pins
and eFuses. The following functionality can be determined:
• GPIO8
• GPIO9
• GPIO25
During power-on reset, and brownout reset (see Chapter 7 Reset and Clock), hardware captures samples and
stores the voltage level of strapping pins as strapping bit of “0” or “1” in latches, and holds these bits until the
chip is powered down or next chip reset. Software can read the latch status (strapping value) from
GPIO_STRAPPING.
Notice:
Only documented patterns should be used. If an undocumented pattern is used, it may trigger unexpected
behaviors.
PRELIMINARY
Espressif Systems 335 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
8 Chip Boot Control GoBack
To change the strapping bit values, 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-H2. After the reset is released, the strapping
pins work as normal-function pins.
In SPI Boot mode, the ROM bootloader loads and executes the program from SPI flash to boot the system. SPI
Boot mode can be further classified as follows:
• Normal Flash Boot: supports Secure Boot. The ROM bootloader loads the program from flash into SRAM
and executes it. In most practical scenarios, this program is the 2nd stage bootloader, which later boots
the target application.
• Direct Boot: does not support Secure Boot and programs run directly from flash. To enable this mode,
make sure that the first two words of the bin file downloaded to flash are 0xaedb041d. For more detailed
process, see Figure 8-1.
In Joint Download Boot mode, users can download binary files into flash using UART0 or USB interface. It is also
possible to download binary files into SRAM and execute it from SRAM.
In SPI Download Boot mode, users can download binary files into flash using SPI interface. It is also possible to
PRELIMINARY
Espressif Systems 336 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
8 Chip Boot Control GoBack
*Note: The strapping values ”1xxx” and ”01xx/0001” are the combination of GPIO9�GPIO8�GPIO3 and GPIO2
pins, see Table 8-2.
• EFUSE_DIS_FORCE_DOWNLOAD
– If this eFuse is 0 (default), software can force switch the chip from SPI Boot mode to Joint Download
Boot mode by setting register LP_AON_FORCE_DOWNLOAD_BOOT and triggering a CPU reset. In
this case, hardware overwrites GPIO_STRAPPING[3:2] from ”1x” to ”01”.
be overwritten.
• EFUSE_DIS_DOWNLOAD_MODE
If this eFuse is 1, Joint Download Boot mode is disabled, and GPIO_STRAPPING will not be overwritten by
LP_AON_FORCE_DOWNLOAD_BOOT.
• EFUSE_ENABLE_SECURITY_DOWNLOAD
If this eFuse is 1, Joint Download Boot mode only allows reading, writing, and erasing plaintext flash and
does not support any SRAM or register operations. Ignore this eFuse if Joint Download Boot mode is
disabled.
• EFUSE_DIS_DIRECT_BOOT
USB Serial/JTAG Controller can also force switch the chip to Joint Download Boot mode from SPI Boot mode,
and vice versa. For detailed information, please refer to Chapter 30 USB Serial/JTAG Controller
(USB_SERIAL_JTAG).
ROM message is printed to UART0 and USB Serial/JTAG Controller by default during power-on. Users can
disable the printing to USB Serial/JTAG Controller by setting the eFuse bit
EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT.
Note that if EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT is set to 0 to print to USB, but the USB Serial/JTAG
Controller has been disabled, then ROM messages will not be printed to USB Serial/JTAG Controller.
PRELIMINARY
Espressif Systems 338 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
8 Chip Boot Control GoBack
PRELIMINARY
Espressif Systems 339 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
9.1 Overview
The interrupt matrix embedded in ESP32-H2 routes one or multiple peripheral interrupt sources to any one of the
ESP-RISC-V CPU’s peripheral interrupts.
The ESP32-H2 has 65 peripheral interrupt sources that can be routed to any of the 28 CPU peripheral interrupts
using the interrupt matrix.
Note:
This chapter focuses on how to map peripheral interrupt sources to the CPU interrupts. For information about interrupt
configuration, vector, and interrupt handling operations recommended by the ISA, please refer to Chapter 1 ESP-RISC-V
CPU > Section 1.6 Interrupt Controller.
9.2.1 Interrupt
An interrupt refers to the event or condition that occurs, causing the CPU to temporarily suspend its current
execution and handle a higher-priority task. It is a mechanism that allows the CPU to respond to specific events
promptly.
The ESP32-H2 Technical Reference Manual may use the term “interrupt” in a broader sense to refer to both
interrupt signal and interrupt source.
From the perspective of peripherals, interrupt signals are generated by the peripheral’s internal interrupt sources
and are sent to the interrupt matrix.
From the perspective of the interrupt matrix, it receives the interrupt signals sent from the peripheral and
considers them interrupt sources. The interrupt matrix then outputs CPU peripheral interrupt signals to the
CPU.
From the perspective of the CPU, the interrupt signals from the interrupt matrix become sources and are sent to
the CPU core together with the core local interrupt sources.
PRELIMINARY
Espressif Systems 340 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
9.3 Features
The interrupt matrix embedded in ESP32-H2 has the following features:
• Multiple interrupt sources mapping to a single CPU interrupt (i.e., shared interrupts)
9.4 Architecture
Figure 9-2 shows the structure of the interrupt matrix.
You need to configure the interrupt matrix registers to map the peripheral interrupt sources to the CPU interrupts.
The Interrupt Matrix Controller in Figure 9-2 manages the mapping and sends the interrupt status of each
interrupt source to the interrupt status registers which belong to the interrupt matrix registers.
• Column “Interrupt Source Mapping Register”: Registers used to configure routing of the peripheral interrupt
sources to the CPU peripheral interrupts.
• Column “Interrupt Status Register”: Registers used to reflect the interrupt source status.
– Column “Interrupt Status Register - Bit”: Bit position in status register, indicating the interrupt status.
PRELIMINARY
Espressif Systems 342 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
(ASSIST_DEBUG�MEM_MONITOR)
12 ESP-RISC-V CPU TRACE_INTR INTMTX_CORE0_TRACE_INTR_MAP_REG 12 INTMTX_CORE0_INT_STATUS_0_REG
13 Cache [to be added later] CACHE_INTR INTMTX_CORE0_CACHE_INTR_MAP_REG 13
14 System Registers CPU_PERI_TIMEOUT_INTR INTMTX_CORE0_CPU_PERI_TIMEOUT_INTR_MAP_REG 14
15 n/a reserved reserved 15
16 n/a reserved reserved 16
17 n/a reserved reserved 17
18 n/a reserved reserved 18
19 n/a reserved reserved 19
ESP32-H2 TRM (Pre-release v0.4)
GoBack
27 Access Permission Management (APM) HP_APM_M1_INTR INTMTX_CORE0_HP_APM_M1_INTR_MAP_REG 27
28 Access Permission Management (APM) HP_APM_M2_INTR INTMTX_CORE0_HP_APM_M2_INTR_MAP_REG 28
29 Access Permission Management (APM) HP_APM_M3_INTR INTMTX_CORE0_HP_APM_M3_INTR_MAP_REG 29
30 n/a reserved reserved 30
31 I2S Controller (I2S) I2S_INTR INTMTX_CORE0_I2S_INTR_MAP_REG 31
Espressif Systems
GoBack
(ECDSA)
9 Interrupt Matrix (INTMTX) GoBack
Note:
For detailed information about the functions and configuration procedure of CPU interrupts, see Chapter 1 ESP-RISC-V
CPU > Section 1.6Interrupt Controller. The configuration registers of CPU interrupts are listed in Section 9.6.2 Interrupt
Priority Register Summary.
• Num_P: stands for the index of CPU interrupts which can be 1, 2, 5, 6, 8 ~ 31.
PRELIMINARY
Espressif Systems 345 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
PRELIMINARY
Espressif Systems 346 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
The abbreviations given in Column Access are explained in Section Access Types for Registers.
GoBack
INTMTX_CORE0_HP_APM_M3_INTR_MAP_REG HP_APM_M3_INTR mapping register 0x0074 R/W
INTMTX_CORE0_I2S_INTR_MAP_REG I2S_INTR mapping register 0x007C R/W
Espressif Systems
GoBack
INTMTX_CORE0_GPSPI2_INTR_MAP_REG GPSPI2_INTR mapping register 0x00EC R/W
INTMTX_CORE0_AES_INTR_MAP_REG AES_INTR mapping register 0x00F0 R/W
Espressif Systems
The abbreviations given in Column Access are explained in Section Access Types for Registers.
GoBack
INTPRI_CORE0_CPU_INT_PRI_6_REG Priority configuration register for CPU interrupt 6 0x0024 R/W
INTPRI_CORE0_CPU_INT_PRI_7_REG Priority configuration register for CPU interrupt 7 0x0028 R/W
Espressif Systems
GoBack
INTPRI_CPU_INTR_FROM_CPU_0_REG CPU_INTR_FROM_CPU_0 mapping register 0x0090 R/W
INTPRI_CPU_INTR_FROM_CPU_1_REG CPU_INTR_FROM_CPU_1 mapping register 0x0094 R/W
Espressif Systems
GoBack
9 Interrupt Matrix (INTMTX) GoBack
9.7 Registers
9.7.1 Interrupt Matrix Registers
The addresses in this section are relative to the interrupt matrix base address provided in Table 4-2 in Chapter 4
System and Memory.
PRELIMINARY
Espressif Systems 352 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
TX
r ve
TM
se
(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 0 Reset
INTMTX_CORE0_SOURCE_INTR_MAP Map the interrupt source (SOURCE) into one CPU interrupt.
For the information of SOURCE, see Table 9-1. (R/W)
PRELIMINARY
Espressif Systems 353 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
0
S_
U
AT
ST
T_
IN
0_
RE
_CO
TX
TM
IN
31 0
0x000000 Reset
1
S_
TU
TA
_S
T
IN
0_
RE
O
_C
TX
TM
IN
31 0
0x000000 Reset
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 354 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
E
AT
_D
G
RE
T_
UP
RR
TE
IN
0_
RE
O
_C
d)
TX
ve
er
TM
s
(re
IN
31 28 27 0
0 0 0 0 0x2209150 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 355 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
PE
Y
_T
NT
U _I
CP
0_
RE
CO
I_
R
TP
IN
31 0
0 Reset
SU
AT
ST
IP_
_E
T
IN
U_
CP
0_
RE
CO
I_
R
TP
IN
31 0
0 Reset
PRELIMINARY
Espressif Systems 356 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
AP
_M
_n
RI
P
U_
CP
0_
RE
O
d)
_C
ve
RI
er
TP
s
(re
IN
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
INTPRI_CORE0_CPU_PRI_n_MAP Configures the priority for CPU interrupt n. The priority here can
be 1 (lowest) ~ 15 (highest). For more information about how to use this register, see Chapter 1
ESP-RISC-V CPU > Section 1.6Interrupt Controller. (R/W)
H
ES
HR
T_T
IN
U_
CP
0_
RE
CO
d)
I_
e
rv
PR
se
T
(re
IN
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 357 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
9 Interrupt Matrix (INTMTX) GoBack
R
EA
CL
T_
IN
U_
CP
0_
RE
O
_C
RI
TP
IN
31 0
0 Reset
_n
PU
_C
M
O
FR
R_
NT
_I
PU
d)
C
I_
ve
PR
r
se
T
(re
IN
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
_
RI
rv
se
TP
(re
IN
31 28 27 0
0 0 0 0 0x2201090 Reset
PRELIMINARY
Espressif Systems 358 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
10.1 Overview
The Event Task Matrix (ETM) peripheral contains 50 configurable channels. Each channel can map an event of
any specified peripheral to a task of any specified peripheral. In this way, peripherals can be triggered to execute
specified tasks without CPU intervention.
10.2 Features
The Event Task Matrix has the following features:
• An ETM channel can be set up to receive any event, and map it to any task
• Each ETM channel can be enabled independently. If not enabled, the channel will not respond to the
configured event and generate the task mapped to that event
• Peripherals supporting ETM include GPIO, LED PWM, general-purpose timers, RTC Timer, system timer,
MCPWM, temperature sensor, ADC, I2S, GDMA, and PMU
Note that the 50 ETM channels are identical regarding their features and operations. Thus, in the following
sections ETM channels are collectively referred to as channeln (where n ranges from 0 to 49).
The Event Task Matrix has 50 independent channels. A channel can choose any event as input, and map the
event to any task as output (For configuration procedures, refer to Section 10.3.2 and Section 10.3.3
PRELIMINARY
Espressif Systems 359 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
respectively). Each channel has an individual enable bit (For configuration procedures, refer to Section
10.3.5).
SOC_ETM_CH_ENABLEn
SOC_ETM_CH_DISABLEn
SOC_ETM_CH_ENABLEDn
ETM channel
Events
DEMUX
Tasks
MUX
Channel n
SOC_ETM_CHn_EVT_ID SOC_ETM_CHn_TASK_ID
Figure 10-2 illustrates the structure of an ETM channel. The SOC_ETM_CHn_EVT_ID field configures the MUX
(multiplexer) to select one of the events as the input of channeln. The SOC_ETM_CHn_TASK_ID field configures
the DEMUX (demultiplexer) to map the event selected by channeln to one of the tasks. SOC_ETM_CH_ENABLEn
and SOC_ETM_CH_DISABLEn are used to enable or disable channeln. SOC_ETM_CH_ENABLEDn is used to
indicate the status of the channeln.
10.3.2 Events
An ETM channel can be set up to choose which event to receive by configuring the SOC_ETM_CHn_EVT_ID field.
Table 10-1 shows the configuration values of SOC_ETM_CHn_EVT_ID and their corresponding events.
PRELIMINARY
Espressif Systems 360 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
Each event corresponds to a pulse signal generated by the corresponding peripheral. When the pulse signal is
valid, the corresponding event is considered as received.
For more detailed descriptions of an event, please refer to the chapter for the peripheral generating this
event.
10.3.3 Tasks
An ETM channel can be set up to map its event to one of the tasks by configuring the SOC_ETM_CHn_TASK_ID
field. Table10-2 shows the configuration values of SOC_ETM_CHn_TASK_ID and their corresponding
tasks.
PRELIMINARY
Espressif Systems 363 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
PRELIMINARY
Espressif Systems 364 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
When a channel receives a valid event pulse signal, it generates the mapped task pulse signal.
For more detailed descriptions of a task, please refer to the chapter for the peripheral receiving this task.
Events from different channels can be optionally mapped to the same task (For example, field
SOC_ETM_CHn_TASK_ID of multiple channels can be configured with the same value, and field
SOC_ETM_CHn_EVT_ID can be configured with the same or different values). In this case, when the event
received by any of the channels is valid, the task is generated. If events received by multiple channels are valid at
the same time, the task will be generated only once.
PRELIMINARY
Espressif Systems 366 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
Events Tasks
ETM channel
DEMUX
MUX
peripheraly clock domain Channel n peripheraly clock domain
ETM is running at the AHB_CLK domain (see Chapter 7 Reset and Clock). Each event corresponds to a pulse
signal generated by the corresponding peripheral in its clock domain, while each task is mapped by the ETM to a
pulse signal under its corresponding peripheral clock domain. The peripherals generating events, the Event Task
Matrix, and peripherals receiving tasks are not necessarily running off the same clock and as such need to be
synchronized. Therefore, there must be a minimum interval between two consecutive events to avoid event loss:
to make sure the Event Task Matrix receives every event successfully, for peripherals generating event pulses, the
interval between two consecutive pulses must be greater than one ETM clock cycle, namely
ceil( peripheral_clock_f requency
ET M _clock_f requency ) in the unit of peripheral clock cycles.
For example, assuming that event 1 generated by peripheral A is in the 96 MHz clock domain (PLL_F96M_CLK),
and the ETM runs in the 32 MHz clock domain (AHB_CLK). To receive each event 1 successfully, the interval
between two consecutive event 1 must be greater than three peripheral A clock cycles (i.e. one ETM clock
cycle).
Likewise, to make sure the Event Task Matrix maps the received event (i.e. event synchronized to the ETM’s
clock domain) successfully to a task, the interval between two consecutive event pulses in the ETM clock domain
ET M _clock_f requency
must be greater than one peripheral clock cycle, namely ceil( peripheral_clock_f requency ) in the unit of ETM clock
cycles.
For example, assuming that task 1 received by peripheral B is in the 8 MHz clock domain (RC_FAST_CLK), and
the ETM runs in the 32 MHz clock domain (AHB_CLK). To map each received event successfully to task 1, the
interval between two consecutive events must be greater than four ETM clock cycles (i.e. one peripheral B clock
cycle).
As a result, to map two consecutive events generated by peripheral A to peripheral B, the interval between these
two events must be ceil( peripheral_A_clock_f requency
ET M _clock_f requency ) ∗ ceil( peripheral_B_clock_f
ET M _clock_f requency
requency ) in the unit of peripheral A
clock cycles.
For example, assuming that event 1 generated by peripheral A is in the 96 MHz clock domain (PLL_F96M_CLK),
task 1 received by peripheral B is in the 8 MHz clock domain (RC_FAST_CLK), and the ETM runs in the 32 MHz
clock domain (AHB_CLK). To successfully map each event 1 (generated by peripheral A) to task 1 (received by
peripheral B), the interval between two consecutive event 1 must be greater than 3 ∗ 4 = 12 peripheral A clock
cycles.
PRELIMINARY
Espressif Systems 367 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
1. Write 1 to SOC_ETM_CH_ENABLEn
2. Read SOC_ETM_CH_ENABLEDn. 1 indicates that channeln has been enabled, and 0 indicates disabled
1. Write 1 to SOC_ETM_CH_DISABLEn
5. When channeln no longer needs to map the selected event to the selected task, disable channeln by
setting SOC_ETM_CH_DISABLEn. To configure a new event and task mapping, repeat Steps 2 to 4. If no
configurations, channeln will remain disabled
6. The ETM module can be reset by writing 0 and then 1 to the PCR_ETM_RST_EN field. Reset is finished
when PCR_ETM_READY becomes 1
PRELIMINARY
Espressif Systems 368 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 369 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
PRELIMINARY
Espressif Systems 370 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
PRELIMINARY
Espressif Systems 371 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
0
0
31
31
SO SO
C
10.5
C_
0
0
30
30
Memory.
SO E SO _E
C TM C TM
0
0
29
29
SO _E _C SO _E _C
C TM H_ C TM H_
0
0
28
28
(WT)
SO _E _C EN SO _E _C EN
C TM H_ AB C TM H_ AB
0
0
27
27
SO _E _C EN LE SO _E _C EN LE
Espressif Systems
C TM H_ AB 31 C TM H_ AB D3
1: Enable
0
0
26
26
1: Enabled
SO _E _C EN LE SO _E _C EN LE 1
0: Disabled
(R/WTC/SS)
C TM H_ AB 30 C TM H_ AB D3
0
0
25
25
Registers
SO _E _C EN LE SO _E _C EN LE 0
C TM H_ AB 29 C TM H_ AB D2
0
0
24
24
SO _E _C EN LE SO _E _C EN LE 9
C TM H_ AB 28 C TM H_ AB D2
0: Invalid. No effect
0
0
23
23
SO _E _C EN LE SO _E _C EN LE 8
C TM H_ AB 27 C TM H_ AB D2
0
0
22
22
SO _E _C EN LE SO _E _C EN LE 7
10 Event Task Matrix (SOC_ETM)
C TM H_ AB 26 C TM H_ AB D2
0
0
21
21
SO _E _C EN LE SO _E _C EN LE 6
C TM H_ AB 25 C TM H_ AB D2
0
0
20
20
SO _E _C EN LE SO _E _C EN LE 5
C TM H_ AB 24 C TM H_ AB D2
0
0
19
19
SO _E _C EN LE SO _E _C EN LE 4
C TM H_ AB 23 C TM H_ AB D2
0
0
18
18
SO _E _C EN LE SO _E _C EN LE 3
C TM H_ AB 22 C TM H_ AB D2
0
0
17
17
SO _E _C EN LE SO _E _C EN LE 2
C TM H_ AB 21 C TM H_ AB D2
0
0
16
16
SO _E _C EN LE SO _E _C EN LE 1
C TM H_ AB 20 C TM H_ AB D2
0
0
15
15
SO _E _C EN LE SO _E _C EN LE 0
C TM H_ AB 19 C TM H_ AB D1
372
0
0
14
14
SO _E _C EN LE SO _E _C EN LE 9
C TM H_ AB 18 C TM H_ AB D1
0
0
13
13
SO _E _C EN LE SO _E _C EN LE 8
C TM H_ AB 17 C TM H_ AB D1
0
0
12
12
SO _E _C EN LE SO _E _C EN LE 7
C TM H_ AB 16 C TM H_ AB D1
0
0
11
11
SO _E _C EN LE SO _E _C EN LE 6
C TM H_ AB 15 C TM H_ AB D1
10
10
SO _E _C EN LE SO _E _C EN LE 5
C TM H_ AB 14 C TM H_ AB D1
9
9
0
0
SO _E _C EN LE SO _E _C EN LE 4
C TM H_ AB 13 C TM H_ AB D1
8
8
0
0
SO _E _C EN LE SO _E _C EN LE 3
C TM H_ AB 12 C TM H_ AB D1
SOC_ETM_CH_ENABLEDn (n: 031) Represents the status of channeln.
7
7
0
0
SO _E _C EN LE SO _E _C EN LE 2
C TM H_ AB 11 C TM H_ AB D1
0
0
SO _E _C EN LE SO _E _C EN LE 1
Register 10.1. SOC_ETM_CH_ENA_AD0_REG (0x0000)
C TM H_ AB 10 C TM H_ AB D1
5
5
0
0
SO _E _C EN LE SO _E _C EN LE 0
C TM H_ AB 9 C TM H_ AB D9
4
4
0
0
SO _E _C EN LE SO _E _C EN LE
C TM H_ AB 8 C TM H_ AB D8
3
3
0
0
SO _E _C EN LE SO _E _C EN LE
C TM H_ AB 7 C TM H_ AB D7
2
2
0
0
SO _E _C EN LE SO _E _C EN LE
1
C TM H_ AB 6 C TM H_ AB D6
1
0
0
SO _E _C EN LE SO _E _C EN LE
C TM H_ AB 5 C TM H_ AB D5
0
0
SO _E _C EN LE SO _E _C EN LE
C_ TM H_ AB 4 C_ TM H_ AB D4
ET _C EN LE ET _C EN LE
M H_ AB 3 M H_ AB D3
The addresses in this section are relative to ETM base address provided in Table 4-2 in Chapter 4 System and
0 Reset
0 Reset
_C EN LE _C EN LE
PRELIMINARY
GoBack
H_ AB 2 H_ AB D
31
31
0
31
SO
C
0
0
0
30
SO _E
C TM
0
0
0
29
SO _E _C
C TM H_
0
0
0
28
(WT)
(WT)
SO _E _C DIS
C TM H_ A
0
0
0
27
SO _E _C DIS BLE
Espressif Systems
C TM H_ A 3
1: Enable
1: Disable
0
0
0
26
1: Enabled
SO _E _C DIS BLE 1
0: Disabled
(R/WTC/SS)
C TM H_ A 3
0
0
0
25
SO _E _C DIS BLE 0
(re (re C TM H_ A 2
0
0
0
24
se se SO _E _C DIS BLE 9
rv rve C TM H_ A 2
0: Invalid. No effect
0: Invalid. No effect
ed 0
0
0
23
) d) SO _E _C DIS BLE 8
C TM H_ A 2
0
22
0
0
SO _E _C DIS BLE 7
10 Event Task Matrix (SOC_ETM)
C TM H_ A 2
0
21
0
0
SO _E _C DIS BLE 6
C TM H_ A 2
0
20
0
0
SO _E _C DIS BLE 5
C TM H_ A 2
0
19
0
0
SO _E _C DIS BLE 4
C TM H_ A 2
0
18
0
18
0
18
SO _E _C DIS BLE 3
C TM H_ A 2
0
0
0
17
17
17
SO SO SO _E _C DIS BLE 2
C C C TM H_ A 2
0
0
0
16
16
16
SO _E SO _E SO _E _C DIS BLE 1
C TM C TM C TM H_ A 2
0
0
0
15
15
15
SO _E _C SO _E _C SO _E _C DIS BLE 0
C TM H_ C TM H_ C TM H_ A 1
373
0
0
0
14
14
14
SO _E _C EN SO _E _C EN SO _E _C DIS BLE 9
C TM H_ AB C TM H_ AB C TM H_ A 1
0
0
0
13
13
13
SO _E _C EN LE SO _E _C EN LE SO _E _C DIS BLE 8
C TM H_ AB 49 C TM H_ AB D4 C TM H_ A 1
0
0
0
12
12
12
SO _E _C EN LE SO _E _C EN LE 9 SO _E _C DIS BLE 7
C TM H_ AB 48 C TM H_ AB D4 C TM H_ A 1
0
0
0
11
11
11
SO _E _C EN LE SO _E _C EN LE 8 SO _E _C DIS BLE 6
C TM H_ AB 47 C TM H_ AB D4 C TM H_ A 1
10
10
10
SO _E _C EN LE SO _E _C EN LE 7 SO _E _C DIS BLE 5
C TM H_ AB 46 C TM H_ AB D4 C TM H_ A 1
9
9
9
0
0
0
SO _E _C EN LE SO _E _C EN LE 6 SO _E _C DIS BLE 4
C TM H_ AB 45 C TM H_ AB D4 C TM H_ A 1
8
8
8
0
0
0
SO _E _C EN LE SO _E _C EN LE 5 SO _E _C DIS BLE 3
C TM H_ AB 44 C TM H_ AB D4 C TM H_ A 1
7
7
7
0
0
0
6
6
6
0
0
0
C TM H_ AB 42 C TM H_ AB D4 C TM H_ A 1
5
5
5
0
0
0
SO _E _C EN LE SO _E _C EN LE 2 SO _E _C DIS BLE 0
C TM H_ AB 41 C TM H_ AB D4 C TM H_ A 9
4
4
4
0
0
0
SO _E _C EN LE SO _E _C EN LE 1 SO _E _C DIS BLE
C TM H_ AB 40 C TM H_ AB D4 C TM H_ A 8
3
3
3
0
0
0
SO _E _C EN LE SO _E _C EN LE 0 SO _E _C DIS BLE
C TM H_ AB 39 C TM H_ AB D3 C TM H_ A 7
2
2
2
0
0
0
SO _E _C EN LE SO _E _C EN LE 9 SO _E _C DIS BLE
C TM H_ AB 38 C TM H_ AB D3 C TM H_ A 6
1
1
1
0
0
0
SO _E _C EN LE SO _E _C EN LE 8 SO _E _C DIS BLE
C TM H_ AB 37 C TM H_ AB D3 C TM H_ A 5
0
0
0
SO _E _C EN LE SO _E _C EN LE 7 SO _E _C DIS BLE
C_ TM H_ AB 36 C_ TM H_ AB D3 C_ TM H_ AB 4
ET _C EN LE ET _C EN LE 6 ET _C DIS LE
M H_ AB 35 M H_ AB D3 M H_ AB 3
0 Reset
0 Reset
0 Reset
_C EN LE _C EN LE 5 _C DI L
PRELIMINARY
GoBack
H_ AB 34 H_ AB D H_ SA E2
SO _E _C DIS BLE 9
SO _E _C DIS BLE 8
SO _E _C DIS BLE 7
SO _E _C DIS BLE 6
SO _E _C DIS BLE 5
SO _E _C DIS BLE 4
SO _E _C DIS BLE 3
SO _E _C DIS BLE 2
SO _E _C DIS BLE 1
SO _E _C DIS BLE 0
SO _E _C DIS BLE 9
SO _E _C DIS BLE 8
SO _E _C DIS BLE 7
C_ TM H_ AB 36
M H_ AB 35
DI BL 4
BL 3
2
C TM H_ A 4
C TM H_ A 4
C TM H_ A 4
C TM H_ A 4
C TM H_ A 4
C TM H_ A 4
C TM H_ A 4
C TM H_ A 4
C TM H_ A 4
C TM H_ A 4
C TM H_ A 3
C TM H_ A 3
C TM H_ A 3
H_ SA E3
SA E3
E3
SO _E _C DIS BLE
ET _C DIS LE
_C DI L
C TM H_ A
SO _E _C DIS
C TM H_
SO E _C
C_ TM
)
ed
SO _E
rv
se
C
SO
31 (re 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
ID
T_
EV
H n_
_C
M
d)
ET
ve
C_
r
se
SO
(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 0 Reset
SOC_ETM_CHn_EVT_ID (n: 049) Configures the event ID of channeln. See Table 10-1. (R/W)
ET
rv
C_
se
SO
(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 0 Reset
SOC_ETM_CHn_TASK_ID (n: 049) Configures the task ID of channeln. See Table 10-2. (R/W)
PRELIMINARY
Espressif Systems 374 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
10 Event Task Matrix (SOC_ETM) GoBack
N
_E
LK
_C
M
d)
ET
ve
C_
r
se
SO
(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
M
)
ed
ET
rv
C_
se
SO
(re
31 28 27 0
0 0 0 0 0x2203092 Reset
PRELIMINARY
Espressif Systems 375 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
11.1 Overview
ESP32-H2 provides a 52-bit timer, which can be used to generate tick interrupts for the operating system, or be
used as a general timer to generate periodic interrupts or one-time interrupts. With the help of the RTC timer,
system timer can be kept up to date after Light-sleep or Deep-sleep.
The timer consists of two counters: UNIT0 and UNIT1. The counter values can be monitored by three
comparators COMP0, COMP1, and COMP2. See the timer block diagram on Figure 11-1.
11.2 Features
The system timer has the following features:
• CNT_CLK used for counting, with an average frequency of 16 MHz in two counting cycles
– Target mode: only a one-time alarm is generated based on the alarm value (t)
– Period mode: periodic alarms are generated based on the alarm period (δt)
• Three comparators generating three independent interrupts based on configured alarm value (t) or alarm
period (δt)
• Able to load back sleep time recorded by RTC timer via software after Deep-sleep or Light-sleep
• Able to stall or continue running when CPU stalls or enters on-chip-debugging mode
PRELIMINARY
Espressif Systems 376 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
Software operation such as configuring registers is clocked by APB_CLK. For more information about APB_CLK,
see Chapter 7 Reset and Clock.
The following two bits of system registers are also used to control the system timer:
Note that if the timer is reset, its registers will be restored to their default values. For more information, please
refer to Chapter 7 Reset and Clock.
Figure 11-2 shows the procedure to generate alarms in the system timer. In this process, one timer counter and
one timer comparator are used. An alarm interrupt will be generated accordingly based on the comparison result
in the comparator.
11.4.1 Counter
The system timer has two 52-bit timer counters, shown as UNITn (n = 0 or 1). Their counting clock source is a 16
MHz clock, i.e. CNT_CLK. Whether UNITn works or not is controlled by two bits in register
PRELIMINARY
Espressif Systems 377 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
SYSTIMER_CONF_REG:
• SYSTIMER_TIMER_UNITn_WORK_EN: set this bit to enable the counter UNITn in the system timer.
• SYSTIMER_TIMER_UNITn_CORE0_STALL_EN: if this bit is set, the counter UNITn stops when CPU is
stalled. The counter continues its counting after CPU resumes.
The configuration of the two bits to control the counter UNITn is shown below, assuming that CPU is
stalled.
When the counter UNITn is at work, the count value is incremented on each counting cycle. When the counter
UNITn is stopped, the count value stops increasing and keeps unchanged.
The lower 32 and higher 20 bits of the initial count value are loaded from registers
SYSTIMER_TIMER_UNITn_LOAD_LO and SYSTIMER_TIMER_UNITn_LOAD_HI. Writing 1 to the bit
SYSTIMER_TIMER_UNITn_LOAD will trigger a reload event, and the current count value will change immediately.
If UNITn is at work, the counter will continue to count up from the newly reloaded value.
Writing 1 to SYSTIMER_TIMER_UNITn_UPDATE will trigger an update event. The lower 32 and higher 20 bits of
the current count value will be locked into registers SYSTIMER_TIMER_UNITn_VALUE_LO and
SYSTIMER_TIMER_UNITn_VALUE_HI, and then SYSTIMER_TIMER_UNITn_VALUE_VALID is asserted. Before
the next update event, the values of SYSTIMER_TIMER_UNITn_VALUE_LO and
SYSTIMER_TIMER_UNITn_VALUE_HI remain unchanged.
Configure SYSTIMER_TARGETx_PERIOD_MODE to choose from the two alarm modes for each COMPx:
• 1: period mode
• 0: target mode
In period mode, the alarm period (δt) is provided by register SYSTIMER_TARGETx_PERIOD. Assuming that
current count value is t1, when it reaches (t1 + δt), an alarm interrupt will be generated. When the counter value
reaches (t1 + 2*δt), another alarm interrupt will be generated. By such way, periodic alarms are generated.
In target mode, the lower 32 bits and higher 20 bits of the alarm value (t) are provided by
SYSTIMER_TIMER_TARGETx_LO and SYSTIMER_TIMER_TARGETx_HI. Assuming that current count value is t2
(t2 <= t), an alarm interrupt will be generated when the count value reaches the alarm value (t). Unlike period
mode, only one alarm interrupt is generated in target mode.
PRELIMINARY
Espressif Systems 378 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
SYSTIMER_TARGETx_TIMER_UNIT_SEL is used to choose the count value from which timer counter to be
compared to generate alarms:
Finally, set SYSTIMER_TARGETx_WORK_EN and COMPx starts to compare the count value:
• In period mode, COMPx compares it with the alarm period (t1 + n*δt).
An alarm is generated when the count value equals to the alarm value (t) in target mode or to the start value (t1) +
n*alarm period δt (n = 1, 2, 3...) in period mode. But if the alarm value (t) set in registers is less than the current
count value, i.e. the target has already passed, when the current count value is 0 ~ 251 - 1 larger than the alarm
value (t), an alarm interrupt will also be generated immediately. No matter in target mode or period mode, the low
32 bits and high 20 bits of the real alarm value can always be read from SYSTIMER_TARGETx_LO_RO and
SYSTIMER_TARGETx_HI_RO. The alarm trigger point and the relationship between current count value tc and
the alarm value tt are shown below.
When SYSTIMER_ETM_EN is set to 1, the alarm pulses can trigger the ETM event.
1. Software writes specific values to configuration fields, see the first column in Table 11-3.
2. Software writes 1 to corresponding bits to start synchronization, see the second column in Table 11-3.
PRELIMINARY
Espressif Systems 379 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
Synchronization is also needed for reading some status registers since the timer counter related status have a
different clock from APB_CLK. A complete synchronization action takes three steps:
11.4.5 Interrupt
Each comparator has one alarm interrupt respectively, named as SYSTIMER_TARGETx_INT. The interrupt signal
is asserted high when the comparator starts to alarm. Until any software clears the interrupt, it remains high. To
enable interrupts, set the bit SYSTIMER_TARGETx_INT_ENA.
2. Poll the reading of SYSTIMER_TIMER_UNITn_VALUE_VALID till it’s 1. Then, user can read the count value
from SYSTIMER_TIMER_UNITn_VALUE_HI and SYSTIMER_TIMER_UNITn_VALUE_LO.
3. Read the lower 32 bits and higher 20 bits from SYSTIMER_TIMER_UNITn_VALUE_LO and
SYSTIMER_TIMER_UNITn_VALUE_HI respectively.
2. Read the current count value, see Section 11.5.1. This value will be used to calculate the alarm value (t) in
Step 4.
4. Set an alarm value (t), and fill its lower 32 bits into SYSTIMER_TIMER_TARGETx_LO, and the higher 20 bits
into SYSTIMER_TIMER_TARGETx_HI.
PRELIMINARY
Espressif Systems 380 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
5. Set SYSTIMER_TIMER_COMPx_LOAD to synchronize the alarm value (t) to COMPx, i.e., load the alarm
value (t) to the COMPx.
6. Set SYSTIMER_TARGETx_WORK_EN to enable the selected COMPx. COMPx starts comparing the count
value with the alarm value (t).
7. Set SYSTIMER_TARGETx_INT_ENA to enable the timer interrupt. When Unitn reaches the alarm value (t), a
SYSTIMER_TARGETx_INT interrupt is triggered.
3. Set SYSTIMER_TIMER_COMPx_LOAD to synchronize the alarm period (δt) to COMPx, i.e., load the alarm
period (δt) to COMPx.
4. Clear and then set SYSTIMER_TARGETx_PERIOD_MODE to configure COMPx into period mode.
5. Set SYSTIMER_TARGETx_WORK_EN to enable the selected COMPx. COMPx starts comparing the count
value with the sum of (start value + n*δt) (n = 1, 2, 3...).
2. Read the sleep time from the RTC timer when the chip wakes up from Deep-sleep or Light-sleep mode.
3. Read the current count value of system timer, see Section 11.5.1.
4. Convert the time value recorded by the RTC timer from the clock cycles based on RTC_SLOW_CLK to that
based on 16 MHz CNT_CLK. For example, if the frequency of RTC_SLOW_CLK is 32 kHz, the recorded
RTC timer value should be converted by multiplying by 500.
5. Add the converted RTC value to the current count value of system timer:
• Set SYSTIMER_TIMER_UNITn_LOAD to load the new timer value into the system timer. By such way,
the system timer is updated.
PRELIMINARY
Espressif Systems 381 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 382 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
PRELIMINARY
Espressif Systems 383 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
11.7 Registers
The addresses in this section are relative to system timer base address provided in Table 4-2 in Chapter 4 System
and Memory.
_T GE _W CO E0_ AL EN
G 1_W RK E1 TAL EN
LL N
N
2_ R EN TA _E
_E
ER AR T0 1_ R ST L_
AR T O R S L_
ET O _ _S L
IM _T GE NIT CO 1_ AL
ST ER AR _U 1_ RE ST
S ER IM _U 0_ R EN
S ER IM _U 0_ R EN
SY TIM _T ER NIT CO E0_
SY TIM _T ER NIT WO K_
SY TIM _T ER NIT CO K_
RK N
N
S ER IM _U 1_ R
O E
_E
SY TIM _T ER NIT WO
W K_
S ER IM _U 0_
SY TIM _T ER NIT
S ER IM _U
N
ST ER IM N
_E
SY TIM _T _E
SY IM _T ER
M
S ER LK
ed ET
SY IM _C
rv _
ST ER
se ER
d)
)
SY TIM
(re TIM
e
rv
se
S
S
SY
SY
(re
31 30 29 28 27 26 25 24 23 22 21 2 1 0
0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 384 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
d)
SY TIM
SY rve
ve
er
se
s
(re
(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
PRELIMINARY
Espressif Systems 385 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
I
_H
AD
LO
0_
T
NI
_U
ER
IM
_T
ER
d)
IM
ve
er
ST
s
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
O
_L
AD
O
_L
T0
NI
_U
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
IM
rv
ST
se
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 386 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
O
_L
UE
AL
_V
T0
NI
_U
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
AD
O
_L
T0
NI
_U
ER
IM
_T
ER
d )
IM
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 0 Reset
PRELIMINARY
Espressif Systems 387 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
D
A LI
_V
AL E
_V AT
UE
T1 PD
NI _U
_U IT1
ER N
IM _U
_T ER
ER IM
IM _T
ST ER
S d)
d)
SY TIM
SY rve
ver
se
se
(re
(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
I
_H
AD
O
_L
T1
NI
_U
ER
IM
_T
ER
)
ed
IM
rv
ST
se
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 388 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
O
_L
AD
LO
1_
T
NI
_U
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
I
_H
UE
AL
_V
T1
NI
_U
ER
MI
_T
ER
d)
IM
ver
ST
se
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 389 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
AD
O
_L
T1
NI
_U
ER
IM
_T
ER
d)
IM
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 0 Reset
SYSTIMER_TIMER_UNIT1_LOAD Configures whether or not to reload the value of UNIT1, i.e., reload
the values of SYSTIMER_TIMER_UNIT1_VALUE_HI and SYSTIMER_TIMER_UNIT1_VALUE_LO to
UNIT1.
0: No effect
1: Reload the value of UNIT1
(WT)
HI
0_
ET
G
AR
_T
ER
IM
_T
ER
)
ed
IM
rv
ST
se
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 390 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
O L
M SE
DE
D_ _
O IT
RI UN
D
PE R_
O
0_ E
RI
ET IM
PE
G 0_T
0_
AR T
ET
_T GE
G
ER AR
AR
IM _T
_T
ST ER
ER
)
ed
SY TIM
IM
rv
ST
se
S
SY
SY
(re
31 30 29 26 25 0
0 0 0 0 0 0 0x00000 Reset
AD
O
_L
P0
M
O
_C
ER
IM
_T
ER
d)
IM
e
rv
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 0 Reset
PRELIMINARY
Espressif Systems 391 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
HI
1_
ET
G
AR
_T
ER
IM
_T
ER
)
ed
IM
rv
ST
se
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LO
1_
ET
G
AR
_T
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
PRELIMINARY
Espressif Systems 392 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
O L
M SE
DE
D_ _
O IT
RI UN
D
PE R_
O
1_ E
RI
ET IM
PE
G 1_T
1_
AR T
ET
_T GE
G
ER AR
AR
IM _T
_T
ST ER
ER
)
ed
SY TIM
IM
rv
ST
se
S
SY
SY
(re
31 30 29 26 25 0
0 0 0 0 0 0 0x00000 Reset
AD
O
_L
P1
M
O
_C
ER
IM
_T
ER
d )
IM
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 0 Reset
PRELIMINARY
Espressif Systems 393 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
HI
2_
ET
G
AR
_T
ER
IM
_T
ER
)
ed
IM
rv
ST
se
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LO
2_
ET
G
AR
_T
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
PRELIMINARY
Espressif Systems 394 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
O L
M SE
DE
D_ _
O IT
RI UN
D
PE R_
O
2_ E
RI
ET IM
PE
G 2_T
2_
AR T
ET
_T GE
G
ER AR
AR
IM _T
_T
ST ER
ER
)
ed
SY TIM
IM
rv
ST
se
S
SY
SY
(re
31 30 29 26 25 0
0 0 0 0 0 0 0x00000 Reset
AD
O
_L
P2
M
O
_C
ER
IM
_T
ER
d )
IM
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 0 Reset
PRELIMINARY
Espressif Systems 395 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
ET NT A
T_ A
A
G 1_I _EN
IN N
EN
0_ _E
AR T T
_T GE _IN
ER AR T2
IM _T GE
ST ER AR
SY TIM _T
S ER
)
ed
SY TIM
v
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
ET NT AW
T_ W
W
IN A
RA
G 1_I _R
0_ _R
AR T T
_T GE _IN
ER AR T2
IM _T GE
ST ER AR
SY TIM _T
S ER
)
ed
SY IM
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
PRELIMINARY
Espressif Systems 396 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
ET NT LR
T_ R
R
IN L
CL
G 1_I _C
0_ _C
AR T T
_T GE _IN
ER AR T2
IM _T GE
ST ER AR
SY TIM _T
S ER
)
ed
SY TIM
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 0 Reset
G 1_I _ST
IN T
ST
0_ _S
T_
AR T T
ET NT
_T GE _IN
ER AR T2
IM _T GE
ST ER AR
SY TIM _T
S ER
)
ed
SY IM
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
31 0
0 Reset
SYSTIMER_TARGET0_LO_RO Represents the actual target value of COMP0, low 32 bits. (RO)
PRELIMINARY
Espressif Systems 397 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
RO
I_
_H
0
ET
G
AR
_T
ER
)
ed
IM
rv
ST
se
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTIMER_TARGET0_HI_RO Represents the actual target value of COMP0, high 20 bits. (RO)
O
_R
LO
1_
ET
G
AR
_T
ER
IM
ST
SY
31 0
0 Reset
SYSTIMER_TARGET1_LO_RO Represents the actual target value of COMP1, low 32 bits. (RO)
M
e
rv
TI
se
S
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTIMER_TARGET1_HI_RO Represents the actual target value of COMP1, high 20 bits. (RO)
PRELIMINARY
Espressif Systems 398 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
11 System Timer (SYSTIMER) GoBack
O
_R
LO
2_
ET
G
AR
_T
ER
IM
ST
SY
31 0
0 Reset
SYSTIMER_TARGET2_LO_RO Represents the actual target value of COMP2, low 32 bits. (RO)
O
_R
HI
2_
ET
G
AR
_T
ER
)
ed
IM
rv
ST
se
SY
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTIMER_TARGET2_HI_RO Represents the actual target value of COMP2, high 20 bits. (RO)
31 0
0x2201073 Reset
PRELIMINARY
Espressif Systems 399 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
12.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 12-1, the ESP32-H2 chip contains
two timer groups, namely timer group 0 (TIMG0) and timer group 1 (TIMG1). Each timer group consists of one
general-purpose timer referred to as T0 and one Main System Watchdog Timer. The general-purpose timer is
based on a 16-bit prescaler and a 54-bit auto-reload-capable up-down counter.
Note that while the Main System Watchdog Timer registers are described in this chapter, their functional
description is included in the Chapter 13 Watchdog Timers (WDT). Therefore, the term ”timer” within this chapter
refers to the general-purpose timer.
12.2 Features
The timer’s features are summarized as follows:
PRELIMINARY
Espressif Systems 400 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
Figure 12-2 is a diagram of timer T0 in a timer group. T0 contains a 16-bit integer divider as a prescaler, a
timer-based counter and a comparator for alarm generation.
• The timer can select its clock source by setting the PCR_TG0_TIMER_CLK_SEL field of the
PCR_TIMERGROUP0_TIMER_CLK_CONF_REG register. When the field is 0, XTAL_CLK is selected; when
the field is 1, RC_FAST_CLK is selected and when the field is 2, PLL_F48M_CLK is selected.
TIMG0_T0_DIVIDER field can be configured as 0 ~ 65535 for a divisor range of 2 ~ 65536. To be more specific,
when TIMG0_T0_DIVIDER is configured as:
• 1: the divisor is 2
To modify the 16-bit prescaler, please first configure the TIMG0_T0_DIVIDER field, and then set
TIMG0_T0_DIVCNT_RST to 1. Meanwhile, the timer must be disabled (i.e. TIMG0_T0_EN should be cleared).
Otherwise, the result can be unpredictable.
PRELIMINARY
Espressif Systems 401 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
To read the 54-bit 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 TIMGn_T0UPDATE_REG, the current
value of the 54-bit timer starts to be latched into the TIMGn_T0LO_REG and TIMGn_T0HI_REG registers
containing the lower 32-bits and higher 22-bits, respectively. When TIMGn_T0UPDATE_REG is cleared by
hardware, it indicates the latch operation has been completed and current timer value can be read from the
TIMGn_T0LO_REG and TIMGn_T0HI_REG registers. TIMGn_T0LO_REG and TIMGn_T0HI_REG registers will
remain unchanged for the CPU to read in its own time until TIMGn_T0UPDATE_REG is written to again.
The 54-bit alarm value is configured using TIMGn_T0ALARMLO_REG and TIMGn_T0ALARMHI_REG, which
represent the lower 32-bits and higher 22-bits of the alarm value, respectively. However, the configured alarm
value is ineffective until the alarm is enabled by setting the TIMGn_T0_ALARM_EN field. To avoid alarm being
enabled ”too late” (i.e. the timer value has already passed the alarm value when the alarm is enabled), the
hardware will trigger the alarm immediately if the current timer value is:
• higher than the alarm value (within a defined range) when the up-down counter increments
• lower than the alarm value (within a defined range) when the up-down counter decrements
Table 12-1 and Table 12-2 show the relationship among the current value of the timer, the alarm value, and when
an alarm is triggered. The current time value and the alarm value are defined as follows:
PRELIMINARY
Espressif Systems 402 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
When an alarm occurs, the TIMGn_T0_ALARM_EN field is automatically cleared and no alarm will occur again
until the TIMGn_T0_ALARM_EN is set next time.
A software instant reload is triggered by the CPU writing any value to TIMGn_T0LOAD_REG, which causes the
timer’s current value to be instantly reloaded. If TIMGn_T0_EN is set, the timer will continue incrementing or
decrementing from the new value. In this case, if TIMGn_T0_ALARM_EN is set, the timer will still trigger alarms in
scenarios listed in Table 12-1 and 12-2. If TIMGn_T0_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 to reload when an alarm occurs, thus allowing the timer to continue
incrementing or 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 TIMGn_T0_AUTORELOAD field should be set. If not
enabled, the timer’s value will continue to increment or decrement past the alarm value after an alarm.
PRELIMINARY
Espressif Systems 403 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
Note:
The above two ETM tasks have the same function as the APB configuration TIMGn_T0_EN. When these operations
occur at the same time, the priority of each operation from high to low is as follows:
3. APB configuration TIMGn_T0_EN: When triggered, it will enable or disable the time-base counter.
Note:
Alarm generation can also be enabled through APB method configuring TIMGn_ALARM_EN and hardware events.
When these operations occur at the same time, the priority of each operation from high to low is as follows:
3. APB configuration TIMGn_T0_ALARM_EN: When triggered, it will enable or disable the alarm generation.
• TIMERn_TASK_CNT_CAP_TIMER0 (n:0-1): When triggered, it will update the current counter value to the
TIMGn_T0LO_REG and TIMGn_T0HI_REG registers.
• TIMERn_TASK_CNT_RELOAD_TIMER0 (n:0-1): When triggered, it will overwrite the current counter value
with the reload value stored in TIMGn_T0_LOAD_LO and TIMGn_T0_LOAD_HI.
All the ETM tasks and events will not take effect until the TIMGn_ETM_EN is set to 1.
In practical applications, timer groups’ ETM events can trigger their own ETM tasks. For example,
TIMERn_TASK_ALARM_START_TIMER0 (n:0-1) can be triggered by TIMERn_EVT_CNT_CMP_TIMER0 (n:0-1) to
realize periodic alarm. For configuration steps, please refer to 12.4.4 Timer as Periodic Alarm by ETM.
1. Start periodic or one-shot frequency calculation (see Section 12.4.5 for details);
2. Once receiving the signal to start the calculation, the counter of XTAL_CLK and the counter of
RTC_SLOW_CLK begin to work at the same time. When the counter of RTC_SLOW_CLK counts to C0,
the two counters stop counting simultaneously;
3. Assume the value of XTAL_CLK’s counter is C1, and the frequency of RTC_SLOW_CLK would be
C0×f _XT AL_CLK
calculated as: f _rtc = C1
PRELIMINARY
Espressif Systems 404 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
12.3.7 Interrupts
Each timer has its own interrupt line that is routed to the CPU, and thus each timer group has a total of two
interrupt lines. Level interrupts generated by timers must be explicitly cleared by the CPU on each
triggering.
Level interrupts are triggered after an alarm (or stage timeout for watchdog timers) occurs. Level interrupts will be
held high after an alarm (or stage timeout) occurs, and will remain so until manually cleared. To enable a timer’s
interrupt, the TIMGn_T0_INT_ENA bit should be set.
The interrupts of each timer group are governed by a set of registers. Each timer within the group has a
corresponding bit in each of these registers:
• TIMGn_T0_INT_RAW : An alarm event sets it to 1. The bit will remain set until the timer’s corresponding bit
in TIMGn_T0_INT_CLR is written.
• TIMGn_WDT_INT_RAW : A stage time out will set the timer’s bit to 1. The bit will remain set until the timer’s
corresponding bit in TIMGn_WDT_INT_CLR is written.
• TIMGn_T0_INT_ST : Reflects the status of each timer’s interrupt and is generated by masking the bits of
TIMGn_T0_INT_RAW with TIMGn_T0_INT_ENA.
• TIMGn_WDT_INT_ST : Reflects the status of each watchdog timer’s interrupt and is generated by masking
the bits of TIMGn_WDT_INT_RAW with TIMGn_WDT_INT_ENA.
• TIMGn_T0_INT_ENA : Used to enable or mask the interrupt status bits of timers within the group.
• TIMGn_WDT_INT_ENA : Used to enable or mask the interrupt status bits of watchdog timer within the
group.
• TIMGn_T0_INT_CLR : Used to clear a timer’s interrupt by setting its corresponding bit to 1. The timer’s
corresponding bit in TIMGn_T0_INT_RAW and TIMGn_T0_INT_ST will be cleared as a result. Note that a
timer’s interrupt must be cleared before the next interrupt occurs.
• TIMGn_WDT_INT_CLR : Used to clear a timer’s interrupt by setting its corresponding bit to 1. The
watchdog timer’s corresponding bit in TIMGn_WDT_INT_RAW and TIMGn_WDT_INT_ST will be cleared as
a result. Note that a watchdog timer’s interrupt must be cleared before the next interrupt occurs.
• Set the timer’s starting value by writing the starting value to TIMGn_T0_LOAD_LO and
TIMGn_T0_LOAD_HI, then reloading it into the timer by writing any value to TIMGn_T0LOAD_REG.
PRELIMINARY
Espressif Systems 405 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
3. Enable auto reload by setting TIMGn_T0_AUTORELOAD and configure the reload value via
TIMGn_T0_LOAD_LO and TIMGn_T0_LOAD_HI.
• If the next alarm requires a new alarm value and reload value (i.e. different alarm interval per iteration),
then TIMGn_T0ALARMLO_REG, TIMGn_T0ALARMHI_REG, TIMGn_T0_LOAD_LO, and
TIMGn_T0_LOAD_HI should be reconfigured as needed. Otherwise, the aforementioned registers
should remain unchanged.
2. Map ETM event to ETM task (which means using the event to trigger the task)
PRELIMINARY
Espressif Systems 406 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
• When alarm generates, the TIMERn_EVT_CNT_CMP_TIMER0 (n:0-1) also generates, and the alarm
generation will be disabled by the alarm.
• If TIMGn_T0_AUTORELOAD is 1, the current counter value is overwritten by the reloaded value. The
alarm generation will be reopened by TIMERn_TASK_ALARM_START_TIMER0 (n:0-1).
• Disable the ETM channels used to map the timer group’s event and task
• Set TIMGn_ETM_EN to 0.
• Select the clock whose frequency is to be calculated (clock source of RTC_SLOW_CLK) via
TIMG0_RTC_CALI_CLK_SEL, and configure the time of calculation via TIMG0_RTC_CALI_MAX.
• Select the clock whose frequency is to be calculated (clock source of RTC_SLOW_CLK) via
TIMG0_RTC_CALI_CLK_SEL, and configure the time of calculation via TIMG0_RTC_CALI_MAX.
PRELIMINARY
Espressif Systems 407 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
3. Timeout
If the counter of RTC_SLOW_CLK cannot finish counting in TIMG0_RTC_CALI_TIMEOUT_RST_CNT
cycles,
TIMG0_RTC_CALI_TIMEOUT will be set to indicate a timeout.
PRELIMINARY
Espressif Systems 408 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 409 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
12.6 Registers
The addresses in this section are relative to Timer Group base address provided in Table 4-2 in Chapter 4 System
and Memory.
AD
ST
LO
N
TO SE
_R
_E
RE
R
AU EA
NT
M
E
AR
ID
0_ R
M d C
_T C
IV
TI rve DIV
TI _T N
AL
G _IN
D
G _E
0_
se 0_
0_
G )
)
ed
M 0
M 0
TI _T
_T
(re _T
_T
rv
G
se
M
(re
TI
TI
TI
31 30 29 28 13 12 11 10 9 0
0 1 1 0x01 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TIMG_T0_ALARM_EN Configures whether or not to enable the timer 0 alarm function. This bit will
be automatically cleared once an alarm occurs.
0: Disable
1: Enable
(R/W/SC)
TIMG_T0_DIVCNT_RST Configures whether or not to reset the timer 0 ’s clock divider counter.
0: No effect
1: Reset
(WT)
TIMG_T0_AUTORELOAD Configures whether or not to enable the timer 0 auto-reload function at the
time of alarm.
0: No effect
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 410 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
LO
0_
_T
G
M
TI
31 0
0x000000 Reset
TIMG_T0_LO Represents the low 32 bits of the time-base counter of timer 0. Valid only after writing
to TIMG_T0UPDATE_REG.
Measurement unit: T0_clk.
(RO)
HI
0_
ed)
_T
rv
G
se
M
(re
TI
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
TIMG_T0_HI Represents the high 22 bits of the time-base counter of timer 0. Valid only after writing
to TIMG_T0UPDATE_REG.
Measurement unit: T0_clk.
(RO)
)
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
PRELIMINARY
Espressif Systems 411 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
O
_L
M
AR
AL
0_
_T
G
M
TI
31 0
0x000000 Reset
TIMG_T0_ALARM_LO Configures the low 32 bits of timer 0 alarm trigger time-base counter value.
Valid only when TIMG_T0_ALARM_EN is 1.
Measurement unit: T0_clk.
(R/W)
I
_H
M
AR
AL
0_
d )
ve
_T
r
G
se
M
(re
TI
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
TIMG_T0_ALARM_HI Configures the high 22 bits of timer 0 alarm trigger time-base counter value.
Valid only when TIMG_T0_ALARM_EN is 1.
Measurement unit: T0_clk.
(R/W)
31 0
0x000000 Reset
TIMG_T0_LOAD_LO Configures low 32 bits of the value that a reload will load onto timer 0 time-base
counter.
Measurement unit: T0_clk.
(R/W)
PRELIMINARY
Espressif Systems 412 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
I
_H
AD
LO
0_
)
ed
_T
rv
G
se
M
(re
TI
31 22 21 0
0 0 0 0 0 0 0 0 0 0 0x0000 Reset
TIMG_T0_LOAD_HI Configures high 22 bits of the value that a reload will load onto timer 0 time-base
counter.
Measurement unit: T0_clk.
(R/W)
AD
O
0 _L
_T
G
M
TI
31 0
0x000000 Reset
TIMG_T0_LOAD Write any value to trigger a timer 0 time-base counter reload. (WT)
PRELIMINARY
Espressif Systems 413 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
RE ET EN
TH
TH
SE _EN
EN
U_ ES D_
N
NG
G
_E
T_
CP _R MO
EN
LE
TE
_L
PP U _
T_
DA
T
ET
_A C O
SE
UP
DT O O
S
RE
B
RE
P
F_
_W _ SH
_
0
rv T_ 3
_
) ON
PU
TG
(re _W STG
YS
G DT LA
_W EN
R
ST
ST
ed C
_C
_S
P
TI _W _F
_
T_
_
DT
DT
DT
DT
DT
DT
G DT
D
se D
d)
_W
_W
_W
_W
_W
_W
TI _W
ve
r
G
se
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 Configures the system reset signal length. Valid only when write
protection is disabled.
Measurement unit: mwdt_clk.
0: 8 4: 40
1: 16 5: 64
2: 24 6: 128
3: 32 7: 256
(R/W)
PRELIMINARY
Espressif Systems 414 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
TIMG_WDT_CPU_RESET_LENGTH Configures the CPU reset signal length. Valid only when write
protection is disabled.
Measurement unit: mwdt_clk.
0: 8 4: 40
1: 16 5: 64
2: 24 6: 128
3: 32 7: 256
(R/W)
TIMG_WDT_STG3 Configures the timeout action of stage 3. See details in TIMG_WDT_STG0. Valid
only when write protection is disabled. (R/W)
TIMG_WDT_STG2 Configures the timeout action of stage 2. See details in TIMG_WDT_STG0. Valid
only when write protection is disabled. (R/W)
TIMG_WDT_STG1 Configures the timeout action of stage 1. See details in TIMG_WDT_STG0. Valid
only when write protection is disabled. (R/W)
TIMG_WDT_STG0 Configures the timeout action of stage 0. Valid only when write protection is dis-
abled.
0: No effect
1: Interrupt
2: Reset CPU
3: Reset system
(R/W)
TIMG_WDT_EN Configures whether or not to enable the MWDT. Valid only when write protection is
disabled.
0: Disable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 415 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
LE
CA
T
RS
ES
T_
PR
CN
_
LK
V
DI
_C
_
DT
DT
)
ed
_W
_W
rv
G
G
se
M
M
(re
TI
TI
31 16 15 1 0
0x01 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TIMG_WDT_CLK_PRESCALE Configures MWDT clock prescaler value. Valid only when write pro-
tection is disabled.
MWDT clock period = MWDT’s clock source period * TIMG_WDT_CLK_PRESCALE.
(R/W)
31 0
26000000 Reset
TIMG_WDT_STG0_HOLD Configures the stage 0 timeout value. Valid only when write protection is
disabled.
Measurement unit: mwdt_clk.
(R/W)
PRELIMINARY
Espressif Systems 416 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
LD
HO
1_
TG
_S
DT
_W
G
M
TI
31 0
0x7ffffff Reset
TIMG_WDT_STG1_HOLD Configures the stage 1 timeout value. Valid only when write protection is
disabled.
Measurement unit: mwdt_clk.
(R/W)
LD
HO
2_
TG
_S
DT
_W
G
M
TI
31 0
0x0fffff Reset
TIMG_WDT_STG2_HOLD Configures the stage 2 timeout value. Valid only when write protection is
disabled.
Measurement unit: mwdt_clk.
(R/W)
31 0
0x0fffff Reset
TIMG_WDT_STG3_HOLD Configures the stage 3 timeout value. Valid only when write protection is
disabled.
Measurement unit: mwdt_clk.
(R/W)
PRELIMINARY
Espressif Systems 417 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
ED
E
_F
DT
_W
G
M
TI
31 0
0x000000 Reset
TIMG_WDT_FEED Write any value to feed the MWDT. Valid only when write protection is disabled.
(WT)
Y
KE
_W
DT
_W
G
M
TI
31 0
0x50d83aa1 Reset
TIMG_WDT_WKEY Configures a different value than its reset value to enable write protection. (R/W)
PRELIMINARY
Espressif Systems 418 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
G
IN
CL
CY
AR )
L
SE
T_
T
K_
AR
AX
AL Y
CL
C_ _RD
ST
ST
_M
I_
I_
I_
LI
I
AL
AL
AL
CA
C
_C
_C
_C
_
TC
TC
TC
TC
T
)
ed
_R
_R
_R
_R
_R
rv
G
G
se
IM
M
(re
(T
TI
TI
TI
TI
31 30 16 15 14 13 12 11 0
0 0x01 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 419 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
LD
_V
A
AT
_D
NG
UE
I
CL
L
CY
VA
_
I_
LI
AL
A
_C
_C
TC
TC
)
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
RE
ST
H
_R
_T
UT
UT
UT
EO
EO
EO
M
IM
M
TI
TI
T
_
I_
I_
LI
AL
AL
CA
_C
_C
C_
TC
TC
)
T
ed
_R
_R
_R
rv
G
G
se
M
M
(re
TI
TI
TI
31 7 6 3 2 1 0
0x1ffffff 3 0 0 0 Reset
TIMG_RTC_CALI_TIMEOUT_THRES Configures the threshold value for the RTC frequency calcula-
tion timer. If the timer’s value exceeds this threshold, a timeout is triggered.
Measurement unit: XTAL_CLK.
(R/W)
PRELIMINARY
Espressif Systems 420 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
EN A
T_ N
A
IN _E
0_ INT
_T _
G DT
)
ed
TI _W
v
er
G
M
M
s
(re
TI
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
RA W
T_ A
W
IN _R
0_ INT
_T _
G DT
d)
TI _W
e
rv
G
se
M
M
(re
TI
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
TIMG_T0_INT_RAW The raw interrupt status bit of the TIMG_T0_INT interrupt. (R/SS/WTC)
TIMG_WDT_INT_RAW The raw interrupt status bit of the TIMG_WDT_INT interrupt. (R/SS/WTC)
T_ T
IN _S
ST
0_ INT
_T _
G DT
d)
TI _W
e
rv
G
se
M
M
(re
TI
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
TIMG_T0_INT_ST The masked interrupt status bit of the TIMG_T0_INT interrupt. (RO)
TIMG_WDT_INT_ST The masked interrupt status bit of the TIMG_WDT_INT interrupt. (RO)
PRELIMINARY
Espressif Systems 421 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
CL R
T_ L
R
IN _C
0_ INT
_T _
G DT
)
ed
TI _W
v
er
G
M
M
s
(re
TI
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
TE
DA
S_
G
M
TI
d)
_N
r ve
G
se
M
(re
TI
31 28 27 0
0 0 0 0 0x2206072 Reset
PRELIMINARY
Espressif Systems 422 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
12 Timer Group (TIMG) GoBack
TI E
AC IV
VE
N S_ CT
_E K_I _A
TM CL _IS
_E _ K
G DT CL
M IM N
_
TI _T E
TI _W ER
G K_
d)
M L
TI _C
ve
er
G
G
M
s
(re
TI
31 30 29 28 27 0
0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 423 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
13.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 triggering a watchdog timeout. Therefore, watchdog
timers are useful for detecting and handling erroneous system/software behavior.
As shown in Figure 13-1, ESP32-H2 contains three digital watchdog timers: one in each of the two timer groups
described in Chapter 12 Timer Group (TIMG) (called Main System Watchdog Timers, or MWDT) and one in the
RTC Module (called the RTC Watchdog Timer, or RWDT). Each digital watchdog timer allows for four separately
configurable stages and each stage can be programmed to take one action upon timeout, unless the watchdog
is fed or disabled. MWDT supports three timeout actions: interrupt, CPU reset, and core reset, while RWDT
supports four timeout actions: interrupt, CPU reset, core reset, and system reset (see details in Section 13.2.2.2
Stages and Timeout Actions). A timeout value can be set for each stage individually.
During the flash boot process, RWDT and the MWDT0 are enabled automatically in order to detect and recover
from booting errors.
ESP32-H2 also has one analog watchdog timer: Super watchdog (SWD). It is an ultra-low-power circuit in the
analog domain that helps to prevent the system from operating in a sub-optimal state and resets the system if
required.
Note that while this chapter provides the functional descriptions of the watchdog timer, MWDT register
descriptions are detailed in Chapter 12 Timer Group (TIMG), and the RWDT and SWD register descriptions are
detailed in Section 13.5 Register Summary.
Note:
Unless otherwise specified, MWDT in this chapter refers to both MWDT0 and MWDT1.
PRELIMINARY
Espressif Systems 424 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
• Four stages, each with a separately programmable timeout value and timeout action
• Timeout actions:
• Write protection that makes WDT register read only unless unlocked
• Clock source:
– RWDT: RTC_SLOW_CLK
PRELIMINARY
Espressif Systems 425 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
Figure 13-2 shows the three watchdog timers in ESP32-H2 digital systems.
• MWDT0 can select between the PLL_F48M_CLK, RC_FAST_CLK or XTAL_CLK (external) clock as its
clock source by setting the PCR_TG0_WDT_CLK_SEL field of the
PCR_TIMERGROUP0_WDT_CLK_CONF_REG register.
• The 16-bit prescaler for MWDT0 is configured via the TIMGn_WDT_CLK_PRESCALE (n: 0 ~ 1, where for
Timer Group 0, the value of n should be 0 here) field of TIMGn_WDTCONFIG1_REG. When
TIMGn_WDT_DIVCNT_RST field is set, the prescaler is reset and it can be re-configured at once.
In contrast, the clock source of RWDT is derived directly from RTC_SLOW_CLK (see details in Chapter 7 Reset
and Clock).
PRELIMINARY
Espressif Systems 426 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
MWDT and RWDT are enabled by setting the TIMGn_WDT_EN and LP_WDT_RWDT_EN fields respectively.
When enabled, the 32-bit counters of the watchdog will increment on each source clock cycle until the timeout
value of the current stage is reached (i.e. timeout 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
TIMGn_WDTFEED_REG for MDWT and by writing 1 to LP_WDT_RWDT_FEED for RWDT.
Timer stages allow for a timer to have a series of different timeout values and corresponding timeout actions.
When one stage times out, the timeout action is triggered, the counter value is reset to zero, and the next stage
becomes active.
The MWDT0, MWDT1 and RWDT each provide four stages, referred to as stages 0 to stage 3. The watchdog
timers advance sequentially through these stages in a loop, starting from stage 0, then progressing through to
stage 3, and then returning back to stage 0.
Timeout values of each stage for MWDT are configured in TIMGn_WDTCONFIGi_REG (where i ranges from 2 to
5), whilst timeout values for RWDT are configured using LP_WDT_RWDT_STGj_HOLD field (where j ranges from
0 to 3).
Please note that the timeout value of stage 0 for RWDT (Thold0 ) is determined by the combination of the
EFUSE_WDT_DELAY_SEL field of eFuse register EFUSE_RD_REPEAT_DATA0_REG and
LP_WDT_RWDT_STG0_HOLD field. The relationship is as follows:
where << is a left-shift operator. For example, if LP_WDT_RWDT_STG0_HOLD is configured as 100 and
EFUSE_WDT_DELAY_SEL is 1, the Thold0 will be 400 cycles.
Upon the timeout of each stage, one of the following timeout actions will be executed:
For MWDT, the timeout action of all stages is configured in TIMGn_WDTCONFIG0_REG. Likewise for RWDT, the
timeout action is configured in LP_WDT_RWDT_CONFIG0_REG.
PRELIMINARY
Espressif Systems 427 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
Watchdog timers are critical to detecting and handling erroneous system/software behavior, thus should not be
disabled easily (e.g. due to a misplaced register write). Therefore, MWDT and RWDT incorporate a write
protection mechanism that prevents the watchdogs from being disabled or tampered with due to an accidental
write.
The write protection mechanism is implemented using a write-key field for each timer (TIMGn_WDT_WKEY for
MWDT, LP_WDT_RWDT_WKEY for RWDT). The value 0x50D83AA1 must be written to the watchdog timer’s
write-key field before any other register of the same watchdog timer can be changed. Any attempts to write to a
watchdog timer’s registers (other than the write-key field itself) whilst the write-key field’s value is not
0x50D83AA1 will be ignored. The recommended procedure for accessing a watchdog timer is as follows:
1. Disable the write protection by writing the value 0x50D83AA1 to the timer’s write-key field.
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 field.
During flash booting process, MWDT0 as well as RWDT, are automatically enabled. Stage 0 for the enabled
MWDT0 is automatically configured as core reset action upon timeout, known as core reset. Likewise, stage 0
for RWDT is configured to system reset, which resets the main system and RTC when it times out. After booting,
TIMGn_WDT_FLASHBOOT_MOD_EN and LP_WDT_RWDT_FLASHBOOT_MOD_EN should be cleared to stop
the flash boot protection procedure for both MWDT0 and RWDT respectively. After this, MWDT0 and RWDT can
be configured by software.
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 whole digital circuits on the chip (system reset).
The source of the clock for SWD is constant and can not be selected.
13.3.1 Features
SWD has the following features:
• Ultra-low power
• Various dedicated methods for software to feed SWD, which enables SWD to monitor the working state of
the whole operating system
PRELIMINARY
Espressif Systems 428 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
13.3.2.1 Structure
13.3.2.2 Workflow
In normal state:
• When trying to feed SWD, CPU needs to disable SWD controller’s write protection by writing 0x50D83AA1
to LP_WDT_SWD_WKEY. This prevents SWD from being fed by mistake when the system is operating in
sub-optimal state.
• If setting LP_WDT_SWD_AUTO_FEED_EN to 1, SWD controller can also feed SWD itself without any
interaction with CPU.
After reset:
13.4 Interrupts
For watchdog timer interrupts, please refer to Section 12.3.7 Interrupts in Chapter 12 Timer Group (TIMG).
PRELIMINARY
Espressif Systems 429 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 430 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
13.6 Registers
MWDT registers are part of the timer submodule and are described in Section 12.5 Register Summary in Chapter
12 Timer Group (TIMG).
The addresses of RWDT and SWD registers in this section are relative to LP_WDT base address provided in
Table 4-2 in Chapter 4 System and Memory.
PRELIMINARY
Espressif Systems 431 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
T_ E N
TH
TH
EN
SE D_
G
G
EN
RE O
EN
U_ _M
LP
_L
_L
_S
ET
ET
CP O
N
O O
ES
_I
B
RE
R
SE
_P H
U_
0
S_
S
G
TG
TG
AU
_W d) DT LA
P
N
R
SY
ST
ST
_C
_S
_S
_P
_E
LP rve RW _F
_
_
DT
DT
DT
DT
DT
DT
DT
se _ DT
DT
W
RW
RW
(re D W
W
_R
_R
_R
_R
_R
_R
_
_W T_
)
ed
DT
DT
DT
DT
DT
DT
DT
DT
LP D
rv
_W
_W
_W
_W
se
_
_
LP
LP
LP
LP
LP
LP
LP
LP
(re
31 30 28 27 25 24 22 21 19 18 16 15 13 12 11 10 9 8 0
PRELIMINARY
Espressif Systems 432 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
31 0
200000 Reset
PRELIMINARY
Espressif Systems 433 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
LD
HO
1_
TG
_S
DT
W
_R
DT
W
_
LP
31 0
80000 Reset
LD
HO
2_
G
T
_S
DT
W
_R
DT
_W
LP
31 0
0x000fff Reset
31 0
0x000fff Reset
PRELIMINARY
Espressif Systems 434 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
D
EE
_F
DT
_W
TC
_R
DT
W
_R
)
ed
DT
rv
_W
se
LP
(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
0x000000 Reset
PRELIMINARY
Espressif Systems 435 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
EN
EE LR
TH
D_
_F _C
AG
ID
W
TO AG
L
_F
E
L_
AU FL
BL
ET
NA
D_ ED
D_ T_
SA
S
IG
W RS
RE
W FE
DI
S
_S D_
D_
_S D_
D_
DT SW
DT SW
W
_S
_S
_W T_
_W T_
)
ed
DT
DT
LP D
LP D
rv
_W
_W
W
se
_
_
LP
LP
LP
LP
(re
31 30 29 20 19 18 17 1 0
0 0 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LP_WDT_SWD_RESET_FLAG Represents the SWD whether or not generate the reset signal
0: No
1: Yes
(RO)
LP_WDT_SWD_SIGNAL_WIDTH Configures the SWD signal length that outputs to the analog circuit.
Measurement unit: LP_DYN_FAST_CLK
(R/W)
PRELIMINARY
Espressif Systems 436 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
Y
KE
W
D_
W
_S
DT
_W
LP
31 0
0x000000 Reset
)
ed
LP D
rv
_W
se
LP
(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
PRELIMINARY
Espressif Systems 437 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
T_ T
IN _S
ST
D_ T
W _IN
_S DT
DT RW
_W T_
)
ed
LP D
rv
_W
se
LP
(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
LP_WDT_SWD_INT_ST Represents the SWD whether or not generates and sends timeout interrupt
to CPU.
0: No
1: Yes
(RO)
LP_WDT_RWDT_INT_ST Represents the RWDT whether or not generates and sends timeout inter-
rupt to CPU.
0: No
1: Yes
(RO)
)
ed
LP D
rv
_W
se
LP
(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
LP_WDT_RWDT_INT_ENA Configure whether or not to enable the RWDT to send timeout interrupt.
0: Disable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 438 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
13 Watchdog Timers (WDT) GoBack
LR
_C
NT
DT R
_I
_W CL
ER T_
UP _IN
_S DT
DT RW
_W T_
)
ed
LP D
rv
_W
se
LP
(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
LP_WDT_SWD_INT_CLR Configure whether to clear the timeout interrupt signal sent by SWD to
CPU.
0: No
1: Yes
(WT)
LP_WDT_INT_CLR Configure whether to clear the timeout interrupt signal sent by RWDT to CPU.
0: No
1: Yes
(WT)
E
LK
AT
_C
_D
DT
DT
_W
_W
LP
LP
31 30 0
0 0x2112080 Reset
PRELIMINARY
Espressif Systems 439 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
14.1 Overview
The permission management of ESP32-H2 can be divided into two parts: PMP (Physical Memory Protection)
and APM (Access Permission Management).
The areas managed by PMP and APM are shown in Table 14-1.
Slaves
ROM HP SRAM LP SRAM CPU_PERI1 HP_PERI2 LP_PERI3 EX_MEM4
Masters
CPU PMP PMP PMP + APM PMP + APM PMP + APM PMP + APM PMP
5
Other masters N/A APM APM N/A N/A N/A N/A
1
Peripheral registers in the CPU, address range: 0x600C_0000 – 0x600C_FFFF
2
Peripheral registers in the high-performance system, address range: 0x6000_0000 – 0x600A_FFFF
3
Peripheral registers in the low-power system, address range: 0x600B_0000 – 0x600B_FFFF
4
External memory, e.g., flash.
5
Masters that can request access to the bus, such as GDMA, MEM_MONITOR. For a complete list of masters, please
refer to Table 14-4.
CPU
PMP
APM
ROM
HP SRAM LP SRAM CPU_PERI
EX_MEM HP_PERI LP_PERI
For the CPU, the permission management relation between PMP and APM is shown in Figure 14-1. PMP
manages the CPU’s access to all address spaces. APM does not manage the CPU’s access to ROM, HP SRAM,
and EX_MEM. If the CPU needs to access ROM, HP SRAM, and EX_MEM, it needs permission only from PMP; if
it needs to access LP SRAM and other address spaces, it needs to pass PMP’s permission management first
and then the APM’s. If the PMP check fails, APM check will not be triggered.
PMP related registers are located inside the CPU and can be read or configured with special instructions. For
how to configure PMP, please refer to Chapter ESP-RISC-V CPU > Section Physical Memory Protection.
The following sections of this chapter will describe the functions and configurations of the APM module.
The APM module contains two parts: the TEE (Trusted Execution Environment) controller and the APM controller.
Each of them contains its own register module: TEE register module and APM register module.
• The TEE controller is responsible for configuring the security mode of a particular master in ESP32-H2
PRELIMINARY
Espressif Systems 440 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
(such as GDMA) to access memory or peripheral registers. There are four security modes: TEE, REE0 (Rich
Execution Environment), REE1, and REE2.
• The APM controller is responsible for managing a master’s access permissions (read/write/execute) when
accessing memory and peripheral registers. By comparing the pre-configured address ranges and
corresponding access permissions with the information carried on the bus, such as ID number (please refer
to Table 14-4), security mode, access address, access permissions, etc, the APM controller determines
whether access is allowed.
TEE related registers are used to configure the security mode of each master, and the APM related registers are
used to specify the access permission and access address range of each security mode. With TEE controller
and APM controller, ESP32-H2 can precisely control the access permission of all masters to memory and
peripheral registers.
14.2 Features
ESP32-H2’s TEE controller has the following features:
TEE Stands for Trusted Execution Environment, which is a secure area that is isolated from
the main operating system and provides a secure environment for executing sensitive
operations.
REE Stands for Rich Execution Environment, which is the main operating system and envi-
ronment in which most applications run.
PRELIMINARY
Espressif Systems 441 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
For the CPU to access memory or peripheral registers, first select the machine mode or user mode of the CPU,
then configure its security mode. For the configuration of machine mode and user mode, please refer to RISC-V
Instruction Set Manual, Volume II: Privileged Architecture, Version 1.10.
• When the CPU is in machine mode, its security mode is TEE mode.
• When the CPU is in user mode, its security mode is REE mode. To specify REE0, REE1 or REE2 mode,
TEE_M0_MODE of TEE_M0_MODE_CTRL_REG should be configured:
– If TEE_M0_MODE is set to 0, which is TEE mode, the valid mode that actually takes effect in the CPU
user mode is REE0.
– if TEE_M0_MODE is set to 1, 2 or 3, which is in REE mode, its security mode is REE0, REE1 and
REE2 respectively.
As for other masters, security mode can be set by configuring TEE_Mn_MODE. n here equals the ID number of
master in Table 14-4.
Value Source
0 CPU
1 Reserved
2 Reserved
3 Reserved
4 Reserved
5 MEM_MONITOR
6 TRACE
7 ~ 15 Reserved
See the peripherals corresponding to the values 0 ~ 15 in Chapter
3 GDMA Controller (GDMA) > Table 3-1 Peripheral-to-Memory and
16 ~ 31 Memory-to-Peripheral Data Transfer. For example, 16 corresponds
to the peripheral with value 0 in that table, and 17 corresponds to
the peripheral with value 1 in that table, and so on.
14.4.2.1 Architecture
Figure 14-2 shows the architecture of the APM controller and the access paths managed by it.
PRELIMINARY
Espressif Systems 442 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
TEE_REG
LP_APM_CTRL
TEE_M0_MODE_CTRL_REG TEE_Mn_MODE_CTRL_REG
BUS Matrix
CPU access
to HP SRAM
is managed
by PMP M2 M0 M3 M1
M0
LP_SYS
LP SRAM LP_PERI
0x50000000 ~ 0x50000FFF 0x600B0000 ~ 0x600BFFFF
As shown in the figure, the APM controller contains two functional modules: HP_APM_CTRL and
LP_APM_CTRL, configured by the register modules HP_APM_REG and LP_APM_REG, respectively.
• HP_APM_CTRL manages four access paths, namely M0 – M3 in the figure. Permission management of
each path can be enabled by configuring HP_APM_FUNC_CTRL_REG (enabled by default).
• LP_APM_CTRL manages one access path, namely M0 in the figure. Permission management of this path
can be enabled by configuring LP_APM_FUNC_CTRL_REG (enabled by default).
Table 14-5 below shows the detailed information of the two functional modules:
Number of
Functional Number of Enable Permission Enable Address
Register Modules Configurable
Modules Access Paths Management Ranges
Address Ranges
HP_APM_ HP_APM_REGION_
HP_APM_CTRL HP_APM_REG 4 16
FUNC_CTRL_REG FILTER_EN_REG
LP_APM LP_APM_REGION_
LP_APM_CTRL LP_APM_REG 1 4
_FUNC_CTRL_REG FILTER_EN_REG
HP_APM_REG register module can configure up to 16 address ranges for functional module HP_APM_CTRL.
The start and end address for each region (address range) are configured by HP_APM_REGIONn_ADDR_START
and HP_APM_REGIONn_ADDR_END, respectively. Configure the bit n of HP_APM_REGION_FILTER_EN_REG
to enable the (n+1)th region. The first address range is enabled by default.
PRELIMINARY
Espressif Systems 443 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
LP_APM_REG register module can configure up to four address ranges for functional module LP_APM_CTRL.
The start and end address for each region are configured by LP_APM_REGIONn_ADDR_START and
LP_APM_REGIONn_ADDR_END. Configure the bit n of LP_APM_REGION_FILTER_EN_REG to enable the
(n+1)th region. The first address range is enabled by default.
When configuring the address ranges, the address requires 4-byte alignment (the lower two bits of the address
are 0). For example, the address range could be set as 0x4080000C ~ 0x40808774 or 0x600C0008 ~
0X600CFF70.
For each address range, the access permissions (read/write/execute) can be configured for different security
modes:
• The master in TEE mode always has read, write, and execute permissions in the address range.
• For master in REE0, REE1 or REE2 mode, access permissions can be configured in
HP_APM_REGIONn_ATTR_REG or LP_APM_REGIONn_ATTR_REG based on the access path.
Different access paths managed by the same register module share the configuration of address ranges and
access permissions. For example, the permission management of data path HP_APM_CTRL M0-M3 shown in
Figure 14-2 should follow the address ranges and access permissions of each address range configured in the
register module HP_APM_REG. Likewise, the permission management of data path LP_APM_CTRL M0 shown
in Figure 14-2 should follow the address ranges and access permissions of each address range configured in the
register module LP_APM_REG.
As Figure 14-2 shows, all masters access HP_MEM through the HP_APM_CTRL M1 path. Suppose that
HP_APM_M1_FUNC_EN is enabled and a master in REE1 mode needs to access LP_MEM. The whole process
is as follows:
1. HP_APM_CTRL M1 will first determine whether the address requested to access is within the 16 address
ranges configured in the HP_APM_REG register module.
2. Assuming that the address requested to access is within the second address range, then HP_APM_CTRL
M1 determines whether the address range is enabled, that is, whether bit 1 of
HP_APM_REGION_FILTER_EN is 1.
3. If the address range is enabled, HP_APM_CTRL M1 checks whether the master has read permission for
the second address range, that is, whether HP_APM_REGION1_R1_R in HP_APM_REGION1_ATTR_REG
is valid (that is, 1). If valid, the read request will be allowed, otherwise 0 will be returned.
The address ranges configured may overlap. For example, region 1 and region 2 overlap. If region 1 is set to be
unreadable and region 2 readable, then the overlapping area of region 1 and region 2 is readable. The same rules
apply for write and execute permissions.
Note:
• When powered up, only the CPU is in TEE mode by default, and the other masters are in REE2 mode. By default,
the APM controller blocks access requests from all masters in REE0, REE1, and REE2 modes.
• All registers listed in 14.7 Register Summary can only be configured by the masters that are in TEE security mode.
PRELIMINARY
Espressif Systems 444 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
2. Choose the security mode of the master by configuring TEE_Mn_MODE. The master ID n is defined in
Table 14-4.
3. Configure the start and end address for access address ranges by setting
HP_APM_REGIONn_ADDR_START, HP_APM_REGIONn_ADDR_END, or
LP_APM_REGIONn_ADDR_START, LP_APM_REGIONn_ADDR_END.
Take I2S accessing HP SRAM via GDMA as an example, assuming that it is only allowed to read and write in the
fourth address range 0x40805000 ~ 0x4080F000:
2. According to the master ID number in Table 14-4, set TEE_M19_MODE to be 1, so that the security mode
for I2S access via GDMA is REE0.
6. Set HP_APM_M1_FUNC_EN to 1.
• Triggers interrupt
The APM controller will automatically record relevant information about the illegal access, including the master ID,
security mode, access address, reasons for illegal access (address out of bounds or permission restrictions), and
permission management result of each access path. All these information can be obtained from relevant registers
listed in Section 14.7 Register Summary.
Take the access path HP_APM_CTRL M0 as an example. When illegal access occurs:
PRELIMINARY
Espressif Systems 445 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
– If the address requested to access is not within the enabled address ranges, bit1 will be set to 1,
indicating address out of bounds.
– If the address requested to access is within the enabled address ranges�but the master does not have
the read/write/execute permission within this region, then bit0 will be set to 1, indicating permission
restrictions.
ESP32-H2’s APM controller can generate five interrupt signals, which will be sent to Interrupt Matrix
(INTMTX):
• HP_APM_M0_INTR
• HP_APM_M1_INTR
• HP_APM_M2_INTR
• HP_APM_M3_INTR
• LP_APM_M0_INTR
These five interrupt signals correspond to the controlled access paths shown in Figure 14-2. If an illegal access
occurs in a controlled access path, the corresponding interrupt will be generated.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 446 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 447 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 448 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
14.8 Registers
14.8.1 APM Registers of HP System (HP_APM_REG)
EN
ER_
ILT
F
N_
IO
EG
_R
)
ed
M
AP
rv
se
_
HP
(re
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x01 Reset
31 0
0 Reset
31 0
0xffffffff Reset
PRELIMINARY
Espressif Systems 449 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
_R W
_R W
_R W
_ d) GIO n_R R
_ d) GIO n_R R
IO _R R
X
X
HP rve RE ON R2_
N n 2_
2_
HP rve RE ON R1_
N n 1_
1_
EG Nn 0_
N n 0_
0_
_R IO _R
se _ GI n_
se _ I _ n
n
(re APM RE ON
(re APM RE ON
PM E N
_A _R IO
_ _ GI
_ _ I G
G
G
G
HP PM E
HP PM E
HP APM RE
_A _R
_A _R
_ _
d)
HP APM
HP APM
HP APM
ve
er
_
s
HP
(re
31 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PM 1 N EN
0_ NC N
NC N
N
_M _FU C_E
FU _E
_E
_A _M _FU C_
HP APM M2 UN
_ _ _F
HP APM M3
_ _
d)
HP APM
e
rv
se
_
HP
(re
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 Reset
PRELIMINARY
Espressif Systems 450 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
S
TU
STA
N_
O
TI
P
CE
EX
0_
_M
)
ed
M
AP
rv
se
_
HP
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
CL
S_
U
AT
ST
N_
IO
G
RE
0_
_M
d)
PM
ve
_A
r
se
HP
(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
PRELIMINARY
Espressif Systems 451 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
N
IO
DE
G
O
RE
ID
M
N_
N_
N_
O
O
TI
TI
TI
P
P
CE
CE
CE
EX
EX
EX
0_
0_
0_
_M
_M
_M
d)
PM
M
ve
P
_A
_A
_A
ser
HP
HP
HP
(re
31 23 22 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 452 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
S
TU
STA
N_
O
TI
P
CE
EX
1_
_M
)
ed
M
AP
rv
se
_
HP
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
CL
S_
U
AT
ST
N_
IO
G
RE
1_
_M
d)
PM
ve
_A
r
se
HP
(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
PRELIMINARY
Espressif Systems 453 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
N
IO
DE
G
O
RE
ID
M
N_
N_
N_
O
O
TI
TI
TI
P
P
CE
CE
CE
EX
EX
EX
1_
1_
1_
_M
_M
_M
d)
PM
M
ve
P
_A
_A
_A
ser
HP
HP
HP
(re
31 23 22 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 454 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
S
TU
STA
N_
O
TI
P
CE
EX
2_
_M
)
ed
M
AP
rv
se
_
HP
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
CL
S_
U
AT
ST
N_
IO
G
RE
2_
_M
d)
PM
ve
_A
r
se
HP
(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
PRELIMINARY
Espressif Systems 455 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
N
IO
DE
G
O
RE
ID
M
N_
N_
N_
O
O
TI
TI
TI
P
P
CE
CE
CE
EX
EX
EX
2_
2_
2_
_M
_M
_M
d)
PM
M
ve
P
_A
_A
_A
ser
HP
HP
HP
(re
31 23 22 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 456 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
S
TU
STA
N_
O
TI
P
CE
EX
3_
_M
)
ed
M
AP
rv
se
_
HP
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
CL
S_
U
AT
ST
N_
IO
G
RE
3_
_M
d)
PM
ve
_A
r
se
HP
(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
PRELIMINARY
Espressif Systems 457 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
N
IO
DE
G
O
RE
ID
M
N_
N_
N_
O
O
TI
TI
TI
P
P
CE
CE
CE
EX
EX
EX
3_
3_
3_
_M
_M
_M
d)
PM
M
ve
P
_A
_A
_A
ser
HP
HP
HP
(re
31 23 22 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 458 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
_M _AP _IN EN
AP _IN EN
_I EN
N
_E
PM 1 PM T_
0_ M T_
M T_
NT
_ A _ M _A _IN
HP APM M2 PM
_ _ _A
HP PM 3
_A _M
d)
HP APM
ve
er
_
s
HP
(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
N
_E
LK
_C
)
ed
PM
rv
_A
se
HP
(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
PRELIMINARY
Espressif Systems 459 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
E
AT
_D
)
ed
P M
rv
_A
se
HP
(re
31 28 27 0
0 0 0 0 0x2205240 Reset
EN
R_
E
LT
FI
N_
IO
EG
_R
)
ed
PM
rv
_A
se
LP
(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 0x1 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 460 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
E ND
R_
DD
_A
Nn
IO
E G
_R
PM
_A
LP
31 0
0xffffffff Reset
_R W
_R W
_R W
_A d) IO _R R
_A d) IO _R R
IO _R R
X
X
LP rve REG Nn 2_
Nn 2_
2_
LP rve REG Nn 1_
Nn 1_
1_
EG Nn 0_
Nn 0_
0_
se _ IO _R
se _ IO _R
_R IO R _
(re PM REG Nn
(re PM EG Nn
n
PM E N
_A _ IO
_A _R IO
_A _R IO
LP PM EG
LP M EG
LP PM REG
G
_A _R
_A _R
_A _
d)
LP PM
LP PM
LP PM
ve
P
er
_A
s
LP
(re
31 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 461 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
_EN
NC
FU
0_
_M
d)
PM
ve
er
_A
s
LP
(re
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 1 Reset
US
AT
ST
N_
IO
PT
CE
EX
0_
_M
)
ed
PM
rv
_A
se
LP
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
CL
S_
U
AT
ST
N_
IO
G
RE
0_
_M
d)
PM
e
rv
_A
se
LP
(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
PRELIMINARY
Espressif Systems 462 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
N
IO
DE
G
O
RE
ID
M
N_
N_
N_
O
O
TI
TI
TI
EP
EP
P
CE
XC
XC
EX
E
E
0_
0_
0_
_M
_M
_M
)
)
ed
ed
PM
M
AP
AP
rv
rv
_A
se
se
_
_
LP
LP
LP
(re
(re
31 23 22 18 17 16 15 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 Reset
31 0
0 Reset
PM
rv
_A
se
LP
(re
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
PRELIMINARY
Espressif Systems 463 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
N
_E
LK
_C
d)
M
ve
AP
r
se
_
LP
(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
E
AT
_D
d)
M
e
AP
rv
se
_
LP
(re
31 28 27 0
0 0 0 0 0x2205240 Reset
DE
O
M
d)
n_
e
M
rv
E_
se
TE
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 464 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
14 Access Permission Management (APM) GoBack
EN
K_
d)
CL
ver
E_
se
TE
(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
E G
_R
E
)
AT
ed
_D
rv
se
E
TE
(re
31 28 27 0
0 0 0 0 0x2205282 Reset
PRELIMINARY
Espressif Systems 465 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
15 System Registers
15.1 Overview
ESP32-H2 supports the following auxiliary chip features:
Each auxiliary chip feature can be controlled with dedicated system registers. This chapter describes how to
configure these system registers.
• First, a mask mechanism is introduced in the symmetric encryption operation process, which interferes with
the power consumption trajectory by masking the real data in the operation process. This security
mechanism cannot be turned off.
• Second, the clock selected for the operation will change dynamically in real time, blurring the power
consumption trajectory during the operation. For this security mechanism, ESP32-H2 provides three
security levels for users to choose to adapt to different applications.
PRELIMINARY
Espressif Systems 466 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
It should be noted that while Core Reset would reset HP_SYSTEM_ROM_TABLE_LOCK_REG and
HP_SYSTEM_ROM_TABLE_REG, CPU Reset would not reset these two registers. For more information on reset
types, please refer to Subsection 7.1.3 Features in Chapter 7 Reset and Clock.
• HP_SYSTEM_CPU_PERI_TIMEOUT_CONF_REG: Reserved.
PRELIMINARY
Espressif Systems 467 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
• HP_SYSTEM_HP_PERI_TIMEOUT_CONF_REG: Reserved.
• LP_PERI_BUS_TIMEOUT_CONF_REG: Reserved.
• LP_PERI_BUS_TIMEOUT_ADDR_REG: When a timeout occurs, this register will record the address of the
timeout.
• LP_PERI_BUS_TIMEOUT_UID_REG: When a timeout occurs, this register will record the Master-ID of the
timeout.
PRELIMINARY
Espressif Systems 468 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
15 System Registers
15.3 Register Summary
The addresses related of LP Peripheral timeout registers are relative to Low-power Peripheral base address provided in Table 4-2 in Chapter 4 System and Memory, and
the others addresses in this section are relative to System Registers base address provided in Table 4-2 in Chapter 4 System and Memory.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
GoBack
15 System Registers GoBack
15.4 Registers
The addresses related of LP Peripheral timeout registers are relative to Low-power Peripheral base address
provided in Table 4-2 in Chapter 4 System and Memory, and the others addresses in this section are relative to
System Registers base address provided in Table 4-2 in Chapter 4 System and Memory.
RY PT
Y
PT
_D NCR
EC
E
PT
G0 AL_
RY
U
CB
NC
OA MAN
_E
WN AD_
D_
AL
NU
O
E_ WNL
MA
PI_
O
DO
EN LE_D
_S
LE
BL
B
AB
(re YSTE ENA
EN
M_
M_
M_
HP YSTE
TE
d)
HP ed)
YS
rve
rv
_S
_S
_S
se
se
HP
(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
PRELIMINARY
Espressif Systems 470 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
_L SEL
EL
_
FG
EV
EC A_C
PA
P
_D
_D
TE EC
YS _S
_S
M
M
HP STE
)
ed
SY
rv
_S
se
_
HP
(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 0x0 Reset
CK
O
_L
LE
AB
_T
M
O
_R
M
TE
)
ed
YS
rv
_S
se
HP
(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
PRELIMINARY
Espressif Systems 471 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
LE
AB
_T
M
O
_R
M
TE
YS
_S
HP
31 0
0x000000 Reset
HP_SYSTEM_ROM_TABLE Software ROM-Table register, whose content can be modified only when
HP_SYSTEM_ROM_TABLE_LOCK is 0. (R/W)
LE EN
AR
_C T_
NT C
_I TE
ES
UT RO
HR
EO _P
_T
M UT
UT
I_ EO
EO
ER IM
M
TI
TI
_P I_T
I_
PU ER
ER
_C _P
_P
M PU
PU
TE _C
_C
YS M
M
_S TE
TE
)
ed
HP SYS
YS
rv
_S
se
_
HP
HP
(re
31 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0xffff Reset
PRELIMINARY
Espressif Systems 472 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
R
DD
_A
UT
EO
M
TI
I_
ER
_P
PU
_C
M
TE
YS
_S
HP
31 0
0x000000 Reset
ID
_U
UT
EO
M
TI
I_
ER
_P
PU
_C
M
TE
d)
YS
e
rv
_S
se
HP
(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
PRELIMINARY
Espressif Systems 473 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
LE EN
AR
_C T_
NT C
_I TE
ES
UT RO
HR
EO _P
_T
IM UT
UT
_T O
EO
RI IME
IM
PE _T
_T
P_ RI
RI
_H PE
PE
M P_
P_
TE _H
_H
YS M
M
_S TE
TE
)
ed
HP SYS
YS
rv
_S
se
_
HP
HP
(re
31 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0xffff Reset
HP_SYSTEM_HP_PERI_TIMEOUT_THRES Configures the timeout threshold for bus access for ac-
cessing HP peripheral register, corresponding to the number of clock cycles of the clock domain.
(R/W)
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 474 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
D
UI
_
UT
EO
M I
_T
RI
PE
P_
_H
EM
ST
d)
ve
SY
r
se
_
HP
(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
LE EN
AR
_C T_
NT C
_I TE
ES
UT RO
HR
EO _P
_T
M T
UT
TI OU
EO
S_ ME
IM
BU TI
_T
I_ S_
US
ER U
_P I_B
B
I_
d)
LP ER
ER
ver
_P
_P
se
LP
LP
(re
31 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0xffff Reset
LP_PERI_BUS_TIMEOUT_THRES Configures the timeout threshold for bus access for accessing
LP peripheral register, corresponding to the number of clock cycles of the clock domain. (R/W)
PRELIMINARY
Espressif Systems 475 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
15 System Registers GoBack
R
DD
_A
UT
EO
MI
_T
US
B
I_
ER
_P
LP
31 0
0x000000 Reset
ID
_U
UT
EO
IM
_T
BUS
I_
d)
ER
e
rv
_P
se
LP
(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
LP_PERI_BUS_TIMEOUT_UID Represents the master id[4:0] and master permission[6:5] when trig-
ger timeout. This register will be cleared after the interrupt is cleared. (WTC)
Y
rv
_S
se
HP
(re
31 28 27 0
0 0 0 0 0x2209271 Reset
PRELIMINARY
Espressif Systems 476 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
16.1 Overview
Debug Assistant is an auxiliary module that features a set of functions to help locate bugs and issues during
software debugging.
16.2 Features
• Read/write monitoring: Monitors whether the CPU bus reads from or writes to a specified memory
address space. A detected read or write in the monitored address space will trigger an interrupt.
• Stack pointer (SP) monitoring: Monitors whether the SP exceeds the specified address space. A bounds
violation will trigger an interrupt.
• Program counter (PC) logging: Records PC value. The developer can get the last PC value at the most
recent CPU reset.
• Bus access logging: Records the information about bus access. When the CPU or Direct Memory
Access (DMA) controller writes a specified value, the Debug Assistant module will record the data type,
address of this write operation, and additionally the PC value when the write is performed by the CPU, and
push such information to the HP SRAM.
16.3.2 SP Monitoring
The Debug Assistant module can monitor the SP so as to prevent stack overflow or erroneous push/pop. When
the SP exceeds the minimum or maximum threshold, the module will record the PC pointer and generate an
interrupt. The threshold is configured by software.
16.3.3 PC Logging
In some cases, software developers want to know the PC at the last CPU reset. For instance, when the program
is stuck and the issue can be solved only by reset, the developer may want to know where the program got stuck
in order to debug. The Debug Assistant module can record the PC at the last CPU reset, which can be then read
for software debugging.
PRELIMINARY
Espressif Systems 477 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
space, the module will record the bus type, the address, PC (only when the write is performed by the CPU will
PC be recorded), and other information, and then store the data in the HP SRAM in a certain format.
2. Configure interrupts.
PRELIMINARY
Espressif Systems 478 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
Assuming that Debug Assistant module needs to monitor whether data bus writes to [A–B] address space, you
can enable monitoring in either data bus region 0 or region 1. The following configuration process is based on
region 0:
6. Configure interrupt matrix to map ASSIST_DEBUG_INT into CPU interrupt (please refer to Chapter 9
Interrupt Matrix (INTMTX)).
PRELIMINARY
Espressif Systems 479 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
• Enable the permission for the Debug Assistant module to access the internal HP SRAM. The
permission is disabled by default. Only when it is enabled can the Debug Assistant module access the
internal HP SRAM. For more information, please refer to Chapter 14 Access Permission Management
(APM).
5. Configure the writing mode for the recorded data: loop mode or non-loop mode.
• In Loop mode, writing to the specified address space is performed in loops. When writing reaches the
end address, it will return to the starting address and continue, overwriting the previously recorded
data. Set MEM_MONITOR_LOG_MEM_LOOP_ENABLE to enable Loop mode.
For example, there are 10 write operations (1 – 10) to address space 0 – 4 during bus access. After
the 5th operation writes to address 4, the 6th operation will start writing from address 0. The 6th to
10th operations will overwrite the previous data written by the 1st to 5th operations.
• In Non-loop mode, when writing reaches the end address, it will stop at the end address and discard
the remaining data, not overwriting the previously recorded data. Clear
PRELIMINARY
Espressif Systems 480 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
• Enable CPU or DMA bus access logging with MEM_MONITOR_LOG_ENA. They can be enabled at
the same time.
The Debug Assistant module first writes the recorded data to an internal buffer, and then fetches the data from
the buffer and writes it to the configured memory space. When the monitored behaviors are triggered
continuously, the generated recording packets may fully occupy the buffer, making it unable to take any incoming
packets. At this time, the module discards these incoming packets and buffers a LOST packet instead to
indicate some packets are discarded before the buffer reaches its capacity. However, the bus type and the
number of these discarded packets are unknown.
When bus access logging is finished, the recorded data can be read from memory for decoding. The recorded
data can be in one of these three packet formats, namely CPU packet (corresponding to CPU data bus), DMA
packet (corresponding to DMA bus), and LOST packet. The packet formats are shown in Table 16-1, 16-2, and
16-3.
It can be seen from the data packet formats that the HP CPU packet size is 64 bits, DMA packet size 32 bits,
and LOST packet 32 bits. These packets contain the following fields:
• format – the packet type. 0: CPU packet; 1: DMA packet; 3: LOST packet.
• pc_offset - the offset of the PC register at the time of access. Actual PC = pc_offset + 0x4000_0000.
• dma_source - the source of DMA access. For more information, please refer to Chapter 14 Access
Permission Management (APM) > Table 14-4.
• anchored - the location of the 32 bits in the data packet. 1 indicates the lower 32 bits. 2 indicates the
higher 32 bits.
PRELIMINARY
Espressif Systems 481 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
The internal buffer of the module is 32 bits wide. When the CPU or DMA bus access logging are all enabled at
the same time and the record data is generated at the same time, the DMA data packets are first buffered, and
then the CPU packets. The Debug Assistant will automatically fetch the buffered data and store it in 32-bit data
width into the specified memory space.
In Loop mode, data looping several times in the configured storage address space may cause residual data,
which can interfere with packet parsing. For example, the lower 32 bits of a CPU packet are overwritten, thus
making its higher 32 bits residual data. Therefore, users need to filter out the possible residual data in order to
determine the starting position of the first valid packet with
MEM_MONITOR_LOG_MEM_CURRENT_ADDR_REG. Once the starting position of the packet is identified,
check the anchored bit value of the packet. If it is 1, the data will be retained. If it is 2, it will be discarded.
2. Read and parse data from the starting address. Read 32 bits each time.
After packet parsing is completed, clear the MEM_MONITOR_LOG_MEM_FULL_FLAG flag bit by setting
MEM_MONITOR_CLR_LOG_MEM_FULL_FLAG.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 482 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
PRELIMINARY
Espressif Systems 483 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
16.6 Registers
The addresses of bus logging configuration registers (see 16.6.1) in this section are relative to
MEM_MONITOR base address. The addresses of other registers (see 16.6.2) are relative to the
ASSIST_DEBUG base address. Both base addresses are provided in Table 4-2 in Chapter 4 System and
PRELIMINARY
Espressif Systems 484 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
Memory.
LE
AB
EN
P_
O
O
_L
DE
EM
NA
O
_M
_M
_E
G
G
LO
LO
LO
R_
R_
R_
O
O
T
T
NI
NI
NI
O
O
)
ed
_M
_M
_M
rv
EM
EM
EM
se
(re
M
31 8 7 6 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 Reset
PRELIMINARY
Espressif Systems 485 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
A
AT
_D
CK
HE
_C
G
LO
R_
TO
NI
O
_M
EM
M
31 0
0 Reset
K
AS
M
A_
AT
_D
G
LO
R_
TO
NI
O
)
ed
_M
rv
EM
se
(re
M
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
PRELIMINARY
Espressif Systems 486 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
IN
_M
G
LO
R_
TO
NI
O
_M
EM
M
31 0
0 Reset
MEM_MONITOR_LOG_MIN Configures the starting address of the monitored address space. (R/W)
AX
_M
G
LO
R_
TO
NI
O
_M
EM
M
31 0
0 Reset
MEM_MONITOR_LOG_MAX Configures the ending address of the monitored address space. (R/W)
31 0
0 Reset
MEM_MONITOR_LOG_MEM_START Configures the starting address of the storage space for the
recorded data. (R/W)
PRELIMINARY
Espressif Systems 487 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
ND
_E
EM
_M
G
LO
R_
TO
NI
O
_M
EM
M
31 0
0 Reset
MEM_MONITOR_LOG_MEM_END Configures the ending address of the storage space for the
recorded data. (R/W)
R
DD
_A
NT
RE
UR
_C
EM
_M
G
LO
R_
TO
NI
O
_M
EM
M
31 0
0 Reset
PRELIMINARY
Espressif Systems 488 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
E
AT
PD
_U
DR
AD
_
EM
_M
G
LO
R_
TO
NI
MO
d)
rve
M_
se
ME
( 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
LA AG
_F _FL
G
L
FU FUL
_
LL
ME MEM
M_
_
LO LOG
G_
_
TO CLR
_
R_
MO OR
M_ NIT
NI
ME _MO
d)
rve
M
se
ME
( 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
PRELIMINARY
Espressif Systems 489 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
EN
K_
CL
R_
OT
NI
O
d)
_M
ver
EM
se
(re
M
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
TE
DA
R_
TO
NI
O
)
ed
_M
rv
EM
se
(re
31 28 27 0
0 0 0 0 0x2202140 Reset
PRELIMINARY
Espressif Systems 490 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
A_ AM0 RD_ A
0_ _ENA
A
NA
EN
EN
_E
A_ AM0 WR_
AR _PIF_ RD_E A
NA
SIS DEB _COR 0_AR _PIF WR A
R
N
RD
A
N
A
AM _W
UG ORE ARE LL_M _EN
_E
_E
RA D_E
IF_ _EN
1_
_
SIS DEB _COR 0_AR _PIF WR
_1
_0
0_
0_
AX
M
RE SP_ LL_M
1
_1
0
_
R
DR
DR
_D
_P
PI
P I
A
A
EA
EA
_S
S
RE ARE
RE ARE
RE
AR
SIS DEB _COR 0_SP
_A
0_
_
0_
0_
0_
0
_0
_
E_
_
_
_
E_
E_
RE
RE
OR
EB _CO
CO
EB _CO
CO
CO
C
G_
G_
UG
G
UG
G
U
U
U
U
U
BU
EB
EB
EB
EB
AS T_D
AS T_D
AS T_D
_D
AS T_D
AS T_D
d )
_
T_
rve
T
SIS
SIS
SIS
SIS
SIS
SIS
SIS
se
AS
AS
AS
AS
AS
(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
PRELIMINARY
Espressif Systems 491 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
PRELIMINARY
Espressif Systems 492 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
IN
M
0_
0_
AM
DR
A_
RE
_A
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0xffffffff Reset
AX
M
0_
0_
AM
R
_D
R EA
_A
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0 Reset
PRELIMINARY
Espressif Systems 493 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
IN
M
1_
0_
AM
DR
A_
RE
_A
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0xffffffff Reset
AX
M
1_
0_
AM
R
_D
R EA
_A
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0 Reset
PRELIMINARY
Espressif Systems 494 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
IN
M
0_
F_
I
A_P
RE
_A
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0xffffffff Reset
AX
M
0_
F_
I
_P
EA
R
_A
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0 Reset
PRELIMINARY
Espressif Systems 495 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
IN
M
1_
IF_
_P
A
RE
_A
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0xffffffff Reset
AX
_M
_1
IF
_P
EA
AR
_
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 496 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
P
_S
A
RE
_A
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0 Reset
IN
_M
P
_S
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0 Reset
31 0
0xffffffff Reset
PRELIMINARY
Espressif Systems 497 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
C
_P
P
_S
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0 Reset
PRELIMINARY
Espressif Systems 498 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
AW
_0_ _RAW
W
0_1 R_RA
_RA
M0 WR_R
_1_ _RAW
AW
AW
AW
L_M _RAW
_RD
RD
F_1 RAW
_W
T_D UG_C E_0_A A_PIF WR_R
T_D UG_C E_0_A A_PIF RD_R
_0_
R
0_1
_
_W
X
N
M0
P_S L_MA
_0_
_0_
I
AM
M
RA
_AR _DRA
RA
PIF
_PI
PIL
PIL
A_D
_D
_
A
EA
A
EA
P_S
RE
OR _ARE
RE
RE
RE
OR _ARE
AR
T_D UG_C E_0_S
T_D UG_C E_0_S
0_A
_0_
0
E_0
E_0
_
_
E
RE
RE
OR
OR
OR
OR
OR
OR
CO
CO
T_D UG_C
_C
_C
G_
G_
G
UG
U
U
U
EB
EB
B
EB
EB
EB
EB
EB
EB
EB
E
T_D
T_D
T_D
T_D
e d)
erv
SIS
SIS
SIS
SIS
SIS
SIS
SIS
SIS
SIS
SIS
(res
AS
AS
AS
AS
AS
AS
AS
AS
AS
AS
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
PRELIMINARY
Espressif Systems 499 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
M0 RD_IN _ENA
NA
M0 WR_IN _ENA
A
_EN
RD TR_E
A
WR NA
R
EN
TR
_IN _ENA
NA
INT
T
R_E
_E
_IN
_
R_E
TR
_
TR
NT
R
INT
N
NT
T
T_D UG_C E_0_A A_PIF WR_I
_ I
_1_
_
_0_
_0_
D_
X_I
0_1
_W
R
N
0
P_S L_MA
1_
_
_0_
I
AM
M
_M
1
F_0
RA
_AR _DRA
RA
_
_
F
PIF
ILL
_PI
_PI
PIL
_D
_D
P
_
A
EA
EA
A
A
EA
P_S
RE
RE
RE
RE
OR _ARE
R
AR
T_D UG_C E_0_S
T_D UG_C E_0_S
0_A
0_A
_0_
_0_
_0
E_0
_
_
E
RE
RE
RE
E
OR
R
OR
OR
OR
OR
O
CO
O
CO
T_D UG_C
_C
G_
G_
G_
G _
UG
U
U
BU
U
EB
B
B
EB
EB
EB
EB
EB
EB
E
E
E
T_D
T_D
T_D
T_D
T_D
ed)
erv
SIS
SIS
SIS
SIS
SIS
SIS
SIS
SIS
SIS
SIS
(res
AS
AS
AS
AS
AS
AS
AS
AS
AS
AS
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
PRELIMINARY
Espressif Systems 500 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
LR
LR
LR
A_D M0_1 R_CL
M0 WR_C
M0 RD_C
_C
LR
R
R
LR
RD
CL
CL
R
LR
_W
_C
_PI _WR_
_
_ 0_
_0_
_PI _RD_
_C
WR
0_1
IN_
_SP MAX
_1_
_
AM
_M
1
F_0
F_0
RA
RA
RA
_AR _PIF_
0_S PILL_
PIF
ILL
A_D
_D
_
EA
A
EA
EA
EA
_S
RE
E
RE
OR _ARE
AR
AR
AR
_AR
P
_SP
A
_0_
_0_
_0_
0
E_0
E_0
E_0
E_0
_
E
RE
RE
RE
RE
OR
OR
R
OR
OR
O
CO
O
CO
CO
_C
_C
_C
_C
_C
_C
G_
G_
G_
G
G
G
UG
UG
SIS EBUG
BU
U
BU
BU
BU
BU
EB
EB
B
EB
(AS T_DE
(AS T_DE
(AS T_DE
(AS T_DE
(AS T_DE
(AS T_DE
_D
_D
T_D
ed)
T
SIS
SIS
SIS
SIS
SIS
SIS
SIS
SIS
erv
SIS
(res
(AS
(AS
(AS
AS
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
PRELIMINARY
Espressif Systems 501 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
N
EC GEN
DE
OR
BU
_R _PDE
_R
RE RCD
CD
0_
_0
G_ RE_
O
CO
DE G_C
U
BU
EB
AS T_D
)
ed
T_
rv
SIS
SIS
se
AS
(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
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 502 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
SP
G
BU
DE
_P
CD
_R
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0x000000 Reset
CX
_E
RE
O
EF
_B
PC
ST
_LA
_0
RE
O
_C
UG
EB
_D
ST
SI
AS
31 0
0 Reset
PRELIMINARY
Espressif Systems 503 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
IVE
CT
OD E_A
_M UL
E
UG OD
EB _M
G
_0 BU
RE DE
_D
CO _0_
G_ RE
BU CO
DE G_
U
SIS EB
AS T_D
d)
T_
rve
SIS
se
AS
(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
N
_E
LK
_C
G
BU
E
_D
d)
e
ST
rv
se
SI
AS
(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
PRELIMINARY
Espressif Systems 504 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
16 Debug Assistant (ASSIST_DEBUG�MEM_MONITOR) GoBack
E
AT
_D
G
BU
E
_D
)
ed
ST
rv
se
SI
AS
(re
31 28 27 0
0 0 0 0 0x2109130 Reset
PRELIMINARY
Espressif Systems 505 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
17.1 Introduction
ESP32-H2 integrates an Advanced Encryption Standard (AES) accelerator, which is a hardware device that
speeds up computation using AES algorithm significantly, compared to AES algorithms implemented solely in
software. The AES accelerator integrated in ESP32-H2 has two working modes, which are Typical AES and
DMA-AES.
17.2 Features
The following functionality is supported:
* CTR (Counter)
– Supports encryption and decryption using cryptographic keys of 128 and 256 bits, specified in NIST
FIPS 197.
In this working mode, the plaintext and ciphertext is written and read via CPU directly.
PRELIMINARY
Espressif Systems 506 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
– Supports encryption and decryption using cryptographic keys of 128 and 256 bits, specified in NIST
FIPS 197;
– Supports block cipher modes ECB, CBC, OFB, CTR, CFB8, and CFB128 under NIST SP 800-38A.
In this working mode, the plaintext and ciphertext are written and read via DMA. An interrupt will be
generated when operation completes.
Users can choose the working mode for AES accelerator by configuring the AES_DMA_ENABLE_REG register
according to Table 17-1 below.
Users can choose the length of cryptographic keys and encryption/decryption by configuring the
AES_MODE_REG register according to Table 17-2 below.
For a detailed introduction to these two working modes, please refer to Section 17.5 and Section 17.6
below.
Notice:
ESP32-H2’s Digital Signature Algorithm (DSA) module will call the AES accelerator. Therefore, users cannot
access the AES accelerator when Digital Signature Algorithm (DSA) module is working.
PRELIMINARY
Espressif Systems 507 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
• For AES-128 encryption or decryption, the 128-bit key is stored in AES_KEY_0_REG ~ AES_KEY_3_REG.
• For AES-256 encryption or decryption, the 256-bit key is stored in AES_KEY_0_REG ~ AES_KEY_7_REG.
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.
• For AES-128 or AES-256 encryption, the AES_TEXT_IN_m_REG registers are initialized with plaintext.
Then, the AES accelerator stores the ciphertext into AES_TEXT_OUT_m_REG after operation.
• For AES-128 or AES-256 decryption, the AES_TEXT_IN_m_REG registers are initialized with ciphertext.
Then, the AES accelerator stores the plaintext into AES_TEXT_OUT_m_REG after operation.
17.5.2 Endianness
Text Endianness
In Typical AES working mode, the AES accelerator uses cryptographic keys to encrypt and decrypt data in
blocks of 128 bits. When filling data into AES_TEXT_IN_m_REG register or reading result from
AES_TEXT_OUT_m_REG registers, users should follow the text endianness type specified in Table 17-4.
Plaintext/Ciphertext
c2
State1
0 1 2 3
0 AES_TEXT_x_0_REG[7:0] AES_TEXT_x_1_REG[7:0] AES_TEXT_x_2_REG[7:0] AES_TEXT_x_3_REG[7:0]
1 AES_TEXT_x_0_REG[15:8] AES_TEXT_x_1_REG[15:8] AES_TEXT_x_2_REG[15:8] AES_TEXT_x_3_REG[15:8]
r
2 AES_TEXT_x_0_REG[23:16] AES_TEXT_x_1_REG[23:16] AES_TEXT_x_2_REG[23:16] AES_TEXT_x_3_REG[23:16]
3 AES_TEXT_x_0_REG[31:24] AES_TEXT_x_1_REG[31:24] AES_TEXT_x_2_REG[31:24] AES_TEXT_x_3_REG[31:24]
1
The definition of “State (including c and r)” is described in Section 3.4 The State in NIST FIPS 197.
2
Where x = IN or OUT.
PRELIMINARY
Espressif Systems 508 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
17
Key Endianness
Table 175. Key Endianness Type for AES128 Encryption and Decryption
Table 176. Key Endianness Type for AES256 Encryption and Decryption
509
1
Column “Bit” specifies the bytes of each word stored in w[0] ~ w[7].
ESP32-H2 TRM (Pre-release v0.4)
2
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.
PRELIMINARY
GoBack
17 AES Accelerator (AES) GoBack
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 and AES_KEY_n_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 17-8 below.
PRELIMINARY
Espressif Systems 510 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
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 disabled. Also, note that the interrupt should be cleared by software after use.
During the block operations, the AES accelerator reads source data from DMA, and writes result data 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 17-9 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.6.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
PRELIMINARY
Espressif Systems 511 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
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 17-10 below.
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 17-10, 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.
PRELIMINARY
Espressif Systems 512 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
• Select block cipher mode by configuring the AES_BLOCK_MODE_REG register. For details, see Table
17-7.
• 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).
4. Wait for the completion of computation, which happens when the content of AES_STATE_REG becomes 2
or the AES interrupt occurs.
5. 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 3
GDMA Controller (GDMA).
6. Clear interrupt by writing 1 to the AES_INT_CLR_REG register, if any AES interrupt occurred during the
computation.
7. Release the AES accelerator by writing 1 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 4 is
completed.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 513 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 514 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
17.9 Registers
The addresses in this section are relative to the AES accelerator base address provided in Table 4-2 in Chapter 4
System and Memory.
)
-7
:0
(n
G
RE
n_
Y_
KE
S_
AE
31 0
0x000000000 Reset
)
-3
:0
(m
EG
_R
m
_
IN
T_
X
TE
S_
AE
31 0
0x000000000 Reset
AES_TEXT_IN_m_REG (m: 03) Represents the source text 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) Represents the result text data when the AES accelerator oper-
ates in the Typical AES working mode. (RO)
PRELIMINARY
Espressif Systems 515 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
DE
)
ed
O
M
rv
S_
se
AE
(re
31 3 2 0
0x00000000 0 Reset
AES_MODE Configures the key length and encryption/decryption of the AES accelerator.
0: AES-128 encryption
1: Reserved
2: AES-256 encryption
3: Reserved
4: AES-128 decryption
5: Reserved
6: AES-256 decryption
7: Reserved
(R/W)
LE
AB
EN
A_
d)
DM
rve
S_
se
AE
(re
31 1 0
0x00000000 0 Reset
PRELIMINARY
Espressif Systems 516 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
DE
O
_M
CK
O
)
ed
BL
v
er
S_
s
AE
(re
31 3 2 0
0x00000000 0 Reset
AES_BLOCK_MODE Configures the block cipher mode of the AES accelerator operating under the
DMA-AES working mode.
0: ECB (Electronic Code Block)
1: CBC (Cipher Block Chaining)
2: OFB (Output FeedBack)
3: CTR (Counter)
4: CFB8 (8-bit Cipher FeedBack)
5: CFB128 (128-bit Cipher FeedBack)
6: Reserved
7: Reserved
(R/W)
31 0
0x00000000 Reset
AES_BLOCK_NUM Represents the Block Number of plaintext or ciphertext when the AES accelerator
operates under the DMA-AES working mode. For details, see Section 17.6.4. (R/W)
IN
rv
S_
se
AE
(re
31 1 0
0x00000000 0 Reset
AES_INC_SEL Configures the Standard Incrementing Function for CTR block operation.
0: INC32
1: INC128
(R/W)
PRELIMINARY
Espressif Systems 517 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
ER
G
IG
d)
TR
ver
S_
se
AE
(re
31 1 0
0x00000000 x Reset
E
AT
)
ed
ST
rv
S_
se
AE
(re
31 2 1 0
PRELIMINARY
Espressif Systems 518 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
17 AES Accelerator (AES) GoBack
IT
EX
A_
d)
DM
ve
r
S_
se
AE
(re
31 1 0
0x00000000 x Reset
LR
_C
d )
T
ve
IN
r
S_
se
AE
(re
31 1 0
0x00000000 x Reset
A
EN
T_
)
ed
IN
rv
S_
se
AE
(re
31 1 0
0x00000000 0 Reset
PRELIMINARY
Espressif Systems 519 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
18.1 Introduction
Elliptic Curve Cryptography (ECC) is an approach to public-key cryptography based on the algebraic structure of
elliptic curves. ECC uses smaller keys compared to RSA cryptography while providing equivalent security.
ESP32-H2’s ECC accelerator can complete various calculations based on different elliptic curves, thus
accelerating the ECC algorithm and ECC-derived algorithms (such as ECDSA).
18.2 Features
ESP32-H2’s ECC accelerator has the following features:
• 2 different elliptic curves, namely P-192 and P-256 defined in FIPS 186-3
• 11 working modes
y 2 = x3 + ax + b mod p
where,
• p is a prime number,
• In affine coordinates:
y 2 = x3 + ax + b mod p
• In Jacobian coordinates:
Y 2 = X 3 + aXZ 4 + bZ 6 mod p
y = Y /Z 3 mod p
PRELIMINARY
Espressif Systems 520 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
Y =y
Z=1
D[255 : 0] = D[7][31 : 0], D[6][31 : 0], D[5][31 : 0], D[4][31 : 0], D[3][31 : 0], D[2][31 : 0], D[1][31 : 0], D[0][31 : 0]
• ···
Note:
When the key size of 192 bits is used, append 0 before 192 bits of data to ensure 256-bit data is written.
PRELIMINARY
Espressif Systems 521 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
• ···
Note:
When the key size of 192 bits is used, only read the low 192 bits (6 blocks) of data.
PRELIMINARY
Espressif Systems 522 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
Note:
Note that the calculation of Jacobian Point Multi mode is about 10% faster than that of the Affine Point Multi mode.
Detailed descriptions about different working modes are provided in the following sections.
where,
Affine Point Verification can be used to verify if a point (Px , Py ) is on a selected elliptic curve.
18.4.2.3 Affine Point Verification + Affine Point Multiplication (Affine Point Verif + Multi)
In this mode, ECC first verifies if point (Px , Py ) is on the selected elliptic curve. If so, the following multiplication is
performed:
Q = (Qx , Qy ) = (Jx , Jy , Jz ) = k · (Px , Py )
PRELIMINARY
Espressif Systems 523 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
where,
• Output:
Q = (Qx , Qy , Qz ) = k · (Px , Py , 1)
where,
where,
• Input:
• Output:
PRELIMINARY
Espressif Systems 524 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
Jacobian Point Verification can be used to verify if point (Qx , Qy , Qz ) is on a selected elliptic curve.
18.4.2.7 Affine Point Verification + Jacobian Point Multiplication (Affine Point Verif +
Jacobian Point Multi)
In this mode, ECC first verifies if point (Px , Py ) is on the selected elliptic curve. If so, the following multiplication is
performed:
Q = (Qx , Qy , Qz ) = k · (Px , Py , 1)
where,
• Output:
where,
• Input:
where,
• Input:
PRELIMINARY
Espressif Systems 525 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
where,
• Input:
where,
• Input:
ECC’s clock and reset is handled by the the Power/Clock/Reset (PCR) module (see Chapter 7 Reset and Clock for
more information). Users should enable the ECC clock by setting PCR_ECC_CLK_EN and release the ECC reset
by clearing PCR_ECC_RST_EN before starting the ECC accelerator. Besides, due to resource reuse between
cryptography accelerator modules, users also need to additionally clear the PCR_ECDSA_RST_EN bit.
PRELIMINARY
Espressif Systems 526 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
18.6 Interrupts
ESP32-H2’s ECC accelerator can generate one interrupt signal ECC_INTR and send it to Interrupt Matrix.
Note:
Each interrupt signal is generated by any of its interrupt sources, i.e., any of its interrupt sources triggered can generate
the interrupt signal.
ECC_INTR has only one interrupt source, i.e., ECC_CALC_DONE_INT, which is triggered on the completion of an
ECC calculation. This ECC_CALC_DONE_INT interrupt source is configured by the following registers:
• ECC_CALC_DONE_INT_CLR: set this bit to clear the ECC_CALC_DONE_INT interrupt status. By setting
this bit to 1, bits ECC_CALC_DONE_INT_RAW and ECC_CALC_DONE_INT_ST will be cleared.
1. Configure the ECC clock and reset. Refer to Section 18.5 for detailed information.
2. Select the key size and working mode as described in Section 18.4.
5. Wait for the ECC_CALC_DONE_INT interrupt, which indicates the completion of the ECC calculation.
PRELIMINARY
Espressif Systems 527 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 528 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
18.9 Registers
The addresses in this section are relative to ECC Accelerator base address provided in Table 4-2 in Chapter 4
System and Memory.
W
RA
T_
IN
_
NE
O
_D
LC
d)
CA
ve
C_
ser
EC
(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
_S
NT
_I
NE
DO
_
LC
d)
CA
ve
C_
r
se
EC
(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
CA
rv
C_
se
EC
(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
PRELIMINARY
Espressif Systems 529 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
R
CL
T_
_IN
NE
DO
C_
AL
d)
ve
C
C_
ser
EC
(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
PRELIMINARY
Espressif Systems 530 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
18 ECC Accelerator (ECC) GoBack
N
O
E_
RC
FO
LT
E_
SU
AT
RE
_G
N_
DE
ST T TH
VE EN CK
EC _R _LE E
O
C_ ESE NG
TI
C_ LK_ LO
C EY AS
_M
CA
EC C _C
EC K _B
T
RK
FI
AR
C_ EM
C_ OD
RI
d)
O
ve
W
EC _M
EC M
C_
C_
r
se
C
EC
EC
EC
(re
31 30 29 28 8 7 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 0 0 0 0 0 Reset
ECC_START Configures whether to start the calculation of the ECC accelerator. This bit will be self-
cleared when the calculation is done.
0: No effect
1: Start the calculation of the ECC accelerator
(R/W/SC)
ECC_MOD_BASE Configures whether to choose using the mod base or order of curve in the mod
operation. Only valid in working modes 8-11.
0: n (order of curve)
1: p (mod base of curve)
(R/W)
ECC_VERIFICATION_RESULT Represents the verification result of the ECC accelerator, valid only
when the calculation is done.
0: Verification failed
1: Verification passed
(R/SS)
DA
rv
C_
se
EC
(re
31 28 27 0
0 0 0 0 0x2207180 Reset
PRELIMINARY
Espressif Systems 532 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
• Hash result only accessible by configurable hardware peripheral (in downstream mode)
• Generates required keys for the Digital Signature Algorithm (DSA) peripheral (in downstream mode)
After the reset signal being released, the HMAC module will check whether the DSA key exists in the eFuse. If the
key exists, the HMAC module will enter downstream digital signature algorithm mode and finish the DSA key
calculation automatically.
• A sends M to B.
• B calculates the HMAC (through M and KEY) and sends the result to A.
• A compares the two results. If the results are the same, then the identity of B is authenticated.
To calculate the HMAC value, users should perform the following steps:
2. Write the correctly padded message to the HMAC, one block at a time.
There are two parameters in eFuse memory to disable JTAG: EFUSE_DIS_PAD_JTAG and
EFUSE_SOFT_DIS_JTAG. Write 1 to EFUSE_DIS_PAD_JTAG to disable JTAG permanently, and write odd
numbers of 1 to EFUSE_SOFT_DIS_JTAG to disable JTAG temporarily. For more details, please see Chapter 5
eFuse Controller (EFUSE). After bit EFUSE_SOFT_DIS_JTAG is set, the key to re-enable JTAG can be calculated
in HMAC module’s downstream mode. JTAG is re-enabled when the result configured by the user is the same as
the HMAC result.
1. Enable the HMAC module by initializing clock and reset signals of HMAC, and enter downstream JTAG
enable mode by configuring HMAC_SET_PARA_PURPOSE_REG. Then, wait for the calculation to
complete. Please see Section 19.2.5 for more details.
3. Write the 256-bit HMAC value to register HMAC_WR_JTAG_REG. This value is obtained by preforming a
local HMAC calculation from the 32-byte 0x00 using SHA-256 and the generated key. It needs to be
written 8 times and 32-bit each time in big-endian word order.
4. If the HMAC result matches the value that users calculated locally, then JTAG is re-enabled. Otherwise,
JTAG remains disabled.
5. After writing 1 to HMAC_SET_INVALIDATE_JTAG_REG or resetting the chip, JTAG will be disabled. If users
want to re-enable JTAG again, they need to repeat the above steps again.
Before starting the DSA module, users need to obtain the parameter decryption key for the DSA module through
HMAC calculation. For more information, please see Chapter 22 Digital Signature Algorithm (DSA). After the chip
is powered on, the HMAC module will check whether the key required to calculate the parameter decryption key
has been burned in the eFuse block. If the key has been burned, HMAC module will automatically enter the
downstream digital signature algorithm mode and complete the HMAC calculation based on the chosen
key.
PRELIMINARY
Espressif Systems 534 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
Table 19-1. Additionally, another purpose specifies a key which may be used for re-enabling JTAG as well as for
serving as DSA KDF.
Before enabling HMAC to do calculations, user should make sure the key to be used has been burned in eFuse
by reading the registers EFUSE_KEY_PURPOSE_x (We have a total of 6 keys in eFuse, so the value of x is 0 ~ 5.
Among which, EFUSE_KEY_PURPOSE_0 ~ EFUSE_KEY_PURPOSE_1 belong to the register
EFUSE_RD_REPEAT_DATA1_REG�and EFUSE_KEY_PURPOSE_2 ~ EFUSE_KEY_PURPOSE_5 belong to the
register EFUSE_RD_REPEAT_DATA2_REG) from 5 eFuse Controller (EFUSE). Take upstream mode as an
example, if there is no EFUSE_KEY_PURPOSE_HMAC_UP in EFUSE_KEY_PURPOSE_0 ~ 5, it means there is
no key in eFuse that can be used for the HMAC upstream mode. Users can burn key to eFuse as follows:
1. Prepare a secret 256-bit HMAC key and burn the key to an empty eFuse block y. As there are 6 blocks for
storing a key in eFuse and the numbers of those blocks range from 4 to 9, the value of y is 4 ~ 9. Hence,
when talking about key0, it means eFuse block4. Then, program the purpose to
EFUSE_KEY_PURPOSE_(y − 4). Take upstream mode as an example: after programming the key, the
user should program EFUSE_KEY_PURPOSE_HMAC_UP (corresponding value is 6) to
EFUSE_KEY_PURPOSE_(y − 4). Please see Chapter 5 eFuse Controller (EFUSE) on how to program eFuse
keys.
2. Configure this eFuse key block to be read protected, so that users cannot read its value. A copy of this key
should be kept by any party who needs to verify this device.
Please note that the key whose purpose is EFUSE_KEY_PURPOSE_HMAC_DOWN_ALL can be used for both
re-enabling JTAG or DSA.
The correct purpose has to be written to register HMAC_SET_PARA_PURPOSE_REG (see Section 19.2.5). If
there is no valid value in eFuse purpose section, HMAC will terminate calculation.
The eFuse controller provides six key blocks, i.e., KEY0 ~ 5. To select a particular KEYn for an HMAC calculation,
write the key number n to register HMAC_SET_PARA_KEY_REG.
Note that the purpose of the key has also been programmed to eFuse memory. Only when the configured HMAC
purpose matches the defined purpose of KEYn, the HMAC module will execute the configured calculation.
Otherwise, it will return a matching error and stop the current calculation.
For example, suppose a user selects KEY3 for HMAC calculation, and the value programmed to
EFUSE_KEY_PURPOSE_3 is 6 (EFUSE_KEY_PURPOSE_HMAC_DOWN_JTAG). Based on Table 19-1, KEY3
can be used to re-enable JTAG. If the value written to register HMAC_SET_PARA_PURPOSE_REG is also 6, then
the HMAC module will start the process to re-enable JTAG.
PRELIMINARY
Espressif Systems 535 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
(a) Set the peripheral clock bits for HMAC and SHA peripherals in register PCR_HMAC_CLK_EN, and
clear the corresponding peripheral reset bits in register PCR_HMAC_RST_EN. For information on
those registers, please see Chapter 7 Reset and Clock.
(a) Write the key purpose m to register HMAC_SET_PARA_PURPOSE_REG. The possible key purpose
values are shown in Table 19-1. For more information, please refer to Section 19.2.4.
(b) Select KEYn in eFuse memory as the key by writing n (ranges from 0 to 5) to register
HMAC_SET_PARA_KEY_REG. For more information, please refer to Section 19.2.4.
(d) Read register HMAC_QUERY_ERROR_REG. If its value is 1, it means the purpose of the selected
block does not match the configured key purpose and the calculation will not proceed. If its value is 0,
it means the purpose of the selected block matches the configured key purpose, and then the
calculation can proceed.
(e) When the value of HMAC_SET_PARA_PURPOSE_REG is not 8, it means the HMAC module is in
downstream mode, proceed with step 3. When the value is 8, it means the HMAC module is in
upstream mode, proceed with step 4.
3. Downstream mode:
(b) To clear the result and make further usage of the dependent hardware (JTAG or DSA) impossible,
write 1 to either register HMAC_SET_INVALIDATE_JTAG_REG to clear the result generated by the
JTAG key; or to register HMAC_SET_INVALIDATE_DS_REG to clear the result generated by DSA key.
Afterwards, the HMAC Process needs to be restarted to re-enable any of the dependent peripherals.
(d) Different message blocks will be generated, depending on whether the size of the to-be-processed
message is a multiple of 512 bits.
• If the bit length of the message is a multiple of 512 bits, there are three possible options:
ii. If Block_n is the last block of the message and users expects to apply SHA padding in
hardware, write 1 to register HMAC_SET_MESSAGE_END_REG, and then jump to step 6.
PRELIMINARY
Espressif Systems 536 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
iii. If Block_n is the last block of the padded message and SHA padding has been applied by
users, write 1 to register HMAC_SET_MESSAGE_PAD_REG, and then jump to step 5.
• If the bit length of the message is not a multiple of 512 bits, there are three possible options as
follows. Note that in this case, the user is required to apply SHA padding to the message, after
which the padded message length should be a multiple of 512 bits.
i. If there is only one message block in total which has included all padding bits, write 1 to
register HMAC_ONE_BLOCK_REG, and then jump to step 6.
iii. If Block_n is neither the last nor the second last message block, write 1 to register
HMAC_SET_MESSAGE_ING_REG and define n = n + 1, and then jump to step 4.(b).
(a) Users apply SHA padding to the last message block as described in Section 19.3.1, write this block
to register HMAC_WDATA0~15_REG, and then write 1 to register
HMAC_SET_MESSAGE_ONE_REG. Then the HMAC module will process this message block.
(c) Write 1 to register HMAC_SET_RESULT_FINISH_REG to finish calculation. The result will be cleared
at the same time.
Note:
The SHA accelerator can be called directly, or used internally by the DSA module and the HMAC module. However, they
can not share the hardware resources simultaneously. Therefore, the SHA module must not be called neither by the CPU
nor by the DSA module when the 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:
1. Append one bit of value “1” to the end of the unpadded message.
PRELIMINARY
Espressif Systems 537 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
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. This block consists of the length of the unpadded
message as a big-endian binary integer value m.
In upstream mode, if the length of the unpadded message is a multiple of 512 bits, users can configure hardware
to apply SHA padding by writing 1 to HMAC_SET_MESSGAE_END_REG or do padding work themselves by
writing 1 to HMAC_SET_MESSAGE_PAD_REG. If the length is not a multiple of 512 bits, SHA padding must be
manually applied by the user. After the user prepared the padding data, they should complete the subsequent
configuration according to the Section 19.2.5.
PRELIMINARY
Espressif Systems 538 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
In Figure 19-2:
The HMAC module appends a 256-bit 0 sequence after the bit sequence of the 256-bit key K in order to get a
512-bit K0 . Then, the HMAC module XORs K0 with ipad to get the 512-bit S1. Afterwards, the HMAC module
appends the input message (multiple of 512 bits) after the 512-bit S1, and exercises the SHA-256 algorithm to
get the 256-bit H1.
The HMAC module appends the 256-bit SHA-256 hash result H1 to the 512-bit S2 value, which is calculated
using the XOR operation of K0 and opad. A 768-bit sequence will be generated. Then, the HMAC module uses
the SHA padding algorithm described in Section 19.3.1 to pad the 768-bit sequence to a 1024-bit sequence,
and applies the SHA-256 algorithm to get the final hash result (256-bit).
PRELIMINARY
Espressif Systems 539 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 540 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
PRELIMINARY
Espressif Systems 541 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
19.5 Registers
The addresses in this section are relative to HMAC Accelerator base address provided in Table 4-2 in Chapter 4
System and Memory.
TR
TA
_S
ET
d)
_S
ve
AC
ser
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
A_
AR
_P
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
PRELIMINARY
Espressif Systems 542 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
G
_IN
EXT
_T
ET
d)
_S
ve
AC
ser
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
T_
EX
_T
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
D
EN
T_
UL
ES
_R
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
HMAC_SET_RESULT_END Configures whether to exit upstream mode and clear calculation results.
0: No effect
1: Exit upstream mode and clear calculation results.
(WO)
PRELIMINARY
Espressif Systems 543 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
G
TA
_J
E
AT
ID
AL
NV
_I
ET
d)
_S
ve
AC
ser
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
_D
E
AT
LID
VA
N
_I
ET
)
_S
d
ve
AC
ser
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
PRELIMINARY
Espressif Systems 544 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
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
E
AT
ST
Y_
US
d)
_B
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
_P
ve
AC
r
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
HMAC_PURPOSE_SET Configures the HMAC purpose, refer to the Table 19-1. (WO)
PRELIMINARY
Espressif Systems 545 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
T
SE
E Y_
)
_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
HMAC_KEY_SET Configures HMAC key. There are six keys with index 0~5. Write the index of the
selected key to this field. (WO)
_0
TA
DA
_W
AC
HM
31 0
0 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 546 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
D
PA
_
E XT
_T
ET
d)
_S
ve
AC
ser
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
CK
LO
_B
NE
_O
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_ONE_BLOCK Write 1 to indicate Block_1 is the only one block, and Block_1 contains
all the padding bits and there is no need for padding. (WO)
TRL
_C
G
TA
_J
FT
O
)
_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
PRELIMINARY
Espressif Systems 547 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
19 HMAC Accelerator (HMAC) GoBack
AG
JT
R_
_W
AC
HM
31 0
x Reset
HMAC_WR_JTAG Writes the comparing input used for re-enabling JTAG. (WO)
E
AT
d)
_D
e
rv
AC
se
HM
(re
31 30 29 0
0 0 0x20200618 Reset
PRELIMINARY
Espressif Systems 548 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
20.1 Introduction
The RSA accelerator provides hardware support for high-precision computation used in various RSA asymmetric
cipher algorithms, significantly improving their run time and reducing their software complexity. Compared with
RSA algorithms implemented solely in software, this hardware accelerator can speed up RSA algorithms
significantly. The RSA accelerator also supports operands of different lengths, which provides more flexibility
during the computation.
20.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_QUERY_CLEAN_REG register is 0 during initialization and will become 1 after the initialization is done.
Therefore, wait until RSA_QUERY_CLEAN_REG becomes 1 before using the RSA accelerator.
The RSA_INT_ENA_REG register is used to control the interrupt triggered on completion of computation. Write 1
or 0 to this field to enable or disable the interrupt. By default, the interrupt function of the RSA accelerator is
enabled.
Notice:
ESP32-H2’s Digital Signature Algorithm (DSA) module also calls the RSA accelerator when working. Therefore,
users cannot access the RSA accelerator when the Digital Signature Algorithm (DSA) module is working.
PRELIMINARY
Espressif Systems 549 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
The RSA accelerator supports operands of length N = 32 × x, where x ∈ {1, 2, 3, . . . , 96}. 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 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.
M ′ = −M −1 mod b
where, M −1 is the modular multiplicative inverse of M , and it can be calculated with the extended binary GCD
algorithm.
(c) Configure registers related to the acceleration options, which are described later in Section 20.3.4.
Users need to write data to each memory block only according to the length of the number; data beyond
this length is ignored.
PRELIMINARY
Espressif Systems 550 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
5. Wait for the completion of computation, which happens when the content of RSA_QUERY_IDLE becomes
1 or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT to clear the interrupt, if you have the interrupt enabled.
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 96 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_QUERY_IDLE becomes
1 or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT to clear the interrupt, if you have the interrupt enabled.
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.
PRELIMINARY
Espressif Systems 551 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
3. Write Xi and Yi for ∈ {0, 1, . . . , n − 1} to memory blocks RSA_X_MEM and RSA_Z_MEM. Each word of
each memory block can store one base-b digit. The memory blocks use the little endian format for storage,
N
i.e. the least significant digit of each number is in the lowest address. n is 32 .
Write Xi for i ∈ {0, 1, . . . , n − 1} to the address of the i words of the RSA_X_MEM memory block. Note
that Yi for i ∈ {0, 1, . . . , n − 1} 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 is ignored.
5. Wait for the completion of computation, which happens when the content of RSA_QUERY_IDLE becomes
1 or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT to clear the interrupt, if you have the interrupt enabled.
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.
Users can choose to use one or two of these options to further accelerate the computation. Note that, even
when none of these two options is configured, using the hardware RSA accelerator is still much faster than
implementing the RSA algorithm in software.
To be more specific, when neither of these two options are configured for additional acceleration, the time
required to calculate Z = X Y mod M is solely determined by the lengths of operands. When either or both of
these two options are configured for additional acceleration, the time required is also correlated with the 0/1
distribution of Y .
To better illustrate how these two options work, first assume Y is represented in binaries as
where,
• N is the length of Y ,
PRELIMINARY
Espressif Systems 552 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
• 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.
– The accelerator ignores the bit positions of Yei , where i > α. Search position α is set by configuring
the RSA_SEARCH_POS_REG register. Set α to a number smaller than N -1, which otherwise leads to
the same result as if this option is not used for additional acceleration. 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.
– Note that this option compromises the security because it ignores some bits, which essentially
shortens the key length, thus should not be enabled for applications with high security requirement.
– 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 is the acceleration performance.
– Note that this option also compromises the security because its time cost correlates with the 0/1
distribution of the key, which can be used in a Side Channel Attack (SCA), thus should not be enabled
for applications with high security requirement.
Below is an example to demonstrate the performance of the RSA accelerator under different combinations of
SEARCH and CONSTANT_TIME configuration. Here we perform Z = X Y mod M with N = 3072 and Y =
65537. Table 20-1 below demonstrates the time costs under different combinations of SEARCH and
CONSTANT_TIME configuration. Here, we should also mention that, α is set to 16 when the SEARCH option is
enabled.
It is obvious that:
• The time cost is biggest when none of these two options is configured for additional acceleration.
• The time cost is smallest when both of these two options are configured for additional acceleration.
• The time cost can be dramatically reduced when either or both option(s) are configured for additional
acceleration.
PRELIMINARY
Espressif Systems 553 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 554 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
20.6 Registers
The addresses in this section are relative to the RSA accelerator base address provided in Table 4-2 in Chapter 4
System and Memory.
For how to program reserved fields, please refer to Section Programming Reserved Register Field.
E
M
RI
_P
M
A_
RS
31 0
0x000000 Reset
DE
d)
O
e
M
rv
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 Reset
XP
DE
O
M
T_
AR
ST
T_
d)
SE
e
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
PRELIMINARY
Espressif Systems 555 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
T
UL
DM
O
M
T_
R
TA
_S
d)
T
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
T
UL
M
T_
AR
ST
T_
d)
SE
e
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
Q
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
PRELIMINARY
Espressif Systems 556 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
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
E
BL
NA
_E
CH
AR
d)
SE
r ve
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
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 0 Reset
RSA_SEARCH_POS Configures the starting address to start search. This field should be used to-
gether with RSA_SEARCH_ENABLE_REG. The field is only valid when RSA_SEARCH_ENABLE is
high. (R/W)
PRELIMINARY
Espressif Systems 557 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
20 RSA Accelerator (RSA) GoBack
NA
LE
_C
RY
UE
d)
ve
Q
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
UP
RR
TE
IN
R_
EA
d)
CL
e
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
A
EN
T_
e d)
IN
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
DA
r ve
A_
se
RS
(re
31 30 29 0
0 0 0x20200618 Reset
PRELIMINARY
Espressif Systems 558 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
21.1 Introduction
ESP32-H2 integrates an SHA accelerator, which is a hardware device that speeds up the SHA algorithm
significantly, compared to a SHA algorithm implemented solely in software. The SHA accelerator integrated in
ESP32-H2 has two working modes, which are Typical SHA and DMA-SHA.
21.2 Features
The following functionality is supported:
– SHA-1
– SHA-224
– SHA-256
– 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 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.
The SHA accelerator is activated by setting the PCR_SHA_CLK_EN bit and clearing the PCR_SHA_RST_EN bit
in the PCR_SHA_CONF_REG register. Additionally, users also need to clear PCR_DS_RST_EN,
PCR_HMAC_RST_EN, and PCR_ECDSA_RST_EN bits to reset Digital Signature Algorithm (DSA), HMAC
Accelerator (HMAC), and Elliptic Curve Digital Signature Algorithm (ECDSA).
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 21-1.
Users can choose hash algorithms by configuring the SHA_MODE_REG register. For details, please see Table
PRELIMINARY
Espressif Systems 559 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
21-2.
Notice:
ESP32-H2’s Digital Signature Algorithm (DSA) and HMAC Accelerator (HMAC) modules also call the SHA
accelerator when working. Therefore, users cannot access the SHA accelerator when these modules are
working.
21.4.1 Preprocessing
Preprocessing consists of three steps: padding the message, parsing the message into message blocks and
setting the initial hash value.
The SHA accelerator can only process message blocks of 512 bits. Thus, all the messages should be padded to
a multiple of 512 bits before the hash operation.
Suppose that the length of the message M is m bits. Then M shall be padded as introduced below:
2. Second, append k bits of zeros, where k is the smallest, non-negative solution to the equation
m + 1 + k ≡ 448 mod 512;
3. Last, append the 64-bit block of value equal to the number m expressed using a binary representation.
For more details, please refer to FIPS PUB 180-4 Spec > Section “Padding the Message”.
The message and its padding must be 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 32 bits of message block i are denoted
(i) (i) (i)
M0 , the next 32 bits are M1 , and so on up to M15 .
(i)
During the task, all the message blocks are written into the SHA_M_n_REG: M0 is stored in SHA_M_0_REG,
(i) (i)
M1 stored in SHA_M_1_REG, …, and M15 stored in SHA_M_15_REG.
PRELIMINARY
Espressif Systems 560 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
Note:
For more information about “message block”, please refer to FIPS PUB 180-4 Spec > Section “Glossary of Terms and
Acronyms”.
Before hash operation begins for any secure hash algorithms, the initial Hash value H(0) must be set based on
different algorithms. However, the SHA accelerator uses the initial Hash values (constant C) stored in the
hardware for hash tasks.
Usually, the SHA accelerator will process all blocks of a message and produce a message digest before starting
the computation of the next message digest.
However, ESP32-H2 SHA also supports optional “interleaved” message digest calculation in Typical SHA mode,
which means before SHA completes all blocks of the current message, users are given a chance to insert new
computation of another message digest upon the completion of each individual block of the current
message.
Specifically, users can read out the message digest from registers SHA_H_n_REG after completing part of a
message digest calculation, and use the SHA accelerator for a different calculation. After the different calculation
completes, users can restore the previous message digest to registers SHA_H_n_REG, and resume the
accelerator with the previously paused calculation.
• 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 calculation;
• If this is not the first time to execute this step2 , 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 calculation.
PRELIMINARY
Espressif Systems 561 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
• Poll register SHA_BUSY_REG until the content of this register becomes 0, indicating the accelerator
has completed the calculation for the current message block and now is in the “idle” status 3 .
Note:
1. In this step, 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 calculation, to save time.
2. You are resuming the SHA accelerator with the previously paused calculation.
3. Here you can decide if you want to insert other calculations. If yes, please go to the process for interleaved
calculations for details.
As mentioned above, ESP32-H2 SHA accelerator supports “interleaving” calculation under the Typical SHA
working mode.
1. Prepare to hand the SHA accelerator over for an interleaved calculation by storing the following data of the
previous calculation.
2. Perform the interleaved calculation. For the detailed process of the interleaved calculation, please refer to
Typical SHA process or DMA-SHA process, depending on the working mode of your interleaved calculation.
3. Prepare to hand the SHA accelerator back to the previously paused calculation by restoring the following
data of the previous calculation.
4. Write the next message block from the previous paused calculation in registers SHA_M_n_REG, and set the
SHA_CONTINUE_REG register to 1 to restart the SHA accelerator with the previously paused calculation.
ESP32-H2 SHA accelerator does not support “interleaving” message digest calculation at the level of individual
message blocks when using DMA, which means you cannot insert new calculation before a complete DMA-SHA
process (of one or more message blocks) completes. In this case, users who need interleaved operation are
recommended to divide the message blocks and perform several DMA-SHA calculations, instead of trying to
compute all the messages in one go.
PRELIMINARY
Espressif Systems 562 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
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 DMA. Therefore, users are required to configure the DMA controller following the
description in Chapter 3 GDMA Controller (GDMA).
DMASHA process
• Select a hash algorithm by configuring the SHA_MODE_REG register. For details, please refer to Table
21-2.
• If the current DMA-SHA calculation follows a previous calculation, firstly write the message digest from
the previous calculation 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 calculation, which happens when:
• An SHA interrupt occurs. In this case, please clear interrupt by writing 1 to the SHA_INT_CLEAR_REG
register.
Table 213. The Storage and Length of Message Digest from Different Algorithms
PRELIMINARY
Espressif Systems 563 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
21.4.4 Interrupt
When working in the DMA-SHA mode, SHA supports interrupt on the completion of message digest
calculation.
• Note that the interrupt should be cleared by software after use via setting the SHA_INT_CLEAR_REG
register to 1.
When working in the Typical SHA mode, SHA completes the calculation quickly, so an interrupt is not necessary.
Therefore, SHA does not support interrupt in the Typical SHA mode.
PRELIMINARY
Espressif Systems 564 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 565 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
21.6 Registers
The addresses in this section are relative to the SHA accelerator base address provided in Table 4-2 in Chapter 4
System and Memory.
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
UE
IN
NT
d )
CO
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
TE
TA
_S
SY
d)
BU
e
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
PRELIMINARY
Espressif Systems 566 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
T
AR
ST
A_
d)
DM
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
E
U
IN
NT
CO
A_
d)
DM
e
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
T
UP
RR
TE
IN
R_
EA
d )
CL
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
IN
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
PRELIMINARY
Espressif Systems 567 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
TE
)
ed
DA
rv
A_
se
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
UM
_N
CK
O
BL
A_
d)
DM
ve
A_
r
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
31 0
0x000000 Reset
SHA_H_n Represents the nth 32-bit piece of the Hash value. (R/W)
PRELIMINARY
Espressif Systems 568 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
21 SHA Accelerator (SHA) GoBack
_n
_M
A
SH
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 569 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
22.1 Overview
The Digital Signature Algorithm (DSA) is used to verify the authenticity and integrity of a message using a
cryptographic algorithm. This can be used to validate a device’s identity to a server or to check the integrity of a
message.
ESP32-H2 includes a Digital Signature Algorithm (DSA) module providing hardware acceleration of messages’
signatures based on RSA. HMAC is used as the key derivation function (KDF) to output the DSA_KEY key using a
key stored in eFuse as the input key. Subsequently, the DSA module uses DSA_KEY to decrypt the
pre-encrypted parameters and calculate the signature. The whole process happens in hardware so that neither
the decryption key for the RSA parameters nor the input key for the HMAC key derivation function can be seen
by users while calculating the signature.
22.2 Features
• RSA digital signatures with key length up to 3072 bits
Private key parameters are stored in flash as ciphertext. They are decrypted using a key (DSA_KEY ) which can
only be calculated by the DSA peripheral via the HMAC peripheral. The required inputs (HM AC_KEY ) to
generate the key are only stored in eFuse and can only be accessed by the HMAC peripheral. That is to say, the
DSA peripheral hardware can decrypt the private key, and the private key in plaintext is never accessed by the
software. For more detailed information about eFuse and HMAC peripherals, please refer to Chapter 5 eFuse
Controller (EFUSE) and Chapter 19 HMAC Accelerator (HMAC).
The input message X will be sent directly to the DSA peripheral by the software each time a signature is needed.
After the RSA signature operation, the signature Z is read back by the software.
For better understanding, we define some symbols and functions here, which are only applicable to this
chapter:
• [x]s : A bit string of s bits, in which s is an integer multiple of 8 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 such as [Y ]4096 or a hexadecimal
constant such as [0x0C]8 . If necessary, the value [x]t can be right-padded with (s − t) number of zeros to
reach s bits in length, and finally get [x]s . For example, [0x05]8 = 00000101, [0x05]16 = 0000010100000000,
[0x0005]16 = 0000000000000101, [0x13]8 = 00010011, [0x13]16 = 0001001100000000,
[0x0013]16 = 0000000000010011.
PRELIMINARY
Espressif Systems 570 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
• ||: A bit string concatenation operator for joining multiple-bit strings into a longer bit string.
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 DSA peripheral in this encrypted format, decrypted by the hardware, and then used
for RSA signature calculation. A detailed description of how to generate C is provided in Section 22.3.3.
The DSA peripheral supports RSA signature calculation Z = X Y mod M , in which the length of operands should
be N = 32 × x where x ∈ {1, 2, 3, . . . , 96}. The bit lengths of arguments Z, X, Y , M , and r should be an
arbitrary value in N , and all of them in a calculation must be of the same length, while the bit length of M ′ should
always be 32. For more detailed information about RSA calculation, please refer to Section 20.3.1 Large-Number
Modular Exponentiation in Chapter 20 RSA Accelerator (RSA).
Note:
1. The software preparation (left side in Figure 22-1) is a one-time operation before any signature is calculated, while
the hardware calculation (right side in Figure 22-1) repeats for every signature calculation.
2. Software preparation requires configuring the clock reset. For more information, please refer to Chapter 7 Reset
and Clock.
PRELIMINARY
Espressif Systems 571 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
Users need to follow the steps shown in the left part of Figure 22-1 to calculate C. Detailed instructions are as
follows:
• Step 1: Prepare operands Y and M whose lengths should meet the requirements in Section 22.3.2.
N
Define [L]32 = 32 (i.e., for RSA 3072, [L]32 == [0x60]32 ). Prepare [HM AC_KEY ]256 and calculate
[DSA_KEY ]256 based on DSA_KEY = HMAC-SHA256 ([HM AC_KEY ]256 , 1256 ). 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 ]3072 , [M ]3072 , and [r]3072 , respectively. This step is only
required for Y , M , and r whose length are less than 3072 bits, since their largest length are 3072 bits.
• Step 5: Build [P ]9600 = ( [Y ]3072 ||[M ]3072 ||[r]3072 ||[Box]384 ), where [Box]384 = (
[M D]256 ||[M ′ ]32 ||[L]32 ||[β]64 ) and [β]64 is a PKCS#7 padding value, i.e., a [0x0808080808080808]64
string composed of 8 bytes (0x80). The purpose of [β]64 is to make the bit length of P a multiple of 128.
• Step 6: Calculate C = [C]9600 = AES-CBC-ENC ([P ]9600 , [DSA_KEY ]256 , [IV ]128 ), where C is the
ciphertext with a length of 1200 bytes. C can also be calculated as C = [C]9600 =
([Yb ]3072 ||[M
c]3072 ||[b d 384 ), where [Yb ]3072 , [M
r]3072 ||[Box] c]3072 , [b d 384 are the four sub-parameters of
r]3072 , [Box]
C, and correspond to the ciphertext of [Y ]3072 , [M ]3072 , [r]3072 , [Box]384 respectively.
The DSA operation at the hardware level can be divided into the following three stages:
The decryption process is the inverse of Step 6 in Figure 22-1. The DSA module will call the AES
accelerator to decrypt C in CBC block mode and get the resulting plaintext. The decryption process can
be represented by P = AES-CBC-DEC (C, DSA_KEY , IV ), where IV (i.e., [IV ]128 ) is defined by the user.
[DSA_KEY ]256 is provided by the HMAC module, derived from HM AC_KEY stored in eFuse.
[DSA_KEY ]256 , as well as [HM AC_KEY ]256 are not readable by users.
With P , the DSA module can derive [Y ]3072 , [M ]3072 , [r]3072 , [M ′ ]32 , [L]32 , MD authentication code, and
the padding value [β]64 . This process is the inverse of Step 5.
The DSA module will perform two checks: MD check and padding check. The padding check is not shown
in Figure 22-1, as it happens at the same time as the MD check.
• MD check: The DSA module calls SHA-256 to calculate the hash value [CALC_M D]256
([CALC_M D]256 is calculated the same way and with same parameters as [M D]256 , see step 4).
Then, [CALC_M D]256 is compared against the MD authentication code [M D]256 from step 4. Only
when the two match does the MD check pass.
PRELIMINARY
Espressif Systems 572 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
• Padding check: The DSA module checks if [β]64 complies with the aforementioned PKCS#7 format.
Only when [β]64 complies with the format does the padding check pass.
The DSA module will only perform subsequent operations if MD check passes. If the padding check fails, a
warning is generated, but it does not affect the subsequent operations.
The DSA module treats X (input by the user) and Y , M , r (decrypted in step 8) as big numbers. With M ′ ,
all operands to perform X Y mod M are in place. The operand length is defined by L only. The DSA
module will calculate the signed result Z by calling RSA to perform Z = X Y mod M .
We assume that the software has called the HMAC peripheral and the HMAC peripheral has calculated
DSA_KEY based on HM AC_KEY .
If the software does not read 0 in DS_QUERY_BUSY_REG after approximately 1 ms, it indicates a problem
with HMAC initialization. In such a case, the software can read register DS_QUERY_KEY_WRONG_REG to
get more information:
• If the software reads 0 in DS_QUERY_KEY_WRONG_REG, it indicates that the HMAC peripheral has
not been called.
4. Configure register: Write the content in the IV block to register DS_IV_m_REG (m: 0 ~ 3). For more
information on the IV block, please refer to Chapter 17 AES Accelerator (AES).
• Write b
ri (i ∈ {0, 1, . . . , 95}) to DS_RB_MEM.
PRELIMINARY
Espressif Systems 573 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
The capacity of DS_Y_MEM, DS_M_MEM, and DS_RB_MEM is 96 words, whereas the capacity of
DS_BOX_MEM is only 12 words. Each word can store one base-b digit. The memory blocks use the
little endian format for storage, i.e., the least significant digit of the operand is in the lowest address.
8. Wait for the operation to be completed: Poll register DS_QUERY_BUSY_REG until the software reads 0.
9. Query check result: Read register DS_QUERY_CHECK_REG and conduct subsequent operations as
illustrated below based on the return value:
• If the value is 0, it indicates that both the 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 will resume directly from Step 11.
• If the value is 2, it indicates that the padding check fails but the MD check passes. Users can continue
to get the signed result Z. But please note that the data does not comply with the aforementioned
PKCS#7 padding format, which may not be what you want.
• If the value is 3, it indicates that both the padding check and MD check fail. In this case, some fatal
errors have occurred and the signed result Z is invalid. The operation will resume directly from Step
11.
10. Read the signed result: Read the signed result Zi (i ∈ {0, 1, . . . , n − 1}), where n = N
32 , from memory
block DS_Z_MEM. The memory block stores Z in little-endian byte order.
11. Exit the operation: Write 1 to DS_SET_FINISH_REG, and then poll DS_QUERY_BUSY_REG until the
software reads 0.
After the operation, all the input/output registers and memory blocks are cleared.
PRELIMINARY
Espressif Systems 574 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
PRELIMINARY
Espressif Systems 575 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 576 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
22.6 Registers
The addresses in this section are relative to Digital Signature Algorithm base address provided in Table 4-2 in
Chapter 4 System and Memory.
)
-3
:0
(m
EG
_R
V _m
_I
DS
31 0
0x000000000 Reset
RT
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
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
PRELIMINARY
Espressif Systems 577 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
SH
NI
FI
d)
T_
ve
SE
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
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
EY
_K
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
PRELIMINARY
Espressif Systems 578 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
22 Digital Signature Algorithm (DSA) GoBack
RO AD
ER _B
R
D_ NG
_M DI
)
ed
DS PAD
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
E
ed
AT
rv
_D
se
DS
(re
31 30 29 0
0 0 0x20200618 Reset
PRELIMINARY
Espressif Systems 579 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
23.1 Introduction
In cryptography, the Elliptic Curve Digital Signature Algorithm (ECDSA) offers a variant of the Digital Signature
Algorithm (DSA) which uses elliptic-curve cryptography.
ESP32-H2’s ECDSA accelerator provides a secure and efficient environment for computing ECDSA signatures. It
offers fast computations while ensuring the confidentiality of the signing process to prevent information leakage.
This makes it a valuable tool for applications that require high-speed cryptographic operations with strong
security guarantees. By using the ECDSA accelerator, users can be confident that their data is being protected
without sacrificing performance.
23.2 Features
ESP32-H2’s ECDSA accelerator supports:
• Two different elliptic curves, namely P-192 and P-256, defined in FIPS 186-3 Spec
• Two hash algorithms for message hash in the ECDSA operation, namely SHA-224 and SHA-256, defined in
FIPS PUB 180-4 Spec
– The prime modulus p, which specifies the size of the finite field over which the elliptic curve is defined.
– The base point G on the curve, which can be used to generate public keys.
– The order n of the curve, which is the number of points on the curve that can be generated by
repeatedly adding G to itself.
– The hash algorithm used to generate a fixed-length hash value from the message being signed.
– The length of the hash value, which determines the size of the signature.
Together, these parameters define the ECDSA domain and are critical for the secure use of ECDSA.
PRELIMINARY
Espressif Systems 580 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
• A private key d is a randomly chosen integer between 1 and n-1. It is essential to use a secure
random number generator to ensure that the private key is truly random and cannot be predicted or
reproduced.
• The private key is used for signature generation. This key must be kept secret and secure.
• Once a private key is chosen, it should be burned into the eFuse OTP in ESP32-H2. (Please refer to
Chapter 5 eFuse Controller (EFUSE)).
• The public key Q is typically represented as a pair of coordinates (Qx, Qy) that can be shared with
others.
2. Calculate the hash of the message e: e is equal to HASH (m), where HASH is a cryptographic hash
function, such as SHA-256.
3. Compute the digest of the message hash z: Let z be the Ln leftmost bits of e, where Ln is the bit length of
the curve order n.
4. Select a random number k, which is chosen between 1 and n-1, where n is the order of the base point on
the elliptic curve.
(b) Calculate r = x mod n. If r is equal to zero, return to the previous step and select a new random value
of k.
(c) Calculate s = k −1 * (z + d ∗ r) mod n. If s is equal to zero, return to step 4 and select a new random
value of k.
PRELIMINARY
Espressif Systems 581 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
2. Calculate the hash of the message e: e is equal to HASH (m), where HASH is a cryptographic hash
function, such as SHA-256.
3. Compute the digest of the message z: Let z be the Ln leftmost bits of e, where Ln is the bit length of the
curve order n.
(a) Verify that r and s are integers between 1 and n-1, where n is the order of the base point on the
elliptic curve. If either r or s is outside of this range, the signature is invalid.
(c) Calculate the point (x1 , y1 ) = u1 ∗ G + u2 ∗ Q, where G is the base point on the elliptic curve, and Q is
the public key associated with the private key used for signature generation.
(d) Verify that r = x1 mod n. If r is not equal to x1 mod n, the signature is invalid.
5. Accept or reject the signature: If the signature is valid, the recipient can accept the message as authentic.
Otherwise, the recipient rejects the message as invalid.
If the signature is valid, the recipient can be confident that the message was not tampered with and that it came
from the expected sender.
Users can choose the working mode for the ECDSA accelerator by configuring the ECDSA_WORK_MODE
according to Table 23-1 below.
Users can select the elliptic curves used by configuring the ECDSA_ECDSA_CURVE according to Table
23-2.
PRELIMINARY
Espressif Systems 582 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
Users can select the SHA algorithms for message hash by configuring the ECDSA_SHA_MODE according to
Table 23-3.
Additionally, users can check the working status of the ECDSA accelerator by inquiring the ECDSA_STATE_REG
register and comparing the return value against the Table 23-4 below.
D[255 : 0] = D[7][31 : 0], D[6][31 : 0], D[5][31 : 0], D[4][31 : 0], D[3][31 : 0], D[2][31 : 0], D[1][31 : 0], D[0][31 : 0]
Writing data means writing data to an ECDSA memory block and using this data as the input to the ECDSA
algorithm. To be specific, writing data to an ECDSA memory block means writing D[n][31 : 0] to the “starting
address of this ECDSA memory block + 4 × n” For a 256-bit long data example:
• ···
Note:
When the data size of 192 bits is used, you need to append 0 after 192 bits of data and write 256 bits of data.
Reading data means reading data from the starting address of an ECDSA memory block and using this data as
the output from the ECDSA algorithm. To be specific, reading data from an ECDSA memory block means
reading D[n][31 : 0] from the “starting address of this ECDSA memory block + 4 × n”. For a 256-bit long data
example:
• ···
Note:
When the data size of 192 bits is used, only use the low 192 bits (6 blocks) of data.
The SHA accelerator can only process message blocks of 512 bits. Thus, all the messages should be padded to
a multiple of 512 bits before the hash operation.
Suppose that the length of the message M is LM bits. Then M shall be padded as introduced below:
2. Second, append LA bits of zeros, where LA is the smallest, non-negative solution to the equation
LM + 1 + LA ≡ 448 mod 512;
3. Last, append the 64-bit block of value equal to the number LM expressed using a binary representation.
For more details, please refer to FIPS PUB 180-4 Spec > Section “Padding the Message”.
The message and its padding must be parsed into N 512-bit message blocks: M (1) , M (2) , …, M (N ) .
For more details about “parsing the message”, please refer to FIPS PUB 180-4 Spec > Section “Parsing the
Message”.
For more information about “message block”, please refer to FIPS PUB 180-4 Spec > Section “Glossary of Terms
and Acronyms”.
PRELIMINARY
Espressif Systems 584 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
ESP32-H2’s ECDSA accelerator has implemented a dynamic access permission mechanism to prevent any
possibility of key theft by tampering with the configuration or accessing the data during the operation.
By implementing this dynamic access permission mechanism, the accesses for ECDSA registers are designed to
vary in different statues. For example, ECDSA_CONF_REG is only available for reading and writing when the
accelerator is in the IDLE status. In this way, the configuration information is protected from reading or writing
when the accelerator is in other statues, such as LOAD, GAIN and BUSY. For details about all ECDSA working
statues, please refer to Table 23-4.
For detailed information about the dynamic access permission of each ECDSA register, please refer to Section
Register Summary.
During the ECDSA operation, the following hardware modules will be occupied by ESP32-H2’s ECDSA
accelerator:
• SHA Accelerator
• RSA Accelerator
• ECC Accelerator
Among them, the SHA accelerator will be released when the ECDSA_SHA_RELEASE_INT is triggered. While, the
RSA accelerator and the ECC accelerator will be occupied during the whole ECDSA operation.
Note:
Hardware occupation is a mechanism to protect multiplexed modules and storage space. When a module is hardware
occupied, the user will fail to:
At the end of the hardware occupation, the occupied module will be automatically reset. In addition, when user performs
a software reset to the master module, all the occupied modules will be reset at the same time.
PRELIMINARY
Espressif Systems 585 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
IDLE
PREP
LOAD
PROC
Signature Yes
GAIN
Generation?
No
POST
The detailed programming procedures of each stage are described in the following sections.
(a) ECDSA_KEY: The value of private key d in ECDSA. To correctly configure the key value in eFuse, user
need to write the key value in KEYn (n = 0 ~ 5), and set the corresponding EFUSE_KEY_PURPOSE_n
as ECDSA_KEY. Please refer to Chapter 5 eFuse Controller (EFUSE) for more detailed configuration
steps.
PRELIMINARY
Espressif Systems 586 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
In the PREP stage, the ECDSA_STATE_REG is BUSY, and the ECDSA accelerator performs preparation.
1. Wait till the PREP stage to end by polling ECDSA_BUSY until it is not BUSY. Then the ECDSA accelerator
will automatically enter the LOAD stage.
1. Provide input z into the ECDSA accelerator using one of the following options:
• ECDSA-SHA interface: generate z from the message. For details, please refer to Section 23.5.1.7.
• Signiture Verification:
• Signiture Generation:
3. Write 1 to ECDSA_LOAD_DONE, indicating the configuration is done. Then the accelerator will
automatically enter the PROC stage.
In the PROC stage, the ECDSA_STATE_REG is BUSY, and the ECDSA accelerator performs ECDSA operation
based on the selected working mode.
1. Wait till the PROC stage to end by polling ECDSA_BUSY until it is not BUSY. Then the ECDSA accelerator
will automatically enter the either the GAIN stage or the POST stage depending on the selected working
mode:
When the Signature Generation mode is selected, the ECDSA accelerator enters the GAIN stage after PROC
stage:
2. Write 1 to ECDSA_GAIN_DONE, indicating the GAIN stage is done. Then the accelerator will automatically
enter the POST stage.
PRELIMINARY
Espressif Systems 587 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
In the POST stage, the ECDSA_STATE_REG is BUSY, and the ECDSA accelerator performs some wrap-up work
of ECDSA operation.
1. Wait till the POST stage to end by polling ECDSA_BUSY until it is not BUSY. Then the ECDSA accelerator
will automatically return to the IDLE stage.
ESP32-H2’s ECDSA accelerator can automatically executes hash operation and generates z based on a direct
input message.
For message hash, ECDSAS accelerator supports SHA algorithms SHA-224 (only valid when P192 is selected as
the elliptic curve) and SHA-256.
2. Parse the message and its padding into message blocks. See details in Section 23.4.2.4.
• If this is the first time to execute this step, write 1 to ECDSA_SHA_START to start the ECDSA SHA
interface;
• If this is not the first time to execute this step2 , write 1 to ECDSA_SHA_CONTINUE to continue the
operation.
• Poll register ECDSA_SHA_BUSY until it’s 0, indicating the interface has completed the operation for
the current message block and now is in the “IDLE” status.
Note:
1. In this step, the software can also write the next message block (to be processed) in register ECDSA_MEM_M, if
any, while the interface starts SHA operation, to save time.
2. You are resuming the ECDSA SHA interface with the previously paused operation.
PRELIMINARY
Espressif Systems 588 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
23.5.3 Interrupts
ESP32-H2’s ECDSA accelerator can generate one interrupt signal ECDSA_INTR and send it to Interrupt
Matrix.
The ECDSA accelerator has two interrupt sources that can generate the ECDSA_INTR interrupt signal:
Note:
For definitions of interrupt, interrupt signal, interrupt source, and their correlations, please refer to Chapter 9 Interrupt Matrix
(INTMTX) > Section 9.2 Interrupt Terminology in ESP32-H2.
PRELIMINARY
Espressif Systems 589 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
PRELIMINARY
Espressif Systems 590 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
To enhance security, ECDSA registers have different read and write permissions in different operating statuses.
The following is the abbreviation and corresponding relationship of each state:
Other abbreviations given in Column Access are explained in Section Access Types for Registers.
Access
Name Description Address
PI PL PG PB
Data Memory See Table 18-1.
Configuration Registers
ECDSA_CONF_REG ECDSA configuration register 0x0004 R/W N/A
ECDSA_START_REG ECDSA start register 0x001C WT N/A
Clock and Reset Register
ECDSA_CLK_REG ECDSA clock gate register 0x0008 R/W N/A
Interrupt Registers
ECDSA_INT_RAW_REG ECDSA interrupt raw register 0x000C RO/WTC/SS
ECDSA_INT_ST_REG ECDSA interrupt status register 0x0010 RO
ECDSA_INT_ENA_REG ECDSA interrupt enable register 0x0014 R/W
ECDSA_INT_CLR_REG ECDSA interrupt clear register 0x0018 WT
Status Registers
ECDSA_STATE_REG ECDSA status register 0x0020 RO
Result Register
ECDSA_RESULT_REG ECDSA result register 0x0024 RO/SS N/A
SHA Registers
ECDSA_SHA_MODE_REG ECDSA controlling SHA register 0x0200 N/A R/W N/A
ECDSA_SHA_START_REG ECDSA controlling SHA register 0x0210 N/A WT N/A
ECDSA_SHA_CONTINUE_REG ECDSA controlling SHA register 0x0214 N/A WT N/A
ECDSA_SHA_BUSY_REG ECDSA controlling SHA status register 0x0218 N/A RO N/A
Version Register
ECDSA_DATE_REG Version control register 0x00FC R/W N/A
PRELIMINARY
Espressif Systems 591 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
23.8 Registers
The addresses in this section are relative to the ECDSA base address provided in Table 4-2 in Chapter 4 System
and Memory.
For how to program reserved fields, please refer to Section Programming Reserved Register Field.
_M E _K
O UR SE Z
W C E_ T_
RK V T
A_ C_ AR SE
DE
DS _EC TW E_
O
EC SA OF AR
D _S TW
EC A F
DS _SO
)
ed
EC SA
v
er
D
s
EC
31 (re 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
PRELIMINARY
Espressif Systems 592 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
T NE
ST _D E
A_ AD ON
AR O
DS _LO _D
EC SA AIN
D _G
d)
ve
EC SA
er
D
s
EC
(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
ECDSA_START Configures whether to start the ECDSA operation. This bit will be self-cleared after
configuration.
0: no effect
1: start the ECDSA operation
(WT)
ECDSA_LOAD_DONE Write 1 to generate a signal indicating the ECDSA accelerator’s LOAD opera-
tion is done. This bit will be self-cleared after configuration. (WT)
ECDSA_GAIN_DONE Write 1 to generate a signal indicating the ECDSA accelerator’s GET operation
is done. This bit will be self-cleared after configuration. (WT)
N
O
E_
RC
O
E_F
AT
G
K_
CL
d)
A_
ve
DS
r
se
EC
(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
PRELIMINARY
Espressif Systems 593 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
_R AW
AW
NT R
_I T_
NE IN
O E_
_D AS
LC LE
CA RE
A_ A_
DS _SH
)
ed
EC SA
rv
se
D
EC
(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
_S T
NT S
T
_I T_
NE IN
O E_
_D AS
LC LE
CA RE
A_ A_
DS _SH
)
ed
EC SA
rv
se
D
EC
(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
PRELIMINARY
Espressif Systems 594 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
_E NA
NA
NT E
_I T_
NE IN
O E_
_D AS
LC LE
CA RE
A_ A_
DS _SH
d)
ve
EC SA
er
D
s
EC
(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
_C LR
LR
NT C
_I T_
NE IN
O E_
_D AS
LC LE
CA RE
A_ A_
DS _SH
)
ed
EC SA
rv
se
D
EC
(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_
ve
DS
r
se
EC
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 595 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
LT
SU
RE
N_
O
TI
RA
PE
_O
d)
ve
A
DS
s er
EC
(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
DE
O
M
A_
SH
)
ed
A_
rv
DS
se
EC
(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
A_
rv
DS
se
EC
(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
ECDSA_SHA_START Write 1 to start the first SHA operation in the ECDSA process. This bit will be
self-cleared after configuration. (WT)
PRELIMINARY
Espressif Systems 596 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
23 Elliptic Curve Digital Signature Algorithm (ECDSA) GoBack
UE
IN
NT
_ CO
HA
_S
d)
ve
A
DS
ser
EC
(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
ECDSA_SHA_CONTINUE Write 1 to start the latter SHA operation in the ECDSA process. This bit
will be self-cleared after configuration. (WT)
SY
BU
A_
SH
d)
A_
e
rv
DS
se
EC
(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
ECDSA_SHA_BUSY Represents the working status of the SHA accelerator in the ECDSA process.
0: IDLE
1: BUSY
(RO)
A_
e
rv
DS
se
EC
(re
31 28 27 0
0 0 0 0 0x2208190 Reset
PRELIMINARY
Espressif Systems 597 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
24.1 Overview
The ESP32-H2 integrates an External Memory Encryption and Decryption module that complies with the
XTS-AES standard algorithm specified in IEEE Std 1619-2007, providing security for users’ application code and
data stored in the external memory (flash). Users can store proprietary firmware and sensitive data (e.g.,
credentials for gaining access to a private network) to the external flash.
24.2 Features
• General XTS-AES algorithm, compliant with IEEE Std 1619-2007
• Encryption and decryption functions jointly enabled/disabled by registers configuration, eFuse parameters,
and boot mode
• Configurable Anti-DPA
PRELIMINARY
Espressif Systems 598 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
The Manual Encryption block can encrypt instructions and data, which will then be written to the external flash as
ciphertext via SPI1.
In the System Registers peripheral (see 15 System Registers), the following three bits in register
HP_SYSTEM_EXTERNAL_DEVICE_ENCRYPT_DECRYPT_CONTROL_REG are relevant to the external memory
encryption and decryption:
• HP_SYSTEM_ENABLE_DOWNLOAD_MANUAL_ENCRYPT
• HP_SYSTEM_ENABLE_DOWNLOAD_G0CB_DECRYPT
• HP_SYSTEM_ENABLE_SPI_MANUAL_ENCRYPT
The XTS_AES module also fetches two parameters from the peripheral eFuse Controller, which are:
EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT and EFUSE_SPI_BOOT_CRYPT_CNT. For detailed information,
please see Chapter 5 eFuse Controller (EFUSE).
24.4.2 Key
The Manual Encryption block and Auto Decryption block share the same Key when implementing the XTS
algorithm. The Key is provided by the eFuse hardware and cannot be accessed by software.
The Key is 256-bit long. The value of the Key is determined by the content in one eFuse block from BLOCK4 ~
BLOCK9. For easier description, we define:
There are two possibilities of how the Key is generated depending on whether BlockA exists or not, as shown in
Table 24-1. In each case, the Key can be uniquely determined.
Notes:
For more information of key purposes, please refer to Table 5-2 Structure in Chapter 5 eFuse Controller
(EFUSE).
PRELIMINARY
Espressif Systems 599 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
• Size: the size of the target memory space, indicating the number of bytes encrypted in one encryption
operation, which supports 16, 32 or 64 bytes.
• Base address: the base_addr of the target memory space. It is a 24-bit physical address, with range of
0x0000_0000 ~ 0x00FF_FFFF. It should be aligned to size, i.e., base_addr%size == 0.
For example, if there are 16 bytes of instruction data need to be encrypted and written to address 0x130 ~ 0x13F
in the external flash, then the target space is 0x130 ~ 0x13F, size is 16 (bytes), and base address is 0x130.
The encryption of any length (must be multiples of 16 bytes) of plaintext instruction/data can be completed
separately in multiple operations, and each operation has its individual target memory space and the relevant
parameters.
For Auto Decryption blocks, these parameters are automatically determined by hardware. For Manual Encryption
blocks, these parameters should be configured by users.
Note:
The “tweak” defined in Section Data units and tweaks of IEEE Std 1619-2007 is a 128-bit non-negative integer
(tweak), which can be generated according to tweak = (base_addr & 0x00FFFF80). The lowest 7 bits and the
highest 97 bits in tweak are always zero.
Actually, the Manual Encryption block does not care where the plaintext comes from, but only where the
ciphertext will be stored. Because of the strict correspondence between plaintext and ciphertext, in order to
better describe how the plaintext is stored in the register block, we assume that the plaintext is stored in the target
memory space in the first place and replaced by ciphertext after encryption. Therefore, the following description
in this section no longer has the concept of “plaintext”, but uses “target memory space” instead.
For example, when the size is 64, all registers in the register block will be used. The mapping between offset and
registers now is shown in Table 24-2.
PRELIMINARY
Espressif Systems 600 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
Note:
Even though the CPU can skip cache and get the encrypted instruction/data directly by reading the external mem-
ory, users can by no means access Key.
If the first bit or the third bit in parameter SPI_BOOT_CRYPT_CNT (3 bits) is set to 1, then the Auto
Decryption block can be enabled. Otherwise, it is not operational.
PRELIMINARY
Espressif Systems 601 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
Note:
• When the Auto Decryption block is enabled, it will automatically decrypt the ciphertext if the CPU reads instruc-
tions/data from the external memory via cache to retrieve the instructions/data. The entire decryption process
does not need software participation and is transparent to the cache. The software can by no means obtain the
decryption Key during the process.
• When the Auto Decryption block is disabled, it does not have any effect on the contents stored in the external
memory, no matter if they are encrypted or not. Therefore, what the CPU reads via cache is the original information
stored in the external memory.
1. Configure XTS_AES:
2. Write plaintext instructions/data to the registers block XTS_AES_PLAIN_n_REG (n: 0-15). For detailed
information, please refer to Section 24.4.4.
Please write data to registers according to your actual needs, and the unused ones could be set to
arbitrary values.
3. Wait for Manual Encryption block to be idle. Poll register XTS_AES_STATE_REG until it reads 0 that
indicates the Manual Encryption block is idle.
5. Wait for the encryption process completion. Poll register XTS_AES_STATE_REG until it reads 2.
Step 1 to 5 are the steps of encrypting plaintext instructions/data with the Manual Encryption block using the
Key.
6. Write 1 to register XTS_AES_RELEASE_REG to grant SPI1 the access to the encrypted ciphertext. After
this, the value of register XTS_AES_STATE_REG will become 3.
7. Call SPI1 to write the ciphertext in the external flash (see Section API Reference - Flash Encrypt in ESP-IDF
Programming Guide).
8. Write 1 to register XTS_AES_DESTROY_REG to destroy the ciphertext. After this, the value of register
XTS_AES_STATE_REG will become 0.
Repeat the above steps according to the amount of plaintext instructions/data that need to be encrypted.
24.6 AntiDPA
DPA (Differential Power Analysis) is a side-channel attack method in cryptography, through which an attacker can
statistically analyze data collected from multiple encryption operations to calculate intermediate values in the
encryption computation. ESP32-H2 XTS_AES supports Anti-DPA to defend against external DPA attacks.
PRELIMINARY
Espressif Systems 602 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
The XTS-AES algorithm can be divided into two steps, according to IEEE Std 1619-2007:
• Step 1: Calculating T value. In this section, we define this step as ”calculating T”.
• Step 2: Calculating Cipher/Plain text. In this section, we define this step as ”calculating D”.
– select_reg = XTS_AES_CRYPT_DPA_SELECT_REGISTER
– reg_d_dpa_en = XTS_AES_CRYPT_CALC_D_DPA_EN
– ef use_dpa_en = EFUSE_CRYPT_DPA_ENABLE
– reg_anti_dpa_level = XTS_AES_CRYPT_SECURITY_LEVEL
– ef use_anti_dpa_level = 3
When Anti_DP A_level equals 0, Anti-DPA is disabled. The higher the value of Anti_DP A_level is, the
stronger the Anti-DPA ability is.
If Anti_DP A_level is not 0, when Anti_DP A_enabled_in_calc_D equals to 1, Anti-DPA is enabled when
XTS-AES algorithm is calculating D.
If Anti_DP A_level is not 0, Anti-DPA is always enabled when the XTS-AES algorithm is calculating T.
Note:
• Even if efuse_dpa_en is set to 1, you can still disable anti-DPA by configuring select_reg = 1 and reg_anti_dpa_level =
0.
• Configuring whether or not to enable Anti-DPA will have an impact on the external storage access bandwidth:
– When Anti-DPA is enabled during the calculation of D, the read and write bandwidth will be reduced by more
than 50% when the Anti-DPA level >= 4.
– When Anti-DPA is disabled during the calculation of D, the read and write bandwidth will be reduced by more
than 50% when the Anti-DPA level >= 6.
PRELIMINARY
Espressif Systems 603 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 604 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
24.8 Registers
The addresses in this section are relative to External Memory Encryption and Decryption base address provided
in Table 4-2 in Chapter 4 System and Memory.
n
N_
AI
PL
S_
AE
S_
XT
31 0
0x000000 Reset
ZE
SI
NE
LI
S_
d )
E
ve
_A
r
se
S
XT
(re
31 1 0
0x00000000 0 Reset
N
O
TI
NA
TI
ES
_D
)
ES
ed
rv
_A
se
S
XT
(re
31 1 0
0x00000000 0 Reset
PRELIMINARY
Espressif Systems 605 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
SS
RE
DD
_A
AL
IC
YS
PH
S_
d)
AE
ve
er
S_
s
XT
(re
31 30 29 0
XTS_AES_PHYSICAL_ADDRESS Configures physical address. Note that its value should be within
the range between 0x0000_0000 and 0x00FF_FFFF). (R/W)
R
N TE
_E IS
PA EG
EL
_D _R
EV
_D CT
_L
LC LE
TY
CA SE
RI
CU
T_ A_
YP _DP
SE
T_
CR T
S_ YP
YP
AE CR
CR
S_ S_
S_
d)
XT _AE
AE
e
rv
S_
se
S
XT
XT
(re
31 5 4 3 2 0
PRELIMINARY
Espressif Systems 606 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
ER
G
IG
TR
S_
d)
E
ve
_A
r
se
S
XT
(re
31 1 0
0x00000000 x Reset
E
AS
LE
RE
S_
d)
E
e
rv
_A
se
S
XT
(re
31 1 0
0x00000000 x Reset
Y
RO
ST
DE
S_
)
ed
AE
rv
S_
se
XT
(re
31 1 0
0x00000000 x Reset
PRELIMINARY
Espressif Systems 607 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
24 External Memory Encryption and Decryption (XTS_AES) GoBack
E
AT
ST
S_
)
ed
AE
rv
S_
se
XT
(re
31 2 1 0
XTS_AES_STATE Represents the status of the Manual Encryption block. 0 (XTS_AES_IDLE): Idle
1 (XTS_AES_BUSY): Busy with encryption
2 (XTS_AES_DONE): Encryption completed, but the encrypted result is not accessible to SPI
3 (XTS_AES_RELEASE): Encrypted result is accessible to SPI
(RO)
TE
DA
S_
)
ed
AE
rv
S_
se
XT
(re
31 30 29 0
0 0 0x20200111 Reset
PRELIMINARY
Espressif Systems 608 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
25.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-H2 has two UART controllers. These
UARTs are compatible with various UART devices, and support Infrared Data Association (IrDA) and RS485
communication.
Each of the two UART controllers 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.
A UART is a character-oriented data link for asynchronous communication between devices. Such
communication does not add clock signals to the data sent. Therefore, in order to communicate successfully, the
transmitter and the receiver must operate at the same baud rate with the same stop bit(s) and parity bit.
A UART data frame usually begins with one start bit, followed by data bits, one parity bit (optional), and one or
more stop bits. UART controllers on ESP32-H2 support various lengths of data bits and stop bits. These
controllers also support software and hardware flow control as well as GDMA for high-speed data transfer. This
allows developers to use multiple UART ports at minimal software cost.
25.2 Features
UART controllers feature:
• 260 x 8 bit RAM, shared by TX FIFOs and RX FIFOs of the UART controller
• Parity bit
• RS485 protocol
• IrDA protocol
• Receive timeout
PRELIMINARY
Espressif Systems 609 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
CLOCK
UART_CLKDIV_REG
UART_SCLK_SEL
UART SCLK DOMAIN
XTAL_CLK
1 CTS ctsn_in
RC_FAST_CLK Clock source Hardware
Divider
PLL_F48M_CLK 0 RTS Flow Control rtsn_out
Receiver
Start_Detect UART_RXD_INV
ffo_wdata 1
wake_up Wakeup_Ctrl
Figure 25-1 shows the basic structure of a UART controller. A UART controller works in four clock domains,
namely APB_CLK, AHB_CLK, UART_SCLK, and UART_FCLK. APB_CLK and AHB_CLK are synchronized but
with different frequencies (APB_CLK is derived from AHB_CLK by division), and likewise UART_SCLK and
UART_FCLK are synchronized but with different frequencies (UART_SCLK is derived from UART_FCLK by
division). UART_FCLK has three clock sources: 48 MHz PLL_F48M_CLK, RC_FAST_CLK, and external crystal
clock XTAL_CLK (for details, please refer to Chapter 7 Reset and Clock), which are selected by configuring
PCR_UARTn_SCLK_SEL. The selected clock source is divided by a divider to generate UART_SCLK clock
signals. The divisor is configured by PCR_UARTn_SCLK_DIV_NUM for the integral part,
PCR_UARTn_SCLK_DIV_A for the denominator of the fractional part, and PCR_UARTn_SCLK_DIV_B for the
numerator of the fractional part. The divisor ranges from 1 ~ 256.
A UART controller can be broken down into two parts according to functions: a transmitter and a receiver.
The transmitter contains a TX FIFO (i.e. Tx_FIFO in Figure 25-1), which buffers data to be sent. Software can
write data to Tx_FIFO via the APB bus, or move data to Tx_FIFO using GDMA. Tx_FIFO_Ctrl controls writing and
reading Tx_FIFO. When Tx_FIFO is not empty, Tx_FSM reads data bits in the data frame via Tx_FIFO_Ctrl, and
converts them into a bitstream. The levels of output bitstream signal txd_out can be inverted by configuring the
UART_TXD_INV field.
PRELIMINARY
Espressif Systems 610 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
The receiver contains an RX FIFO (i.e. Rx_FIFO in Figure 25-1), which buffers data to be processed. The input
bitstream signal rxd_in is transferred to the UART controller, and its level can be inverted by configuring
UART_RXD_INV field. Baudrate_Detect measures the baud rate of input bitstream 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. Software can read data from Rx_FIFO via the
APB bus, or receive data using GDMA.
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 adding special characters to outgoing data and
detecting special characters in incoming data. When a UART controller is in Light-sleep mode (see Chapter 2
Low-power Management (RTC_CNTL) [to be added later] for more details), a wake_up signal can be generated in
four ways and sent to RTC, which then wakes up the ESP32-H2 chip. For more information about wakeup,
please refer to Section 25.4.8.
When the frequency of the UART_SCLK is higher than the frequency needed to generate the baud rate, the UART
Core can be clocked at a lower frequency by the divider, in order to reduce power consumption. The UART
Core’s clock frequency is lower than the PLL_CLK’s frequency, and can be divided by the largest divisor when
higher than the frequency needed to generate the baud rate. The clock for the UART transmitter and the UART
receiver can be controlled independently. To enable the clock for the UART transmitter, UART_TX_SCLK_EN
shall be set; to enable the clock for the UART receiver, UART_RX_SCLK_EN shall be set.
To ensure that the configured register values are synchronized from APB_CLK domain to the UART Core’s clock
domain, please follow the procedures in Section25.5.
• Write 1 to PCR_UARTn_RST_EN.
• Clear PCR_UARTn_RST_EN to 0.
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 GDMA, 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
PRELIMINARY
Espressif Systems 611 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
hardware Rx_FSM, written into RX FIFO, and then stored into RAM via the APB bus or using GDMA. The two
UART controllers share one GDMA channel.
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.
UARTn can access FIFO via register UART_FIFO_REG. You can put data into TX FIFO by writing
UART_RXFIFO_RD_BYTE, and get data in RX FIFO by reading UART_RXFIFO_RD_BYTE.
Before a UART controller sends or receives data, the baud rate should be configured by setting corresponding
registers. The baud rate generator of a UART controller functions by dividing the input clock source. It can divide
the clock source by a fractional amount. The divisor is configured by UART_CLKDIV_SYNC_REG:
UART_CLKDIV for the integral part, and UART_CLKDIV_FRAG for the fractional part. When using the 80 MHz
input clock, the UART controller supports a maximum baud rate of 5 Mbaud.
where INPUT_FREQ is the frequency of UART Core’s source clock. For example, if UART_CLKDIV = 694 and
UART_CLKDIV_FRAG = 7, then the divisor value is
7
694 + = 694.4375
16
When UART_CLKDIV_FRAG is 0, 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 0, the divider is fractional and the output baud rate clock pulses are not
strictly uniform. As shown in Figure 25-2, 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 25-2 below, to make the output timing more uniform:
PRELIMINARY
Espressif Systems 612 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
To support IrDA (see Section 25.4.7 for details), the fractional clock divider for IrDA data transmission generates
clock signals divided by 16 × UART_CLKDIV_SYNC_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.
Automatic baud rate detection (Autobaud) on UARTs is enabled by setting UART_AUTOBAUD_EN. The
Baudrate_Detect module shown in Figure 25-3 filters any noise whose pulse width is shorter than
UART_GLITCH_FILT.
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 positive
edges, and UART_NEGEDGE_MIN_CNT stores the minimum pulse width between two negative edges. These
four fields are read by software to determine the transmitter’s baud rate.
Figure 253. The Timing Diagram of Weak UART Signals Along Negative Edges
1. Normally, to avoid sampling erroneous data along rising or negative edges in metastable state, which
results in the inaccuracy of UART_LOWPULSE_MIN_CNT or UART_HIGHPULSE_MIN_CNT, use a
weighted average of these two values to eliminate errors for 1-bit pulses. In this case, the baud rate is
calculated as follows:
fclk
Buart =
(UART_LOWPULSE_MIN_CNT + UART_HIGHPULSE_MIN_CNT + 2)/2
PRELIMINARY
Espressif Systems 613 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
2. If UART signals are weak along negative edges as shown in Figure 25-3, which leads to an 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 positive edges, use UART_NEGEDGE_MIN_CNT to determine the
transmitter’s baud rate as follows:
fclk
Buart =
(UART_NEGEDGE_MIN_CNT + 1)/2
Figure 25-4 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, or 2 bits long, configured by UART_STOP_BIT_NUM (in RS485 mode turnaround delay may
be added. See details in Section 25.4.6.2). 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 the data received, a UART_PARITY_ERR_INT interrupt
is generated, and the data received will still be stored into RX FIFO. When the receiver detects a data frame error,
a UART_FRM_ERR_INT interrupt is generated, and the 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 enter the Break condition and 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.
The receiver can also detect the Break conditions when the RX data line detects any low logical level for one
NULL character transmission, and a UART_BRK_DET_INT interrupt will be triggered when a Break condition has
been completed.
The receiver can detect the current bus state through the timeout interrupt UART_RXFIFO_TOUT_INT. The
UART_RXFIFO_TOUT_INT interrupt will be triggered when the bus is in the idle state for more than
UART_RX_TOUT_THRHD bit time on current baud rate after the receiver has received at least one byte. You can
use this interrupt to detect whether all the data from the transmitter has been sent.
PRELIMINARY
Espressif Systems 614 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
Figure 25-5 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 cycles.
• The interval between two AT_CMD_CHAR characters is less than UART_RX_GAP_TOUT in the unit of
baud rate cycles.
• The interval between the last AT_CMD_CHAR character and next non-AT_CMD_CHAR character is at least
UART_POST_IDLE_NUM cycles.
Note: Given that the interval between AT_CMD_CHAR characters is less than UART_RX_GAP_TOUT in the unit
of baud rate cycles, the PLL_CLK frequency is suggested not to be lower than 8 MHz.
25.4.6 RS485
The two UART controllers support RS485 communication mode. In this mode differential signals are used to
transmit data, so it can communicate over longer distances at higher bit rates than RS232. RS485 has two-wire
half-duplex and four-wire full-duplex options. UART controllers support two-wire half-duplex transmission and
bus snooping.
As shown in Figure 25-6, in a two-wire multidrop network, an external RS485 transceiver is needed for differential
to single-ended conversion or the other way around. An RS485 transceiver contains a driver and a receiver.
When a UART controller is not in transmitter mode, the connection to the differential line can be broken by
disabling the driver. When DE is 1, the driver is enabled; when DE is 0, the driver is disabled.
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 the data sent by itself.
DE can be controlled by either software or hardware. To reduce the cost of software, in our design DE is
controlled by hardware. As shown in Figure 25-6, DE is connected to dtrn_out of UART (please refer to Section
25.4.9.1 for more details).
PRELIMINARY
Espressif Systems 615 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
By default, the two UART controllers work in receiver mode. When a UART controller is switched from transmitter
mode to receiver mode, the RS485 protocol requires a turnaround delay of one cycle after the stop bit. The
UART transmitter supports adding a turnaround delay of one cycle before the start bit or after the stop bit. When
UART_DL0_EN is set, a turnaround delay of one cycle is added before the start bit; when UART_DL1_EN is set,
a turnaround delay of one cycle is added after the stop bit.
In a two-wire multidrop network, UART controllers support bus snooping if RE of the external RS485 transceiver
is 0. By default, a UART controller is not allowed to transmit and receive data simultaneously. If
UART_RS485TX_RX_EN is set and the external RS485 transceiver is configured as in Figure 25-6, a UART
controller may receive data in transmitter mode and snoop the bus. If UART_RS485RXBY_TX_EN is set, a UART
controller may transmit data in receiver mode.
The two UART controllers can snoop the data sent by themselves. In transmitter mode, when a UART controller
monitors a collision between the data sent and the data received, a UART_RS485_CLASH_INT is generated;
when a UART controller monitors 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.
25.4.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’s 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 25-7, the IrDA
encoder converts a non-return to zero code (NRZ) signal to a return to zero inverted code (RZI) 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 are high.
PRELIMINARY
Espressif Systems 616 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
Figure 257. 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 25-8, IrDA function is enabled by setting UART_IRDA_EN. When UART_IRDA_TX_EN is set to 1, the IrDA
transceiver is enabled to send data and not allowed to receive data; when UART_IRDA_TX_EN is reset to 0, the
IrDA transceiver is enabled to receive data and not allowed to send data.
25.4.8 Wakeup
UART can be set as wake-up source. When a UART controller is in Light-sleep mode, a wake_up signal can be
generated in four ways and be sent to the RTC module, which then wakes up ESP32-H2.
• UART_WK_MODE_SEL = 0: When all the clocks are disabled, the chip can be woken up by reverting RXD
for multiple cycles until the number of positive edges is greater than UART_ACTIVE_THRESHOLD.
• UART_WK_MODE_SEL = 1: UART Core keeps working, so the UART receiver can still receive data and
store the received data in RX FIFO. When the number of data bytes in RX FIFO is greater than
UART_RX_WAKE_UP_THRHD, the chip can be woken up from the Light-sleep mode.
• UART_WK_MODE_SEL = 2: When the UART receiver detects a start bit, the chip will be woken up.
• UART_WK_MODE_SEL = 3: When the UART receiver receives a specific character sequence, the chip will
be woken up. The wakeup characters can be defined by configuring UART_WK_CHAR0,
PRELIMINARY
Espressif Systems 617 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
UART_RXFIFO_CNT
UART_RX_FLOW_THRHD UART_RX_FLOW_EN
rts_int
Comparator 1
rtsn_out
0
UART_SW_RTS UART_RTS_INV
UART_LOOPBACK
1
cts_int ctsn_in
0
DE Control Logic
UART_CTS_INV
UART_SW_DTR
1
dtrn_out
0
UART_DTR_INV
UART_RS485_EN
1
dsrn_in
0
UART_LOOPBACK UART_DSR_INV
PRELIMINARY
Espressif Systems 618 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
Figure 25-9 shows the hardware flow control of a UART controller. Hardware flow control uses output signal
rtsn_out and input signal dsrn_in. Figure 25-10 illustrates how these signals are connected between UART on
ESP32-H2 (hereinafter referred to as IU0) and the external UART (hereinafter referred to as EU0).
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. The output signal rtsn_out can be controlled in two ways.
• Software control: Enter this mode by clearing 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 the
UART_SW_DTR field. When the IU0 transmitter detects an 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 generated by hardware
and used for transmit/receive turnaround. 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 a 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
the data sent matches the data received, it indicates that UART controllers are working properly.
Instead of CTS/RTS lines, software flow control uses XON/XOFF characters to start or stop data transmission.
Such flow control is enabled by setting UART_SW_FLOW_CON_EN to 1.
PRELIMINARY
Espressif Systems 619 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
When using software flow control, hardware automatically detects if there are XON/XOFF characters in the 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 configured by UART_XOFF_CHAR 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 configured by UART_XON_CHAR after the current byte in
transmission.
In full-duplex mode, when the UART receiver receives an XOFF character, the UART transmitter is not allowed to
send any data including XOFF even if the UART receiver receives more data than its threshold. To avoid
deadlocks in software flow control or overflow caused thereby, you can set UART__XON_XOFF_STILL_SEND. In
this way, the UART transmitter can still send an XOFF character when it is not allowed to send any data.
Figure 25-11 shows how data is transferred using GDMA. Before GDMA receives data, software prepares an
inlink. GDMA_INLINK_ADDR_CHn points to the first receive descriptor in the inlink. After
GDMA_INLINK_START_CHn 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 GDMA.
Before GDMA sends data, software prepares an outlink and data to be sent. GDMA_OUTLINK_ADDR_CHn
points to the first transmit descriptor in the outlink. After GDMA_OUTLINK_START_CHn is set, GDMA reads data
from the RAM pointed by outlink. The data is then encoded by the encoder, and sent sequentially by the UART
transmitter.
PRELIMINARY
Espressif Systems 620 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
HCI data packets have separators at the beginning and the end, with data bits in the middle (separators + data
bits + separators). 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 GDMA_OUT_TOTAL_EOF_CHn_INT interrupt is generated. When all
data has been received, a GDMA_IN_SUC_EOF_CHn_INT is generated.
• 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 has sent all NULL characters after all data in TX
FIFO had 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 (i.e. logic 0 for one NULL
character transmission) after stop bits.
• UART_CTS_CHG_INT: Triggered when the receiver detects an edge change of 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 has received at least one byte, and the bus remains
idle for UART_RX_TOUT_THRHD bit time.
PRELIMINARY
Espressif Systems 621 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
• 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 UHCI has sent a series of short packets using always_send.
• UHCI_SEND_S_REG_Q_INT: Triggered when UHCI has sent a series of short packets using single_send.
• UHCI_TX_HUNG_INT: Triggered when UHCI takes too long to read RAM using a GDMA transmit channel.
• UHCI_RX_HUNG_INT: Triggered when UHCI takes too long to receive data using a GDMA receive channel.
UART configuration registers can be classified into two groups. One group of registers are read in APB_CLK or
AHB_CLK domains, so once such registers are configured no extra operations are required. The other group of
registers are read in the UART Core’s clock domain, and therefore need to implement the clock domain crossing
design. Once these registers are configured, the configured values need to be synchronized to the UART Core’s
clock domain by writing to UART_REG_UPDATE. Once all values have been synchronized, UART_REG_UPDATE
will be automatically cleared by hardware. After configuring registers that need synchronization, it is
recommended to check whether UART_REG_UPDATE is 0. This is to ensure that register values configured
before have already been synchronized.
To distinguish between these two groups of registers easily, all registers that implement the clock domain
crossing design have the _SYNC suffix, and are put together in Section 25.6. Those without the _SYNC suffix in
Section 25.6 are configuration registers that require no clock domain crossing.
PRELIMINARY
Espressif Systems 622 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
To initialize UARTn:
• Write 1 to PCR_UARTn_RST_EN.
• Clear PCR_UARTn_RST_EN to 0.
• Wait for UART_REG_UPDATE to become 0, which indicates the completion of the last synchronization.
• Configure the baud rate for transmission via UART_CLKDIV and UART_CLKDIV_FRAG.
• Synchronize the configured values to the Core Clock domain by writing 1 to UART_REG_UPDATE.
PRELIMINARY
Espressif Systems 623 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
• Read data from RX FIFO via UART_RXFIFO_RD_BYTE, and obtain the number of bytes received in RX FIFO
via UART_RXFIFO_CNT.
PRELIMINARY
Espressif Systems 624 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
PRELIMINARY
Espressif Systems 625 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
PRELIMINARY
Espressif Systems 626 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
PRELIMINARY
Espressif Systems 627 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
25.7 Registers
25.7.1 UART Registers
The addresses in this section are relative to UART Controller base address provided in Table 4-2 in Chapter 4
System and Memory.
E
YT
B
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 0 Reset
D
RH
N
H
_E
_T
UT
UT
TO
O
_T
X_
X
)
RT d)
ed
_R
_R
UA rve
rv
RT
se
se
UA
(re
(re
31 12 11 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0xa 0 0 Reset
UART_RX_TOUT_THRHD Configures the amount of time that the bus can remain idle before timeout.
Measurement unit: bit time (the time to transmit 1 bit). (R/W)
PRELIMINARY
Espressif Systems 628 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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 1 0 Reset
PRELIMINARY
Espressif Systems 629 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
PRELIMINARY
Espressif Systems 630 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
PRELIMINARY
Espressif Systems 631 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
PRELIMINARY
Espressif Systems 632 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
PRELIMINARY
Espressif Systems 633 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
AG
FR
_
IV
IV
D
KD
LK
CL
)
)
ed
ed
_C
T_
rv
rv
RT
se
se
R
UA
UA
(re
(re
31 24 23 20 19 12 11 0
UART_CLKDIV Configures the integral part of the divisor for baud rate generation. (R/W)
UART_CLKDIV_FRAG Configures the fractional part of the divisor for baud rate generation. (R/W)
_EN
LT
LT
FI
FI
_
H_
CH
TC
T
LI
LI
)
ed
_G
_G
rv
RT
RT
se
UA
UA
(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 0x8 Reset
PRELIMINARY
Espressif Systems 634 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
VF
UA T_R D_I DA SK
M
UA T_T _R _M N
R X NV T_O
R R BA EN
NU
R IS R _E
R RD BA N
R X X_ A
R RD TX V
R RD W V
R E TS T
UA TXD DP N
R W O_ T
UA T_I OP _E
UA T_I A_ CTL
UA T_I A_ _IN
UA T_I A_ CK
UA T_D R_W UD
UA T_I A_ _IN
UA T_E TO K_
_B LX
UA T_M _R RS
IT EN
T_
UA _S IF S
_ A_ E
R O OW
RT XF _R
RT RD TX_
TO K
M
R U CL
R X EN
BI
R RD NV
R RD RX
AR _
R
NU
_ P ITY
Y
UA T_R FIFO
P_
UA T_A M_
UA T_T A_
UA T_L _FL
UA T_I D_I
RT AR
IT
)
R X
ed
_B
_S
UA _P
UA T_T
rv
RT
RT
RT
se
R
UA
UA
UA
(re
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3 0 0 Reset
UART_TXD_BRK Configures whether or not to send NULL characters when finishing data transmis-
sion.
0: Not send
1: Send
(R/W)
UART_IRDA_TX_INV Configures whether or not to invert the level of the IrDA transmitter.
0: Not invert
1: Invert
(R/W)
UART_IRDA_RX_INV Configures whether or not to invert the level of the IrDA receiver.
0: Not invert
1: Invert
(R/W)
UART_TX_FLOW_EN Configures whether or not to enable flow control for the transmitter.
0: Disable
1: Enable
(R/W)
UART_RXD_INV Configures whether or not to invert the level of UART RXD signal.
0: Not invert
1: Invert
(R/W)
UART_TXD_INV Configures whether or not to invert the level of UART TXD signal.
0: Not invert
1: Invert
(R/W)
UART_DIS_RX_DAT_OVF Configures whether or not to disable data overflow detection for the UART
receiver.
0: Enable
1: Disable
(R/W)
UART_ERR_WR_MASK Configures whether or not to store the received data with errors into FIFO.
0: Store
1: Not store
(R/W)
UART_MEM_CLK_EN Configures whether or not to enable clock gating for UART memory.
0: Disable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 637 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
D
RH
D
RH
TH
TH
Y_
L_
PT
UL
M
_F
_E
TS NV
R T TR
R T NV
NV
RT SR NV
R W N
FO
O
UA T_S K_E
UA T_D _D
_C _I
UA T_R R_I
_I
UA T_D S_I
IF
FI
XF
R L
RX
d)
UA T_C
_T
ve
T_
RT
er
R
s
UA
UA
UA
(re
31 22 21 20 19 18 17 16 15 8 7 0
UART_CTS_INV Configures whether or not to invert the level of UART CTS signal.
0: Not invert
1: Invert
(R/W)
UART_DSR_INV Configures whether or not to invert the level of UART DSR signal.
0: Not invert
1: Invert
(R/W)
UART_RTS_INV Configures whether or not to invert the level of UART RTS signal.
0: Not invert
1: Invert
(R/W)
UART_DTR_INV Configures whether or not to invert the level of UART DTR signal.
0: Not invert
1: Invert
(R/W)
PRELIMINARY
Espressif Systems 638 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
HD
HR
N
_E
_T
W
W
O
LO
FL
_F
X_
RX
d)
_R
ve
T_
RT
er
R
s
UA
UA
(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
UART_RX_FLOW_THRHD Configures the maximum number of data bytes that can be received dur-
ing hardware flow control.
Measurement unit: byte. (R/W)
1
AR
AR
AR
AR
CH
CH
CH
CH
K_
K_
K_
K_
_W
_W
_W
_W
RT
RT
RT
RT
UA
UA
UA
UA
31 24 23 16 15 8 7 0
W
e
T_
rv
se
R
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
PRELIMINARY
Espressif Systems 639 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
HD
LD
HR
HO
K
_T
AS
L
ES
U
E
UP
M
_S
_N
HR
R_
E_
DE
AR
_T
A
AK
O
CH
CH
VE
M
_W
TI
K_
K_
K_
AC
RX
d)
_W
_W
W
ve
T_
T_
T_
RT
RT
er
R
s
UA
UA
UA
UA
UA
(re
31 28 27 26 25 21 20 18 17 10 9 0
UART_ACTIVE_THRESHOLD Configures the number of RXD edge changes to wake up the chip in
wakeup mode 0. (R/W)
UART_RX_WAKE_UP_THRHD Configures the number of received data bytes to wake up the chip
in wakeup mode 1. (R/W)
PRELIMINARY
Espressif Systems 640 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
D
EN
TI N
_S
_S _E
LL
FF ON
O O L
R O E_ FF
XO _C
RT W FF_ N
_X _FL DE
R
R O _X F
AR
UA T_F RC ON
UA T_X RC XO
UA T_S NO XO
UA T_F ND OF
HA
N_ W
CH
R O E_
R E _X
_C
UA T_S ND
N_
FF
O
XO
R E
d)
UA T_S
_X
ve
T_
RT
er
R
s
UA
UA
UA
(re
31 23 22 21 20 19 18 17 16 15 8 7 0
UART_XON_XOFF_STILL_SEND Configures whether the UART transmitter can send XON or XOFF
characters when it is disabled.
0: Cannot send
1: Can send
(R/W)
UART_XONOFF_DEL Configures whether or not to remove flow control characters from the received
data.
0: Not remove
1: Remove
(R/W)
UART_FORCE_XOFF Configures whether or not to stop the transmitter from sending data.
0: Not stop
1: Stop
(R/W)
PRELIMINARY
Espressif Systems 641 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
LD
LD
O
HO
SH
S
E
RE
HR
TH
_T
N_
FF
O
XO
d)
_X
ve
T_
RT
er
R
s
UA
UA
(re
31 16 15 8 7 0
UART_XON_THRESHOLD Configures the threshold for data in RX FIFO to send XON characters in
software flow control.
Measurement unit: byte. (R/W)
UART_XOFF_THRESHOLD Configures the threshold for data in RX FIFO to send XOFF characters
in software flow control.
Measurement unit: byte. (R/W)
UM
_N
RK
_B
d)
X
_T
ve
RT
r
se
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 0xa Reset
UART_TX_BRK_NUM Configures the number of NULL characters to be sent after finishing data trans-
mission.
Valid only when UART_TXD_BRK is 1. (R/W)
HR
NU
_T
E_
LE
DL
D
_I
_I
RX
d)
X
_T
e
T_
rv
RT
se
R
UA
UA
(re
31 20 19 10 9 0
UART_RX_IDLE_THRHD Configures the threshold to generate a frame end signal when the receiver
takes more time to receive one byte data.
Measurement unit: bit time (the time to transmit 1 bit). (R/W)
PRELIMINARY
Espressif Systems 642 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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 0 0 0 0 0 0 0 Reset
UART_DL0_EN Configures whether or not to add a turnaround delay of 1 bit before the start bit.
0: Not add
1: Add
(R/W)
UART_DL1_EN Configures whether or not to add a turnaround delay of 1 bit after the stop bit.
0: Not add
1: Add
(R/W)
UART_RS485TX_RX_EN Configures whether or not to enable the receiver for data reception when
the transmitter is transmitting data in RS485 mode.
0: Disable
1: Enable
(R/W)
UART_RS485RXBY_TX_EN Configures whether or not to enable the RS485 transmitter for data
transmission when the RS485 receiver is busy.
0: Disable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 643 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
RT X_ T_ RE
X_ LK RE
LK N
N
UA T_R _RS _CO
_T SC CO
SC _E
_E
R X T
UA _T RS
RT X_
)
)
ed
ed
UA T_R
rv
rv
se
se
R
UA
(re
(re
31 28 27 26 25 24 23 0
0 0 0 0 0 0 1 1 0 Reset
NT
NT
_C
_C
FO
O
N
N
_D N
_D N
IF
FI
SR
RT XD
TR
RT TS
RT TS
UA T_R D
XF
X
)
)
R X
ed
ed
UA _C
UA T_R
_R
UA T_T
_T
rv
rv
RT
RT
se
se
R
R
UA
UA
UA
UA
(re
(re
31 30 29 28 24 23 16 15 14 13 12 8 7 0
1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 Reset
UART_DSRN Represents the level of the internal UART DSR signal. (RO)
UART_CTSN Represents the level of the internal UART CTS signal. (RO)
UART_RXD Represents the level of the internal UART RXD signal. (RO)
UART_DTRN Represents the level of the internal UART DTR signal. (RO)
UART_RTSN Represents the level of the internal UART RTS signal. (RO)
UART_TXD Represents the level of the internal UART TXD signal. (RO)
PRELIMINARY
Espressif Systems 644 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
DR
DR
AD
AD
_W
_R
AM
M
RA
SR
_S
X_
)
TX
ed
ed
_T
T_
rv
rv
RT
se
se
R
UA
UA
(re
(re
31 17 16 9 8 7 0
DR
DR
AD
AD
_W
_R
AM
M
RA
SR
_S
X_
X
)
)
ed
ed
_R
_R
rv
rv
RT
RT
se
se
UA
UA
(re
(re
31 17 16 9 8 7 0
UT
UT
O
O
X_
X_
UR
UT
T_
T_
)
ed
_S
_S
rv
RT
RT
se
UA
UA
(re
31 8 7 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 645 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
X_ IFO U Y
_F TY
_T AF _F PT
AF _ LL
L
O P
UL
RT X_ IFO M
IF EM
UA T_T _AF O_E
R X IF
UA T_R _AF
R X
d)
UA T_R
ve
er
R
s
UA
(re
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 Reset
_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 Configures the idle time before the receiver receives the first AT_CMD.
Measurement unit: bit time (the time to transmit 1 bit). (R/W)
PRELIMINARY
Espressif Systems 646 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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 Configures the interval between the last AT_CMD and subsequent data.
Measurement unit: bit time (the time to transmit 1 bit). (R/W)
UT
O
_T
AP
_G
X
)
d
_R
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 11 Reset
AR
CH
M
NU
D_
R_
CM
HA
T_
)
ed
_C
_A
rv
RT
RT
se
UA
UA
(re
31 16 15 8 7 0
UART_CHAR_NUM Configures the number of continuous AT_CMD characters a receiver can receive.
(R/W)
PRELIMINARY
Espressif Systems 647 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
NT
_C
IN
M
E_
DG
SE
PO
d)
ve
T_
er
R
s
UA
(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 0xfff Reset
UART_POSEDGE_MIN_CNT Represents the minimal input clock counter value between two positive
edges. It is used for baud rate detection. (RO)
T
_ CN
IN
M
E_
G
ED
G
E
d)
_N
ve
RT
r
se
UA
(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 0xfff Reset
UART_NEGEDGE_MIN_CNT Represents the minimal input clock counter value between two nega-
tive edges. It is used for baud rate detection. (RO)
_L
rv
RT
se
UA
(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 0xfff Reset
PRELIMINARY
Espressif Systems 648 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
NT
_C
IN
M
E_
S
UL
HP
G
)
ed
HI
T_
rv
se
R
UA
(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 0xfff Reset
T
CN
E_
DG
_E
XD
d)
_R
ve
RT
r
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 0x0 Reset
UART_RXD_EDGE_CNT Represents the number of RXD edge changes. It is used for baud rate
detection. (RO)
31 0
0x2201260 Reset
PRELIMINARY
Espressif Systems 649 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
TE
DA
P
_U
G
RE
d)
ve
T_
er
R
s
UA
(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
31 0
0x000500 Reset
PRELIMINARY
Espressif Systems 650 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
EN
F_
se EP EN N EN
O
C R ID N N
UH _C T_ _E _E
C EA E EO
CI NC N RK
CI AR OF C R
UH I_U _E _C
UH I_R T0 E
_T RS E
C AR _C
CI X_ _C
C LK RX
C d) _E
C EN E
X_ T
T
UH _L OD
UH rve ER
UH _U T1
UH I_C T_
RS
C AR
CI AR
)
ed
UH I_U
UH I_U
rv
se
C
UH
(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 0 1 1 0 1 1 1 0 0 0 0 0 Reset
UHCI_TX_RST Write 1 and then write 0 to reset the decoder state machine. (R/W)
UHCI_RX_RST Write 1 and then write 0 to reset the encoder state machine. (R/W)
UHCI_SEPER_EN Configures whether or not to separate the data frame with a special character.
0: Not separate
1: Separate
(R/W)
UHCI_HEAD_EN Configures whether or not to encode the data packet with a formatting header.
0: Not use formatting header
1: Use formatting header
(R/W)
UHCI_CRC_REC_EN Configures whether or not to enable the reception of the 16-bit CRC.
0: Disable
1: Enable
(R/W)
UHCI_UART_IDLE_EOF_EN Configures whether or not to stop receiving data when UART is idle.
0: Not stop
1: Stop
(R/W)
PRELIMINARY
Espressif Systems 651 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
UHCI_UART_RX_BRK_EOF_EN Configures whether or not to stop UHCI from receiving data after
UART has received a NULL frame.
0: Not stop
1: Stop
(R/W)
PRELIMINARY
Espressif Systems 652 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
E
_R
UH I_C E_ K_ _RE
RT
N
UH I_C C_D AD M
UM N
_E
_S _E
C R HE SU
TA
HE K_ LE
C AV EC M
CK EQ
UH I_S CH NU
_S
_C C B
UH rve IT_ RT
CI HE ISA
S
C d) SW
C _ _
se A A
K
(re _W ST
UH _T C
CI X_A
CI W_
d)
X
UH I_S
ve
UH I_T
er
C
s
UH
(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 1 1 0 0 1 1 Reset
UHCI_CHECK_SEQ_EN Configures whether or not to enable the sequence number check when
UHCI receives a data packet.
0: Disable
1: Enable
(R/W)
UHCI_SAVE_HEAD Configures whether or not to save the packet header when UHCI receives a data
packet.
0: Not save
1: Save
(R/W)
UHCI_TX_CHECK_SUM_RE Configures whether or not to encode the data packet with a checksum.
0: Not use checksum
1: Use checksum
(R/W)
UHCI_TX_ACK_NUM_RE Configures whether or not to encode the data packet with an acknowl-
edgment when a reliable packet is to be transmitted.
0: Not use acknowledgement
1: Use acknowledgement
(R/W)
PRELIMINARY
Espressif Systems 653 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
UHCI_WAIT_SW_START Configures whether or not to put the UHCI encoder state machine to
ST_SW_WAIT state.
0: No
1: Yes
(R/W)
UHCI_SW_START Configures whether or not to send data packets when the encoder state machine
is in ST_SW_WAIT state.
0: Not send
1: Send
(R/W/SC)
PRELIMINARY
Espressif Systems 654 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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 Configures whether or not to decode character 0xC0 when DMA receives
data.
0: Not decode
1: Decode
(R/W)
UHCI_TX_DB_ESC_EN Configures whether or not to decode character 0xDB when DMA receives
data.
0: Not decode
1: Decode
(R/W)
UHCI_TX_11_ESC_EN Configures whether or not to decode flow control character 0x11 when DMA
receives data.
0: Not decode
1: Decode
(R/W)
UHCI_TX_13_ESC_EN Configures whether or not to decode flow control character 0x13 when DMA
receives data.
0: Not decode
1: Decode
(R/W)
UHCI_RX_C0_ESC_EN Configures whether or not to replace 0xC0 by special characters when DMA
sends data.
0: Not replace
1: Replace
(R/W)
UHCI_RX_DB_ESC_EN Configures whether or not to replace 0xDB by special characters when DMA
sends data.
0: Not replace
1: Replace
(R/W)
PRELIMINARY
Espressif Systems 655 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
UHCI_RX_11_ESC_EN Configures whether or not to replace flow control character 0x11 by special
characters when DMA sends data.
0: Not replace
1: Replace
(R/W)
UHCI_RX_13_ESC_EN Configures whether or not to replace flow control character 0x13 by special
characters when DMA sends data.
0: Not replace
1: Replace
(R/W)
PRELIMINARY
Espressif Systems 656 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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_SHIFT Configures the upper limit of the timeout counter for TX FIFO. (R/W)
UHCI_TXFIFO_TIMEOUT_ENA Configures whether or not to enable the data reception timeout for
TX FIFO.
0: Disable
1: Enable
(R/W)
UHCI_RXFIFO_TIMEOUT Configures the timeout value for DMA to read data from RAM.
Measurement unit: ms. (R/W)
UHCI_RXFIFO_TIMEOUT_SHIFT Configures the upper limit of the timeout counter for RX FIFO.
(R/W)
PRELIMINARY
Espressif Systems 657 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
AD
O
_L
M
UM
NU
_N
K_
CK
d)
AC
_A
ve
_
er
CI
CI
s
UH
UH
(re
31 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0x0 Reset
UHCI_ACK_NUM Configures the number of acknowledgements used in software flow control. (R/W)
PRELIMINARY
Espressif Systems 658 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
PRELIMINARY
Espressif Systems 659 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
PRELIMINARY
Espressif Systems 660 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
PRELIMINARY
Espressif Systems 661 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
PRELIMINARY
Espressif Systems 662 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
PRELIMINARY
Espressif Systems 663 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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
0
AR
AR
H
CH
_C
AR
C_
SC
CH
ES
_E
R_
R_
ER
PE
PE
EP
d)
SE
_S
_S
e
rv
I_
CI
CI
se
C
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_SEPER_CHAR Configures separators to encode data packets. The default value is 0xC0.
(R/W)
UHCI_SEPER_ESC_CHAR0 Configures the first character of SLIP escape sequence. The default
value is 0xDB. (R/W)
UHCI_SEPER_ESC_CHAR1 Configures the second character of SLIP escape sequence. The default
value is 0xDC. (R/W)
PRELIMINARY
Espressif Systems 664 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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 Configures the character that needs to be encoded. The default value is 0xDB
used as the first character of SLIP escape sequence. (R/W)
UHCI_ESC_SEQ0_CHAR0 Configures the first character of SLIP escape sequence. The default value
is 0xDB. (R/W)
UHCI_ESC_SEQ0_CHAR1 Configures the second character of SLIP escape sequence. 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 Configures a character that need to be encoded. The default value is 0x11 used
as a flow control character. (R/W)
UHCI_ESC_SEQ1_CHAR0 Configures the first character of SLIP escape sequence. The default value
is 0xDB. (R/W)
UHCI_ESC_SEQ1_CHAR1 Configures the second character of SLIP escape sequence. The default
value is 0xDE. (R/W)
PRELIMINARY
Espressif Systems 665 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
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 Configures the character that needs to be decoded. The default value is 0x13
used as a flow control character. (R/W)
UHCI_ESC_SEQ2_CHAR0 Configures the first character of SLIP escape sequence. The default value
is 0xDB. (R/W)
UHCI_ESC_SEQ2_CHAR1 Configures the second character of SLIP escape sequence. 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
PRELIMINARY
Espressif Systems 666 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
W
C X_ NG G IN T_
X_ AR INT AW RA
UH I_R HU RE _Q_ _IN
UH I_S D_ _E T_ W
UH I_T D_ RE _ER W
_R T _ R _
W
T_ W
AR IN AW
C EN K _IN RA
C EN A_ OF RA
C X_ S_ G R
RA
IN A
UH I_S TLIN L0 T_
T_ _R
ST T_ _R
C U TR _IN
T
UH I_O _C L1
C PP TR
UH I_A _C
C PP
d)
UH I_A
ve
er
C
s
UH
(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
PRELIMINARY
Espressif Systems 667 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
_R T _ S _
C EN K _IN ST
C EN A_ OF ST
C X_ S_ G R
ST
IN T
AR IN T
UH I_T D_ RE _ER
UH I_S TLIN L0 T_
UH I_S D_ _E T_
T_ T_S
ST T_ _S
T_
C U TR _IN
UH I_O _C L1
C PP TR
UH I_A _C
C PP
d)
UH I_A
ve
er
C
s
UH
(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
PRELIMINARY
Espressif Systems 668 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
A
C X_ NG G IN T_
X_ AR INT NA EN
UH I_R HU RE _Q_ _IN
_R T _ E _
UH I_S D_ _E T_ A
UH I_T D_ RE _ER A
C EN K _IN EN
C EN A_ OF EN
A
T_ A
AR IN NA
C X_ S_ G R
EN
IN N
UH I_S TLIN L0 T_
T_ _E
ST T_ _E
C U TR _IN
T
UH I_O _C L1
C PP TR
UH I_A _C
C PP
d)
UH I_A
ve
er
C
s
UH
(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
PRELIMINARY
Espressif Systems 669 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
R
C X_ NG G IN T_
X_ AR INT LR CL
UH I_R HU RE _Q_ _IN
_R T _ C _
UH I_S D_ _E T_ R
UH I_T D_ RE _ER R
C EN K _IN CL
C EN A_ OF CL
R
IN LR
AR IN LR
C X_ S_ G R
CL
UH I_S TLIN L0 T_
T_ _C
ST T_ _C
T_
C U TR _IN
T
UH I_O _C L1
C PP TR
UH _A _C
CI PP
d)
UH I_A
ve
er
C
s
UH
(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
PRELIMINARY
Espressif Systems 670 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
SE
E
AT
AU
ST
C
_
R_
DE
ER
CO
X_
)
DE
ed
_R
rv
_
CI
CI
se
UH
UH
(re
31 6 5 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UHCI_RX_ERR_CAUSE Represents the error type when DMA has received a packet with error.
0: Invalid. No effect
1: Checksum error in the HCI packet
2: Sequence number error in the HCI packet
3: CRC bit error in the HCI packet
4: 0xC0 is found but the received HCI packet is not complete
5: 0xC0 is not found when the HCI packet has been received
6: CRC check error
7: Invalid. No effect
(RO)
TE
TA
_S
DE
CO
)
N
ed
_E
rv
CI
se
UH
(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
31 0
0x000000 Reset
PRELIMINARY
Espressif Systems 671 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
25 UART Controller (UART) GoBack
E
AT
_D
CI
UH
31 0
0x2007170 Reset
PRELIMINARY
Espressif Systems 672 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
26.1 Overview
The Serial Peripheral Interface (SPI) is a synchronous serial interface useful for communication with external
peripherals. The ESP32-H2 chip integrates three SPI controllers:
• SPI0,
• SPI1,
SPI0 and SPI1 controllers (MSPI) are primarily reserved for internal use to communicate with external flash and
PSRAM memory. This chapter mainly focuses on the GP-SPI2 controller.
26.2 Glossary
To better illustrate the functions of GP-SPI2, the following terms are used in this chapter.
Master Mode GP-SPI2 acts as an SPI master and initiates SPI transactions.
Slave Mode GP-SPI2 acts as an SPI slave and exchanges data with its master
when its CS is asserted.
MISO Master in, slave out, data transmission from a slave to a master.
MOSI Master out, slave in, data transmission from a master to a slave
Transaction One instance of a master asserting a CS line, transferring data to
and from a slave, and de-asserting the CS line. Transactions are
atomic, which means they can never be interrupted by another
transaction.
SPI Transfer The whole process of an SPI master exchanging data with a slave.
One SPI transfer consists of one or more SPI transactions.
Single Transfer An SPI transfer that consists of only one transaction.
CPUControlled Transfer A data transfer that happens between CPU buffer SPI_W0_REG ~
SPI_W15_REG and SPI peripheral.
DMAControlled Transfer A data transfer that happens between DMA and SPI peripheral,
controlled by the DMA engine.
Configurable Segmented Transfer A data transfer controlled by DMA in SPI master mode. Such trans-
fer consists of multiple transactions (segments), and each transac-
tion can be configured independently.
Slave Segmented Transfer A data transfer controlled by DMA in SPI slave mode. Such transfer
consists of multiple transactions (segments).
Fullduplex The sending line and receiving line between the master and the
slave are independent. Sending data and receiving data happen
at the same time.
Halfduplex Only one side, the master or the slave, sends data, and the other
side receives data. Sending data and receiving data can not happen
simultaneously on one side.
4line fullduplex 4-line here means: clock line, CS line, and two data lines. The two
data lines can be used to send or receive data simultaneously.
PRELIMINARY
Espressif Systems 673 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
4line halfduplex 4-line here means: clock line, CS line, and two data lines. The two
data lines can not be used simultaneously.
3line halfduplex 3-line here means: clock line, CS line, and one data line. The data
line is used to transmit or receive data.
1bit SPI In one clock cycle, one bit can be transferred.
(2bit) Dual SPI In one clock cycle, two bits can be transferred.
Dual Output Read A data mode of Dual SPI. In one clock cycle, one bit of a command,
or one bit of an address, or two bits of data can be transferred.
Dual I/O Read Another data mode of Dual SPI. In one clock cycle, one bit of a
command, or two bits of an address, or two bits of data can be
transferred.
(4bit) Quad SPI In one clock cycle, four bits can be transferred.
Quad Output Read A data mode of Quad SPI. In one clock cycle, one bit of a command,
or one bit of an address, or four bits of data can be transferred.
Quad I/O Read Another data mode of Quad SPI. In one clock cycle, one bit of a
command, or four bits of an address, or four bits of data can be
transferred.
QPI In one clock cycle, four bits of a command, or four bits of an ad-
dress, or four bits of data can be transferred.
FSPI Fast SPI. The prefix of the signals for GP-SPI2. FSPI bus signals
are routed to GPIO pins via either GPIO matrix or IO MUX.
26.3 Features
Some of the key features of GP-SPI2 are:
– QPI mode
– Master: up to 48 MHz
– Slave: up to 32 MHz
PRELIMINARY
Espressif Systems 674 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
• Able to communicate with SPI devices, such as a sensor, a screen controller, as well as a flash or RAM chip
Figure 26-1 shows an overview of SPI module. GP-SPI2 exchanges data with SPI devices by the following
ways:
The signals for GP-SPI2 are prefixed with “FSPI” (Fast SPI). FSPI bus signals are routed to GPIO pins via either
GPIO matrix or IO MUX. For more information, see Chapter 6 IO MUX and GPIO Matrix (GPIO, IO MUX).
PRELIMINARY
Espressif Systems 675 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
For more information about the data modes used when GP-SPI2 works as a master or a slave, see Section
26.5.8 and Section 26.5.9, respectively.
PRELIMINARY
Espressif Systems 676 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
Master Slave
FSPI Signal 1bit SPI 1bit SPI
1 2
2bit Dual SPI 4bit Quad SPI QPI 2bit Dual SPI 4bit Quad SPI QPI
FD 3line HD 4line HD FD 3line HD 4line HD
FSPICLK Y Y Y Y Y Y Y Y Y Y Y Y
FSPICS0 Y Y Y Y Y Y Y Y Y Y Y Y
FSPICS1 Y Y Y Y Y Y
FSPICS2 Y Y Y Y Y Y
FSPICS3 Y Y Y Y Y Y
FSPICS4 Y Y Y Y Y Y
FSPICS5 Y Y Y Y Y Y
Submit Documentation Feedback
3 4 5
FSPID Y Y (Y) Y Y Y Y Y (Y)6 Y7 Y8 Y
3 4 5 6 7 8
FSPIQ Y (Y) Y Y Y Y (Y) Y Y Y
FSPIWP Y5 Y Y8 Y
677
FSPIHD Y5 Y Y8 Y
1
FD: full-duplex
2
HD: half-duplex
3
Only one of the two signals is used at a time.
4
The two signals are used in parallel.
5
The four signals are used in parallel.
6
Only one of the two signals is used at a time.
ESP32-H2 TRM (Pre-release v0.4)
7
The two signals are used in parallel.
8
The four signals are used in parallel.
PRELIMINARY
GoBack
26 SPI Controller (SPI) GoBack
• The bit order of the command, address, and data sent by the GP-SPI2 master is controlled by
SPI_WR_BIT_ORDER.
• The bit order of the data received by the master is controlled by SPI_RD_BIT_ORDER.
• The bit order of the data sent by the GP-SPI2 slave is controlled by SPI_WR_BIT_ORDER.
• The bit order of the command, address, and data received by the slave is controlled by
SPI_RD_BIT_ORDER.
PRELIMINARY
Espressif Systems 678 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
Espressif Systems
Bit Mode FSPI Bus Data SPI_RD/WR_BIT_ORDER = 0 (MSB) SPI_RD/WR_BIT_ORDER = 2 (MSB) SPI_RD/WR_BIT_ORDER = 1 (LSB) SPI_RD/WR_BIT_ORDER = 3 (LSB)
1-bit mode FSPID or FSPIQ B7->B6->B5->B4->B3->B2->B1->B0 B7->B6->B5->B4->B3->B2->B1->B0 B0->B1->B2->B3->B4->B5->B6->B7 B0->B1->B2->B3->B4->B5->B6->B7
FSPIQ B7->B5->B3->B1 B6->B4->B2->B0 B1->B3->B5->B7 B0->B2->B4->B6
2-bit mode
FSPID B6->B4->B2->B0 B7->B5->B3->B1 B0->B2->B4->B6 B1->B3->B5->B7
FSPIHD B7->B3 B4->B0 B3->B7 B0->B4
FSPIWP B6->B2 B5->B1 B2->B6 B1->B5
4-bit mode
FSPIQ B5->B1 B6->B2 B1->B5 B2->B6
FSPID B4->B0 B7->B3 B0->B4 B3->B7
Submit Documentation Feedback
679
ESP32-H2 TRM (Pre-release v0.4)
PRELIMINARY
GoBack
26 SPI Controller (SPI) GoBack
The following sections provide detailed information about the transfer types listed in the table above.
In a CPU-controlled master full-duplex or half-duplex transfer, the RX or TX data is saved to or sent from
SPI_W0_REG ~ SPI_W15_REG. The bits SPI_USR_MOSI_HIGHPART and SPI_USR_MISO_HIGHPART control
which buffers are used. See the list below.
• TX data
– When SPI_USR_MOSI_HIGHPART is cleared, i.e., high part mode is disabled, TX data is read from
SPI_W0_REG ~ SPI_W15_REG and the data address is incremented by 1 on each byte transferred. If
the data byte length is larger than 64 bytes, the data in SPI_W0_REG ∼ SPI_W15_REG may be
sent more than once. Take each 256 bytes as a cycle:
PRELIMINARY
Espressif Systems 680 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
* The first 64 bytes (Byte 0 ~ Byte 63) are read from SPI_W0_REG ~ SPI_W15_REG, respectively.
* Byte 256 ~ Byte 319 (the first 64 bytes in the another 256 bytes) are read from SPI_W0_REG ~
SPI_W15_REG again, respectively, same as the behaviors described above.
For instance: to send 258 bytes (Byte 0 ~ Byte 257), the data is read from the registers as follows:
* The first 64 bytes (Byte 0 ~ Byte 63) are read from SPI_W0_REG ~ SPI_W15_REG, respectively.
* The other bytes (Byte 256 and Byte 257) are read from SPI_W0_REG[7:0] and SPI_W0_REG[15:8]
again, respectively. The logic is:
· The address to read data for Byte 256 is the result of (256 % 64 = 0), i.e.,SPI_W0_REG[7:0].
· The address to read data for Byte 257 is the result of (257 % 64 = 1), i.e., SPI_W0_REG[15:8].
– When SPI_USR_MOSI_HIGHPART is set, i.e., high part mode is enabled, TX data is read from
SPI_W8_REG ~ SPI_W15_REG and the data address is incremented by 1 on each byte transferred. If
the data byte length is larger than 32, the data in SPI_W8_REG ∼ SPI_W15_REG may be sent
more than once. Take each 256 bytes as a cycle:
* The first 32 bytes (Byte 0 ~ Byte 31) are read from SPI_W8_REG ~ SPI_W15_REG, respectively.
* Byte 256 ~ Byte 287 (the first 32 bytes in the another 256 bytes) are read from SPI_W8_REG ~
SPI_W15_REG again, respectively, same as the behaviors described above.
For instance: to send 258 bytes (Byte 0 ~ Byte 257), the data is read from the registers as follows:
* The first 32 bytes (Byte 0 ~ Byte 31) are read from SPI_W8_REG ~ SPI_W15_REG, respectively.
* The other bytes (Byte 256 and Byte 257) are read from SPI_W8_REG[7:0] and SPI_W8_REG[15:8]
again, respectively. The logic is:
· The address to read data for Byte 256 is the result of (256 % 32 = 0), i.e., SPI_W8_REG[7:0].
· The address to read data for Byte 257 is the result of (257 % 32 = 1), i.e., SPI_W8_REG[15:8].
• RX data
– When SPI_USR_MISO_HIGHPART is cleared, i.e., high part mode is disabled, RX data is saved to
SPI_W0_REG ~ SPI_W15_REG, and the data address is incremented by 1 on each byte transferred.
If the data byte length is larger than 64, the data in SPI_W0_REG ∼ SPI_W15_REG may be
overwritten. Take each 256 bytes as a cycle:
* The first 64 bytes (Byte 0 ~ Byte 63) are saved to SPI_W0_REG ~ SPI_W15_REG, respectively.
* Byte 255 ~ Byte 319 (the first 64 bytes in the another 256 bytes) are saved to SPI_W0_REG ~
SPI_W15_REG again, respectively, same as the behaviors described above.
For instance: to receive 258 bytes (Byte 0 ~ Byte 257), the data is saved to the registers as follows:
PRELIMINARY
Espressif Systems 681 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
* The first 64 bytes (Byte 0 ~ Byte 63) are saved to SPI_W0_REG ~ SPI_W15_REG, respectively.
* The other bytes (Byte 256 and Byte 257) are saved to SPI_W0_REG[7:0] and SPI_W0_REG[15:8]
again, respectively. The logic is:
· The address to save Byte 256 is the result of (256 % 64 = 0), i.e., SPI_W0_REG[7:0].
· The address to save Byte 257 is the result of (257 % 64 = 1), i.e., SPI_W0_REG[15:8].
– When SPI_USR_MISO_HIGHPART is set, i.e., high part mode is enabled, the RX data is saved to
SPI_W8_REG ∼ SPI_W15_REG, and the data address is incremented by 1 on each byte transferred.
If the data byte length is larger than 32, the content of SPI_W8_REG ∼ SPI_W15_REG may be
overwritten. Take each 256 bytes as a cycle:
* Byte 256 ~ Byte 287 (the first 32 bytes in the another 256 bytes) are saved to SPI_W8_REG ~
SPI_W15_REG again, respectively.
For instance: to receive 258 bytes (Byte 0 ~ Byte 257), the data is saved to the registers as follows:
* The first 32 bytes (Byte 0 ~ Byte 31) are saved to SPI_W8_REG ~ SPI_W15_REG, respectively.
* The other bytes (Byte 256 and Byte 257) are saved to SPI_W8_REG[7:0] and SPI_W8_REG[15:8]
again, respectively. The logic is:
· The address to save Byte 256 is the result of (256 % 32 = 0), i.e., SPI_W8_REG[7:0].
· The address to save Byte 257 is the result of (257 % 32 = 1), i.e., SPI_W8_REG[15:8].
Note:
• To avoid any possible error in TX/RX data, such as TX data being sent more than once or RX data being overwritten,
please make sure the registers are configured correctly.
In a CPU-controlled slave full-duplex or half-duplex transfer, the RX data or TX data is saved to or sent from
SPI_W0_REG ~ SPI_W15_REG, which are byte-addressable.
PRELIMINARY
Espressif Systems 682 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
~ SPI_W15_REG will be overwritten, same as the behaviors described in the master mode when high part
mode is disabled.
• In half-duplex communication, the ADDR value in transmission format is the start address of the RX or TX
data, corresponding to the registers SPI_W0_REG ~ SPI_W15_REG. The RX or TX address is incremented
by 1 on each byte transferred. If the address is larger than 63 (the highest byte address, i.e.,
SPI_W15_REG[31:24]), the data in SPI_W8_REG ~ SPI_W15_REG will be overwritten, same as the
behaviors described in the master mode when high part mode is enabled.
According to your applications, the registers SPI_W0_REG ~ SPI_W15_REG can be used as:
• a single transfer, consisting of only one transaction. GP-SPI2 supports this transfer both as master and as
slave.
• a configurable segmented transfer, consisting of several transactions (segments). GP-SPI2 supports this
transfer only as master. For more information, see Section 26.5.8.5.
• a slave segmented transfer, consisting of several transactions (segments). GP-SPI2 supports this transfer
only as slave. For more information, see Section 26.5.9.3.
A DMA-controlled transfer only needs to be triggered once by CPU. When such a transfer is triggered, data is
transferred by the GDMA engine from or to the DMA-linked memory, without CPU operation.
• Select a GDMA channeln, and configure a GDMA TX/RX descriptor. See Chapter 3 GDMA Controller
(GDMA).
PRELIMINARY
Espressif Systems 683 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
• Before all the GDMA TX buffer is used or the GDMA TX engine is reset, if GDMA_OUTLINK_RESTART_CHn
is set, a new TX buffer will be added to the end of the last TX buffer in use.
• GDMA RX buffer is linked in the same way as the GDMA TX buffer, by setting GDMA_INLINK_START_CHn
or GDMA_INLINK_RESTART_CHn.
• The TX and RX data lengths are determined by the configured GDMA TX and RX buffer respectively, both of
which are 0 ~ 32 KB.
• Initialize GDMA inlink and outlink before GDMA starts. The bits SPI_DMA_RX_ENA and SPI_DMA_TX_ENA
in register SPI_DMA_CONF_REG should be set, otherwise the read/write data will be stored to/sent from
the registers SPI_W0_REG ~ SPI_W15_REG.
It is recommended that the length of configured GDMA TX/RX buffer is equal to the length of actual data
transferred.
• If the length of configured GDMA TX buffer is shorter than that of actual data transferred, the extra data will
be the same as the last transferred data. SPI_OUTFIFO_EMPTY_ERR_INT and
GDMA_OUT_EOF_CHn_INT are triggered.
• If the length of configured GDMA TX buffer is longer than that of actual data transferred, the TX buffer is not
fully used, and the remaining buffer will be used for following transaction even if a new TX buffer is linked
later. Please keep it in mind. Or save the unused data and reset DMA.
• If the length of configured GDMA RX buffer is shorter than that of actual data transferred, the extra data will
be lost. The interrupts SPI_INFIFO_FULL_ERR_INT and SPI_TRANS_DONE_INT are triggered. But
GDMA_IN_SUC_EOF_CHn_INT interrupt is not generated.
• If the length of configured GDMA RX buffer is longer than that of actual data transferred, the RX buffer is not
fully used, and the remaining buffer is discarded. In the following transaction, a new linked buffer will be
PRELIMINARY
Espressif Systems 684 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
used directly.
• Master FSM: all the features supported in GP-SPI2 as master are controlled by this state machine together
with register configuration.
• SPI Buffer: SPI_W0_REG ~ SPI_W15_REG. See Figure 26-2. The data transferred in CPU-controlled mode
is prepared in this buffer.
• clk_spi_mst: this clock is the module clock of GP-SPI2 and derived from PLL_CLK. It is used in GP-SPI2
as master to generate SPI_CLK signal for data transfer and for slaves.
• SPI_CLK_out Mode Control: outputs the SPI_CLK signal for data transfer and for slaves.
• SPI_CLK_in Mode Control: captures the SPI_CLK signal from SPI master when GP-SPI2 works as a slave.
PRELIMINARY
Espressif Systems 685 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Figure 26-4 shows the data flow of GP-SPI2 as master. Its control logic is as follows:
• RX data: data in FSPI bus is captured by Timing Module, converted in units of bytes by spi_mst_din_ctrl
module, then buffered in spi_rx_afifo, and finally stored in corresponding addresses according to the
transfer modes.
• TX data: the TX data is from corresponding addresses according to transfer modes and is saved to
buf_tx_afifo.
The data in buf_tx_afifo is sent out to Timing Module in 1/2/4-bit modes, controlled by GP-SPI2 state machine.
The Timing Module can be used for timing compensation.
PRELIMINARY
Espressif Systems 686 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Figure 26-5 shows the data flow in GP-SPI2 as slave. Its control logic is as follows:
• In CPU/DMA-controlled full-/half-duplex transfer, when an external SPI master starts the SPI transfer, data
on the FSPI bus is captured, converted into unit of bytes by the spi_slv_din_ctrl module, and then is stored
in spi_rx_afifo.
– In CPU-controlled full-duplex transfer, the received data in spi_rx_afifo will be later stored into registers
SPI_W0_REG ~ SPI_W15_REG, successively.
– In half-duplex Wr_BUF transfer, when the value of address (SLV_ADDR[7:0]) is received, the received
data in spi_rx_afifo will be stored in the related address of registers SPI_W0_REG ~ SPI_W15_REG
– In CPU-controlled full-duplex transfer, when SPI_SLAVE_MODE and SPI_DOUTDIN are set and
SPI_DMA_TX_ENA is cleared, the data in SPI_W0_REG ~ SPI_W15_REG will be stored into
buf_tx_afifo;
The data in buf_tx_afifo or dma_tx_afifo is sent out by spi_slv_dout_ctrl module in 1/2/4-bit modes.
Note:
• The length of transferred data must be an integral multiple of byte (8 bits), otherwise the extra bits will be lost. The
extra bits here means the result of total data bits mod 8.
• To transfer bits that is not an integral multiple of byte (8 bits), consider implementing it in CMD state or ADDR state.
PRELIMINARY
Espressif Systems 687 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
When GP-SPI2 works as a master, the state machine controls its various states during data transfer, including
configuration (CONF), preparation (PREP), command (CMD), address (ADDR), dummy (DUMMY), data out
(DOUT), and data in (DIN) states. GP-SPI2 is mainly used to access 1/2/4-bit SPI devices, such as flash and
external RAM, thus the naming of GP-SPI2 states keeps consistent with the sequence naming of flash and
external RAM. The meaning of each state is described as follows and Figure 26-6 shows the workflow of
GP-SPI2 state machine.
2. CONF: only used in DMA-controlled configurable segmented transfer. Set SPI_USR and SPI_USR_CONF
to enable this state. If this state is not enabled, it means the current transfer is a single transfer.
3. PREP: prepare an SPI transaction and control SPI CS setup time. Set SPI_USR and SPI_CS_SETUP to
enable this state.
4. CMD: send command sequence. Set SPI_USR and SPI_USR_COMMAND to enable this state.
5. ADDR: send address sequence. Set SPI_USR and SPI_USR_ADDR to enable this state.
6. DUMMY (wait cycle): send dummy sequence. Set SPI_USR and SPI_USR_DUMMY to enable this state.
• DOUT: send data sequence. Set SPI_USR and SPI_USR_MOSI to enable this state.
• DIN: receive data sequence. Set SPI_USR and SPI_USR_MISO to enable this state.
8. DONE: control SPI CS hold time. Set SPI_USR to enable this state.
Note:
To start this state machine, set SPI_USR first. SPI_MST_FD_WAIT_DMA_TX_DATA controls when SPI_USR
takes effect:
• 0: the configured state takes effect immediately after SPI_USR and other control registers are configured.
• 1: if DOUT state is configured, the SPI_USR and other control registers will take effect, and the state
machine will start, only when the data is ready in buf_tx_afifo.
PRELIMINARY
Espressif Systems 688 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Figure 266. GPSPI2 State Machine as Master
PRELIMINARY
Espressif Systems 689 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
• —: corresponding registers are set and conditions are satisfied; goes to next state.
• —: state registers are not set; skips one or more following states, depending on the registers of the
following states are set or not.
A counter (gpc[17:0]) is used in the 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. The cycle length of
each state can also be configured independently.
Introduction
The registers, related to GP-SPI2 state control, are listed in Table 26-8. Users can enable QPI mode for GP-SPI2
by setting the bit SPI_QPI_MODE in register SPI_USER_REG.
Control Registers for 1bit Control Registers for 2bit Control Registers for 4bit
State
Mode FSPI Bus Mode FSPI Bus Mode FSPI Bus
SPI_USR_COMMAND_VALUE SPI_USR_COMMAND_VALUE
SPI_USR_COMMAND_VALUE
SPI_USR_COMMAND_BITLEN SPI_USR_COMMAND_BITLEN
CMD SPI_USR_COMMAND_BITLEN
SPI_FCMD_DUAL SPI_FCMD_QUAD
SPI_USR_COMMAND
SPI_USR_COMMAND SPI_USR_COMMAND
SPI_USR_ADDR_VALUE SPI_USR_ADDR_VALUE
SPI_USR_ADDR_VALUE
SPI_USR_ADDR_BITLEN SPI_USR_ADDR_BITLEN
ADDR SPI_USR_ADDR_BITLEN
SPI_USR_ADDR SPI_USR_ADDR
SPI_USR_ADDR
SPI_FADDR_DUAL SPI_FADDR_QUAD
SPI_USR_DUMMY_CYCLELEN SPI_USR_DUMMY_CYCLELEN SPI_USR_DUMMY_CYCLELEN
DUMMY
SPI_USR_DUMMY SPI_USR_DUMMY SPI_USR_DUMMY
SPI_USR_MISO SPI_USR_MISO
SPI_USR_MISO
DIN SPI_MS_DATA_BITLEN SPI_MS_DATA_BITLEN
SPI_MS_DATA_BITLEN
SPI_FREAD_DUAL SPI_FREAD_QUAD
PRELIMINARY
Espressif Systems 690 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Control Registers for 1bit Control Registers for 2bit Control Registers for 4bit
State
Mode FSPI Bus Mode FSPI Bus Mode FSPI Bus
SPI_USR_MOSI SPI_USR_MOSI
SPI_USR_MOSI
DOUT SPI_MS_DATA_BITLEN SPI_MS_DATA_BITLEN
SPI_MS_DATA_BITLEN
SPI_FWRITE_DUAL SPI_FWRITE_QUAD
As shown in Table 26-8, the registers in each cell should be configured to set the FSPI bus to corresponding bit
mode, i.e., the mode shown in the table header, at a specific state (corresponding to the first column).
Configuration
• Set SPI_USR_COMMAND.
• Clear SPI_FADDR_QUAD.
• Set SPI_USR_DUMMY.
PRELIMINARY
Espressif Systems 691 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
• Clear SPI_FREAD_DUAL.
5. Clear SPI_USR_MOSI.
When writing data (DOUT state), SPI_USR_MOSI should be configured instead, while SPI_USR_MISO should be
cleared. The output data bit length is the value of SPI_MS_DATA_BITLEN + 1. Output data should be configured
in GP-SPI2 data buffer (SPI_W0_REG ~ SPI_W15_REG) in CPU-controlled mode, or GDMA 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.
Introduction
GP-SPI2 supports SPI full-duplex communication. In this mode, SPI master provides CLK and CS signals,
exchanging data with SPI slave in 1-bit mode via MOSI (FSPID, sending) and MISO (FSPIQ, receiving) at the
same time. To enable this communication mode, set the bit SPI_DOUTDIN in register SPI_USER_REG. Figure
26-7 illustrates the connection of GP-SPI2 with its slave in full-duplex communication.
In full-duplex communication, the behavior of states CMD, ADDR, DUMMY, DOUT and DIN are configurable.
Usually, the states CMD, ADDR and DUMMY are not used in this communication. The bit length of transferred
data is configured in SPI_MS_DATA_BITLEN. The actual bit length used in communication equals to
(SPI_MS_DATA_BITLEN + 1).
Configuration
• Configure the IO path via IO MUX or GPIO matrix between GP-SPI2 and an external SPI device.
• Configure AHB and APB clock (AHB_CLK and APB_CLK, see Chapter 7 Reset and Clock) and module
clock (clk_spi_mst) for the GP-SPI2 module.
PRELIMINARY
Espressif Systems 693 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
• Configure SPI CS setup time and hold time according to Section 26.6.
– In DMA-controlled mode,
* configure SPI_DMA_TX_ENA/SPI_DMA_RX_ENA,
* and start GDMA TX/RX engine, as described in Section 26.5.6 and Section 26.5.7.
• Configure interrupts and wait for SPI slave to get ready for transfer.
• Set SPI_USR in register SPI_CMD_REG to start the transfer and wait for the configured interrupts.
Introduction
In this mode, GP-SPI2 provides CLK and CS signals. Only one side (SPI master or slave) can send data at a
time, while the other side receives the data. To enable this communication mode, clear the bit SPI_DOUTDIN in
register SPI_USER_REG. The standard format of SPI half-duplex communication is CMD + [ADDR +] [DUMMY +]
[DOUT or DIN]. The states ADDR, DUMMY, DOUT, and DIN are optional, and can be disabled or enabled
independently.
As described in Section 26.5.8.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 26-8.
4. DOUT: 0 ~ 512 bits (64 B) in CPU-controlled mode and 0 ~ 256 Kbits (32 KB) in DMA-controlled mode,
master output, slave input.
5. DIN: 0 ~ 512 bits (64 B) in CPU-controlled mode and 0 ~ 256 Kbits (32 KB) in DMA-controlled mode,
master input, slave output.
Configuration
1. Configure the IO path via IO MUX or GPIO matrix between GP-SPI2 and an external SPI device.
2. Configure AHB and APB clock (AHB_CLK and APB_CLK) and module clock (clk_spi_mst) for the GP-SPI2
module.
PRELIMINARY
Espressif Systems 694 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
5. Configure SPI CS setup time and hold time according to Section 26.6.
• In DMA-controlled mode,
– configure SPI_DMA_TX_ENA/SPI_DMA_RX_ENA,
– and start GDMA TX/RX engine, as described in Section 26.5.6 and Section 26.5.7.
8. Configure interrupts and wait for SPI slave to get ready for transfer.
10. Set SPI_USR in register SPI_CMD_REG to start the transfer and wait for the configured interrupts.
Application Example
The following example shows how GP-SPI2 accesses flash and external RAM in master half-duplex mode.
Figure 268. Connection of GPSPI2 to Flash and External RAM in 4bit Mode
Figure 26-9 indicates GP-SPI2 Quad I/O Read sequence according to standard flash specification. Other
GP-SPI2 command sequences are implemented in accordance with the requirements of SPI slaves.
PRELIMINARY
Espressif Systems 695 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Figure 269. SPI Quad I/O Read Command Sequence Sent by GPSPI2 to Flash
Introduction
When GP-SPI2 works as a master, it provides a feature named configurable segmented transfer controlled by
DMA.
In a configurable segmented transfer, the registers of each single transaction (segment) are configurable. This
feature enables GP-SPI2 to do as many transactions (segments) as configured after such transfer is triggered
once by the CPU. Figure 26-10 shows how this feature works.
As shown in Figure 26-10, the registers for one transaction (segment n) can be reconfigured by GP-SPI2
hardware according to the content in its Conf_bufn during a CONF state, before this segment starts.
It’s recommended to provide separate GDMA CONF links and CONF buffers (Conf_bufi in Figure 26-10) for each
PRELIMINARY
Espressif Systems 696 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
CONF state. A GDMA TX link is used to connect all the CONF buffers and TX data buffers (Tx_bufi in Figure
26-10) into a chain. Hence, the behavior of the FSPI bus in each segment can be controlled independently.
For example, in a configurable segmentent transfer, its segmenti, segmentj, and segmentk can be configured to
full-duplex, half-duplex MISO, and half-duplex MOSI, respectively. i, j, and k represent different segment
numbers.
Meanwhile, the state of GP-SPI2, the data length and cycle length of the FSPI bus, and the behavior of the
GDMA, can be configured independently for each segment. When this whole DMA-controlled transfer (consisting
of several segments) has finished, a GP-SPI2 interrupt, SPI_DMA_SEG_TRANS_DONE_INT, is triggered.
Configuration
1. Configure the IO path via IO MUX or GPIO matrix between GP-SPI2 and an external SPI device.
2. Configure AHB and APB clock (AHB_CLK and APB_CLK) and module clock (clk_spi_mst) for GP-SPI2
module.
5. Configure SPI CS setup time and hold time according to Section 26.6.
7. Prepare descriptors for GDMA CONF buffer and TX data (optional) for each segment. Chain the descriptors
of CONF buffer and TX buffers of several segments into one linked list.
8. Similarly, prepare descriptors for RX buffers for each segment and chain them into one linked list.
9. Configure all the needed CONF buffers, TX buffers and RX buffers, respectively for each segment before
this DMA-controlled transfer begins.
10. Point GDMA_OUTLINK_ADDR_CHn to the head address of the CONF and TX buffer descriptor linked list,
and then set GDMA_OUTLINK_START_CHn to start the TX GDMA.
11. Clear the bit SPI_RX_EOF_EN in register SPI_DMA_CONF_REG. Point GDMA_INLINK_ADDR_CHn to the
head address of the RX buffer descriptor linked list, and then set GDMA_INLINK_START_CHn to start the
RX GDMA.
14. Wait for all the slaves to get ready for transfer.
17. Wait for SPI_DMA_SEG_TRANS_DONE_INT interrupt, which means this transfer has finished and the data
has been stored into corresponding memory.
In a configurable segmented transfer, only registers which will change from the last transaction (segment) need to
be re-configured to new values in CONF state. The configuration of other registers can be skipped (i.e., kept the
PRELIMINARY
Espressif Systems 697 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
The first word in GDMA CONF bufferi, called SPI_BIT_MAP_WORD, defines whether each GP-SPI2 register is to
be updated or not in segmenti. The relation of SPI_BIT_MAP_WORD and GP-SPI2 registers to update can be
seen in Bitmap (BM) Table, Table 26-11. If a bit in the BM table is set to 1, its corresponding register value will be
updated in this segment. 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 be modified should be placed right after 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 in register SPI_SLAVE_REG. The
value of SPI_DMA_SEG_MAGIC_VALUE should be configured before this DMA-controlled transfer starts, and
can not be changed during these segments.
Table 26-12 and Table 26-13 provide an example to show how to configure a CONF buffer for a transaction
(segment i) in which SPI_ADDR_REG, SPI_CTRL_REG, SPI_CLOCK_REG, SPI_USER_REG, SPI_USER1_REG
need to be updated.
Notes:
In a DMA-controlled configurable segmented transfer, please pay special attention to the following bits:
• SPI_USR_CONF_NXT: if segmenti is not the final transaction of this whole DMA-controlled transfer, its
SPI_USR_CONF_NXT bit should be set to 1.
• SPI_CONF_BITLEN: GP-SPI2 CS setup time and hold time are programmable independently in each
segment, see Section 26.6 for detailed configuration. The CS high time in each segment is about:
The CS high time in CONF state can be set from 156.25 ns to 8.1918 ms when fAPB_CLK is 32 MHz.
(SPI_CONF_BITLEN + 5) will overflow from (0x40000 - SPI_CONF_BITLEN - 5) if SPI_CONF_BITLEN is
larger than 0x3FFFA.
The CS signal must be held low during the transmission, and its falling/rising edges indicate the start/end of a
single or segmented transmission. 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 bits % 8.
In GP-SPI2 as slave, SPI full-duplex and half-duplex communications are available. To select from the two
communications, configure SPI_DOUTDIN in register SPI_USER_REG.
PRELIMINARY
Espressif Systems 699 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Full-duplex communication means that input data and output data are transmitted simultaneously throughout the
entire transaction. All bits are treated as input or output data, which means no command, address or dummy
states are expected. The interrupt SPI_TRANS_DONE_INT is triggered once the transaction ends.
1. CMD:
• Only the values in Table 26-14 and Table 26-15 are valid;
2. ADDR:
• The address for Wr_BUF and Rd_BUF commands in CPU-controlled transfer, or placeholder bits in
other transfers and can be defined by application;
3. DUMMY:
4. DIN or DOUT:
• Can be sent in 1-bit, 2-bit or 4-bit modes according to the CMD value.
Note:
The states of ADDR and DUMMY can never be skipped in any half-duplex communications.
When a half-duplex transaction is complete, the transferred CMD and ADDR values are latched into
SPI_SLV_LAST_COMMAND and SPI_SLV_LAST_ADDR respectively. The SPI_SLV_CMD_ERR_INT_RAW will be
set if the transferred CMD value is not supported by GP-SPI2 as slave. The SPI_SLV_CMD_ERR_INT_RAW can
only be cleared by software.
In half-duplex communication, the defined values of CMD determine the transfer types. Unsupported CMD
values are disregarded, meanwhile the related transfer is ignored and SPI_SLV_CMD_ERR_INT_RAW is set. The
transfer format is CMD (8 bits) + ADDR (8 bits) + DUMMY (8 SPI_CLK cycles) + DATA (unit in bytes). The detailed
description of CMD[3:0] is as follows:
PRELIMINARY
Espressif Systems 700 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
• 0x1 (Wr_BUF): CPU-controlled write mode. Master sends data and GP-SPI2 receives data. The data is
stored in the related address of SPI_W0_REG ~ SPI_W15_REG.
• 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_W15_REG.
• 0x3 (Wr_DMA): DMA-controlled write mode. Master sends data and GP-SPI2 receives data. The data is
stored in GP-SPI2 GDMA RX buffer.
• 0x4 (Rd_DMA): DMA-controlled read mode. Master receives the data sent by GP-SPI2. The data comes
from GP-SPI2 GDMA TX buffer.
• 0x8 (CMD8): only used to generate an SPI_SLV_CMD8_INT interrupt, which will not end GP-SPI2’s slave
segmented transfer.
• 0x9 (CMD9): only used to generate an SPI_SLV_CMD9_INT interrupt, which will not end GP-SPI2’s slave
segmented transfer.
• 0xA (CMDA): only used to generate an SPI_SLV_CMDA_INT interrupt, which will not end GP-SPI2’s slave
segmented transfer.
The detailed function of CMD7, CMD8, CMD9, and CMDA commands is reserved for user definition. These
commands can be used as handshake signals, as passwords of some specific functions, as triggers of some
user defined actions, and so on.
1/2/4-bit modes in states of CMD, ADDR, DATA are supported, which are determined by value of CMD[7:4]. The
DUMMY state is always in 1-bit mode and lasts for eight SPI_CLK cycles. The definition of CMD[7:4] is as
follows:
• 0x0: CMD, ADDR, and DATA states all are in 1-bit mode.
• 0x1: CMD and ADDR are in 1-bit mode. DATA is in 2-bit mode.
• 0x2: CMD and ADDR are in 1-bit mode. DATA is in 4-bit mode.
• 0x5: CMD is in 1-bit mode. ADDR and DATA are in 2-bit mode.
• 0xA: CMD is in 1-bit mode, ADDR and DATA are in 4-bit mode or in QPI mode.
In addition, if the value of CMD[7:0] is 0x05, 0xA5, 0x06, or 0xDD, DUMMY and DATA states are skipped. The
definition of CMD[7:0] is as follows:
• 0x05 (End_SEG_TRANS): master sends 0x05 command to end slave segmented transfer in SPI mode.
• 0xA5 (End_SEG_TRANS): master sends 0xA5 command to end slave segmented transfer in QPI mode.
• 0x06 (En_QPI): GP-SPI2 enters QPI mode when receiving the 0x06 command and the bit SPI_QPI_MODE
in register SPI_USER_REG is set.
• 0xDD (Ex_QPI): GP-SPI2 exits QPI mode when receiving the 0xDD command and the bit SPI_QPI_MODE
is cleared.
All the CMD values supported by GP-SPI2 are listed in Table 26-14 and Table 26-15. Note that DUMMY state is
always in 1-bit mode and lasts for eight SPI_CLK cycles.
PRELIMINARY
Espressif Systems 701 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
PRELIMINARY
Espressif Systems 702 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Master sends 0x06 CMD (En_QPI) to set GP-SPI2 slave to QPI mode. The transfer types supported by GP-SPI2
in the QPI mode are listed in Table 26-15, which will be in 4-bit mode afterwards. If 0xDD CMD (Ex_QPI) is
received, GP-SPI2 slave will be back to SPI mode.
Other transfer types than these described in Table 26-14 and Table 26-15 are ignored. If the transferred data is
not in unit of byte, GP-SPI2 will send or receive the data in unit of byte, but the extra bits (the result of total bits
mod 8) will be lost. But if the CS low time is longer than 2 APB clock (APB_CLK) cycles, SPI_TRANS_DONE_INT
will be triggered. For more information on interrupts triggered at the end of transmissions, please refer to Section
26.8.
When GP-SPI2 works as a slave, it supports full-duplex and half-duplex communications controlled by DMA and
by CPU. DMA-controlled transfer can be a single transfer, or a slave segmented transfer consisting of several
transactions (segments). The CPU-controlled transfer can only be one single transfer, since each CPU-controlled
transaction needs to be triggered by CPU.
In a slave segmented transfer, all transfer types listed in Table 26-14 and Table 26-15 are supported in a single
transaction (segment). It means that CPU-controlled transaction and DMA-controlled transaction can be mixed in
one slave segmented transfer.
• CPU-controlled transaction is used for handshake communication and short data transfers.
When operating as slave, GP-SPI2 supports CPU/DMA-controlled full-duplex/half-duplex single transfers. The
register configuration procedure is as follows:
1. Configure the IO path via IO MUX or GPIO matrix between GP-SPI2 and an external SPI device.
PRELIMINARY
Espressif Systems 703 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
4. Configure SPI_DOUTDIN:
5. Prepare data:
• if CPU-controlled transfer mode is selected and GP-SPI2 is used to send data, then prepare data in
registers SPI_W0_REG ~ SPI_W15_REG.
– and start GDMA TX/RX engine, as described in Section 26.5.6 and Section 26.5.7.
GDMA must be used in this mode. The register configuration procedure is as follows:
1. Configure the IO path via IO MUX or GPIO matrix between GP-SPI2 and an external SPI device.
7. Set bits SPI_DMA_RX_ENA and SPI_DMA_TX_ENA. Clear the bit SPI_RX_EOF_EN. Configure GDMA
TX/RX link and start GDMA TX/RX engine, as shown in Section 26.5.6 and Section 26.5.7.
When End_SEG_TRANS (0x05 in SPI mode, 0xA5 in QPI mode) is received by GP-SPI2, this slave segmented
transfer is ended and the interrupt SPI_DMA_SEG_TRANS_DONE_INT is triggered.
PRELIMINARY
Espressif Systems 704 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
GDMA must be used in this mode. In such transfer, the data is transferred from and to the GDMA buffer. The
interrupt GDMA_IN_SUC_EOF_CHn
_INT is triggered when the transfer ends. The configuration procedure is as follows:
1. Configure the IO path via IO MUX or GPIO matrix between GP-SPI2 and an external SPI device.
5. Set SPI_DMA_TX_ENA/SPI_DMA_RX_ENA. Configure GDMA TX/RX link and start GDMA TX/RX engine, as
shown in Section 26.5.6 and Section 26.5.7.
CS setup time is the time between the CS falling edge and the first latch edge of SPI bus CLK (SPI_CLK). The
first latch edge for mode 0 and mode 3 is rising edge, and falling edge for mode 2 and mode 4.
CS hold time is the time between the last latch edge of SPI_CLK and the CS rising edge.
When operating as slave, the CS setup time and hold time should be longer than 0.5 x T_SPI_CLK, otherwise the
SPI transfer may be incorrect. T_SPI_CLK is one cycle of SPI_CLK.
When operating as master, set the CS setup time by specifying SPI_CS_SETUP in SPI_USER_REG and
SPI_CS_SETUP_TIME in SPI_USER1_REG:
Figure 26-11 and Figure 26-12 show the recommended CS timing and register configuration to access external
RAM and flash.
PRELIMINARY
Espressif Systems 705 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Figure 2611. Recommended CS Timing and Settings When Accessing External RAM
• clk_spi_mst: module clock of GP-SPI2, derived from PLL_CLK. Used in GP-SPI2 as master to generate
SPI_CLK signal for data transfer and for slaves.
• 0: XTAL_CLK
PRELIMINARY
Espressif Systems 706 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
• 1: PLL_F48M_CLK
• 2: RC_FAST_CLK
When operating as master, the maximum output clock frequency of GP-SPI2 is fclk_spi_mst . To have slower
frequencies, the output clock frequency can be divided as follows:
fclk_spi_mst
fSPI_CLK =
(SPI_CLKCNT_N + 1)(SPI_CLKDIV_PRE + 1)
The divider is configured by SPI_CLKCNT_N and SPI_CLKDIV_PRE in register SPI_CLOCK_REG. When the bit
SPI_CLK_EQU_SYSCLK in register SPI_CLOCK_REG is set to 1, the output clock frequency of GP-SPI2 will be
fclk_spi_mst . For other integral clock divisions, SPI_CLK_EQU_SYSCLK should be set to 0.
When operating as slave, the input clock frequency supported by GP-SPI2 isfclk_spi_slv , and
PRELIMINARY
Espressif Systems 707 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
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. The first data is shifted out before the first negative edge of SCK.
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. The first data is shifted out before the first positive edge of SCK.
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 is used to select the number of rising edges of SPI_CLK when SPI_CS raises high to be 0, 1, 2
or SPI_CLK always on.
PRELIMINARY
Espressif Systems 708 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
Note:
When SPI_CLK_MODE is configured to 1 or 2, the bit SPI_CS_HOLD must be set and the value of SPI_CS_HOLD_TIME
should be larger than 1.
26.8 Interrupts
Interrupt Summary
GP-SPI2 provides an SPI interface interrupt SPI_INT. When an SPI transfer ends, an interrupt is generated in
GP-SPI2.
• SPI_DMA_INFIFO_FULL_ERR_INT: triggered when the length of GDMA RX FIFO is shorter than that of
actual data transferred.
• SPI_DMA_OUTFIFO_EMPTY_ERR_INT: triggered when the length of GDMA TX FIFO is shorter than that of
actual data transferred.
• SPI_SLV_EX_QPI_INT: triggered when Ex_QPI is received correctly in GP-SPI2 as slave and the SPI transfer
ends.
• SPI_SLV_EN_QPI_INT: triggered when En_QPI is received correctly in GP-SPI2 as slave and the SPI
transfer ends.
• SPI_SLV_CMD7_INT: triggered when CMD7 is received correctly in GP-SPI2 as slave and the SPI transfer
ends.
• SPI_SLV_CMD8_INT: triggered when CMD8 is received correctly in GP-SPI2 as slave and the SPI transfer
ends.
• SPI_SLV_CMD9_INT: triggered when CMD9 is received correctly in GP-SPI2 as slave and the SPI transfer
ends.
• SPI_SLV_CMDA_INT: triggered when CMDA is received correctly in GP-SPI2 as slave and the SPI transfer
ends.
• SPI_TRANS_DONE_INT: triggered at the end of SPI bus transfer in both as master and as slave.
• SPI_SEG_MAGIC_ERR_INT: triggered when a Magic error occurs in CONF buffer during configurable
segmented transfer as master.
• SPI_SLV_CMD_ERR_INT: triggered when a received command value is not supported in GP-SPI2 as slave.
• SPI_APP2_INT: used and triggered by software. Only used for user defined function.
• SPI_APP1_INT: used and triggered by software. Only used for user defined function.
Table 26-18 and Table 26-19 show the interrupts used in GP-SPI2 as master and as slave, respectively. Set the
interrupt enable bit SPI_*_INT_ENA in SPI_DMA_INT_ENA_REG and wait for the SPI_INT interrupt. When the
transfer ends, the related interrupt is triggered and should be cleared by software before the next transfer.
PRELIMINARY
Espressif Systems 710 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
PRELIMINARY
Espressif Systems 711 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 712 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
PRELIMINARY
Espressif Systems 713 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
26.10 Registers
The addresses in this section are relative to SPI base address provided in Table 4-2 in Chapter 4 System and
Memory.
EN
L
IT
_B
TE
NF
DA
d)
d)
I_ R
CO
ve
ve
SP US
UP
er
er
I_
I_
s
s
SP
SP
(re
(re
31 25 24 23 22 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_UPDATE Configures whether or not to synchronize SPI registers from APB clock domain into SPI
module clock domain.
0: Not synchronize
1: Synchronize
This bit is only used in SPI master transfer. (WT)
31 0
0 Reset
PRELIMINARY
Espressif Systems 714 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
HP T
T
IG AR
AR
IS IG E
_H HP
M I_H L
I_ R_ DR ND
R_ OS Y_ID
XT
I_ _S ED E
_ D
AL
SP CS ET GE
_N
E
SP CS _I_ DG
SP US AD MA
SP US MIS MY
TE UA
G
I_ R_ MM
ed DU
I_ d) NF
I_ d) ED
DE
I_ CK _E
I_ _H UP
I_ R_ O
SP US DU I
O
I_ R_ M
RI _Q
I_ R_ M
I_ R_ S
se CK D
N
SP US MO
SP US CO
SP rve CO
SP US DU
SP RS UT
(re TS OL
SP rve _I_
DI
FW E
US M
_M
I_ RIT
UT
I_ _O
I_ R_
se R_
)
I_ d)
)
ed
ed
(re SIO
PI
SP FW
SP rve
DO
SP CK
SP US
(re US
rv
rv
rv
Q
se
se
se
se
I_
I_
I_
I_
SP
SP
SP
SP
(re
(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_TSCK_I_EDGE Configures whether or not to change the polarity of TSCK in slave transfer.
0: TSCK = SPI_CK_I
1: TSCK = !SPI_CK_I
(R/W)
SPI_CS_HOLD Configures whether or not to keep SPI CS low when SPI is in DONE state.
0: Not keep low
1: Keep low
Can be configured in CONF state. (R/W)
SPI_CS_SETUP Configures whether or not to enable SPI CS when SPI is in prepare (PREP) state.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_RSCK_I_EDGE Configures whether or not to change the polarity of RSCK in slave transfer.
0: RSCK = !SPI_CK_I
1: RSCK = SPI_CK_I
(R/W)
SPI_FWRITE_DUAL Configures whether or not to enable the 2-bit mode of read-data phase in write
operations.
0: Not enable
1: Enable
Can be configured in CONF state. (R/W)
SPI_FWRITE_QUAD Configures whether or not to enable the 4-bit mode of read-data phase in write
operations.
0: Not enable
1: Enable
Can be configured in CONF state. (R/W)
SPI_USR_CONF_NXT Configures whether or not to enable the CONF state for the next transaction
(segment) in a configurable segmented transfer.
0: this transfer will end after the current transaction (segment) is finished. Or this is not a config-
urable segmented transfer.
1: this configurable segmented transfer will continue its next transaction (segment).
Can be configured in CONF state. (R/W)
SPI_SIO Configures whether or not to enable 3-line half-duplex communication, where MOSI and
MISO signals share the same pin.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_USR_MISO_HIGHPART Configures whether or not to enable “high part mode”, i.e., only access
to high part of the buffers: SPI_W8_REG ~ SPI_W15_REG in read-data phase.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_USR_MOSI_HIGHPART Configures whether or not to enable ”high part mode”, i.e., only access
to high part of the buffers: SPI_W8_REG ~ SPI_W15_REG in write-data phase.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_USR_MOSI Configures whether or not to enable the write-data (DOUT) state of an operation.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_USR_MISO Configures whether or not to enable the read-data (DIN) state of an operation.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_USR_ADDR Configures whether or not to enable the address (ADDR) state of an operation.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_USR_COMMAND Configures whether or not to enable the command (CMD) state of an opera-
tion.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
PRELIMINARY
Espressif Systems 717 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
N
_E
N
LE
ND
E
_E
CL
EN
RR
CY
TL
E
E
_E
Y_
IM
BI
TI
LL
R_
_T
M
P_
UM
FU
LD
DD
TU
_W
O
_D
_A
SE
_H
)
ST
ed
R
R
S_
CS
US
US
rv
M
C
se
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
(re
31 27 26 22 21 17 16 15 8 7 0
23 0x1 0 1 0 0 0 0 0 0 0 0 7 Reset
SPI_MST_WFULL_ERR_END_EN Configures whether or not to end the SPI transfer when SPI RX
AFIFO wfull error occurs in master full-/half-duplex transfers.
0: Not end
1: End
(R/W)
PRELIMINARY
Espressif Systems 718 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
EN
D_
EN
UE
EN
TL
L
R_
VA
BI
ER
D_
D_
AN
AN
Y_
PT
M
M
M
M
EM
CO
O
_R
_C
R_
d)
ST
R
ve
US
US
M
er
I_
I_
I_
s
SP
SP
SP
(re
31 28 27 26 16 15 0
7 1 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_MST_REMPTY_ERR_END_EN Configures whether or not to end the SPI transfer when SPI TX
AFIFO read empty error occurs in master full-/half-duplex transfers.
0: Not end
1: End
(R/W)
PRELIMINARY
Espressif Systems 719 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
ER
ER
SP rve R_ AD
DU D
AL
AL
UT
RD
SP rve _D AD
RD
L
D_ UA
I_ d) UA
I_ PO OL
se D QU
I_ d) DU
O
O
se MD U
O
EA Q
Y_
T_
(re FC _Q
SP HO OL
T_
SP D_ _P
(re AD _
FR D_
L
R
Q L
M
BI
I_ MD
I
I_ _P
I_ LD
(re PO
_B
I_ D
I_ EA
)
I_ d)
)
M
R_
ed
ed
ed
ed
SP FAD
SP P
SP rve
DU
RD
SP FC
SP FR
rv
rv
rv
rv
W
F
se
se
se
se
se
I_
I_
I_
I_
SP
SP
SP
SP
(re
(re
(re
(re
31 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 10 9 8 7 6 5 4 3 2 0
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_DUMMY_OUT Configures whether or not to output the FSPI bus signals in DUMMY state.
0: Not output
1: Output
Can be configured in CONF state. (R/W)
SPI_FADDR_DUAL Configures whether or not to enable 2-bit mode during address (ADDR) state.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_FADDR_QUAD Configures whether or not to enable 4-bit mode during address (ADDR) state.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_FCMD_DUAL Configures whether or not to enable 2-bit mode during command (CMD) state.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_FCMD_QUAD Configures whether or not to enable 4-bit mode during command (CMD) state.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_FREAD_DUAL Configures whether or not to enable the 2-bit mode of read-data (DIN) state in
read operations.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_FREAD_QUAD Configures whether or not to enable the 4-bit mode of read-data (DIN) state in
read operations.
0: Disable
1: Enable
Can be configured in CONF state. (R/W)
SPI_WP_POL Configures the output value of write-protect signal when SPI is in idle.
0: Output low
1: Output high
Can be configured in CONF state. (R/W)
SPI_WR_BIT_ORDER Configures the bit order in command (CMD), address (ADDR), and write-data
(MOSI) states.
0: MSB first
1: LSB first
Can be configured in CONF state. (R/W)
S_
ve
M
r
se
I_
SP
(re
31 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_MS_DATA_BITLEN Configures the data bit length of SPI transfer in DMA-controlled master trans-
fer or in CPU-controlled master transfer. Or configures the bit length of SPI RX transfer in DMA-
controlled slave transfer.
This value shall be (expected bit_num - 1). Can be configured in CONF state. (R/W)
PRELIMINARY
Espressif Systems 721 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
L
ED IVE
O
L
E
_P
E_ CT
O
G
_P
CS
DL A
_I P_
R_
_C
SP CS DIS
SP CS DIS
SP CS DIS
SP CS DIS
0_ S
S
CK EE
SP CS IS
CS I
DI
TE
I_ 1_D
VE
I_ _D
I_ _K
I_ 5_
I_ 4_
I_ 3_
I_ 2_
I_ d)
AS
ed
ed
LA
SP rve
SP CK
SP CS
rv
M
S
er
se
se
I_
I_
I_
s
SP
SP
SP
(re
(re
(re
31 30 29 28 24 23 22 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
PRELIMINARY
Espressif Systems 722 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
_E EN
RA CL EN
NS R_
_T _ _
N
G NS LR
SE RA _C
Y
PT
V_ _T S
SL G AN
M
FO L
FI UL
_E
SP DM FIF _R T
A_ _SE _TR
I_ A_ O_ ST
I_ _A FO S
A_ _E T
UT F
SP RX AFI _R
NA
X S
RX NA
O O_
DM X G
DM T R
SP SLV TX_ N
I_ F_ IFO
I_ _R SE
_E
A_ FIF
I_ _ _E
SP BU AF
SP SLV OF
DM IN
I_ A_
I_ A_
I_ _E
)
)
ed
ed
SP DM
SP DM
SP RX
rv
rv
se
se
I_
I_
I_
SP
SP
SP
(re
(re
31 30 29 28 27 26 22 21 20 19 18 17 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
SPI_DMA_OUTFIFO_EMPTY Represents whether or not the DMA TX FIFO is ready for sending data.
0: Ready
1: Not ready
(RO)
SPI_DMA_INFIFO_FULL Represents whether or not the DMA RX FIFO is ready for receiving data.
0: Ready
1: Not ready
(RO)
• if the size of DMA RX buffer is not 0, the data in the following Wr_DMA transactions will be
received.
• if the size of DMA RX buffer is 0, the data in the following Wr_DMA transactions will not be
received.
(R/W)
(R/W)
SPI_RX_AFIFO_RST Configures whether or not to reset spi_rx_afifo as shown in Figure 26-4 and in
Figure 26-5.
0: Not reset
1: Reset
spi_rx_afifo is used to receive data in SPI master and slave transfer. (WT)
SPI_BUF_AFIFO_RST Configures whether or not to reset buf_tx_afifo as shown in Figure 26-4 and
in Figure 26-5.
0: Not reset
1: Reset
buf_tx_afifo is used to send data out in CPU-controlled master and slave transfer. (WT)
SPI_DMA_AFIFO_RST Configures whether or not to reset dma_tx_afifo as shown in Figure 26-4 and
in Figure 26-5.
0: Not reset
1: Reset
dma_tx_afifo is used to send data out in DMA-controlled slave transfer. (WT)
PRELIMINARY
Espressif Systems 724 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
A
AT
_D
UE
EN N
N
DM _B EN N
A_ ITL _EN
TX
TL _E
_E
RD MA TL _E
AL
A_
BI EN
V_ D BI EN
_V
M
IC
SL R F_ L
E_ T
I_ FT NF _D
I_ _W U BIT
CL OD OU
AG
13
SP SO CO AIT
SP SLV DB F_
M A_
E_ ET
_M
D
DE
I_ R_ _W
I_ _R BU
O
SP K_ AT
AV ES
G
M
O
SE
D
SP SLV WR
SP US FD
SL _R
M
CL _
A_
I_ CK
I_ T_
K_
)
)
I_ _
ed
ed
ed
SP SLV
DM
SP S
SP RS
rv
rv
M
er
se
se
I_
I_
I_
I_
I_
s
SP
SP
SP
SP
(re
(re
(re
31 30 29 28 27 26 25 22 21 12 11 10 9 8 7 4 3 2 1 0
0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 725 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
SPI_SOFT_RESET Configures whether to reset the SPI clock line, CS line, and data line via software.
0: Not reset
1: Reset
Can be configured in CONF state. (WT)
SPI_USR_CONF Configures whether or not to enable the CONF state of the current DMA-controlled
configurable segmented transfer.
0: No effect, which means the current transfer is not a configurable segmented transfer.
1: Enable, which means a configurable segmented transfer is started.
(R/W)
PRELIMINARY
Espressif Systems 726 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
D
AN
N
M
R
LE
M
DD
T
CO
BI
_A
_
T_
TA
ST
DA
LA
LA
V_
V_
_
LV
SL
SL
S
I_
I_
I_
SP
SP
SP
31 26 25 18 17 0
0 0 0 Reset
SPI_SLV_DATA_BITLEN Configures the transferred data bit length in SPI slave full-/half-duplex
modes. (R/W/SS)
E
PR
_N
_H
U_
L
T_
_
NT
NT
Q
IV
CN
_E
KC
KC
KD
d)
LK
LK
ve
CL
CL
CL
C
C
r
se
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
(re
31 30 22 21 18 17 12 11 6 5 0
SPI_CLKCNT_L In master transfer, this field must be equal to SPI_CLKCNT_N. In slave mode, it must
be 0. Can be configured in CONF state. (R/W)
SPI_CLKCNT_H Configures the duty cycle of SPI_CLK (high level) in master transfer.
It’s recommended to configure this value to floor((SPI_CLKCNT_N + 1)/2 - 1). floor() here is to
round a number down, e.g., floor(2.2) = 2. In slave mode, it must be 0.
Can be configured in CONF state. (R/W)
PRELIMINARY
Espressif Systems 727 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
E N
K_
)
se d)
I_ d)
ed
(re rve
SP rve
CL
rv
se
se
(re
(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
PRELIMINARY
Espressif Systems 728 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
VE
I
CT
_A
K
CL
DE
DE
DE
DE
_H
O
M
_M
_M
_M
G
3_
IN
)
N2
N1
N0
ed
ed
M
IN
rv
rv
DI
DI
DI
TI
D
se
se
I_
I_
I_
I_
I_
SP
SP
SP
SP
SP
(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 0 0 0 Reset
PRELIMINARY
Espressif Systems 729 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
PRELIMINARY
Espressif Systems 730 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
UM
UM
UM
NU
_N
_N
_N
_
d)
N3
N2
N1
N0
ve
DI
DI
DI
DI
r
se
I_
I_
I_
I_
SP
SP
SP
SP
(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 Reset
SPI_DIN0_NUM Configures 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
2: Delayed by 3 clock cycles
3: Delayed by 4 clock cycles
Can be configured in CONF state. (R/W)
SPI_DIN1_NUM Configures 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
2: Delayed by 3 clock cycles
3: Delayed by 4 clock cycles
Can be configured in CONF state. (R/W)
SPI_DIN2_NUM Configures 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
2: Delayed by 3 clock cycles
3: Delayed by 4 clock cycles
Can be configured in CONF state. (R/W)
SPI_DIN3_NUM Configures 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
2: Delayed by 3 clock cycles
3: Delayed by 4 clock cycles
Can be configured in CONF state. (R/W)
PRELIMINARY
Espressif Systems 731 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
SP DO 2_ DE
UT _MO E
M E
DE
DO 1 D
0_ D
I_ UT MO
I_ UT MO
O
SP DO 3_
I_ U T
)
ed
SP DO
v
er
I_
s
SP
(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
PRELIMINARY
Espressif Systems 732 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
_E A
NA
NT N
A A
A _I T_E
EN N
NA
T_ _E
EN RR IN
IN INT
_E
T_ _E R_
I_ _ D8 T_ A _E A
NA
SP SLV M A ON NT NA
SP SLV M _IN ON _IN NA
SP SLV WR UF_ ON NA INT
R_ R_
IN LL R
I_ _R _B _IN DO NA
I_ _C M D _I E
R_ FU Y_E
I_ _C DA _D E _E
ER R
I_ _ D9 T_ E_ T_
I_ _ B _D E E_
L_ _E
SP SLV D_ MA ON INT
SP LV R E _ E
SP SLV D_ UF T_ N
ER W T
UL TY
I_ d) D_ O_ MP
I_ _W O AN NT
A_ UTF INT NA
I_ _R _D D E_
FO E A
I_ _E D7 T_ A
I_ _ Q T_ A
I_ A_ QP INT A
_F MP
FI O_ N
E
I
SP SLV CM _IN EN
SP LV N_ IN N
SP DM EX_ PI_ EN
E
SP rve M FIF RE
SP SLV S_ TR R_
IN IF _E
S
DM O I_ _
E
I_ AN G_ ER
se _C _A O_
_
I_ T_ T_ A
I_ T_ _A A
SP MS _IN EN
SP MS TX EN
SP TR SE C_
(re SLV RX FIF
_
I_ P2 T_
I_ A_ GI
D
D
SP DM MA
SP AP _IN
I_ G_
I_ P1
d)
ve
SP AP
SP SE
S
er
I_
s
SP
(re
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 734 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
_C R
LR
NT CL
R R
CL L
R _I T_
T_ _C
LR
CL RR IN
IN INT
_C
T_ _E R_
I_ _ D8 T_ R _C R
LR
SP SLV M A ON NT LR
SP SLV M _IN ON _IN LR
SP SLV WR UF_ ON LR INT
R_ R_
IN LL R
I_ _C M D _I C
I_ _R _B _IN DO LR
I_ _C DA _D E _C
R_ FU Y_E
ER R
I_ _ D9 T_ E_ T_
I_ _ B _D C E_
L_ _E
SP SLV D_ MA ON INT
SP LV R E _ C
SP SLV D_ UF T_ N
ER W T
UL TY
I_ d) D_ O_ MP
I_ _W O AN NT
A_ UTF INT LR
I_ _R _D D E_
FO E R
I_ _E D7 T_ R
I_ _ Q T_ R
I_ A_ QP INT R
_F MP
FI O_ L
E
C
I
SP SLV CM _IN CL
SP LV N_ IN L
SP DM EX_ PI_ CL
IN IF _C
SP rve M FIF RE
SP SLV S_ TR R_
S
DM O I_ _
I_ AN G_ ER
se _C _A O_
_
I_ T_ T_ R
I_ T_ _A R
SP MS _IN CL
SP MS TX CL
SP TR SE C_
(re SLV RX FIF
_
I_ P2 T_
I_ A_ GI
D
D
SP DM MA
SP AP _IN
I_ G_
I_ P1
d)
ve
SP AP
SP SE
S
er
I_
s
SP
(re
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 735 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
PRELIMINARY
Espressif Systems 736 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
_R W
AW
W W
NT A
W _I T_R
RA A
AW
T_ _R
RA RR IN
IN INT
_R
I_ _ D8 T_ W _R W
T_ _E R_
AW
SP SLV M A ON NT AW
SP SLV M _IN ON _IN AW
SP SLV WR UF_ ON AW INT
R_ R_
IN LL R
I_ _R _B _IN DO AW
I_ _C M D _I R
R_ FU Y_E
I_ _C DA _D E _R
ER R
I_ _ D9 T_ E_ T_
I_ _ B _D R E_
L_ _E
SP SLV D_ MA ON INT
SP LV R E _ R
SP SLV D_ UF T_ N
ER W T
UL TY
A_ UTF INT AW
FO E W
I_ d) D_ O_ MP
I_ _W O AN NT
I_ _R _D D E_
I_ _E D7 T_ W
I_ _ Q T_ W
I_ A_ QP INT W
_F MP
FI O_ A
E
I
SP SLV CM _IN RA
SP LV N_ IN A
SP DM EX_ PI_ RA
R
IN IF _R
SP rve M FIF RE
SP SLV S_ TR R_
S
DM O I_ _
I_ AN G_ ER
se _C _A O_
I_ T_ T_ W
I_ T_ _A W
_
SP MS _IN RA
SP MS TX RA
SP TR SE C_
(re SLV RX FIF
_
I_ P2 T_
I_ A_ GI
D
D
SP DM MA
SP AP _IN
I_ G_
I_ P1
d)
ve
SP AP
SP SE
S
er
I_
s
SP
(re
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 737 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
SPI_APP2_INT_RAW The raw interrupt status of SPI_APP2_INT interrupt. The value is only controlled
by the application. (R/WTC)
SPI_APP1_INT_RAW The raw interrupt status of SPI_APP1_INT interrupt. The value is only controlled
by the application. (R/WTC)
PRELIMINARY
Espressif Systems 738 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
NT T
_I T_S
ST T
_S
T_ _S
T
ST RR IN
IN INT
_S
T_ _E R_
R_ R_
SP SLV CM _IN ST INT ST
T
SP SLV M A ON NT T
IN LL R
_S
I_ _C M D _I S
R_ FU Y_E
I_ _C DA _D E _S
ER R
I_ _ D9 T_ E_ T_
I_ _ B _D S E_
_
I_ _R _B _IN DO T
L_ _E
SP SLV D_ MA ON INT
SP LV R E _ S
SP SLV D_ UF T_ N
ER W T
UL TY
I_ d) D_ O_ MP
I_ _W O AN NT
I_ _R _D D E_
A_ UTF INT T
_F MP
E
FI O_ T
I
S
SP SLV CM _IN ST
SP LV N_ IN T
SP DM EX_ PI_ ST
SP rve M FIF RE
IN IF _S
SP SLV S_ TR R_
S
DM O I_ _
FO E
I_ A_ QP INT
I_ _ D8 T_
I_ _E D7 T_
I_ _ Q T_
I_ AN G_ ER
se _C _A O_
_
SP MS _IN ST
SP MS TX ST
SP TR SE C_
(re SLV RX IF
_
I_ T_ _AF
I_ P2 T_
I_ T_ T_
I_ A_ GI
D
D
SP DM MA
SP AP _IN
I_ G_
I_ P1
d)
ve
SP AP
SP SE
S
er
I_
s
SP
(re
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 740 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
_S T
NT SE
ET
T T
SE E
T _I T_
T_ _S
ET
SE RR IN
IN INT
_S
T_ _E R_
I_ _ D8 T_ T _S T
ET
SP SLV M A ON NT ET
SP SLV WR UF_ ON ET INT
R_ R_
IN LL R
I_ _C M D _I S
R_ FU Y_E
I_ _R _B _IN DO ET
I_ _C DA _D E _S
ER R
I_ _ D9 T_ E_ T_
I_ _ B _D S E_
L_ _E
SP SLV D_ MA ON INT
SP LV R E _ S
SP SLV D_ UF T_ N
ER W T
UL TY
I_ d) D_ O_ MP
I_ _W O AN NT
I_ _R _D D E_
A_ UTF INT ET
FI O_ ET
_F MP
I_ _E D7 T_ T
I_ _ Q T_ T
I_ A_ QP INT T
E
I
S
SP SLV CM _IN SE
SP LV N_ IN E
SP DM EX_ PI_ SE
SP rve M FIF RE
IN IF _S
SP SLV S_ TR R_
S
DM O I_ _
FO E
I_ AN G_ ER
se _C _A O_
_
I_ T_ T_ T
I_ T_ _A T
SP MS _IN SE
SP MS TX SE
SP TR SE C_
(re SLV RX FIF
_
I_ P2 T_
I_ A_ GI
D
D
SP DM MA
SP AP _IN
I_ G_
I_ P1
)
ed
SP AP
SP SE
rv
S
se
I_
SP
(re
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 741 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
26 SPI Controller (SPI) GoBack
n
BUF
I_
SP
31 0
0 Reset
AT
ve
D
r
se
I_
SP
(re
31 28 27 0
0 0 0 0 0x2201300 Reset
PRELIMINARY
Espressif Systems 742 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
27.1 Overview
The I2C bus has two lines, namely a serial data line (SDA) and a serial clock line (SCL). Both SDA and SCL lines
are open-drain. Therefore, multiple peripherals can be mounted on the I2C bus, usually with one or more masters
and one or more slaves. However, only one master is allowed to occupy the bus to access one slave at the same
time.
The master initiates communication by generating a START condition: pulling the SDA line low while SCL is high.
Then it issues nine clock pulses via SCL. The first eight pulses are used to transmit a 7-bit address followed by a
read/write (R/W ) bit. If the address of an I2C slave matches the 7-bit address transmitted, this matching slave
can respond by pulling SDA low on the ninth clock pulse. Then, the master and the slave can send or receive
data according to the R/W bit, and terminate the data transfer according to the logic level of the acknowledge
(ACK) bit. During data transfer, SDA changes only when SCL is low. Once the communication has finished, 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 an RSTART condition, a slave address, and a R/W bit before switching between the
operations. The RSTART condition is used to change the transfer direction and the mode of the devices (master
mode or slave mode).
27.2 Features
The I2C controller of ESP32-H2 has the following features:
• Dual address mode, which uses slave address and slave memory or register address
PRELIMINARY
Espressif Systems 743 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
The I2C controller runs either in master mode or slave mode, which is determined by I2C_MS_MODE. Figure
27-1 shows the architecture of a master, while Figure 27-2 shows that of a slave. The I2C controller has the
following main parts:
• Transmit and receive memory (TX/RX RAM): store data to be transmitted and data received respectively.
• Command controller (CMD_Controller): generate (R)START, STOP, WRITE, READ, and END commands
• SCL clock controller (SCL_FSM): generate the timing sequence conforming to the I2C protocol. Figure
PRELIMINARY
Espressif Systems 744 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
27-3 and Figure 27-1 are the timing diagram and corresponding parameters of the I2C protocol.
• SDA data controller (SCL_MAIN_FSM): control the execution of I2C commands and the data sequence of
the SDA line. It also controls the ack_deal module to generate the ACK bit and detect the level of the ACK
bit on the SDA line.
• Serial/parallel data converter (DATA_Shifter): shift data between serial and parallel form
• ACK bit controller (ack_deal): generate the ACK bit and detect the level of the ACK bit on the SDA line
under the control of SCL_MAIN_FSM.
Besides, the I2C controller also has a clock module that generates I2C clocks, and a synchronization module that
synchronizes the APB bus and the I2C controller.
The clock module is used to select clock sources, turn on and off clocks, and divide clocks. The synchronization
module synchronizes signal transfer between different clock domains.
Figure 273. I2C Protocol Timing (Cited from Fig.31 in The I2Cbus specification Version 2.1)
PRELIMINARY
Espressif Systems 745 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
Table 271. I2C Timing Parameters (Cited from Table 5 in The I2Cbus specification Version 2.1)
You can choose the clock source for I2C_SCLK from XTAL_CLK or RC_FAST_CLK via
PCR_I2C_SCLK_SEL:
The clock source then passes through a fractional divider to generate I2C_SCLK according to the following
equation:
P CR_I2C_SCLK_DIV _A
Divisor = P CR_I2C_SCLK_DIV _N U M + 1 +
P CR_I2C_SCLK_DIV _B
Limited by timing parameters, the derived clock I2C_SCLK should operate at a frequency 20 times larger than
SCL’s frequency.
PRELIMINARY
Espressif Systems 746 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
Take SCL_Filter as an example. When enabled, 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 I2C_SCLK
clock cycles. Given that only valid input signals can pass through the filter, SCL_Filter can remove glitches whose
pulse width is shorter than I2C_SCL_FILTER_THRES I2C_SCLK clock cycles, while SDA_Filter can remove
glitches whose pulse width is shorter than I2C_SDA_FILTER_THRES I2C_SCLK clock cycles.
1. Address match: The address of the slave matches the address sent by the master via the SDA line, and the
R/W bit is 1.
2. RAM being full: RX RAM of the slave is full. Note that when the slave receives less data than the FIFO
depth, which is 32 bytes in ESP32-H2 I2C, it is not necessary to enable clock stretching; when the slave
receives FIFO depth bytes or more, you may interrupt data transmission to wrapped around RAM via the
FIFO threshold, or enable clock stretching for more time to process data. When clock stretching is enabled,
I2C_RX_FULL_ACK_LEVEL must be cleared, otherwise, there will be unpredictable consequences.
3. RAM being empty: The slave is sending data, but its TX RAM is empty.
4. Sending an ACK: If I2C_SLAVE_BYTE_ACK_CTL_EN is set, the slave pulls SCL low when sending an ACK
bit. At this stage, software validates data and configures I2C_SLAVE_BYTE_ACK_LVL to control the level of
the ACK bit. Note that when RX RAM of the slave is full, the level of the ACK bit to be sent is determined by
I2C_RX_FULL_ACK_LEVEL, instead of I2C_SLAVE_BYTE_ACK_LVL. In this case,
I2C_RX_FULL_ACK_LEVEL should also be cleared to ensure the proper functioning of clock stretching.
When clock stretching occurs, the cause of stretching can be read from the I2C_STRETCH_CAUSE bit. Clock
stretching can be cleared by setting the I2C_SLAVE_SCL_STRETCH_CLR bit.
27.4.5 Synchronization
I2C registers are configured in the APB_CLK domain, whereas the I2C controller is configured in the
asynchronous I2C_SCLK domain. Therefore, before being used by the I2C controller, register values should be
synchronized by first writing configuration registers and then writing 1 to I2C_CONF_UPGATE. Registers that
need synchronization are listed in Table 27-2.
PRELIMINARY
Espressif Systems 747 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
PRELIMINARY
Espressif Systems 748 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
Because these lines are configured as open-drain, the low-to-high transition time of each line is longer,
determined together by the pull-up resistor and line capacitance. The output duty cycle 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.
Figure 27-4 shows the timing diagram of an I2C master. This figure 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. Timing
parameters (please refer to Table 27-1) are calculated as follows in I2C_SCLK clock cycles:
Timing registers below are divided into two groups, depending on the mode in which these registers are
active:
PRELIMINARY
Espressif Systems 749 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
1. I2C_SCL_START_HOLD_TIME: Specifies the interval between the moment SDA is pulled low and the
moment SCL is pulled low when the master generates a START condition. This interval is
(I2C_SCL_START_HOLD_TIME +1) in I2C_SCLK cycles. 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_LOW_PERIOD
+1) in I2C_SCLK cycles. This register is active only when the I2C controller works in master mode.
3. I2C_SCL_WAIT_HIGH_PERIOD: Specifies time for SCL to switch from low to high in I2C_SCLK cycles.
Please make sure that SCL can 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 I2C_SCLK cycles. This register is active
only when the I2C controller works in master mode. When SCL goes high within
(I2C_SCL_WAIT_HIGH_PERIOD + 1) in I2C_SCLK cycles, its frequency is:
fI2C_SCLK
fscl = I2C_SCL_LOW_PERIOD + I2C_SCL_HIGH_PERIOD + I2C_SCL_WAIT_HIGH_PERIOD + 3 + I2C_SCL_FILTER_THRES
where 3 represents the number of clock cycles required to synchronize the SCL. If the SCL filtering
function is turned on, the delay caused by I2C_SCL_FILTER_THRES needs to be added. As the SCL
low-to-high transition time represented by I2C_SCL_WAIT_HIGH_PERIOD + 1 module clock can be
affected by the pull-up resistor, IO drive capability, SCL line capacitance, etc., deviation may occur
between the actual frequency of the test and the theoretical frequency. At this point, deviations can be
reduced by adjusting the value of I2C_SCL_WAIT_HIGH_PERIOD.
1. 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, so as to correctly
sample the level of SCL. This register is active both in master mode and slave mode.
2. 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.
PRELIMINARY
Espressif Systems 750 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
When SCL_FSM remains unchanged for more than 2I2C_SCL_ST _T O_I2C clock cycles, an I2C_SCL_ST_TO_INT
interrupt is triggered, and then SCL_FSM goes to idle state. The value of I2C_SCL_ST_TO_I2C should be less
than or equal to 22, which means SCL_FSM could remain unchanged for 222 I2C_SCLK clock cycles at most
before the interrupt is generated.
When SCL_MAIN_FSM remains unchanged for more than 2I2C_SCL_M AIN _ST _T O_I2C I2C_SCLK clock cycles,
an I2C_SCL_MAIN_ST_TO_INT interrupt is triggered, and then SCL_MAIN_FSM goes to idle state. The value of
I2C_SCL_MAIN_ST_TO_I2C should be less than or equal to 22, which means SCL_MAIN_FSM could remain
unchanged for 222 clock cycles at most before the interrupt is generated.
Timeout control for SCL is enabled by setting I2C_TIME_OUT_EN. When the level of SCL remains unchanged for
more than 2I2C_T IM E_OU T _V ALU E clock cycles, an I2C_TIME_OUT_INT interrupt is triggered, and then the I2C
bus goes to idle state.
Command registers, whose structure is illustrated in Figure 27-5, are active only when the I2C controller works in
master mode. Fields of command registers are:
1. CMD_DONE: Indicates that a command has been executed. After each command has been executed, the
CMD_DONE bit in the corresponding command register 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:
• WRITE: op_code = 1. The I2C controller sends a slave address, a register address (only in dual
address mode), and data to the slave.
• STOP: op_code = 2. 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.
PRELIMINARY
Espressif Systems 751 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
• READ: op_code = 3. The I2C controller reads data from the slave.
• 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 been completed, and the CMD_Controller
stops executing commands. Once the software refreshes data in command registers and the RAM,
the CMD_Controller can be restarted to execute commands from command register 0 again.
• RSTART: op_code = 6. The I2C controller sends a START bit or an RSTART bit defined by the I2C
protocol.
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 in 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 the ACK 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, there must be a STOP or an END command in the eight command registers.
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, etc. This allows efficient use of
available peripheral RAM and also achieves more flexible I2C communication.
TX RAM stores data that the I2C controller needs to send. During communication, when the I2C controller needs
to send data (except acknowledgment bits), it reads data from TX RAM and sends them sequentially via SDA.
When the I2C controller works in master mode, all data must be stored in TX RAM in the order they need to be
sent to slaves. The data stored in TX RAM include slave addresses, read/write bits, register addresses (only in
dual address mode) and data to be sent. When the I2C controller works in slave mode, TX RAM only stores data
to be sent.
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 the 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 is I2C Base Address + 0x104, the third byte is I2C Base Address + 0x108, and so on.
PRELIMINARY
Espressif Systems 752 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
The CPU can only read TX RAM via direct addresses. Bytes written to the TX RAM can be read back by the CPU,
via the direct addresses. Addresses for reading TX RAM are the same as addresses for writing TX RAM.
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 dual address mode) will be
stored in RX RAM. Values of RX RAM can be read by software after I2C communication completes.
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 the 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 + 0x180) ~(I2C Base Address + 0x1FC). Each byte in RX RAM occupies an
entire word in the address space. Therefore, the address of the first byte is I2C Base Address + 0x180, the
second byte is I2C Base Address + 0x184, the third byte is I2C Base Address + 0x188 and so on.
In FIFO mode, TX RAM of a master may wrap around to send data larger than the FIFO depth. Set
I2C_FIFO_PRT_EN. If the size of data to be sent is smaller than I2C_TXFIFO_WM_THRHD (master), an
I2C_TXFIFO_WM_INT (master) interrupt is generated. After receiving the interrupt, the software continues writing
to I2C_DATA_REG (master). Please ensure that software writes to or refreshes TX RAM before the master sends
data, otherwise it may result in unpredictable consequences.
In FIFO mode, the RX RAM of a slave may also wrap around to receive data larger than the FIFO depth. Set
I2C_FIFO_PRT_EN and clear I2C_RX_FULL_ACK_LEVEL. If data already received (to be overwritten) is larger
than I2C_RXFIFO_WM_THRHD (slave), an I2C_RXFIFO_WM_INT (slave) interrupt is generated. After receiving the
interrupt, the software continues reading from I2C_DATA_REG (slave).
Assume the slave address is SLV_ADDR. In 7-bit addressing mode, the slave address is SLV_ADDR[6:0]; in
10-bit addressing mode, the slave address is SLV_ADDR[9:0].
In 7-bit addressing mode, the master only needs to send one byte of the address, which comprises
SLV_ADDR[6:0] and a R/W bit. In the 7-bit addressing mode, there is a special case called general call
addressing (broadcast). It is enabled by setting I2C_ADDR_BROADCASTING_EN in a slave. When the slave
receives the general call address (0x00) from the master and the R/W bit followed is 0, it responds to the master
regardless of its own address.
In 10-bit addressing mode, the master needs to send two bytes of address. The first byte is
slave_addr_first_7bits followed by a R/W bit, and slave_addr_first_7bits should be configured as (0x78 |
SLV_ADDR[9:8]). The second byte is slave_addr_second_byte, which should be configured as
SLV_ADDR[7:0].
The slave can enable 10-bit addressing by configuring I2C_ADDR_10BIT_EN. I2C_SLAVE_ADDR is used to
configure I2C slave address. Specifically, I2C_SLAVE_ADDR[14:7] should be configured as SLV_ADDR[7:0], and
PRELIMINARY
Espressif Systems 753 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
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. Please refer to Programming Example for detailed descriptions.
When working in slave mode, the I2C controller supports dual address mode, where the first address is the
address of an I2C slave, and the second one is the slave’s memory address. When using dual address mode,
RAM must be accessed in non-FIFO mode. Dual address mode is enabled by setting
I2C_FIFO_ADDR_CFG_EN. When the slave address received by the slave is inconsistent with the internally
configured slave address, the I2C_SLAVE_ADDR_UNMATCH interrupt will be generated.
There are two ways to start the I2C controller in slave mode:
• Set I2C_SLV_TX_AUTO_START_EN, and the slave starts automatic transfer upon an address match.
• Clear I2C_SLV_TX_AUTO_START_EN, and always set I2C_TRANS_START before accepting any transfer.
27.5.1 I2Cmaster Writes to I2Cslave with a 7bit Address in One Command Sequence
PRELIMINARY
Espressif Systems 754 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
27.5.1.1 Introduction
Figure 27-6 shows how I2Cmaster writes N bytes of data to I2Cslave registers or RAM using 7-bit addressing. As
shown in figure 27-6, the first byte in the RAM of I2Cmaster is a 7-bit I2Cslave address followed by a R/W bit.
When the R/W bit is 0, 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, I2Cmaster enables the controller and initiates
data transfer by setting the I2C_TRANS_START bit. The controller has four steps to take:
1. Wait for SCL to go high, to avoid SCL being used by other masters or slaves.
3. Execute a WRITE command by taking N+1 bytes from the RAM in order and sending them to I2Cslave in the
same order. The first byte is the address of I2Cslave .
4. Execute a STOP command. Once the I2Cmaster transfers a STOP bit, an I2C_TRANS_COMPLETE_INT
interrupt is generated.
1. Configure the timing parameter registers of I2Cmaster and I2Cslave according to Section 27.4.7.
PRELIMINARY
Espressif Systems 755 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
5. Write the address of I2Cslave and data to be sent to TX RAM of I2Cmaster in either FIFO mode or non-FIFO
mode according to Section 27.4.10.
6. Write the address of I2Cslave to I2C_SLAVE_ADDR (slave) in the I2C_SLAVE_ADDR_REG (slave) register.
9. I2Cslave compares the slave address sent by I2Cmaster with its own address in I2C_SLAVE_ADDR (slave).
When ack_check_en (master) in I2Cmaster ’s WRITE command is 1, I2Cmaster checks ACK value each time it
sends a byte. When ack_check_en (master) is 0, I2Cmaster does not check the ACK value and takes I2Cslave
as a matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an I2C_NACK_INT
(master) interrupt and stops data transfer.
10. I2Cmaster sends data and determines whether to check ACK value according to ack_check_en (master).
11. If data to be sent (N) is larger than TX FIFO depth, TX RAM of I2Cmaster may wrap around in FIFO mode. For
details, please refer to Section 27.4.10.
12. If data to be received (N) is larger than RX FIFO depth, RX RAM of I2Cslave may wrap around in FIFO mode.
For details, please refer to Section 27.4.10.
If the data to be received (N) is larger than RX FIFO depth, the other way is to enable clock stretching by
setting the I2C_SLAVE_SCL_STRETCH_EN (slave), and clearing I2C_RX_FULL_ACK_LEVEL. When RX
RAM is full, an I2C_SLAVE_STRETCH_INT (slave) interrupt is generated. In this way, I2Cslave can hold SCL
low, in exchange for more time to read data. After the software has finished reading, you can set
I2C_SLAVE_STRETCH_INT_CLR (slave) to 1 to clear interrupt, and set I2C_SLAVE_SCL_STRETCH_CLR
(slave) to release the SCL line.
13. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
27.5.2 I2Cmaster Writes to I2Cslave with a 10bit Address in One Command Sequence
PRELIMINARY
Espressif Systems 756 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
27.5.2.1 Introduction
Figure 27-7 shows how I2Cmaster writes N bytes of data using 10-bit addressing to an I2C slave. The
configuration and transfer process is similar to what is described in 27.5.1, except that a 10-bit I2Cslave address is
formed from two bytes. Since a 10-bit I2Cslave address has one more byte than a 7-bit I2Cslave address,
byte_num and length of data in TX RAM increase by 1 accordingly.
4. Configure I2C_SLAVE_ADDR (slave) in I2C_SLAVE_ADDR_REG (slave) as I2Cslave ’s 10-bit address, and set
I2C_ADDR_10BIT_EN (slave) to 1 to enable 10-bit addressing.
5. Write the address of I2Cslave and data to be sent to TX RAM of I2Cmaster . The first byte of the address of
I2Cslave comprises ((0x78 | I2C_SLAVE_ADDR[9:8])«1) and a R/W bit. The second byte of the address of
I2Cslave is I2C_SLAVE_ADDR[7:0]. These two bytes are followed by data to be sent in FIFO or non-FIFO
mode.
8. I2Cslave compares the slave address sent by I2Cmaster with its own address in I2C_SLAVE_ADDR (slave).
PRELIMINARY
Espressif Systems 757 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
When ack_check_en (master) in I2Cmaster ’s WRITE command is 1, I2Cmaster checks ACK value each time it
sends a byte. When ack_check_en (master) is 0, I2Cmaster does not check the ACK value and takes I2Cslave
as the matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an I2C_NACK_INT
(master) interrupt and stops data transfer.
9. I2Cmaster sends data, and determines whether to check ACK value according to ack_check_en (master).
10. If the data to be sent is larger than TX FIFO depth, TX RAM of I2Cmaster may wrap around in FIFO mode.
For details, please refer to Section 27.4.10.
11. If the data to be received is larger than RX FIFO depth, RX RAM of I2Cslave may wrap around in FIFO mode.
For details, please refer to Section 27.4.10.
If the data to be received is larger than RX FIFO depth, the other way is to enable clock stretching by
setting I2C_SLAVE_SCL_STRETCH_EN (slave), and clearing I2C_RX_FULL_ACK_LEVEL to 0. When RX
RAM is full, an I2C_SLAVE_STRETCH_INT (slave) interrupt is generated. In this way, I2Cslave can hold SCL
low, in exchange for more time to read data. After the software has finished reading, you can set
I2C_SLAVE_STRETCH_INT_CLR (slave) to 1 to clear interrupt, and set I2C_SLAVE_SCL_STRETCH_CLR
(slave) to release the SCL line.
12. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
27.5.3 I2Cmaster Writes to I2Cslave with Two 7bit Addresses in One Command Sequence
27.5.3.1 Introduction
Figure 27-8 shows how I2Cmaster writes N bytes of data to I2Cslave registers or RAM using 7-bit double
addressing. The configuration and transfer process is similar to what is described in Section 27.5.1, except that
PRELIMINARY
Espressif Systems 758 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
in 7-bit dual address mode I2Cmaster sends two 7-bit addresses. The first address is the address of an I2C slave,
and the second one is I2Cslave ’s memory address (i.e. addrM in Figure 27-8). When using double addressing,
RAM must be accessed in non-FIFO mode. The I2C slave put received byte0 ~ byte(N-1) into its RAM in an order
starting from addrM. The RAM is overwritten every 32 bytes.
5. Write the address of I2Cslave and data to be sent to TX RAM of I2Cmaster in FIFO or non-FIFO mode.
6. Write the address of I2Cslave to I2C_SLAVE_ADDR (slave) in the I2C_SLAVE_ADDR_REG (slave) register.
9. I2Cslave compares the slave address sent by I2Cmaster with its own address in I2C_SLAVE_ADDR (slave).
When ack_check_en (master) in I2Cmaster ’s WRITE command is 1, I2Cmaster checks ACK value each time it
sends a byte. When ack_check_en (master) is 0, I2Cmaster does not check ACK value and takes I2Cslave as
a matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an I2C_NACK_INT
(master) interrupt and stops data transfer.
10. I2Cslave receives the RX RAM address sent by I2Cmaster and adds the offset.
11. I2Cmaster sends data, and determines whether to check ACK value according to ack_check_en (master).
12. If data to be sent is larger than TX FIFO depth, TX RAM of I2Cmaster may wrap around in FIFO mode. For
details, please refer to Section 27.4.10.
13. If data to be received is larger than RX FIFO depth, you may enable clock stretching by setting
I2C_SLAVE_SCL_STRETCH_EN (slave), and clearing I2C_RX_FULL_ACK_LEVEL to 0. When RX RAM is
full, an I2C_SLAVE_STRETCH_INT (slave) interrupt is generated. In this way, I2Cslave can hold SCL low, in
exchange for more time to read data. After the software has finished reading, you can set
I2C_SLAVE_STRETCH_INT_CLR (slave) to 1 to clear interrupt, and set I2C_SLAVE_SCL_STRETCH_CLR
(slave) to release the SCL line.
14. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
PRELIMINARY
Espressif Systems 759 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
27.5.4 I2Cmaster Writes to I2Cslave with a 7bit Address in Multiple Command Sequences
27.5.4.1 Introduction
Figure 279. I2Cmaster Writing to I2Cslave with a 7bit Address in Multiple Sequences
Given that the I2C controller RAM holds only the size of TX/RX FIFO depth, when data are too large to be
processed, 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, SCL will be pulled low, and
the software can refresh command sequence registers and the RAM for next the transfer.
Figure 27-9 shows how I2Cmaster writes to an I2C slave in two or three segments as an example. For the first
segment, the CMD_Controller registers are configured as shown in Segment0. Once data in I2Cmaster ’s RAM is
ready and I2C_TRANS_START is set, I2Cmaster initiates data transfer. After executing the END command,
I2Cmaster turns off the SCL clock and pulls 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, the 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 I2Cslave in two segments. I2Cmaster resumes data transfer
PRELIMINARY
Espressif Systems 760 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
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 I2Cmaster are configured as shown in Segment2. Once I2C_TRANS_START is set,
I2Cmaster generates a STOP bit and terminates the transfer.
Note that other I2Cmaster s will not transact on the bus between two segments. The bus is only released after a
STOP command is sent. The I2C controller can be reset by setting I2C_FSM_RST field at any time. This field will
later be cleared automatically by hardware.
4. Write the address of I2Cslave and data to be sent to TX RAM of I2Cmaster in either FIFO mode or non-FIFO
mode according to Section 27.4.10.
5. Write the address of I2Cslave to I2C_SLAVE_ADDR (slave) in the I2C_SLAVE_ADDR_REG (slave) register.
8. I2Cslave compares the slave address sent by I2Cmaster with its own address in I2C_SLAVE_ADDR (slave).
When ack_check_en (master) in I2Cmaster ’s WRITE command is 1, I2Cmaster checks ACK value each time it
sends a byte. When ack_check_en (master) is 0, I2Cmaster does not check the ACK value and takes I2Cslave
as a matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an I2C_NACK_INT
(master) interrupt and stops data transfer.
9. I2Cmaster sends data, and checks ACK value or not according to ack_check_en (master).
10. After the I2C_END_DETECT_INT (master) interrupt is generated, set I2C_END_DETECT_INT_CLR (master)
to 1 to clear this interrupt.
PRELIMINARY
Espressif Systems 761 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
12. Write M bytes of data to be sent to TX RAM of I2Cmaster in FIFO or non-FIFO mode.
13. Write 1 to I2C_TRANS_START (master) bit to start the transfer and repeat step 9.
14. If the command is a STOP, I2C stops the transfer and generates an I2C_TRANS_COMPLETE_INT (master)
interrupt.
18. I2Cmaster executes the STOP command and generates an I2C_TRANS_COMPLETE_INT (master) interrupt.
27.5.5 I2Cmaster Reads I2Cslave with a 7bit Address in One Command Sequence
27.5.5.1 Introduction
Figure 27-10 shows how I2Cmaster reads N bytes of data from an I2C slave using 7-bit addressing. cmd1 is a
WRITE command. When cmd1 is executed, I2Cmaster sends the address of I2Cslave . The byte sent comprises a
7-bit I2Cslave 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 I2Cmaster . I2Cmaster generates
acknowledgments according to ack_value defined in the READ command upon receiving a byte.
As illustrated in Figure 27-10, I2Cmaster 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.
PRELIMINARY
Espressif Systems 762 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
I2Cmaster writes received data into the controller RAM from addr0, whose original content (the address of I2Cslave
and a R/W bit) is overwritten by byte0 marked red in Figure 27-10.
2. It is recommended to set I2C_SLAVE_SCL_STRETCH_EN (slave) to 1, so that SCL can be held low for
more processing time when I2Cslave needs to send data. If this bit is not set, the software should write data
to be sent to I2Cslave ’s TX RAM before I2Cmaster initiates the transfer. The configuration below is applicable
to the scenario where I2C_SLAVE_SCL_STRETCH_EN (slave) is 1.
5. Write the address of I2Cslave to TX RAM of I2Cmaster in either FIFO mode or non-FIFO mode according to
Section 27.4.10.
6. Write the address of I2Cslave to I2C_SLAVE_ADDR (slave) in the I2C_SLAVE_ADDR_REG (slave) register.
10. I2Cslave compares the slave address sent by I2Cmaster with its own address in I2C_SLAVE_ADDR (slave).
When ack_check_en (master) in I2Cmaster ’s WRITE command is 1, I2Cmaster checks ACK value each time it
sends a byte. When ack_check_en (master) is 0, I2Cmaster does not check the ACK value and takes I2Cslave
as a matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an I2C_NACK_INT
(master) interrupt and stops data transfer.
11. After I2C_SLAVE_STRETCH_INT (slave) is generated, the I2C_STRETCH_CAUSE bit is 0. The address of
I2Cslave matches the address sent over SDA, and I2Cslave needs to send data.
12. Write data to be sent to TX RAM of I2Cslave in either FIFO mode or non-FIFO mode according to Section
27.4.10.
PRELIMINARY
Espressif Systems 763 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
14. I2Cslave sends data, and I2Cmaster checks ACK value or not according to ack_check_en (master) in the
READ command.
15. If data to be read by I2Cmaster is larger than the TX FIFO depth of I2Cslave , an I2C_SLAVE_STRETCH_INT
(slave) interrupt will be generated when TX RAM of I2Cslave becomes empty. In this way, I2Cslave can hold
SCL low, so that software has more time to pad data in TX RAM of I2Cslave and read data in RX RAM of
I2Cmaster . After the software has finished reading, you can set I2C_SLAVE_STRETCH_INT_CLR (slave) to 1
to clear interrupt, and set I2C_SLAVE_SCL_STRETCH_CLR (slave) to release the SCL line.
16. After I2Cmaster has received the last byte of data, set ack_value (master) to 1. I2Cslave will stop the transfer
once receiving the I2C_NACK_INT interrupt.
17. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
27.5.6 I2Cmaster Reads I2Cslave with a 10bit Address in One Command Sequence
27.5.6.1 Introduction
Figure 27-11 shows how I2Cmaster reads data from an I2C slave using 10-bit addressing. Unlike 7-bit addressing,
in 10-bit addressing the WRITE command of the I2Cmaster is formed from two bytes, and correspondingly TX
RAM of this master stores a 10-bit address of two bytes. The R/W bit in the first byte is 0, which indicates a
WRITE operation. After an RSTART condition, I2Cmaster sends the first byte of address again to read data from
I2Cslave , but the R/W bit is 1, which indicates a READ operation. The two address bytes can be configured as
described in Section 27.5.2.
PRELIMINARY
Espressif Systems 764 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
2. We recommend setting I2C_SLAVE_SCL_STRETCH_EN (slave) to 1, so that SCL can be held low for more
processing time when I2Cslave needs to send data. If this bit is not set, the software should write data to be
sent to I2Cslave ’s TX RAM before I2Cmaster initiates the transfer. The configuration below is applicable to a
scenario where I2C_SLAVE_SCL_STRETCH_EN (slave) is 1.
5. Configure I2C_SLAVE_ADDR (slave) in I2C_SLAVE_ADDR_REG (slave) as I2Cslave ’s 10-bit address, and set
I2C_ADDR_10BIT_EN (slave) to 1 to enable 10-bit addressing.
6. Write the address of I2Cslave and data to be sent to TX RAM of I2Cmaster in either FIFO or non-FIFO mode.
The first byte of address comprises ((0x78 | I2C_SLAVE_ADDR[9:8])«1) and a R/W bit, which is 1 and
indicates a WRITE operation. The second byte of address is I2C_SLAVE_ADDR[7:0]. The third byte is
((0x78 | I2C_SLAVE_ADDR[9:8])«1) and a R/W bit, which is 1 and indicates a READ operation.
10. I2Cslave compares the slave address sent by I2Cmaster with its own address in I2C_SLAVE_ADDR (slave).
When ack_check_en (master) in I2Cmaster ’s WRITE command is 1, I2Cmaster checks ACK value each time it
sends a byte. When ack_check_en (master) is 0, I2Cmaster does not check ACK value and takes I2Cslave as
a matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an I2C_NACK_INT
(master) interrupt and stops data transfer.
11. I2Cmaster sends an RSTART and the third byte in TX RAM, which is ((0x78 | I2C_SLAVE_ADDR[9:8])«1) and
a R/W bit that indicates READ.
12. I2Cslave repeats step 10. If its address matches the address sent by I2Cmaster , I2Cslave proceed on to the
next steps.
PRELIMINARY
Espressif Systems 765 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
13. After I2C_SLAVE_STRETCH_INT (slave) is generated, the I2C_STRETCH_CAUSE bit is 0. The address of
I2Cslave matches the address sent over SDA, and I2Cslave needs to send data.
14. Write data to be sent to TX RAM of I2Cslave in either FIFO mode or non-FIFO mode according to Section
27.4.10.
16. I2Cslave sends data, and I2Cmaster checks ACK value or not according to ack_check_en (master) in the
READ command.
17. If data to be read by I2Cmaster is larger than the TX FIFO depth of I2Cslave , an I2C_SLAVE_STRETCH_INT
(slave) interrupt will be generated when TX RAM of I2Cslave becomes empty. In this way, I2Cslave can hold
SCL low, so that software has more time to pad data in TX RAM of I2Cslave and read data in RX RAM of
I2Cmaster . After the software has finished reading, you can set I2C_SLAVE_STRETCH_INT_CLR (slave) to 1
to clear interrupt, and set I2C_SLAVE_SCL_STRETCH_CLR (slave) to release the SCL line.
18. After I2Cmaster has received the last byte of data, set ack_value (master) to 1. I2Cslave will stop the transfer
once receiving the I2C_NACK_INT interrupt.
19. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
27.5.7 I2Cmaster Reads I2Cslave with Two 7bit Addresses in One Command Sequence
27.5.7.1 Introduction
Figure 2712. I2Cmaster Reading N Bytes of Data from addrM of I2Cslave with a 7bit Address
PRELIMINARY
Espressif Systems 766 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
Figure 27-12 shows how I2Cmaster reads data from specified addresses in an I2C slave. I2Cmaster sends two bytes
of addresses: the first byte is a 7-bit I2Cslave address followed by a R/W bit, which is 0 and indicates a WRITE;
the second byte is I2Cslave ’s memory address. After an RSTART condition, I2Cmaster sends the first byte of
address again, but the R/W bit is 1 which indicates a READ. Then, I2Cmaster reads data starting from
addrM.
2. We recommend setting I2C_SLAVE_SCL_STRETCH_EN (slave) to 1, so that SCL can be held low for more
processing time when I2Cslave needs to send data. If this bit is not set, the software should write data to be
sent to I2Cslave ’s TX RAM before I2Cmaster initiates the transfer. The configuration below is applicable to a
scenario where I2C_SLAVE_SCL_STRETCH_EN (slave) is 1.
7. Write the address of I2Cslave and data to be sent to TX RAM of I2Cmaster in either FIFO or non-FIFO mode
according to Section 27.4.10. The first byte of address comprises ( I2C_SLAVE_ADDR[6:0])«1) and a R/W
bit, which is 0 and indicates a WRITE. The second byte of the address is memory address M of I2Cslave .
The third byte is ( I2C_SLAVE_ADDR[6:0])«1) and a R/W bit, which is 1 and indicates a READ.
11. I2Cslave compares the slave address sent by I2Cmaster with its own address in I2C_SLAVE_ADDR (slave).
When ack_check_en (master) in I2Cmaster ’s WRITE command is 1, I2Cmaster checks ACK value each time it
sends a byte. When ack_check_en (master) is 0, I2Cmaster does not check the ACK value and takes I2Cslave
as a matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
PRELIMINARY
Espressif Systems 767 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an I2C_NACK_INT
(master) interrupt and stops data transfer.
12. I2Cslave receives memory address sent by I2Cmaster and adds the offset.
13. I2Cmaster sends an RSTART and the third byte in TX RAM, which is ((0x78 | I2C_SLAVE_ADDR[9:8])«1) and
an R bit.
14. I2Cslave repeats step 11. If its address matches the address sent by I2Cmaster , I2Cslave proceed on to the
next steps.
15. After I2C_SLAVE_STRETCH_INT (slave) is generated, the I2C_STRETCH_CAUSE bit is 0. The address of
I2Cslave matches the address sent over SDA, and I2Cslave needs to send data.
16. Write data to be sent to TX RAM of I2Cslave in either FIFO mode or non-FIFO mode according to Section
27.4.10.
18. I2Cslave sends data, and I2Cmaster checks ACK value or not according to ack_check_en (master) in the
READ command.
19. If data to be read by I2Cmaster is larger than the TX FIFO depth of I2Cslave , an I2C_SLAVE_STRETCH_INT
(slave) interrupt will be generated when TX RAM of I2Cslave becomes empty. In this way, I2Cslave can hold
SCL low, so that software has more time to pad data in TX RAM of I2Cslave and read data in RX RAM of
I2Cmaster . After the software has finished reading, you can set I2C_SLAVE_STRETCH_INT_CLR (slave) to 1
to clear interrupt, and set I2C_SLAVE_SCL_STRETCH_CLR (slave) to release the SCL line.
20. After I2Cmaster has received the last byte of data, set ack_value (master) to 1. I2Cslave will stop the transfer
once receiving the I2C_NACK_INT interrupt.
21. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
27.5.8 I2Cmaster Reads I2Cslave with a 7bit Address in Multiple Command Sequences
PRELIMINARY
Espressif Systems 768 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
27.5.8.1 Introduction
Figure 27-13 shows how I2Cmaster reads (N+M) bytes of data from an I2C slave in two/three segments separated
by END commands. Configuration procedures are described as follows:
1. The procedures for Segment0 is similar to 27-10, except that the last command is an END.
2. Prepare data in the TX RAM of I2Cslave , and set I2C_TRANS_START to start data transfer. After executing
the END command, I2Cmaster refreshes command registers and the RAM as shown in Segment1, and
clears the corresponding I2C_END_DETECT_INT interrupt. If cmd2 in Segment1 is a STOP, then data is
read from I2Cslave in two segments. I2Cmaster 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 I2Cslave in three segments. After the second data
PRELIMINARY
Espressif Systems 769 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
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, I2Cmaster terminates the transfer by sending a STOP bit.
2. We recommend setting I2C_SLAVE_SCL_STRETCH_EN (slave) to 1, so that SCL can be held low for more
processing time when I2Cslave needs to send data. If this bit is not set, the software should write data to be
sent to I2Cslave ’s TX RAM before I2Cmaster initiates the transfer. The configuration below is applicable to a
scenario where I2C_SLAVE_SCL_STRETCH_EN (slave) is 1.
6. Write the address of I2Cslave to I2C_SLAVE_ADDR (slave) in the I2C_SLAVE_ADDR_REG (slave) register.
10. I2Cslave compares the slave address sent by I2Cmaster with its own address in I2C_SLAVE_ADDR (slave).
When ack_check_en (master) in I2Cmaster ’s WRITE command is 1, I2Cmaster checks ACK value each time it
sends a byte. When ack_check_en (master) is 0, I2Cmaster does not check ACK value and takes I2Cslave as
a matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an I2C_NACK_INT
(master) interrupt and stops data transfer.
11. After I2C_SLAVE_STRETCH_INT (slave) is generated, the I2C_STRETCH_CAUSE bit is 0. The address of
I2Cslave matches the address sent over SDA, and I2Cslave needs to send data.
12. Write data to be sent to TX RAM of I2Cslave in either FIFO mode or non-FIFO mode according to Section
27.4.10.
14. I2Cslave sends data, and I2Cmaster checks ACK value or not according to ack_check_en (master) in the
READ command.
PRELIMINARY
Espressif Systems 770 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
15. If data to be read by I2Cmaster in one READ command (N or M) is larger than the TX FIFO depth of I2Cslave ,
an I2C_SLAVE_STRETCH_INT (slave) interrupt will be generated when TX RAM of I2Cslave becomes empty.
In this way, I2Cslave can hold SCL low, so that software has more time to pad data in TX RAM of I2Cslave and
read data in RX RAM of I2Cmaster . After the software has finished reading, you can set
I2C_SLAVE_STRETCH_INT_CLR (slave) to 1 to clear interrupt, and set I2C_SLAVE_SCL_STRETCH_CLR
(slave) to release the SCL line.
16. Once finishing reading data in the first READ command, I2Cmaster executes the END command and triggers
an I2C_END_DETECT_INT (master) interrupt, which is cleared by setting I2C_END_DETECT_INT_CLR
(master) to 1.
17. Update I2Cmaster ’s command registers using one of the following two methods:
Or
18. Write M bytes of data to be sent to TX RAM of I2Cslave . If M is larger than the TX FIFO depth, then repeat
step 12 in FIFO or non-FIFO mode.
19. Write 1 to I2C_TRANS_START (master) bit to start the transfer and repeat step 14.
20. If the last command is a STOP, then set ack_value (master) to 1 after I2Cmaster has received the last byte of
data. I2Cslave stops transfer upon the I2C_NACK_INT interrupt. I2Cmaster executes the STOP command to
stop the transfer and generates an I2C_TRANS_COMPLETE_INT (master) interrupt.
21. If the last command is an END, then repeat step 16 and proceed to the next steps.
24. I2Cmaster executes the STOP command to stop transfer, and generates an I2C_TRANS_COMPLETE_INT
(master) interrupt.
PRELIMINARY
Espressif Systems 771 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
27.6 Interrupts
• 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].
• 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_END_DETECT_INT: Triggered when op_code of the master indicates an END command and an END
condition is detected.
• 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_TIME_OUT_INT: Triggered when SCL stays high or low for more than 2I2C_T IM E_OU T _V ALU E clock
cycles during data transfer.
• 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_TXFIFO_OVF_INT: Triggered when the I2C controller writes TX FIFO via the APB bus, but TX FIFO is full.
• I2C_RXFIFO_UDF_INT: Triggered when the I2C controller reads RX FIFO via the APB bus, but RX FIFO is
empty.
• I2C_SCL_ST_TO_INT: Triggered when the state machine SCL_FSM remains unchanged for over
I2C_SCL_ST_TO_I2C[23:0] clock cycles.
• I2C_SCL_MAIN_ST_TO_INT: Triggered when the main state machine SCL_MAIN_FSM remains unchanged
for over I2C_SCL_MAIN_ST_TO_I2C[23:0] clock cycles.
• I2C_DET_START_INT: Triggered when the master or the slave detects a START signal.
• I2C_SLAVE_STRETCH_INT: Generated when one of the four stretching events occurs in slave mode.
• I2C_SLAVE_ADDR_UNMATCH_INT: Triggered when the received slave address is inconsistent with the
internally configured slave address in slave mode.
PRELIMINARY
Espressif Systems 772 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 773 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
PRELIMINARY
Espressif Systems 774 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
27.8 Registers
The addresses in this section are relative to I2C Controller base address provided in Table 4-2 in Chapter 4
System and Memory.
D
IO
ER
_P
W
_LO
d)
CL
ve
_S
ser
C
(re
I2
31 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SCL_LOW_PERIOD Configures the low level width of the SCL Clock in Master mode.
Measurement unit: I2C_SCLK
(R/W)
E
IM
_T
LD
HO
A_
)
ed
D
rv
_S
se
C
(re
I2
31 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SDA_HOLD_TIME Configures the time to hold the data after the falling edge of SCL.
Measurement unit: I2C_SCLK
(R/W)
SD
rv
se
C_
(re
I2
31 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 775 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
D
IO
ER
D
P
IO
H_
ER
G
HI
P
H_
T_
AI
G
HI
W
L_
_
d)
CL
ve
SC
_S
er
C_
s
C
(re
I2
I2
31 16 15 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_SCL_HIGH_PERIOD Configures for how long SCL remains high in Master mode.
Measurement unit: I2C_SCLK
(R/W)
I2C_SCL_WAIT_HIGH_PERIOD Configures the SCL_FSM’s waiting period for SCL high level in Mas-
ter mode.
Measurement unit: I2C_SCLK
(R/W)
E
M
TI
_
LD
HO
T_
AR
ST
L_
)
ed
C
v
_S
ser
C
(re
I2
31 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 Reset
I2C_SCL_START_HOLD_TIME Configures the time between the falling edge of SDA and the falling
edge of SCL for a START condition.
Measurement unit: I2C_SCLK
(R/W)
PRELIMINARY
Espressif Systems 776 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
E
M
TI
P_
TU
SE
RT_
TA
_RS
)
ed
CL
rv
_S
se
C
(re
I2
31 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 Reset
I2C_SCL_RSTART_SETUP_TIME Configures the time between the positive edge of SCL and the
negative edge of SDA for a RESTART condition.
Measurement unit: I2C_SCLK
(R/W)
E
IM
_T
LD
HO
P_
O
ST
L_
)
ed
C
rv
_S
se
C
(re
I2
31 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 Reset
SC
rv
se
C_
(re
I2
31 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 Reset
I2C_SCL_STOP_SETUP_TIME Configures the time between the rising edge of SCL and the rising
edge of SDA.
Measurement unit: I2C_SCLK
(R/W)
PRELIMINARY
Espressif Systems 777 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
C2
_I
TO
T_
_S
)
ed
CL
rv
S
se
C_
(re
I2
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 0x10 Reset
I2C_SCL_ST_TO_I2C Configures the threshold value of SCL_FSM state unchanged period. It should
be no more than 23.
Measurement unit: I2C_SCLK
(R/W)
2C
_I
O
_T
ST
N_
AI
M
L_
d)
ve
SC
r
se
C_
(re
I2
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 0x10 Reset
PRELIMINARY
Espressif Systems 778 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
_E EN
N
_
C_ M P _ H E
N
C_ B T E R K
I2 FS _U TO _C G_
I2 AR RS AT TA EC
F U W N
FO E EV L
RC _OU EL
A_ RC L_L VE
C_ N A R TI
I2 O X_ IT_ AS
UT
SD FO C LE
E_ T
N
_ G S
_E
C_ _ 0B C
C_ L_ _S _
O
C_ AN _F ST
C_ _F E T
C_ _ ST T
I2 SLV _1 AD
I2 SC LE CK
I2 X N N
I2 RX OD AR
I2 MS S_ RS
SB IR
IO
O
P A
I
C_ L F
C_ M _
C_ K_ T
C_ D R
I2 TX_ SB_
I2 CL RA
I2 SA ULL
I2 AD _B
M
T
T
R
R
C_ _L
d)
I
C_ D
ve
I2 AD
I2 R
C
T
r
se
C_
(re
I2
31 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 1 0 0 0 Reset
I2C_RX_FULL_ACK_LEVEL Configures the ACK value that needs to be sent by master when
rx_fifo_cnt has reached the threshold.
(R/W)
I2C_TRANS_START Configures whether the slave starts sending the data in TX FIFO.
0: No effect
1: Start (WT)
I2C_TX_LSB_FIRST Configures whether or not to control the sending order for data needing to be
sent.
0: Send data from the most significant bit
1: Send data from the least significant bit
(R/W)
I2C_RX_LSB_FIRST Configures whether or not to control the storage order for received data.
0: Receive data from the most significant bit
1: Receive data from the least significant bit
(R/W)
PRELIMINARY
Espressif Systems 780 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
UE
L
N
VA
_E
_
UT
UT
O
O
E_
E_
d)
IM
IM
ve
T
er
C_
C_
s
(re
I2
I2
31 6 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x10 Reset
I2C_TIME_OUT_VALUE Configures the timeout threshold period for SCL stucking at the high or low
level. The actual period is 2I2C_T IM E_OU T _V ALU E .
Measurement unit: I2C_SCLK
(R/W)
R
IT
DD
B
10
_A
R_
E
AV
)d
DD
ve
SL
_A
er
C_
s
C
(re
I2
I2
31 30 15 14 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_ADDR_10BIT_EN Configures whether to enable the slave 10-bit addressing mode in Master
mode.
0: No effect
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 781 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
HD
HD
N _E
HR
HR
_E FG
_T
_T
IF _C
I2 RX FO EN
T
I2 FIF IFO ST
NO _A S
M
M
NF DDR
C_ O _R
I _
C_ _F _R
_W
_W
C_ F T
O
I2 TX_ PR
FO
FO
_
d)
C_ O
FI
FI
ve
I2 FIF
RX
TX
er
C_
C_
C_
s
(re
I2
I2
I2
31 15 14 13 12 11 10 9 5 4 0
I2C_FIFO_ADDR_CFG_EN Configures the slave to enable dual address mode. When this mode is
enabled, the byte received after the I2C address byte represents the offset address in the I2C Slave
RAM.
0: Disable
1: Enable
(R/W)
I2C_FIFO_PRT_EN Configures whether to enable FIFO pointer in non-FIFO access mode. This bit
controls the valid bits and the TX/RX FIFO overflow, underflow, full and empty interrupts.
0: No effect
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 782 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
ES
ES
HR
HR
ER N
N
LT E
_T
_E
_T
FI R_
ER
ER
L_ LTE
LT
LT
SC _FI
FI
FI
A_
L_
)
ed
C_ A
SC
I2 SD
SD
rv
se
C_
C_
C_
(re
I2
I2
I2
31 10 9 8 7 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 Reset
I2C_SCL_FILTER_THRES Configures the threshold pulse width to be filtered on SCL. When a pulse
on the SCL input has smaller width than this register value, the I2C controller will ignore that pulse.
Measurement unit: I2C_SCLK
(R/W)
I2C_SDA_FILTER_THRES Configures the threshold pulse width to be filtered on SDA. When a pulse
on the SDA input has smaller width than this register value, the I2C controller will ignore that pulse.
Measurement unit: I2C_SCLK
(R/W)
PRELIMINARY
Espressif Systems 783 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
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 0 0 Reset
I2C_SCL_RST_SLV_EN Configures whether or not to send out SCL pulses when I2C master is IDLE.
The number of pulses equals to I2C_SCL_RST_SLV_NUM[4:0]. (R/W/SC)
I2C_SCL_PD_EN Configures whether or not to power down the I2C output SCL line.
0: Not power down
1: Power down
Valid only when I2C_SCL_FORCE_OUT is 1. (R/W)
I2C_SDA_PD_EN Configures whether or not to power down the I2C output SDA line.
0: Not power down
1: Power down
Valid only when I2C_SDA_FORCE_OUT is 1. (R/W)
PRELIMINARY
Espressif Systems 784 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
H_ LR
RE H N
UM
EN
ST TC _E
TC _C
L_ RE TL
_N
E_ L_ CK VL
SC ST _C
AV SC _A _L
CT
SL E_ TE CK
TE
C_ AV Y A
O
I2 SL E_B TE_
PR
H_
C_ AV Y
I2 SL E_B
TC
RE
C_ AV
)
ed
ST
I2 SL
rv
se
C_
C_
(re
I2
I2
31 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 0 0 0 0 0 Reset
I2C_STRETCH_PROTECT_NUM Configures the time period to release the SCL line from stretching
to avoid timing violation. Usually it should be larger than the SDA setup time.
Measurement unit: I2C_SCLK
(R/W)
I2C_SLAVE_SCL_STRETCH_EN Configures whether to enable slave SCL stretch function. The SCL
output line will be stretched low when I2C_SLAVE_SCL_STRETCH_EN is 1 and stretch event hap-
pens. The stretch cause can be seen in I2C_STRETCH_CAUSE.
0: Disable
1: Enable
(R/W)
I2C_SLAVE_SCL_STRETCH_CLR Configures whether or not to clear the I2C slave SCL stretch func-
tion.
0: No effect
1: Clear
(WT)
I2C_SLAVE_BYTE_ACK_CTL_EN Configures whether to enable the function for slave to control ACK
level.
0: Disable
1: Enable
(R/W)
I2C_SLAVE_BYTE_ACK_LVL Configures the ACK level when slave controlling ACK level function en-
ables.
0: Low level
1: High level
(R/W)
PRELIMINARY
Espressif Systems 785 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
T
AS
D
_L
SE
SE
E
T
AS
AT
se B_ SY ES
AU
ST
_L
(re AR BU DR
NT
NT
_C
N_
TE
SP RW
EC
T
C_ S D
_C
CH
_C
C_ d S
TA
I2 BU E_A
AI
I2 rve LO
_R
RE E_
O
_M
O
_S
ET
IF
_
F
C_ AV
C_ AV
)
d)
C_ )
)
ed
ed
ed
FI
CL
CL
TR
XF
ve
I2 SL
I2 SL
TX
rv
rv
R
_S
S
er
er
se
se
C_
C_
C_
C_
s
s
C
(re
(re
(re
(re
I2
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
0 0 0 0 0 0 0 0x3 0 0 0 0 0 0 0 0 0 Reset
I2C_RESP_REC Represents the received ACK value in Master mode or Slave mode.
0: ACK
1: NACK
(RO)
I2C_ARB_LOST Represents whether the I2C controller loses control of SCL line.
0: No arbitration lost
1: Arbitration lost
(RO)
I2C_SLAVE_ADDRESSED Represents whether the address sent by the master is equal to the ad-
dress of the slave.
Valid only when the module is configured as an I2C Slave.
0: Not equal
1: Equal
(RO)
PRELIMINARY
Espressif Systems 786 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
I2C_SCL_STATE_LAST Represents 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
DR
DR
O
_P
AD
AD
AD
AD
RW
_W
_W
_R
_R
E_
FO
FO
FO
IF
AV
)
d)
ed
FI
FI
FI
F
e
RX
RX
SL
TX
TX
rv
rv
se
se
C_
C_
C_
C_
C_
(re
(re
I2
I2
I2
I2
I2
31 30 29 22 21 20 19 15 14 10 9 5 4 0
0 0 0 0 0 0 0 0 0 Reset
I2C_RXFIFO_RADDR Represents the offset address of the APB reading from RX FIFO. (RO)
I2C_RXFIFO_WADDR Represents the offset address of i2c module receiving data and writing to RX
FIFO. (RO)
I2C_TXFIFO_RADDR Represents the offset address of I2C module reading from TX FIFO. (RO)
I2C_TXFIFO_WADDR Represents the offset address of APB bus writing to TX FIFO. (RO)
I2C_SLAVE_RW_POINT Represents the offset address in the I2C Slave RAM addressed by I2C Mas-
ter when in I2C Slave mode. (RO)
PRELIMINARY
Espressif Systems 787 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
TA
DA
_R
)
O
ed
F
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 0 Reset
AW
C_ L_ IN NT N W _R
AW
FI _W _IN _R T_ W
I2 RX DE NS OS T_R AW
I2 SC MA _I H_I RA NT
RX O VF NT _IN A
W
W
C_ DF T _ AW AW
FO M T AW R
C_ IF O _I E _R
_ I
C_ C O W AW A
_L IN R
C_ FI TE _D T_ A
C_ L_ R C T _
I2 NA O_ RA _R T_R
I2 EN _TR ON F_ NT_
I2 SC STA RET _IN CH
I2 AR TX MP RA AW
I2 TXF O_ CT ON INT
I2 _U ST_ _ST _R _R
M T_ W
W
AW
NT W
L T
C_ T C T_ _R
C_ IF T NT _IN
I D I
C_ T_ T L A
_W _IN _RA
C_ TE T U _
W
C_ E ST W A
_I RA
I2 BY TRA O_ ETE
I2 DE E_S CA NM
I2 TIM S_ RA _R
_R
I2 MS S_ IN NT
TO
I
C_ AV L _U
C_ AN T T_
F L
C_ AN T IN
I2 TR _OU AR
I2 SL RA DR
I2 XF IN _I
I2 TR _IN F_
O
T
_
_
_ O
K V
_
A
C_ N D
C_ B FI
I2 GE E_A
_
E
F
_
C_ AV
)
I
d
C_ D
ve
I2 SL
T
r
se
C_
(re
I2
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 Reset
PRELIMINARY
Espressif Systems 788 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
PRELIMINARY
Espressif Systems 789 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
LR
C_ L_ IN NT N R _C
LR
FI _W _IN _C T_ R
I2 SC MA _I H_I CL NT
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
_ I
_L IN C
C_ C O IN LR L
C_ L_ R C T _
C_ FI TE _D T_ L
I2 NA O_ F_ _C T_C
I2 EN _TR ON F_ NT_
I2 SC STA RET _IN CH
I2 TXF O_ CT ON INT
I2 AR TX MP CLR LR
I2 RX ST_ _ST _C _C
M T_ R
L T
LR
C_ T C T_ _C
T
NT R
C_ IF U NT _IN
I D I
C_ T_ T L A
C_ AN T IN L
C_ TE T U _
_W _IN _CL
C_ E ST R L
_I CL
I2 BY TRA O_ ETE
I2 TR _IN F_ T_C
I2 DE E_S CA NM
I2 TIM S_ CL _C
_C
I2 MS S_ IN NT
FO O TO
I
C_ AV L _U
C_ AN T T_
F L
I2 TR _OU AR
I2 SL RA DR
I2 XF _ _I
T
_
_
D
_ O
K V
_
A
C_ N D
C_ B FI
I2 GE E_A
E
F
_
C_ AV
)
I
ed
C_ D
I2 SL
rv
T
se
C_
(re
I2
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 790 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
NA
C_ L_ IN NT N A _E
A
FI _W _IN _E T_ A
I2 SC MA _I H_I EN NT
I2 RX DE NS OS T_E NA
FO M T NA EN
RX O VF NT _IN N
A
A
FO O TO A A
C_ IF O _I E _E
_ I
C_ C O IN A N
_L IN E
C_ FI TE _D T_ N
C_ L_ R C T _
I2 EN _TR ON F_ NT_
I2 SC STA RET _IN CH
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
L T
NA
T
NT A
C_ T C T_ _E
C_ IF U NT _IN
I D I
C_ AN T IN N
C_ T_ T L A
_W _IN _EN
C_ TE T U _
C_ E ST A N
_I EN
A
I2 BY TRA O_ ETE
I2 DE E_S CA NM
I2 TR _IN F_ T_E
I2 MS S_ IN NT
I2 TIM S_ EN _E
_E
T
I
C_ AV L _U
C_ AN T T_
F L
C_ FI T _
I2 TR _OU AR
I2 SL RA DR
I2 XF _ _I
T
_
_
D
_ O
K V
_
A
C_ N D
C_ B FI
I2 GE E_A
E
F
_
C_ AV
d)
C_ D
ve
I2 SL
T
er
C_
s
(re
I2
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 791 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
T
_S
I2 SC MA _I H_I ST NT
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
_ I
_L IN S
T
C_ L_ R C 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 SC STA RET _IN CH
I2 TXF O_ CT ON INT
I2 RX ST_ _ST _ST _S
I2 AR TX MP ST T
L T
C_ T C T_ _S
C_ IF U NT _IN
I D I
C_ T_ T L A
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 DE E_S CA NM
I2 TR _IN F_ T_S
I2 TIM S_ _ST _S
I2 MS S_ _IN INT
_S
FO O TO
M T_
T
NT
C_ AV L _U
C_ AN T T_
F L
C_ FI T _
I2 TR _OU AR
I2 SL RA DR
I2 XF _ _I
T
_ O
K V
_
C_ E ST
A
C_ N D
C_ B FI
I2 GE E_A
E
F
_
C_ AV
)
I
ed
C_ D
I2 SL
rv
T
se
C_
(re
I2
31 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 792 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
D0
AN
AN
M
M
M
M
d)
O
CO
ve
_C
r
se
C_
C
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 793 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
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 0 Reset
D2
AN
AN
M
M
M
M
)
ed
CO
O
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 0 Reset
PRELIMINARY
Espressif Systems 794 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
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 0 Reset
D4
AN
AN
M
M
M
M
)
ed
CO
O
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 0 Reset
PRELIMINARY
Espressif Systems 795 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
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 0 Reset
D6
AN
AN
M
M
M
M
)
ed
CO
O
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 0 Reset
PRELIMINARY
Espressif Systems 796 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
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 0 Reset
31 0
0x2201172 Reset
31 0
0 Reset
PRELIMINARY
Espressif Systems 797 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
27 I2C Controller (I2C) GoBack
DR
AD
T_
R
TA
_S
O
IF
XF
R
C_
I2
31 0
0 Reset
PRELIMINARY
Espressif Systems 798 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
28.1 Overview
ESP32-H2 has a built-in I2S interface, which provides a flexible communication interface for streaming digital
data in multimedia applications, especially digital audio applications.
The I2S standard bus defines three signals, namely, 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-H2 provides separate transmit (TX) and receive (RX)
units for high performance.
28.2 Terminology
To better illustrate the functionality of I2S, the following terms are used in this chapter.
Master mode As a master, I2S drives BCK/WS signals and sends data to or re-
ceives data from a slave.
Slave mode As a slave, I2S is driven by BCK/WS signals and receives data from
or sends data to a master.
Fullduplex There are two separate data lines. Transmitted and received data
are carried simultaneously.
Halfduplex Only one side, the master or the slave, sends data first, and the
other side receives data. Sending data and receiving data can not
happen at the same time.
Alaw and µlaw A-law and µ-law are compression/decompression algorithms in
digital pulse code modulated (PCM) non-uniform quantization,
which can effectively improve the signal-to-quantization noise ra-
tio.
TDM RX mode In this mode, pulse code modulated (PCM) data is received and
stored into memory via direct memory access (DMA), utilizing time
division multiplexing (TDM). The signal lines include BCK, WS, and
SD. Data from 16 channels at most can be received. TDM Philips
standard, TDM MSB alignment standard, and TDM PCM standard
are supported in this mode, depending on user configuration.
Normal PDM RX mode In this mode, pulse density modulation (PDM) data is received and
stored in memory via DMA. Used signals include WS and DATA.
PDM standard is supported in this mode by user configuration.
TDM TX mode In this mode, pulse code modulated (PCM) data is sent from mem-
ory via DMA, in a way of time division multiplexing (TDM). The signal
lines include BCK, WS, and DATA. Data up to 16 channels can be
sent. TDM Philips standard, TDM MSB alignment standard, and
TDM PCM standard are supported in this mode, depending on user
configuration.
Normal PDM TX mode In this mode, pulse density modulation (PDM) data is sent from
memory via DMA. The signal lines include WS and DATA. PDM stan-
dard is supported in this mode by user configuration.
PRELIMINARY
Espressif Systems 799 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
PCMtoPDM TX mode In this mode, I2S as a master, converts the pulse code modulated
(PCM) data from memory via DMA into pulse density modulation
(PDM) data, and then sends the data out. Used signals include
WS and DATA. PDM standard is supported in this mode by user
configuration.
28.3 Features
The I2S module has the following features:
– PDM standard
Note:
In slave mode, due to the frequency limitation of the clock source, the maximum sampling frequency of the ESP32-H2 I2S
is limited by the data bit width and the number of channels. For example, sampling frequencies up to 187.5 kHz (such as
8 kHz, 16 kHz, 32 kHz, 44.1 kHz, 48 kHz, 88.2 kHz, 96 kHz, and 128 kHz) are supported in 32-bit two-channel sampling.
Please refer to Section 28.6 for detailed information.
PRELIMINARY
Espressif Systems 800 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
CPU DMA
I2S
RX Unit
I2S_MCLK_out
TDM RX
RX FIFO I2SI_BCK_in/ RX
PDM RX I2SI_BCK_out
Compress
I2SI_WS_in/
I2SI_WS_out
TX Unit
Decompress I2SI_SD_in
TDM TX
TX FIFO I/O
PDM TX Sync
TX
I2SO_SD_out
PCM-to-PDM
TX I2SO_BCK_in/
I2SO_BCK_out
I2SO_WS_in/
XTAL_CLK BCK I2SO_WS_out
PLL_F96M_CLK
Clock Generator I2S_TX/RX_CLK
PLL_F64M_CLK
I2S_MCLK_in
Figure 28-1 shows the structure of the ESP32-H2 I2S module, consisting of:
• 64 x 32-bit TX FIFO
• 64 x 32-bit RX FIFO
• Compress/Decompress units
The I2S module supports direct memory access (DMA) to internal memory. For more information, see Chapter 3
GDMA Controller (GDMA).
Both the TX unit and the RX unit have a three-line interface that uses a bit clock line (BCK), a word select line
(WS), and a serial data line (SD). The SD line of the TX unit is used for data output and the SD line of the RX unit
for data input. BCK and WS signal lines for the TX unit and the RX unit can be configured as master output mode
or slave input mode.
The signal bus of the I2S module is shown at the right part of Figure 28-1. The naming of these signals in RX and
TX units follows the pattern of I2SA_B_C, such as I2SI_BCK_in.
PRELIMINARY
Espressif Systems 801 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
– BCK
– WS
– SD
Note:
Any required signals of I2S must be mapped to the chip’s pins via GPIO matrix. For more information, see Chapter 6 IO
MUX and GPIO Matrix (GPIO, IO MUX).
• I2S_TX/RX_TDM_EN
• I2S_TX/RX_PDM_EN
PRELIMINARY
Espressif Systems 802 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
• I2S_TX/RX_MSB_SHIFT
– 1: WS signal changes one BCK clock cycle earlier than SD signal, i.e., enable Philips standard or
select PCM standard
Note:
I2S_TX/RX_TDM_EN and I2S_TX/RX_PDM_EN must not be configured to 1 or 0 at the same time, otherwise ESP32-H2
I2S will send data incorrectly in a mode that is neither TDM nor PDM.
Compared with the Philips standard, TDM Philips standard supports multiple channels. See Figure 28-2.
Compared with MSB alignment standard, TDM MSB alignment standard supports multiple channels. See Figure
28-3.
PRELIMINARY
Espressif Systems 803 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
Compared with PCM standard, TDM PCM standard supports multiple channels. See Figure 28-4.
PRELIMINARY
Espressif Systems 804 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
• 40 MHz XTAL_CLK
• 96 MHz PLL_F96M_CLK
• 64 MHz PLL_F64M_CLK
The serial clock (BCK) of the I2S TX/RX unit is divided from I2S_TX/RX_CLK, as shown in Figure 28-6.
PCR_I2S_TX/RX_CLKM_SEL is used to select clock source for TX/RX unit, and PCR_I2S_TX/RX_CLKM_EN to
enable or disable the clock source.
PCR_I2S_TX_CLKM_SEL[1:0]
XTAL_CLK
0 1 I2SO_BCK_out
PLL_F96M_CLK MO
1 1 I2S_TX_CLK
PLL_F64M_CLK b
2 N+
a
I2S_MCLK_in PCR_I2S_MCLK_SEL
3
0 I2S_MCLK_out
PCR_I2S_RX_CLKM_SEL[1:0]
1
XTAL_CLK
0
PLL_F96M_CLK
1 1 I2S_RX_CLK
PLL_F64M_CLK b
2 N+
a
I2S_MCLK_in 1 I2SI_BCK_out
3 MI
PRELIMINARY
Espressif Systems 805 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
The following formula shows the relation between I2S_TX/RX_CLK frequency fI2S_TX/RX_CLK and the divider clock
source frequency fI2S_CLK_S :
fI2S_CLK_S
fI2S_TX/RX_CLK =
N + ba
N is an integer value between 2 and 256. The value of N is mapped to that of PCR_I2S_TX/RX_CLKM_DIV_NUM
in register PCR_I2S_TX/RX_CLKM_CONF_REG as follows:
• When PCR_I2S_TX/RX_CLKM_DIV_NUM = 1, N = 2;
The values of “a” and “b” in fractional divider depend only on x, y, z, and yn1. The corresponding formulas are as
follows:
Note:
Using fractional divider may introduce some clock jitter.
In master TX mode, the serial clock BCK for I2S TX unit is I2SO_BCK_out divided from I2S_TX_CLK, which
is:
fI2S_TX_CLK
fI2SO_BCK_out =
MO
Note:
Note that I2S_TX_BCK_DIV_NUM must not be configured as 1.
In master RX mode, the serial clock BCK for I2S RX unit is I2SI_BCK_out divided from I2S_RX_CLK, which
is:
fI2S_RX_CLK
fI2SI_BCK_out =
MI
PRELIMINARY
Espressif Systems 806 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
Note:
• In I2S slave mode, make sure fI2S_TX/RX_CLK >= 8 * fBCK . The I2S module can output I2S_MCLK_out as the master
clock for peripherals.
Note:
The I2S module clock must be configured first before the module and FIFO are reset.
• I2S_TX_SLAVE_MOD
– 0: Master TX mode
– 1: Slave TX mode
• I2S_RX_SLAVE_MOD
– 0: Master RX mode
– 1: Slave RX mode
– If I2S_TX_STOP_EN is set and all the data in FIFO is transmitted, the master stops transmitting data
and clock signals.
– If I2S_TX_STOP_EN is cleared and all the data in FIFO is transmitted, meanwhile no new data is filled
into FIFO, the TX unit keeps sending the last data frame and clock signal.
– Set I2S_TX_START.
PRELIMINARY
Espressif Systems 807 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
– If I2S_TX_STOP_EN is set and all the data in FIFO is transmitted, then the slave keeps sending zeros,
till the master stops providing BCK signal.
– If I2S_TX_STOP_EN is cleared and all the data in FIFO is transmitted, meanwhile no new data is filled
into FIFO, the TX unit keeps sending the last data frame.
– If I2S_TX_START is cleared, slave keeps sending zeros till the master stops providing BCK clock
signal.
* 1: The RX unit suspends data receiving when I2S_RX_START is cleared or the number of
received bytes is greater than the value configured in I2S_RX_EOF_NUM_REG;
* 2: The RX unit suspends data receiving when I2S_RX_START is cleared or DMA RX FIFO is full.
– Set I2S_RX_START.
– Wait for master BCK signal to start receiving data. Configure I2S_RX_STOP_MODE to control the
suspension of data receiving:
* 1: The RX unit will suspend data receiving when the number of received bytes is greater than the
value configured in I2S_RX_EOF_NUM_REG;
* 2: The RX unit will suspend data receiving when DMA RX FIFO is full.
– The RX unit stops receiving data when the bit I2S_RX_START is cleared.
Note:
Updating the configuration described in this and subsequent sections requires to set I2S_TX_UPDATE accordingly to
synchronize registers from APB clock domain to TX clock domain. For more detailed configuration, see Section 28.11.1.
In TX mode, I2S first reads data through DMA and sends these data out via output signals according to the
configured data mode and channel mode.
PRELIMINARY
Espressif Systems 808 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
• Phase II: Read the TX data from TX FIFO and convert the data according to the output data mode;
The bit width of valid data in each channel is determined by I2S_TX_BITS_MOD and I2S_TX_24_FILL_EN. For
details, see the table below.
When I2S reads data through DMA, the data endian under various data width is controlled by
I2S_TX_BIG_ENDIAN. Table 28-4 shows how I2S_TX_BIG_ENDIAN controls the data reading with different
channel valid data widths.
Channel Valid Data Width Original Data Endian of Processed Data I2S_TX_BIG_ENDIAN
{B3, B2, B1, B0} 0
32 {B3, B2, B1, B0}
{B0, B1, B2, B3} 1
{B2, B1, B0} 0
24 {B2, B1, B0}
{B0, B1, B2} 1
{B1, B0} 0
16 {B1, B0}
{B0, B1} 1
8 {B0} {B0} x
Note:
B0, B1, B2, B3 each represents 8-bit data, and the symbol {} means that the bytes are combined together. For example,
{B3, B2, B1, B0} represents a 32-bit number, wherein B0 represents bit 0-7, B1 represents bit 8-15, B2 represents bit
16-23, and B3 represents bit 24-31.
ESP32-H2 I2S compresses/decompresses the valid data into 32-bit by A-law or by µ-law. If the bit width of valid
data is smaller than 32, zeros are filled to the extra high bits of the data to be compressed/decompressed by
default.
PRELIMINARY
Espressif Systems 809 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
Note:
Extra high bits here mean the bits[31: channel valid data width] of the data to be compressed/decompressed.
Configure I2S_TX_PCM_BYPASS:
Configure I2S_TX_PCM_CONF:
• If TX data width in each channel is larger than the valid data width, zeros will be filled to these extra bits.
Configure I2S_TX_LEFT_ALIGN:
– 0: The valid data is at the lower bits of TX data. Zeros are filled into higher bits of TX data;
– 1: The valid data is at the higher bits of TX data. Zeros are filled into lower bits of TX data.
• If the TX data width in each channel is smaller than the valid data width, only the lower bits of valid data are
sent out, and the higher bits are discarded.
At this point, the data format control is completed. Figure 28-7 shows the complete process of TX data format
control.
PRELIMINARY
Espressif Systems 810 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
• Most stereo I2S codecs can be controlled by setting the I2S module into 2-channel mode under TDM standard.
In TDM TX mode, I2S supports up to 16 channels to send data. The total number of TX channels in use is
controlled by I2S_TX_TDM_TOT_CHAN_NUM. For example, if I2S_TX_TDM_TOT_CHAN_NUM is set to 5, six
channels in total (channel 0 ~ 5) will be used to transmit data. See Figure 28-8.
PRELIMINARY
Espressif Systems 811 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
• I2S_TX_TDM_WS_WIDTH: The cycles the WS default level lasts for when transmitting all channel data.
• I2S_TX_CHAN_EQUAL = 1, i.e., data of the previous channel will be transmitted if the bit
I2S_TX_TDM_CHANn_EN is cleared. n = 0 ~ 5.
• I2S_TX_TDM_CHAN1/3/4_EN = 0, i.e., these channels send the previous channel’s data out.
I2S_TX_TDM_CHAN_NUM = 5; I2S_TX_CHAN_EQUAL = 1;
I2S_TX_TDM_CHAN0_EN = 1; I2S_TX_TDM_CHAN1_EN = 0; I2S_TX_TDM_CHAN2_EN = 1;
I2S_TX_TDM_CHAN3_EN = 0; I2S_TX_TDM_CHAN4_EN = 0; I2S_TX_TDM_CHAN5_EN = 1;
ESP32-H2 I2S supports two PDM TX modes, namely, normal PDM TX mode and PCM-to-PDM TX mode.
In PDM TX mode, fetching data through DMA is controlled by I2S_TX_MONO and I2S_TX_MONO_FST_VLD.
See Table 28-5. Please configure the two bits according to the data stored in memory, be it the single-channel or
dual-channel data.
When the I2S is in PDM TX master mode, the default level of WS signal is controlled by I2S_TX_WS_IDLE_POL,
and the WS signal frequency is half of the BCK signal frequency. The configuration of WS signal is similar to that
of BCK signal. Please refer to Section 28.6 and Figure 28.6.
PRELIMINARY
Espressif Systems 812 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
In normal PDM TX mode, the I2S channel mode is controlled by I2S_TX_CHAN_MOD and
I2S_TX_WS_IDLE_POL. See the table below.
Mode Channel
Channel Con Left Channel Right Channel Control Select
1
trol Option Field Bit2
Stereo mode Transmit the left channel data Transmit the right channel data 0 x
Transmit the left channel data Transmit the left channel data 1 0
Transmit the right channel data Transmit the right channel data 1 1
Transmit the right channel data Transmit the right channel data 2 0
Transmit the left channel data Transmit the left channel data 2 1
Mono mode 3
Transmit the value of “single” Transmit the right channel data 3 0
Transmit the left channel data Transmit the value of “single” 3 1
Transmit the left channel data Transmit the value of “single” 4 0
Transmit the value of “single” Transmit the right channel data 4 1
1
I2S_TX_CHAN_MOD
2
I2S_TX_WS_IDLE_POL
3
The “single” value is equal to the value of I2S_SINGLE_DATA.
In PCMtoPDM TX mode, the PCM data through DMA is converted to PDM data and then output in PDM
signal format. Configure I2S_PCM2PDM_CONV_EN to enable this mode. The register configuration for
PCM-to-PDM TX mode is as follows:
• Configure 1-line PDM output format or 1-/2-line DAC output mode as the table below:
Note:
1. In PDM output format, SD data of two channels is sent out in one WS period.
2. In DAC output format, SD data of one channel is sent out in one WS period.
OSR = I2S_TX_PDM_SINC_OSR2 × 64
PRELIMINARY
Espressif Systems 813 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
Configure the registers according to needed sampling frequency, upsampling rate, and PDM clock
frequency.
• I2S_TX_MONO = 0, i.e., data is fetched from memory via DMA in both the high and low levels of WS.
• I2S_TX_CHAN_MOD = 2, i.e., mono mode is selected, and the right channel data will be discarded.
• I2S_TX_WS_IDLE_POL = 1, i.e., both the left channel and right channel transmit the left channel data.
Once the configuration is done, assume that the data in memory after data format control is:
Note:
1. The data above refers to the processed data after data format control instead of the original data.
2. The “Left” and “Right” represent channel data, and their bit widths are channel valid data width. Please refer to
Section 28.9.1�
Then the channel data is transmitted after channel mode control as follows.
Left Right
WS(LRCK)
I2S_TX_CHAN_MOD = 2; I2S_TX_WS_IDLE_POL = 1;
Note:
I2S_RX_TDM_EN and I2S_RX_PDM_EN must not be cleared or set simultaneously.
In TDM RX mode, I2S supports up to 16 channels to input data. The total number of RX channels in use is
controlled by I2S_RX_TDM_TOT_CHAN_NUM. For example, if I2S_RX_TDM_TOT_CHAN_NUM is set to 5,
channel 0 ~ 5 will be used to receive data.
• 0: The channel data is invalid and will not be stored into RX FIFO.
• I2S_RX_TDM_WS_WIDTH: The cycles the WS default level lasts for when receiving all channel data.
In PDM RX mode, I2S converts the serial data from channels to the data to be entered into memory.
In PDM RX master mode, the default level of WS signal is controlled by I2S_RX_WS_IDLE_POL. WS frequency is
half of BCK frequency. The configuration of BCK signal is similar to that of WS signal as described in Section
28.6. Note, in PDM RX mode, the value of I2S_RX_HALF_SAMPLE_BITS must be same as that of
I2S_RX_BITS_MOD.
• Phase I: Serial input data is converted into the data to be saved to RX FIFO;
• Phase II: The data is read from RX FIFO and converted according to the input data mode.
PRELIMINARY
Espressif Systems 815 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
The storage data width in each channel is controlled by I2S_RX_BITS_MOD and I2S_RX_24_FILL_EN. See the
table below.
• If the storage data width in each channel is smaller than the received (RX) data width, then only the bits
within the storage data width is saved into memory. Configure I2S_RX_LEFT_ALIGN to:
– 0: Only the lower bits of the received data within the storage data width is stored to memory;
– 1: Only the higher bits of the received data within the storage data width is stored to memory.
• If the received data width is smaller than the storage data width in each channel, the higher bits of the
received data will be filled with zeros and then the data is saved to memory.
The received data is then converted into storage data (to be stored to memory) after some processing, such as
discarding extra bits or filling zeros in missing bits. The endian of the storage data is controlled by
I2S_RX_BIG_ENDIAN under various data width. See the table below.
PRELIMINARY
Espressif Systems 816 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
ESP32-H2 I2S compresses/decompresses the storage data in 32-bit by A-law or by µ-law. By default, zeros are
filled into high bits.
Configure I2S_RX_PCM_BYPASS:
Configure I2S_RX_PCM_CONF:
At this point, the data format control is completed. Data then is stored into memory via DMA.
• 0: Master TX mode
• 1: Slave TX mode
4. Set needed TX data mode and TX channel mode as described in Section 28.9, and then set
I2S_TX_UPDATE.
8. Set I2S_TX_STOP_EN if needed. For more information, please refer to Section 28.8.1.
• In master mode, wait till I2S slave gets ready, then set I2S_TX_START to start transmitting data;
• In slave mode, set I2S_TX_START. When the I2S master supplies BCK and WS signals, I2S slave
starts transmitting data.
10. Wait for the interrupt signals set in Step 6, or check whether the transfer is completed by querying
I2S_TX_IDLE:
• 0: Transmitter is working;
PRELIMINARY
Espressif Systems 817 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
• 0: Master RX mode
• 1: Slave RX mode
4. Set needed RX data mode and RX channel mode as described in Section 28.10, and then set
I2S_RX_UPDATE.
7. Configure DMA inlink, and set the length of RX data by configuring I2S_RX_EOF_NUM_REG.
• 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 BCK and WS signals are received from
the master.
9. The received data is then stored to the specified address of ESP32-H2 memory according the
configuration of DMA. Then the corresponding interrupt set in step 6 is generated.
• I2S_RX_HUNG_INT: Triggered when the data receiving is timed out. For example, if the I2S module is
configured as RX slave mode, but the master does not send data for a long time (specified in
I2S_LC_HUNG_CONF_REG), this interrupt will be triggered.
PRELIMINARY
Espressif Systems 818 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
• I2S_EVT_X_WORDS_SENT: Indicates that the word number sent by I2S TX is equal to or larger than the
value set by I2S_ETM_TX_SEND_WORD_NUM.
• I2S_EVT_X_WORDS_RECEIVED: Indicates that the word number received by I2S RX is equal to or larger
than the value set by I2S_ETM_RX_RECEIVE_WORD_NUM.
In practical applications, I2S’s ETM events can trigger its own ETM tasks. For example, the
I2S_EVT_X_WORDS_SENT event can trigger the I2S_TASK_STOP_TX task, and in this way stop the I2S
operation through ETM.
PRELIMINARY
Espressif Systems 819 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 820 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
28.14 Registers
The addresses in this section are relative to the I2S Controller base address provided in Table 4-2 in Chapter 4
System and Memory.
NE T W
_D E_ T_ W
AW
NT W
O IN RA
RX ON _IN RA
_I _RA
_R
S_ D G _
I2 TX_ UN INT
_
S_ _H G
I2 RX UN
S_ H
)
ed
I2 TX_
v
er
S_
s
(re
I2
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
O IN ST
RX ON _IN ST
T
_I _ST
_S
_D E_ T_
S_ D G _
I2 TX_ UN INT
NT
NE T
_
S_ _H G
I2 RX UN
S_ H
)
ed
I2 TX_
rv
se
S_
(re
I2
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
PRELIMINARY
Espressif Systems 821 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
NE T A
_D E _ T_ A
NA
NT A
O IN EN
RX ON _IN EN
_I _EN
_E
S_ D G _
I2 TX_ UN INT
_
S_ _H G
I2 RX UN
S_ H
)
ed
I2 TX_
rv
se
S_
(re
I2
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
NE T R
_D E_ T_ R
LR
NT R
O IN CL
RX ON _IN CL
_I _CL
_C
S_ D G _
I2 TX_ UN INT
_
S_ _H G
I2 RX UN
S_ H
d)
I2 TX_
e
rv
se
S_
(re
I2
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
PRELIMINARY
Espressif Systems 822 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
LD
UM
I2 rve EFT _E L
SS
RX IG E _V
se _L ILL PO
DE
S_ _F RT OD
O IAN
ET ET
N
NF
S_ _2 ID R
S_ d _ N
S_ _B AT T
_N
CM PA
IG
I2 X D FS
I2 RX S_ DE
S_ _S _MO
(re RX 4_F LE_
ES ES
M
S_ _M CO
O ND
V
I2 RX DM N
Y
AL
I2 RX IT_ N
_
DI
S_ _W OR
_B
S_ _T _E
_ R _R
S_ _B _E
S_ _U O
S_ _S E
_M _E
_
P
_
I2 X AV
I2 RX ON
N
CM
I2 RX DM
RX IFO
CK
TO
A
P
T
L
_B
S_ _P
_P
_P
_S
d)
RX )
ve
RX
I2 RX
RX
I2 X
RX
I2 RX
I2 X
R
R
R
er
S_
S_
S_
S_
S_
s
S
(re
I2
I2
I2
I2
I2
I2
31 27 26 21 20 19 18 17 16 15 14 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 6 0 0 0 0 0 1 0 1 0x1 1 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 823 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
I2S_RX_UPDATE Configures whether to update I2S RX registers from APB clock domain to I2S RX
clock domain.
0: No effect
1: Update
This bit will be cleared by hardware after the register update is done.
(R/W/SC)
I2S_RX_MSB_SHIFT Configures the timing between the WS signal and the MSB of data.
0: Align at the rising edge
1: The WS signal changes one BCK clock earlier
(R/W)
PRELIMINARY
Espressif Systems 824 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
I2S_RX_24_FILL_EN Configures the bit number that the 24-bit channel data is stored to.
0: Store 24-bit channel data to 24 bits
1: Store 24-bit channel data to 32 bits (Extra bits are filled with zeros)
(R/W)
I2S_RX_WS_IDLE_POL Configures the relationship between WS level and which channel data to
receive.
0: WS remains low when receiving left channel data and high when receiving right channel data
1: WS remains high when receiving left channel data and low when receiving right channel data
(R/W)
I2S_RX_BCK_DIV_NUM Configures the divider of BCK in RX mode. Note this divider must not be
configured to 1. (R/W)
PRELIMINARY
Espressif Systems 825 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
TS
BI
TS
H
E_
T
BI
ID
PL
N_
W
M
D
HA
S_
SA
_W
M
_C
F_
S_
M
DM
AL
IT
TD
_H
_B
_T
ed
X_
RX
RX
X
rv
_R
_R
se
S_
S_
S
S
(re
I2
I2
I2
I2
31 27 26 19 18 14 13 9 8 0
I2S_RX_TDM_WS_WIDTH Configures the width of rx_ws_out (WS default level) at idle level in TDM
mode. Width of rx_ws_out at idle level in TDM mode = (I2S_RX_TDM_WS_WIDTH[8:0] +1) x
T_BCK. (R/W)
I2S_RX_TDM_CHAN_BITS Configures RX bit number for each channel in TDM mode. Bit number
expected = I2S_RX_TDM_CHAN_BITS + 1. (R/W)
PRELIMINARY
Espressif Systems 826 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
UT N
N
O _E
_E
se d) _D _M EN
_2 DE
2
SR
(re rve DM AC V_
AC O
O
se P _D N
C_
(re X_ DM _CO
IN
_S
S_ P M
I2 TX_ PD
M
D
2
d)
)
_P
S_ M
ed
ed
ed
ed
ed
ed
ed
ve
I2 PC
TX
rv
rv
rv
rv
rv
rv
rv
T
er
se
se
se
se
se
se
S_
S_
s
(re
(re
(re
(re
(re
(re
(re
I2
I2
31 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 5 4 1 0
I2S_TX_PDM_DAC_MODE_EN Configures whether to enable 1-line PDM output mode or DAC out-
put mode.
0: Enable 1-line PDM output mode
1: Enable DAC output mode
(R/W)
d)
)
_P
ed
ed
ed
e
TX
rv
rv
rv
rv
se
se
se
se
S_
(re
(re
(re
(re
I2
31 26 25 23 22 20 19 10 9 0
PRELIMINARY
Espressif Systems 827 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
UM
S_ _T _P _ N N
S_ _T _P _ N N
S_ _T _P _ N N
_T _P M_ AN EN
_P M_ AN EN
_C AN EN
N0 N
N
I2 RX DM DM HA 7_E
I2 RX DM DM HA 6_E
I2 RX M DM HA 5_E
HA 1_E
_E
RX DM D CH 4_
DM D CH 3_
DM CH 2_
_N
S_ _T _C N EN
S_ _T _C N EN
S_ _T _C N EN
S_ _T _C N EN
S_ _T _C N EN
S_ _T _C N EN
S_ _T _P _ N
AN
S_ _T _P N N
S_ _T _P _ N
I2 X M M A
I2 X M HA _E
I2 RX DM DM _E
I2 RX DM HA 5_
I2 X M HA 4_
I2 RX DM HA 3_
I2 RX DM HA 2_
I2 RX M HA 1_
I2 RX DM HA 0_
CH
CH
C
C
C
1
1
1
1
1
1
9
8
S_ _T _C N
T_
I2 RX M HA
D
O
S_ _T _C
_T
M
I2 RX DM
TD
D
d)
S_ T
X_
_
ve
I2 RX
_R
R
er
S_
s
S
(re
I2
I2
31 20 19 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 0x0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Reset
I2S_RX_TDM_PDM_CHANn_EN (n: 07) Configures whether to enable the valid data input of I2S RX
TDM or PDM channel n.
0: Disable. Channel n only inputs 0
1: Enable
(R/W)
I2S_RX_TDM_CHANn_EN (n: 815) Configures whether to enable the valid data input of I2S RX TDM
channel n.
0: Disable. Channel n only inputs 0
1: Enable
(R/W)
RX
rv
se
S_
(re
I2
31 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x40 Reset
I2S_RX_EOF_NUM Configures the bit length of RX data. Bit length of RX data = (I2S_RX_BITS_MOD
+ 1) x (I2S_RX_EOF_NUM + 1). Once the received data reaches such bit length, a
GDMA_IN_SUC_EOF_CHn_INT interrupt is triggered in the configured DMA RX channel. (R/W)
PRELIMINARY
Espressif Systems 828 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
I2 X_ G_ E VLD
M
I2 TX_ FT _E L
I2 TX_ LAV EN L
SS
C H LY
S_ L IL PO
U
A
K
S_ F T D
S_ C O N
ET ET
S_ M N N
D
NF
S_ 2 ID R
TX M_B IFT
S_ S _ U
S_ B _A N
S_ B T T
_N
_P _S _D
CM PA
AC
I2 TX_ AR MO
I2 TX_ ON DIA
I2 TX_ CK_ LIG
O
I2 TX_ PDA FS
I2 TX_ S_ DE
I2 TX_ TOP EQ
I2 TX_ _F E_
ES ES
S_ M CO
M
IV
TX SB O
I2 TX_ M N
Y
I2 TX_ IT_O N
PB
_
4 L
E L
_
S_ M EN
S_ W R
N_
S_ T _E
S _ S N_
_D
_ R _R
S_ B _E
S_ U O
S_ S E
_
O
I2 TX_ ON
I2 TX_ DM
HA
I2 TX_ HA
TX IFO
K
O
BC
T
_L
I
_C
SI )
S_ P
_P
S_ d
I2 TX_
I2 X_
G
I2 rve
TX
TX
T
se
S_
S_
S_
S_
S_
(re
I2
I2
I2
I2
I2
31 30 29 27 26 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 6 0 0 0 0 0 1 1 1 1 0x0 1 0 0 0 0 1 0 0 0 0 Reset
I2S_TX_STOP_EN Configures whether to stop outputting the BCK signal and the WS signal when
TX FIFO is empty.
0: No effect
1: Stop
(R/W)
I2S_TX_CHAN_EQUAL Configures whether to equalize left channel data and right channel data in
I2S TX mono mode or TDM mode.
0: The I2S_SINGLE_DATA is invalid channel data in I2S TX mono mode or TDM mode
1: The left channel data is equal to right channel data in I2S TX mono mode or TDM mode
(R/W)
PRELIMINARY
Espressif Systems 829 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
I2S_TX_UPDATE Configures whether to update I2S TX registers from APB clock domain to I2S TX
clock domain.
0: No effect
1: Update
This bit will be cleared by hardware after update register done.
(R/W/SC)
I2S_TX_MSB_SHIFT Configures the timing between the WS signal and the MSB of data.
0: Align at the rising edge
1: WS signal changes one BCK clock earlier
(R/W)
I2S_TX_BCK_NO_DLY Configures whether BCK is delayed to generate the rising and falling edges
in master mode.
0: Delayed
1: No delayed
(R/W)
I2S_TX_24_FILL_EN Configures the bit number that the 24 channel bits are stored to.
0: Store 24-bit channel data to 24 bits
1: Store 24-bit channel data to 32 bits (Extra bits are filled with zeros)
(R/W)
I2S_TX_WS_IDLE_POL Configures the relationship between WS and which channel data to send.
0: WS remains low when sending left channel data and high when sending right channel data
1: WS remains high when sending left channel data and low when sending right channel data
(R/W)
I2S_TX_BCK_DIV_NUM Configures the divider of BCK in TX mode. Note this divider must not be
configured to 1. (R/W)
I2S_TX_CHAN_MOD Configures I2S TX channel mode. For more information, see Table 28-6. (R/W)
I2S_SIG_LOOPBACK Configures whether to enable TX unit and RX unit sharing the same WS and
BCK signals.
0: Disable
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 831 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
TS
BI
TS
H
E_
T
BI
ID
PL
N_
W
AM
D
HA
S_
O
_S
_W
_M
_C
LF
M
TS
DM
HA
TD
BI
_T
ed
X_
_
TX
TX
X
rv
_T
_T
se
S_
S_
S
S
(re
I2
I2
I2
I2
31 27 26 19 18 14 13 9 8 0
I2S_TX_TDM_WS_WIDTH Configures the width of tx_ws_out (WS default level) at idle level in TDM
mode. The width of tx_ws_out at idle level in TDM mode = (I2S_TX_TDM_WS_WIDTH[8:0] +1) x
T_BCK. (R/W)
I2S_TX_TDM_CHAN_BITS Configures TX bit number for each channel in TDM mode. Bit number
expected = I2S_TX_TDM_CHAN_BITS + 1. (R/W)
PRELIMINARY
Espressif Systems 832 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
UM
N
_N
_E
S_ T _C N EN
S_ T _C AN _EN
S_ T _C N EN
S_ T _C N EN
S_ T _C N EN
S_ T _C N EN
AN
S_ T _C AN EN
S_ T _C N N
S_ T _C N N
S_ T _C N N
S_ T _C N N
S _ T _C N N
_T _C AN EN
_C AN EN
N0 N
N
SK
I2 TX_ M HA _E
I2 TX_ M HA _E
I2 TX_ M HA _E
I2 TX_ M HA _E
I2 TX_ M HA _E
HA 1_E
_E
I2 TX_ M HA 5_
I2 TX_ M HA 3_
I2 TX_ M HA 2_
I2 TX_ M HA 1_
I2 TX_ M HA 0_
DM H 14
D M H 9_
TX DM H 3_
DM H 2_
CH
M
1
1
1
1
8
7
6
5
4
S_ T _C N
P_
T_
I2 TX_ M HA
KI
S_ T _C
_S
_T
DM
DM
TD
D
D
D
D
D
D
D
D
D
D
D
)
_T
S_ T
ed
X_
I2 TX_
I2 X_
I2 X_
I2 X_
TX
rv
_T
T
se
S_
_
S
S
(re
I2
I2
I2
31 21 20 19 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 0x0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Reset
I2S_TX_TDM_CHANn_EN (n: 015) Configures whether to enable the valid data output of I2S TX
TDM channel n.
0: Channel TX data is controlled by I2S_TX_CHAN_EQUAL and I2S_SINGLE_DATA. See Section
28.9.2.1
1: Enable
(R/W)
PRELIMINARY
Espressif Systems 833 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
M
_D
DM
_D
M
DM
UT
_D
UT
N_
_O
N_
IN
O
_I
S_
S_
I
CK
CK
D_
_W
_W
_B
_B
_S
d)
)
ed
ed
ed
ed
ve
RX
RX
RX
RX
RX
rv
rv
rv
rv
er
se
se
se
se
S_
S_
S_
S_
S_
s
(re
(re
(re
(re
(re
I2
I2
I2
I2
I2
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 2 1 0
I2S_RX_WS_OUT_DM Configures the delay mode of I2S RX WS output signal. For detailed config-
uration values, please refer to I2S_RX_SD_IN_DM. (R/W)
I2S_RX_BCK_OUT_DM Configures the delay mode of I2S RX BCK output signal. For detailed con-
figuration values, please refer to I2S_RX_SD_IN_DM. (R/W)
I2S_RX_WS_IN_DM Configures the delay mode of I2S RX WS input signal. For detailed configuration
values, please refer to I2S_RX_SD_IN_DM. (R/W)
I2S_RX_BCK_IN_DM Configures the delay mode of I2S RX BCK input signal. For detailed configu-
ration values, please refer to I2S_RX_SD_IN_DM. (R/W)
PRELIMINARY
Espressif Systems 834 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
DM
M
DM
_D
M
_D
M
_
D
UT
UT
_
_D
UT
N_
UT
_O
O
IN
O
_I
O
_
S_
S_
CK
D1
D_
BC
W
W
d)
d)
)
_B
_S
_S
d
ed
ed
ed
_
X_
X_
ve
ve
ve
TX
TX
TX
rv
rv
rv
_T
_T
_T
er
er
er
se
se
se
S_
S_
S_
s
s
S
S
(re
(re
(re
(re
(re
(re
I2
I2
I2
I2
I2
I2
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 6 5 4 3 2 1 0
I2S_TX_SD1_OUT_DM Configures the delay mode of I2S TX SD1 output signal. For detailed config-
uration values, please refer to I2S_TX_SD_OUT_DM. (R/W)
I2S_TX_WS_OUT_DM Configures the delay mode of I2S TX WS output signal. For detailed configu-
ration values, please refer to I2S_TX_SD_OUT_DM. (R/W)
I2S_TX_BCK_OUT_DM Configures the delay mode of I2S TX BCK output signal. For detailed con-
figuration values, please refer to I2S_TX_SD_OUT_DM. (R/W)
I2S_TX_WS_IN_DM Configures the delay mode of I2S TX WS input signal. For detailed configuration
values, please refer to I2S_TX_SD_OUT_DM. (R/W)
I2S_TX_BCK_IN_DM Configures the delay mode of I2S TX BCK input signal. For detailed configura-
tion values, please refer to I2S_TX_SD_OUT_DM. (R/W)
PRELIMINARY
Espressif Systems 835 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
T
IF
A
SH
N
_E
_
UT
UT
UT
EO
EO
EO
IM
IM
I
_T
_T
_T
O
O
IF
IF
IF
)
_F
_F
ed
C_
LC
LC
rv
_L
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 Configures tick counter threshold. The tick counter is reset when
counter value >= 88000/2I2S_LC_F IF O_T IM EOU T _SHIF T . (R/W)
31 0
0 Reset
_I
TX
rv
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
PRELIMINARY
Espressif Systems 836 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
28 I2S Controller (I2S) GoBack
UM
UM
_N
RD
_N
O
RD
_W
O
VE
_W
EI
ND
EC
SE
R
X_
X_
_R
_T
)
ed
M
ET
T
rv
_E
se
S_
S
(re
I2
I2
31 20 19 10 9 0
AT
rv
_D
se
S
(re
I2
31 28 27 0
0 0 0 0 0x2208250 Reset
PRELIMINARY
Espressif Systems 837 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
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 input pulse signal (e.g. sig_ch0_un, the input pulse signal for ch0 of unit n ch0)
2. One control signal (e.g. ctrl_ch0_un, the control signal for ch0 of unit n ch0)
29.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)
• Independently filter glitches 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
PRELIMINARY
Espressif Systems 838 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
2. Configuration to Increment, Decrement, or Disable counter mode for control signal’s high and low
states
Figure 29-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 with different counter modes to count 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 active edge can be configured
by software), 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 to 1
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 active edge can be
configured by software), 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 to 1 before pulse_cnt reaches PCNT_CNT_L_LIM_Un, then pulse_cnt
freezes and its counter mode changes.
PRELIMINARY
Espressif Systems 839 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
• Disable mode: Counting is disabled, and the counter value pulse_cnt freezes.
Table 29-1 to Table 29-4 provide information on how to configure the counter mode for channel 0.
Table 291. Counter Mode. Positive Edge of Input Pulse Signal. Control Signal in Low State
Table 292. Counter Mode. Positive Edge of Input Pulse Signal. Control Signal in High State
Table 293. Counter Mode. Negative Edge of Input Pulse Signal. Control Signal in Low State
PRELIMINARY
Espressif Systems 840 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
Table 294. 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. The filter can be enabled with the bit
PCNT_FILTER_EN_Un. It 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 shown on Figure 29-2, 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 which has a 16-bit wide signed register. 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 is greater than or equal to PCNT_CNT_H_LIM_Un, a high limit
interrupt is triggered and PCNT_CNT_THR_H_LIM_LAT_Un is high.
• Minimum count value: When pulse_cnt is less than or equal to PCNT_CNT_L_LIM_Un, a low limit interrupt
is triggered and PCNT_CNT_THR_L_LIM_LAT_Un is high.
29.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.
PRELIMINARY
Espressif Systems 841 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
Figure 29-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 29.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 29-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 29-3
in the following aspects:
PRELIMINARY
Espressif Systems 842 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
Figure 29-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 29-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.
PRELIMINARY
Espressif Systems 843 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 844 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
29.5 Registers
The addresses in this section are relative to Pulse Count Controller base address provided in Table 4-2 in Chapter
4 System and Memory.
U0
0
0
_U
_U
_U
U0
U0
0
E_
NT HR _L _EN _U
_U
_U
DE
DE
DE
_E _EN U0
ILT ER _E 0
U0 U0
N H _L S0 _
U0
D
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
1_
H1
H1
H1
H0
H0
H0
LT
CH
PC CH
FI
_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 Configures the maximum threshold for the filter. Any pulses with width
less than this will be ignored when the filter is enabled.
Measurement unit: APB_CLK cycles.
(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. Configures it to
enable the high limit interrupt. (R/W)
PCNT_THR_L_LIM_EN_Un This is the enable bit for unit n’s thr_l_lim comparator. Configures it to
enable the low limit interrupt. (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 Configures the behavior when the signal input of channel 0 detects a
negative edge.
1: Increment the counter
2: Decrement the counter
0, 3: No effect
(R/W)
PCNT_CH0_POS_MODE_Un Configures the behavior when the signal input of channel 0 detects a
positive edge.
1: Increment the counter
2: Decrement the counter
0, 3: No effect
(R/W)
PRELIMINARY
Espressif Systems 845 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
PCNT_CH1_NEG_MODE_Un Configures the behavior when the signal input of channel 1 detects a
negative edge.
1: Increment the counter
2: Decrement the counter
0, 3: No effect
(R/W)
PCNT_CH1_POS_MODE_Un Configures the behavior when the signal input of channel 1 detects a
positive edge.
1: Increment the counter
2: Decrement the counter
0, 3: No effect
(R/W)
PRELIMINARY
Espressif Systems 846 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
U0
U0
1_
0_
S
ES
RE
HR
TH
T
T_
T_
CN
CN
_
_
NT
NT
PC
PC
31 16 15 0
0
0
_U
_U
IM
MI
_L
_L
_H
_L
NT
NT
_C
_C
NT
NT
PC
PC
31 16 15 0
PCNT_CNT_H_LIM_Un Configures the thr_h_lim value for unit n. When pluse_cnt reaches this value,
the counter will be cleared to 0. (R/W)
PCNT_CNT_L_LIM_Un Configures the thr_l_lim value for unit n. When pluse_cnt reaches this value,
the counter will be cleared to 0. (R/W)
PRELIMINARY
Espressif Systems 847 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
PC T_P T_P CN U2 U3
_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
EN
PC T_P T_P
K_
N N
CL
)
)
ed
ed
PC T_C
_
rv
rv
NT
se
se
N
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 Configures whether or not to enable the registers clock gate of the PCNT module.
0: The clock for registers is enabled when registers are read and written
1: The clock for registers is always on
(R/W)
_P
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 Represents the current pulse count value for unit n. (RO)
PRELIMINARY
Espressif Systems 848 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
0
LA U0
0
_U
_M _U
NT R_T RES AT_ 0
HR RE _LA 0
PC CN TH L_L _L _U0
_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 T_C
_C
ver
se
N
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 Represents the latched value of the low limit event of PCNT_Un
when the threshold event interrupt is valid.
0: Others
1: The current pulse counter equals to thr_l_lim and the low limit event is valid.
(RO)
PCNT_CNT_THR_H_LIM_LAT_Un Represents the latched value of the high limit event of PCNT_Un
when the threshold event interrupt is valid.
0: Others
1: The current pulse counter equals to thr_h_lim and the high limit event is valid.
(RO)
PRELIMINARY
Espressif Systems 849 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
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
PRELIMINARY
Espressif Systems 850 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
29 Pulse Count Controller (PCNT) GoBack
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
PRELIMINARY
Espressif Systems 851 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
30.1 Overview
While programming and debugging an ESP32-H2 project using the UART and JTAG functionality is certainly
possible, it has a few downsides. First of all, both UART and JTAG take up IO pins and as such, fewer pins are
left usable for controlling external signals in software. Additionally, an external chip or adapter is needed for both
UART and JTAG to interface with a host computer, which means it will be necessary to integrate these two
functionalities in the form of external chips or debugging adapters.
In order to alleviate these issues, ESP32-H2 provides a USB Serial/JTAG Controller, which integrates the
functionality of both a USB-to-serial converter as well as a USB-to-JTAG adapter. As this device directly
interfaces with an external USB host using only the two data lines required by USB 2.0, only two pins are
required to be dedicated to this functionality for debugging ESP32-H2.
30.2 Features
The USB Serial/JTAG controller has the following features:
• USB Full-speed device; Hardwired for CDC-ACM (Communication Device Class - Abstract Control Model)
and JTAG adapter functionality
• CDC-ACM:
– Integrates CDC-ACM adherent serial port emulation (plug-and-play on most modern OSes)
– Supports host controllable chip reset and entry into download mode
– Allows fast communication with CPU debugging core using a compact representation of JTAG
instructions
• Two OUT endpoints and three IN endpoints in addition to Control endpoint 0; Up to 64-byte data payload
size
• Internal PHY: very few or no external components needed to connect to a host computer
PRELIMINARY
Espressif Systems 852 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
As shown in Figure 30-1, the USB Serial/JTAG controller consists of a USB PHY, a USB device interface, a JTAG
command processor with an integrated response capture unit, and the CDC-ACM registers. The PHY and
device interface are clocked from a 48 MHz clock derived from the baseband PLL (BBPLL); the
software-accessible side of the CDC-ACM block is clocked from APB_CLK. The JTAG command processor is
connected to the JTAG debugging unit of the main processor; the CDC-ACM registers are connected to the APB
bus and as such can be read from and written to by software running on the main CPU.
Note that while the USB Serial/JTAG device supports USB 2.0 standard, it only supports Full-speed (12 Mbps)
mode but not other modes that the USB 2.0 standard introduced, e.g., the High-speed (480 Mbps) mode.
Figure 30-2 shows the internal details of the USB Serial/JTAG controller on the USB side. The USB Serial/JTAG
controller consists of a USB 2.0 Full-speed device. It contains a control endpoint, a dummy interrupt endpoint,
two bulk input endpoints, and two bulk output endpoints. Together, these form a USB composite device, which
consists of a CDC-ACM USB class device as well as a vendor-specific device implementing the JTAG interface.
On the SoC side, the JTAG interface is directly connected to the RISC-V CPU’s debugging interface, allowing
debugging of programs running on that core. Meanwhile, the CDC-ACM device is exposed as a set of registers,
allowing a program on the CPU to read and write from it. Additionally, the ROM startup code of the SoC contains
code that allows the user to reprogram attached flash memory using this interface.
PRELIMINARY
Espressif Systems 853 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
The CDC-ACM interface accepts the following standard CDC-ACM control requests:
Command Action
SEND_BREAK Accepted but ignored (dummy)
SET_LINE_CODING Accepted, value sent is readable in software
GET_LINE_CODING By default, returns 9600 baud, no parity, 8 databits, 1 stopbit (Can
be changed through software)
SET_CONTROL_LINE_STATE Set the state of the RTS/DTR lines. See Table 30-2
Aside from general-purpose communication, the CDC-ACM interface can also be used to reset ESP32-H2 and
optionally make it enter download mode to flash new firmware. This can be realized by setting the RTS and DTR
lines on the virtual serial port.
PRELIMINARY
Espressif Systems 854 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
Note that if the download mode flag is set when ESP32-H2 is reset, ESP32-H2 will reboot into download mode.
When this flag is cleared and the chip is reset, ESP32-H2 will boot from flash. For specific sequences, please
refer to Section 30.4. All these functions can also be disabled by programming various eFuses. Please refer to
Chapter 5 eFuse Controller (EFUSE) for more details.
USB CDC-ACM serial data is sent to and received from the host in packets of 0 to 64 bytes in size. When enough
CDC-ACM data has accumulated in the host, the host sends a packet to the CDC-ACM receive endpoint, and
the USB Serial/JTAG controller accepts this packet if it has a free buffer. Conversely, the host checks periodically
if the USB Serial/JTAG controller has a packet ready to be sent to the host, and if so, receives this packet.
Firmware can get notified of new data from the host in one of the following two ways. First of all, the
USB_SERIAL_JTAG_SERIAL_OUT_EP_DATA_AVAIL bit will remain set as long as there still is unread host data in
the buffer. Secondly, the availability of data will trigger the USB_SERIAL_JTAG_SERIAL_OUT_RECV_PKT_INT
interrupt. When data is available, it can be read by firmware through repeatedly reading bytes from USB_
SERIAL_JTAG_EP1_REG. The amount of bytes to read can be determined by checking the USB_SERIAL_
JTAG_SERIAL_OUT_EP_DATA_AVAIL bit after reading each byte to see if there is more data to read. After all data
is read, the USB debugging device is automatically readied to receive a new data packet from the host.
When the firmware has data to send, it can put the data in the send buffer and trigger a flush to allow the host to
receive the data in a USB packet. In order to do so, there needs to be space available in the send buffer.
Firmware can check this by reading USB_REG_SERIAL_IN_EP_DATA_FREE. A 1 in this register field indicates
there is still free room in the buffer, and firmware can fill the buffer by writing bytes to the USB_SERIAL_
JTAG_EP1_REG register. Writing the buffer does not immediately trigger sending data to the host until the buffer
is flushed. After the flush, the entire buffer will be ready to be received by the USB host at once. A flush can be
triggered in two ways: 1) after the 64th byte is written to the buffer, the USB hardware will automatically flush the
buffer to the host; or 2) firmware can trigger a flush by writing 1 to USB_SERIAL_JTAG_WR_DONE.
Regardless of how a flush is triggered, the send buffer will be unavailable for firmware to write into until it has
been fully read by the host. As soon as the send buffer has been fully read, the USB_SERIAL_JTAG_
SERIAL_IN_EMPTY_INT interrupt will be triggered, indicating that the send buffer can receive another 64
bytes.
It is possible to handle some out-of-band serial requests in software, specifically, the host setting DTR and RTS
and changing the line state. If the CDC-ACM interface receives a SET_LINE_CODING request, the peripheral can
be configured to trigger a USB_SERIAL_JTAG_SET_LINE_CODE_INT interrupt, at which point the line coding
PRELIMINARY
Espressif Systems 855 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
Finally, the host can read the current line state using GET_LINE_CODING. This event sends back the data in the
USB_SERIAL_JTAG_GET_LINE_CODE_W0_REG register and triggers a
USB_SERIAL_JTAG_GET_LINE_CODE_INT interrupt.
Commands from the host to the JTAG interface are interpreted by the JTAG command processor. Internally, the
JTAG command processor implements a full four-wire JTAG bus, consisting of the TCK, TMS and TDI output
lines to the RISC-V CPU, as well as the TDO line signalling back from the CPU to the JTAG response capture
unit. These signals adhere to the IEEE 1149.1 JTAG standards. Additionally, there is an SRST line to reset
ESP32-H2.
The JTAG command processor parses each received nibble (4-bit value) as a command. As USB data is
received in 8-bit bytes, this means each byte contains two commands. The USB command processor will
execute high-nibble first and low-nibble second. The commands are used to control the TCK, TMS, TDI, and
SRST lines of the internal JTAG bus, as well as to signal the JTAG response capture unit the state of the TDO line
(which is driven by the CPU debugging logic) that needs to be captured.
In the internal JTAG bus, TCK, TMS, TDI, and TDO are connected directly to the JTAG debugging logic of the
RISC-V CPU. SRST is connected to the reset logic of the digital circuitry in ESP32-H2 and a high level on this line
will cause a digital system reset. Note that the USB Serial/JTAG controller itself is not affected by SRST.
bit 3 2 1 0
CMD_CLK 0 cap tms tdi
CMD_RST 1 0 0 srst
CMD_FLUSH 1 0 1 0
CMD_RSV 1 0 1 1
CMD_REP 1 1 R1 R0
• CMD_CLK will set the TDI and TMS as the indicated values and emit one clock pulse on TCK. If the CAP
bit is 1, it will instruct the JTAG response capture unit to capture the state of the TDO line. This instruction
PRELIMINARY
Espressif Systems 856 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
• CMD_RST will set the state of the SRST line as the indicated value. This can be used to reset ESP32-H2.
• CMD_FLUSH will instruct the JTAG response capture unit to flush the buffer of all bits it collected so the
host is able to read them. Note that in some cases, a JTAG transaction will end in an odd number of
commands and as such an odd number of nibbles. In this case, it is allowed to repeat the CMD_FLUSH
command to get an even number of nibbles fitting an integer number of bytes.
• CMD_RSV is reserved in the current implementation. This command will be ignored when received by
ESP32-H2.
• CMD_REP repeats the last (non-CMD_REP) command for a certain number of times. The purpose is to
compress command streams which repeat the CMD_CLK instruction for multiple times. A command such
as CMD_CLK can be followed by multiple CMD_REP commands. The number of repetitions done by one
CMD_REP can be expressed as repetition_count = (R1 × 2 + R0) × (4cmd_rep_count ), where
cmd_rep_count indicates the number of the CMD_REP instruction that went directly before it. A CMD_REP
instruction can be repeated up to five times, for a maximum of 1023 repeats of the initial instruction. Note
that the CMD_REP command is only intended to repeat a CMD_CLK command. Specifically, using it on a
CMD_FLUSH command may lead to an unresponsive USB device, and a USB reset will be required to
recover it.
1. TCK is clocked with the TDI and TMS lines set to 0. No data is captured.
2. TCK is clocked another (0 × 2 + 1) × (40 ) = 1 time with the same settings as step 1.
3. TCK is clocked with the TDI line set to 0 and TMS set to 1. Data on the TDO line is captured.
4. TCK is clocked another (1 × 2 + 0) × (40 ) = 2 times with the same settings as step 3.
5. Nothing happens: (0 × 2 + 0) × (41 ) = 0. Note that this increases cmd_rep_count in the next step.
6. TCK is clocked another (1 × 2 + 1) × (42 ) = 48 times with the same settings as step 3.
In other words, this example stream has the same net effect as that of executing command 1 twice, then
repeating command 3 for 51 times.
PRELIMINARY
Espressif Systems 857 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
As soon as either 64 bytes (512 bits) have been collected or a CMD_FLUSH command is executed, the response
capture unit will make the buffer available for the host to receive. Note that the interface to the USB logic is
double-buffered. Therefore, as long as the USB throughput is sufficient, the response capture unit can always
receive more data. That is to say, while one of the buffers is waiting to be sent to the host, the other can receive
more data. When the host has received data from its buffer and the response capture unit flushes its buffer, the
two buffers exchange position.
This also means that a command stream can cause at most 128 bytes of capture data generated (less if there
are flush commands in the stream) without the host acting to receive the generated data. If more data is
generated anyway, the command stream will pause and the device will not accept more commands until the
generated capture data is read out.
Note that in general, the logic of the response capture unit tries not to send zero-byte responses. For instance,
sending a series of CMD_FLUSH commands will not cause a series of zero-byte USB responses to be sent.
However, in the current implementation, some zero-byte responses may be generated in extraordinary
circumstances. It is recommended to ignore these responses.
• VEND_JTAG_SETDIV sets the divider used. This directly affects the duration of a TCK clock pulse. The
TCK clock pulses are derived from a base clock of 48 MHz, which is divided down using an internal divider.
This control request allows the host to set this divider. Note that on startup, the divider is set to 2, which
means the TCK clock rate will generally be 24 MHz.
• VEND_JTAG_SETIO can bypass the JTAG command processor to set the internal TDI, TDO, TMS, and
SRST lines to given values. These values are encoded in the wValue field in the format of 11’b0, srst, trst,
tck, tms, tdi.
• VEND_JTAG_GETTDO can bypass the JTAG response capture unit to read the internal TDO signal directly.
This request returns one byte of data, of which the least significant bit represents the status of the TDO line.
• GET_DESCRIPTOR is a standard USB request. However, it can also be used with a vendor-specific wValue
of 0x2000 to get the JTAG capabilities descriptor. This returns a certain amount of bytes representing the
PRELIMINARY
Espressif Systems 858 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
following fixed structure, which describes the capabilities of the USB-to-JTAG adapter (as shown in Table
30-5). This structure allows host software to automatically support future revisions of the hardware without
the need for an update.
The JTAG capability descriptors of ESP32-H2 are as follows. Note that all 16-bit values are little-endian.
On the firmware side, very little initialization is needed either. The USB hardware is self-initialized and after
boot-up, if a host is connected and listening on the CDC-ACM interface, data can be exchanged as described
above without any specific setup except for the situation when the firmware optionally sets up an interrupt service
handler.
One thing to note is that there may be situations where either the host is not attached or the CDC-ACM virtual
port is not opened. In such cases, the packets that are flushed to the host will never be picked up and the send
buffer will never be empty. It is important to detect these situations and implement timeout, as this is the only way
to reliably detect whether the port on the host side is closed or not.
Another thing to note is that the USB device is dependent on the BBPLL for the 48 MHz USB PHY clock. If this
PLL is disabled, the USB communication will cease to function.
One scenario where this happens is Deep-sleep. The USB Serial/JTAG controller (as well as the attached RISC-V
CPU) will be entirely powered down in Deep-sleep mode. If a device needs to be debugged in this mode, it may
be preferable to use an external JTAG debugger and a serial interface instead.
The CDC-ACM interface can also be used to reset the SoC and take it into or out of download mode. Generating
the correct sequence of handshake signals can be a bit complicated, since most operating systems only allow
setting or clearing DTR and RTS separately, but not in tandem. Additionally, some drivers (e.g., the standard
CDC-ACM driver on Windows) do not set DTR until RTS is set and the user needs to explicitly set RTS in order to
‘propagate’ the DTR value. The recommended procedures are introduced below.
PRELIMINARY
Espressif Systems 859 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
30.5 Interrupts
• USB_SERIAL_JTAG_JTAG_IN_FLUSH_INT: triggered when flush cmd is received for IN endpoint 2 of JTAG.
• USB_SERIAL_JTAG_RTS_CHG_INT: triggered when level of RTS from USB serial channel is changed.
• USB_SERIAL_JTAG_DTR_CHG_INT: triggered when level of DTR from USB serial channel is changed.
PRELIMINARY
Espressif Systems 860 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
PRELIMINARY
Espressif Systems 861 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 862 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
PRELIMINARY
Espressif Systems 863 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
30.7 Registers
The addresses in this section are relative to USB Serial/JTAG controller base address provided in Table 4-2 in
Chapter 4 System and Memory.
TE
BY
R_
DW
_R
G
TA
_J
AL
RI
d)
E
ve
_S
er
B
s
US
(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
PRELIMINARY
Espressif Systems 864 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
FR IL
A_ AVA
EE
NE _D TA_
DO EP DA
AT
R_ _IN_ EP_
_
IAL UT
TA SER _O
L
AL AG ERIA
W
SE L_J G_S
_
G_
A
US SER L_JT
T
_J
IA
IA
RI
US SER
)
ed
erv
B_
B_
B_
s
US
(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 0 Reset
PRELIMINARY
Espressif Systems 865 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
DE
N
DE IDE
US SER L_JT _DM UP_ NA E_E
RI
ER
US SER L_JT _DM PUL LUE E
ER ERR
_E DG
VA BL
OV
IAL AG _P LUP N
TA PAD LLU N
US SER _JT _PU PAD BRI
_O _OV
W
SE S_
RI
HG NS
G_ PU O
P
Y_ PIN
IAL AG B_ G_
TA EXC _PI
L
VR UL
L
US SER L_JT _US JTA
_
G
U
FH
_P
AL TAG XCH
AG B_
AG LL
EF
EF
_
_
RE
PH
US SER L_JT _US
VR
_V
SE L_J G_E
_
G_
G_
_
G_
AG
AG
AG
AG
TA
A
US SER L_JT
US SER L_JT
_J
_J
_J
_J
_
AL
AL
AL
IA
IA
IA
IA
IA
IA
IA
IA
RI
RI
RI
US SER
US ER
d)
SE
SE
SE
rve
S
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
se
US
US
US
US
(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 1 0 0 0 0 1 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 867 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
AB E
LE
_J G_ ST _D V
US _SE IAL TAG TES _RX M
EN O
TA TE _T M
AL A E TX C
SE AL AG ES RX P
ES US P
T_ B_
B R _ J _ T _D
B_ RI _JT _T T_ _D
RI _JT _T T_ _R
_T _ D
G ST X_
US _SE IAL TAG TES _RX
B R _J _ T
US _SE IAL TAG TES
B R _J _
US _SE IAL TAG
B R _J
US SE AL
B_ RI
d)
US _SE
ve
er
B
s
US
(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 1 1 0 0 0 0 Reset
USB_SERIAL_JTAG_TEST_ENABLE Configures whether to enable the test mode of the USB pad.
0: Resume normal operation
1: Enable the test mode of the USB pad
Enabling the test mode of the USB pad allows the USB pad to be controlled/read using the other
bits in this register.
(R/W)
USB_SERIAL_JTAG_TEST_RX_DP Represents the logical level of the USB D+ pad in test mode.
(RO)
USB_SERIAL_JTAG_TEST_RX_DM Represents the logical level of the USB D- pad in test mode.
(RO)
PRELIMINARY
Espressif Systems 868 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
EN
_
LK
_C
G
TA
J
L_
IA
ER
d)
ve
_S
er
B
s
US
(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 N
_P K_E
EM CL
_M M_
SB E
_U _M
G B
TA US
_J G_
AL A
RI _JT
SE AL
B_ RI
)
ed
US _SE
rv
se
B
US
(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
PRELIMINARY
Espressif Systems 869 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
IS
_D
ST
_R
IP
CH
T_
G R R
TA DT UA
_J G_ B_
TS
AL A S
RI _JT _U
_R
SE AL AG
B_ RI _JT
US _SE IAL
B R
d)
US _SE
ve
er
B
s
US
(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
USB_SERIAL_JTAG_RTS Represents the state of RTS signal as set by the most recent
SET_LINE_CODING command. (RO)
USB_SERIAL_JTAG_DTR Represents the state of DTR signal as set by the most recent
SET_LINE_CODING command. (RO)
31 0
0 Reset
PRELIMINARY
Espressif Systems 870 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
AT
PE
RM
TS
TY
O
BI
_F
Y_
_
AR
TA
RI
CH
DA
PA
_B
_B
_B
ET
ET
ET
_G
_G
_G
G
G
TA
TA
TA
_J
_J
L_
AL
AL
IA
RI
RI
ER
d)
SE
E
ve
_S
_S
B_
er
B
s
US
US
US
(re
31 24 23 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 Reset
TE
PDA
_U
IG
NF
O
_C
G
TA
_J
AL
RI
d )
SE
ve
B_
ser
US
(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
PRELIMINARY
Espressif Systems 871 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
WR
IN_ IFO_ ESE D
R
R
RE TY
ES RD
RIA IN_A IFO_ SET_
T_
_W
JTA SER _OU FIFO EMP
T_
UT IFO_ LL
ET
SE
FU
R
R
RE
_
UT O_W
_R
IFO
F
AF
F
A
A
IAL AG_ RIAL _AFI
F
AF
_
_
T_
_IN
_O
_O
_
L_
G_ RIAL
G_ RIAL
L
IAL
RIA JTAG ERIA
SE
SE
SE
S
S
G_
_
G_
US SERI JTA
US SERI JTA
US SERI JTA
JT
_
_
_
_
_
L_
AL
L
AL
AL
A
US SERI
ER
)
ed
SE
S
erv
B_
B_
B_
B_
B_
B_
s
US
US
(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 1 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 872 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
RR _IN _R NT W
W
US SER L_JT _CR F_E REC _INT D_I _RA
US SER L_JT _CR 16_E _IN _EP AW _RA
W
W
RA
RA
OA NT
T_
_
W V_P RAW
US SER _JT _ST KE ES AYL D_I
_IN
W
T INT W
W
IAL AG _TO S_R _P OA
IAL AG UT_ G_I _RA _RA
IAL AG S_ G_I DE_ _RA
RR T_R 1_
RA
KT
_
JT INT T_R _INT
US SER L_JT _SE ERR _INT RAW
US SER L_JT _IN BU ERO AYL
T_
RI JTA SER L_IN _RA W
O INT
_IN
W
_P
Y
IAL AG UT_ _Z RA
EC
IAL AG RIA _IN _R
_
AG R_ E_C E_
AG UF N_ ET
TA SOF _O MPT
T
SH
US ER _JT _US EP1 RO
US SER _JT _DT LIN OD
LU
N
T
E
IAL _E
A
IAL AG ET_ E_C
AG B_ _Z
U
R
AG _R
_F
US SER L_JT _RT CH
_IN
US SER _JT _O CH
US SER L_JT _G LIN
_
AG T_
C
C
D _
US SER L_JT _SE
_
G_
G_
AG
AG
AG
AG
US SER L_JT
_J
_
AL
IA
IA
IA
IA
IA
IA
IA
IA
IA
US SER
)
ed
SE
S
erv
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
s
US
(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 1 0 0 0 Reset
PRELIMINARY
Espressif Systems 873 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
PRELIMINARY
Espressif Systems 874 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
ST
ST
OA NT
RR _IN _S NT
T_
T_
US SER _JT _ST KE ES AYL D_I
IN
IN
V_ ST
US SER L_JT _CR 16_E _IN _EP T
T_
IAL AG _TO S_R _P OA
IAL AG UT_ G_I _ST _ST
C5 RR T_S 1_
IAL AG S_ G_I DE_ _ST
ST
AG T_S REC NT_
PK
US SER L_JT _IN BU ERO AYL
T_
T INT
O INT
I
US ER _JT _PI _ER _IN T
_IN UT_ Y_
_IN
T
_P
AG UT_ _Z ST
AG UF N_ ET
TA SOF _O MPT
RI JTA SER L_IN _ST
SH
US SER L_JT _US EP1 ERO
US SER _JT _O EP2 NT_
US SER _JT _DT LIN OD
LU
N
T
_E
_IN T
IAL AG ET_ E_C
AG B_ _Z
_F
US SER L_JT _RT CH
US SER _JT _O CH
US SER L_JT _G LIN
A L
AG T_
I
C
AG D_
US SER L_JT _SE
JT
_
G_
G_
AG
AG
IAL AG
US SER L_JT
_J
_
AL
IA
IA
IA
IA
IA
IA
IA
IA
IA
US SER
)
ed
SE
S
erv
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
s
US
(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
PRELIMINARY
Espressif Systems 876 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
RR _IN _E NT A
A
US SER L_JT _CR F_E REC _INT D_I _EN
US SER L_JT _CR 16_E _IN _EP NA _EN
A
A
EN
EN
OA NT
T_
_
US SER _JT _ST KE ES AYL D_I
PK A
US SER L_JT _PI 5_ER _IN NA INT
IN
V_ _EN
A
T INT A
A
T_
IAL AG _TO S_R _P OA
IAL AG UT_ G_I _EN _EN
IAL AG S_ G_I DE_ _EN
1_
EN
JT INT T_R _INT
US SER L_JT _IN BU ERO AYL
T_
O INT
_IN
_P
RR T_E
Y
A
IAL AG UT_ _Z EN
EC
_IN _E
_
AG R_ E_C E_
AG UF N_ ET
TA SOF _O MPT
T
SH
US ER _JT _US EP1 RO
US SER _JT _DT LIN OD
A
LU
N
T
E
IAL _E
N
IAL AG ET_ E_C
AG B_ _Z
U
R
AG _E
_F
US SER L_JT _RT CH
_IN
US SER _JT _O CH
US SER L_JT _G LIN
_
AG T_
IAL AG RI
C
C
D _
US SER L_JT _SE
_
G_
G_
AG
AG
AG
AG
US SER L_JT
_J
_
AL
IA
IA
IA
IA
IA
IA
IA
IA
IA
US SER
)
ed
SE
S
erv
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
s
US
(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
PRELIMINARY
Espressif Systems 877 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
PRELIMINARY
Espressif Systems 878 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
RR _IN _C NT R
R
US SER L_JT _CR F_E REC _INT D_I _CL
US SER L_JT _CR 16_E _IN _EP LR _CL
R
R
CL
CL
OA NT
T_
_
US SER _JT _ST KE ES AYL D_I
PK R
IN
V_ _CL
R
T INT R
R
T_
IAL AG _TO S_R _P OA
IAL AG UT_ G_I _CL _CL
RR T_C 1_
IAL AG S_ G_I DE_ _CL
CL
JT INT T_R _INT
US SER L_JT _IN BU ERO AYL
T_
O INT
_IN
L
_P
Y
R
IAL AG RIA _IN _C
IAL AG UT_ _Z CL
EC
_
AG R_ E_C E_
AG UF N_ ET
TA SOF _O MPT
T
SH
US ER _JT _US EP1 RO
US SER _JT _DT LIN OD
R
LU
N
T
E
IAL _E
L
IAL AG ET_ E_C
AG B_ _Z
U
AG _C
R
_F
US SER L_JT _RT CH
_IN
US SER _JT _O CH
US SER L_JT _G LIN
_
AG T_
C
C
D _
US SER L_JT _SE
_
G_
G_
AG
AG
AG
AG
US SER L_JT
_J
_
AL
IA
IA
IA
IA
IA
IA
IA
IA
IA
US SER
)
ed
SE
S
erv
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
s
US
(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
PRELIMINARY
Espressif Systems 879 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
PRELIMINARY
Espressif Systems 880 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
Y
U IF SE T
PT
_O _F E E
_ L
_C Y
AG T_ O_ T
T
G T _R ES
FO L
FO PT
B_ IAL AG T_F EM
AL G_ _FIF _CN
N_ _EM L
FI FU
NT
FO L
TA OU O R
FI _FU
_ J _ FIF _
B_ IAL AG N_ IFO
O
IF
N_ O
US ER _JT G_I T_F
FI
S AL A U
US ER _JT OU
A N
B_ RI _JT _O
SE _JT _I
_I
_
US SE AL AG
G
TA
B_ RI _JT
JT
_J
L_
US _SE IAL
S AL
I A
B_ RI
RI
B R
US ER
d)
US _SE
US SE
ve
S
B_
er
B
s
US
(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 1 0 0 1 0 Reset
PRELIMINARY
Espressif Systems 881 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
X
DE
IN
E_
AM
FR
F_
O
_S
G
TA
_J
AL
RI
d)
SE
ve
B_
ser
US
(re
31 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
DR
DR
AD
D
E
_A
AT
R_
D
ST
_W
_R
0_
P0
P0
EP
_E
_E
N_
N
N
_I
_I
_I
G
G
TA
TA
TA
_J
_J
_J
AL
AL
AL
RI
RI
RI
d)
SE
SE
SE
e
rv
B_
B_
B_
se
US
US
US
(re
31 16 15 9 8 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
PRELIMINARY
Espressif Systems 882 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
R
DR
DD
AD
E
A
AT
R_
D_
ST
_W
_R
1_
P1
P1
EP
E
E
N_
N_
N_
_I
_I
_I
G
G
TA
TA
TA
_J
_J
_J
AL
AL
IA
RI
RI
ER
d)
SE
E
ve
_S
_S
B_
er
B
s
US
US
US
(re
31 16 15 9 8 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
DR
DR
AD
D
E
_A
AT
R_
D
ST
_W
_R
2_
P2
P2
EP
_E
_E
N_
N
N
_I
_I
_I
G
G
TA
TA
TA
_J
_J
_J
AL
AL
AL
RI
RI
RI
d)
SE
SE
SE
ve
B_
B_
B_
r
se
US
US
US
(re
31 16 15 9 8 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
PRELIMINARY
Espressif Systems 883 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
R
DR
DD
AD
E
A
AT
R_
D_
ST
_W
_R
3_
P3
P3
EP
E
E
N_
N_
N_
_I
_I
_I
G
G
TA
TA
TA
_J
_J
_J
AL
AL
IA
RI
RI
ER
d)
SE
E
ve
_S
_S
B_
er
B
s
US
US
US
(re
31 16 15 9 8 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
DR
DR
AD
AD
TE
R_
D_
TA
W
_R
_S
0_
P0
P0
P
_E
_E
_E
UT
UT
UT
_O
_O
_O
G
G
TA
TA
TA
_J
_J
_J
AL
AL
AL
RI
RI
RI
d)
SE
SE
SE
ve
B_
B_
B_
r
se
US
US
US
(re
31 16 15 9 8 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 884 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
NT
_C
TA
DR
R
DD
DA
AD
E
_A
C_
AT
R_
RD
RE
ST
W
1_
1_
1_
1_
P
EP
EP
_E
_E
_
_
UT
UT
UT
UT
_O
_O
_O
_O
G
G
TA
TA
TA
TA
J
_J
_J
L_
L_
AL
AL
IA
IA
RI
RI
ER
ER
)
ed
SE
E
_S
_S
_S
rv
B_
se
B
US
US
US
US
(re
31 23 22 16 15 9 8 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DR
DR
AD
AD
TE
R_
D_
TA
W
_R
_S
2_
P2
P2
P
_E
_E
_E
UT
UT
UT
_O
_O
_O
AG
AG
G
TA
JT
JT
_J
_
L_
AL
AL
A
RI
RI
RI
d)
SE
SE
SE
e
rv
B_
B_
B_
se
US
US
US
(re
31 16 15 9 8 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 885 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
TE
RA
E_
T
_D
W
_D
G
TA
J
L_
IA
ER
B _S
US
31 0
0 Reset
USB_SERIAL_JTAG_DW_DTE_RATE Represents the value of dwDTERate (in bits per second) set
by host through SET_LINE_CODING command. Note that the value here does not affect the actual
communication speed at all. (RO)
AT
PE
RM
TS
O
_T
BI
_F
Y
A_
AR
RIT
AT
CH
PA
D
_B
_B
_B
G
G
TA
TA
TA
_J
_J
_J
AL
AL
AL
RI
RI
RI
)d
SE
SE
SE
ve
B_
B_
B_
er
s
US
US
US
(re
31 24 23 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 886 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
30 USB Serial/JTAG Controller (USB_SERIAL_JTAG) GoBack
ST
T_
SE
E
_R
US
_B
SB
G _U
TA
_J
AL
RI
d)
SE
rve
B_
se
US
(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
31 0
0x2109220 Reset
PRELIMINARY
Espressif Systems 887 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
ESP32-H2 contains one TWAI controller. The controller 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.
31.1 Features
The TWAI controller on ESP32-H2 supports the following features:
• Standard Frame Format (11-bit ID) and Extended Frame Format (29-bit ID)
– Normal
• Special transmissions:
– Error counters
PRELIMINARY
Espressif Systems 888 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
Single Channel and NonReturntoZero: The bus has only one transmission line for single-channel
communication, which is half-duplex. Synchronization is also implemented in this channel, so 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 data in a dominant state always overrides the other node transmitting
data in a recessive state. The physical implementation on the bus is left to the application level to decide (e.g.,
differential pair or a single wire).
Bit Stuffing: Certain fields of TWAI messages are bit-stuffed. A transmitter that transmits five consecutive bits of
the same value (e.g., dominant value or recessive value) should automatically insert a complementary bit.
Likewise, a receiver that receives five consecutive bits of the same value should treat the next bit as a stuffed bit.
Bit stuffing is applied to the following fields: SOF, arbitration field, control field, data field, and CRC sequence (see
Section 31.2.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 31.2.3 for more details).
MultiMaster: Any node can initiate a transmission. If a transmission is already ongoing, a node will wait until the
current transmission is over before initiating a new transmission.
Message Priority 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 the arbitration.
Error Detection and Signaling: Each node actively monitors the bus for errors, and signals the detected errors
by transmitting an error frame.
Fault Confinement: Each node maintains a set of error counters that are incremented/decremented according
to a set of rules. When the error counters surpass a certain threshold, the 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 on 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 generating a message is a transmitter. The node remains a transmitter until the bus is idle or until
the node loses arbitration. Please note that there could be multiple nodes that act as transmitters during
arbitration.
• Data frame
• Remote frame
• Error frame
PRELIMINARY
Espressif Systems 889 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
• Overload frame
• Interframe space
Data frames are used by nodes to send data to other nodes, and can have a payload of 0 to 8 data bytes.
Remote frames are used for nodes to request a data frame with the same identifier from other nodes, and thus
they do not contain any data bytes. However, data frames and remote frames share many fields. Figure 31-1
illustrates the fields and sub-fields of different frames and formats.
Arbitration Field
When two or more nodes transmit data or remote frames simultaneously, the arbitration field is used to determine
which node will win arbitration of the bus. In the arbitration field, if a node transmits a recessive bit while
detecting a dominant bit, it 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 switch to be a receiver.
The arbitration field primarily consists of a frame identifier that is transmitted from the most significant bit first.
Given that a dominant bit represents a logical 0, and a recessive bit represents a logical 1:
PRELIMINARY
Espressif Systems 890 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
• Given the same ID and format, data frames always prevail over remote frames due to their RTR bits being
dominant.
• Given the same first 11 bits of ID, a Standard Format Data Frame always prevails over an Extended Format
Data Frame due to its SRR bits being recessive.
Control Field
The control field primarily consists of the Data Length Code (DLC) 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 from
the most significant bit first.
Data Field
The data field contains the actual payload data bytes of a data frame. Remote frames do not contain any data
field.
CRC Field
The CRC field primarily consists of a CRC sequence. The CRC sequence is a 15-bit cyclic redundancy code
calculated from 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 indicates that the receiver has
received an effective message from the transmitter.
Table 311. Data Frames and Remote Frames in SFF and EFF
PRELIMINARY
Espressif Systems 891 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
Error Frames
Error frames are transmitted when a node detects a bus error. Error frames notably consist of an Error Flag which
is made up of six 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 from the next bit. However, when a node
detects a CRC error, the error frame will start at the bit following the ACK Delim (see Section 31.2.3 for more
details). The following Figure 31-2 shows different fields of an error frame:
PRELIMINARY
Espressif Systems 892 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
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 cases that can trigger the transmission of an overload frame. Figure 31-3 below shows the bit fields of an
overload frame.
3. A dominant bit is detected at the eighth (last) bit of an Error Delimiter. Note that in this case, TEC and REC
will not be incremented (see Section 31.2.3 for more details).
Transmitting an overload frame due to one of the above cases must also satisfy the following rules:
• The start of an overload frame due to case 1 is only allowed to be started at the first bit time of an expected
intermission.
• The start of an overload frame due to case 2 and 3 is only allowed to be started one bit after detecting the
dominant bit.
PRELIMINARY
Espressif Systems 893 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
The Interframe Space acts as a separator between frames. Data frames and remote frames must be separated
from preceding frames by an Interframe Space, regardless of the preceding frame’s type (data frame, remote
frame, error frame, or overload frame). However, error frames and overload frames do not need to be separated
from preceding frames.
Bit Error
A Bit Error occurs when a node transmits a bit value (i.e., dominant or recessive) but detects an opposite bit (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, ACK Slot, or Passive Error Flag, then detecting a dominant bit will not be
considered as a Bit Error.
Stuff Error
A Stuff Error occurs when six consecutive bits of the same value are detected (which violates the bit-stuffing
encoding rules).
CRC Error
A receiver of a data or remote frame will calculate 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.
Format Error
A Format Error occurs when a format-fixed bit field of a message contains an illegal bit. For example, the r1 and
PRELIMINARY
Espressif Systems 894 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
ACK Error
An ACK Error occurs when a transmitter does not detect a dominant bit at the ACK Slot.
TWAI nodes implement fault confinement by maintaining two error counters in each node, where the counter
values determine the error state. The two error counters are known as the Transmit Error Counter (TEC) and
Receive Error Counter (REC). TWAI has the following error states:
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 and transmit a Passive Error Flag when it
detects an error. Error Passive nodes that have transmitted data or remote frames 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 data).
The TEC and REC are incremented/decremented according to the following rules. Note that more than one
rule can apply to a given message transfer.
1. When a receiver detects an error, the REC is 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 is increased by 8.
3. When a transmitter sends an Error Flag, the TEC is increased by 8. However, the following scenarios are
exempt from this rule:
• A transmitter is Error Passive and no dominant bit is detected when an Acknowledgment Error is
detected and the Passive Error Flag is sent. In this case, the TEC should not be increased.
• A transmitter transmits an Error Flag due to a Stuff Error during Arbitration. If the stuffed 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 while sending an Active Error Flag or Overload Flag, the TEC 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. A node can tolerate 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. Every additional 8 consecutive dominant bits will also
increase the TEC for transmitters or REC for receivers by 8 as well.
PRELIMINARY
Espressif Systems 895 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
7. When a transmitter has transmitted a message, which means getting ACK and no errors until the EOF is
completed, the TEC is decremented by 1, unless the TEC is already at 0.
8. When a receiver successfully receives a message, which means getting no errors before ACK Slot and
successfully sending ACK, the REC is decremented accordingly.
9. A node becomes Error Passive when its TEC and/or REC is greater than or equal to 128. Though the node
becomes Error Passive, it still sends an Active Error Flag. Note that once the REC has reached 128, any
further increases to its value are invalid 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 TWAI protocol allows a TWAI bus to operate at a particular bit rate. However, all nodes within a TWAI bus
must operate at the same bit rate.
• The Nominal Bit Rate is defined as the number of bits transmitted per second.
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 minimum unit of time, and is implemented as some form of a prescaled clock
signal in each node. Figure 31-5 illustrates the segments within a single Nominal Bit Time.
TWAI controller will operate in time steps of one Time Quanta where the state of the TWAI bus is analyzed. If the
bus states in two consecutive Time Quanta are different (i.e., recessive to dominant or vice versa), an edge is
generated. The intersection of PBS1 and PBS2 is considered the Sample Point and the sampled bus value is
considered the value of that bit.
PRELIMINARY
Espressif Systems 896 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
Segment Description
SS The Synchronization Segment (SS) is 1 Time Quantum long. If all nodes are perfectly synchro-
nized, the edge of a bit will lie in the SS.
PBS1 Phase Buffer Segment 1 (PBS1) can be 1 to 16 Time Quanta long. PBS1 is meant to com-
pensate for the physical delay times within the network. PBS1 can also be lengthened for
synchronization purposes.
PBS2 Phase Buffer Segment 2 (PBS2) can be 1 to 8 Time Quanta long. PBS2 is meant to compen-
sate for the information processing time of nodes. PBS2 can also be shortened for synchro-
nization purposes.
Due to clock skew and jitter, the bit timing of nodes on the same bus may become out of phase. Therefore, a bit
edge may come before or after the SS. To ensure that the internal bit timing clocks of each node are kept in
phase, TWAI has various methods of synchronization. The Phase Error “e” is measured in the number of Time
Quanta and relative to the SS.
• 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 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 (i.e., the first SOF bit after Bus Idle) edges when the
bus is idle. All nodes will restart their internal bit timings so that the recessive to dominant edge lies within the SS
of the restarted bit timing.
Resynchronization
Resynchronization occurs on recessive to dominant edges when the bus is not 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 programmable.
• When the magnitude of the Phase Error (e) is less than or equal to the SJW, PBS1/PBS2 are
lengthened/shortened by the e number of Time Quanta. This has the same effect as Hard Synchronization.
• When the magnitude of the Phase Error is greater than 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.
PRELIMINARY
Espressif Systems 897 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
The major functional blocks of the TWAI controller are shown in Figure 31-6.
The TWAI controller only works in the CORE clock domain, where RC_FAST_CLK or crystal clock XTAL_CLK can
be selected as the clock source. Users may configure PCR_TWAI0_FUNC_CLK_CONF_REG to select the clock
source.
PRELIMINARY
Espressif Systems 898 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
Configuration Registers
The configuration register stores various configuration items for the TWAI controller such as bit rates, Operation
mode, Acceptance Filter, etc. Configuration registers can only be modified whilst the TWAI controller is in Reset
mode (See Section 31.4.1).
Command Registers
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 31.4.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, all reads and writes to 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.
PRELIMINARY
Espressif Systems 899 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
Entering Reset mode is required in order to modify the various configuration registers of the TWAI controller.
When entering Reset mode, the TWAI controller is essentially disconnected from the TWAI bus. When in Reset
mode, the TWAI controller will not be able to transmit any messages (including error signals). Any transmission in
progress is immediately terminated. Likewise, the TWAI controller will not be able to receive any messages
either.
In Operation mode, the TWAI controller connects to the bus and write-protects all configuration registers to
ensure consistency during operation. When in Operation mode, the TWAI controller can transmit and receive
messages (including error signaling) depending on which operation sub-mode the TWAI controller was
configured with. The TWAI controller supports the following operation sub-modes:
• Normal mode: The TWAI controller can transmit and receive messages including error signals (such as
Error and Overload Frames).
PRELIMINARY
Espressif Systems 900 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
• SelfTest mode: Self-test mode is similar to Normal mode, but the TWAI controller will consider the
transmission of a data or remote frame successful and not generate an ACK error even if it was not
acknowledged. This mode is commonly used during the self-test of a TWAI controller.
• ListenOnly 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
monitoring.
Note that when exiting Reset mode (i.e., entering Operation mode), the TWAI controller must wait for 11
consecutive recessive bits to occur before fully connecting to the TWAI bus (i.e., being able to transmit or
receive).
The following Table 31-6 illustrates the bit fields of TWAI_BUS_TIMING_0_REG. The frequency of the TWAI core
clock has multiple clock sources that can be configured by the user as needed. See Chapter 7 Reset and Clock
for detailed configuration instructions.
Notes:
• BRP: The TWAI Time Quanta clock is derived from the XTAL clock (the default is 40 MHz and is
configured). 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 cycle and tCLK is TWAI core clock cycle:
tT q = 2 × tCLK × (213 × BRP.13 + 212 × BRP.12 + 211 × BRP.11 + ... + 21 × BRP.1 + 20 × BRP.0 + 1)
• SJW: Synchronization Jump Width (SJW) is configured in SJW.0 and SJW.1 where SJW = (2 x SJW.1 +
SJW.0 + 1)�
Bit 318 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 to filter spikes on the
bus line.
PRELIMINARY
Espressif Systems 901 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
• 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_ST_REG, and deasserted when all bits in TWAI_INT_ST_REG are cleared. The majority
of interrupt bits in TWAI_INT_ST_REG are automatically cleared when the register is read, except for the Receive
Interrupt which can only be cleared when all the messages are released by setting the TWAI_RELEASE_BUF
bit.
The Receive Interrupt (RXI) is asserted whenever the TWAI controller has received messages that are pending to
be read from the Receive Buffer (i.e., when TWAI_RX_MESSAGE_CNT_REG > 0). Pending received messages
includes valid messages in the Receive FIFO and also overrun messages. The RXI will not be deasserted until all
pending received messages are cleared using the TWAI_RELEASE_BUF command bit.
The Transmit Interrupt (TXI) is triggered whenever Transmit Buffer becomes free, indicating another message can
be loaded into the Transmit Buffer to be transmitted. The Transmit Buffer becomes free under the following
scenarios:
• A message transmission has been completed successfully, i.e., acknowledged without any errors. Any
failed messages will automatically be resent.
• A single shot transmission has been completed (successfully or unsuccessfully, indicated by the
TWAI_TX_COMPLETE bit).
The Error Warning Interrupt (EWI) is triggered whenever there is a change to the TWAI_ERR_ST and
TWAI_BUS_OFF_ST bits of TWAI_STATUS_REG (i.e., transition from 0 to 1 or vice versa). Thus, an EWI could
PRELIMINARY
Espressif Systems 902 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
indicate one of the following events, depending on the values of TWAI_ERR_ST and TWAI_BUS_OFF_ST at the
moment when the EWI is triggered.
– 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 Off 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 Data Overrun Interrupt (DOI) is triggered whenever the Receive FIFO has overrun. The DOI indicates that the
Receive FIFO is full and should be cleared immediately to prevent any further overrun messages.
The DOI is only triggered by 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 could be triggered again when all received messages (valid or overrun) have been
cleared.
The Error Passive Interrupt (EPI) is triggered whenever the TWAI controller switches from Error Active to Error
Passive, or vice versa.
The Arbitration Lost Interrupt (ALI) is triggered whenever the TWAI controller is attempting to transmit a message
and loses arbitration. The bit position where the TWAI controller lost arbitration is automatically recorded in the
Arbitration Lost Capture register (TWAI_ARB_LOST_CAP_REG). When the ALI occurs again, the Arbitration Lost
Capture register will no longer record a new bit location until it is cleared (via CPU reading this register).
The Bus Error Interrupt (BEI) is triggered whenever the TWAI controller detects an error on the TWAI bus. When a
bus error occurs, the Bus Error type and its bit position are automatically recorded in the Error Code Capture
register (TWAI_ERR_CODE_CAP_REG). When the BEI occurs again, the Error Code Capture register will no
longer record new error information until it is cleared (via a read from the CPU).
PRELIMINARY
Espressif Systems 903 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
The Bus Idle Status Interrupt (BISI) is triggered when the number of clock cycles of the TWAI controller in the idle
status exceeds the pre-configured value in the TWAI_IDLE_INTR_CNT_REG register. Users can configure this
interrupt to get the TWAI controller idle status and further decide whether to turn off the external TWAI receiver to
reduce the overall power consumption (see Section 31.4.10).
Table 318. Buffer Layout for Standard Frame Format and Extended Frame Format
Table 31-8 illustrates the layout of the Transmit Buffer and Receive Buffer registers. Both the Transmit and
Receive Buffer registers share the same address space and are only accessible when the TWAI controller is in
Operation mode. The CPU accesses Transmit Buffer registers for write operations, and Receive Buffer registers
for read operations. Both buffers share the exact same register layout and fields to store 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 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 to clear the Receive Buffer registers. If there are still messages in the Receive FIFO, the
Receive Buffer registers will map the first of the remaining messages again.
PRELIMINARY
Espressif Systems 904 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
The frame information is one byte long and specifies a message’s frame type, frame format, and length of data.
The frame information fields are shown in Table 31-9.
Bit 318 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 DLC.3 DLC.2 DLC.1 DLC.04
Notes:
1. 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 the FF bit is 1, and SFF when the FF bit is 0.
2. 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.
4. 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, and thus the DLC should range from 0 to 8.
The Frame Identifier fields occupy two-byte (11-bit) long if the message is SFF, and four-byte (29-bit) long if the
message is EFF.
The Frame Identifier fields for an SFF (11-bit) message are shown in Table 31-10 ~ 31-11.
Bit 318 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.10 ID.9 ID.8 ID.7 ID.6 ID.5 ID.4 ID.3
Bit 318 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 2 2 2
Reserved ID.2 ID.1 ID.0 X X X X X2
Notes:
1. Don’t care. Recommended to be compatible with receive buffer (i.e., set to RTR) in case of using the
self-reception functionality (or together with self-test functionality).
2. Don’t care. Recommended to be compatible with receive buffer (i.e., set to 0) in case of using the
self-reception functionality (or together with self-test functionality).
PRELIMINARY
Espressif Systems 905 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
The Frame Identifier fields for an EFF (29-bits) message is shown in Table 31-12 ~ 31-15.
Bit 318 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 318 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 318 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 318 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
Notes:
1. Don’t care. Recommended to be compatible with receive buffer (i.e., set to RTR ) in case of using the
self-reception functionality (or together with self-test functionality).
2. Don’t care. Recommended to be compatible with receive buffer (i.e., set to 0 ) in case of using the
self-reception functionality (or together with self-test functionality).
The Frame Data field contains the payloads of transmitted or received data frame, and can range from 0 to 8
bytes. The number of valid bytes should be equal to the DLC. However, if the DLC is larger than eight bytes, the
number of valid bytes would still be limited to eight. Remote frames do not have data payloads, so their Frame
Data fields will be unused.
For example, when transmitting a data frame with five bytes, the CPU should write five to the DLC field, and then
write data to the corresponding register of the first to the fifth data field. Likewise, when the CPU receives a data
frame with a DLC of five data bytes, only the first to the fifth data byte will contain valid payload data for the CPU
to read.
PRELIMINARY
Espressif Systems 906 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
When the TWAI controller receives a message, it will increment the value of TWAI_RX_MESSAGE_COUNTER by
1 with a maximum of 64. If there is adequate space in the Receive FIFO, the message contents will be written into
the Receive FIFO. Once a message has been read from the Receive Buffer, the TWAI_RELEASE_BUF bit should
be set. This will decrement TWAI_RX_MESSAGE_COUNTER by 1 and free the space occupied by the first
message in the Receive FIFO. The 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 adequate free
space to store the received message in its entirety (either due to the message contents being larger than the free
space in the Receive FIFO, or the Receive FIFO being completely full).
• The free space 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.
• When data in the Receive FIFO overruns for the first time, 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 Receive 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 until
TWAI_RX_MESSAGE_COUNTER is 0. This requires users to read all valid messages in the Receive FIFO and
clear all overrun messages.
The Acceptance Filter configuration registers can only be accessed whilst the TWAI controller is in Reset mode,
since they share the same address spaces with the Transmit Buffer and Receive Buffer registers.
The configuration registers consist of a 32-bit Acceptance Code Value and a 32-bit Acceptance Mask Value. The
Acceptance Code value specifies a bit pattern which each filtered bit of the message must match in order for the
message to be accepted. The Acceptance 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 31-8.
message bit
1 = accepted
XNOR OR 0 = not accepted
acceptance code bit acceptance mask bit
AND
PRELIMINARY
Espressif Systems 907 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
The TWAI controller Acceptance Filter allows the 32-bit Acceptance 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 the filter mode and the format of received messages (i.e., SFF or
EFF).
Single Filter mode is enabled by setting the TWAI_RX_FILTER_MODE bit to 1. This will cause the 32-bit code and
mask values to define a single filter. The single filter can filter the following bits of data or remote frames:
• SFF
– RTR bit
• EFF
– RTR bit
The following Figure 31-9 illustrates how the 32-bit code and mask values will be interpreted under Single Filter
mode.
Dual Filter mode is enabled by clearing the TWAI_RX_FILTER_MODE bit to 0. This will cause the 32-bit code and
mask values to define two separate filters referred to as filter 1 or filter 2. Under Dual Filter mode, a message will
be accepted if it is accepted by one of the two filters.
The two filters can filter the following bits of data or remote frames:
• SFF
PRELIMINARY
Espressif Systems 908 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
– RTR bit
• EFF
The following Figure 31-10 illustrates how the 32-bit code and mask values will be interpreted in 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
PRELIMINARY
Espressif Systems 909 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
trigger interrupts, so that users are notified of error state transitions (see section 31.4.3). The following figure
31-11 shows the relation between the error states, values and bits, and error state related interrupts.
The Error Warning Limit (EWL) is a configurable threshold value for the TEC and REC, which will trigger an
interrupt when exceeded. The EWL is intended to serve as a warning about severe TWAI bus errors, and is
triggered before the TWAI controller enters the Error Passive state. The EWL is configured in
TWAI_ERR_WARNING_LIMIT_REG and can only be configured whilst the TWAI controller is in Reset mode. The
TWAI_ERR_WARNING_LIMIT_REG has a default value of 96.
When the values of TEC and/or REC are larger than or equal to the EWL value, the TWAI_ERR_ST bit is
immediately set to 1. Likewise, when the values of both the TEC and REC are smaller than the EWL value, the
TWAI_ERR_ST bit is immediately reset to 0. The Error Warning Interrupt is triggered whenever the value of the
TWAI_ERR_ST bit (or the TWAI_BUS_OFF_ST) changes.
The TWAI controller is in the Error Passive state when the TEC or REC value exceeds 127. Likewise, when both
the TEC and REC are less than or equal to 127, the TWAI controller enters the Error Active state. The Error
Passive Interrupt is triggered whenever the TWAI controller transitions from the Error Active state to the Error
Passive state or vice versa.
The TWAI controller enters the Bus-Off state when the TEC value exceeds 255. On entering the Bus-Off state,
the TWAI controller will automatically do the following:
• Set REC to 0
PRELIMINARY
Espressif Systems 910 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
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 when 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 318 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 1 2 3 3 3 3
Reserved ERRC.1 ERRC.0 DIR SEG.4 SEG.3 SEG.2 SEG.1 SEG.03
Notes:
• ERRC: The Error Code (ERRC) indicates the type of bus error; 00 for bit error, 01 for format error, 10 for
stuff error, and 11 for other types of error.
• DIR: The Direction (DIR) indicates whether the TWAI controller was transmitting or receiving when the bus
error occurred; 0 for the transmitter, 1 for the receiver.
• SEG: The Error Segment (SEG) indicates the segment of the TWAI message at which the bus error
occurred.
The following Table 31-17 shows how to interpret the SEG.0 to SEG.4 bits.
Bit SEG.4 Bit SEG.3 Bit SEG.2 Bit SEG.1 Bit SEG.0 Description
0 0 0 1 1 start of frame
0 0 0 1 0 ID.28 ~ ID.21
0 0 1 1 0 ID.20 ~ ID.18
0 0 1 0 0 bit SRTR
0 0 1 0 1 bit IDE
0 0 1 1 1 ID.17 ~ ID.13
0 1 1 1 1 ID.12 ~ ID.5
0 1 1 1 0 ID.4 ~ ID.0
0 1 1 0 0 bit RTR
Cont’d on next page
PRELIMINARY
Espressif Systems 911 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
Notes:
Subsequent losses in arbitration will trigger the Arbitration Lost Interrupt, but will not be recorded in
TWAI_ARB_LOST_CAP_REG until the current Arbitration Lost Capture is read from the
TWAI_ERR_CODE_CAP_REG.
Table 31-18 illustrates bits and fields of TWAI_ERR_CODE_CAP_REG whilst Figure 31-12 illustrates the bit
positions of a TWAI message.
• BITNO: Bit Number (BITNO) indicates the nth bit of a TWAI message where arbitration was lost.
ESP32-H2’s TWAI controller supports both hardware control (i.e., automatic) and software control (i.e., manual)
of the standby signal to control the switching of TWAI transceivers connected to the chip. When hardware
controlled, the TWAI controller will automatically assert the standby signal when the bus remains idle for longer
than a configurable amount of time. When software controlled, the standby signal can be manually
asserted/de-asserted directly by the software.
• Hardware output:
2. Configure the TWAI_HW_STANDB_CNT_REG register. This register indicates the time required before
hardware triggers the standby signal after entering idle status, in which the value indicates the number
of cycles of the TWAI controller operating clock (32 MHz by default).
• Software output:
The standby signal generated using either of the above methods will be pulled down (cleared) when either of the
following conditions is met:
1. The standby signal will be automatically cleared when the TWAI controller exits the idle status.
2. Users can also pull down the standby signal by setting the TWAI_SW_STANDBY_CLR field in the
TWAI_SW_STANDBY_CFG_REG register.
PRELIMINARY
Espressif Systems 913 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 914 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
31.6 Registers
’|’ here means a separate line. The left describes the access in Operation mode. The right belongs to Reset
mode with red color. The addresses in this section are relative to Two-wire Automotive Interface base address
(each TWAI 0 and TWAI 1 has an individual base address) provided in Table 4-2 in Chapter 4 System and
Memory.
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_
d)
TW I_R
ve
er
A
s
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
PRELIMINARY
Espressif Systems 915 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
H
T
ID
W
C
P_
ES
UM
PR
J
D_
C_
AU
YN
)
ed
_B
_S
rv
AI
AI
se
TW
TW
(re
31 16 15 14 13 0
TWAI_BAUD_PRESC Configures baud rate prescaler value, determining the frequency dividing ratio.
0: Low
1: High
(RO | R/W)
1
M
G
SA
SE
SE
E_
E_
E_
M
IM
IM
)d
I
ve
_T
_T
_T
er
AI
AI
AI
s
TW
TW
TW
(re
31 8 7 6 4 3 0
PRELIMINARY
Espressif Systems 916 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
IT
IM
_L
NG
NI
AR
W
R_
d)
R
ve
_E
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 0x60 Reset
TWAI_ERR_WARNING_LIMIT Configures error warning threshold. In the case when any of an error
counter value exceeds the threshold, or all the error counter values are below the threshold, an
error warning interrupt will be triggered. Valid only when the enable signal is 1. (RO | R/W)
_0
DE
O
_C
CE
N
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 Configures the 0th byte information of the data to be transmitted in Operation
mode. (WO)
TWAI_ACCEPTANCE_CODE_0 Configures the 0th byte of the filter code in Reset mode. (R/W)
PRELIMINARY
Espressif Systems 917 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
_1
DE
O
E_C
NC
TA
EP
CC
_A
AI
W
|T
1
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_1 Configures the 1st byte information of the data to be transmitted in Operation
mode. (WO)
TWAI_ACCEPTANCE_CODE_1 Configures the 1st byte of the filter code in Reset mode. (R/W)
_2
DE
O
_C
CE
N
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 Configures the 2nd byte information of the data to be transmitted in Operation
mode. (WO)
TWAI_ACCEPTANCE_CODE_2 Configures the 2nd byte of the filter code in Reset mode. (R/W)
PRELIMINARY
Espressif Systems 918 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
_3
DE
O
E_C
NC
TA
EP
CC
_A
AI
W
|T
3
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_3 Configures the 3rd byte information of the data to be transmitted in Operation
mode. (WO)
TWAI_ACCEPTANCE_CODE_3 Configures the 3rd byte of the filter code in Reset mode. (R/W)
0
K_
AS
_M
CE
N
TA
EP
CC
_A
AI
W
|T
4
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_4 Configures the 4th byte information of the data to be transmitted in Operation
mode. (WO)
TWAI_ACCEPTANCE_MASK_0 Configures the 0th byte of the filter code in Reset mode.
1: nihao
2: world
3: success
(R/W)
PRELIMINARY
Espressif Systems 919 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
1
K_
AS
E_M
NC
TA
EP
CC
_A
AI
W
|T
5
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_5 Configures the 5th byte information of the data to be transmitted in Operation
mode. (WO)
TWAI_ACCEPTANCE_MASK_1 Configures the 1st byte of the filter code in Reset mode. (R/W)
2
K_
AS
_M
CE
N
TA
EP
CC
_A
AI
W
|T
6
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_6 Configures the 6th byte information of the data to be transmitted in Operation
mode. (WO)
TWAI_ACCEPTANCE_MASK_2 Configures the 2nd byte of the filter code in Reset mode. (R/W)
PRELIMINARY
Espressif Systems 920 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
3
K_
AS
_M
E
NC
TA
EP
CC
_A
AI
W
|T
7
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_7 Configures the 7th byte information of the data to be transmitted in Operation
mode. (WO)
TWAI_ACCEPTANCE_MASK_3 Configures the 3rd byte of the filter code in Reset mode. (R/W)
8
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_8 Configures the 8th byte information of the data to be transmitted in Operation
mode. (WO)
_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_9 Configures the 9th byte information of the data to be transmitted in Operation
mode. (WO)
PRELIMINARY
Espressif Systems 921 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
10
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_10 Configures the 10th byte information of the data to be transmitted in Operation
mode. (WO)
11
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_11 Configures the 11th byte information of the data to be transmitted in Operation
mode. (WO)
12
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_12 Configures the 12th byte information of the data to be transmitted in Operation
mode. (WO)
PRELIMINARY
Espressif Systems 922 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
FF
O_
CK
LO
)
D
ed
_C
_C
rv
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_CLOCK_OFF Configures whether or not to enable the external CLKOUT pin in Reset mode.
0: Enable the external CLKOUT pin
1: Disable the external CLKOUT pin
(RO | R/W)
BY CLR
N
_E
ND Y_
TA B
_S ND
W TA
_S S
AI W_
d)
TW I_S
e
rv
se
A
TW
(re
31 2 1 0
0x0 0 0 Reset
PRELIMINARY
Espressif Systems 923 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
EN
_
BY
ND
TA
_S
W
d)
_H
ve
er
AI
s
TW
(re
31 1 0
0x0 0 Reset
T
CN
T_
AI
W
Y_
N DB
TA
_S
AI
TW
31 0
0x0 Reset
TWAI_STANDBY_WAIT_CNT Configures the time required before hardware triggers the standby sig-
nal after entering idle status. (R/W | R/W)
Measurement unit: TWAI controller clock cycles.
31 0
0x0 Reset
TWAI_IDLE_INTR_CNT Configures the time required before hardware generates the bus idle status
interrupt signal after entering idle status. (R/W | R/W)
Measurement unit: TWAI controller clock cycles.
PRELIMINARY
Espressif Systems 924 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
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
PRELIMINARY
Espressif Systems 925 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
AI VE F_S TE
F_ ST
A X_ T T
TW I_O BU PLE
TW I_T _S _S
ST
_R R R 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_
d)
TW I_M
ve
er
A
s
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_TX_COMPLETE Represents whether or not the TWAI controller has received a packet from
the bus.
0: Not received
1: Received
(RO)
TWAI_RX_ST Represents whether or not the TWAI Controller is receiving a message from the bus.
0: Not receiving
1: Receiving
(RO)
TWAI_TX_ST Represents whether or not the TWAI Controller is transmitting a message to the bus.
0: Not transmitting
1: Transmitting
(RO)
TWAI_ERR_ST Represents 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 Represents whether or not the TWAI Controller involves in bus activities in bus-
off status.
0: Involved
1: No longer involved
(RO)
TWAI_MISS_ST Represents whether or not the data packet in the RX FIFO is complete.
0: The current packet is complete
1: The current packet is missing
(RO) PRELIMINARY
Espressif Systems 926 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
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
T
O
EN
TI
EC
M
E
EG
_E TYP
IR
_D
_S
_
TW CC
CC
CC
)
ed
_E
_E
rv
AI
AI
AI
se
TW
TW
(re
31 8 7 6 5 4 0
TWAI_ECC_SEGMENT Represents the location of errors, see Table 31-16 for details. (RO)
_R
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_RX_ERR_CNT The RX error counter register, reflects value changes in reception status. (RO |
R/W)
PRELIMINARY
Espressif Systems 927 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
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 in 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
PRELIMINARY
Espressif Systems 928 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
31 Two-wire Automotive Interface (TWAI) GoBack
T
_S
ST
se RR OS T ST
VE ST
X_ _S _IN T
NT
TW rve _P T_ _ST
IN T T_
(re I_E _L _IN T_
_R T N S
SI _
AI X_I AR NT_
_I
A d) AS INT
A RB RR _IN
TW _T _W _I
TW I_A _E TE
ST
AI RR UN
A US TA
T_
TW _E RR
TW _B _S
N
AI US
AI VE
d)
TW I_O
TW I_B
ve
er
A
s
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 0 0 0 0 Reset
NA
A
TW rve _P T_ _EN A
_E
_I A
EN
se RR OS T EN
X_ _E _IN NA
A d) AS INT A
VE EN
NT
IN N T_
(re I_E _L _IN T_
_R T N E
SI _
AI X_I AR NT_
A RB RR _IN
A
T_ A
TW _T _W _I
TW I_A _E TE
EN
AI RR UN
A US TA
TW _E RR
TW _B _S
N
AI US
AI VE
)
ed
TW I_O
TW I_B
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 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 929 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
32.1 Overview
The LED PWM Controller is a peripheral designed to generate PWM signals for LED control. It has specialized
features such as automatic duty cycle fading. However, the LED PWM Controller can also be used to generate
PWM signals for other purposes.
32.2 Features
The LED PWM Controller has the following features:
• Automatic duty cycle fading — gradual increase/decrease of a PWM’s duty cycle without interference from
the processor. An interrupt will be generated upon fade completion
• Up to 16 duty cycle ranges for each PWM generator to generate gamma curve signals - each range can be
independently configured in terms of fading direction (increase or decrease), fading amount (the amount by
which the duty cycle increases or decreases each time), the number of fades (how many times the duty
cycle fades in one range), and fading frequency
• Event generation and task response related to the Event Task Matrix (ETM) peripheral
Note that the four timers are identical regarding their features and operation. The following sections refer to the
timers collectively as Timerx (where x ranges from 0 to 3). Likewise, the six PWM generators are also identical in
features and operation, and thus are collectively referred to as PWMn (where n ranges from 0 to 5).
PRELIMINARY
Espressif Systems 930 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
Each of the four timers has an internal timebase counter (i.e. a counter that counts on cycles of a reference
clock) and thus can be independently configured (i.e. configurable clock divider, and counter overflow value).
Each PWM generator selects one of the timers by configuring LEDC_TIMER_SEL_CHn, and uses the timer’s
counter value timerx_cnt as a reference to generate its PWM signal.
Figure 32-2 illustrates the main functional blocks of the timer and the PWM generator.
32.3.2 Timers
Each timer in LED PWM Controller internally maintains a timebase counter. Referring to Figure 32-2, this clock
signal used by the timebase counter is named ref_pulsex. All timers use the same clock source LEDC_CLKx,
which is then passed through a clock divider to generate ref_pulsex for the counter.
LED PWM registers configured by software are clocked by APB_CLK. To use the LED PWM peripheral, the
APB_CLK signal going to the LED PWM has to be enabled. The APB_CLK signal to LED PWM can be enabled
by setting the PCR_LEDC_CLK_EN field in the PCR_LEDC_CONF_REG register, and reset via software by
setting the PCR_LEDC_RST_EN field in the PCR_LEDC_CONF_REG register.
Timers in LED PWM Controller choose their common clock source from one of the following clock signals:
PLL_F96M_CLK, RC_FAST_CLK, and XTAL_CLK. The procedure for selecting a clock source signal for
LEDC_CLKx is described below:
The LEDC_CLKx signal will then be passed through the clock divider.
If LEDC_SCLK_SEL[1:0] is set to 0 (an invalid value), LED PWM Controller cannot perform any function due to no
clock source.
The LEDC_CLKx signal is passed through a clock divider to generate the ref_pulsex signal for the counter. The
frequency of ref_pulsex is equal to the frequency of LEDC_CLKx divided by the divisor LEDC_CLK_DIV (see
Figure 32-2).
The divisor LEDC_CLK_DIV can be non-integer values, and it is configured according to the following
equation.
B
LEDC_CLK_DIV = A + 256
• The integer part A corresponds to the most significant 10 bits of LEDC_CLK_DIV_TIMERx (i.e.
LEDC_TIMERx_CONF_REG[22:13])
When the fractional part B is 0, LEDC_CLK_DIV is an integer (i.e. an integer prescaler). In other words, a
ref_pulsex clock pulse is generated after every A LEDC_CLKx clock pulses.
However, when B is not 0, LEDC_CLK_DIV becomes a non-integer. The clock divider implements non-integer
frequency division by generating a ref_pulsex clock pulse after every A and (A+1) LEDC_CLKx clock pulses
alternately. In this way, the average frequency of ref_pulsex clock pulse will be the desired frequency (i.e. the
non-integer divided frequency). For every 256 ref_pulsex clock pulses:
• A number of B ref_pulsex clock pulses are generated every (A+1) LEDC_CLKx clock pulses
• A number of (256-B) ref_pulsex clock pulses are generated every A LEDC_CLKx clock pulses
• The ref_pulsex clock pulses generated every (A+1) pulses are evenly distributed amongst those generated
every A pulses
Figure 32-3 illustrates the relation between LEDC_CLKx clock pulses and ref_pulsex clock pulses when
LEDC_CLK_DIV is a non-integer.
PRELIMINARY
Espressif Systems 932 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
To change the timer’s clock divisor at runtime, first configure the LEDC_CLK_DIV_TIMERx field, and then set the
LEDC_TIMERx_PARA_UP field to apply the new configuration. This will cause the newly configured values to
take effect upon the next overflow of the counter. The LEDC_TIMERx_PARA_UP field will be automatically
cleared by hardware.
Each timer contains a 20-bit timebase counter that uses ref_pulsex as its reference clock (see Figure 32-2). The
LEDC_TIMERx_DUTY_RES field configures the overflow value of this 20-bit counter. Hence, the maximum
resolution of the PWM signal is 20 bits. The counter counts up to 2LEDC_TIMERx_DUTY_RES − 1, overflows and begins
counting from 0 again. The counter’s value can be read, reset, and suspended by software. Figure 32-4 shows
the relationship between the counter and PWM resolution.
Every time the counter overflows, it can trigger the LEDC_TIMERx_OVF_INT interrupt (generated automatically by
hardware without configuration). It can also be configured to trigger LEDC_OVF_CNT_CHn_INT interrupt after
overflowing LEDC_OVF_NUM_CHn + 1 times. To configure LEDC_OVF_CNT_CHn_INT interrupt, please:
3. Configure LEDC_OVF_NUM_CHn with the number of counter overflows (that triggers an interrupt) minus 1
5. Set LEDC_TIMERx_DUTY_RES to enable the timer and wait for a LEDC_OVF_CNT_CHn_INT interrupt
To change the overflow value at runtime, first set the LEDC_TIMERx_DUTY_RES field, and then set the
LEDC_TIMERx_PARA_UP field. This will cause the newly configured values to take effect upon the next overflow
of the counter. If LEDC_OVF_CNT_EN_CHn field is reconfigured, LEDC_PARA_UP_CHn should be set to apply
the new configuration. In summary, these configuration values need to be updated by setting
LEDC_TIMERx_PARA_UP or LEDC_PARA_UP_CHn. LEDC_TIMERx_PARA_UP and LEDC_PARA_UP_CHn will
be automatically cleared by hardware.
Referring to Figure 32-2, the frequency of a PWM generator output signal (sig_outn) is dependent on the
frequency of the timer’s clock source LEDC_CLKx, the clock divisor LEDC_CLK_DIV, and the duty resolution
(counter width) LEDC_TIMERx_DUTY_RES:
fLEDC_CLKx
fPWM =
LEDC_CLK_DIV · 2LEDC_TIMERx_DUTY_RES
Based on the formula above, the desired duty resolution can be calculated as follows:
PRELIMINARY
Espressif Systems 933 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
fLEDC_CLKx
LEDC_TIMERx_DUTY_RES = log2
fPWM · LEDC_CLK_DIV
Table 32-1 lists the commonly-used frequencies and their corresponding resolutions.
As shown in Figure 32-2, each PWM generator has a comparator and two multiplexers. A PWM generator
compares the timer’s 20-bit counter value (Timerx_cnt) to two trigger values Hpointn and Lpointn. When the
timer’s counter value is equal to Hpointn or Lpointn, the PWM signal is high or low, respectively, as described
below:
Figure 32-5 illustrates how Hpointn and Lpointn are used to generate the PWM output signal with a fixed duty
cycle.
For a particular PWM generator (PWMn), its Hpointn is sampled from the LEDC_HPOINT_CHn field each time the
selected timer’s counter overflows. Likewise, Lpointn is also sampled on every counter overflow and is calculated
from the sum of the LEDC_DUTY_CHn[24:4] and LEDC_HPOINT_CHn fields. By setting Hpointn and Lpointn via
the LEDC_HPOINT_CHn and LEDC_DUTY_CHn[24:4] fields, the relative phase and duty cycle of the PWM
output can be set.
The bits LEDC_DUTY_CHn[3:0] are used to dither the duty cycles of the PWM output signal (sig_outn) by
periodically altering the duty cycle of sig_outn. When LEDC_DUTY_CHn[3:0] is not 0, then for every 16 cycles of
PRELIMINARY
Espressif Systems 934 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
timer_cnt[19:0]
overfow
lpoint ......
hpoint
0
t
......
sig_out
sig_outn, LEDC_DUTY_CHn[3:0] of those cycles will have PWM pulses that are one timer tick longer than the
other (16- LEDC_DUTY_CHn[3:0]) cycles. For instance, if LEDC_DUTY_CHn[24:4] is set to 10 and
LEDC_DUTY_CHn[3:0] is set to 5, then 5 of 16 cycles will have a PWM pulse with a duty value of 11 and the rest
of the 16 cycles will have a PWM pulse with a duty value of 10. The average duty cycle after 16 cycles is
10.3125.
Linear fading PWM signals can be generated by configuring the direction, fading amount, the number of fades,
and fading frequency of the first duty cycle range.
2. Set the LEDC_DUTY_START_CHn field to enable Duty Cycle Fading. When this field is cleared, Duty Cycle
Fading will be disabled.
4. Configure the number of times the counter overflows per an increase or decrease of Lpointn via the
LEDC_CHn_GAMMA_DUTY_CYCLE field of the LEDC_CHn_GAMMA_WR_REG register. In other words,
PRELIMINARY
Espressif Systems 935 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
Lpointn will increase or decrease after the counter overflows for LEDC_CHn_GAMMA_DUTY_CYCLE times.
5. Configure the amount by which Lpointn increase or decrease in the configured range via the
LEDC_CHn_GAMMA_SCALE field of the LEDC_CHn_GAMMA_WR_REG register.
7. Write the duty cycle range number (0 in this case) to the LEDC_CHn_GAMMA_WR_ADDR field of the
LEDC_CHn_GAMMA_WR_ADDR_REG register. This range number (from 0 to 15) specifies to which range
the configurations in Step 3, 4, 5, and 6 apply. For linear duty cycle fading only the first range needs to be
configured, so configure LEDC_CHn_GAMMA_WR_ADDR as 0.
8. Configure the number of ranges per each fading (1 in this case) via the LEDC_CHn_GAMMA_ENTRY_NUM
field of the LEDC_CHn_GAMMA_CONF_REG. Once the specified number of ranges have been faded, Duty
Cycle Fading stops and the PWM generator triggers the LEDC_DUTY_CHNG_END_CHn_INT interrupt. For
linear duty cycle fading there is only one duty cycle range (i.e. the first one), so configure
LEDC_CHn_GAMMA_ENTRY_NUM as 1.
9. Set the LEDC_PARA_UP_CHn field to apply the above configurations. After this field is set, the
configurations for Duty Cycle Fading will take effect upon the next overflow of the counter, and the PWM
generator will output a linear fading PWM signal following configurations. LEDC_PARA_UP_CHn field will
be automatically cleared by hardware.
After the above procedures, the PWM generator can fade the duty cycle of a PWM signal once per
LEDC_CHn_GAMMA_DUTY_CYCLE times of counter overflows. Every time when the PWM signal is faded,
Lpointn increases or decreases (configured by LEDC_CHn_GAMMA_DUTY_INC) by
LEDC_CHn_GAMMA_SCALE, and the duty cycle increases or decreases (configured by
LEDC_CHn_GAMMA_DUTY_INC) by
LEDC_CHn_GAMMA_SCALE
LEDC_TIMERx_DUTY_RES
The duty cycle is faded for LEDC_CHn_GAMMA_DUTY_NUM times. After that, the PWM generator stops fading
and keeps outputting signals at this duty cycle. Upon each fading the duty cycle increases or decreases by the
same amount, and therefore the PWM signal is a linear fading signal.
Gamma curve fading PWM signals can be generated by configuring the fading direction, fading amount, the
number of fades, and fading frequency of multiple duty cycle fading ranges.
PRELIMINARY
Espressif Systems 936 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
timer_cnt[19:0] LEDC_CHn_GAMMA_DUTY_INC=1
overfow
lpoint
lpoint
...... ......
hpoint
sig_out
Duty cycle fading one time Duty cycle fading LEDC_Chn_GAMMA_DUTY_NUM times
(e) Write the duty cycle range number (from 0 to 15) to the LEDC_CHn_GAMMA_WR_ADDR field of the
LEDC_CHn_GAMMA_WR_ADDR_REG register. This range number specifies to which range the
above configurations apply. It must start from 0 and increase by 1 for the next range to be configured.
(f) Once the above procedures are finished, the configuration for one range is complete. Other ranges
are configured by repeating the same set of procedures. You can configure any number of ranges
from 0 to 16, and each can be configured independently.
4. After all required ranges are configured, write the total number of ranges configured in Step 3 to the
LEDC_CHn_GAMMA_ENTRY_NUM field of the LEDC_CHn_GAMMA_CONF_REG register.
5. Set the LEDC_PARA_UP_CHn field to apply the above configuration. After this field is set, the
configurations for duty cycle fading will take effect upon the next overflow of the counter, and the PWM
generator will output a gamma curve fading PWM signal following the configurations.
LEDC_PARA_UP_CHn field will be automatically cleared by hardware.
After the above procedures, the PWM generator can generate a PWM signal with
LEDC_CHn_GAMMA_ENTRY_NUM ranges. The duty cycle of the PWM signal fades according to the
configurations of range 0 first, and then range 1, till range (LEDC_CHn_GAMMA_ENTRY_NUM − 1) (the last
range) where Duty Cycle Fading ends. The PWM signal fades independently in each range. In range
LEDC_CHn_GAMMA_WR_ADDR, every time when the counter overflows for
LEDC_CHn_GAMMA_DUTY_CYCLE times, Lpointn increases or decreases (configured by
PRELIMINARY
Espressif Systems 937 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
LEDC_CHn_GAMMA_SCALE
LEDC_TIMERx_DUTY_RES
After the duty cycle fades for LEDC_CHn_GAMMA_DUTY_NUM times in a range, Duty Cycle Fading in this range
finishes.
When Duty Cycle Fading finishes in all ranges (the number of ranges is specified by
LEDC_CHn_GAMMA_ENTRY_NUM), the PWM signal stops fading and keeps the duty cycle of the last fade.
Given that the duty cycle fades differently and linearly in each range, several linear fading ranges would be fitted
to a gamma curve.
To suspend Duty Cycle Fading that has already been started, write 1 to the LEDC_CHn_GAMMA_PAUSE field of
the LEDC_CHn_GAMMA_CONF_REG register. Once LEDC_CHn_GAMMA_PAUSE is set to 1, the PWM signal
keeps the duty cycle of the most recent fade.
section introduces the ETM tasks and events related to LEDC. For more information, please refer to Chapter 10
Event Task Matrix (SOC_ETM).
ETM-related events and tasks are enabled by configuring corresponding fields of LEDC_EVT_TASK_EN0_REG,
LEDC_EVT_TASK_EN1_REG and LEDC_EVT_TASK_EN2_REG registers. For the correspondence between
events, tasks, and fields, Please refer to Section 32.5).
PRELIMINARY
Espressif Systems 939 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
• LEDC_EVT_TIMERx_CMP: Generated when the LEDC_EVT_TIMEx_CMP_EN field is enabled and the value
of Timerx)’s counter reaches that of the LEDC_TIMERx_CMP field of register LEDC_TIMERx_CMP_REG.
In practical applications, LEDC’s ETM events can trigger its own ETM tasks. For example,
LEDC_EVT_DUTY_CHNG_END_CHn event can trigger the LEDC_TASK_GAMMA_RESTART_CHn task, thus
starting the next fading directly after the current fading is completed.
32.3.6 Interrupts
• LEDC_OVF_CNT_CHn_INT: Triggered when the timer counter overflows for LEDC_OVF_NUM_CHn + 1
times and the register LEDC_OVF_CNT_EN_CHn is set to 1. To trigger this interrupt, the field
LEDC_OVF_CNT_CHn_INT_ENA of register LEDC_INT_ENA_REG should be set.
• LEDC_TIMERx_OVF_INT: Triggered when an LED PWM timer has reached its maximum counter value. To
trigger this interrupt, the field LEDC_TIMERx_OVF_INT_ENA of register LEDC_INT_ENA_REG should be
set.
PRELIMINARY
Espressif Systems 940 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
The abbreviations given in Column Access are explained in Section Access Types for Registers.
PRELIMINARY
Espressif Systems 941 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
PRELIMINARY
Espressif Systems 942 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
PRELIMINARY
Espressif Systems 943 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
32.5 Registers
The addresses in this section are relative to LED PWM Controller base address provided in Table 4-2 in Chapter 4
System and Memory.
0 0
CH H
N_ _C
0
_E ET
_S _CH
H0
H0
DC _O CH 0
NT ES
_C
LE SIG LV_ CH
U 0
N
_C
_C _R
IM T_E
EL
_ E_ _
UM
VF NT
DC DL UP
_O F_C
_N
LE C_I RA_
ER
VF
DC V
)
D A
ed
LE C_O
_O
LE C_P
_T
rv
DC
se
D
LE
LE
LE
(re
31 17 16 15 14 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 Reset
PRELIMINARY
Espressif Systems 944 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
)
ed
_D
rv
DC
se
LE
(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
PRELIMINARY
Espressif Systems 945 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
0
31
(re
s
0
30
er
ve
0
29
LE d)
DC
0
28
LE _T
(R/W)
(R/W)
(R/W)
(R/W)
(R/W)
event.
D AS
0
27
LE C_T K_
Espressif Systems
1: Enable
1: Enable
1: Enable
1: Enable
1: Enable
D AS D
0: Disable
0: Disable
0: Disable
0: Disable
0: Disable
0
26
LE C_T K_ UTY
D AS D _S
0
25
LE C_T K_ UTY CA
DC AS DU _S LE
0
24
LE _T K_ TY CA _U
D AS D _S L PD
0
23
LE C_T K_ UTY CA E_U AT
DC AS DU _S LE PD E_
32 LED PWM Controller (LEDC)
0
22
LE _E K_ TY CA _U AT CH
D V D _S L PD E_ 5_
0
21 LE C_E T_T UTY CA E_U AT CH EN
DC VT IM _S LE PD E_ 4_
0
20
LE _E _T E3 CA _U AT CH EN
D V IM _C L PD E_ 3_
0
19
LE C_E T_T E1 MP N AT CH EN
D V IM _C _E E_ 1_
0
17
CH EN
LEDC_EVT_OVF_CNT_PLS_CHn event.
LE C_E T_T E0 MP N
DC VT M C _E I _ 0_
_ E M N
0
16
LE _E T _O P EN
LEDC_EVT_DUTY_CHNG_END_CHn event.
LEDC_EVT_TIME_OVF_TIMERx_EN Configures
_ _T _ _
LEDC_EVT_OVF_CNT_PLS_CHn_EN Configures
(re EVT IM OV TIM
946
LEDC_TASK_DUTY_SCALE_UPDATE_CHn task.
se _T E_ F_ ER
0
14
rv O T
LEDC_EVT_DUTY_CHNG_END_CHn_EN Configures
LE ) _O _T R N
D VF IM 2_E
0
12
LE C_E _T ER N
DC VT IM 1_
LEDC_TASK_DUTY_SCALE_UPDATE_CHn_EN Configures
whether
0
11
ER EN
whether
LE _E _O
DC VT VF 0_
LE _E _O _C EN
whether
DC VT VF NT
or
_ _ _
9
or
LE _E O C P
D V V N LS
8
or
whether
0
_ _ O _ C _ P _ C _E
not
or
not
(re EVT VF NT LS H4 N
Register 32.3. LEDC_EVT_TASK_EN0_REG (0x01A0)
not
se _ O _ C _ P _ C _E
0
6
rv N
ed VF_ NT_ LS_ H3_
5
not
to LE
to
CN PL CH EN
D
to
T_ S_ 2_
4
LE C_E PL CH EN
to
DC VT S_ 1_
3
LE _E _D CH EN
DC VT UT 0_
2
LE _E _D Y_ EN
enable
enable
DC VT UT CH
enable
1
enable
LE _E _D Y_ NG
D V U CH _
0
the
LEDC_EVT_TIMEn_CMP_EN Configures whether or not to enable the LEDC_EVT_TIMEn_CMP
the
the
the
_E _D Y_ NG EN CH
VT UT CH _ D_ 5_
0 Reset
_D Y_ N EN CH EN
PRELIMINARY
GoBack
UT CH G_ D_ 4_
0
30
LE C_T
DC AS
0
29
LE _T K_
D AS TI
0
28
task.
task.
LE C_T K_ ME
(R/W)
(R/W)
(R/W)
(R/W)
(R/W)
(R/W)
D AS TI R3
0
27
Espressif Systems
LE C_T K_ ME _PA
1: Enable
1: Enable
1: Enable
1: Enable
1: Enable
1: Enable
D AS TI R2 U
0: Disable
0: Disable
0: Disable
0: Disable
0: Disable
0: Disable
0
26
LE C_T K_ ME _PA SE
D AS TI R1 U _R
0
25
LE C_T K_ ME _PA SE ES
D AS TI R0 U _R UM
0
24
LE C_T K_ ME _PA SE ES E_
DC AS TIM R3 U _R UM EN
0
23
_ K E _R SE ES E_
(re TAS _TIM R2 ST _R UM EN
32 LED PWM Controller (LEDC)
se
0
22
K_ E _R _E ES E_
rv R S N UM EN
ed TIM 1_ T_
0
21
LE ) ER RS EN E_
EN
0 DC 0_ T_
20
LE _T RS EN
DC AS T_
0
19
LE _T K_ EN
DC AS OV
0
18
LE _T K_ F_
D AS O CN
LEDC_TASK_SIG_OUT_DIS_CHn task.
0
17
LE C_T K_ VF_ T_
LEDC_TASK_OVF_CNT_RST_CHn task.
D AS O CN RS
LEDC_TASK_TIMERx_RES_UPDATE task.
0
16
LE C_T K_ VF_ T_ T_
DC AS OV CN RS CH
0
15
_ K F_ T T_ 5_
LEDC_TASK_SIG_OUT_DIS_CHn_EN Configures
(re TAS _OV CN _RS CH EN
947
LEDC_TASK_OVF_CNT_RST_CHn_EN Configures
se
0
14
K_ F_ T_ T_ 4_
rv
LEDC_TASK_TIMERx_RES_UPDATE_EN Configures
ed OV CN RS CH EN
0
13
LE ) F_ T_ T_ 3_
D CN RS CH EN
LEDC_TASK_TIMERx_PAUSE_RESUME_EN Configures
0
12
LE C_T T_ T_ 2_
DC AS RS CH EN
0
11
LE _T K_ T_ 1_
whether
whether
DC AS SI CH EN
LE _T K_ G_ 0_
whether
DC AS SI U O EN
K G T
9
whether
or
LE _T _ _ _
or
DC AS SI OU DIS
or
8
LE _T K_ G_ T_ _C
D AS SI OU DIS H
or
7
LE C_T K_ G_ T_ _C 5_E
not
Register 32.4. LEDC_EVT_TASK_EN1_REG (0x01A4)
not
LE C_T K_ G_ T_ _C 4_E
not
D AS SI OU DIS H N
5
LE C_T K_ G_ T_ _C 3_E
to
to
D AS TI OU DIS H N
to
4
to
LE C_T K_ ME T_ _C 2_E
D AS TI R3 DIS H N
3
LE C_T K_ ME _C _C 1_E
D AS TI R2 AP H N
2
LE C_T K_ ME _C _E 0_E
D AS TI R1 AP N N
enable
enable
enable
1
enable
LE C_T K_ ME _C _E
D AS TI R0 AP N
0
LE C_T K_ ME _C _E
DC AS TIM R3 AP N
the
LEDC_TASK_TIMERx_RST_EN Configures whether or not to enable the LEDC_TASK_TIMERx_RST
the
the
LEDC_TASK_TIMERx_CAP_EN Configures whether or not to enable the LEDC_TASK_TIMERx_CAP
the
_T K_ E _RE _EN
AS TI R2 S
0 Reset
K_ ME _R _U
PRELIMINARY
GoBack
TI R1 ES PD
31
31
0
0
0
0
0
0
(R/W)
(R/W)
(R/W)
0
0
Espressif Systems
1: Enable
1: Enable
1: Enable
(re
0: Disable
0: Disable
0: Disable
0
0
se
(re rv
ed
0
0
se
rv )
ed
0
0
)
0
0
32 LED PWM Controller (LEDC)
0
0
22
0
21
0
LE
0 D
20
0
20
LE C_T
DC AS
19
0
19
LE _T K_
D AS G
0
18
LE C_T K_ AM
DC AS GA MA
0
17
LE _T K_ M _R
D AS G MA ES
LEDC_TASK_GAMMA_PAUSE_CHn task.
0
16
LE C_T K_ AM _R UM
LEDC_TASK_GAMMA_RESUME_CHn task.
LEDC_TASK_GAMMA_RESTART_CHn task.
DC AS GA MA ES E
0
15
_ K M _R U _C
(re TAS _GA MA ES ME H5
948
se
0
14
K_ M _R UM _C _E
M H N
LEDC_TASK_GAMMA_PAUSE_CHn_EN Configures
rv
ed GA A_ ESU E_ 4_
0
13
LEDC_TASK_GAMMA_RESUME_CHn_EN Configures
LE M R M C EN
LEDC_TASK_GAMMA_RESTART_CHn_EN Configures
D M E H
A_ SU E_ 3_
0
12
LE C_T RE M CH EN
D AS SU E_ 2_
0
11
LE C_T K_ M CH EN
DC AS GA E_ 1_
whether
10
LE _T K_ M CH EN
whether
LE DC AS GA MA
whether
0_
K _
9
0x000
DC LE _T _ M P EN
_T DC AS GA MA AU
or
8
IM LE _T K_ M _P SE
or
or
ER DC AS GA MA AU _C
7
0_ _ K M _P SE H
CM (re TAS _GA MA AU _C 5_E
Register 32.5. LEDC_EVT_TASK_EN2_REG (0x01A8)
not
P se
0
6
not K_ M _P SE H4 N
M
not
rv
LE ) M P E 3
M A
D
to
to
LE C_T PA E_ 2_
DC AS US CH EN
3
LE _T K_ E_ 1_
DC AS GA CH EN
2
LE _T K_ M 0_
DC AS GA MA EN
enable
1
enable
0
enable
LE _T K_ M _R
DC AS GA MA ES
0
0
LE _T K_ M _R TA
DC AS GA MA ES RT
the
the
the
_T K_ M _R TA _C
AS G MA ES RT H5
Reset
0 Reset
K_ AM _R TA _C _E
PRELIMINARY
GoBack
G MA ES RT H4 N
AP
_C
T
CN
0_
ER
IM
d)
_T
ve
DC
er
s
LE
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
LE GA A_ AM LK N_C 5
A M LK N_ 4
M LK _ 3
LK _ 2
N_ 1
0
_ MM R _C _E CH
DC MM RA _C _E H
CL _RA _C _EN CH
SE _C _EN CH
_E CH
CH
DC A A_ M LK _
LE C_G MM _RA _C _EN
D A A M LK
LE _G MM RA _C
DC A A_ M
LE C_G MM _RA
L
EN
D A A
LE C_G MM
K_
K_
D A
L
)
ed
LE _G
_C
_S
rv
DC
DC
se
LE
LE
(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 Reset
PRELIMINARY
Espressif Systems 949 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
0
CH
T_
IN
PO
)
ed
_H
v
DC
ser
LE
31 (re 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
0
CH
Y_
UT
)
ed
_D
rv
DC
se
LE
(re
31 25 24 0
0 0 0 0 0 0 0 0x00000 Reset
_D
rv
DC
se
LE
(re
31 25 24 0
0 0 0 0 0 0 0 0x00000 Reset
LEDC_DUTY_CHn_R Represents the current duty cycle of the output signal on channel n. (RO)
PRELIMINARY
Espressif Systems 950 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
32 LED PWM Controller (LEDC) GoBack
ES
P
_R
_U
ER
E
TY
US
RA
IM
0_ T
DU
ER RS
PA
PA
_T
D d) 0_
IM _
0_
IV
0
_D
LE rve ER
_T ER
ER
K
se IM
DC IM
IM
CL
d)
(re C_T
LE C_T
_T
ve
C_
DC
er
D
s
LE
LE
LE
(re
31 27 26 25 24 23 22 5 4 0
LEDC_TIMERx_DUTY_RES Configures the duty cycle resolution (the width of the counter in timer n).
(R/W)
LEDC_TIMERx_RST Configures whether or not to reset timer n (the counter will show 0 after reset).
0: Not reset
1: Reset
(R/W)
_T
e
rv
DC
se
LE
(re
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PRELIMINARY
Espressif Systems 951 ESP32-H2 TRM (Pre-release v0.4)
Submit Documentation Feedback
0
0
31
31
0
0
0
0
0
0
0
0
Espressif Systems
0
0
(R/WTC/SS)
0
0
(re (re
s
0
0
se er
rv ve
ed
0
0
) d)
32 LED PWM Controller (LEDC)
0
0
0
0
0
0
0
0
LEDC_OVF_CNT_CHn_INT_RAW The
0
18
0
18
LEDC_DUTY_CHNG_END_CHn_INT.
0
0
17
17
LE LE
D D
raw
0
0
16
16
LE C_O LE C_O
LEDC_DUTY_CHNG_END_CHn_INT_ST The
D V DC V
LEDC_DUTY_CHNG_END_CHn_INT_RAW The
0
0
15
15
952
0
0
14
14
DC V N H DC V N H
0
0
13
13
D V N H NT D V N H NT
0
0
12
12
DC V N H NT T DC V N H NT AW
0
0
11
11
masked
_ F_ T_ 3_ _S _ F_ T_ 3_ _R
se se
0
10
0
10
rv C C IN T rv C C IN A
ed NT H1 T_ ed NT H1 T_ W
9
9
0
0
LE ) _C _I S LE ) _C _I R
D D
of
H0 NT T H0 NT AW
8
8
0
0
7
7
0
0
Register 32.14. LEDC_INT_RAW_REG (0x00C0)
LE _D TY_ _S LE _D TY_ _R
T AW
interrupt
DC U C DC U C
T H T H
interrupt
6
6
0
0
LE _D Y_ N LE _D Y_ N
D U C G_ DC U C G_
5
5
0
0
4
4
0
0
0
0
2
2
0
0
status
LE C_T TY_ HN EN CH IN ST LE C_T TY_ HN EN CH IN RAW
1
1
0
0
DC IM 2_ F_ D_ 1_ T_S DC IM 2_ F_ D_ 1_ T_R
of
of
LEDC_OVF_CNT_CHn_INT.
ER OV IN T IN T ER OV IN AW IN A
PRELIMINARY
T_ T_ W
GoBack
0_ F_ T_S 0_ F_ T_R
31
31
0
0
0
0
0
0
(WT)
(R/W)
0
0
Espressif Systems
0
0
0
0
(re (re
s
0
0
se
rve
er
ve
0
0
d) d)
32 LED PWM Controller (LEDC)
0
0
0
0
0
0
0
0
0
18
0
18
0
0
17
17
LE LE
DC D
0
0
16
16
LE _O LE C_O
D V DC V
0
0
15
15
953
0
0
14
14
0
0
13
13
0
0
12
12
0
0
11
11
_ F_ T_ 3_ _C _ F_ T_ 3_ _E
(re OV CN CH INT LR (re OV CN CH INT NA
0
10
0
10
rv C C IN L rv C C IN N
ed NT H1 T_ R ed NT H1 T_ A
9
9
0
0
LE ) _C _I C LE ) _C _I EN
D H0 NT LR D H0 NT A
8
8
0
0
7
7
0
0
LE _D TY_ _C LE _D TY_ _E
DC U C LR DC U C NA
T H T H
6
6
0
0
LE _D Y_ N LE _D Y_ N
5
5
0
0
0
0
3
3
0
0
2
2
0
0
0
0
ER OV IN LR IN L ER OV IN NA IN N
PRELIMINARY
T_ R T_ A
GoBack
0_ F_ T_C 0_ F_ T_E