Esp32-C6 Technical Reference Manual en - Pdf#riscvcpu
Esp32-C6 Technical Reference Manual en - Pdf#riscvcpu
Version 1.0
Espressif Systems
Copyright © 2024
www.espressif.com
About This Document
The ESP32-C6 Technical Reference Manual is targeted at developers working on low level software projects
that use the ESP32-C6 SoC. It describes the hardware modules listed below for the ESP32-C6 SoC and other
products in ESP32-C6 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 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-c6_technical_reference_manual_en.pdf
Contents
1 High-Performance CPU 36
1.1 Overview 36
1.2 Features 36
1.3 Terminology 37
1.4 Address Map 37
1.5 Configuration and Status Registers (CSRs) 37
1.5.1 Register Summary 37
1.5.2 Register Description 39
1.6 Interrupt Controller 52
1.6.1 Features 52
1.6.2 Functional Description 52
1.6.3 Suggested Operation 54
1.6.3.1 Latency Aspects 54
1.6.3.2 Configuration Procedure 55
1.6.4 Registers 56
1.7 Core Local Interrupts (CLINT) 57
1.7.1 Overview 57
1.7.2 Features 57
1.7.3 Software Interrupt 57
1.7.4 Timer Counter and Interrupt 57
1.7.5 Register Summary 58
1.7.6 Register Description 58
1.8 Physical Memory Protection 62
1.8.1 Overview 62
1.8.2 Features 62
1.8.3 Functional Description 62
1.8.4 Register Summary 63
1.8.5 Register Description 63
1.9 Physical Memory Attribute (PMA) Checker 64
1.9.1 Overview 64
1.9.2 Features 64
1.9.3 Functional Description 64
1.9.4 Register Summary 65
1.9.5 Register Description 66
1.10 Debug 67
1.10.1 Overview 67
1.10.2 Features 68
1.10.3 Functional Description 68
1.10.4 JTAG Control 68
1.10.5 Register Summary 69
1.10.6 Register Description 69
1.11 Hardware Trigger 72
1.11.1 Features 72
1.11.2 Functional Description 72
1.11.3 Trigger Execution Flow 73
1.11.4 Register Summary 73
1.11.5 Register Description 74
1.12 Trace 78
1.12.1 Overview 78
1.12.2 Features 78
1.12.3 Functional Description 78
1.13 Debug Cross-Triggering 79
1.13.1 Overview 79
1.13.2 Features 79
1.13.3 Functional Description 79
1.13.4 Register Summary 80
1.13.5 Register Description 80
1.14 Dedicated IO 81
1.14.1 Overview 81
1.14.2 Features 81
1.14.3 Functional Description 81
1.14.4 Register Summary 82
1.14.5 Register Description 82
1.15 Atomic (A) Extension 84
1.15.1 Overview 84
1.15.2 Functional Description 84
1.15.2.1 Load Reserve (LR.W) Instruction 84
1.15.2.2 Store Conditional (SC.W) Instruction 84
1.15.2.3 AMO Instructions 85
Glossary 1352
Abbreviations for Peripherals 1352
Abbreviations Related to Registers 1352
Access Types for Registers 1354
List of Tables
1-2 CPU Address Map 37
1-4 Core Local Interrupt (CLINT) Sources 57
1-10 NAPOT encoding for maddress 73
2-2 Trace Encoder Parameters 88
2-3 Header Format 90
2-4 Index Format 91
2-5 Packet format 3 subformat 0 91
2-6 Packet format 3 subformat 1 91
2-7 Packet format 3 subformat 3 92
2-8 Packet format 2 92
2-9 Packet format 1 with address 93
2-10 Packet format 1 without address 94
3-2 LP CPU Exception Causes 111
3-5 Performance Counter 118
3-6 Wake Sources 122
4-1 Selecting Peripherals via Register Configuration 127
4-2 Descriptor Field Alignment Requirements 130
5-1 Memory Address Mapping 163
5-2 Module/Peripheral Address Mapping 167
6-1 Parameters in eFuse BLOCK0 172
6-2 Secure Key Purpose Values 175
6-3 Parameters in BLOCK1 to BLOCK10 176
6-4 Registers Information 181
6-5 Configuration of Default VDDQ Timing Parameters 182
7-1 Bit Used to Control IO MUX Functions in Light-sleep Mode 244
7-2 Peripheral Signals via GPIO Matrix 247
7-3 IO MUX Functions List 252
7-4 LP IO MUX Functions List 253
7-5 Analog Functions of IO MUX Pins 254
8-1 Reset Source 294
8-2 CPU_CLK Clock Source 296
8-3 Frequency of CPU_CLK, AHB_CLK and HP_ROOT_CLK 297
8-4 Derived Clock Source 299
8-5 HP Clocks Used by Each Peripheral 299
8-6 LP Clocks Used by Each Peripheral 300
8-7 Mapping Between PMU Register Bits and the Clock Gating of Peripherals’ Register R/W Operations302
8-8 Mapping Between PMU Register Bits and the Gating of Peripherals’ Operating Clock 303
9-1 Default Configuration of Strapping Pins 363
9-2 Boot Mode Control 363
9-3 ROM Message Printing Control 365
9-4 JTAG Signal Source Control 366
9-5 SDIO Input Sampling Edge/Output Driving Edge Control 366
10-1 CPU Peripheral Interrupt Source Mapping/Status Registers and Peripheral Interrupt Sources 369
List of Figures
1-1 CPU Block Diagram 36
1-2 Debug System Overview 67
2-1 Trace Encoder Overview 86
2-2 Trace Overview 87
2-3 Trace packet Format 90
3-1 LP CPU Overview 102
3-2 Wake-Up and Sleep Flow of LP CPU 120
4-1 Modules with GDMA Feature and GDMA Channels 124
4-2 GDMA controller Architecture 125
4-3 Structure of a Linked List 126
4-4 Relationship among Linked Lists 128
5-1 System Structure and Address Mapping 162
5-2 Cache Structure 165
5-3 Modules/peripherals that can work with GDMA 166
6-1 Data Flow in eFuse 171
6-2 Shift Register Circuit (first 32 output) 178
6-3 Shift Register Circuit (last 12 output) 178
7-1 Architecture of IO MUX, LP IO MUX, and GPIO Matrix 236
7-2 Internal Structure of a Pad 237
7-3 GPIO Input Synchronized on Rising Edge or on Falling Edge of IO MUX Operating Clock 238
7-4 GPIO Filter Timing of GPIO Input Signals 239
7-5 Glitch Filter Timing Example 239
8-1 Reset Types 293
8-2 System Clock 295
8-3 Clock Configuration Example 305
9-1 Chip Boot Flow 364
10-1 Interrupt Matrix Structure 367
11-1 Event Task Matrix Architecture 386
11-2 ETM Channeln Architecture 387
11-3 Event Task Matrix Clock Architecture 394
12-1 ESP32-C6 Power Scheme 405
12-2 PMU Workflow 407
12-3 Brownout Reset Workflow 417
12-4 ESP32-C6 Boot Flow 419
13-1 System Timer Structure 482
13-2 System Timer Alarm Generation 483
14-1 Timer Group Overview 505
14-2 Timer Group Architecture 506
15-1 Watchdog Timers Overview 529
15-2 Digital Watchdog Timers in ESP32-C6 531
15-3 Super Watchdog Controller Structure 534
16-1 PMP-APM Management Relation 544
16-2 APM Controller Structure 546
1 High-Performance 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 160 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
• 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.
¹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
²mtvec only provides configuration for trap handling in vectored mode with the base address aligned to 256 bytes
³External interrupt IDs reflected in mcause include even those IDs which have been reserved by RISC-V standard for core internal sources.
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
⁴These custom CSRs have been implemented in the address space reserved by RISC-V standard for custom use
ID
CH
AR
M
31 0
0x80000002 Reset
D
PI
IM
M
31 0
0x00000002 Reset
31 0
0x00000000 Reset
UP ed)
)
ed
ed
ed
ed
rv
rv
rv
rv
rv
se
se
se
se
se
E
IE
PP
PI
IE
E
(re
TW
(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) instruc-
tion is executed in U mode.
0: Not cause illegal exception in U mode
1: Cause illegal instruction exception
(R/W)
)
ed
rv
se
XL
(re
M
M
W
O
U
G
N
C
H
B
Z
P
R
V
A
T
Y
E
F
X
J
L
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)
EG
EL
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]
:8
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
E
se
SE
OD
(re
BA
31 8 7 2 1 0
MODE Represents whether machine 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)
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)
de
Co
g
la
)
F
n
ed
io
pt
rv
pt
rru
se
ce
te
(re
Ex
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)
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)
UT :5]
:8
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
)
ed
ed
rv
rv
se
se
IE
E
(re
(re
UP
UI
31 5 4 3 1 0
UPIE Write 1 to enable the user previous interrupt (before trap). (R/W)
UX ed)
UX ed)
]
]
:8
US 1]
:5
31
:
rv
rv
[6
[2
E[
se
se
IE
IE
IE
IE
I
(re
(re
UX
UT
31 8 7 6 5 4 3 2 1 0
)
ed
rv
E
se
SE
OD
(re
BA
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)
de
Co
g
la
)
F
n
ed
io
pt
rv
pt
rru
se
ce
te
(re
Ex
In
31 30 5 4 0
Interrupt ID This field is automatically updated with the unique ID of the most recent user mode
interrupt 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 ed)
UX ed)
]
1:8
:1]
:4
rv
rv
[2
[3
[5
se
se
IP
IP
IP
IP
IP
(re
(re
UX
US
UT
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)
P H KEN
IN AZ ARD
JM NC _TA
LO RE ON
RD
BR NC P
)
RA M
O C
_H Z
ed
A H
ST A
(B _CO
ST _UN
LD _HA
rv
E
se
ID D
CL
ST
P
LE
A
JM
(re
CY
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
se
U
CO
(re
31 2 1 0
0 1 1 Reset
CR
PC
M
31 0
0x00000000 Reset
• 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 10
Interrupt Matrix (INTMTX) > Section 10.4.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):
• 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 same priority are statically prioritized by their IDs, lowest ID having 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 modes.
• 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 detailed description of the core local interrupt sources, please refer to Section 1.7.
• 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.
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 are jump instructions 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 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 10.4.2 and
Section 10.5.2 respectively.
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 modes.
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.
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 64b timer value exceeds the 64b 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 64b 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.
d)
rve
se
P
SI
(re
M
31 1 0
0x00000000 0 Reset
M F
E
se
P
E
TO
TC
TI
TI
(re
M
M
31 4 3 2 1 0
0x0000000 0 0 0 0 Reset
]
:32
63
E[
M
TI
M
63 32
0 Reset
]
:0
31
E[
M
TI
M
31 0
0 Reset
]
32
3:
6
P[
M
EC
M
TI
M
63 32
0 Reset
]
:0
31
P[
M
EC
M
TI
M
31 0
0 Reset
I P
(re
US
31 1 0
0x00000000 0 Reset
)
ed
ed
rv
rv
se
se
UT F
IP
IE
O
(re
(re
UT
UT
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[
I M
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
I M
UT
31 0
0 Reset
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. 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, software can set the lock bit of 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 processor level and 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.
1.9.2 Features
PMAC supports below features:
Exception generation and handling for PMAC related faults will be handled in 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 processor level and 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 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.
TE
se E
ed
ed
PE d
U
re UT
TY rve
IB
EX E
rv
rv
re K
W D
EC
T
TR
se
se
C
A
RI
LO
RE
AT
re
A
31 30 29 28 27 24 23 5 4 3 2 1 0
2 0 0 0 0 0 0 0 0 0 Reset
A Configures address type. The functionality is the same as pmpcfg register’s A field. (R/W)
0x0: OFF
0x1: TOR
0x2: NA4
0x3: NAPOT
LOCK Configures whether to lock the corresponding pma_cfgX and pma_addrX. (R/W)
0: Not locked
1: Locked. The write permission to the corresponding pma_cfgX and pma_addrX is revoked.
It can only be unlocked by core reset.
31 0
0 Reset
1.10 Debug
1.10.1 Overview
This section describes how to debug software running on HP and LP CPU cores. 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 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.
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.
Temporary EFUSE_DIS_ EFUSE_DIS_ EFUSE_DIS_ EFUSE_JTAG_ Strapping USB JTAG PAD JTAG
disable USB_JTAG USB_SERIAL_ PAD_JTAG 4 SEL_ENABLE Pin Status Status
JTAG 3,4 4 JTAG 4 4 GPIO15 5
0 0 0 0 0 x2 Available 1 Unavailable 1
0 0 0 0 1 1 Available Unavailable
Temporary EFUSE_DIS_ EFUSE_DIS_ EFUSE_DIS_ EFUSE_JTAG_ Strapping USB JTAG PAD JTAG
disable USB_JTAG USB_SERIAL_ PAD_JTAG 4 SEL_ENABLE Pin Status Status
JTAG 3 4 JTAG 4 4 GPIO15 5
0 0 0 0 1 0 Unavailable Available
0 0 1 0 x x Unavailable Available
0 1 0 0 x x Unavailable Available
0 1 1 0 x x Unavailable Available
0 0 0 1 x x Available Unavailable
0 0 1 1 x x Unavailable Unavailable
0 1 0 1 x x Unavailable Unavailable
0 1 1 1 x x Unavailable Unavailable
1 x x x x x Unavailable Unavailable
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-C6, 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 GPIO15.
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.
er
tim t
op n
e
gv
ed
eb d
op d
ed
st cou
m
re aku
e
st rve
ak
bu
rv
rv
rv
e
ep
us
re
re
se
se
se
se
e
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.
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.
Setting this bit does not mask interrupts. This is a deviation from the RISC-V External Debug
Support Specification Version 0.13.
(R/W)
prv Contains the privilege level the core was operating in when Debug Mode was entered. A de-
bugger 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)
c
dp
31 0
0 Reset
dpc Upon entry to debug mode, dpc is written with the virtual address of the instruction that en-
countered 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)
0
ch
at
cr
ds
31 0
0 Reset
31 0
0 Reset
• each unit can be configured for matching the address of 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 (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.
)
ed
rv
t
ec
se
el
(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
supported. (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)
)
ed
ed
rv
rv
se
se
e
pt
te
(re
(re
m
m
31 8 7 6 1 0
)
ed
ed
ed
ed
ed
st ute
rv
rv
rv
rv
rv
e
ch
od
se
se
se
se
se
e
tio
ec
ad
or
at
dm
(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)
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)
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.
1.13.2 Features
• Control register to enable or disable cross-trigger between cores
d)
ve
r
n
se
_e
(re
xt
31 1 0
0 0 Reset
1.14 Dedicated IO
1.14.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.14.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.
]
CP GP _O [6]
GP _O [2]
CP _GP _O [3]
CP _GP _O [5]
CP _GP _O [4]
CP _GP _O [7]
EN ]
[0
_O [1
U IO EN
U_ IO EN
U IO EN
U IO EN
U IO EN
U_ IO EN
I O EN
CP GP _O
U_ IO
)
ed
CP _GP
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 7-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)
0]
CP GP _IN ]
GP _IN ]
CP _GP _IN ]
CP _GP _IN ]
CP _GP _IN ]
CP _GP _IN ]
IO [1]
U_ IO [6
U_ IO [2
U IO [3
U IO [5
U IO [4
U IO [7
N[
CP GP _IN
_I
U_ IO
)
ed
CP _GP
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 7-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 7.4 in Chapter IO MUX and GPIO Matrix (GPIO, IO MUX).
(RO)
]
CP GP _O [6]
GP _O [2]
CP _GP _O [3]
CP _GP _O [5]
CP _GP _O [4]
CP _GP _O [7]
UT ]
[0
_O [1
U IO UT
U_ IO UT
U IO UT
U IO UT
U IO UT
U_ IO UT
IO UT
CP _GP _O
U IO
)
ed
CP _GP
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 7-2 Peripheral
Signals via GPIO Matrix.
CPU_GPIO_OUT[7:0] can only be mapped to GPIO pins through GPIO matrix. For details please
refer to Section 7.5 in Chapter IO MUX and GPIO Matrix (GPIO, IO MUX).
(R/W)
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 instruction
is encountered instead, the lock will be released eventually (not immediately) in the manner described in
Section 1.15.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 acknowledgement 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.15.2.1), it will set a fail code (currently always 1) in the destination register rd.
1. Read data from 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 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.
HP
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, for example, 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.
ESP Chip
Debug Host
Instruction Trace
Interface
JTAG Trace Encoder
DTM
Debug
Translator JTAG/
USB-JTAG adapter
DMI HP CPU Core
BUS
Trace
Decoder System
DM Memory
• The HP CPU core provides an instruction trace interface that outputs the instruction information executed
by the HP CPU. Such information includes instruction address, instruction type, etc. For more details
about ESP32-C6 HP CPU’s instruction trace interface, please refer to Chapter 1 High-Performance CPU.
• The trace encoder connects to the HP CPU’s instruction trace interface and compresses the information
into lower bandwidth 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-C6’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:
– 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 HP 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 bandwidth is insufficient, the FIFO may overflow 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.
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 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
Header is 1-byte long. The format of header is shown in Table 2-3.
2.6.2 Index
Index has 2 bytes. The format of index is shown in Table 2-4.
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-C6 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 expiry of the synchronization timer. The payload length is 5
bytes.
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.
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.
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.
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 HP 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 HP CPU can respond to these trace encoder interrupts. For details, please refer to Chapter
10 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
Once the encoder is enabled, it will keep tracing the HP 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
The abbreviations given in Column Access are explained in Section Access Types for Registers.
2.10 Registers
The addresses in this section are relative to RISC-V Trace Encoder base address provided in Table 5-2 in
Chapter 5 System and Memory.
R
DD
_A
RT
TA
_S
EM
M
E_
AC
TR
31 0
0x000000 Reset
31 0
0xffffffff Reset
31 0
0x000000 Reset
AT
UPD
R_
DD
_A
NT
RE
UR
_C
EM
d)
M
ve
E_
r
AC
se
(re
TR
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 US
Y
_E AT
PT
FO ST
FI K_
E_ R
AC WO
)
ed
TR CE_
rv
se
A
(re
TR
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
A
EN
R_
W NA
NT
LO _E
_I
RF TR
VE _IN
_O LL
FO U
FI _F
E_ EM
d)
AC M
ve
TR CE_
r
se
A
(re
TR
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
ed
TR CE_
rv
se
A
(re
TR
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
AC M
ed
TR CE_
rv
se
A
(re
TR
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_ IGG OO A
R_ F
ON
AC TR _L N
GE OF
TR E P
TR CE_ EM T_E
IG R_
A M AR
TR E_ ST
AC RE
)
ed
TR CE_
rv
se
A
(re
TR
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)
RO
M
_P
C_
NC
YN
SY
ES
E
)
ed
_R
_R
rv
E
AC
AC
se
(re
TR
TR
31 25 24 23 0
0 0 0 0 0 0 0 0 128 Reset
N
K _E
CL
d)
ve
E_
r
AC
se
(re
TR
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)
E
AT
)
ed
_D
rv
E
AC
se
(re
TR
31 28 27 0
0 0 0 0 0x2203030 Reset
3 Low-Power CPU
The ESP32-C6 Low-Power CPU (LP CPU) is a 32-bit processor based upon RISC-V ISA comprising integer (I),
multiplication/division (M), atomic (A), and compressed (C) standard extensions. It features ultra-low power
consumption and has a 2-stage, in-order, and scalar pipeline. The LP CPU core complex has an interrupt
controller (INTC), a debug module (DM), and system bus (SYS BUS) interfaces for memory and peripheral
access.
The LP CPU is in sleep mode by default (see Section 3.9). It can stay powered on when the chip enters
Deep-sleep mode (see Chapter 12 Low-Power Management for details) and can access most peripherals and
memories (see Chapter 5 System and Memory for details). It has two application scenarios:
• Power insensitive scenario: When the High-Performance CPU (HP CPU) is active, the LP CPU can assist
the HP CPU with some speed- and efficiency-insensitive controls and computations.
• Power sensitive scenario: When the HP CPU is in the power-down state to save power, the LP CPU can
be woken up to handle some external wake-up events.
HP CPU LP CPU
3.1 Features
The LP CPU has the following features:
• 1 vector interrupts
• Debug module compliant with RISC-V External Debug Support Version 0.13 with external debugger
support over an industry-standard JTAG/USB port
• Hardware trigger compliant with RISC-V External Debug Support Version 0.13 with up to 2
breakpoints/watchpoints
⁵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.
⁶mtvec only provides configuration for trap handling in vectored mode with the base address aligned to 256 bytes.
⁷External interrupt IDs reflected in mcause include even those IDs which have been reserved by RISC-V standard for core internal sources.
Note that if write, set, or clear operation is attempted on any of the read-only (RO) CSRs indicated in the above
table, the CPU will generate an illegal instruction exception.
3.2.2 Registers
ID
RT
HA
M
31 0
0x00000001 Reset
)
ed
ed
ed
ed
ed
rv
rv
rv
rv
rv
se
se
se
se
se
E
PP
PI
IE
(re
TW
(re
(re
(re
(re
M
M
31 22 21 20 13 12 11 10 8 7 6 4 3 2 0
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) instruc-
tion is executed in User mode.
0: Not cause illegal exception in User mode
1: Cause illegal instruction exception
(R/W)
)
ed
rv
se
XL
(re
M
M
W
O
U
G
N
C
H
B
Z
P
R
V
A
T
Y
E
F
X
J
L
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)
d)
)
ed
IE rve
rv
se
se
(re
(re
31 30 29 0
)
ed
rv
E
se
SE
OD
(re
BA
M
31 8 7 2 1 0
MODE Represents whether machine 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
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)
de
Co
g
la
)
F
n
ed
io
pt
rv
pt
rru
se
ce
te
(re
Ex
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:
0x2: Illegal instruction
0x3: Hardware breakpoint/watchpoint or EBREAK
0x6: Misaligned atomic instructions
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,
it indicates that the latest trap occurred due to an interrupt. For exceptions it remains unset.
(R/W)
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)
d)
)
ed
IP rve
rv
se
se
(re
(re
31 30 29 0
e
cl
cy
m
31 0
0x0 Reset
MCYCLE Configures the lower 32 bits of the clock cycle counter. (R/W)
31 0
0x0 Reset
31 0
0x0 Reset
eh
cl
cy
m
31 0
0x0 Reset
MCYCLEH Configures the higher 32 bits of the clock cycle counter. (R/W)
th
re
st
in
m
31 0
0x0 Reset
31 0
0x0 Reset
d )
CY rve
se
M
(re
HP
IR
31 3 2 1 0
• Saves the current program counter (PC) value to the mepc CSR
– For exceptions, the handler address is the base address of the vector table in the mtvec CSR.
After the mret instruction is executed, the core jumps to the PC saved in the mepc CSR and restores the
value of MPIE of mstatus to MIE of mstatus .
When the core starts up, the base address of the vector table is initialized to the boot address 0x50000000.
After startup, the base address can be changed by writing to the mtvec CSR. For more information about
CSRs, see Section 3.2.1.
3.3.1 Interrupts
The ESP32-C6 LP CPU supports only one interrupt entry, to which all interrupt events jump. The LP CPU
supports the following peripheral interrupt sources:
For more information on those peripheral interrupts, please refer to the corresponding chapter.
1. Enable interrupts
2. After interrupts are enabled, the LP CPU can respond to interrupts. It also needs to configure interrupts
of the peripherals so that they can send an interrupt signal to the LP CPU.
4. After enterring the interrupt handler, users need to read LPPERI_INTERRUPT_SOURCE_REG to get the
peripheral that triggered the interrupt and process the interrupt. Note that if the interrupts are triggered
by multiple peripherals, the CPU will process them one by one in sequence until none is left. If not all
interrupts are processed, the CPU will enter the interrupt handler again.
3.3.3 Exceptions
The LP CPU supports the RISC-V standard exceptions and can trigger the following exceptions:
Exception ID Description
2 Illegal instructions
3 Breakpoints (EBREAK)
6 Misaligned atomic instructions
3.4 Debugging
This section describes how to debug and test the LP CPU. Debug support is provided through standard JTAG
pins and complies with RISC-V External Debug Support Version 0.13.
For ESP32-C6 system debugging overview, please refer to Section 1.10 Debug > Figure 1-2.
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 CPU’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).
DM supports multi-core debugging in compliance with the specification RISC-V External Debug Support
Version 0.13, and can control the HP CPU and the LP CPU simultaneously. Hart 1 represents the LP CPU. Users
can use OpenOCD to select a hart (0: HP CPU, 1: LP CPU) for debugging.
The LP CPU implements four registers for core debugging: dcsr, dpc, dscratch0, and dscratch1. All of those
registers can only be accessed from debug mode. If software attempts to access them when the LP CPU is
not in debug mode, an illegal instruction exception will be triggered.
3.4.1 Features
The Low-Power CPU has the following debugging features:
• Hardware single-stepping.
• Two hardware triggers (which can be used as breakpoints/watchpoints). See Section 3.5 for details.
According to the specification, a hart can be in the following states: nonexistent, unavail, running, and halted.
By default, the LP CPU is in the unavail state. To connect the LP CPU for debugging, users need to clear the
state by configuring the LPPERI_CPU_REG register.
All debug module registers are implemented in accordance with the specification RISC-V External Debug
3.4.4 Registers
The following is a detailed description of the debug CSR supported by the LP CPU.
d)
eb ed)
)
ed
ed
gv
ve
(re m
u
rv
rv
rv
ak
ak
bu
e
se
se
se
se
ep
us
re
re
e
v
(re
(re
(re
xd
eb
pr
ca
st
31 28 27 16 15 14 13 12 11 9 8 6 5 3 2 1 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 Reset
cause Represents the reason 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: 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.
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.
Setting this bit does not mask interrupts. This is a deviation from the RISC-V External Debug
Support Specification Version 0.13.
(R/W)
prv Contains the privilege level the core is operating in when debug mode is 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. (RO)
c
dp
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
dpc Upon entry to debug mode, dpc is written with the address of the next instruction that will be
executed. When resuming, the CPU core’s PC is updated to the address stored in dpc. In debug
mode, dpc can be modified. This field can be accessed in debug mode. (R/W)
0
ch
at
cr
ds
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
To select a specific trigger unit, the corresponding number (0-1) needs to be written to the tselect CSR. When
a valid value is written, the abstract CSRs, tdata1 and tdata2, automatically match the internal registers of the
trigger unit. Each trigger unit has two internal registers, namely mcontrol and maddress, which are mapped to
tdata1 and tdata2, respectively.
Since software or debugger may need to know the type of the selected trigger to correctly interpret tdata1 and
tdata2, the 4-bit field (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 support for address and data matching.
Hence, it is inferred that tdata1 and tdata2 are to be interpreted as fields of mcontrol and maddress,
respectively. The specification RISC-V External Debug Support Version 0.13 provides information on other
possible values, but the trigger module only supports the 0x2 type.
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).
• The cause field in dcsr is set to 2, which means halt due to trigger
3.5.5 Registers
31 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
e
od
pe
ta
dm
da
ty
31 28 27 26 0
0 0 1 0 1 0 x 1 0 4 0 Reset
type Represents the trigger type. This field is reserved since only match type (0x2) triggers are
supported. (RO)
dmode This is set to 1 if a trigger is being used by the debugger. This field is reserved since it is
only supported in debug mode. (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
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
tdata2 Configures the abstract tdata2 content. This will always be interpreted as maddress since
only match type (0x2) triggers are supported. (R/W)
d)
ed
ax
s rve
st ute
rv
km
ch
tim ct
od
o
se
se
n
in
e
tio
ec
el
ad
le
ai
as
or
at
dm
(re
(re
siz
ch
se
ac
t
ex
m
lo
hi
u
31 28 27 26 21 20 19 18 17 16 15 12 11 10 7 6 5 4 3 2 1 0
sizelo Only match of any size is supported. This field remains 0. (RO)
match Configures the trigger to perform the matching operation of the lower data/instruction ad-
dress.
0x0: Exact match. Namely, the address corresponding to a certain byte during the access must
exactly match the value of maddress.
0x1: NAPOT match. Namely, at least one byte during the access is in the NAPOT region specified
in maddress.
Note: Only exact byte match is supported. This field remains 0.
(R/W)
m Set this field to make the selected trigger operate in machine mode. (RO)
S Set this field to make the selected trigger operate in supervisor mode. Operation in supervisor
mode is not supported. This field is always 0. (RO)
U Set this field to make the selected trigger operate in user mode. Operation in user mode is not
supported. This field is always 0. (RO)
execute Configures whether to enable the selected trigger to match the virtual address of instruc-
tions.
0: Not enable
1: Enable
(R/W)
store Set this field to make the selected trigger match the virtual address of the memory write
operation. Not supported by hardware. This field is always 0. (RO)
load Set this field to make the selected trigger match the virtual address of a memory read operation.
Not supported by hardware. This field is always 0. (RO)
31 0
0x00000000 Reset
maddress Configures the address used by the selected trigger when performing match operation.
(R/W)
By default, all counters are enabled after reset. A counter can be enabled or disabled individually via the
corresponding bit in the mcountinhibit CSR.
• LP SRAM: 16 KB starting from 0x5000_0000 to 0x5000_3FFF, where you can fetch instructions, read
data, write data, etc.
• HP SRAM: 512 KB starting from 0x4080_0000 to 0x4087_FFFF, where you can fetch instructions, read
data, write data, etc.
Note:
The LP CPU has a high latency to access the HP SRAM, but can access the LP SRAM with no latency.
The LP CPU supports the atomic instruction set. Both the LP CPU and the HP CPU can access memory
through atomic instructions, thus achieving atomicity of memory access. For details on the atomic instruction
set, please refer to RISC-V Instruction Set Manual Volume I: Unprivileged ISA, Version 2.2.
• Able to actively configure registers to enter the sleep status based on software operating status
• Wake-up events:
– ETM events
3.9.2 Process
The LP CPU is in sleep by default and its wake-up module follows the process below to wake it up for work
and make it sleep.
stall PMU_LP_CPU_SLP_STALL_EN == 1
Stall stall unstall
unstall PMU_LP_CPU_SLP_STALL_EN == 0
disable PMU_LP_CPU_SLP_BYPASS_INTR_EN == 1
Interrupt disable enable
enable PMU_LP_CPU_SLP_BYPASS_INTR_EN == 0
enable PMU_LP_CPU_SLP_RESET_EN == 1
Reset enable disable
disable PMU_LP_CPU_SLP_RESET_EN == 0
PMU_LP_CPU_SLP_STALL_WAIT
The first startup of the LP CPU after power-up depends on the wake-up enable and wake-up source
configuration by the HP CPU.
– Start the LP CPU. Since the startup of the LP CPU depends on the wake-up process, it is
recommended to use the PMU_HP_TRIGGER_LP register to start the initialization of the LP CPU in
the following way:
• Wake-up process:
– The wake-up module receives a wake-up signal and sends a power-up request to the PMU.
– If the current power consumption state (clock, power supply, etc.) meets the requirements of the
LP CPU, the PMU will immediately reply with the completion signal. Otherwise, it will adjust the
power consumption state before replying with the completion signal.
– The wake-up module disables the STALL state of the LP CPU and enables interrupt receiving.
– The wake-up module starts the clock, releases reset (ignore this step if reset is not enabled for
sleep), and starts working.
• Sleep process:
– The LP CPU configures the register PMU_LP_CPU_SLEEP_REQ to enable the wake-up module to
start the sleep process.
– If PMU_LP_CPU_SLP_STALL_EN is 1, the wake-up module enables the STALL state of the LP CPU. If
it is 0, the module does not enable that state.
– The wake-up module waits for PMU_LP_CPU_SLP_STALL_WAIT LP CPU clock cycles, and then
turns off the LP CPU clock. If PMU_LP_CPU_SLP_RESET_EN is 1, the module enables reset of the
LP CPU.
3.11 Registers
The addresses in this section are relative to Low-Power Peripheral base address provided in Table 5-2 in
Chapter 5 System and Memory.
E
BL
IA
AL
AV
N
_U
M
BG
_D
RE
CO
P
d)
_L
ve
RI
r
se
PE
(re
LP
31 30 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 0 Reset
CE
O UR
_S
PT
RU
ER
NT
_I
LP
)
ed
I_
rv
ER
se
P
(re
LP
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
4.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-C6 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
4.2 Features
The GDMA controller has the following features:
4.3 Architecture
In ESP32-C6, 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 4-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 fixed-priority arbitration scheme for channels requesting read or write access. For available
address range of Internal RAM, please see Chapter 5 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.
Figure 4-3 shows the structure of a linked list. An outlink and an inlink have the same structure. A linked list is
formed by one or more descriptors, and each descriptor consists of three words. Linked lists should be in
internal RAM for the GDMA controller to be able to use them. 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 bit. 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.
• reserved (DW0) [29]: Reserved. 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 data segment corresponding to a descriptor, this bit in the receive descriptor is set to 1 by
hardware.
• length (DW0) [23:12]: Specifies the number of valid bytes in the buffer that this descriptor points to. This
field in a transmit descriptor is written by software and indicates how many bytes can be read from the
buffer; this field in a receive descriptor is written by hardware automatically and indicates how many 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,
this value is 0. This field can only point to internal RAM.
If the length of data received is smaller than the size of the buffer, the GDMA controller will not use available
space of the buffer in the next transaction.
Every transmit and receive channel can be connected to any peripheral with GDMA feature. Table 4-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 address of the first descriptor in the new list to
DW2 of the last descriptor in the loaded list, and set GDMA_INLINK_RESTART_CHn bit or
GDMA_OUTLINK_RESTART_CHn bit (these two bits are cleared automatically by hardware). As shown in Figure
4-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.
• Buffer address pointer (DW1) check. If the buffer address pointer points to 0x40800000 ~ 0x4087FFFF
(please refer to Section 4.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.
4.4.6 EOF
The GDMA controller uses EOF (end of frame) flags to indicate the end of data segment transfer
corresponding to a specific descriptor.
Before the GDMA controller transmits data, GDMA_OUT_TOTAL_EOF_CHn_INT_ENA bit should be set to enable
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, GDMA_IN_SUC_EOF_CHn_INT_ENA bit should be set to enable
GDMA_IN_SUC_EOF_CHn_INT interrupt. If a data segment with an EOF flag has been received successfully, a
GDMA_IN_SUC_EOF_CHn_INT interrupt is generated. In addition, when GDMA channel is connected to UHCI
or PARLIO, the GDMA controller also supports GDMA_IN_ERR_CHn_EOF_INT interrupt. This interrupt is
enabled by setting GDMA_IN_ERR_EOF_CHn_INT_ENA bit, and it indicates that a data segment corresponding
to a descriptor 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.
is enabled for receive channels by setting GDMA_IN_DATA_BURST_EN_CHn, and enabled for transmit
channels by setting GDMA_OUT_DATA_BURST_EN_CHn.
Table 4-2 lists the requirements for descriptor field alignment when accessing internal RAM.
When 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 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.
4.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.
• 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_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_OUT_DONE_CHn_INT: Triggered when all data corresponding to a transmit descriptor has been
sent via transmit channel n.
• 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 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.
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 (SPI2, UHCI (UART0 or UART1), I2S, AES, SHA, and
ADC). See details in individual chapters of these peripherals.
6. Wait for GDMA_OUT_TOTAL_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 (SPI2, UHCI (UART0 or UART1), I2S, AES, SHA, and
ADC). See details in individual chapters of these peripherals.
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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
4.8 Registers
The addresses in this section are relative to GDMA base address provided in Table 5-2 in Chapter 5 System
and Memory.
RA AW
ON OF H0 IN T_
IN T_ W
GD A_ _ER R_E PT INT AW
A_ S E _ H W
0_ _IN RA
_D _E C 0_ IN
M IN_ R_ RR Y_C _RA
T_ R
W
M IN C M _ _R
IN UC OF_ CH 0_
GD A_ _DS R_E CH0 INT
M IN C F_ _
GD A_ _DS OV CH0
M IN O_ F_
GD A_ FIF UD
M IN O_
GD A_ IF
M INF
)
ed
GD A _
rv
se
M
GD
(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 0 0 Reset
E_ _C _IN T_S T
ON OF H0 IN T_S
CH H0 T_ T
T_ ST
0_ _IN ST
_D _E C 0_ IN
GD A_ _ER R_E PT INT T
M IN_ R_ RR Y_C _ST
M IN C M _ _S
IN UC OF_ CH 0_
IN T_
ST
GD A_ _DS R_E CH0 INT
A_ S E _ H
M IN C F_ _
GD A_ _DS OV CH0
M IN O_ F_
GD A_ FIF UD
M IN O_
GD A_ IF
M INF
d)
ve
GD A_
r
se
M
GD
(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 0 0 Reset
EN NA
IN T_ A
GD A_ _ER R_E PT INT NA
A_ S E _ H A
0_ _IN EN
_D _E C 0_ IN
M IN_ R_ RR Y_C _EN
T_ E
A
M IN C M _ _E
IN UC OF_ CH 0_
GD A_ _DS R_E CH0 INT
M IN C F_ _
GD A_ _DS OV CH0
M IN O_ F_
GD A_ FIF UD
M IN O_
GD A_ FIF
)
ed
M IN
GD A _
rv
se
M
GD
(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 0 0 Reset
E_ _C _IN T_C LR
ON OF H0 IN T_C
CH H0 T_ LR
CL LR
IN T_ R
GD A_ _ER R_E PT INT LR
A_ S E _ H R
0_ _IN CL
_D _E C 0_ IN
T_ C
M IN_ R_ RR Y_C _CL
R
M IN C M _ _C
IN UC OF_ CH 0_
GD A_ _DS R_E CH0 INT
M IN C F_ _
GD A_ _DS OV CH0
M IN O_ F_
GD A_ FIF UD
M IN O_
GD A_ IF
M INF
d)
ve
GD A_
r
se
M
GD
(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 0 0 Reset
H0 _R NT_ W
W
_C INT _I RA
_I AW RA
OU EO _E F_C NT AW
DO CH _C _I W
T_ F_ RR H0 _RA
NE 0_ H0 NT_
AW
A_ T_ CR O _I R
M OU DS _E H0 T_
_R
GD A_ T_ TAL _C _IN
NT
M OU O VF H0
GD A_ T_T _O F_C
M OU IFO D
GD A_ TF _U
M OU IFO
GD A _ TF
M OU
d)
ve
GD A _
r
se
M
GD
(re
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_C INT _I ST
_I T ST
OU EO _E F_C NT T
NE 0_ H0 NT_
T_ F_ RR H0 _ST
H0 _S NT_
A_ T_ CR O _I S
M OU DS _E H0 T_
T
DO CH _C _I
_S
GD A_ T_ TAL _C _IN
NT
M OU O VF H0
GD A_ T_T _O F_C
M OU IFO D
GD A_ TF _U
M OU IFO
GD A _ TF
M OU
d)
ve
GD A _
r
se
M
GD
(re
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
H0 _E NT_ A
A
_C INT _I EN
_I NA EN
OU EO _E F_C NT NA
DO CH _C _I A
T_ F_ RR H0 _EN
NE 0_ H0 NT_
A_ T_ CR O _I E
NA
M OU DS _E H0 T_
_E
GD A_ T_ TAL _C _IN
NT
M OU O VF H0
GD A_ T_T _O F_C
M OU IFO D
GD A_ TF _U
M OU IFO
GD A _ TF
M OU
d)
ve
GD A _
r
se
M
GD
(re
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
H0 _C NT_ R
R
_C INT _I CL
_I LR CL
OU EO _E F_C NT LR
DO CH _C _I R
NE 0_ H0 NT_
T_ F_ RR H0 _CL
A_ T_ CR O _I C
LR
M OU DS _E H0 T_
_C
GD A_ T_ TAL _C _IN
NT
M OU O VF H0
GD A_ T_T _O F_C
M OU IFO D
GD A_ TF _U
M OU IFO
GD A_ TF
M OU
)
ed
GD A _
rv
se
M
GD
(re
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
DR
OD
AD
M
ST
ST
rv _TE
TE
B_
B
d)
)
(re AH
AH
ed
ve
A_
A_
r
se
se
M
M
GD
GD
(re
31 6 5 4 3 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
ER
NT
S
_I
DI
ST
I_
_R
M d ) PR
se AR EN
BM
GD rve B_
(re A_ K_
)
AH
M CL
ed
GD A_
A_
rv
se
M
GD
(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
GDMA_AHBM_RST_INTER Write 1 and then 0 to reset the internal AHB FSM. (R/W)
_C ST N H0
H0 H0
ST TE _E _C
IN OO UR _E 0
H0 _C _C
A_ L B ST H
_R P_ ST N
M IN_ R_ UR _C
M IN TA S 0
GD A_ DSC _B _EN
GD A_ _DA RAN CH
M IN _T N_
GD A_ EM _E
M M M
GD A_ ET
M IN_
d)
ve
GD A _
r
se
M
GD
(re
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
GDMA_IN_RST_CHn Write 1 and then 0 to reset GDMA channel 0 RX FSM and RX FIFO pointer.(R/W)
0
CH
R_
NE
W
_O
CK
HE
_C
)
d)
ed
IN
ve
A_
rv
r
se
se
M
GD
(re
(re
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)
H0
0
_C
H
_C
TA
OP
DA
_P
_R
FO
FO
FI
FI
)
ed
IN
IN
A_
A_
rv
se
M
GD
GD
(re
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
0
CH
NK TO C 0
LI S T_ H
T_
_A P_ H0
IN K_ AR T_C
0
M INL K_S STA H0
O_ 0
CH
RE
UT CH
GD A_ LIN RE _C
A _ IN T R
R_
M IN K_ RK
DD
GD A_ LIN PA
_A
M IN K_
NK
GD A_ IN
LI
M INL
d)
IN
ve
GD A_
A_
r
se
M
GD
GD
(re
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)
OU LO _W _C _C n
T_ OP RB Hn Hn
A_ T_ TO DE EN H
n CH Hn
M OU AU O T_ _C
CH T_ _C
GD A_ T_ F_M RS EN
n
T_ ES K
M OU EO BU T_
M OU SC B Hn
RS _T AC
GD A_ T_ R_ URS
GD A_ TD TA_ _C
M OU DA EN
GD A_ T_ M_
M OU ET
GD A_ T_
M OU
)
ed
GD A_
rv
se
M
GD
(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 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)
0
CH
R_
NE
OW
K_
EC
CH
T_
OU
d)
d)
ve
ve
A_
r
r
se
se
M
GD
(re
(re
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
0
0
H
CH
_C
H_
TA
DA
US
W
P
O_
O_
IF
IF
TF
TF
OU
OU
)
ed
A_
A_
rv
se
M
GD
GD
(re
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)
OP CH 0
ST T_ H
_C 0
K_ R _C
0
TL K_ STA H0
H0
H
IN STA RT
_C
OU IN RE _C
DR
A _ TL _ K
M OU INK AR
AD
GD A_ TL K_P
K_
M OU IN
IN
GD A_ TL
TL
M OU
OU
d)
ve
GD A_
A_
r
se
M
GD
GD
(re
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
_C 0
DE 2B H0
UN ER_ _C 0
H0
1B H
N_ D 3B H
R_ _C
AI UN R_ _C
EM IN_ DE 4B
IN EM _ DE 0
A_ R AIN N H
_R A UN R_
L _ H0
M IN_ M _U Y_C
0
0
UL Y_C
CH
GD A_ _RE AIN GR
H
_C
_F PT
M IN M N
NT
GD A_ _RE _HU
FI EM
_C
IN O_
M IN F
FO
FO
GD A_ _BU
A_ IF
FI
M INF
)
d)
ed
M IN
IN
ve
GD A_
A_
GD A_
rv
r
se
se
M
M
GD
GD
GD
(re
(re
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
GDMA_INFIFO_CNT_CHn Represents the number of data bytes in L1 RX FIFO for RX channel n. (RO)
0
CH
0
R_
CH
DD
E_
A
AT
H0
R_
ST
SC
_C
R_
_D
TE
C
TA
NK
DS
_S
LI
_
d)
IN
IN
IN
ve
A_
A_
A_
r
se
M
GD
GD
GD
(re
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 next receive descriptor ad-
dress that is pre-read (but not processed yet). If the current receive descriptor is the last de-
scriptor, then this field represents the address of the current receive descriptor. (RO)
0
CH
R_
DD
_A
ES
_D
OF
_E
UC
_S
IN
A_
M
GD
31 0
0x000000 Reset
0
CH
R_
A DD
S_
DE
F_
EO
R_
_ ER
IN
A_
M
GD
31 0
0x000000 Reset
H0
_C
CR
DS
K_
N
LI
IN
A_
M
GD
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
0
CH
F 1_
_B
SCR
K _D
IN
L
IN
A_
M
GD
31 0
0 Reset
GDMA_INLINK_DSCR_BF1_CHn Represents the address of the previous receive descriptor x-1 that
is pre-read. (RO)
H0
1B H
N_ D 3B H
R_ _C
AI N _ C
M _U ER B_
RE IN ND _4
_C 0
T_ MA _U ER
LL CH
H0
0
OU RE IN ND
FU TY_
CH
A_ T_ A U
T_
O_ P
M OU REM IN_
IF EM
N
_C
GD A_ T_ MA
TF O_
FO
M OU RE
OU IF
FI
A_ TF
GD A_ T_
T
M OU
OU
M U
)
)
ed
ed
O
GD A_
A_
GD A_
rv
rv
se
se
M
M
GD
GD
GD
(re
(re
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
0
CH
R_
0
CH
DD
E_
_A
AT
0
CR
CH
ST
S
E_
R_
_D
AT
SC
NK
ST
LI
T_
T_
T
OU
OU
OU
)
ed
A_
A_
A_
rv
se
M
GD
GD
GD
(re
31 23 22 20 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0x000000 Reset
0
CH
R_
DD
A
S_
DE
R_
BF
F_
EO
T_
OU
A_
M
GD
31 0
0x000000 Reset
H 0
_C
CR
DS
K_
IN
TL
OU
A_
M
GD
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
0
CH
1_
F
_B
S CR
_D
K
IN
TL
OU
A_
M
GD
31 0
0 Reset
H0
_C
RI
_P
)
RX
ed
A_
rv
se
M
GD
(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
TX
ed
A_
rv
se
M
GD
(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
0
CH
L_
SE
N_
_I
RI
d)
PE
ve
A_
r
se
M
GD
(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 0x3f Reset
H0
_C
EL
_S
UT
_O
RI
d)
PE
ve
A_
r
se
M
GD
(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 0x3f Reset
5.1 Overview
ESP32-C6 is an ultra-low power and highly-integrated system that integrates:
• a high-performance 32-bit RISC-V single-core processor (HP CPU), four-stage pipeline, clock frequency
up to 160 MHz
• a low-power 32-bit RISC-V single-core processor (LP CPU), two-stage pipeline, clock frequency up to
20 MHz
All internal memory, external memory, and peripherals are located on the HP CPU and LP CPU buses.
5.2 Features
• Address Space
– 832 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 the data bus
• Internal Memory
– 512 KB HP SRAM
– 16 KB LP SRAM
• External Memory
• Peripheral Space
– 51 modules/peripherals in total
• GDMA
– 8 GDMA-supported modules/peripherals
Note:
• The range of addresses available in the address space may be larger than the actual available memory of a
particular type.
Both data bus and instruction bus of the HP CPU and LP CPU are little-endian. The HP CPU and LP 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.
• (for HP CPU only) directly access the external memory which is mapped into the address space via
cache.
Table 5-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 0x3FFF_FFFF Reserved
Data/Instruction bus 0x4000_0000 0x4004_FFFF 320 KB ROM*
0x4005_0000 0x407F_FFFF Reserved
Data/Instruction bus 0x4080_0000 0x4087_FFFF 512 KB HP SRAM*
0x4088_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_3FFF 16 KB LP SRAM*
0x5000_4000 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
memory can only be accessed when it is allowed by Permission Control, then the in-
ternal memory can be available to the HP CPU and LP CPU. For more information about
Permission Control, please refer to Chapter 16 Permission Control (PMS).
• ROM (320 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 (512 KB): The HP SRAM is a volatile memory that can be quickly accessed by the HP CPU or
LP CPU (generally within a single HP CPU clock cycle for HP CPU).
• LP SRAM (16 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 the HP CPU or LP CPU and is usually used
to store program instructions and data that need to be kept in sleep mode.
1. ROM
This 320 KB ROM is a read-only memory, addressed by the HP CPU through the instruction bus or through the
data bus via 0x4000_0000 ~ 0x4004_FFFF, as shown in Table 5-1.
2. HP SRAM
This 512 KB HP SRAM is a read-and-write memory, accessed by the HP CPU or LP CPU through the instruction
bus or through the data bus as shown in Table 5-1.
3. LP SRAM
This 16 KB LP SRAM is a read-and-write memory, accessed by the HP CPU or LP CPU through the instruction
bus or through the data bus via their shared address 0x5000_0000 ~ 0x5000_3FFF as shown in Table
5-1.
• high-speed mode, i.e., the LP SRAM is accessed in HP CPU clock frequency. In this case:
– But the latency of LP CPU accessing LP SRAM ranges from a few dozen to dozens of LP CPU
cycles.
• low-speed mode, i.e., the LP SRAM is accessed in LP CPU clock frequency. In this case:
– But the latency of HP CPU accessing LP SRAM ranges from a few dozen to dozens of HP CPU
cycles.
• If the LP CPU is not working, you can switch to high-speed mode to improve the access speed of the
HP CPU.
• If the LP CPU is executing code in the LP SRAM, you can switch to the low-speed mode.
When the HP CPU is in sleep mode, you must switch to the low-speed mode.
– 1: high-speed mode
– 0: low-speed mode
– 0: mode is switched
The HP CPU accesses the external memory via the cache. According to information inside the MMU (Memory
Management Unit), the cache maps the HP CPU’s address (0x4200_0000 ~ 0x42FF_FFFF) into a physical
address of the external memory. Due to this address mapping, ESP32-C6 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.
5.3.3.2 Cache
As shown in Figure 5-2, ESP32-C6 has a read-only uniform cache which is four-way set-associative. Its size is
32 KB and its block size is 32 bytes. The cache is accessible by the instruction bus and the data bus at the
same time, but can only respond to one of them at a time. When a cache miss occurs, the cache controller
will initiate a request to the external memory.
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 HP 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 ~ 0x4087_FFFF to access HP SRAM.
Eight modules/peripherals in ESP32-C6 work together with GDMA. As shown in Figure 5-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.
These modules/peripherals can access any memory available to GDMA. For more information, please refer to
Chapter 4 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 16 Permission Control (PMS).
Address).
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 (I2C) 0x6000_4000 0x6000_4FFF 4
UHCI Controller (UHCI) 0x6000_5000 0x6000_5FFF 4
Remote Control Peripheral (RMT) 0x6000_6000 0x6000_6FFF 4
LED PWM Controller (LEDC) 0x6000_7000 0x6000_7FFF 4
Timer Group 0 (TIMG0) 0x6000_8000 0x6000_8FFF 4
Timer Group 1 (TIMG1) 0x6000_9000 0x6000_9FFF 4
System Timer (SYSTIMER) 0x6000_A000 0x6000_AFFF 4
Two-wire Automotive Interface 0 (TWAI0) 0x6000_B000 0x6000_BFFF 4
I2S Controller (I2S) 0x6000_C000 0x6000_CFFF 4
Two-wire Automotive Interface 1 (TWAI1) 0x6000_D000 0x6000_DFFF 4
Successive Approximation ADC (SAR ADC) 0x6000_E000 0x6000_EFFF 4
USB Serial/JTAG Controller 0x6000_F000 0x6000_FFFF 4
Interrupt Matrix (INTMTX) 0x6001_0000 0x6001_0FFF 4
Reserved 0x6001_1000 0x6001_1FFF
Pulse Count Controller (PCNT) 0x6001_2000 0x6001_2FFF 4
Event Task Matrix (SOC_ETM) 0x6001_3000 0x6001_3FFF 4
Motor Control PWM (MCPWM) 0x6001_4000 0x6001_4FFF 4
Parallel IO Controller (PARL_IO) 0x6001_5000 0x6001_5FFF 4
SDIO HINF* 0x6001_6000 0x6001_6FFF 4
SDIO SLC* 0x6001_7000 0x6001_7FFF 4
SDIO SLCHOST * 0x6001_8000 0x6001_8FFF 4
Reserved 0x6001_9000 0x6007_FFFF
GDMA Controller (GDMA) 0x6008_0000 0x6008_0FFF 4
General Purpose SPI2 (GP-SPI2) 0x6008_1000 0x6008_1FFF 4
Reserved 0x6008_2000 0x6008_7FFF
AES Accelerator (AES) 0x6008_8000 0x6008_8FFF 4
SHA Accelerator (SHA) 0x6008_9000 0x6008_9FFF 4
RSA Accelerator (RSA) 0x6008_A000 0x6008_AFFF 4
ECC Accelerator (ECC) 0x6008_B000 0x6008_BFFF 4
Digital Signature (DS) 0x6008_C000 0x6008_CFFF 4
HMAC Accelerator (HMAC) 0x6008_D000 0x6008_DFFF 4
Reserved 0x6008_E000 0x6008_FFFF
IO MUX 0x6009_0000 0x6009_0FFF 4
GPIO Matrix 0x6009_1000 0x6009_1FFF 4
Cont’d on next page
Note:
As shown in the figure 5-1�
• LP CPU can access all peripherals listed in the table 5-2 except RISC-V Trace Encoder (TRACE), DEBUG ASSIST
(ASSIST_DEBUG) and Interrupt Priority Register (INTPRI).
6 eFuse Controller
6.1 Overview
ESP32-C6 contains a 4096-bit eFuse memory to store parameters and user data. The parameters include
control parameters for some hardware modules, system data parameters and keys used for the decryption
module. Once an eFuse bit is programmed to 1, it can never be reverted to 0. The eFuse controller programs
individual bits of parameters in eFuse according to user configurations. From outside the chip, eFuse data can
only be read via the eFuse controller. For some data, such as some keys stored in eFuse for internal use by
hardware cryptography modules (e.g., digital signature, HMAC), if read protection is not enabled, the data can
be read from outside the chip; if read protection is enabled, the data cannot be read from outside the
chip.
6.2 Features
• 4096-bit one-time programmable storage including 1792 bits reserved for custom use
Users can program bits in the eFuse memory via the eFuse controller by writing the data to be programmed to
the programming register and executing the programming instruction. For detailed programming steps, please
refer to Section 6.3.2.
Users cannot directly read the data programmed in the eFuse memory, so they need to read the programmed
data into the Reading Data Register of the corresponding address segment through the eFuse controller.
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 6.3.1.3 for details), and send
the error message to the error report register. For detailed steps to read parameters, please refer to the
Section 6.3.3.
Table 6-1 lists all the parameters accessible (readable and usable) to users in BLOCK0 and their offsets, bit
widths, accessibility by hardware, write protection, and brief function description. For more description on the
parameters, please click the link of the corresponding parameter 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 on these two parameters, please
see Section 6.3.1.1 and Section 6.3.1.2.
6 eFuse Controller
Table 6-1. Parameters in eFuse BLOCK0
Write Protection
Bit Accessible
Parameters by EFUSE_WR_DIS Description
Width by Hardware
Bit Number
EFUSE_DIS_USB_SERIAL_JTAG 1 Y 2
abled.
Represents whether the function to force the chip into
EFUSE_DIS_FORCE_DOWNLOAD 1 Y 2
Download mode is disabled.
Represents whether the SPI0 controller is disabled in
EFUSE_SPI_DOWNLOAD_MSPI_DIS 1 Y 17
boot_mode_download.
EFUSE_DIS_TWAI 1 Y 2 Represents whether the TWAI controller is disabled.
Represents whether the selection of a JTAG signal source
through the strapping value of GPIO15 is enabled when
ESP32-C6 TRM (Version 1.0)
EFUSE_JTAG_SEL_ENABLE 1 Y 2
both EFUSE_DIS_PAD_JTAG and EFUSE_DIS_USB_JTAG
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).
GoBack
Cont’d on next page
Espressif Systems
6 eFuse Controller
Table 6-1 – cont’d from previous page
Write Protection
Bit Accessible
Parameters by EFUSE_WR_DIS Description
Width by Hardware
Bit Number
EFUSE_SPI_BOOT_CRYPT_CNT 3 Y 4
abled.
Represents whether revoking the first Secure Boot key is
EFUSE_SECURE_BOOT_KEY_REVOKE0 1 N 5
enabled.
173
GoBack
abled.
EFUSE_SECURE_BOOT_EN 1 N 16 Represents whether Secure Boot is enabled or disabled.
Cont’d on next page
Espressif Systems
6 eFuse Controller
Table 6-1 – cont’d from previous page
Write Protection
Bit Accessible
Parameters by EFUSE_WR_DIS Description
Width by Hardware
Bit Number
EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE 1 N 18
tion is disabled.
EFUSE_ENABLE_SECURITY_DOWNLOAD 1 N 18 Represents whether security download is enabled.
EFUSE_UART_PRINT_CONTROL 2 N 18 Represents the type of UART printing.
174
GoBack
6 eFuse Controller GoBack
Table 6-2 lists all key purposes and their values. Setting the eFuse parameter EFUSE_KEY_PURPOSE_n
declares the purpose of KEYn (n: 0 ~ 5).
Key
Purpose Purposes
Values
0 User purposes
1 Reserved
2 Reserved
3 Reserved
4 XTS_AES_128_KEY (flash/SRAM encryption and decryption)
5 HMAC Downstream mode (both JTAG and DS)
6 JTAG in HMAC Downstream mode
7 Digital Signature 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)
6 eFuse Controller
Table 6-3. Parameters in BLOCK1 to BLOCK10
GoBack
6 eFuse Controller 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 6-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 into the KEY5 block, i.e., BLOCK9. Otherwise, the key may be unreadable. Instead,
program it 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 6.3.1.3 and Section 6.3.2.
6.3.1.1 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 so the new values would take
effect.
Column “Write Protection by EFUSE_WR_DIS Bit Number” in Table 6-1 and Table 6-3 list the specific bits in
EFUSE_WR_DIS that disable writing.
When the write protection bit of a parameter is set to 0, it means that this parameter is not write-protected and
can be programmed, unless it has been programmed before.
When the write protection bit of a parameter is set to 1, it means that this 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.
6.3.1.2 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 6-3. After EFUSE_RD_DIS has been programmed,
execute an eFuse read operation so the new values would take effect.
If the corresponding EFUSE_RD_DIS bit is 0, the parameter controlled by this bit is not read-protected from
users. If it is 1, the parameter controlled by it is read-protected from users.
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.
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 eFuse
memory space occupied by BLOCK0 is 32 + 152 * 4 = 640 bits.
BLOCK1 ~ BLOCK10 use 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.
The shift register circuit shown in Figure 6-2 and 6-3 processes 32 data bytes using RS (44, 32). This coding
scheme encodes 32 bytes of data into 44 bytes:
• Bytes [32:43] are the encoded parity bytes stored in 8-bit flip-flops DFF1, DFF2, ..., DFF12 (gf_mul_n 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
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 6-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
read 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
Programming process
3. Make sure the eFuse programming voltage VDDQ is configured correctly as described in Section 6.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 6.3.3.
8. Trigger an eFuse read operation (see Section 6.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 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 read 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.
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
10 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.
6.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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
6.5 Registers
The addresses in this section are relative to eFuse controller base address provided in Table 5-2 in Chapter 5
System and Memory.
_0
A
AT
_D
GM
_P
SE
U
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
_3
A
AT
_D
GM
_P
SE
U
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
A _7
AT
_D
GM
_P
SE
U
EF
31 0
0x000000 Reset
_0
TA
DA
S_
_R
GM
_P
SE
U
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
_2
TA
DA
S_
_R
GM
_P
SE
U
EF
31 0
0x000000 Reset
IS
D
R_
E_W
US
EF
31 0
0x000000 Reset
T
YP
CR
EN
L_
HE
UA
US DI US LO L_ AD
U D DO SE WN I_
SW ICA JTA _I G
AN
AP CH G CAC
EF E_ S_ B_ DO SP
E_ S_ B_ AD JTA
N
EX AS_ _2
RV _0
_E
RV _1
AG M
US DI US E_ _M
LE
G_ PIO
D0
NS
IO
JT D_
ED
ED
AB
EF SE_ IS_ RC AD
G
SD
VE
PI
CH G
D_ OA
TA
U D O LO
T_
ER
US SP W E
PA NL
_J
_U E
SE
SE
EF E_ S_T EL_
EF SE_ IS_ WN
AR
ES
B_ I_
IS
S_ W
EF E_ _ I
RE
RE
A
US SP
_D
_R
DI DO
U D DO
US DI _S
IS
_
_D
FT
E_ D_
US PT4
T4
T4
EF E_ AG
E_ S_
I
SO
RD
RP
RP
)
US VD
US JT
US DI
ed
_R
E_
E_
EF E_
EF SE_
E_
EF E_
E_
rv
SE
US
US
US
US
US
se
U
U
(re
EF
EF
EF
EF
EF
EF
EF
EF
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_SWAP_UART_SDIO_EN Represents whether the pads of UART and SDIO are swapped or
not.
1: Swapped
0: Not swapped
(RO)
EFUSE_DIS_FORCE_DOWNLOAD Represents whether the function that forces chip into download
mode is disabled.
1: Disabled
0: Enabled
(RO)
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)
0
Y_ VO 2
VO 1
KE RE KE
RE KE
KE
T_ Y_ VO
OO KE RE
T
CN
_B T_ Y_
_0
T_
RE OO KE
D1
_0
YP
_1
EL
CU _B T_
E
SE
SE
RV
CR
SE RE OO
_S
PO
PO
SE
AY
T_
E_ CU _B
EL
E
OO
UR
UR
US SE RE
_R
_D
P
B
EF E_ CU
T4
Y_
Y_
I_
DT
RP
SP
KE
KE
US SE
W
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
E
OK
EV
_R
VE
SI
T_ ER EN ES
US RYP ES OT_ GR
0
LE
EN _1
2_
C _R O AG
AB
A _ D2
2
3
4
5
ED
L
E_ T4 _B T_
E_
E_
E_
E_
VE
DP VE
RV
US RP RE OO
UW
OS
OS
OS
OS
LE
SE
EF E_ CU _B
A_
RP
RP
RP
RP
P
RE
_T
US SE RE
DP
PU
PU
PU
PU
H
EF E_ CU
C_
T4
AS
Y_
Y_
Y_
Y_
RP
KE
KE
KE
KE
US SE
SE
FL
E_
E_
EF E_
E_
E_
E_
E_
E_
US
US
US
US
US
US
US
EF
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)
E
OD
M
D_
E
NT
AK
OA
RI
_W
NL
_P
S_ E RI _5 D AD
ST
OW
M
DI DIR SE D3 G_ LO
FA
RO
E_ S_ B_ VE JTA N
E_
US DI US ER L_ OW
OA T _
E
D ME
NL O AG
BL
OD
US RP US EC TRO
VE _3
_4
W BO JT
SA
VE SU
ER 3_1
3_
M
DO CT_ AL_
OO D3
ER D3
D3
DI
ON
U D _R SE IT
N
D_
ER RE
ED
EF E_ T4 _ R
_B VE
ES VE
ES D_
SI
U
C
V
T_
ER
RE ER
_R ER
_R N
N
US PT4 _SE
EF E_ S_ _S
_V
CU ES
ES
US PT4 ES
RI
B
RE
US DI LE
SE _R
_R
R _R
_P
R E
E_ RC
EF E_ AB
U
RT
E_ T4
T4
E_ T4
EC
US EN
US FO
US RP
RP
US RP
UA
_S
EF SE_
EF SE_
E_
EF E_
E_
EF E_
SE
US
US
U
U
EF
EF
EF
EF
EF
EF
EF
31 30 29 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
_1
D4
D4
E
E
RV
RV
SE
SE
RE
RE
4_
4_
PT
PT
_R
_R
E
E
US
US
EF
EF
31 24 23 0
_0
AC
E _M
US
EF
31 0
0x000000 Reset
_1
AC
AC
M
_M
E_
E
US
US
EF
EF
31 16 15 0
D
E
RV
_1
SE
NF
RE
CO
I_
D_
P
_S
PA
AC
I_
SP
_M
E_
E
US
US
EF
EF
31 14 13 0
_0
T0
_2
NF
AR
_P
CO
TA
D_
DA
PA
S_
I_
SP
SY
E_
E_
US
US
EF
EF
31 18 17 0
EFUSE_SYS_DATA_PART0_0 Represents the first 14 bits of the zeroth part of system data. (RO)
1
0_
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART0_1 Represents the first 32 bits of the zeroth part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART0_2 Represents the second 32 bits of the zeroth part of system data. (RO)
0
1_
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_0 Represents the zeroth 32 bits of the first part of system data. (RO)
1
1_
RT
PA
_
TA
DA
_
YS
E_S
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_1 Represents the first 32 bits of the first part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_2 Represents the second 32 bits of the first part of system data. (RO)
3
1_
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_3 Represents the third 32 bits of the first part of system data. (RO)
4
1_
RT
PA
_
TA
DA
_
YS
E_S
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_4 Represents the fourth 32 bits of the first part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_5 Represents the fifth 32 bits of the first part of system data. (RO)
6
1_
RT
PA
_
TA
_ DA
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_6 Represents the sixth 32 bits of the first part of system data. (RO)
_7
T1
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_7 Represents the seventh 32 bits of the first part of system data. (RO)
31 0
0x000000 Reset
1A
AT
_D
SR
E _U
US
EF
31 0
0x000000 Reset
2
TA
DA
R_
US
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
A5
AT
_D
SR
_U
E
US
EF
31 0
0x000000 Reset
6
TA
DA
R_
US
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
1
TA
DA
0_
EY
E_K
US
EF
31 0
0x000000 Reset
A2
AT
_D
Y0
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
5
TA
DA
0_
EY
_K
SE
U
EF
31 0
0x000000 Reset
6
TA
DA
0_
EY
E_K
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
1
TA
DA
1_
EY
E_K
US
EF
31 0
0x000000 Reset
2
TA
DA
1_
K EY
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
5
TA
DA
1_
EY
E _K
US
EF
31 0
0x000000 Reset
A6
AT
_D
Y1
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
A1
AT
_D
2
EY
_K
E
US
EF
31 0
0x000000 Reset
2
TA
DA
2_
EY
_K
E
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
A5
AT
_D
Y2
KE
E_
US
EF
31 0
0x000000 Reset
6
A
AT
_D
Y2
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
1
TA
DA
3_
EY
_K
E
US
EF
31 0
0x000000 Reset
A2
AT
_D
Y3
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
5
TA
DA
3_
EY
_K
E
US
EF
31 0
0x000000 Reset
6
TA
DA
3_
EY
_K
E
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
1
TA
DA
4_
EY
E_K
US
EF
31 0
0x000000 Reset
2
TA
DA
4_
EY
E_K
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
5
TA
DA
4_
EY
E_K
US
EF
31 0
0x000000 Reset
6
TA
DA
4_
EY
_K
SE
U
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
A1
AT
_D
5
EY
_K
E
US
EF
31 0
0x000000 Reset
A2
AT
_D
Y5
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
A 5
AT
_D
5
EY
_K
SE
U
EF
31 0
0x000000 Reset
6
TA
DA
5_
EY
E_K
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_0 Represents the 0th 32 bits of the 2nd part of system data. (RO)
_1
2
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_1 Represents the 1st 32 bits of the 2nd part of system data. (RO)
_2
2
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_2 Represents the 2nd 32 bits of the 2nd part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_3 Represents the 3rd 32 bits of the 2nd part of system data. (RO)
_4
2
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_4 Represents the 4th 32 bits of the 2nd part of system data. (RO)
_5
T2
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_5 Represents the 5th 32 bits of the 2nd part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_6 Represents the 6th 32 bits of the 2nd part of system data. (RO)
_7
2
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_7 Represents the 7th 32 bits of the 2nd part of system data. (RO)
R
ER
T_
YP
CR
E_ S_ B_ AD JTA _E RR
EN
R
US DI US LO L_ AD _E
SW ICA JTA _I G_ RR
ER
_U E_ ER H R
L_
AP CH G_ CAC ER
RR
AR ER R E_
_2
0_ _0
1
ED RR_
RR UA
RR
_E
U D DO SE WN I_
NS RR
R
RR
RR
RV _ER
_E AN
EF E_ S_ B_ DO SP
EN
EF E_ _ WN R _E
RR
PI _E
E
EX S_ _E
_E
AG M
US DI US E_ _M
E
O_
G_ PIO
_E
D0
US DI DO ER L
JT D_
T_ R
ED
EF E_ _ I_ AB
I
EF SE_ IS_ RC AD
G
SD
VE
CH G
D_ OA
TA
RV
U D FO LO
ER
RR
US SP W E
PA NL
_J
SE
SE
EF E_ S_T EL_
A
ES
_E
B_ I_
IS
S_ W
RE
RE
A
US SP
_D
_R
DI DO
US DI _S
IS
_
_D
FT
E_ D_
US PT4
T4
T4
EF E_ AG
E_ S_
S
I
SO
RD
RP
RP
)
US VD
US JT
US DI
ed
_R
E_
E_
EF E_
EF E_
E_
EF E_
E_
rv
SE
US
US
US
US
US
US
se
U
(re
EF
EF
EF
EF
EF
EF
EF
EF
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)
VO 1_ R
R
0_ R
RE KE ER
ER
KE ER
Y_ VO 2_
KE RE KE
R
ER
T_ Y_ VO
0
R_
_
OO KE RE
NT
R
R
RR
RR
ER
_B T_ Y_
_E
_C
_E
_E
RE OO KE
0_
D1
PT
_1
EL
CU _B T_
E_
E
Y
SE
RV
CR
SE RE OO
_S
OS
PO
SE
AY
T_
E_ CU _B
RP
EL
E
OO
UR
US SE RE
_R
PU
_D
P
B
EF SE_ CU
T4
Y_
Y_
I_
DT
RP
SP
KE
KE
U SE
W
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
R
ER
E_
OK
EV
_R
C_ SER AB ERR IVE
0
_E RR
E EN _ S
_1
R_
_R A_ EN ES
RR
D2 _E
R
R
R
R
ER
RR
US PT4 DP OT_ GR
ER
ER
ER
ER
VE LE
2_
E
R T_ O AG
RR
2_
4_
5_
3_
L_
ED
E_ YP _B T_
_E
E_
E_
E_
E_
VE
RV
US CR RE OO
UW
OS
OS
OS
OS
LE
SE
EF E_ U B
A_
RP
RP
RP
RP
P
_
RE
_T
US SE RE
DP
PU
PU
PU
PU
H
EF E_ CU
T4
AS
Y_
Y_
Y_
Y_
C
RP
KE
KE
KE
KE
US SE
SE
FL
E_
E_
EF E_
E_
E_
E_
E_
E_
US
US
US
US
US
US
US
EF
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
R
ER
E_
OD
_M
_5 N RR
AD
DO CT_ R RR OW _E
LO
S_ E ER _E D AD
DI DIR T_ D3 G_ LO
R
ED RR_ R
ER
R
ER
E_ _ IN E TA N
_2
0
ER 3
4
ER 3_E _E
1
E_
US DI PR R _ OW
R_
NT 3_ R_
ON R_
L_
RR
M R
D ME
RR
OD
ER
D R
D_ R
U RP US EC TRO
VE _E
E
_E
VE SU
3_
OA T_
J
3
3
N
U U _R SE IT
ER RE
NL O
ED
L
IO
EF SE_ T4 B_ UR
W BO
ES VE
ES D_
_C
RS
RV
V
_R ER
R
_R N
VE
SE
E
US PT4 _SE
EF SE_ IS_ _S
ES
US PT4 ES
RI
E_
RE
U D LE
_R
R _R
_P
R
R E
4_
E_ RC
EF SE_ AB
CU
RT
T4
E_ T4
PT
S
U EN
US FO
RP
US RP
UA
SE
_R
E_
EF SE_
E_
EF E_
E_
EF E_
SE
US
US
US
U
U
EF
EF
EF
EF
EF
EF
EF
31 30 29 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
EFUSE_SECURE_VERSION_ERR Any bit of this field being 1 represents a programming error of SE-
CURE_VERSION. (RO)
_0
1
R_
RR
ER
_E
4_
4
ED
ED
RV
RV
SE
SE
RE
E
_R
_
T4
T4
RP
RP
E_
E_
US
US
EF
EF
31 24 23 0
U M
M
M
_N
NU
NU
RR
AI
R_
R_
UM
M
UM
IL
M
_E
_F
UM
ER
NU
FA
AI
NU
ER
8M
M
_N
_N
_F
_N
1_
1_
R_
_8
A_
R_
IL
L
L
RR
I_
RR
L
TA
RT
RT
IL
RR
AI
AI
I
T
ER
PI
A
ER
FA
P
FA
DA
DA
_E
_F
_F
_E
_F
PA
PA
_E
_S
_S
0_
_
4_
R_
R_
Y0
Y2
Y2
Y3
Y3
S_
S_
Y4
Y1
Y1
AC
AC
EY
US
US
KE
KE
KE
KE
KE
KE
KE
KE
KE
SY
SY
M
K
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
US
US
US
US
US
US
US
US
US
US
US
US
US
US
US
US
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
31 30 28 27 26 24 23 22 20 19 18 16 15 14 12 11 10 8 7 6 4 3 2 0
UM
_N
IL
RR
UM
FA
_E
_N
2_
T2
RR
RT
AI
AR
_E
_F
PA
Y5
Y5
_
_
YS
YS
KE
KE
)
ed
_S
_S
E_
E_
rv
SE
SE
US
US
se
U
(re
EF
EF
EF
EF
31 8 7 6 4 3 2 0
D N
_P _O
CE CE
_F _F PU
OR OR
EM LK _
M _C CE
E_ EM OR
N
US M _F
_E
EF SE_ EM
K
CL
)
d)
U M
ed
ve
E_
EF SE_
rv
r
US
se
se
U
(re
(re
EF
EF
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_MEM_FORCE_PD Configures whether or not to force eFuse SRAM into power-saving mode.
1: Force
0: No effect
(R/W)
EFUSE_MEM_FORCE_PU Configures whether or not to force eFuse SRAM into working mode.
1: Force
0: No effect
(R/W)
EFUSE_CLK_EN Configures whether or not to force enable eFuse register configuration clock sig-
nal.
1: Force
0: The clock is enabled only during the reading and writing of registers
(R/W)
_O
rv
E
US
se
(re
EF
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
T
CN
T_
BI
D_
LI
A
_V
E
K0
AT
BL
d)
d)
ST
ve
ve
E_
E_
r
r
US
US
se
se
(re
(re
EF
EF
31 20 19 10 9 4 3 0
D
AD MD
UM
M
_C
RE _C
_N
E_ M
LK
US PG
)
ed
B
E_
EF E_
rv
US
US
se
(re
EF
EF
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 cor-
responds to block number 0-10, respectively. (R/W)
W
IN AW
RA
E_ T_R
T_
ON IN
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
ST
IN T
E_ T_S
T_
ON IN
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
A
IN NA
EN
E_ T_E
T_
ON IN
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
IN LR
CL
E_ T_C
T_
ON IN
_D E_
AD ON
RE _D
E_ M
US PG
)
ed
EF SE_
rv
se
U
(re
EF
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
L
SE
D_
IV
PA
_D
_
UM
LK
LK
R
_C
_C
L
_C
C_
AC
AC
DA
OE
)
ed
_D
_D
E_
E_
rv
E
US
US
US
US
se
(re
EF
EF
EF
EF
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)
M
NU
T_
NI
_A
I
D_
A
UR
R_
A
D
RE
TH
TR
S
_T
E_
E_
E_
SE
US
US
US
U
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
TH
TS
E_
E_
E_
US
US
US
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)
UM
_N
O FF
R_
GM
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)
TE
_I
GM
DA
UP
)
)
P
ed
ed
ed
_T
E_
rv
rv
rv
E
US
US
se
se
se
(re
(re
(re
EF
EF
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
(re
EF
31 28 27 0
0 0 0 0 0x2206300 Reset
7.1 Overview
The ESP32-C6 chip features 31 GPIO pins. Each pin can be used as a general-purpose I/O, or be connected
to an internal peripheral signal. Through GPIO matrix, IO MUX, and low-power (LP) 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:
• For chip variants without an in-package flash, GPIO14 is not led out to any chip pins, so GPIO14 is not available
to users.
• For chip variants with an in-package flash, GPIO24 ~ GPIO30 are dedicated to connecting the in-package flash,
not for other uses. GPIO10 ~ GPIO11 are not led out to any chip pins, thus not available to users. The remaining
22 GPIO pins (numbered GPIO0 ~ GPIO9, GPIO12 ~ GPIO23) are configurable by users.
7.2 Features
GPIO matrix has the following features:
• A full-switching matrix between the peripheral input/output signals and the GPIO pins.
• 85 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 8 Reset and Clock.
• 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
• Control of eight LP GPIO pins (GPIO0 ~ GPIO7) that can be used by the peripherals in ULP and LP system.
1. Only part of peripheral input signals (marked “yes” in column “Direct input through IO MUX” in Table 7-2)
can bypass GPIO matrix. The other input signals can only be routed to peripherals via GPIO matrix.
2. There are only 31 inputs from GPIO SYNC to GPIO matrix, since ESP32-C6 provides 31 GPIO pins in total.
Note:
• For chip variants without an in-package flash, there are 30 inputs from GPIO SYNC to GPIO matrix in
total. GPIO14 is not led out to any chip pins.
• For chip variants with an in-package flash, there are only 22 inputs from GPIO SYNC to GPIO matrix
in total. GPIO10 ∼ GPIO11 are not let out to chip pins, and GPIO24 ∼ GPIO30 are used to connect
the in-package flash.
3. The pins supplied by VDDPST1 or by VDDPST2 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 7-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 31 outputs (corresponding to GPIO pin X: 0 ~ 30) from GPIO matrix to IO MUX. Note:
• For chip variants without an in-package flash, there are 30 outputs (corresponding to GPIO X: 0 ~
13, 15 ~ 30) from GPIO matrix to IO MUX in total.
• For chip variants with an in-package flash, there are only 22 outputs (corresponding to GPIO X: 0 ~
9, 12 ~ 23) from GPIO matrix to IO MUX in total.
Figure 7-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 31 GPIO pins and can be controlled using IE, OE, WPU, and WPD
signals.
• 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 7-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 7.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 7.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 7.4.2. Such signal filtering
and synchronization features apply to all GPIO matrix signals but do not apply when using the IO MUX.
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 7-3. GPIO Input Synchronized on Rising Edge or on Falling Edge of IO MUX Operating Clock
Figure 7-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.
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 7-4.
3. Glitch filter hardware supports eight channels, each of which selects one signal from the 31 (0~30)
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:
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 GPIO7, please follow the
steps below. Note that GPIO7 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.
• For chip variants without an in-package flash, output signals can be mapped to 30 GPIO pins, i.e., GPIO0
~ GPIO13, GPIO15 ~ GPIO30.
• For chip variants with an in-package flash, output signals can only be mapped to 22 GPIO pins, i.e.,
GPIO0 ~ GPIO9, GPIO12 ~ GPIO23.
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.
Note:
There is a range of peripheral output signals (97 ~ 100 in Table 7-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 7-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.
• 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 93 peripheral output signals (index: 83 ~ 86 in Table 7-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).
• Route one of SDM outputs to a pin via GPIO matrix, see Section 7.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 7.12.
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 peripheral via GPIO matrix.
If controlled by LP IO MUX, these pins will bypass IO MUX and GPIO matrix for the use by ULP and peripherals
in LP system.
When configured as LP GPIOs, the pins can still be controlled by ULP or the peripherals in LP system during
chip Deep-sleep, and wake up the chip from Deep-sleep.
If LP_AON_GPIO_MUX_SEL[n] is set to 1, then input/output signals are controlled by LP IO MUX. In this mode,
LP_IO_GPIOn_REG is used to control the LP GPIO pins. See 7-4 for the LP functions of each LP GPIO pin. Note
that LP_IO_GPIOn_REG applies the LP GPIO pin numbering, not the GPIO pin numbering.
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 7.5.2 for how to enable output in normal execution.
– LP_AON_GPIO_HOLD0_REG[n] (n = 0 ~ 7), controls the Hold signal of each pin of GPIO0 ~ GPIO7.
– 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.
• 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 7-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 7-2 are valid input signals.
• Only the signals with a name assigned in the column “Output signal” in Table 7-2 are valid output signals.
Signal Default Direct Input via Output enable signal when Direct Output
Input Signal Output Signal
No. value IO MUX GPIO_FUNCn_OEN_SEL = 0 via IO MUX
0 ext_adc_start 0 no ledc_ls_sig_out0 1’d1 no
1 - - - ledc_ls_sig_out1 1’d1 no
2 - - - ledc_ls_sig_out2 1’d1 no
3 - - - ledc_ls_sig_out3 1’d1 no
4 - - - ledc_ls_sig_out4 1’d1 no
5 - - - ledc_ls_sig_out5 1’d1 no
6 U0RXD_in 0 yes U0TXD_out 1’d1 yes
7 U0CTS_in 0 no U0RTS_out 1’d1 no
Submit Documentation Feedback
GoBack
24 - - - - - -
25 - - - - - -
Espressif Systems
39 - - - - - -
40 - - - - - -
41 - - - - - -
42 - - - - - -
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
ESP32-C6 TRM (Version 1.0)
GoBack
52 parl_rx_data5 0 no parl_tx_data5 1’d1 no
53 parl_rx_data6 0 no parl_tx_data6 1’d1 no
Espressif Systems
69 parl_rx_clk_in 0 no 1’d1 no
sdio_tohost_int_out
70 parl_tx_clk_in 0 no parl_tx_clk_out 1’d1 no
71 rmt_sig_in0 0 no rmt_sig_out0 1’d1 no
72 rmt_sig_in1 0 no rmt_sig_out1 1’d1 no
73 twai0_rx 1 no twai0_tx 1’d1 no
ESP32-C6 TRM (Version 1.0)
74 - - - twai0_bus_off_on 1’d1 no
75 - - - twai0_clkout 1’d1 no
76 - - - twai0_standby 1’d1 no
77 twai1_rx 1 no twai1_tx 1’d1 no
78 - - - twai1_bus_off_on 1’d1 no
GoBack
79 - - - twai1_clkout 1’d1 no
80 - - - twai1_standby 1’d1 no
Espressif Systems
94 pwm0_cap1_in 0 no - - -
95 pwm0_cap2_in 0 no - - -
96 - - - - - -
97 sig_in_func_97 0 no sig_in_func97 1’d1 no
98 sig_in_func_98 0 no sig_in_func98 1’d1 no
99 sig_in_func_99 0 no sig_in_func99 1’d1 no
100 sig_in_func_100 0 no sig_in_func100 1’d1 no
101 pcnt_sig_ch0_in0 0 no FSPICS1_out FSPICS1_oe yes
ESP32-C6 TRM (Version 1.0)
GoBack
107 pcnt_ctrl_ch0_in1 0 no - - -
108 pcnt_ctrl_ch1_in1 0 no - - -
Espressif Systems
118 - - - - - -
119 - - - - - -
120 - - - - - -
121 SPIQ_in 0 yes SPIQ_out SPIQ_oe yes
251
GoBack
7 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
GPIO Pin Name Function 0 Function 1 Function 2 Function 3 DRV Reset Notes
0 XTAL_32K_P GPIO0 GPIO0 — — 2 0 R
1 XTAL_32K_N GPIO1 GPIO1 — — 2 0 R
2 GPIO2 GPIO2 GPIO2 FSPIQ — 2 1 R
3 GPIO3 GPIO3 GPIO3 — — 2 1 R
4 MTMS MTMS GPIO4 FSPIHD — 2 1 R
5 MTDI MTDI GPIO5 FSPIWP — 2 1 R
6 MTCK MTCK GPIO6 FSPICLK — 2 1* R
7 MTDO MTDO GPIO7 FSPID — 2 1 R
8 GPIO8 GPIO8 GPIO8 — — 2 1 —
9 GPIO9 GPIO9 GPIO9 — — 2 3 —
10 GPIO10 GPIO10 GPIO10 — — 2 1 S1
11 GPIO11 GPIO11 GPIO11 — — 2 1 S1
12 GPIO12 GPIO12 GPIO12 — — 3 1 USB
13 GPIO13 GPIO13 GPIO13 — — 3 3 USB
14 GPIO14 GPIO14 GPIO14 — — 2 1 S0
15 GPIO15 GPIO15 GPIO15 — — 2 1 —
16 U0TXD U0TXD GPIO16 FSPICS0 — 2 4 —
17 U0RXD U0RXD GPIO17 FSPICS1 — 2 3 —
18 SDIO_CMD SDIO_CMD GPIO18 FSPICS2 — 2 3 —
19 SDIO_CLK SDIO_CLK GPIO19 FSPICS3 — 2 3 —
20 SDIO_DATA0 SDIO_DATA0 GPIO20 FSPICS4 — 2 3 —
21 SDIO_DATA1 SDIO_DATA1 GPIO21 FSPICS5 — 2 3 —
22 SDIO_DATA2 SDIO_DATA2 GPIO22 — — 2 3 —
23 SDIO_DATA3 SDIO_DATA3 GPIO23 — — 2 3 —
24 SPICS0 SPICS0 GPIO24 — — 2 3 S1, S2
25 SPIQ SPIQ GPIO25 — — 2 3 S1, S2
26 SPIWP SPIWP GPIO26 — — 2 3 S1, S2
27 VDD_SPI GPIO27 GPIO27 — — 2 0 S1, S2
28 SPIHD SPIHD GPIO28 — — 2 3 S1, S2
29 SPICLK SPICLK GPIO29 — — 2 3 S1, S2
30 SPID SPID GPIO30 — — 2 3 S1, S2
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)
Note:
• R - Pins in VDDPST1 domain, and part of them have analog functions, see Table 7-5.
• USB - GPIO12 and GPIO13 are USB pins. The pull-up value of the two pins are controlled by the pins’
pull-up value together with USB pull-up value. If any one of the pull-up value is 1, the pin’s pull-up resistor
will be enabled. The pull-up resistors of USB pins are controlled by USB_SERIAL_JTAG_DP_PULLUP.
• S0 - For chip variants without an in-package flash, this pin can not be used.
• S1 - For chip variants with an in-package flash, this pin can not be used.
• S2 - For chip variants with an in-package flash, this pin can only be used to connect the in-package
flash, i.e., only Function 0 is available. For chip variants without an in-package flash, this pin can be used
as a normal pin, i.e., all the functions are available.
LP Functions
LP GPIO No. GPIO No. GPIO Pin
0 1
0 0 XTAL_32K_P LP_GPIO0 lp_uart_dtrn1
1 1 XTAL_32K_N LP_GPIO1 lp_uart_dsrn1
2 2 GPIO2 LP_GPIO2 lp_uart_rtsn1
3 3 GPIO3 LP_GPIO3 lp_uart_ctsn1
4 4 MTMS LP_GPIO4 lp_uart_rxd1
5 5 MTDI LP_GPIO5 lp_uart_txd1
6 6 MTCK LP_GPIO6 lp_i2c_sda2
7 7 MTDO LP_GPIO7 lp_i2c_scl2
1 For the configuration of lp_uart_xx, please refer to Section: LP UART Controller in
Chapter 3 Low-Power CPU.
2 For the configuration of sar_i2c_xx, please refer to Section: LP I2C Controller in
Chapter 3 Low-Power CPU.
Table 7-5 shows the LP GPIO pins and how they correspond to GPIO pins and analog functions.
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;
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
7-1) has a rising edge;
• GPIO_EVT_CHx_FALL_EDGE: Indicates that the output signal of the corresponding GPIO filter (see
Figure 7-1) has a falling edge;
• GPIO_EVT_CHx_ANY_EDGE: Indicates that the output signal of the corresponding GPIO filter (see Figure
7-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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
Note: For chip variants with an in-package flash, 22 GPIO pins are available, i.e., GPIO0 ~ GPIO9 and GPIO12 ~
GPIO23. For this case:
• Configuration Registers: can only be configured for GPIO0 ~ GPIO9 and GPIO12 ~ GPIO23.
• Input Configuration Registers: can only be configured for GPIO0 ~ GPIO9 and GPIO12 ~ GPIO23.
Note: For chip variants with an in-package flash, only 22 GPIO pins are available, i.e., GPIO0 ~ GPIO9 and
GPIO12 ~ GPIO23. For this case, Configuration Registers of IO_MUX_GPIO10_REG ~ IO_MUX_GPIO11_REG and
IO_MUX_GPIO24_REG ~ IO_MUX_GPIO30_REG are not configurable.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
The addresses in this section are relative to (GPIO base address + 0x0F00). GPIO base address is provided in
Table 5-2 in Chapter 5 System and Memory.
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.
7.16 Registers
7.16.1 GPIO Matrix Registers
The addresses in this section are relative to GPIO base address provided in Table 5-2 in Chapter 5 System and
Memory.
G
RI
_O
TA
DA
UT_
_O
IO
GP
31 0
0x000000 Reset
GPIO_OUT_DATA_ORIG Configures the output value of GPIO0 ~ 30 output in simple GPIO output
mode.
0: Low level
1: High level
The value of bit0 ~ bit30 correspond to the output value of GPIO0 ~ GPIO30 respectively. Bit31
is 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 ~
GPIO30.
0: Not set
1: The corresponding bit in GPIO_OUT_REG will be set to 1
Bit0 ~ bit30 are corresponding to GPIO0 ~ GPIO30. Bit31 is invalid. Recommended operation:
use this register to set GPIO_OUT_REG.
(WT)
C
1T
_W
UT
_O
IO
GP
31 0
0x000000 Reset
GPIO_OUT_W1TC Configures whether or not to clear the output register GPIO_OUT_REG of GPIO0
~ GPIO30 output.
0: Not clear
1: The corresponding bit in GPIO_OUT_REG will be cleared.
Bit0 ~ bit30 are corresponding to GPIO0 ~ GPIO30. Bit31 is invalid. Recommended operation:
use this register to clear GPIO_OUT_REG.
(WT)
31 0
0x000000 Reset
S
1T
_W
LE
B
NA
_E
IO
GP
31 0
0x000000 Reset
31 0
0x000000 Reset
NG
PI
AP
)
TR
ed
_S
rv
se
IO
(re
GP
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
• bit2: GPIO8
• bit3: GPIO9
• bit4: GPIO15
• bit5: MTMS
• bit6: MTDI
(RO)
31 0
0x000000 Reset
GPIO_IN_DATA_NEXT Represents the input value of GPIO0 ~ GPIO30. Each bit represents a pin
input value:
0: Low level
1: High level
Bit0 ~ bit30 are corresponding to GPIO0 ~ GPIO30. Bit31 is invalid.
(RO)
PT
RU
ER
NT
I
S_
TU
TA
_S
IO
GP
31 0
0x000000 Reset
GPIO_STATUS_INTERRUPT The interrupt status of GPIO0 ~ GPIO30, can be configured by the soft-
ware.
(R/W/WTC)
31 0
0x000000 Reset
• If the value 1 is written to a bit here, the corresponding bit in GPIO_STATUS_INTERRUPT will
be set to 1.
(WT)
C
1T
W
S_
TU
TA
_S
IO
GP
31 0
0x000000 Reset
• 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
GPIO_PROCPU_INT Represents the CPU interrupt status of GPIO0 ~ GPIO30. Each bit represents:
0: Represents CPU interrupt is not enabled, or the GPIO does not generate the interrupt config-
ured by GPIO_PINn_INT_TYPE.
1: Represents the GPIO generates an interrupt configured by GPIO_PINn_INT_TYPE after the CPU
interrupt is enabled.
Bit0 ~ bit30 are corresponding to GPIO0 ~ GPIO30. Bit31 is invalid. This interrupt status
is corresponding to the bit in GPIO_STATUS_REG when assert (high) enable signal (bit13 of
GPIO_PINn_REG).
(RO)
LE
SS
S
AB
_D AS
PA
NC ER
EN
YP
BY
SY RIV
P_
PE
IO n_P 1_B
A
2_
EN
EU
TY
NC
T_
T_
AK
AD
_P SY
IN
IN
W
n_
n_
n_
n_
GP INn
d)
GP ed)
)
ed
IN
IN
IN
IN
ve
I
P
_P
_P
_P
_P
rv
rv
O_
r
se
se
se
IO
IO
IO
IO
I
(re
(re
(re
GP
GP
GP
GP
31 18 17 13 12 11 10 9 7 6 5 4 3 2 1 0
GPIO_PINn_INT_ENA Configures whether or not to enable CPU interrupt or CPU non-maskable in-
terrupt.
(R/W)
31 0
0x000000 Reset
L
SE
V_
L
SE
IN
_I L
Cn SE
N_
N_
UN IN_
_I
Cn
_F _
IO IGn
)
UN
ed
GP _S
_F
rv
se
IO
IO
(re
GP
GP
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 31 GPIO pins to connect the input signal
n.
0: Select GPIO0
1: Select GPIO1
......
29: Select GPIO29
30: Select GPIO30
Or
0x38: A constantly high input
0x3C: A constantly low input
(R/W)
UT EL EL
EL
_O _S _S
_S
EL
C0 OEN INV
NV
_S
_I
UN 0_ _
UT
_F C EN
IO UN _O
_O
GP _F C0
C0
d)
IO U N
UN
ve
GP _F
_F
r
se
IO
IO
(re
GP
GP
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)
EN
K_
d)
L
ve
_C
r
se
IO
(re
GP
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
se
IO
(re
GP
31 28 27 0
0 0 0 0 0x1907040 Reset
T1
U
OU
U
_O
_O
K_
LK
LK
L
_C
_C
_C
)
ed
UX
UX
UX
rv
se
_M
_M
_M
(re
IO
IO
IO
31 15 14 10 9 5 4 0
_G On CU PU
_M _S D
V
_ U
D
EL
V
_E
On LP P
DR
E
UN P
_M WP
CU EL
DR
IO UX PI _M _IE
UX GPI _M U_W
PI _S _W
_O
_S
PI _F _IE
IO X_G _F _W
ER
_M _ On U_
N_
U
U
_G On UN
On UN
LT
_M _ On C
_M _ On C
FU
M
IO UX PI _M
FI
UX GPI _F
n_
n_
On
_M _ On
IO UX On
IO
O
PI
IO UX PI
PI
IO UX PI
P
_M GP
_G
_G
G
G
G
)
ed
_M _
_M _
UX
UX
UX
IO UX
rv
U
se
_M
_M
_M
_M
_M
(re
IO
IO
IO
IO
IO
31 16 15 14 12 11 10 9 8 7 6 5 4 3 2 1 0
IO_MUX_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)
IO_MUX_GPIOn_FILTER_EN Configures whether or not to enable filter for pin input signals.
0: Disable
1: Enable
(R/W)
_
UX
rv
se
_M
(re
IO
31 28 27 0
0 0 0 0 0x2006050 Reset
E
AL
SC
RE
N
_P
I
n_
Dn
SD
_S
T_
d)
XT
X
ve
_E
_E
r
se
IO
IO
(re
GP
GP
31 16 15 8 7 0
GPIO_EXT_SDn_IN (n: 0 - 3) Configures the duty cycle of sigma delta modulation output.
(R/W)
)
XT
ed
GP rve
_E
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_SD_FUNCTION_CLK_EN Configures whether or not to enable the clock for sigma delta
modulation.
0: Not enable
1: Enable
(R/W)
S
TH
M
RE
NU
ID
H
_W
_T
O_
W
_I
DO
DO
UT
IN
IN
N
IN
_W
_W
_E
n_
Hn
Hn
n
CH
CH
_C
_C
R_
R_
ER
ER
E
ILT
ILT
LT
LT
FI
FI
_F
_F
T_
T_
)
XT
XT
ed
X
E
_E
_E
_E
rv
O_
se
IO
IO
IO
I
(re
GP
GP
GP
GP
31 19 18 13 12 7 6 1 0
GPIO_EXT_FILTER_CHn_WINDOW_WIDTH Configures the window width for Glitch Filter. The effec-
tive value of window width is 0 ~ 62. 63 is a reserved value and cannot be used.
Measurement unit: IO MUX operating clock cycle
(R/W)
L
N
E
_S
_E
NT
NT
VE
VE
E
_E
n_
Hn
CH
_C
ed M_
M
ET
T
_E
(re XT_
)
XT
ed
_E
_E
rv
rv
se
se
IO
IO
(re
GP
GP
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
L
L
L
EN
EN
N
SE
SE
SE
N
SE
_E
_E
2_
2_
0_
0_
3_
1_
O3
O1
IO
IO
IO
IO
IO
IO
PI
PI
GP
GP
GP
GP
GP
GP
_G
_G
K_
K_
K_
K_
K_
K_
SK
K
AS
AS
AS
AS
AS
AS
AS
A
_T
_T
_T
_T
_T
_T
_T
_T
M
TM
TM
TM
TM
TM
TM
T
T
_E
_E
_E
_E
_E
_E
_E
T_
d)
)
XT
XT
XT
XT
XT
XT
XT
ed
ed
ed
EX
ve
_E
_E
_E
_E
_E
_E
_E
rv
rv
rv
O_
r
se
se
se
se
IO
IO
IO
IO
IO
IO
IO
I
(re
(re
(re
(re
GP
GP
GP
GP
GP
GP
GP
GP
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
L
L
EN
EN
SE
SE
SE
N
SE
_E
_E
6_
6_
5_
4_
4_
7_
O5
O7
IO
IO
IO
IO
IO
IO
PI
PI
GP
GP
GP
GP
GP
GP
_G
_G
K_
K_
K_
K_
K_
K_
SK
K
AS
AS
AS
AS
AS
AS
AS
A
_T
_T
_T
_T
_T
_T
_T
_T
TM
TM
TM
TM
TM
TM
TM
T
_E
_E
_E
_E
_E
_E
_E
T_
)
)
XT
XT
XT
XT
XT
XT
XT
ed
ed
ed
ed
EX
_E
_E
_E
_E
_E
_E
_E
rv
rv
rv
rv
O_
se
se
se
se
IO
IO
IO
IO
IO
IO
IO
I
(re
(re
(re
(re
GP
GP
GP
GP
GP
GP
GP
GP
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
EL
L
L
N
L
EN
SE
EN
N
SE
SE
_S
_E
_E
11_
1_
8_
8_
9_
10
10
O9
O1
IO
IO
IO
IO
IO
IO
PI
PI
GP
GP
GP
GP
GP
GP
_G
_G
K_
K_
K_
K_
K_
K_
SK
K
AS
AS
AS
AS
AS
AS
AS
A
_T
_T
_T
_T
_T
_T
_T
_T
M
TM
TM
TM
TM
TM
TM
T
T
_E
_E
_E
_E
_E
_E
_E
_E
)
)
XT
XT
XT
XT
XT
XT
XT
XT
ed
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
rv
rv
rv
rv
se
se
se
se
IO
IO
IO
IO
IO
IO
IO
IO
(re
(re
(re
(re
GP
GP
GP
GP
GP
GP
GP
GP
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
GPIO_EXT_ETM_TASK_GPIOn_SEL (n: 8 - 11) Configures to select an ETM task channel for GPIOn.
0: Select channel 0
1: Select channel 1
......
7: Select channel 7
(R/W)
EL
EL
EL
EL
EN
N
N
EN
_S
_S
_E
_S
_E
_S
5_
3_
15
12
12
13
14
14
O1
O1
IO
IO
IO
IO
IO
IO
PI
PI
GP
GP
GP
GP
GP
GP
_G
_G
K_
K_
K_
K_
K_
K_
SK
K
AS
AS
AS
AS
AS
AS
AS
A
_T
_T
_T
_T
_T
_T
_T
_T
M
TM
TM
TM
TM
TM
TM
T
T
_E
_E
_E
_E
_E
_E
_E
_E
)
)
XT
XT
XT
XT
XT
XT
XT
XT
ed
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
rv
rv
rv
rv
se
se
se
se
IO
IO
IO
IO
IO
IO
IO
IO
(re
(re
(re
(re
GP
GP
GP
GP
GP
GP
GP
GP
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
GPIO_EXT_ETM_TASK_GPIOn_SEL (n: 12 - 15) Configures to select an ETM task channel for GPIOn.
0: Select channel 0
1: Select channel 1
......
7: Select channel 7
(R/W)
EL
EL
EL
N
N
EN
EN
SE
_S
_E
_S
_E
_S
9_
17_
7_
16
16
19
18
18
O1
O1
IO
IO
IO
IO
IO
IO
PI
PI
GP
GP
GP
GP
GP
GP
_G
_G
K_
K_
K_
K_
K_
K_
SK
K
AS
AS
AS
AS
AS
AS
AS
A
_T
_T
_T
_T
_T
_T
_T
_T
M
TM
TM
TM
TM
TM
TM
T
T
_E
_E
_E
_E
_E
_E
_E
T_
)
)
XT
XT
XT
XT
XT
XT
XT
ed
ed
ed
ed
EX
_E
_E
_E
_E
_E
_E
_E
rv
rv
rv
rv
O_
se
se
se
se
IO
IO
IO
IO
IO
IO
IO
I
(re
(re
(re
(re
GP
GP
GP
GP
GP
GP
GP
GP
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
GPIO_EXT_ETM_TASK_GPIOn_SEL (n: 16 - 19) Configures to select an ETM task channel for GPIOn.
0: Select channel 0
1: Select channel 1
......
7: Select channel 7
(R/W)
EL
EL
EL
EL
N
N
EN
EN
_S
_E
_S
_E
_S
_S
3_
1_
20
20
22
22
23
21
O2
O2
IO
IO
IO
IO
IO
IO
PI
PI
GP
GP
GP
GP
GP
GP
_G
_G
K_
K_
K_
K_
K_
K_
SK
K
AS
AS
AS
AS
AS
AS
AS
A
_T
_T
_T
_T
_T
_T
_T
_T
M
TM
TM
TM
TM
TM
TM
T
T
_E
_E
_E
_E
_E
_E
_E
_E
)
)
XT
XT
XT
XT
XT
XT
XT
XT
ed
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
rv
rv
rv
rv
se
se
se
se
IO
IO
IO
IO
IO
IO
IO
IO
(re
(re
(re
(re
GP
GP
GP
GP
GP
GP
GP
GP
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
EL
EL
EL
EL
EN
N
EN
_S
_S
_E
_S
_E
_S
5_
7_
26
26
25
24
24
27
O2
O2
IO
IO
IO
IO
IO
IO
PI
PI
GP
GP
GP
GP
GP
GP
_G
_G
K_
K_
K_
K_
K_
K_
SK
K
AS
AS
AS
AS
AS
AS
AS
A
_T
_T
_T
_T
_T
_T
_T
_T
M
TM
TM
TM
TM
TM
TM
T
T
_E
_E
_E
_E
_E
_E
_E
_E
)
)
XT
XT
XT
XT
XT
XT
XT
XT
ed
ed
ed
ed
_E
_E
_E
_E
_E
_E
_E
_E
rv
rv
rv
rv
se
se
se
se
IO
IO
IO
IO
IO
IO
IO
IO
(re
(re
(re
(re
GP
GP
GP
GP
GP
GP
GP
GP
31 28 27 25 24 23 20 19 17 16 15 12 11 9 8 7 4 3 1 0
EL
EL
EN
N
EN
SE
_S
_E
_S
0_
0_
9_
29
28
28
O2
O3
O3
IO
IO
IO
PI
PI
PI
GP
GP
GP
_G
_G
_G
K_
K_
K_
K
SK
K
AS
AS
AS
AS
AS
TA
_T
_T
_T
_T
_T
_
TM
TM
TM
TM
TM
TM
_E
_E
_E
_E
_E
_E
d)
)
XT
XT
XT
XT
XT
XT
ed
ed
ve
_E
_E
_E
_E
_E
_E
rv
rv
r
se
se
se
IO
IO
IO
IO
IO
IO
(re
(re
(re
GP
GP
GP
GP
GP
GP
31 20 19 17 16 15 12 11 9 8 7 4 3 1 0
XT
ve
_E
r
se
IO
(re
GP
31 28 27 0
0 0 0 0 0x2203050 Reset
TA
DA
U T_
_O
)
ed
IO
rv
P
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
S
1T
_W
TA
DA
U T_
_O
)
ed
IO
rv
P
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
• If the value 1 is written to a bit here, the corresponding bit in LP_IO_OUT_REG will be set to
1.
(WT)
C
1T
_W
TA
DA
U T_
_O
)
ed
IO
rv
P
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
• If the value 1 is written to a bit here, the corresponding bit in LP_IO_OUT_REG will be cleared.
(WT)
E
BL
NA
_E
)
ed
IO
rv
P
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
S
1T
_W
LE
B
NA
_E
d)
IO
ve
P
r
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
• If the value 1 is written to a bit here, the corresponding bit in LP_IO_ENABLE_REG will be
set to 1.
(WT)
C
1T
W
E_
BL
NA
_E
)
ed
IO
rv
P
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
• If the value 1 is written to a bit here, the corresponding bit in LP_IO_ENABLE_REG will be
cleared.
(WT)
INT
S_
TU
TA
_S
)
ed
IO
rv
P
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
S
1T
_W
I NT
S_
TU
TA
_S
)
ed
IO
rv
P
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
• If the value 1 is written to a bit here, the corresponding bit in LP_IO_STATUS_INT will be set
to 1.
(WT)
C
1T
_W
I NT
S_
TU
TA
_S
d)
IO
ve
P
r
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
• If the value 1 is written to a bit here, the corresponding bit in LP_IO_STATUS_INT will be
cleared
(WT)
XT
NE
N_
)
_I
ed
IO
rv
P
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 Reset
R
R CL
LE
VE _
RI EUP
AB
EN
_D AK
P_
PE
AD W
EU
ed _P E_
TY
T_
n G
AK
IN ED
IN
W
n_
n_
(re O_P n_
IN
IN
PI PIN
_P
_P
d)
)
_G _
ed
IO
IO
LP PIO
ve
rv
rv
P
P
r
se
se
se
_G
_G
_G
(re
(re
LP
LP
LP
31 11 10 9 7 6 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
• If the value 1 is written to a bit here, the edge wake-up status of corresponding GPIO will
be cleared.
(WT)
GP n_ U_ E
n_ P_ E
RV
_ E
E
EL
O_ IO C RU
IO SL RD
E
CU L
UN U
_ M RD
_G _ On C E
_O
M SE
PI _F _IE
_G _ On N_D
_G _F _R
_S
PI GP _M U_
UN
LP O_G IOn UN
On UN
_G _ On C
FU
_F
PI GP _F
n_
On
LP PIO IOn
O
PI
PI
LP PIO GPI
LP PIO GPI
P
_G
LP O_G
)
_G _
_G _
ed
IO
LP PIO
O
rv
PI
PI
P
se
_G
_G
_G
_G
_G
(re
LP
LP
LP
31 15 14 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
LP_GPIO_GPIOn_FUN_SEL Configures to select the LP IO MUX function for GPIOn in normal exe-
cution mode.
0: Select Function 0
1: Select Function 1
......
(R/W)
LP_GPIO_GPIOn_FUN_IE Configures whether or not to enable the input of GPIOn in normal execu-
tion mode.
0: Not enable
1: Enable
(R/W)
LP_GPIO_GPIOn_MCU_IE Configures whether or not to enable the input of GPIOn during sleep
mode.
0: Not enable
1: Enable
(R/W)
LP_GPIO_GPIOn_MCU_RUE Configures whether or not to enable the pull-up resistor of GPIOn dur-
ing sleep mode.
0: Not enable
1: Enable
(R/W)
LP_GPIO_GPIOn_SLP_SEL Configures whether or not to enable the sleep mode for GPIOn.
0: Not enable
1: Enable
(R/W)
LP_GPIO_GPIOn_MCU_OE Configures whether or not to enable the output of GPIOn during sleep
mode.
0: Not enable
1: Enable
(R/W)
E XT
_N
NT
I
S_
TU
TA
_S
d)
IO
ve
P
r
se
_G
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DA
ed
rv
O_
se
_I
(re
LP
31 30 0
0 0x2202100 Reset
8.1 Reset
8.1.1 Overview
ESP32-C6 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 8-1 shows the scopes of affected subsystems by each type of reset.
ESP32-C6’s Digital System consists of High Performance System (HP system) that includes Digital Core and
Wireless Circuit, and Low Power System (LP system). See Figure 8-1 for details.
8.1.3 Features
• Four reset types:
– CPU Reset: resets CPU core. Once such reset is released, the instructions from the CPU reset
vector will be executed.
– Core Reset: resets the whole digital system except LP system, including CPU, peripherals, Wi-Fi,
Bluetooth® LE, and digital GPIOs.
– Software Reset: triggered via software by configuring the corresponding registers of CPU, see
Chapter 12 Low-Power Management.
8.2 Clock
8.2.1 Overview
ESP32-C6 clocks are mainly sourced from oscillator (OSC), RC, and PLL circuit, 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 8-2 shows the system clock structure.
PLL_CLK CLK_MANAGEMENT
PLL
HP_ROOT_CLK
(max 160M)
MUX
Wi-Fi
Bluetooth
LE
AHB_CLK APB_CLK
DIV DIV DIV
DIV CRYPTO_CLK
MSPI_CLK
DIV
PERI
DIV
PLL_F80M_CLK
RC_FAST_CLK LEDC_SCLK
MUX
XTAL_CLK
DIV
PLL_F160M_CLK
RC_FAST_CLK MCPWM_CLK
MUX
XTAL_CLK
LP_FAST_CLK
DIV
XTAL_D2_CLK LP_DYN_FAST_CLK
LP_
RC RC32K_CLK SYSTEM
32 kHz
Note:
The AUTODIV in the figure will divide 480 MHz PLL_CLK into 160 MHz clock by hardware control only when the MUX
before selects PLL_CLK. If the MUX before selects RC_FAST_CLK or XTAL_CLK, AUTODIV will not divide the clock
frequency.
8.2.3 Features
ESP32-C6 clock sources as shown on the left side of Figure 8-2 can be classified into two types depending
on their frequencies:
• High-speed clock sources for devices working at a higher frequency, such as CPU and digital peripherals
– PLL_CLK (480 MHz): internal PLL clock. Its reference clock is XTAL_CLK.
• Slow-speed clock sources for LP system and some peripherals working in low-power mode
– RC_FAST_CLK (17.5 MHz by default): internal fast RC oscillator with adjustable frequency
– RC_SLOW_CLK (136 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. After
configuring this GPIO, also configure the Hold function (see Chapter 7 IO MUX and GPIO Matrix
(GPIO, IO MUX) > 7.9 Pin Hold Feature)
As Figure 8-2 shows, CPU_CLK is the master clock for CPU and it can be as high as 160 MHz when CPU works
in high performance mode. 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, CRYPTO_CLK, and
MSPI_CLK. Users can select from XTAL_CLK, PLL_CLK, or RC_FAST_CLK as the clock source of CPU_CLK by
configuring PCR_SOC_CLK_SEL. See Table 8-2 and Table 8-3. When PLL_CLK is selected as the clock
source, CPU_CLK will be divided into 160 MHz clock by hardware control before the configurable divider,
please refer to AUTODIV in figure 8-2. By default, the CPU clock is sourced from XTAL_CLK with a divider of 1,
i.e., the CPU clock is 40 MHz.
The available divider values for CPU_CLK and AHB_CLK are as follows:
• PCR_CPU_HS_DIV_NUM: 0, 1, 3
• PCR_CPU_LS_DIV_NUM: 0, 1, 3, 7, 15, 31
• PCR_AHB_HS_DIV_NUM: 3, 7, 15
• PCR_AHB_LS_DIV_NUM: 0, 1, 3, 7, 15, 31
As shown in 8-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. 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
– RC32K_CLK
– OSC_SLOW_CLK
– RC_FAST_CLK
The clock source of LP_DYN_FAST_CLK depends on the chip’s power mode (see Chapter 12 Low-Power
Management).
Table 8-4, Table 8-5, and Table 8-6 list the derived clocks source and HP clocks/LP clocks for each peripheral.
Source Clock Derived Clock Source Clock Derived Clock Source Clock
I2C Controller Y Y
(I2C)
SPI2 Y Y Y
SAR ADC Y Y Y
USB Serial/JTAG Y
Controller
(USB_SERIAL_JTAG)
Two-wire Auto- Y Y
motive Interface
(TWAI)
GoBack
LED PWM Con- Y Y Y
troller (LEDC)
System Timer Y Y
(SYSTIMER)
Continued on the next page...
Espressif Systems
troller (PCNT)
Event Task Matrix Y
(SOC_ETM)
GDMA Controller Y
(GDMA)
UHCI Y
300
Source Clock Derived Clock Source Clock Derived Clock Source Clock
Brownout Detec- Y
tor
Power Manage- Y Y Y
ment Unit (PMU)
UART Controller Y Y
(LP_UART)
Low-Power CPU Y
I2C Controller Y Y
(LP_I2C)
LP_IO MUX Y
GoBack
8 Reset and Clock GoBack
PLL_CLK
PLL_F480M_CLK is the source clock of PLL�which is 480 MHz. PLL_D2_CLK (240 MHz), PLL_F160M_CLK,
PLL_F80M_CLK, and PLL_F48M_CLK are divided from PLL_F480M_CLK.
CRYPTO_CLK
As shown in Figure 8-2, CRYPTO_CLK shares the same clock sources with CPU_CLK, and its frequency is up
to 160 MHz.
To protect encryption and decryption peripherals from DPA (Differential Power Analysis) attacks, a random
divider strategy is implemented for the function clock of encryption and decryption peripherals. Four 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 configuration of EFUSE_SEC_DPA_LEVEL, otherwise, by the value of
HP_SYSTEM_SEC_DPA_LEVEL.
LED_PWM
LEDC module uses PLL_F80M_CLK, RC_FAST_CLK and XTAL_CLK as clock source when APB_CLK is
disabled. In other words, when the system is in low-power mode, most peripherals will be halted (APB_CLK is
turned off), but LEDC can work normally via RC_FAST_CLK.
Wi-Fi and Bluetooth LE can work only when CPU_CLK uses PLL_CLK as its clock source. Suspending
PLL_CLK requires that Wi-Fi and Bluetooth LE have entered low-power mode first.
Tables 8-7 and 8-8 list the correspondence between pre-configured PMU register bits and HP system clock
gating.
Table 8-7. Mapping Between PMU Register Bits and the Clock Gating of Peripherals’ Register R/W Operations
Table 8-8. Mapping Between PMU Register Bits and the Gating of Peripherals’ Operating Clock
The operating clock (function clock) of most peripherals can be selected from multiple clock sources. In the
description of the gating registers, it will be stated whether the register belongs to the bus clock (AHB_CLK,
APB_CLK) gating register or the function clock gating register.
Bus clock switches, function clock switches, and the configuration registers for clock source selection and
clock frequency division are grouped into the PCR module. For more information, see Section 8.4�Register
Summary.
When a peripheral is not working, users can turn off its function clock by configuring related registers. Turning
off the peripheral’s function clock does not affect the rest of the system.
Figure 8-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 function clock, the bus clock of the peripheral can also be turned off to further lower power
consumption.
Note that if you turn off the bus clock first, the function clock may continue working. It is recommended to
turn off the function clock first and then the bus clock when turning off the clocks. It is also recommended to
turn on the bus clock first and then the function clock when turning on the clocks.
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.
8.5 Registers
8.5.1 PCR Registers
The addresses in this section are relative to the Power/Clock/Reset (PCR) Register base address provided in
Table 5-2 in Chapter 5 System and Memory.
EN
CL EN
K_
0_ T_
RT RS
UA 0_
R_ RT
)
ed
PC _UA
rv
se
R
(re
PC
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
M
NU
A
V_
IV_
IV_
EL
SC EN
I
_D
_D
_D
_S
_
RT CLK
LK
LK
LK
LK
SC
SC
SC
S
R_ T0_
0_
0_
0_
0_
RT
RT
RT
d)
R
ve
UA
UA
UA
UA
UA
r
R_
R_
R_
R_
se
(re
PC
PC
PC
PC
PC
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 frequency divider factor for UART0
function clock.
(R/W)
PCR_UART0_SCLK_DIV_B Configures the numerator of the frequency divider factor for UART0
function clock.
(R/W)
PCR_UART0_SCLK_DIV_NUM Configures the integral part of the frequency divider factor for UART0
function clock.
(R/W)
U
CE D
OR _P
_P
_F RCE
EM FO
ed M _
rv 0_ EM
se RT M
(re _UA T0_
d)
)
R R
ve
PC _UA
r
se
R
(re
PC
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 N
1_ T_E
K_
RT RS
UA 1_
R_ RT
)
ed
PC _UA
rv
se
R
(re
PC
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
M
NU
A
V_
IV_
V_
EL
SC EN
DI
DI
_D
_S
_
K_
LK
LK
LK
LK
CL
UA SC
SC
SC
S
1_
1_
1_
1_
1_
PC ART
RT
RT
RT
RT
)
ed
UA
UA
UA
rv
U
R_
R_
R_
R_
R_
se
(re
PC
PC
PC
PC
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 frequency divider factor for UART1
function clock.
(R/W)
PCR_UART1_SCLK_DIV_B Configures the numerator of the frequency divider factor for UART1 func-
tion clock.
(R/W)
PCR_UART1_SCLK_DIV_NUM Configures the integral part of the frequency divider factor for UART1
function clock.
(R/W)
U
CE D
OR _P
_P
_F CE
) EM OR
ed M _F
rv 1_ M
se RT ME
(re _UA T1_
d)
R R
ve
PC _UA
r
se
R
(re
PC
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
K_
C_ T_
I2 RS
)
R_ C_
ed
PC _I2
rv
se
R
(re
PC
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
M
NU
A
V_
V_
V_
EL
N
DI
DI
DI
_S
_E
K_
K_
_
R_ d) LK
LK
LK
CL
CL
PC rve SC
SC
SC
_S
_S
)
se C_
C_
C_
ed
2C
2C
(re _I2
I2
I2
rv
I
R_
R_
R_
se
R
(re
PC
PC
PC
PC
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_I2C_SCLK_DIV_A Configures the denominator of the frequency divider factor for I2C function
clock.
(R/W)
PCR_I2C_SCLK_DIV_B Configures the numerator of the frequency divider factor for I2C function
clock.
(R/W)
PCR_I2C_SCLK_DIV_NUM Configures the integral part of the frequency divider factor for I2C func-
tion clock.
(R/W)
N
LK N
_E
_C E
CI ST_
UH _ R
)
R_ CI
ed
PC _UH
rv
se
R
(re
PC
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_
T_ T_
RM RS
R_ T_
)
ed
PC _RM
rv
se
R
(re
PC
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
M
NU
A
V_
V_
V_
EL
SC EN
DI
_D
_D
_S
_
_
RM CLK
LK
LK
LK
LK
SC
SC
SC
S
PC MT_
T_
T_
T_
T_
)
ed
RM
rv
R
R_
R_
R_
R_
R_
se
(re
PC
PC
PC
PC
31 23 22 21 20 19 12 11 6 5 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 frequency divider factor for RMT func-
tion clock.
(R/W)
PCR_RMT_SCLK_DIV_B Configures the numerator of the frequency divider factor for RMT function
clock.
(R/W)
PCR_RMT_SCLK_DIV_NUM Configures the integral part of the frequency divider factor for RMT
function clock.
(R/W)
N
LK N
_E
_C _E
DC ST
LE _R
R_ DC
)
ed
PC _LE
rv
se
R
(re
PC
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
SE
DC LK_
K_
CL
C
_S
_S
DC
)
)
ed
ed
LE
LE
rv
rv
R_
R_
se
se
(re
(re
PC
PC
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
EN
CL EN
K_
0_ T_
TG RS
R_ 0_
)
ed
PC _TG
rv
se
R
(re
PC
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
_S
K_
LK
CL
_C
0_ R_
ER
E
R_ TIM
M
TI
0_
)
)
ed
ed
TG
TG
rv
rv
R_
se
se
(re
(re
PC
PC
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
EL
EN
_S
K_
LK
CL
_C
TG DT_
DT
W
W
0_
0_
)
d)
ed
ve
TG
rv
r
R_
R_
se
se
(re
(re
PC
PC
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
EN
CL N
1_ T_E
K_
TG RS
)
R_ 1_
ed
PC _TG
rv
se
R
(re
PC
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
EL
N
_S
_E
LK
LK
1_ R_C
_C
ER
E
R_ TIM
M
TI
d)
d)
1_
ve
ve
TG
TG
r
r
R_
se
se
(re
(re
PC
PC
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
CL
_C
T_
DT
R_ WD
W
)
)
1_
1_
ed
ed
TG
TG
rv
rv
R_
se
se
(re
(re
PC
PC
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
N
LK N
_E
_C _E
ER ST
IM _R
ST ER
SY IM
R_ ST
)
ed
PC _SY
rv
se
R
(re
PC
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
SE
K_
K_
CL
CL
C_
C_
UN
UN
_F
_F
R_ d) ER
ER
PC rve IM
IM
se ST
ST
)
)
ed
ed
(re _SY
SY
rv
rv
se
se
R
(re
(re
PC
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
EN
CL EN
K_
0_ T_
AI RS
TW 0_
)
R_ AI
ed
PC _TW
rv
se
R
(re
PC
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
_S
_E
LK
LK
_C
_C
NC
NC
R_ d) FU
FU
PC rve I0_
0_
)
)
AI
ed
ed
se A
(re _TW
TW
rv
rv
se
se
R
(re
(re
PC
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
EN
CL N
1_ _E
K_
AI ST
TW 1_R
)
R_ AI
ed
PC _TW
rv
se
R
(re
PC
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
_S
K_
LK
CL
_C
C_
NC
R_ d) UN
FU
PC rve I1_F
1_
)
)
AI
ed
ed
se A
(re _TW
TW
rv
rv
se
se
R
(re
(re
PC
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
EN
CL EN
K_
S_ T_
I2 RS
)
R_ S_
ed
PC _I2
rv
se
R
(re
PC
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
_D
_S
_
KM
KM
M
LK
2S CL
_C
X_
X_
X
_T
_T
_T
)
)
ed
ed
2S
2S
rv
rv
I
I
R_
R_
R_
se
se
(re
(re
PC
PC
PC
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
1
YN
Z
X
Y
IV_
IV_
V_
IV_
I
_D
_D
_D
_D
KM
KM
KM
M
LK
L
CL
CL
_C
_C
X_
X_
X
TX
_T
_T
_T
)
S_
ed
2S
2S
2S
I2
rv
I
R_
R_
R_
R_
se
(re
PC
PC
PC
PC
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 fractional divider, respectively. For more information, see
Section 30.6 in Chapter I2S Controller (I2S).
M
NU
IV_
EL
_C _EN
_D
_S
LK L
_C E
M
M
R_ RX _S
LK
LK
PC S_ LK
_C
I2 MC
RX
RX
)
d)
R_ S_
S_
S_
ed
ve
PC _I2
I2
I2
rv
r
R_
se
se
R
(re
(re
PC
PC
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
1
YN
Z
X
Y
IV_
IV_
IV_
V_I
_D
_D
_D
_D
KM
KM
KM
M
LK
CL
CL
CL
_C
X_
X_
X_
RX
R
_R
_R
)
S_
S_
ed
2S
2S
I2
I2
rv
I
R_
R_
R_
R_
se
(re
PC
PC
PC
PC
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 fractional divider, respectively. For more information, see
Section 30.6.
EN EN
) RS CL EN
T_ K_
ed C_ B_ _
rv D P ST
se RA _A _R
(re _SA ADC APB
R R _
PC SA DC
R_ RA
d)
ve
PC _SA
r
se
R
(re
PC
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 1 Reset
PCR_SARADC_RST_EN Configures whether or not to reset function register of SAR ADC module.
0: Not reset
1: Reset
(R/W)
PCR_SARADC_APB_RST_EN Configures whether or not to reset APB register of SAR ADC module.
0: Not reset
1: Reset
(R/W)
M
NU
A
IV_
IV_
V_
EL
_C _EN
I
_D
_D
_D
_S
DC KM
KM
KM
LK
LK
L
CL
CL
SA C_C
_C
C_
C_
DC
D
AD
D
PC ARA
RA
RA
RA
d)
R
ve
SA
SA
SA
S
r
R_
R_
R_
R_
R_
se
(re
PC
PC
PC
PC
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 frequency divider factor for SAR
ADC function clock.
(R/W)
PCR_SARADC_CLKM_DIV_B Configures the numerator of the frequency divider factor for SAR ADC
function clock.
(R/W)
PCR_SARADC_CLKM_DIV_NUM Configures the integral part of the frequency divider factor for SAR
ADC function clock.
(R/W)
L
EN
SE
R_ d) CL EN
K_
K_
PC rve S_ T_
se EN RS
CL
(re _TS S_
S_
R EN
EN
d)
)
ed
ve
PC _TS
TS
rv
r
se
se
R
(re
(re
PC
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
EN
CL EN
K_
G_ T_
TA RS
_J G_
AL A
RI JT
SE AL_
B_ RI
US SE
R_ B_
)
ed
PC _US
rv
se
R
(re
PC
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
N
LK N
_E
_C _E
TX RST
TM _
IN TX
R_ TM
)
ed
PC _IN
rv
se
R
(re
PC
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
N
LK N
_E
_C _E
NT ST
PC _R
R_ NT
)
ed
PC _PC
rv
se
R
(re
PC
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
N
LK N
_E
_C E
M ST_
ET _R
)
R_ M
ed
PC _ET
rv
se
R
(re
PC
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
N
LK N
_E
_C E
M ST_
PW _R
R_ M
)
ed
PC _PW
rv
se
R
(re
PC
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
EL
_C _EN
M
_S
NU
KM
V_
LK
L
I
_D
_C
M
M
)
d)
ed
PW
PW
ve
rv
r
R_
R_
R_
se
se
(re
(re
PC
PC
PC
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 frequency divider factor for PWM function
clock.
(R/W)
N
LK N
_E
_C _E
RL ST
PA _R
R_ RL
)
ed
PC _PA
rv
se
R
(re
PC
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
M
NU
V_
L
EN
SE
_R EN
DI
X_
X_
X_
LK T_
_C RS
_R
R
K_
PC ARL X_
LK
CL
_C
P _R
L_
R_ RL
RL
)
ed
R
PC _PA
PA
PA
rv
R_
R_
se
R
(re
PC
PC
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
PCR_PARL_CLK_RX_DIV_NUM Configures the integral part of the frequency divider factor for PARL
RX clock.
(R/W)
M
NU
V_
L
EN
SE
_T EN
I
_D
X_
X_
LK T_
TX
_C RS
_T
K_
LK
PC ARL X_
CL
_C
P _T
L_
R_ RL
RL
d)
R
ve
PC _PA
PA
PA
r
R_
R_
se
R
(re
PC
PC
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
PCR_PARL_CLK_TX_DIV_NUM Configures the integral part of the frequency divider factor for PARL
TX clock.
(R/W)
N
LK N
_E
_C _E
VE ST
LA _R
_S E
IO LAV
SD _S
)
R_ IO
ed
PC _SD
rv
se
R
(re
PC
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_
A_ T_
M RS
GD A_
)
R_ M
ed
PC _GD
rv
se
R
(re
PC
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
N
LK N
_E
_C E
I2 ST_
SP _R
)
R_ I2
ed
PC _SP
rv
se
R
(re
PC
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
_S
M
M
SP LK
LK
R_ _C
)
)
I2
I2
ed
ed
SP
rv
rv
R_
se
se
(re
(re
PC
PC
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
EN
CL EN
K_
S_ T_
A E RS
R_ S_
)
ed
PC _AE
rv
se
R
(re
PC
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_
A_ T_
SH RS
R_ A_
)
ed
PC _SH
rv
se
R
(re
PC
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_
A_ T_
RS RS
R_ A_
)
ed
PC _RS
rv
se
R
(re
PC
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
U
_P RCE PD
D _P
EM O _
M _F CE
A_ EM OR
RS M _F
R_ A_ EM
PC _RS _M
)
ed
R A
PC _RS
rv
se
R
(re
PC
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)
EN
CL EN
K_
C_ T_
EC RS
R_ C_
)
ed
PC _EC
rv
se
R
(re
PC
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
U
_P RCE PD
D _P
EM O _
M _F CE
C_ EM OR
EC M _F
R_ C_ EM
PC _EC _M
)
R C
ed
PC _EC
rv
se
R
(re
PC
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)
N
LK N
_E
_C _E
DS ST
R_ _R
)
ed
PC _DS
rv
se
R
(re
PC
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
N
LK N
_E
_C _E
AC RST
HM C_
)
R_ A
ed
PC _HM
rv
se
R
(re
PC
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
N
LK N
_E
_C _E
UX ST
M R
IO X_
R_ MU
)
ed
PC _IO
rv
se
R
(re
PC
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
SE
UN LK_
K_
CL
C
UX NC_
C_
IO _FU
_F
X
PC MU
)
)
ed
ed
M
IO
rv
rv
R_
R_
se
se
(re
(re
PC
31 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
N
LK N
_E
_C _E
OR ST
I T _R
ON OR
_M NIT
EM O
M _M
R_ EM
)
ed
PC _M
rv
se
R
(re
PC
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_ T_
AC RS
TR E_
R_ AC
)
ed
PC _TR
rv
se
R
(re
PC
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
N
LK N
_E
_C _E
ST T
SI RS
AS ST_
)
R_ SI
ed
PC _AS
rv
se
R
(re
PC
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_ T_
CH RS
CA E_
R_ CH
)
ed
PC _CA
rv
se
R
(re
PC
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
N
_E
LK
PB N
_C
_A T_E
E M RS
OD _
M EM
)
R_ OD
ed
PC _M
rv
se
R
(re
PC
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
N
_E
_R EN
ST
UT _
) EO ST
ed M _R
rv TI UT
se U_ EO
(re _CP IM
)
R _T
ed
PC _HP
rv
se
R
(re
PC
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
Q
RE
M
SE
M
_F
NU
NU
K_
AL
IV_
V_
L
XT
_C
DI
D
K_
)
OC
S_
ed
ed
S_
CL
rv
rv
H
S
L
R_
R_
R_
R_
se
se
(re
(re
PC
PC
PC
PC
31 30 24 23 18 17 16 15 8 7 0
0 40 0 0 0 0 0 0 0 2 0 Reset
ON
E_
RC
UM
FO
_N
E_
AY
OD
EL
_D
M
IT_
TI
AI
A
W
W
U_
U_
)
)
ed
ed
CP
CP
rv
rv
R_
R_
se
se
(re
(re
PC
PC
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
CE
OR
M
_F
NU
NU
0M
V_
IV_
DI
12
_D
S_
S_
LS
_H
_H
U_
)
PU
PU
ed
CP
rv
C
R_
R_
R_
se
(re
PC
PC
PC
31 17 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
M
NU
NU
V_
V_
DI
DI
S_
S_
_H
_L
)
HB
HB
ed
rv
A
R_
R_
se
(re
PC
PC
31 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 Reset
M
NU
IV_
_D
E
AS
M
NU
RE
IV_
EC
_D
_D
d)
PB
PB
ve
A
r
R_
R_
se
(re
PC
PC
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
N
LK N
0M LK N
PC _PL 48 _CL _EN
PL 16 _C EN
PC _PL 80 _CL _EN
PC _PL 120 _CL _EN
_E
_C _E
24 _C _E
R_ L_ M K_
L_ 0M LK
R L_ M LK
R L_ M K
R L_ M K
PC PL 40 C
R_ L_ M_
PC _PL 20
R L_
d)
ve
PC _PL
r
se
R
(re
PC
31 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 Reset
PCR_PLL_240M_CLK_EN Configures whether or not to enable 240 MHz clock derived from SPLL
divided by 2.
0: Not enable
1 (default): Enable
Only available when high-speed clock source SPLL is active.
(R/W)
PCR_PLL_160M_CLK_EN Configures whether or not to enable 160 MHz clock derived from SPLL
divided by 3.
0: Not enable
1 (default): Enable
Only available when high-speed clock source SPLL is active.
(R/W)
PCR_PLL_120M_CLK_EN Configures whether or not to enable 120 MHz clock derived from SPLL
divided by 4.
0: Not enable
1 (default): Enable
Only available when high-speed clock source SPLL is active.
(R/W)
PCR_PLL_80M_CLK_EN Configures whether or not to enable 80 MHz clock derived from SPLL
divided by 6.
0: Not enable
1 (default): Enable
Only available when high-speed clock source SPLL is active.
(R/W)
PCR_PLL_48M_CLK_EN Configures whether or not to enable 48 MHz clock derived from SPLL
divided by 10.
0: Not enable
1 (default): Enable
Only available when high-speed clock source SPLL is active.
(R/W)
PCR_PLL_40M_CLK_EN Configures whether or not to enable 40 MHz clock derived from SPLL
divided by 12.
0: Not enable
1 (default): Enable
Only available when high-speed clock source SPLL is active.
(R/W)
PCR_PLL_20M_CLK_EN Configures whether or not to enable 20 MHz clock derived from SPLL
divided by 24.
0: Not enable
1 (default): Enable
Only available when high-speed clock source SPLL is active.
(R/W)
M
NU
K_
C
TI
C_
)
)
ed
ed
S
FO
rv
rv
R_
se
se
(re
(re
PC
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)
K
32
rv
R_
se
(re
PC
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_32K_SEL Configures to select one 32 kHz clock for MODEM_SYSTEM and TIMER_GROUP.
0: Select RC32K_CLK (default)
1: Select XTAL32K_CLK
2/3: Select OSC_SLOW_CLK from GPIO0
(R/W)
N
N
_O
_O
CE
CE
OR
R
FO
_F
U
D
PU
PD
_P
_P
_
TE
TE
E_
CE
CE
GA
CE
GA
OR
OR
LK
OR
OR
LK
_C
_F
_F
_C
_F
_F
AM
AM
M
)
OM
OM
OM
ed
RA
SR
SR
rv
S
R_
R_
R_
R_
R_
R_
se
(re
PC
PC
PC
PC
PC
PC
31 21 20 18 17 15 14 12 11 8 7 4 3 0
PCR_SRAM_CLKGATE_FORCE_ON Configures whether or not to force open the clock and bypass
the gate-clock when accessing the SRAM.
0: A gate-clock will be used when accessing the SRAM.
1: Force to open the clock and bypass the gate-clock when accessing the SRAM.
(R/W)
PCR_ROM_CLKGATE_FORCE_ON Configures whether or not to force open the clock and bypass
the gate-clock when accessing the ROM.
0: A gate-clock will be used when accessing the ROM.
1: Force to open the clock and bypass the gate-clock when accessing the ROM.
(R/W)
M
AP
_
BY SS
SS
T_ PA
PA
EN BY
EV T_
T_ EN
SE EV
RE T_
R_ SE
)
ed
PC _RE
rv
se
R
(re
PC
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 Reset
F
C_
_F
)
ed
S
LL
FO
rv
P
R_
R_
se
(re
PC
PC
31 18 17 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 480 20 Reset
TE
)
ed
DA
rv
R_
se
(re
PC
31 28 27 0
0 0 0 0 0x2206150 Reset
8.5.2 LP Registers
The addresses in this section are relative to the Low-power Clock/Reset Register (LP_CLKRST) base address.
For base address, please refer to Table 5-2 in Chapter 5 System and Memory.
EL
_C EL
_S
OW _S
LK
K
CL
RS ST_
SL
FA
T_
T_
)
RS
ed
LK
LK
rv
se
_C
_C
(re
LP
LP
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 0x0 Reset
_C RS O K EN N
LP LK T_F C32 _O _OE
EN
OW EN
_O
_C RS O O N
_C RS S 2K E
SL _O
LP LK T_F G_O OEN
T_ N_ EN
LK T_ SC EN
N_ ST
LP LK T_C W_ N
LP LK T_S T_ N
_C RS LO OE
_C RS O O
RS AO _O
_C RS AS E
AO FA
_C RS TA E
_C RS N _
LP LK T_R BUS
_C RS P
LP LK T_L
)
_C RS
ed
LP LK
rv
se
_C
(re
LP
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
)
ed
KR
rv
L
se
_C
(re
LP
31 30 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EN
E T_
ES
RE N
_R
N_ E EN EN
CO _E
E_ ET
AO TIM T_ T_
T_ C_ SE SE
US ES
RS RT RE RE
EF R_R
LK T_ T_ RI_
_C RS D E
LP LK T_W A_P
_C RS N
LP LK T_A
d)
_C RS
ve
LP LK
r
se
_C
(re
LP
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
LP_CLKRST_WDT_RESET_EN Configures whether or not to reset RTC_WDT and super watch dog
0: Invalid.No effect
1: Reset
(R/W)
LR
_C
E
US
CA
T_
SE
SE
AU
E
_R
_C
E0
ET
R
ES
CO
_R
T_
ST
LP ed)
)
RS
ed
R
LK
LK
rv
rv
se
se
_C
_C
(re
(re
LP
31 30 29 28 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
H
GT
EN
N
_E
_L
ET
ET
ES
ES
T
_R
_R
AI
N
PU
PU
_W
_E
_C
_C
LL
LL
DT
DT
A
A
ST
ST
_W
W
U_
U_
C_
TC
P
RT
_C
_C
_R
T_
ST
ST
ST
d)
RS
R
KR
KR
ve
LK
LK
L
r
se
_C
_C
_C
_C
(re
LP
LP
LP
LP
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_EN Configures whether or not CPU entry stall state before RTC_WDT and
software reset CPU
0: CPU will not entry stall state before RTC_WDT and software reset CPU
1: CPU will entry stall state before RTC_WDT and software reset CPU
(R/W)
)
ed
KR
rv
L
se
_C
(re
LP
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
LP_CLKRST_FOSC_DFREQ Configures the RC_FAST_CLK frequency, the clock frequency will in-
crease with this field.
(R/W)
EQ
FR
_D
2K
C3
_R
ST
d)
KR
ve
L
r
se
_C
(re
LP
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
LP_CLKRST_RC32K_DFREQ Configures the RC32K_CLK frequency, the clock frequency will in-
crease with this field.
(R/W)
L3
_X C
RS ICG P_ SC
IC HP C
TA
T_ _ OS
LK T_ _H FO
_C RS CG P_
LP LK T_I _H
_C RS CG
LP LK T_I
)
_C RS
ed
LP LK
rv
se
_C
(re
LP
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
N
_O
R CE
FO
_
LK
_C
EM
PM
_L
ST
d)
KR
ve
L
r
se
_C
(re
LP
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
)
_C RS
ed
LP LK
rv
se
_C
(re
LP
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
2K
K
2K
2K
32
L3
L3
L3
AL
TA
A
XT
TA
XT
_X
F_
_X
ES
M
BU
AC
DG
DR
_D
_D
T_
T_
ST
ST
d)
RS
RS
KR
KR
ve
LK
LK
L
r
se
_C
_C
_C
_C
(re
LP
LP
LP
LP
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
RS
ed
LK
rv
se
_C
(re
LP
31 30 0
0 0x2206090 Reset
9.1 Overview
Chip boot process and some chip functions are determined on power-on or hardware reset using strapping
pins and eFuses. The following functionality can be determined:
• MTMS
• MTDI
• GPIO8
• GPIO9
• GPIO15
During power-on reset, and brownout reset (see Chapter 8 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 the 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.
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-C6. 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 9-1.
In Download Boot mode, users can download code into flash using UART0 or USB interface. It is also possible
to load a program into SRAM and execute it from SRAM.
Reset
Check Strapping
Value* 10
x1
Check binary
Initialization
header
Yes No
Header = 0xaedb041d
Wait for
Initialization Initialization downloading from
UART0 or USB
*Note: The strapping values ”x1” and ”10” are the combination of GPIO8 and GPIO9 pins, see Table 9-2.
• EFUSE_DIS_FORCE_DOWNLOAD
– If this eFuse is 0 (default), software can force switch the chip from SPI Boot mode to 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”.
• EFUSE_DIS_DOWNLOAD_MODE
If this eFuse is 1, Download Boot mode is permanently disabled. GPIO_STRAPPING will not be
overwritten by LP_AON_FORCE_DOWNLOAD_BOOT.
• EFUSE_ENABLE_SECURITY_DOWNLOAD
If this eFuse is 1, Download Boot mode only allows reading, writing, and erasing plaintext flash and does
not support any SRAM or register operations. Ignore this eFuse if Download Boot mode is disabled.
• EFUSE_DIS_DIRECT_BOOT
USB Serial/JTAG Controller can also force switch the chip to Download Boot mode from SPI Boot mode, and
vice versa. For detailed information, please refer to Chapter 32 USB Serial/JTAG Controller
(USB_SERIAL_JTAG).
• UART0
EFUSE_UART_PRINT_CONTROL and GPIO8 control ROM messages printing to UART0 as shown in Table 9-3
ROM Message Printing Control.
9.2.5 SDIO Sampling Input Edge and Output Driving Edge Control
The strapping pin MTMS and MTDI can be used to control the input sampling edge and the output driving
edge. See Table 9-5 SDIO Input Sampling Edge/Output Driving Edge Control. For more information about SDIO
sampling control, see Chapter 34 SDIO 2.0 Slave Controller (SDIO).
10.1 Overview
The interrupt matrix embedded in ESP32-C6 independently routes peripheral interrupt sources to the
ESP-RISC-V CPU’s peripheral interrupts to timely inform CPU to process the coming interrupts.
The ESP32-C6 has 77 peripheral interrupt sources that can be routed to any of the 28 CPU interrupts using the
interrupt matrix.
Note:
This chapter focuses on how to map peripheral interrupt sources to CPU interrupts. For more details about interrupt
configuration, vector, and interrupt handling operations recommended by the ISA, please refer to Chapter 1 High-
Performance CPU.
10.2 Features
The interrupt matrix embedded in ESP32-C6 has the following features:
• Multiple interrupt sources mapping to a single CPU interrupt (i.e., shared interrupts)
• Column “Interrupt Source Mapping Register”: Registers used for routing the peripheral interrupt sources
to CPU peripheral interrupts.
• Column “Interrupt Status Register”: Registers used for indicating the interrupt status of peripheral
interrupt sources.
– Column “Interrupt Status Register - Bit”: Bit position in status register, indicating the interrupt status.
GoBack
Espressif Systems
GoBack
Espressif Systems
GoBack
10 Interrupt Matrix (INTMTX) GoBack
Note:
For detailed information about the function and configuration of CPU interrupts, see Chapter 1 High-Performance CPU.
• Source_X: stands for a peripheral interrupt source, wherein X means the number of this interrupt source
in Table 10-1.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
GoBack
INTMTX_CORE0_HP_APM_M1_INTR_MAP_REG HP_APM_M1_INTR mapping register 0x0090 R/W
INTMTX_CORE0_HP_APM_M2_INTR_MAP_REG HP_APM_M2_INTR mapping register 0x0094 R/W
Espressif Systems
GoBack
INTMTX_CORE0_DMA_IN_CH1_INTR_MAP_REG GDMA_IN_CH1_INTR mapping register 0x010C R/W
INTMTX_CORE0_DMA_IN_CH2_INTR_MAP_REG GDMA_IN_CH2_INTR mapping register 0x0110 R/W
Espressif Systems
The abbreviations given in Column Access are explained in Section Access Types for Registers.
GoBack
INTPRI_CORE0_CPU_INT_PRI_2_REG Priority configuration register for CPU interrupt 2 0x0014 R/W
INTPRI_CORE0_CPU_INT_PRI_3_REG Priority configuration register for CPU interrupt 3 0x0018 R/W
Espressif Systems
GoBack
INTPRI_CORE0_CPU_INT_PRI_31_REG Priority configuration register for CPU interrupt 31 0x0088 R/W
INTPRI_CORE0_CPU_INT_THRESH_REG Threshold configuration register for CPU interrupts 0x008C R/W
Espressif Systems
GoBack
10 Interrupt Matrix (INTMTX) GoBack
10.5 Registers
10.5.1 Interrupt Matrix Registers
The addresses in this section are relative to the interrupt matrix base address provided in Table 5-2 in Chapter
5 System and Memory.
TX
rv
se
TM
(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_X_MAP Map the interrupt source (SOURCE_X) into one CPU interrupt.
For the information of SOURCE_X, see Table 10-1. (R/W)
0
S_
TU
TA
_S
NT
I
0_
ORE
_C
TX
TM
IN
31 0
0x000000 Reset
1
S_
TU
TA
_S
NT
I
0_
ORE
_C
TX
TM
IN
31 0
0x000000 Reset
_2
US
AT
ST
T_
IN
0_
RE
O
_C
TX
MT
IN
31 0
0x000000 Reset
E
AT
_D
EG
R
T_
UP
R
ER
I NT
0_
E
OR
_C
)
ed
TX
rv
se
TM
(re
IN
31 28 27 0
0 0 0 0 0x2203110 Reset
B LE
NA
_E
I NT
U_
CP
0_
O RE
_C
RI
TP
IN
31 0
0 Reset
31 0
0 Reset
S
TU
TA
_S
IP
E
T_
IN
PU_
_C
R E0
CO
I_
T PR
IN
31 0
0 Reset
AP
_M
_n
P RI
U_
CP
0_
ORE
)
ed
_C
rv
RI
se
TP
(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
High-Performance CPU. (R/W)
I_
rv
R
se
TP
(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
A R
LE
_C
NT
I
U_
CP
0_
RE
O
_C
RI
TP
IN
31 0
0 Reset
0
U_
P
_C
OM
FR
R_
NT
I
P U_
)
ed
_C
rv
RI
se
TP
(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
_D
rv
RI
se
TP
(re
IN
31 28 27 0
0 0 0 0 0x2201090 Reset
11.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.
11.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, LP CPU, 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 11.3.2 and Section 11.3.3
respectively). Each channel has an individual enable bit (For configuration procedures, refer to Section
11.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 11-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.
11.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 11-1 shows the configuration values of SOC_ETM_CHn_EVT_ID and their corresponding
events.
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.
11.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. Table11-2 shows the configuration values of SOC_ETM_CHn_TASK_ID and their
corresponding tasks.
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.
Events Tasks
ETM channel
DEMUX
MUX
peripheraly clock domain Channel n peripheraly clock domain
ETM is running at the AHB_CLK domain (see Chapter 8 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 80 MHz clock domain
(PLL_F80M_CLK), and the ETM runs in the 40 MHz clock domain (AHB_CLK). To receive each event 1
successfully, the interval between two consecutive event 1 must be greater than two 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
ET M _clock_f requency
domain 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 20 MHz clock domain (RC_FAST_CLK), and
the ETM runs in the 40 MHz clock domain (AHB_CLK). To map each received event successfully to task 1, the
interval between two consecutive events must be greater than two 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
ET M _clock_f requency
these two events must be ceil( peripheral_A_clock_f requency
ET M _clock_f requency ) ∗ ceil( peripheral_B_clock_f requency ) in the unit of
peripheral A clock cycles.
For example, assuming that event 1 generated by peripheral A is in the 80 MHz clock domain
(PLL_F80M_CLK), task 1 received by peripheral B is in the 20 MHz clock domain (RC_FAST_CLK), and the
ETM runs in the 40 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
2 ∗ 2 = 4 peripheral A clock cycles.
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 1 to 3. 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
The abbreviations given in Column Access are explained in Section Access Types for Registers.
31
31
SO SO 11.5
C C
0
0
30
30
SO _ET SO _ET
C_ M C_ M
0
0
29
29
SO ET _C SO ET _C
C M H_ C M H_
0
0
28
28
(WT)
SO _ET _C EN SO _ET _C EN
C M H_ AB C M H_ AB
0
0
27
27
SO _ET _C EN LE SO _ET _C EN LE
Espressif Systems
1: Enable
C M H_ AB 31 C M H_ AB D3
1: Enabled
0
0
26
26
SO _ET _C EN LE SO _ET _C EN LE 1
0: Disabled
System and Memory.
(R/WTC/SS)
Registers
C M H_ AB 30 C M H_ AB D3
0
0
25
25
SO _ET _C EN LE SO _ET _C EN LE 0
C M H_ AB 29 C M H_ AB D2
0
0
24
24
SO _ET _C EN LE SO _ET _C EN LE 9
C M H_ AB 28 C M H_ AB D2
0
0
0: Invalid. No effect
23
23
SO _ET _C EN LE SO _ET _C EN LE 8
C M H_ AB 27 C M H_ AB D2
0
0
22
22
11 Event Task Matrix (SOC_ETM)
SO _ET _C EN LE SO _ET _C EN LE 7
C M H_ AB 26 C M H_ AB D2
0
0
21
21
SO _ET _C EN LE SO _ET _C EN LE 6
C M H_ AB 25 C M H_ AB D2
0
0
20
20
SO _ET _C EN LE SO _ET _C EN LE 5
C M H_ AB 24 C M H_ AB D2
0
0
19
SO _ET _C EN LE 19 SO _ET _C EN LE 4
C M H_ AB 23 C M H_ AB D2
0
0
18
18
SO _ET _C EN LE SO _ET _C EN LE 3
C M H_ AB 22 C M H_ AB D2
0
0
17
17
SO _ET _C EN LE SO _ET _C EN LE 2
C M H_ AB 21 C M H_ AB D2
0
0
16
16
SO _ET _C EN LE SO _ET _C EN LE 1
C M H_ AB 20 C M H_ A B D2
0
0
15
15
SO _ET _C EN LE SO _ET _C EN LE 0
C M H_ AB 19 C M H_ AB D1
399
0
0
14
14
SO _ET _C EN LE SO _ET _C EN LE 9
C M H_ AB 18 C M H_ AB D1
0
0
13
13
SO _ET _C EN LE SO _ET _C EN LE 8
C M H_ AB 17 C M H_ AB D1
0
0
12
12
SO _ET _C EN LE SO _ET _C EN LE 7
C M H_ AB 16 C M H_ AB D1
0
0
11
11
SO _ET _C EN LE SO _ET _C EN LE 6
C M H_ AB 15 C M H_ AB D1
10
10
SO _ET _C EN LE SO _ET _C EN LE 5
C M H_ AB 14 C M H_ A B D1
9
9
0
0
SO _ET _C EN LE SO _ET _C EN LE 4
C M H_ AB 13 C M H_ AB D1
8
8
0
0
SO _ET _C EN LE SO _ET _C EN LE 3
C M H_ AB 12 C M H_ A B D1
SOC_ETM_CH_ENABLEDn (n: 0-31) Represents the status of channeln.
7
7
0
0
SO _ET _C EN LE SO _ET _C EN LE 2
C M H_ AB 11 C M H_ AB D1
6
6
0
0
SO _ET _C EN LE SO _ET _C EN LE 1
C M H_ AB 10 C M H_ A B D1
Register 11.2. SOC_ETM_CH_ENA_AD0_SET_REG (0x0004)
5
5
0
0
SO _ET _C EN LE SO _ET _C EN LE 0
C M H_ AB 9 C M H_ AB D9
4
4
0
0
SO _ET _C EN LE SO _ET _C EN LE
C M H_ AB 8 C M H_ AB D8
3
3
0
0
SO _ET _C EN LE SO _ET _C EN LE
C M H_ AB 7 C M H_ AB D7
2
2
0
0
SO _ET _C EN LE SO _ET _C EN LE
1 C M H_ AB 6 C M H_ AB D6
1
0
0
SO _ET _C EN LE SO _ET _C EN LE
C M H_ AB 5 C M H_ A B D5
0
0
SO _ET _C EN LE SO _ET _C EN LE
C_ M H_ AB 4 C_ M H_ AB D4
ET _C EN LE3 ET _C EN LED
M H_ AB M H_ AB 3
0 Reset
0 Reset
_C EN LE _C EN LE
GoBack
H_ AB 2 H_ A B D2
The addresses in this section are relative to Event Task Matrix base address provided in Table 5-2 in Chapter 5
31
31
0
31
SO
C
0
0
0
30
SO _ET
C M
0
0
0
29
SO _ET _C
C M H_
0
0
0
28
(WT)
(WT)
SO _ET _C DIS
C M H_ AB
0
0
0
27
SO _ET _C DIS LE
Espressif Systems
1: Enable
1: Disable
C M H_ AB 31
1: Enabled
0
0
0
26
SO _ET _C DIS LE
0: Disabled
(R/WTC/SS)
C M H_ AB 30
0
0
0
25
SO _ET _C DIS LE
(re (re C M H_ AB 29
0
0
24
se se SO _ET _C DIS LE
rv rv C M H_ AB 28
ed ed 0
0: Invalid. No effect
0: Invalid. No effect
0
0
23
) ) SO _ET _C DIS LE
C M H_ AB 27
0
22
0
0
11 Event Task Matrix (SOC_ETM)
SO _ET _C DIS LE
C M H_ AB 26
0
21
0
0
SO _ET _C DIS LE
C M H_ AB 25
0
20
0
0
SO _ET _C DIS LE
C M H_ AB 24
0
19
0
0
SO _ET _C DIS LE
C M H_ AB 23
0
18
0
18
0
18
SO _ET _C DIS LE
C M H_ AB 22
0
0
0
17
17
17
SO SO SO _ET _C DIS LE
C C C M H_ AB 21
0
0
0
16
16
16
0
0
0
15
15
15
400
0
0
0
14
14
14
0
0
0
13
13
13
0
0
0
12
12
12
0
0
0
11
11
11
10
10
10
9
9
9
0
0
0
8
8
8
0
0
0
7
7
7
0
0
0
6
6
6
0
0
0
C M H_ AB 42 C M H_ AB D4
5
5
5
0
0
0
4
4
4
0
0
0
3
3
3
0
0
0
2
2
2
0
0
0
1
1
1
0
0
0
0
0
0
0 Reset
0 Reset
0 Reset
_C EN LE _C EN LE 5 _C DI L
GoBack
H_ AB 34 H_ AB D3 H_ SA E2
C_ M H_ AB 36
C M H_ AB 40
BL 3
M H_ AB 35
2
C M H_ AB 42
C M H_ AB 39
C M H_ AB 38
C M H_ AB 46
C M H_ AB 43
DI BL 4
C M H_ AB 45
C M H_ AB 48
C M H_ AB 44
C M H_ AB 49
C M H_ AB 37
C M H_ AB 47
C M H_ AB 41
H_ SA E3
SA E3
E3
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
SO _ET _C DIS LE
ET _C DIS LE
_C DI L
C M H_ AB
SO _ET _C DIS
C M H_
SO _ET _C
)
C M
ed
SO _ET
rv
se
C
(re
SO
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
_I
VT
_E
Hn
_C
)
TM
ed
rv
E
C_
se
(re
SO
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: 0-49) Configures the event ID of channeln. See Table 11-1. (R/W)
M
ed
ET
rv
C_
se
(re
SO
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: 0-49) Configures the task ID of channeln. See Table 11-2. (R/W)
EN
L K_
_C
d)
TM
ve
E
r
C_
se
(re
SO
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
)
TM
ed
rv
E
C_
se
(re
SO
31 28 27 0
0 0 0 0 0x2203092 Reset
12 Low-Power Management
12.1 Overview
ESP32-C6 features an advanced low-power management system that can optimize the chip’s power
consumption while maintaining its high performance.
The low-power management system employs various power-saving techniques such as sleep modes, dynamic
voltage and frequency scaling, and peripheral power gating to minimize the chip’s power consumption.
The power management unit (PMU) is a hardware component that is the core part of the low-power
management system and is responsible for powering up and down different power domains of the chip, to
achieve the best balance among chip performance, power consumption, and wake-up latency.
12.2 Terminology
The following terms related to low-power management are defined in the context of the ESP32-C6 Technical
Reference Manual to help readers better understand this document:
Low-power management Refers to the whole system that manages the chip’s power con-
sumption.
Power management unit (PMU) Refers to the specific hardware module that controls power up
and down for the power domains, clocks, and power-related logic.
Power domain Refers to the smallest unit that can be independently powered up
or down. A power domain can contain one or multiple modules
within the chip.
PMU states Refers to four states of the PMU’s state machine. Users can con-
figure the clock gating and power gating of a power domain in
each of the four states.
Power modes Refers to the five preset power modes that power up different
domains for typical application scenarios.
12.3 Features
The PMU has the following features:
• Supports four configurable PMU states. Software can flexibly configure them according to the needs.
– HP_ACTIVE
– HP_MODEM
– HP_SLEEP
– LP_SLEEP
• Supports five preset power modes that suit various typical usage scenarios:
– Active
– Modem-sleep
– Light-sleep0
– Light-sleep1
– Deep-sleep
• 16 KB SRAM
• Programmable retention DMA to backup and restore the status of the CPU and peripherals when the chip
switches between PMU states
• Supports a power controller that controls the power and clocks depending on the power modes
• Power scheme: The power scheme of ESP32-C6 includes power regulators, digital power domains,
analog power domains, etc.
• PMU controller: It is the core part of PMU that controls the power up and down of the power domains,
clocks, etc.
• Eight LP GPIO pins (GPIO0 ∼ GPIO7): These pins are always powered up and are not affected by any
low-power modes, which makes them suitable for working as wake-up sources when the chip is in
low-power modes. These pins can also work as regular GPIOs. For more information about the LP
GPIOs, please refer to Chapter 7 IO MUX and GPIO Matrix (GPIO, IO MUX).
• 16 KB SRAM: The 16 KB SRAM is accessible to both HP CPU and LP CPU. It works under the HP CPU
clock when accessed by the HP CPU and under the LP CPU clock when accessed by the LP CPU.
• Brownout detector: It monitors the power of the supply voltage pins, ensuring stable chip operation and
preventing the SoC from potential malfunction if subject to glitches or under voltage.
The following sections provide a detailed description of the components mentioned above.
• Two regulators
12.4.1.1 Regulators
As shown in Figure 12-1, the analog part of ESP32-C6 contains two regulators that regulate the power supply
to different power domains. The two regulators are:
• One HP sys regulator, used for regulating the power supply to high-performance modules. It features
high drive strength, high power consumption, and regulated output power.
• One LP sys regulator, used for regulating the power supply to low-power modules. It also features
regulated output power.
ESP32-C6 has digital power domains as listed below. The HP sys regulator powers the HP system, and there is
an independent power switch between the regulator and each power domain, enabling up/down control of
the digital power domain. The LP sys regulator powers the LP system.
– CPU: It mainly includes the CPU and its supporting peripherals (such as TRACE).
– Internal SRAMx: It is divided into four sub-power domains, as shown in Figure 12-1, where each of
SRAM0/1/2 has an independent power switch, while SRAM3 is directly connected to the regulator
without a power switch.
– Modem Power: It mainly includes modules that control the operating of the wireless section.
– LP always-on: It mainly includes LP always-on peripherals (e.g., RTC timer), PMU controller. This
power domain keeps powered on all the time.
As Figure 12-1 shows, ESP32-C6 contains the following analog power domains, among which PLL belongs to
the HP system while the other domains belong to the HP system:
• Fast RC Oscillator
• PLL
• RF circuit
12.4.2 PMU
The PMU of ESP32-C6 controls power consumption-related components of each power domain, such as
power and clock. PMU consists of the following major parts:
• PMU main state machine: It records and switches the PMU states.
• Sleep/wake-up controller: It sends sleep or wake-up requests to the PMU main state machine.
• Power controllers: They control the power and clock signals depending on the power modes of the
chip. The power controllers include:
– Analog power controller: It enables the analog modules, such as the regulators, analog clocks, etc.
– Clock controller: It manages the clock gating of peripherals and selects analog clock sources for
digital clocks.
– Data backup controller: It controls the data backup and restore process when the chip switches
between PMU states.
The PMU workflow involves the sleep/wake-up controller sending sleep or wake-up requests to the PMU main
state machine, which then generates power gating, clock gating, and reset signals. The power controllers and
clock controller will then power up or down different power domains and clocks based on the signals
generated by the PMU main state machine, allowing the chip to enter or exit different low-power modes. The
PMU workflow is shown in Figure 12-2.
POWER_DOWN
HP_ACTIVE HP_MODEM
cfg
cfg
HP_SLEEP
cfg
cfg
modem_wakeup_req
soc_wakeup_req
LP_SLEEP wakeup controller
lp_sys_busy
The PMU main state machine can receive sleep and wake-up signals, change the state of power and clock
through the power controllers, thereby switching PMU states, and achieving a balance between performance
and power consumption of the chip.
The PMU main state machine supports four PMU states, each controlled by different sleep and wake-up
signals, supporting software customization of power and clocks. These four PMU states allow the software to
expand power modes for various application scenarios. The four PMU states are:
• HP_ACTIVE: PMU state where the circuits on the chip are powered up to a maximum, supporting the HP
system and LP system operation.
• HP_MODEM: PMU state where Modem (wireless MAC and baseband) can operate independently of the
CPU.
• HP_SLEEP: PMU state where the HP system is in sleep, supporting LP peripherals operation.
• LP_SLEEP: PMU state where HP system and LP peripherals are in sleep, while the always-on circuits
remain operational.
Note:
The division of HP and LP system is as follows:
• HP system: This includes all peripherals (including Modem) except those belonging to LP system.
For more details, please refer to ESP32-C6 Datasheet > Functional Block Diagram.
HP_ACTIVE, HP_MODEM, HP_SLEEP are the states of the HP system, while LP_SLEEP is the state of the LP
system.
• If a module belongs to the HP system, its power up/down can be configured in the
HP_ACTIVE/HP_MODEM/HP_SLEEP states, but not in the LP_SLEEP state. It will reuse the HP_SLEEP
state in the LP_SLEEP state.
• If a module belongs to the LP system, its power up/down can be configured in the LP_SLEEP state and
will reuse the HP_SLEEP configuration in the HP_ACTIVE/HP_MODEM/HP_SLEEP states.
Take the HP CPU as an example. The HP CPU belongs to the HP system, so it can be configured to power
up/down in the HP_ACTIVE/HP_MODEM/HP_SLEEP states through the following registers and reuse the
HP_SLEEP configuration in LP_SLEEP.
• HP_ACTIVE: PMU_HP_ACTIVE_PD_HP_CPU_PD_EN
• HP_MODEM: PMU_HP_MODEM_PD_HP_CPU_PD_EN
• HP_SLEEP: PMU_HP_SLEEP_PD_HP_CPU_PD_EN
Similarly, users can define other power domains’ power up and down in different PMU states. For specific
registers, please refer to Section 12.9.
Note:
In the following text, all such registers will be collectively referred to as PMU_n1_PD_POWERDOMAIN_PD_EN, where
n1 represents the four PMU states.
Once the configuration is done, PMU will use various controllers to make these configurations effective, as
described in the sections below.
The sleep/wake-up controller is responsible for initiating sleep and wake-up requests to the PMU main state
machine. ESP32-C6 supports multiple wake sources to wake the CPU from different power modes that can be
enabled through PMU_WAKEUP_ENA.
ESP32-C6 provides a hardware mechanism that can reject sleep, meaning if some peripherals are in an
uninterruptible working state and the CPU tries to sleep, the peripherals will send a wake-up signal to prevent
the CPU from sleeping, thus ensuring the peripherals work normally.
The wake-up sources in Table 12-2 can all be configured as events to reject sleep. Users can configure the
following registers to implement sleep rejection. The configuration values of PMU_SLEEP_REJECT_ENA and
PMU_SLP_REJECT_CAUSE_REG and the corresponding wake-up sources are the same as shown in Table
12-2.
The analog power controller controls the power up and down of the analog circuits (including voltage
regulators, high-speed clocks, and slow-speed clocks) in PMU states.
• XTAL_CLK: Configure PMU_HP_SLEEP_XPD_XTAL to 1 to enable XTAL_CLK when the chip switches PMU
state to HP_SLEEP.
Note: To avoid the instability in XTAL_CLK during startup, users have the option to configure
PMU_WAIT_XTAL_STABLE to delay the gate opening for XTAL_CLK. This delay ensures that the gate
opening is enabled after PMU_WAIT_XTAL_STABLE CLK_DYN_FAST_CLK cycles following the power-up
of XTAL_CLK.
• PLL_CLK: PMU can enable PLL_CLK in different PMU states by configuring PMU_n1_XPD_BBPLL to 1.
For example, configuring PMU_HP_ACTIVE_XPD_BBPLL to 1 will enable the PLL_CLK clock when the
chip is in HP_ACTIVE state.
Note:
– To avoid the instability in PLL_CLK during startup, users have the option to configure
PMU_WAIT_PLL_STABLE to delay the gate opening for PLL_CLK. This delay ensures that the gate
opening is enabled after PMU_WAIT_PLL_STABLE CLK_DYN_FAST_CLK cycles following the
power-up of PLL_CLK.
Slow-speed clocks operate with low power. The power up and down of the slow-speed clocks in HP_ACTIVE,
HP_MODEM, and HP_SLEEP states are controlled by PMU_HP_SLEEP_XPD_FOSC_CLK. In LP_SLEEP state, the
power up and down of the slow-speed clocks are controlled by PMU_LP_SLEEP_XPD_FOSC_CLK. For
example, PMU_LP_SLEEP_XPD_FOSC_CLK controls power up and down of RC_FAST_CLK clock in LP_SLEEP
state. The following slow-speed clocks can be configured in LP_SLEEP:
• RC_FAST_CLK
• XTAL32K_CLK
• RC32K_CLK
The digital power controller controls the power up and down of digital power domains in different PMU states.
Unlike the analog power controller, the digital power controller does not directly control the regulator but
instead controls the power switch connected to the regulator to power up and down the digital power
domains.
Among the digital power domains, the LP PD Peripherals domain can only be powered up and down during
the PMU state switch between HP_SLEEP and LP_SLEEP PMU, while the other power domains can be
powered up and down during the PMU states switch between HP_SLEEP, HP_ACTIVE, and HP_MODEM.
When the chip switches between PMU states, if the power configuration of a power domain in the current
PMU state does not match the power configuration it is about to switch to, then the power up-down process
will be activated. Take the power up-to-down process of the CPU power domain as an example. Configure
PMU_HP_MODEM_PD_HP_CPU_PD_EN to 1 or 0 to indicate that the CPU power domain is powered down or
up in the HP_MODEM state. PMU will perform the following configurations:
• Enable the digital isolation unit to ensure that the powered-down modules do not output unstable
voltage levels to the powered-up modules. When a power domain loses power, the output of this
module will be clamped to a fixed value.
• Enable reset. When the CPU power domain loses power, its global reset signal is set to a reset state,
which persists for a period after the CPU power domain is re-powered. This mechanism guarantees a
reset-to-release process for the CPU power domain during power-up, effectively mitigating any instability
caused by power up-down transitions.
The following will explain the power up and down of each digital power domain:
• Internal SRAMx
The power up and down of the Internal SRAMx domain is not controlled by a dedicated register. The
Internal SRAMx domain shares the PMU_n1_PD_TOP_PD_EN register with the Peripherals domain. If
PMU_PD_HP_MEMn_PD_MASK (n=0,1,2) is 0, both the Internal SRAMx and Peripherals power domains
are turned up or down simultaneously. If PMU_PD_HP_MEMn_PD_MASK is configured as 1, the Internal
SRAMx can remain powered up when the Peripherals domain is powered down.
• Modem Power
Modem Power is connected to the HP sys regulator through a power switch. The power up and down of
Modem Power in the HP_ACTIVE state is determined by PMU_HP_ACTIVE_PD_HP_AON_PD_EN. From
Figure 12-1, it can be seen that if any of the CPU, Modem, or Peripherals + ROM power domains needs to
be powered up, the Modem Power domain must also be powered up. Such a design meets functional
requirements.
• Peripherals + ROM/Modem/CPU:
Each of the three power domains can be powered up and down in different PMU states using the
PMU_n1_PD_n_PD_EN register (n=TOP/HP_WIFI/HP_CPU). “WIFI” in the register represents the Modem
Power domain.
When the Peripherals domain is powered down, the following features are configurable:
– Powering down the Peripherals domain may cause instability in GPIOs. This can be addressed by
maintaining the state of the GPIOs (excluding eight LP GPIOs) through PMU. For example,
configuring PMU_HP_SLEEP_HP_PAD_HOLD_ALL can keep GPIOs in the same state as before
Peripherals was powered down in HP_SLEEP.
– In HP_ACTIVE and HP_MODEM states, the Internal SRAMx domain can be powered down or put into
Deep-sleep mode. In Deep-sleep, the memory cannot be read or written to, but data can be
retained. Configure PMU_n1_HP_MEM_DSLP to enable Memory Deep-sleep mode.
• LP PD Peripherals
The LP PD Peripherals power domain remains powered up when the chip is in HP_ACTIVE and
HP_MODEM states. The power state of LP PD Peripherals is configurable only in HP_SLEEP and
LP_SLEEP states. The LP PD Peripherals power domain has an independent digital power switch, and its
power control is not dependent on the power state of other digital power domains.
The clock controller is mainly used to control high-performance system clocks and lp system clocks when the
chip switches between PMU states.
High-performance system clocks include HP_ROOT_CLK and high-performance system peripherals clocks.
When the chip switches between HP_ACTIVE, HP_MODEM, and HP_SLEEP states, PMU can switch, power
up/down, and divide the frequency of HP_ROOT_CLK, as well as power up/down high-performance system
peripherals clocks.
– Configure PMU_n1_SYS_CLK_SLP_SEL to 1 to indicate that when the chip enters the corresponding
PMU state, the clock source is controlled by PMU.
– Configure PMU_n1_DIG_SYS_CLK_SEL to select the clock source after the chip enters the
corresponding PMU state. For details, please refer to Chapter 8 Reset and Clock > Table 8-2.
– Configure PMU_n1_ICG_SLP_SEL to 1 so that the clock gating in the target state will be controlled
by PMU. Configure this register to 0 so that the clock gating is controlled by PCR registers.
– Configure PMU_n1_DIG_ICG_FUNC_EN to power up/down the function clock in the target PMU
state. For detailed configuration please see Table 12-3.
– Configure PMU_n1_DIG_ICG_APB_EN to power up/down the APB clock in the target PMU state. For
detailed configuration please see Table 12-4.
LP system clocks are mainly used in the low-power system and include the following four clocks:
• LP_SLOW_CLK
• LP_FAST_CLK
• LP_DYN_SLOW_CLK
• LP_DYN_FAST_CLK
The clock frequency of LP_DYN_FAST_CLK is controlled by hardware as follows, depending on the PMU state
(and cannot be changed by the user):
ESP32-C6 has a Retention DMA module that can transfer data between memory and peripherals when the
chip switches between PMU states, so that the data is backed up when the power domain is powered down
and restored when the power domain is powered up again.
Data transfer is implemented in the Peripherals power domain. PMU only generates relevant control signals. It
is important to note that the data transfer control registers are directional, as unlike other control registers,
these control behaviors are determined by both the original PMU state and the target PMU state.
Taking the HP_SLEEP target PMU state as an example, the control registers for transitioning from HP_ACTIVE to
HP_SLEEP and from HP_MODEM to HP_SLEEP are different. The possible PMU state switches are listed below,
collectively represented by n2 in the register names:
• HP_SLEEP2ACTIVE
• HP_SLEEP2MODEM
• HP_MODEM2ACTIVE
• HP_MODEM2SLEEP
• HP_ACTIVE2SLEEP
The following will introduce how PMU controls the Retention DMA:
• Enable data transfer: Configure PMU_n2_BACKUP_EN to 1 to enable data transfer when the
corresponding PMU state switch is performed.
After the data transfer is completed, the value of PMU_n1_BACKUP_ICG_FUNC_EN is determined by the
configuration of PMU_n1_DIG_ICG_FUNC_EN in the target PMU state.
• Select linked list pointer: Configure the lower two bits of PMU_n2_BACKUP_MODE to select the linked
list pointer, specifically:
– 0: PAU_LINK_ADDR_0
– 1: PAU_LINK_ADDR_1
– 2: PAU_LINK_ADDR_2
– 3: PAU_LINK_ADDR_3
The system controller controls some functional modules when the chip switches PMU states, to achieve
stable and low-power chip performance. Specifically, the system controller supports:
• Pausing the watchdog function: Configuring PMU_n1_DIG_PAUSE_WDT to 1 can disable the RTC
watchdog timer (RWDT) function when the chip switches to the corresponding target PMU state. Note
that if this register is configured to 0 in any sleep mode, the watchdog function is not disabled, and
RWDT will reset as the CPU does not feed the watchdog.
• Switching GPIO to sleep mode, where the configuration of the GPIO holds. Consider a GPIO pin working
in low-drive mode as an input and a wake-up pin. Setting PMU_n1_HP_PAD_HOLD_ALL to 1 can latch the
current configuration of the GPIO pin as the sleep configuration when the chip transitions to the
corresponding PMU state. For more information about GPIO’s hold function, please refer to Chapter 7 IO
MUX and GPIO Matrix (GPIO, IO MUX) > Section 7.9.
• Disabling UART wake-up function: Configuring PMU_n1_UART_WAKEUP_EN to 0 can disable the four
UART wake-up modes in the corresponding PMU state. For more information on UART wake-up modes,
please refer to Chapter 27 UART Controller (UART, LP_UART, UHCI).
• Pausing CPU: Setting PMU_n1_DIG_CPU_STALL to 1 can suspend the CPU in the corresponding PMU
state.
The RTC timer updates two groups of registers upon any new trigger.
• Register group 0 records the count value of the RTC timer under the current trigger, with the counting
unit being LP_SLOW_CLK.
– RTC_TIMER_MAIN_BUF0_HIGH
– RTC_TIMER_MAIN_BUF0_LOW
• Register group 1 records the count value of the RTC timer under the previous trigger.
– RTC_TIMER_MAIN_BUF1_HIGH
– RTC_TIMER_MAIN_BUF1_LOW
Each time there is a new trigger, the record from the previous trigger will be moved from register group 0 to
register group 1 (the record in register group 1 will be overwritten), and the record of the current trigger will be
stored in register group 0. Therefore, the RTC timer can record up to two trigger values simultaneously.
It is worth noting that any reset or sleep state other than the chip’s power-up reset will not stop or reset the
RTC timer. Additionally, the RTC timer can also be used as a wake-up source (see Table 12-2).
LP_ANA_BOD_MODE0_LP_INT_RAW indicates the output level of the brownout detector. This register is low
level by default and outputs a high level when the voltage of the detected pin drops below the predefined
threshold.
When a brownout signal is detected, the brownout detector can handle it in one of the following two modes
(Mode 1 is the default):
• Mode 0: Triggers an interrupt when the counter counts to the thresholds pre-defined in Int Comparer
(LP_ANA_BOD_MODE0_INTR_WAIT) and Rst Comparer (LP_ANA_BOD_MODE0_RESET_WAIT), then
resets the chip based on the configuration of bod_mode0_rst_sel
(LP_ANA_BOD_MODE0_RESET_SEL). This method can be enabled by setting the bod_mode0_en
(LP_ANA_BOD_MODE0_INTR_ENA) signal.
bod_mode0_int
bod_mode0_en Int
Comparer
Brown-out
Counter
Chip Reset
Rst
Brown-out bod_mode0_rst_sel System Reset
Comparer
Brown-out Detected
bod_mode0_rst_en
Detector
System Reset
1
0
&&
bod_mode1_rst_en 1
bod_mode1_sel
• bod_mode0_en: LP_ANA_BOD_MODE0_INTR_ENA
• bod_mode0_rst_en: LP_ANA_BOD_MODE0_RESET_ENA
– 0: chip reset
– 1: system reset
For more information regarding chip reset and system reset, please refer to Chapter 8 Reset and Clock.
• bod_mode1_rst_en: LP_ANA_BOD_MODE1_RESET_ENA
Power Domain
LP LP PD RF
Power Modes Peripherals Modem CPU RC_FAST_CLK XTAL_CLK PLL
always-on peripherals circuit
Active ON ON ON ON ON ON ON ON ON
Note:
1. For power consumption data, please refer to ESP32-C6 Datasheet > Section Current Consumption.
1. Set LP_AON_CORE0_STAT_VECTOR_SEL to 1 to start up the chip from the RTC fast memory.
2. Calculate CRC for the RTC fast memory and save the result in LP_AON_STORE7_REG.
5. When the CPU is powered up, it begins unpacking the ROM and performing initialization. Then,
recalculate the CRC code of the RTC fast memory. If it matches the result stored in
LP_AON_STORE7_REG, the CPU will jump to the entry address of the RTC fast memory.
The boot flow after the chip’s wake-up is shown in Figure 12-4.
The low-power management system can receive the following ETM tasks:
The low-power management system can generate the following ETM events:
12.8 Interrupts
ESP32-C6’s low-power management system can generate the following interrupt signals:
• PMU_INTR
• PMU_LP_INT
• LP_RTC_TIMER_INTR
• LP_RTC_TIMER_LP_INT
Among these interrupt signals, PMU_INTR and LP_RTC_TIMER_INTR are sent to the Interrupt Matrix, while
PMU_LP_INT and LP_RTC_TIMER_LP_INT are sent to the LP CPU.
The interrupt signals are generated by the internal interrupt sources of each module, specifically:
PMU_INTR:
• PMU_SW_INT: Triggered when LP CPU is used as a wake-up source and wakes up the chip to
HP_ACTIVE state.
PMU_LP_INT:
• PMU_ACTIVE_SWITCH_SLEEP_END_INT: Triggered when the PMU state has switched from HP_MODEM
to HP_ACTIVE.
• PMU_MODEM_SWITCH_SLEEP_END_INT: Triggered when the PMU state has switched from HP_MODEM
to HP_ACTIVE.
• PMU_SLEEP_SWITCH_MODEM_END_INT: Triggered when the PMU state has switched from HP_SLEEP
to HP_MODEM.
• PMU_SLEEP_SWITCH_ACTIVE_END_INT: Triggered when the PMU state has switched from HP_SLEEP to
HP_ACTIVE.
LP_RTC_TIMER_INTR:
• RTC_TIMER_MAIN_TIMER_INT: Triggered when the count value of the RTC timer reaches the target value
RTC_TIMER_MAIN_TIMER_TAR_LOW0 or RTC_TIMER_MAIN_TIMER_TAR_HIGH0.
• RTC_TIMER_MAIN_TIMER_OVERFLOW_INT: Triggered when the count value of the RTC timer reaches the
maximum value.
M AX = (RT C_T IM ER_M AIN _T IM ER_T AR_HIGH0 <<
32) + RT C_T IM ER_M AIN _T IM ER_T AR_LOW 0
• LP_ANA_BOD_MODE0_INT: Triggered when the brownout detector detects that the voltage is below the
threshold.
LP_RTC_TIMER_LP_INT:
• RTC_TIMER_MAIN_TIMER_LP_INT: Triggered when the count value of the RTC timer reaches the target
value RTC_TIMER_MAIN_TIMER_TAR_LOW1 or RTC_TIMER_MAIN_TIMER_TAR_HIGH1.
• RTC_TIMER_MAIN_TIMER_OVERFLOW_LP_INT: Triggered when the count value of the RTC timer reaches
the maximum value.
M AX = (RT C_T IM ER_M AIN _T IM ER_T AR_HIGH1 <<
32) + RT C_T IM ER_M AIN _T IM ER_T AR_LOW 1
• LP_ANA_BOD_MODE0_LP_INT: Triggered when the brownout detector detects that the voltage is below
the threshold.
Each interrupt source can be configured by a common set of registers that are described in Section Interrupt
Configuration Registers. The specific registers can be found in Section 12.9 Register Summary.
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.
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.
12.10 Registers
12.10.1 PMU Registers
The addresses in this section are relative to the PMU base address provided in Table 5-2 in Chapter 5 System
and Memory.
For how to program reserved fields, please refer to Section Programming Reserved Register Field.
PD EN
N
N
_E
_E
U_ D_
N
PD
_H AO EN
I_ LP
_E
CP P
P_ N_
I_
SP DS
PD P_ D_
PD
IF
D_ M_
E_ H P
_W
U_ d) TIV PD_ P_
VD E
HP
PM rve AC E_ _TO
E_ M
D_
IV HP_
se P_ TIV PD
P
(re _H AC E_
E_
CT E_
U P_ TIV
IV
_A IV
CT
HP CT
PM _H AC
_A
U_ P_A
)
d)
U P_
ed
HP
ve
PM _H
PM H
rv
U_
r
se
se
U
PM
PM
(re
(re
31 30 29 28 27 26 23 22 21 20 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EN
C_
UN
F
G_
IC
G_
_ DI
VE
I
CT
_A
HP
U_
PM
31 0
0xffffffff Reset
N
_E
PB
_A
CG
_I
IG
_D
VE
I
CT
_A
HP
U_
PM
31 0
0xffffffff Reset
AK D_ LL
P_ L
UA AD OL EL
EN
EU AL
_W OL A
CT E_ PA _S DT
E_ P H _S
HP CT E_H _P SE LL
RT _H D_
_A IV P_ AD _W
IV LP_ D_ LP
U_ P_A TIV DIG AU TA
PM _H AC E_ G_P U_S
U P_ TIV DI P
PM _H AC E_ G_C
U P_ TIV DI
PM _H AC E_
U P_ TIV
PM _H AC
PM ed)
)
U P_
ed
PM _H
rv
rv
se
se
U
(re
(re
31 30 29 28 27 26 25 24 23 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LL
BP
_B
PD
_X
I VE
CT
_A
U_ d)
d)
HP
PM rve
ve
r
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
L
SE
L
E
SE
K_
OD
K_
OD
UP _EN
CL
_M
N
CL
_M
P_
_E
CK UP
UP
P_
KU
UP
BA K
CK
KU
E_ AC
AC
CK
BA
AC
IV _B
_B
BA
E_
_B
CT VE
VE
E_
IV
E
2A TI
TI
IV
IV
CT
EP AC
AC
CT
CT
2A
LE M2
2
2A
2A
M
EM
EP
EP
_S DE
E
OD
OD
LE
LE
HP O
U_ P_M
_M
_M
_S
_S
PM _H )
d)
U d
ed
ed
ed
HP
HP
HP
HP
PM rve
ve
rv
rv
rv
U_
U_
U_
U_
r
se
se
se
se
se
PM
PM
PM
PM
(re
(re
(re
(re
(re
31 30 29 28 26 25 23 22 20 19 18 17 16 15 14 13 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMU_HP_SLEEP2ACTIVE_BACKUP_MODE Configures the backup direction and link list when PMU
state switches switch from HP_SLEEP to HP_ACTIVE.
Highest bit:
0: From peripheral to memory
1: From memory to peripheral
Lower two bits:
0: PAU_LINK_ADDR_0
1: PAU_LINK_ADDR_1
2: PAU_LINK_ADDR_2
3: PAU_LINK_ADDR_3
(R/W)
EN
C_
FUN
G_
C
_I
UP
K
AC
_B
VE
TI
AC
HP_
U_
PM
31 0
0 Reset
EN
OC L
E_ _ _S SEL
K_
CL SE
S_ P_
_
LK
IC CL EL
SY SL
_C
G_ K_
IV YS P
YS
L
CT _ _S
_S
_A IV CG
IG
U_ P_A E_D
S
HP CT _I E
E
V
U_ P_A TIV
TI
AC
PM H C
d)
P_
ve
H
PM _H
U_
r
se
U
PM
PM
(re
31 30 29 28 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PD
_X
OR
AT
UL
EG
_R
HP
_
VE
TI
AC
)
P_
ed
ed
rv
U_
rv
se
se
PM
(re
re
31 19 18 17 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
)
P_
ed
H
rv
U_
se
PM
(re
31 30 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 0 Reset
_P _EN
EN
N
_E
D_
EN
PU PD
PD
HP ON N
_P P
D_ _A _E
PI SL
D_
_C _
I_
_S _D
_P HP D
F
M _ _P
I
_W
DD EM
U_ d) DE PD OP
HP
_V _M
PM rve MO EM D_T
D_
EM HP
se P_ D _P
_P
_
OD _
(re _H MO EM
M
E
_M E
U P_ D
OD
D
PM _H MO
HP O
_M
U_ P_M
)
d)
U P_
ed
HP
ve
PM _H
PM H
rv
U_
r
se
se
U
PM
PM
(re
(re
31 30 29 28 27 26 23 22 21 20 0
0 0 0 0 0 0 0 0 0 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
NC
FU
G_
IC
IG_
_D
EM
OD
M
H P_
U_
PM
31 0
0xffffffff Reset
N
_E
PB
_A
CG
I
IG_
_D
EM
OD
M
H P_
U_
PM
31 0
0xffffffff Reset
AK _ L
P_ L
AR D_ LD L
W LD L
EN
EU AL
_U PA HO _SE
T_ HO _A
OD M_ _P D_S DT
HP O M_ G_ SE LL
_M DE HP PA _W
EM LP_ AD_ LP
U_ _M DE DI PAU STA
PM _H MO EM IG_ U_
U P_ D D CP
PM _H MO EM IG_
U P_ D D
_
_
_
PM _H MO EM
U P_ D
PM _H MO
PM ed)
)
U P_
ed
P
PM _H
rv
rv
se
se
U
(re
(re
31 30 29 28 27 26 25 24 23 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
L
BPL
_B
PD
_X
EM
OD
_M
U_ d)
d)
HP
PM rve
rve
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
L
SE
E
K_
OD
N
CL
_M
E
P_
P_
UP
KU
KU
K
AC
AC
AC
_B
_B
_B
EM
EM
EM
OD
OD
OD
2M
M
P2
P2
EP
EE
EE
LE
SL
L
_S
_S
PM ed)
d)
d)
d)
d)
d)
P_
HP
HP
ve
ve
ve
ve
ve
H
rv
U_
U_
U_
r
r
se
se
se
se
se
se
PM
PM
(re
(re
(re
(re
(re
(re
31 30 29 28 23 22 20 19 16 15 14 13 6 5 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMU_HP_SLEEP2MODEM_BACKUP_MODE Configures the backup direction and link list when PMU
state switches switch from HP_SLEEP to HP_MODEM.
Highest bit:
0: From peripheral to memory
1: From memory to peripheral
Lower two bits:
0: PAU_LINK_ADDR_0
1: PAU_LINK_ADDR_1
2: PAU_LINK_ADDR_2
3: PAU_LINK_ADDR_3
(R/W)
EN
C_
UN
_F
CG
_I
UP
K
AC
_B
EM
OD
_M
HP
U_
PM
31 0
0 Reset
N
_E
LO EL
_I _C SE EL
CK
_C _S
_S
YS LP
LK
CG L L
_S K_S
_C
_
EM SYS LP
HP O M_ SYS
OD M_ G_S
U_ P_M DE IG_
_M DE IC
PM _H MO _D
EM
OD
M
d)
P_
P_
ve
H
PM _H
U_
r
se
U
U
PM
PM
(re
31 30 29 28 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PD
_X
OR
AT
UL
R EG
P_
_H
EM
OD
_M
d)
HP
ed
ed
ve
U_
r
rv
rv
se
se
se
PM
(re
re
re
31 19 18 17 16 15 0
0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
)
P_
ed
H
rv
U_
se
PM
(re
31 30 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 0 Reset
_P _EN
EN
N
_E
D_
EN
PU PD
PD
HP ON N
_P P
D_ _A _E
PI SL
D_
_C _
I_
_S _D
_P HP D
IF
U_ d) EP D_ P_P
_W
DD EM
HP
PM rve SLE P_P TO
_V M
se P_ E D_
D_
EP P_
LE _H
(re _H SLE P_P
_P
EP
_S EP
U P_ E
PM _H SLE
LE
HP LE
_S
U_ P_S
)
)
U P_
ed
ed
HP
PM _H
PM _H
rv
rv
se
se
U
U
PM
PM
(re
(re
31 30 29 28 27 26 23 22 21 20 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EN
C_
UN
_F
CG
_I
IG
_D
EP
LE
_S
HP
U_
PM
31 0
0xffffffff Reset
N
_E
PB
_A
CG
_I
DIG
P_
E
LE
_S
HP
U_
PM
31 0
0xffffffff Reset
AK _ L
P_ L
AR D_ LD L
W LD L
EN
EU AL
_U PA HO SE
T_ HO _A
LE _L PA SL T
HP LE _H PA E_ L
_S EP P_ D_ WD
U_ _S EP IG_ US AL
EP P_ D_ P_
PM _H SLE P_D _PA _ST
U P_ E IG U
P
PM _H SLE P_D _C
U P_ E IG
PM _H SLE P_D
U P_ E
PM _H SLE
PM ed)
d)
U P_
ve
PM _H
rv
r
se
se
U
(re
(re
31 30 29 28 27 26 25 24 23 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
L
B PL
_B
PD
X
P_
L EE
_S
U_ d)
d)
HP
PM rve
ve
r
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
EL
L
SE
_S
E
E
OD
K_
OD
LK
EN
M
KU N
CL
_C
_M
AC P_E
P_
P_
P_
UP
UP
KU
_B U
KU
CK
EP CK
CK
AC
AC
BA
LE BA
BA
_B
_B
_
2S EP_
EP
EP
P
EP
EE
LE
) EM LE
LE
SL
SL
2S
ed D S
2S
2
rv MO E2
E2
EM
E
E
se P_ TIV
IV
IV
OD
OD
CT
CT
(re _H AC
_M
_M
_A
_A
)
d)
U P_
ed
ed
HP
HP
HP
HP
ve
PM _H
rv
rv
U_
U_
U_
U_
r
se
se
se
U
PM
PM
PM
PM
PM
(re
(re
(re
31 30 29 28 26 25 23 22 20 19 18 17 16 15 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 Reset
PMU_HP_MODEM2SLEEP_BACKUP_MODE Configures the backup direction and link list when PMU
state switches switch from HP_MODEM to HP_SLEEP.
Highest bit:
0: From peripheral to memory
1: From memory to peripheral
Lower two bits:
0: PAU_LINK_ADDR_0
1: PAU_LINK_ADDR_1
2: PAU_LINK_ADDR_2
3: PAU_LINK_ADDR_3
(R/W)
PMU_HP_ACTIVE2SLEEP_BACKUP_MODE Configures the backup direction and link list when PMU
state switches from HP_MODEM to HP_ACTIVE. The configuration is the same as the register
above. (R/W)
EN
C_
UN
_F
CG
I
P_
KU
C
BA
P_
EE
SL
HP_
U_
PM
31 0
0 Reset
N
_E
LO EL
_I _C SE EL
CK
_C _S
_S
YS LP
LK
CG L L
_S K_S
_C
EP YS P_
YS
L E S SL
_S
_S EP G_
IG
HP LE IC
U_ P_S _D
_
_
P
U_ P_S EP
EE
PM H LE
SL
d)
P_
ve
H
PM _H
U_
r
se
U
PM
PM
(re
31 30 29 28 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PD
_X
OR
AT
UL
EG
_R
HP
P_
EE
L
_S
d)
HP
d
ve
ve
U_
r
se
r
se
PM
(re
re
31 19 18 17 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
)
P_
ed
H
rv
U_
se
PM
(re
31 30 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 0 Reset
P N
SL _E
_D PD
EM I_
M ER
P_ _P
_L LP
EP D_
LE _P
_S EP
HP LE
U_ P_S
d)
ve
PM _H
r
se
U
PM
(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
_X 2K K
PD C3 CL
2K
_X _R C_
L3
EP PD OS
TA
LE _X _F
_S EP PD
HP LE _X
U_ P_S EP
PM _H SLE
PM _H )
)
U P_
U d
ed
PM rve
rv
se
se
(re
(re
31 30 29 28 27 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
rv
U_
se
PM
(re
31 30 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 0 Reset
P N
SL _E
_D PD
EM I_
M ER
P_ _P
_L LP
EP D_
LE _P
_S EP
LP LE
U_ P_S
d)
ve
PM _L
r
se
U
PM
(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
_X 2K K
PD C3 CL
2K
_X _R C_
L3
EP PD OS
TA
LE _X _F
_S EP D
LP LE XP
U_ P_S EP_
PM _L SLE
PM _L )
d)
U P_
U d
PM rve
ver
se
se
(re
(re
31 30 29 28 27 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
K
K
AS
AS
AS
_M
M
K
K
_M
K
AS
AS
D_
AS
PD
PD
M
M
P
M
2_
2_
0_
0_
1_
1_
EM
EM
EM
EM
EM
EM
M
_M
_M
M
P_
P_
P_
P_
HP
HP
H
_H
_H
d)
D_
D_
D_
D_
PD
PD
ve
P
P
U_
U_
U_
U_
U_
U_
r
se
PM
PM
PM
PM
PM
PM
(re
31 27 26 22 21 17 16 15 14 10 9 5 4 0
0 0 0 0 0 0 0 0 Reset
PMU_PD_HP_MEM2_PD_MASK Configures whether the Internal SRAM2 domain follows the power
up/down state of the Peripherals domain.
0: Follows Peripherals domain
1: Does not follow Peripherals domain.
(R/W)
PMU_PD_HP_MEM1_PD_MASK Configures whether the Internal SRAM1 domain follows the power
up/down state of the Peripherals domain.
0: Follows Peripherals domain
1: Does not follow Peripherals domain.
(R/W)
PMU_PD_HP_MEM0_PD_MASK Configures whether the Internal SRAM0 domain follows the power
up/down state of the Peripherals domain.
0: Follows Peripherals domain
1: Does not follow Peripherals domain.
(R/W)
E
LE
BL
B
TA
TA
_S
_S
AL
L
PL
XT
T_
T_
AI
AI
W
W
U_
U_
M
PM
(P
31 16 15 0
)
ed
SL
rv
U_
se
PM
(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
PMU_SLEEP_REQ Configures whether to switch the chip’s PMU state to HP_SLEEP or LP_SLEEP.
0: Do not switch
1: Switch to HP_SLEEP or LP_SLEEP, depending on the state of the LP CPU.
(WT)
T_
E
EC
T_
EC
EJ
_R
EJ
EP
_R
LP
LE
S
S
U_
U_
PM
PM
31 30 0
0 0 Reset
PMU_SLEEP_REJECT_ENA Configures the sleep rejection source. For the mapping between values
and sources please refer to Table 12-2. (R/W)
NA
E
P_
EU
AK
W
U_
PM
31 0
0 Reset
PMU_WAKEUP_ENA Configures wake-up source. For the mapping between values and sources
please refer to Table 12-2. (R/W)
)
LP
ed
S
rv
U_
se
PM
(re
31 30 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
PMU_WAKEUP_CAUSE Indicates the wake-up source. For the mapping between values and
sources please refer to Table 12-2. (RO)
E
US
CA
T_
EC
R EJ
U_
PM
31 0
0 Reset
PMU_REJECT_CAUSE Indicates the wake-up rejection source. For the mapping between values
and sources please refer to Table 12-2. (RO)
AW
T_
_I W
U_ DIO _R RE _R
_R
A
PM _S INT EP_ INT
XC _R
NT
_E NT
U W_ LE P_
PM _S _S EU
PU _I
_C LE
U OC AK
PM _S _W
)
U OC
ed
PM _S
rv
se
U
PM
(re
31 30 29 28 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
ST
T_
IN
U_ DIO _S RE _ST
T_
T
_S
LP _ID T JEC
T
PM _S INT EP_ INT
NT
XC _S
_E NT
U W_ LE P_
_I
PM _S _S EU
PU _I
_C LE
U OC AK
PM _S _W
d)
U OC
ve
PM _S
r
se
U
PM
(re
31 30 29 28 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
NA
U_ DIO _E RE _EN
T_
_I A
_E
N
PM _S INT EP_ INT
NT
XC _E
_E NT
U W_ LE P_
PM _S _S EU
PU _I
_C LE
U OC AK
PM _S _W
)
U OC
ed
PM _S
rv
se
U
PM
(re
31 30 29 28 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
CL
T_
IN
LP _ID LR JEC LR
LR
T_
U_ DIO _C RE _C
_I R
_C
L
PM _S INT EP_ INT
XC _C
NT
_E NT
U W_ LE P_
PM _S _S EU
PU _I
_C LE
U OC AK
PM _S _W
d)
U OC
ve
PM _S
r
se
U
PM
(re
31 30 29 28 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_W ITC CT _ D_ RA AW
U LE SW IT SL VE RT T W
U_ OD SW CH SL _E AR T_R W
W
N W
LP EM ITC _M EE ND T_I AW
P_ TI ND INT AW
T_ _E NT AW
PM _S EP_ SW H_ CTI TA T_IN _RA
PM _M EP_ IT CH_ EEP _ST _IN _RA
PU SW _A EM EN NT_ _R
RA
AK H_ IVE EN INT W
W _ AW
PM _S DEM WI CH_ IVE STA T_I RA
_C _ H OD P_ _I NT
EU AC _E D_ _R
IN VE _I _R
T_
U O _S IT CT _ R T_
U LE _ TC A _S R T
RA ND _R
IN
PM _M IVE SW _A DEM STA _IN
U CT _ CH O P_ RT
PM _A DEM IT _M LEE TA
U LE SW IT SL AW
U O SW CH S _S
PM _M EP_ IT CH_ EEP
PM _S EP_ SW H_ T_R
U LE _ TC IN
PM _S DEM WI R_
U O _S GE
PM _M IVE RIG
U CT _T
PM _A SW
d)
U P_
ve
PM _H
r
se
U
PM
(re
31 30 29 28 27 26 25 24 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_W ITC CT _ D_ ST T
PM _S EP_ SW H_ CTI TA T_IN _ST
PM _M EP_ IT CH_ EEP _ST _IN _ST
PU SW _A EM EN NT_ _S
T
PM _S DEM WI CH_ IVE STA T_I ST
LP EM ITC _M EE ND T_I T
P_ TI ND INT T
T_ _E NT T
_S
U_ OD SW CH SL _E AR T_S
_C _ H OD P_ _I NT
_I T
EU AC _E D_ _S
IN VE _I _S
U O _S IT CT _ R T_
U LE _ TC A _S R T
U LE SW IT SL VE RT T
ST ND _S
NT
N
AK H_ IVE EN INT
PM _M IVE SW _A DEM STA _IN
U CT _ CH O P_ RT
PM _A DEM IT _M LEE TA
U O SW CH S _S
U LE SW IT SL T
PM _M EP_ IT CH_ EEP
PM _S EP_ SW H_ T_S
U LE _ TC IN
PM _S DEM WI R_
U O _S GE
PM _M IVE RIG
U CT _T
PM _A SW
d)
U P_
ve
PM _H
r
se
U
PM
(re
31 30 29 28 27 26 25 24 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_W ITC CT _ D_ EN NA
U LE SW IT SL VE RT T A
U_ OD SW CH SL _E AR T_E A
NA
U LE _ TC A _S R T A
LP EM ITC _M EE ND T_I NA
PM _S EP_ SW H_ CTI TA T_IN _EN
PM _M EP_ IT CH_ EEP _ST _IN _EN
P_ TI ND INT NA
EN ND _E A
PU SW _A EM EN NT_ _E
PM _S DEM WI CH_ IVE STA T_I EN
AK H_ IVE EN INT A
A _I NA
T_ _E NT N
_E
_C _ H OD P_ _I NT
EU AC _E D_ _E
IN VE _I _E
U O _S IT CT _ R T_
NT
N
PM _M IVE SW _A DEM STA _IN
U CT _ CH O P_ RT
PM _A DEM IT _M LEE TA
U LE SW IT SL NA
U O SW CH S _S
PM _M EP_ IT CH_ EEP
PM _S EP_ SW H_ T_E
U LE _ TC IN
PM _S DEM WI R_
U O _S GE
PM _M IVE RIG
U CT _T
PM _A SW
d)
U P_
ve
PM _H
r
se
U
PM
(re
31 30 29 28 27 26 25 24 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_W ITC CT _ D_ CL LR
U LE SW IT SL VE RT T R
U_ OD SW CH SL _E AR T_C R
R
PM _S DEM WI CH_ IVE STA T_I CLR
LP EM ITC _M EE ND T_I LR
PM _S EP_ SW H_ CTI TA T_IN _CL
PM _M EP_ IT CH_ EEP _ST _IN _CL
PU SW _A EM EN NT_ _C
P_ TI ND INT LR
T_ _E NT LR
CL
AK H_ IVE EN INT R
R D_ LR
_C _ H OD P_ _I NT
EU AC _E D_ _C
IN VE _I _C
T_
U O _S IT CT _ R T_
U LE _ TC A _S R T
CL N _C
N
IN
PM _M IVE SW _A DEM STA _IN
U CT _ CH O P_ RT
PM _A DEM IT _M LEE TA
U O SW CH S _S
U LE SW IT SL LR
PM _M EP_ IT CH_ EEP
PM _S EP_ SW H_ T_C
U LE _ TC IN
PM _S DEM WI R_
U O _S GE
PM _M IVE RIG
U CT _T
PM _A SW
d)
U P_
ve
PM _H
r
se
U
PM
(re
31 30 29 28 27 26 25 24 23 22 21 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
N
LL N _E
TA _E R
_S ET INT
N
LP ES S_
_E
_S _R AS
PU LP YP
_C _S _B
LP PU LP
U_ P_C _S
PM _L CPU
d)
U P_
ve
PM _L
r
se
U
PM
(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
PMU_LP_CPU_SLP_STALL_EN Configures whether to stall LP CPU when it goes into sleep mode.
0: Do not stall
1: Stall
(R/W)
PMU_LP_CPU_SLP_RESET_EN Configures whether to reset LP CPU when it goes into sleep mode.
0: Do not reset
1: Reset
(R/W)
E
P_
R
P_
EU
EE
AK
SL
W
U_
U_
CP
CP
)
P_
P_
ed
L
L
rv
U_
U_
se
PM
PM
(re
31 30 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMU_LP_CPU_WAKEUP_EN Configures the wake-up source for LP CPU. For details please refer to
Chapter 3 Low-Power CPU > Table 3-6 Wake Sources. (R/W)
ER LP
P
_H
GG _
RI ER
_T G
LP RIG
U_ P_T
)
ed
PM _H
rv
se
U
PM
(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
PMU_LP_TRIGGER_HP When LP CPU configures this register to 1, the chip is woken up. (WT)
PMU_HP_TRIGGER_LP When HP CPU configures this register to 1, LP CPU is woken up. (WT)
TE
DA
U_
)
ed
MP
rv
U_
se
PM
(re
31 30 0
0 0x2206250 Reset
For how to program reserved fields, please refer to Section Programming Reserved Register Field.
31 0
00000000 Reset
ET
ES
_R
W
_S
YS
PS
_H
d)
ve
ON
r
se
_A
(re
LP
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
ET
R_
ES
TO
_R
EC
W
_S
_V
AT
E0
ST
OR
ON ) 0_
_C
_A d E
LP rve OR
PU
se _C
_C
)
ed
_A d
(re ON
LP rve
rv
se
se
(re
re
31 30 29 28 27 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
LP_AON_CORE0_STAT_VECTOR_SEL Configures whether to start up the CPU from the RTC fast
memory.
0: Do not start up from the RTC fast memory.
1: Start up from the RTC fast memory.
(R/W)
For how to program reserved fields, please refer to Section Programming Reserved Register Field.
0
WO
_L
AR
_T
ER
M
TI
N_
AI
_M
ER
T IM
C_
RT
31 0
0x00000000 Reset
RTC_TIMER_MAIN_TIMER_TAR_LOW0 Configures the low 32 bits of the target count value 0 (48
bits total) of the RTC timer. (R/W)
H0
N0
IG
_H
_E
AR
AR
_T
_T
ER
ER
M
M
TI
TI
N_
N_
AI
AI
_M
_M
ER
ER
IM
IM
ed
T
T
rv
C_
C_
se
RT
RT
re
31 30 16 15 0
RTC_TIMER_MAIN_TIMER_TAR_HIGH0 Configures the high 16 bits of the target count value 0 (48
bits total) of the RTC timer. (R/W)
1
OW
_L
AR
_T
ER
M
TI
N_
AI
_M
ER
T IM
C_
RT
31 0
0x00000000 Reset
RTC_TIMER_MAIN_TIMER_TAR_LOW1 Configures the low 32 bits of the target count value 1 (48 bits
total) of the RTC timer. (R/W)
1
GH
N1
I
_H
_E
AR
AR
_T
_T
ER
ER
M
M
TI
TI
N_
N_
AI
AI
_M
_M
ER
ER
IM
M
ed
TI
T
rv
C_
C_
se
RT
RT
re
31 30 16 15 0
RTC_TIMER_MAIN_TIMER_TAR_HIGH1 Configures the high 16 bits of the target count value 1 (48
bits total) of the RTC timer. (R/W)
_O L
FF
AL AL
AT E SYS ST
XT T
PD TIM R_ _R
E R_ _S
_U IN_ E YS
ER A IM _S
M M _T R
TI R_ IN ME
C_ E MA TI
RT _TIM R_ IN_
C E MA
RT TIM R_
C_ E
RT _TIM
ed
rv
se
C
RT
re
31 30 29 28 27 0
RTC_TIMER_MAIN_TIMER_SYS_STALL Configures whether to trigger RTC timer when the CPU en-
ters or exits stall state.
0: Do not trigger
1: Trigger
(R/W)
31 0
0x00000000 Reset
RTC_TIMER_MAIN_BUF0_LOW Register group 0 records the count value of the RTC timer, bit0 to
bit31. (RO)
GHI
_H
F0
BU
N_
AI
_M
ER
IM
T
C_
RT
31 0
0x00000000 Reset
RTC_TIMER_MAIN_BUF0_HIGH Register group 0 records the count value of the RTC timer, bit32
to bit47, corresponding to bit[0:15]. (RO)
OW
_L
F1
BU
N_
AI
_M
ER
IM
T
C_
RT
31 0
0x00000000 Reset
RTC_TIMER_MAIN_BUF1_LOW Register group 1 records the count value of the RTC timer, bit0 to
bit31. (RO)
31 0
0x00000000 Reset
RTC_TIMER_MAIN_BUF1_HIGH Register group 1 records the count value of the RTC timer, bit32 to
bit47, corresponding to bit[0:15]. (RO)
AW
_R
NT
_I
W
LO
VE AW
RF
_O R
ER T_
M IN
TI R_
N_ E
AI TIM
_M IN_
ER A
M M
TI R_
C_ E
RT _TIM
d
rve
se
C
RT
re
31 30 29 0
ed
rv
se
C
RT
re
31 30 29 0
NA
_E
NT
_I
W
LO
VE A
_O EN
RF
ER T_
M IN
TI R_
N_ E
AI TIM
_M IN_
ER A
M M
TI R_
C_ E
RT _TIM
d
rve
se
C
RT
re
31 30 29 0
ed
rv
se
C
RT
re
31 30 29 0
AW
_R
NT
_I
OW
ER W
FL
OV A
P_ _R
_L INT
ER _
M LP
TI R_
N_ E
AI TIM
_M IN_
ER A
M M
TI R_
C_ E
RT _TIM
d
rve
se
C
RT
re
31 30 29 0
ed
rv
se
C
RT
re
31 30 29 0
NA
_E
NT
I
P_
_L
RF NA
W
VE _E
LO
_O INT
ER _
M LP
TI R_
N_ E
AI TIM
_M IN_
ER A
M M
TI R_
C_ E
RT _TIM
d
rve
se
C
RT
re
31 30 29 0
ed
rv
se
C
RT
re
31 30 29 0
For how to program reserved fields, please refer to Section Programming Reserved Register Field.
NA
_E
SH
T
SE NA
LA
OD 0_I SET NA
_C R_ EL
AI
T
_C A
AI
_W
_F
LR
LO _E
E0 NT _S
_M DE RE T_E
NT EN
_C RF
ET
R_
OD MO 0_ SE
E0 D_
ES
NT
_B D_ DE RE
OD 0_P
_R
I
NA O MO 0_
0_
E0
_A _B _ DE
_M DE
OD
OD
LP NA OD MO
OD MO
_M
_M
_A _B _
_B D_
LP NA OD
OD
OD
NA O
_A _B
_B
_B
_A _B
)
ed
LP NA
NA
NA
LP A
rv
N
se
_A
_A
_A
_A
(re
LP
LP
LP
LP
31 30 29 28 27 18 17 8 7 6 5 0
0 0 0 0 0x3ff 1 0 0 0 0 0 0 0 0 Reset
LP_ANA_BOD_MODE0_CNT_CLR Configures whether to clear the count value of the brownout de-
tector.
0: Do not clear
1: Clear
(R/W)
LP_ANA_BOD_MODE0_RESET_SEL Configures the reset type when the brownout detector is trig-
gered.
0: Chip reset
1: System reset
(R/W)
A
EN
T_
SE
RE
E1_
OD
_M
OD
_B
d)
ve
NA
r
se
_A
(re
LP
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
0xffffffff Reset
)
ed
NA
rv
se
_A
(re
LP
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
T
_S
NT
_I
E0
OD
M
OD_
_B
d)
ve
NA
r
se
_A
(re
LP
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
)
ed
NA
rv
se
_A
(re
LP
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
)
ed
NA
rv
se
_A
(re
LP
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
AW
_R
NT
I
P_
_L
E0
OD
_M
OD
_B
d)
ve
NA
r
se
_A
(re
LP
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
)
ed
NA
rv
se
_A
(re
LP
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
)
ed
NA
rv
se
_A
(re
LP
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
R
L
_C
NT
I
P_
_L
E0
OD
_M
OD
_B
d)
ve
NA
r
se
_A
(re
LP
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
E
AT
_D
EN
NA
_
A
LK
P_
_C
_L
NA
NA
_A
_A
LP
LP
31 30 0
0 0x2112110 Reset
13.1 Overview
ESP32-C6 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.
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 13-1.
13.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)
• Software configuring the reference count value. For example, the system timer is able to load back the
sleep time recorded by the RTC timer via software after Light-sleep
• Able to stall or continue running when CPU stalls or enters the on-chip-debugging mode
Software operation such as configuring registers is clocked by APB_CLK. For more information about
APB_CLK, see Chapter 8 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 8 Reset and Clock.
Figure 13-2 shows the procedure to generate alarm in 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 comparator.
13.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
SYSTIMER_CONF_REG:
• SYSTIMER_TIMER_UNITn_WORK_EN: set this bit to enable the counter UNITn in 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 the 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 initial count value are loaded from the 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 be changed
immediately. If UNITn is at work, the counter will continue to count up from the new reloaded value.
Writing 1 to SYSTIMER_TIMER_UNITn_UPDATE will trigger an update event. The lower 32 and higher 20 bits of
current count value will be locked into the 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 the register SYSTIMER_TARGETx_PERIOD. Assuming that
current count value is t1, when it reaches (t1 + δt), an alarm interrupt will be generated. When the count value
reaches (t1 + 2*δt), another alarm interrupt also 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 in
period mode, only one alarm interrupt is generated in target mode.
SYSTIMER_TARGETx_TIMER_UNIT_SEL is used to choose the count value from which timer counter to be
compared for alarm:
Finally, set SYSTIMER_TARGETx_WORK_EN and COMPx starts to compare the count value:
• In period mode, COMPx compares 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 +
n*alarm period δt (n = 1, 2, 3...) in period mode. But if the alarm value (t) set in registers is less than current
count value, i.e. the target has already passed, when the current count value is larger than the alarm value (t)
within a range (0 ~ 251 - 1), an alarm interrupt is also 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 13-3.
2. Software writes 1 to corresponding bits to start synchronization, see the second column in Table 13-3.
Synchronization is also needed for reading some status registers since the timer counter related status have a
different clock than APB_CLK. A complete synchronization action takes three steps:
13.4.5 Interrupt
Each comparator has one level-type alarm interrupt, named as SYSTIMER_TARGETx_INT. Interrupts signal is
asserted high when the comparator starts to alarm. Until the interrupt is cleared by software, 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 current count value, see Section 13.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 to SYSTIMER_TIMER_TARGETx_LO, and the higher 20 bits
to SYSTIMER_TIMER_TARGETx_HI.
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 timer interrupt. When Unitn counts to 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 is woken up from Light-sleep mode.
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 the system timer:
• Set SYSTIMER_TIMER_UNITn_LOAD to load new timer value into system timer. By such way, the
system timer is updated.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
13.7 Registers
The addresses in this section are relative to system timer base address provided in Table 5-2 in Chapter 5
System and Memory.
_T GE _W CO 0_ LL N
GE _W RK 1_ AL EN
LL EN
N
ER AR T0 1_ RE TA _E
_E
AR T1 O RE ST _
T2 OR _EN STA L_
IM _T E IT O 1_S LL
ST ER RG UN 1_C RE STA
ST ER M UN 0_ K N
SY IM _TI ER_ IT CO _EN
SY IM _TI ER_ IT OR _E
SY IM _TA R_ IT CO 0_
ST ER M UN 1_W RK
ST ER ME UN 0_ RE
EN
OR EN
SY IM _TI R_ IT WO
K_
_W K_
ST ER ME UN 0_
SY IM _TI ER_ IT
ST ER M UN
EN
SY IM _TI _EN
SY IM _TI R_
) M_
ST ER ME
ST ER LK
ed T
SY IM _C
rv _E
)
ST ER
se ER
ed
SY IM
(re IM
rv
se
ST
ST
(re
SY
SY
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
)
ST ER
ed
SY rve
SY IM
rv
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
D_
OA
_L
T0
NI
_U
ER
MI
_T
d)
ER
ve
M
r
I
se
ST
(re
SY
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
O
_L
AD
LO
0_
IT
N
_U
ER
IM
_T
ER
M
I
ST
SY
31 0
0 Reset
ER
ed
M
rv
I
se
ST
(re
SY
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LO
E_
A LU
_V
T0
NI
_U
ER
IM
_T
ER
I M
ST
SY
31 0
0 Reset
AD
LO
0_
IT
N
_U
ER
M
I
_T
)
ER
ed
M
rv
I
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
A LI
_V
AL E
_V AT
UE
T1 D
NI UP
_U T1_
ER NI
IM _U
_T ER
ER IM
IM _T
ST d)
d)
ST ER
SY rve
ve
SY IM
r
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
LO
1_
N IT
_U
ER
M
I
_T
)
ER
ed
M
rv
I
se
ST
(re
SY
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LO
D_
OA
_L
T1
NI
_U
ER
IM
_T
ER
M
I
ST
SY
31 0
0 Reset
HI
E_
LU
VA
1_
IT
N
_U
ER
MI
_T
)
ER
ed
M
rv
I
se
ST
(re
SY
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
AD
LO
1_
T
NI
_U
ER
MI
_T
d)
ER
ve
M
r
I
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
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)
I
_H
T0
GE
AR
_T
ER
M
I
_T
)
ER
ed
M
rv
I
se
ST
(re
SY
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
M EL
E
D_ _S
OD
IO NIT
ER _U
OD
_P ER
RI
T0 IM
E
_P
GE _T
AR T0
T0
_T GE
GE
ER AR
AR
IM _T
_T
)
ST ER
ER
ed
SY IM
IM
rv
se
ST
ST
(re
SY
SY
31 30 29 26 25 0
0 0 0 0 0 0 0x00000 Reset
D
OA
_L
P0
MO
_C
ER
MI
_T
d)
ER
ve
M
r
I
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I
_H
T1
GE
AR
_T
ER
I M
_T
)
ER
ed
M
rv
I
se
ST
(re
SY
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
O
_L
T1
GE
AR
_T
ER
M
I
_T
ER
IM
ST
SY
31 0
0 Reset
D
IO
_P R
T1 IME
ER
_P
GE _T
AR T1
T1
_T GE
GE
ER AR
AR
IM _T
_T
)
ST ER
ER
ed
SY IM
M
rv
I
se
ST
ST
(re
SY
SY
31 30 29 26 25 0
0 0 0 0 0 0 0x00000 Reset
SYSTIMER_TARGET1_PERIOD_MODE Selects the two alarm modes for COMP1. See details in SYS-
TIMER_TARGET0_PERIOD_MODE. (R/W)
D
OA
_L
P1
M
O
_C
ER
MI
_T
d)
ER
ve
M
r
I
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I
_H
T2
GE
AR
_T
ER
M
I
_T
)
ER
ed
M
rv
I
se
ST
(re
SY
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
M EL
E
D_ _S
OD
IO NIT
ER _U
D
IO
_P ER
ER
T2 IM
_P
GE _T
AR T2
T2
_T GE
GE
ER AR
AR
IM _T
_T
)
ST ER
ER
ed
SY IM
M
rv
I
se
ST
ST
(re
SY
SY
31 30 29 26 25 0
0 0 0 0 0 0 0x00000 Reset
SYSTIMER_TARGET2_PERIOD_MODE Configures Configures the two alarm modes for COMP2. See
details in SYSTIMER_TARGET0_PERIOD_MODE. (R/W)
D
OA
_L
P2
MO
_C
ER
MI
_T
)
ER
ed
M
rv
I
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T0 T_ A
NA
NT A
GE _IN EN
_I EN
_E
AR T1 T_
_T GE _IN
ER AR T2
IM _T E
ST ER RG
SY IM _TA
d)
ST ER
ve
SY IM
r
se
ST
(re
SY
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
T0 T_ W
AW
NT W
GE _IN RA
_I RA
_R
AR T1 T_
_T GE _IN
ER AR T2
IM _T E
ST ER RG
SY IM _TA
)
ST ER
ed
SY IM
rv
se
ST
(re
SY
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
T0 T_ R
LR
NT R
GE _IN CL
_I CL
_C
AR T1 T_
_T GE _IN
ER AR T2
IM _T E
ST ER RG
SY IM _TA
d)
ST ER
ve
SY IM
r
se
ST
(re
SY
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
GE _IN ST
T
_I ST
_S
AR T1 T_
T0 T_
NT
_T GE _IN
ER AR T2
IM _T E
ST ER RG
SY IM _TA
)
ST ER
ed
SY IM
rv
se
ST
(re
SY
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)
O
_R
I
_H
T0
GE
AR
_T
)
ER
ed
M
rv
I
se
ST
(re
SY
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)
OR
O_
_L
T1
GE
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)
ER
ed
M
rv
I
se
ST
(re
SY
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)
O
_R
LO
_
T2
GE
AR
_T
ER
M
I
ST
SY
31 0
0 Reset
SYSTIMER_TARGET2_LO_RO Represents the actual target value of COMP2, low 32 bits. (RO)
RO
I_
_H
T2
GE
AR
_T
)
ER
ed
M
rv
I
se
ST
(re
31 20 19 SY 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
14.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 14-1, the ESP32-C6 chip
contains two timer groups, namely timer group 0 and timer group 1. 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 15 Watchdog Timers (WDT). Therefore, the term ”timer” within this
chapter refers to the general-purpose timer.
14.2 Features
The timer’s features are summarized as follows:
Figure 14-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, PLL_F80M_CLK is selected and when the field is 2, RC_FAST_CLK is selected.
TIMG_T0_DIVIDER field can be configured as 0 ~ 65535 for a divisor range of 2 ~ 65536. To be more specific,
when TIMG_T0_DIVIDER is configured as:
• 1: the divisor is 2
To modify the 16-bit prescaler, please first configure the TIMG_T0_DIVIDER field, and then set
TIMG_T0_DIVCNT_RST to 1. Meanwhile, the timer must be disabled (i.e. TIMG_T0_EN should be cleared).
Otherwise, the result can be unpredictable.
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 TIMG_T0UPDATE_REG, the
current value of the 54-bit timer starts to be latched into the TIMG_T0LO_REG and TIMG_T0HI_REG registers
containing the lower 32-bits and higher 22-bits, respectively. When TIMG_T0UPDATE_REG is cleared by
hardware, it indicates the latch operation has been completed and current timer value can be read from the
TIMG_T0LO_REG and TIMG_T0HI_REG registers. TIMG_T0LO_REG and TIMG_T0HI_REG registers will remain
unchanged for the CPU to read in its own time until TIMG_T0UPDATE_REG is written to again.
The 54-bit alarm value is configured using TIMG_T0ALARMLO_REG and TIMG_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 TIMG_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 14-1 and Table 14-2 show the relationship between 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:
When an alarm occurs, the TIMG_T0_ALARM_EN field is automatically cleared and no alarm will occur again
until the TIMG_T0_ALARM_EN is set next time.
A software instant reload is triggered by the CPU writing any value to TIMG_T0LOAD_REG, which causes the
timer’s current value to be instantly reloaded. If TIMG_T0_EN is set, the timer will continue incrementing or
decrementing from the new value. In this case if TIMG_T0_ALARM_EN is set, the timer will still trigger alarms
in scenarios listed in Table 14-1 and 14-2. If TIMG_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 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 TIMG_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.
Note:
The above two ETM tasks have the same function as the APB configuration TIMG_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 TIMG_T0_EN: When triggered, it will enable or disable the time-base counter.
Note:
Alarm generation can also be configured through APB method 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 TIMG_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
TIMG_T0LO_REG and TIMG_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 TIMG_T0_LOAD_LO and TIMG_T0_LOAD_HI.
All the ETM tasks and events will not take effect until the TIMG_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 14.4.4 Timer as Periodic Alarm by ETM.
1. Start periodic or one-shot frequency calculation (see Section 14.4.5 for details);
2. Once receiving the signal to start 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
14.3.7 Interrupts
Each timer has its own interrupt line that can be routed to the CPU, and thus each timer group has a total of
two interrupt lines. Timers generate level interrupts that must be explicitly cleared by the CPU on each
triggering.
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 TIMG_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:
• TIMG_T0_INT_RAW : An alarm event sets it to 1. The bit will remain set until the timer’s corresponding bit
in TIMG_T0_INT_CLR is written.
• TIMG_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 TIMG_WDT_INT_CLR is written.
• TIMG_T0_INT_ST : Reflects the status of each timer’s interrupt and is generated by masking the bits of
TIMG_T0_INT_RAW with TIMG_T0_INT_ENA.
• TIMG_WDT_INT_ST : Reflects the status of each watchdog timer’s interrupt and is generated by masking
the bits of TIMG_WDT_INT_RAW with TIMG_WDT_INT_ENA.
• TIMG_T0_INT_ENA : Used to enable or mask the interrupt status bits of timers within the group.
• TIMG_WDT_INT_ENA : Used to enable or mask the interrupt status bits of watchdog timer within the
group.
• TIMG_T0_INT_CLR : Used to clear a timer’s interrupt by setting its corresponding bit to 1. The timer’s
corresponding bit in TIMG_T0_INT_RAW and TIMG_T0_INT_ST will be cleared as a result. Note that a
timer’s interrupt must be cleared before the next interrupt occurs.
• TIMG_WDT_INT_CLR : Used to clear a timer’s interrupt by setting its corresponding bit to 1. The
watchdog timer’s corresponding bit in TIMG_WDT_INT_RAW and TIMG_WDT_INT_ST will be cleared as a
result. Note that a watchdog timer’s interrupt must be cleared before the next interrupt occurs.
• Set the timer’s starting value by writing the starting value to TIMG_T0_LOAD_LO and
TIMG_T0_LOAD_HI, then reloading it into the timer by writing any value to TIMG_T0LOAD_REG.
3. Enable auto reload by setting TIMG_T0_AUTORELOAD and configure the reload value via
TIMG_T0_LOAD_LO and TIMG_T0_LOAD_HI.
• If the next alarm requires a new alarm value and reload value (i.e. different alarm interval per
iteration), then TIMG_T0ALARMLO_REG, TIMG_T0ALARMHI_REG, TIMG_T0_LOAD_LO, and
TIMG_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)
• 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 TIMG_T0_AUTORELOAD is 1, the current counter value is overwritten by the reloaded value. The
alarm generation will be reopen by TIMERn_TASK_ALARM_START_TIMER0 (n:0-1).
• Disable the ETM channels used to map timer group’s event and task
• Set TIMER_ETM_EN to 0.
• Select the clock whose frequency is to be calculated (clock source of RTC_SLOW_CLK) via
TIMG_RTC_CALI_CLK_SEL, and configure the time of calculation via TIMG_RTC_CALI_MAX.
• Select the clock whose frequency is to be calculated (clock source of RTC_SLOW_CLK) via
TIMG_RTC_CALI_CLK_SEL, and configure the time of calculation via TIMG_RTC_CALI_MAX.
3. Timeout
If the counter of RTC_SLOW_CLK cannot finish counting in TIMG_RTC_CALI_TIMEOUT_RST_CNT cycles,
TIMG_RTC_CALI_TIMEOUT will be set to indicate a timeout.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
14.6 Registers
The addresses in this section are relative to Timer Group base address provided in Table 5-2 in Chapter 5
System and Memory.
T
OA
RS
N
OR E
_E
EL
UT AS
T_
ER
RM
G_ ) N
_A RE
ID
M d C
LA
T0 C
IV
TI rve DIV
TI T N
G_ IN
_D
_A
G_ E
d)
M 0_
M 0_
se 0_
T0
T0
ve
TI _T
(re _T
G_
r
se
G
G
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)
LO
T 0_
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
)
_
ed
T0
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
T0
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
O
_L
RM
LA
_A
T0
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
RM
LA
_A
)
ed
T0
rv
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)
HI
D_
OA
_L
)
ed
T0
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)
D
OA
_L
T0
G_
M
TI
31 0
0x000000 Reset
TIMG_T0_LOAD Write any value to trigger a timer 0 time-base counter reload. (WT)
RE T_ N
TH
TH
U_ ESE D_E
SE EN
EN
EN
NG
NG
T_
CP _R O
E_
LE
PP PU _M
LE
AT
T_
T_
_A C OT
PD
SE
SE
DT O O
_U
RE
W PR HB
RE
) NF
_
0
G3
G_ T_ S
1
PU
TG
TG
TG
YS
M D LA
ed O
G_ _EN
ST
rv _C
_C
_S
_S
_S
_S
TI _W T_F
_
DT
DT
DT
DT
DT
se DT
DT
DT
d)
M D
ve
W
(re _W
TI W
G_
G_
G_
G_
G_
G_
G_
r
se
G
G
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)
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
disabled.
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)
E
AL
ST
SC
_R
E
PR
NT
K_
VC
L
I
_D
_C
DT
DT
d)
ve
W
W
G_
G_
r
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 protec-
tion 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)
D
HOL
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)
D
OL
2 _H
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)
ED
_FE
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)
NG
LI
YC
L
_C
SE
T
RT
CA LK_
AR
AX
AL Y
TA
D
ST
C
C_ _R
_S
I_
I_
I_
LI
LI
L
L
CA
CA
G_ _CA
C
C_
C_
C_
C
)
ed
RT
RT
RT
RT
RT
rv
G_
G_
G_
G_
se
M
(re
TI
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
LD
_V
A
AT
_D
NG
E
LI
LU
YC
VA
_C
I_
LI
L
CA
CA
C_
C_
d)
RT
RT
ve
G_
G_
r
se
M
M
(re
TI
TI
31 7 6 1 0
0x00000 0 0 0 0 0 0 0 Reset
T
N
S
_C
RE
ST
TH
R
T_
T_
T
U
U
EO
EO
EO
IM
IM
IM
I_T
I_T
I_T
L
L
CA
CA
CA
C_
C_
C_
)
ed
RT
RT
RT
rv
G_
G_
G_
se
M
M
(re
TI
TI
31 7 6 3 2 1 TI
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)
_E A
NT EN
NA
_I T_
T0 IN
G_ T_
)
ed
M D
TI _W
rv
se
G
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
_R W
AW
NT RA
_I T_
T0 IN
G_ T_
)
ed
M D
TI _W
rv
se
G
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)
NT ST
T
_I T_
_S
T0 IN
G_ T_
)
ed
M D
TI _W
rv
se
G
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)
_C R
NT CL
LR
_I T_
T0 IN
G_ T_
)
ed
M D
TI _W
rv
se
G
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
E
AT
_D
GS
M
)
TI
ed
N
rv
G_
se
M
(re
TI
31 28 27 0
0 0 0 0 0x2206072 Reset
CT IVE
E
N _A CT
IV
_E IS A
M K_ IS_
ET CL K_
G_ T_ L
M D C
M IM N
TI W R_
TI _T _E
G_ E
)
G K
ed
M L
TI _C
rv
se
G
M
(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
15.1 Overview
Watchdog timers are hardware timers used to detect and recover from malfunctions. They must be
periodically fed (reset) to prevent a timeout. A system/software that is behaving unexpectedly (e.g. is stuck in
a software loop or in overdue events) will fail to feed the watchdog thus trigger a watchdog timeout.
Therefore, watchdog timers are useful for detecting and handling erroneous system/software behavior.
As shown in Figure 15-1, ESP32-C6 contains three digital watchdog timers: one in each of the two timer
groups in Chapter 14 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 15.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 MWDT in timer group 0 are enabled automatically in order to
detect and recover from booting errors.
ESP32-C6 also has one analog watchdog timer: Super watchdog (SWD). It is an ultra-low-power circuit in
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’s, MWDT register
descriptions are detailed in Chapter 14 Timer Group (TIMG), and the RWDT and SWD register descriptions are
detailed in Section 15.5 Register Summary.
• 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
Figure 15-2 shows the three watchdog timers in ESP32-C6 digital systems.
• MWDT0 can select between the PLL_F80M_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 MWDT is configured via the TIMG_WDT_CLK_PRESCALE field of
TIMG_WDTCONFIG1_REG. When TIMG_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 8 Reset
and Clock).
MWDT and RWDT are enabled by setting the TIMG_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 TIMG_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 action.
When one stage times out, the timeout action is triggered, the counter value is reset to zero, and the next
stage becomes active.
MWDT/RWDT provide four stages (called stages 0 to 3). The watchdog timers will progress through each
stage in a loop (i.e. from stage 0 to 3, then back to stage 0).
Timeout values of each stage for MWDT are configured in TIMG_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 (Thold₀) 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 Thold₀ 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 TIMG_WDTCONFIG0_REG. Likewise for RWDT, the
timeout action is configured in LP_WDT_RWDT_CONFIG0_REG.
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 prevent 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 (TIMG_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, TIMG_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.
15.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
15.3.2.1 Structure
15.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:
15.4 Interrupts
For watchdog timer interrupts, please refer to Section 14.3.7 Interrupts in Chapter 14 Timer Group
(TIMG).
The abbreviations given in Column Access are explained in Section Access Types for Registers.
15.6 Registers
MWDT registers are part of the timer submodule and are described in Section 14.5 Register Summary in
Chapter 14 Timer Group (TIMG).
The addresses of RWDT and SWD registers in this section are relative to LP_WDT base address provided in
Table 5-2 in Chapter 5 System and Memory.
T_ N
TH
SE _E
EN
GT
NG
RE OD
EN
LE
LP
U_ M
_L
T_
T_
S
ET
N_
OC OO
SE
ES
_I
RE
PR B
P
SE
H
R
U_
0
S_
_W d T_ AS
1
AU
TG
TG
TG
TG
N
LP rve WD FL
_C
_P
_S
_S
_S
_S
S
_E
T_
se R T_
DT
DT
DT
DT
DT
DT
DT
D
(re DT WD
W
W
)
)
_R
_R
_R
_R
_R
_R
_R
_W _R
_R
ed
_
DT
DT
DT
DT
DT
DT
DT
LP DT
DT
rv
_W
_W
_W
_W
_W
_W
_W
_W
se
(re
LP
LP
LP
LP
LP
LP
LP
LP
31 30 28 27 25 24 22 21 19 18 16 15 13 12 11 10 9 8 0
LP_WDT_RWDT_PAUSE_IN_SLP Configure whether or not pause RWDT when chip is in sleep mode.
0: Enable
1: Disable
(R/W)
31 0
200000 Reset
LD
HO
1_
TG
_S
DT
W
_R
DT
_W
LP
31 0
80000 Reset
D
OL
2_H
TG
_S
DT
W
_R
DT
_W
LP
31 0
0x000fff Reset
31 0
0x000fff Reset
D
EE
_F
DT
_W
TC
_R
DT
W
d)
_R
ve
DT
r
_W
se
(re
LP
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
EN
EE LR
TH
D_
_F _C
AG
ID
_W
TO AG
L
_F
E
AU FL
AL
BL
ET
D_ ED
D_ T_
GN
SA
ES
W RS
W FE
DI
SI
R
_S _
D_
_S _
D_
DT WD
DT WD
W
W
d)
_W _S
_S
_W _S
_S
ve
LP DT
DT
LP DT
DT
r
_W
_W
_W
_W
se
(re
LP
LP
LP
LP
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 Confgure the SWD signal length that output to analog circuit.
Measurement unit: LP_DYN_FAST_CLK (R/W)
Y
KE
W
D_
W
_S
DT
_W
LP
31 0
0x000000 Reset
)
_W _R
ed
LP DT
rv
_W
se
(re
LP
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
IN ST
ST
D_ T_
T_
W IN
_S T_
DT WD
d)
_W _R
ve
LP DT
r
_W
se
(re
LP
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)
)
_W _R
ed
LP DT
rv
_W
se
(re
LP
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_ENA Configure whether or not to enable the SWD to send timeout interrupt.
0: Disable
1: Enable
(R/W)
LP_WDT_RWDT_INT_ENA Configure whether or not to enable the RWDT to send timeout interrupt.
0: Disable
1: Enable
(R/W)
T_ R
R
IN CL
CL
D_ T_
W IN
_S T_
DT WD
d)
_W _R
ve
LP DT
r
_W
se
(re
LP
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_RWDT_INT_CLR Configure whether to clear the timeout interrupt signal sent by RWDT to
CPU.
0: No
1: Yes
(WT)
E
LK
AT
_D
_C
DT
DT
_W
_W
LP
LP
31 30 0
0 0x2112080 Reset
16.1 Overview
The permission management of ESP32-C6 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 the table 16-1. The first column lists the masters and the
first row lists the slaves. For the CPU, the permission management relation between PMP and APM is shown in
Figure 16-1.
For example, to access the ROM, the master HP CPU needs the permission from PMP; and to access the
LP_MEM, the master HP CPU needs permission from PMP and APM. It is worth noting that HP CPU passes the
PMP permission management first and then the APM. If the PMP check fails, the APM permission
management will not be triggered.
For HP CPU, PMP manages the access permission of all address spaces, but APM can’t manage HP CPU’s
access to HP_MEM and ROM.
CPU
PMP
APM
PMP related registers are located inside HP CPU and can be read or configured by special instructions. For
how to configure PMP, please refer to chapter High-Performance CPU > Physical Memory Protection.
APM module contains two parts: TEE (Trusted Execution Environment) controller and 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-C6
(such as DMA, which can access memory as a master). There are four types of security mode: TEE,
REE0 (Rich Execution Environment), REE1, 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 the table 18-5 in Chapter 18 Debug Assistant (ASSIST_DEBUG)), security mode, access address,
access permissions, etc, APM 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-C6 can precisely control the access permission of all masters to memory
and peripheral registers.
16.2 Features
ESP32-C6’s TEE controller has the following features:
• Interrupt function
For the HP CPU to access memory or peripheral registers, first select the machine mode or user mode of the
HP 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 HP CPU is in machine mode, its security mode is TEE mode.
• When the HP 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 set TEE_M0_MODE to 1,2 or 3, which is in REE mode, it security mode is REE0, REE1 and REE2
respectively.
For the LP CPU’s access to memories or peripheral registers, security mode can be set by configuring the
LP_TEE_M0_MODE of LP_TEE_M0_MODE_CTRL_REG register.
As for other masters, security mode can be set by configuring the TEE_Mn_MODE of TEE registers. n here
equals to the ID number of master in table 18-5.
16.3.2.1 Architecture
Figure 16-2 shows the access path managed by the APM controller.
LP_APM0_CTRL
TEE_REG LP_TEE_REG
TEE_M0_MODE_CTRL_REG TEE_Mx_MODE_CTRL_REG LP_APM_CTRL
LP_TEE_M0_MODE_CTRL_REG
BUS Matrix
HP_CPU access to
memory is managed
through the PMP M2
M1 M0 M3
Manage LP_CPU
access to memory
M0
M1 LP_SYS M0
Note:
For the difference between Low speed mode and High speed mode in the figure, please refer to System and Memory.
As shown in the Figure 16-2, APM controller contains 3 functional modules: HP_APM_CTRL�LP_APM0_CTRL
and LP_APM_CTRL, configured by the register modules HP_APM_REG, LP_APM0_REG and LP_APM_REG
respectively.
• HP_APM_CTRL manages 4 access paths, namely M0-M3 in the figure 16-2. Permission management of
each path can be enabled by configuring HP_APM_FUNC_CTRL_REG (enabled by default).
• LP_APM0_CTRL manages one access path, namely M0 in the figure 16-2. Permission management of
this path can be enabled by configuring LP_APM0 _FUNC_CTRL_REG (enabled by default).
• LP_APM_CTRL manages 2 access paths, namely M0 and M1 in the figure 16-2. Permission management
of each path can be enabled by configuring LP_APM _FUNC_CTRL_REG (enabled by default).
The table 16-2 below shows the detailed information of each functional module:
Register Mod- Functional Access Enable Permission Configurable Enable Address Ranges
ules Modules Path No. Management Address
Ranges No.
HP_APM_REG HP_APM_CTRL 4 HP_APM_ 16 HP_APM_REGION_FILTER_
FUNC_CTRL_REG EN_REG
LP_APM0_REG LP_APM0_CTRL 1 LP_APM0 4 LP_APM0_REGION_FILTER_
_FUNC_CTRL_REG EN_REG
LP_APM_REG LP_APM_CTRL 2 LP_APM 4 LP_APM_REGION_FILTER_
_FUNC_CTRL_REG EN_REG
• HP_APM_REG register module can configure up to 16 groups of address ranges for functional mudule
HP_APM_CTRL. The start and end address for each region (address range) can be configured by setting
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 region n. The first group of address ranges is enabled
by default.
• LP_APM0_REG register module can configure up to 4 groups of address ranges for functional mudule
LP_APM0_CTRL. The start and end address for each region can be configured by setting
LP_APM0_REGIONn_ADDR_START and LP_APM0_REGIONn_ADDR_END. Configure the bit n of
LP_APM0_REGION_FILTER_EN_REG to enable region n. The first group of address ranges is enabled by
default.
• LP_APM_REG register module can configure up to 4 groups of address ranges for functional mudule
LP_APM_CTRL. The start and end address for region n can be configured by setting
LP_APM_REGIONn_ADDR_START and LP_APM_REGIONn_ADDR_END. Configure the bit n of
LP_APM_REGION_FILTER_EN_REG to enable region n. The first group of address ranges 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.
Within each address range, 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, LP_APM_REGIONn_ATTR_REG or LP_APM0_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 M0-M3 shown in figure
16-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 M0-M1 shown in
figure 16-2 should follow the address ranges and access permissions of each address range configured in the
register module LP_APM_REG.
For the access path HP_APM M1, all masters except HP CPU and LP CPU access HP_MEM through this data
access path. Suppose that HP_APM_M1_FUNC_EN is enabled and a master in REE1 mode needs to access
HP_MEM through HP_APM M1. The whole process is as follows:
1. HP_APM M1 will first determine whether the address requested to access is within the 16 address ranges
configured in the HP_APM_REG register module. If 16 groups of address ranges are partially enabled,
HP_APM M1 will only determine whether the address requested to access is within the enabled address
ranges.
2. Assuming that the address requested to access is within second group of configured address ranges,
then determine whether the address range of this group is enabled, that is, whether bit 1 of
HP_APM_REGION_FILTER_EN is 1.
3. If the address range is enabled, judge whether the master has read permission for the second group of
address ranges in REE1 mode, 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 it will return 0.
When the HP power domain (see chapter Low-Power Management) powered down and restarted, the LP CPU
does not have access to HP_MEM by default. The master must be in the TEE mode to configure
LP_TEE_FORCE_ACC_HPMEM_EN in the LP power domain. When LP_TEE_FORCE_ACC_HPMEM_EN is
enabled, the LP CPU can access the HP_MEM without the permission management of APM controller.
The address ranges configured above may overlap. For example, region 1 and region 2 overlap. If region 1 is
set to be unreadable and region 2 is set to be readable, in this case 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 HP CPU is in TEE mode by default, and the other masters are in REE2 mode. By
default, APM controller blocks access requests from all master in REE0, REE1, and REE2 modes.
• All registers listed in 16.6 Register Summary can only be configured by the master in TEE security mode.
• Choose the security mode of the master by configuring TEE_Mn_MODE or LP_TEE_Mn_MODE. n here
equals to the master ID in Table 18-5.
• Configure the start and end address for access address ranges by setting
HP_APM_REGIONn_ADDR_START, HP_APM_REGIONn_ADDR_END, or
LP_APM0_REGIONn_ADDR_START, LP_APM0_REGIONn_ADDR_END, or
LP_APM_REGIONn_ADDR_START, LP_APM_REGIONn_ADDR_END.
• Configure the access permissions of each region in different security mode by configuring
HP_APM_REGIONn_ATTR_REG or LP_APM_REGIONn_ATTR_REG or LP_APM0_REGIONn_ATTR_REG.
Take I2S accessing HP_MEM via GDMA as an example, assuming that it is only allowed to read and write in the
fourth group address range 0x40805000 ~ 0x4080F000 address range:
• According to the ID number in the table 18-5, set the TEE_M19_MODE to be 1, so as to set the security
mode for I2S access via GDMA to REE0 mode.
• Configure the start address to 0x40805000 and end address to 0x4080F000 for the access address
range by configuring HP_APM_REGION3_ADDR_START and HP_APM_REGION3_ADDR_END respectively.
• Set HP_APM_M1_FUNC_EN to 1.
Through the above configuration, I2S can read and write in the address range of 0x40805000 ~ 0x4080F000
in HP_MEM via GDMA.
• Trigger interrupt
The APM controller module will automatically record relevant information about illegal access, including master
ID, security mode, access address, reason 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 the section 16.6 Register Summary.
Take the access path HP_APM M0 as an example. When illegal access occurs:
– If the address requested to access is not among the enabled region of the 16 address ranges
configured by HP_APM_REGIONn_ADDR_START, HP_APM_REGIONn_ADDR_END and
– If the address requested to access is among the enabled region/regions of the 16 address
ranges�but the master doesn’t have the read/write/execute permission within this region/regions,
then the bit0 will be set to 1, indicating permission restrictions.
ESP32-C6’s APM controller can generate seven 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
• LP_APM_M1_INTR
• LP_APM0_M0_INTR
These seven interrupt signals correspond to the controlled access paths shown in Figure 16-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.
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.
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.
16.7 Registers
16.7.1 High Performance APM Registers (HP_APM_REG)
N
_E
ER
ILT
_F
N
IO
EG
_R
d)
PM
ver
_A
se
(re
HP
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
_R W
_R W
_A d) IO _R R
IO _R R
X
X
_R W
_A d) IO _R R
X
HP rve REG Nn 2_
Nn 2_
2_
EG Nn 0_
Nn 0_
0_
HP rve REG Nn 1_
Nn 1_
1_
se _ IO _R
se _ IO R
_R GIO _R
_
(re PM REG Nn
(re PM EG Nn
Nn
_ A _ IO
_A _ IO
_ A _ IO
HP APM REG
HP M EG
HP APM REG
PM E
R
R
R
d)
_ _
_A _
_ _
HP APM
HP PM
HP P M
ve
P
r
se
_
(re
HP
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
0_ NC EN
N
PM M1 UN EN
NC N
_E
FU _E
_M _FU C_
_A _ _F C_
HP APM M2 UN
_ _ _F
HP PM M3
)
_A _
ed
HP APM
rv
se
_
(re
HP
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
S
TU
TA
_S
ON
TI
EP
XC
E
0_
_M
)
ed
PM
rv
_A
se
(re
HP
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
L R
_C
US
AT
ST
N_
O
GI
RE
0_
_M
)
ed
PM
rv
_A
se
(re
HP
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
GI
RE
ID
_M
N_
N_
ON
IO
IO
I
PT
PT
PT
E
E
XC
XC
XC
E
E
0_
0_
0_
_M
_M
_M
)
ed
PM
PM
PM
rv
_A
_A
_A
se
(re
HP
HP
HP
31 23 22 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
ADD
N_
IO
PT
CE
EX
0_
_M
PM
_A
HP
31 0
0 Reset
US
AT
ST
N_
IO
EPT
XC
E
1_
_M
)
ed
PM
rv
_A
se
(re
HP
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_
TU
TA
_S
ON
I
R EG
1_
_M
)
ed
PM
rv
_A
se
(re
HP
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
ON
E
OD
GI
RE
D
M
_I
N_
N_
ON
O
TI
TI
TI
EP
EP
P
CE
XC
XC
EX
E
E
1_
1_
1_
_M
_M
_M
)
ed
PM
PM
PM
rv
_A
_A
_A
se
(re
HP
HP
HP
31 23 22 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
DR
AD
N_
IO
PT
CE
EX
1_
_M
PM
_A
HP
31 0
0 Reset
US
AT
ST
N_
IO
PT
CE
EX
2_
_M
)
ed
PM
rv
_A
se
(re
HP
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_
TU
TA
_S
ON
GI
RE
2_
_M
d)
PM
r ve
_A
se
(re
HP
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
N
E
O
OD
GI
RE
ID
_M
N_
_
ON
ON
IO
TI
TI
PT
P
CE
CE
CE
EX
EX
EX
2_
2_
2_
_M
_M
_M
)
ed
PM
PM
PM
rv
_A
_A
_A
se
(re
HP
HP
HP
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
US
AT
ST
N_
IO
PT
CE
EX
3_
_M
d)
PM
r ve
_A
se
(re
HP
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_
TU
TA
_S
ON
GI
RE
3_
_M
)
ed
PM
rv
_A
se
(re
HP
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
I
EG
D
_M
_R
I
N_
ON
ON
IO
TI
TI
PT
EP
EP
E
XC
XC
XC
E
E
3_
3_
3_
_M
_M
_M
)
ed
PM
PM
PM
rv
_A
_A
_A
se
(re
HP
HP
HP
31 23 22 18 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
DD
_A
ON
TI
P
CE
EX
3_
_M
PM
_A
HP
31 0
0 Reset
AP IN EN
N
_M _AP _IN _EN
_I N
_E
M T_E
0_ M_ T_
NT
PM M1 PM NT
_A _ _A _I
HP APM M2 PM
_ _ _A
HP PM M3
)
_A _
ed
HP APM
rv
se
_
(re
HP
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
d)
PM
ve
r
_A
se
(re
HP
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
)
ed
PM
rv
_A
se
(re
HP
31 28 27 0
0 0 0 0 0x2205240 Reset
N
_E
ER
ILT
_F
I ON
EG
_R
)
ed
PM
rv
se
_A
(re
LP
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
ART
ST
R_
DD
A
n_
ION
EG
_R
PM
_A
LP
31 0
0 Reset
D
EN
R_
DD
A
n_
ION
EG
_R
PM
_A
LP
31 0
0xffffffff Reset
_R W
_R W
_A d IO _R R
I O _R R
X
X
_R W
LP rve REG Nn 1_R
X
LP rve REG Nn 2_
Nn 2_
2_
EG Nn 0_
Nn 0_
0_
Nn 1_
1_
se _ IO _R
se _ I O R
_A d IO _R
_R IO _R
_
(re PM REG Nn
(re PM EG Nn
PM RE Nn
_ A _ IO
_A _ IO
_A _ IO
LP PM REG
LP M EG
LP PM EG
G
R
R
R
d)
LP PM )
LP PM )
_A _
_A _
_A _
ve
LP PM
P
r
se
_A
(re
LP
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
N
NC N
_E
FU _E
0_ NC
_M _FU
P M M1
)
ed
_A _
LP PM
rv
se
_A
(re
LP
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 Reset
S
TU
TA
_S
ON
P TI
CE
EX
0_
_M
)
ed
PM
rv
se
_A
(re
LP
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_
TU
TA
_S
ION
EG
R
0_
_M
)
ed
PM
rv
se
_A
(re
LP
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
I
EG
D
_R
_I
N_
ON
ON
IO
TI
TI
PT
EP
EP
E
XC
XC
XC
E
E
0_
0_
0_
_M
_M
_M
)
)
ed
ed
PM
PM
PM
rv
rv
se
se
_A
_A
_A
(re
(re
LP
LP
LP
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
R
ADD
N_
IO
PT
CE
EX
0_
_M
PM
_A
LP
31 0
0 Reset
US
AT
ST
N_
IO
EPT
XC
E
1_
_M
)
ed
PM
rv
se
_A
(re
LP
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_
TU
TA
_S
ON
I
R EG
1_
_M
)
ed
PM
rv
se
_A
(re
LP
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
ON
E
OD
GI
RE
D
M
I
N_
N_
N_
IO
IO
IO
PT
PT
PT
CE
CE
XC
EX
EX
E
1_
1_
1_
_M
_M
_M
)
d)
ed
ve
PM
PM
PM
rv
r
se
se
_A
_A
_A
(re
(re
LP
LP
LP
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
DR
AD
N_
IO
PT
CE
EX
1_
_M
PM
_A
LP
31 0
0 Reset
N
_I N
_E
M T_E
NT
AP IN
0_ M_
_M _AP
P M M1
)
ed
_A _
LP PM
rv
se
_A
(re
LP
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EN
LK_
_C
)
ed
PM
rv
se
_A
(re
LP
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
PM
rv
se
_A
(re
LP
31 28 27 0
0 0 0 0 0x2205240 Reset
EN
R_
E
ILT
_F
ON
GI
RE
0_
d)
ve
PM
r
se
_A
(re
LP
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
31 0
0xffffffff Reset
n_ _W
n_ _W
_A d G n_ _R
GI n_ _R
_X
_X
n_ W
_ A d G n_ R
_X
LP rve _RE ION R1_
LP PM ) ION R1_
RE ON R0
ON R0
R0
LP rve _RE ION R2
LP PM ) ION R2
R2
R1
se 0 G n_
0_ EGI n_
n
(re PM _RE ION
(re PM RE N
PM _R ION
I O
_A 0 G
_A 0 G
se 0 G
_A 0 G
LP PM _RE
LP PM _RE
LP PM _RE
_
d)
_A 0
_A 0
_A 0
ve
LP PM
r
se
_A
(re
LP
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
NE
C_
UN
F
0_
M
0_
)
ed
PM
rv
se
_A
(re
LP
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
US
AT
ST
N_
IO
PT
CE
EX
0_
M
0_
)
ed
PM
rv
se
_A
(re
LP
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_
TU
TA
_S
I ON
EG
R
0_
M
0_
)
ed
PM
rv
se
_A
(re
LP
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
N
E
IO
OD
EG
D
_M
_R
I
N_
ON
ON
O
TI
TI
TI
EP
EP
CE
XC
XC
EX
E
E
0_
0_
0_
M
M
0_
0_
0_
)
d)
ed
ve
PM
PM
PM
rv
r
se
se
_A
_A
_A
(re
(re
LP
LP
LP
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
DR
AD
N_
IO
PT
E
E XC
0_
M
0_
PM
_A
LP
31 0
0 Reset
N
_E
NT
_I
PM
A
0_
M
0_
d)
ve
PM
r
se
_A
(re
LP
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EN
K_
CL
0_
d)
ve
PM
r
se
_A
(re
LP
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
T E
DA
0_
)
ed
PM
rv
se
_A
(re
LP
31 28 27 0
0 0 0 0 0x2205240 Reset
E
OD
M
)
n_
ed
rv
_M
se
E
(re
TE
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
E N
d)
K_
ve
CL
r
se
E_
(re
TE
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
EG
_R
)
E
ed
AT
rv
_D
se
E
(re
TE
31 28 27 0
0 0 0 0 0x2205282 Reset
E
OD
M
0_
)
M
ed
E_
rv
E
se
_T
(re
LP
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 3 Reset
EN
K_
CL
d)
E_
ve
r
E
se
_T
(re
LP
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
N
_E
EM
M
HP
C_
AC
E_
RC
FO
)
ed
E_
rv
E
se
_T
(re
LP
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
ed
rv
EE
se
_T
(re
LP
31 28 27 0
0 0 0 0 0x2205270 Reset
17 System Registers
17.1 Overview
ESP32-C6 supports a set of auxiliary chip features listed in subsection 17.2 Features below, which are
configured via registers. This chapter provides a description of the registers used to configure these
features.
17.2 Features
ESP32-C6 system registers can be used to control the following peripheral blocks and core modules:
• 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-C6 provides 4
security levels for users to choose to adapt to different applications.
• HP_SYSTEM_CPU_PERI_TIMEOUT_UID_REG: When a timeout occurs, this register will record the address
of the timeout.
HP peripherals refer to the peripherals or modules whose addresses are in the range of 0x6000_0000 ~
0x6009_FFFF. For corresponding peripheral information, please refer to Subsection 5.3.5
Modules/Peripherals Address Mapping in Chapter 5 System and Memory.
• HP_SYSTEM_HP_PERI_TIMEOUT_UID_REG: When a timeout occurs, this register will record the Master-ID
of the timeout.
• 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.
17 System Registers
17.4 Register Summary
The addresses in this section are relative to System Registers base address provided in Table 5-2 in Chapter 5 System and Memory.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
Version Register
HP_SYSTEM_DATE_REG Date control and version control register 0x03FC R/W
GoBack
17 System Registers GoBack
17.5 Registers
The addresses in this section are relative to System Registers base address provided in Table 5-2 in Chapter 5
System and Memory.
T
EC RYP
PT
C
RY
CB _EN
PT
AL
_D
RY
D_ NU
NC
A
_E
0
NL D_M
AL
NU
OW OA
OA
MA
_D NL
W
PI_
AB DO
_S
HP ved _EN LE_
LE
LE
AB
AB
res YST _EN
EN
M_
_S EM
EM
d)
TE
HP YST
ve
YS
r
se
_S
_S
er
(re
HP
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
_L SEL
EL
_
_D CFG
EV
_
_S DPA
PA
C_
EC
YS _SE
M
M
d)
HP TE
TE
ve
YS
r
se
_S
_S
(re
HP
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
LE
AB
EN
L_
AL
ST
RUN
G_
BU
E
_D
RE
O
_C
EM
d)
T
rve
YS
se
_S
(re
HP
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LE EN
AR
_C T_
NT C
_I TE
ES
UT RO
HR
EO _P
_T
IM UT
UT
I_T EO
EO
ER IM
IM
_P I_T
I_T
PU ER
ER
_C _P
_P
M PU
PU
TE C
_C
YS M_
M
d)
_S TE
TE
ve
HP SYS
YS
r
se
_S
_
(re
HP
HP
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_CPU_PERI_TIMEOUT_THRES Configures the timeout threshold for bus access for ac-
cessing CPU peripheral register in the number of clock cycles of the clock domain. (R/W)
31 0
0x000000 Reset
ID
_U
UT
EO
IM
_T
E RI
_P
PU
_C
M
d)
TE
ve
YS
r
se
_S
(re
HP
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
IM UT
UT
_T O
EO
RI ME
IM
PE TI
_T
P_ RI_
RI
_H PE
PE
M P_
P_
TE H
_H
YS M_
M
)
_S TE
TE
ed
HP SYS
YS
rv
se
_S
_
(re
HP
HP
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 do-
main. (R/W)
R
DD
_A
UT
EO
M
I
I_T
ER
P
P_
_H
M
TE
YS
_S
HP
31 0
0x000000 Reset
D
UI
U T_
EO
IM
I _T
ER
P
P_
_H
M
)
TE
ed
YS
rv
se
_S
(re
HP
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
M
BU TI
I
_T
I_ S_
US
ER BU
_B
)
ed
_P I_
RI
LP ER
rv
E
se
_P
_P
(re
LP
LP
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)
31 0
0x000000 Reset
ID
_U
UT
EO
M I
_T
US
_B
d)
ve
E RI
r
se
_P
(re
LP
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)
E
AT
_D
M
)
TE
ed
YS
rv
se
_S
(re
HP
31 28 27 0
0 0 0 0 0x2206110 Reset
18.1 Overview
Debug Assistant is an auxiliary module that features a set of functions to help locate bugs and issues during
software debugging.
18.2 Features
• Read/write monitoring: Monitors whether the High-Performance CPU (HP 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 HP CPU reset.
• Bus access logging: Records the information about bus access. When the HP CPU, LP CPU, or Direct
Memory Access controller (DMA) 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 HP CPU, and push such information to the HP SRAM.
18.3.2 SP Monitoring
The Debug Assistant module can monitor the SP so as to prevent stack overflow or erroneous push/pop.
When the stack pointer exceeds the minimum or maximum threshold, the module will record the PC pointer
and generate an interrupt. The threshold is configured by software.
18.3.3 PC Logging
In some cases, software developers want to know the PC at the last HP CPU reset. For instance, when the
program is stuck and can only be 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 HP CPU reset, which can be then read
for software debugging.
address space, the module will record the bus type, the address, PC (only when the write is performed by the
HP CPU will PC be recorded), and other information, and then store the data in the HP SRAM in a certain
format.
2. Configure interrupts.
Assuming that Debug Assistant module needs to monitor whether Data bus has written to [A ~ B] address
space, the user 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 HP CPU interrupt (please refer to Chapter 10
Interrupt Matrix (INTMTX)).
• Configure the permission for the Debug Assistant module to access the internal HP SRAM. Only
when the access permission is enabled can the Debug Assistant module access the internal HP
SRAM. For more information, please refer to Chapter 16 Permission Control (PMS).
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 1th to 5th operations.
• In non-loop mode, when writing reaches the end address, it will stop at the end address and dump
the remaining data, not overwriting the previously recorded data. Clear
MEM_MONITOR_LOG_MEM_LOOP_ENABLE to use non-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 to 10th write operations will stop at address 4 and will
not be performed any more. Therefore, the address 0 ~ 4 stores the values written by the 1 ~ 5
operations and the values of the 6 ~ 10 operations are dumped.
• Enable HP CPU, LP 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 dumps these incoming packets and buffers a LOST packet instead
before the buffer reaches its capacity. However, the bus type and the number of these dumped packets are
unknown.
When bus access logging is finished, the recorded data can be read from memory for decoding. The
recorded data is in four packet formats, namely HP CPU packet (corresponding to HP CPU Data bus), LP CPU
packet (corresponding to LP CPU bus), DMA packet (corresponding to DMA bus), and LOST packet. The
packet formats are shown in Table 18-1, 18-2, 18-3, and 18-4.
It can be seen from the data packet formats that the HP CPU packet size is 64 bits, LP CPU packet 32 bits,
DMA packet size 32 bits, and LOST packet 32 bits. These packets contain the following fields:
• format – the packet type. 0: HP CPU packet; 1: DMA packet; 2: LP CPU packet; 3: LOST packet.
• pc_offset - the offset of the PC register at the time of access. Actual PC = pc_offset + 0x4000_0000.
MEM_MONITOR_LOG_MIN_REG.
• dma_source - the source of DMA access. Refer to Table 18-5. For more information on the values 16 ~
31 in the table, please refer to 4 GDMA Controller (GDMA).
• anchored - the location of the 32 bits in the data packet. 1 indicates the lower 32 bits. 2 indicates the
higher 32 bits.
Value Source
0 HP CPU
1 LP CPU
2 reserved
3 SDIO_SLV
4 reserved
5 MEM_MONITOR
6 TRACE
7 ~ 15 reserved
See the peripherals corresponding to the values 0 ~
15 in Chapter 4 GDMA Controller (GDMA) > Table 4-
1 Peripheral-to-Memory and Memory-to-Peripheral
Data Transfer. For example, the source correspond-
16 ~ 31
ing to the value 16 is the peripheral corresponding to
the value 0 in that table, the source corresponding
to 17 is the peripheral corresponding to 1 in that table,
and etc.
The internal buffer of the module is 32 bits wide. When the HP CPU, LP 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, then the HP CPU packets, and finally the LP CPU packets. This priority of buffering packets also
applies to the case where only two types of packets are generated at the same time. 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 storage memory may cause residual data, which can interfere
with packet parsing. For example, the lower 32 bits of a HP 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 dumped.
LOG_MEM_END_REG.
• 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.
18.6 Registers
The addresses of bus logging configuration registers (see 18.6.1) in this section are relative to MEM_MONITOR
base address. The addresses of other registers (see 18.6.2) are relative to the ASSIST_DEBUG base address.
Both base addresses are provided in Table 5-2 in Chapter 5 System and Memory.
LE
AB
EN
P_
OO
_L
E
EM
OD
NA
M
_M
_E
G_
OG
O
LO
_L
_L
R_
OR
OR
TO
IT
IT
I
ON
ON
ON
d)
ve
_M
_M
_M
r
se
EM
EM
EM
(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
TA
DA
K_
H EC
_C
OG
_L
OR
IT
ON
_M
EM
M
31 0
0 Reset
K
AS
_M
TA
DA
OG_
_L
OR
IT
ON
)
ed
_M
rv
se
EM
(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
IN
M
G_
LO
O R_
IT
ON
_M
EM
M
31 0
0 Reset
MEM_MONITOR_LOG_MIN Configures the lower bound address of the monitored address space.
(R/W)
AX
M
G_
LO
R_
ITO
ON
_M
EM
M
31 0
0 Reset
MEM_MONITOR_LOG_MAX Configures the upper bound address of the monitored address space.
(R/W)
31 0
0 Reset
ND
_E
EM
M
G_
O
_L
OR
IT
ON
_M
EM
M
31 0
0 Reset
R
ADD
T_
EN
RR
U
_C
EM
M
G_
LO
R_
ITO
ON
_M
EM
M
31 0
0 Reset
TE
DA
UP
R_
DDA
M_
ME
G_
LO
R_
ITO
ON
d)
_M
rve
e
M
es
ME
(r
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
LL L_
G
FU UL
M_ _F
ME EM
G_ _M
LO OG
R_ _L
TO LR
NI _C
MO TOR
M_ NI
d)
ME _MO
rve
e
M
es
ME
(r
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EN
K_
L
_C
OR
IT
ON
d)
ve
_M
r
se
EM
(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
E
AT
_D
OR
IT
ON
)
ed
_M
rv
se
EM
(re
31 28 27 0
0 0 0 0 0x2202140 Reset
0_ _ENA
NA
A
NA
_1_ _EN
_E
A_ AM0 RD_E
_D 0_RD NA
_1_ A
A
R
A
RD
NA
N
WR
A
N
AM 0_W
N
E
_E
SIS EBU COR _AR _PIF_ N_EN
E
SIS EBU COR _AR _PIF_ D_E
SIS EBU COR _AR _PIF_ WR_
OR _AR ILL_ X_E
R_
_
0_
1_W
_R
M0
A_ AM0
MA
_
M I
0
_1
RA
OR _SP ILL_
OR _AR _PIF
R
DR
DR
CO _0_A A_D
_0 _SP
P
A
EA
A
EA
EA
_S
E
E
RE
RE
AR
OR _SP
_A
DE G_CO _0_
0
0
_0
0
_0
0
_0
E_
E_
E_
E_
E
E
E
RE
OR
R
AS T_DE G_C
AS T_DE G_C
AS T_DE G_C
AS T_DE G_C
AS T_DE G_C
_
_
_
G_
G
G
G
BU
BU
BU
BU
BU
BU
BU
AS T_DE
d)
_D
_D
D
rve
_
T_
T
T
T
SIS
SIS
SIS
SIS
SIS
SIS
SIS
se
(re
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
IN
M
0_
0_
AM
DR
A_
RE
_A
_0
RE
CO
UG_
EB
D
T_
S IS
AS
31 0
0xffffffff Reset
AX
M
0_
0_
AM
DR
A_
RE
_A
_0
RE
CO
UG_
EB
D
T_
S IS
AS
31 0
0 Reset
IN
M
1_
0_
AM
DR
A_
RE
_A
_0
RE
CO
UG_
EB
D
T_
S IS
AS
31 0
0xffffffff Reset
AX
M
1_
0_
AM
DR
A_
RE
_A
_0
RE
CO
UG_
EB
D
T_
S IS
AS
31 0
0 Reset
IN
M
0_
F_
PI
A_
RE
_A
_0
RE
CO
UG_
EB
D
T_
S IS
AS
31 0
0xffffffff Reset
AX
M
0_
F_
PI
A_
RE
_A
_0
RE
CO
UG_
EB
D
T_
S IS
AS
31 0
0 Reset
IN
M
1_
F_
PI
A_
RE
_A
_0
RE
CO
G_
BU
DE
T_
S IS
AS
31 0
0xffffffff Reset
AX
M
1_
F_
PI
A_
RE
_A
_0
RE
CO
G_
BU
DE
T_
S IS
AS
31 0
0 Reset
31 0
0 Reset
SP
A_
RE
_A
_0
RE
CO
UG_
DEB
T_
S IS
AS
31 0
0 Reset
IN
M
P_
_S
_0
RE
CO
UG_
DEB
T_
S IS
AS
31 0
0 Reset
31 0
0xffffffff Reset
PC
P_
_S
_0
RE
CO
U G_
EB
D
T_
S IS
AS
31 0
0 Reset
AW
AW
AW
AW
M0 WR_R
_R
_R
REA RAM0 RD_R
AW
AW
RAW
AW
MIN AW
RD
RAW
R
R
R
_W
R
_0_
_0_
R_
_R
_
_
D_
RD
0_1
0_1
_
WR
EA_ _0_W
RE_ SP_SP _MAX
1_R
0_
_1_
AM
M
IF_
RA
LL_
PIF
F
PIF
R
DR
LL
_D
D
_D
P
P
E_0 P_SPI
I
E_0 REA_
E_0 REA_
E_0 REA_
E_0 REA_
EA _
REA
AR
R
_A
_A
_A
A
A
_A
_A
_S
_
_
G_C E_0_
0_
E_0
E_0
RE_
OR
OR
OR
OR
OR
OR
OR
OR
CO
O
_C
C
_C
_C
_C
C
_C
_C
_
_
_
UG
UG
G
UG
UG
UG
UG
UG
UG
U
BU
ASS _DEB
ASS _DEB
B
ASS _DEB
ASS _DEB
ASS _DEB
ASS _DEB
EB
EB
DE
DE
)
ved
D
_D
_
_
_
IST
IST
IST
IST
IST
IST
IST
IST
IST
IST
ser
ASS
ASS
ASS
ASS
(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
TR_ A
A
TR_ A
A
EN
EN
EN
EN
R_
A
A
R_
A
A
EN
A
N
A
EN
NT
N
EN
INT
E
N
_IN
R_
_
_IN
_W TR_E
1_R NTR_
R_
M0 WR_I
TR_
R
R_
INT
NT
RD
NT
D
W
_R
_IN
_0_
_0_
N
_
I
_
I
_
_
D_
R
I
RD
0_1
0_1
IN_
W
_SP _MAX
M0
_0_
0_
AM
AM
_M
F_1
IF_
IF_
A
RA
F
R
R
DR
L
ILL
_D
D
_D
_0_ SPIL
P
P
P
_P
E_0 REA_
_
E_0 REA_
A_
E_0 REA_
RE_ AREA
A
RE_ AREA
REA
E
E
_
AR
R
_SP
P
A
_A
A
A
_A
S
0_
_
_
_0_
0_
_
E_0
E_0
RE_
E
E
OR
OR
OR
OR
OR
OR
OR
CO
CO
CO
_C
C
_C
_C
C
_C
_C
_
_
_
_
UG
UG
G
UG
UG
G
UG
G
UG
UG
U
U
ASS _DEB
ASS _DEB
B
ASS _DEB
EB
B
ASS _DEB
B
ASS _DEB
EB
DE
DE
DE
)
ved
_D
_
_
_
_
IST
IST
IST
IST
IST
IST
IST
IST
IST
IST
ser
ASS
ASS
ASS
ASS
ASS
(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
LR
LR
LR
L R
M0 WR_C
_C
_C
REA RAM0 RD_C
LR
R
LR
RD
CLR
R
L
CLR
ILL X_CLR
PIF WR_C
_C
_W
_C
0_
_0_
_1_
_
RD
0_1
IN_
WR
RD
_
M0
0_
_0_
A
_1_
_1_
M
M
_SP ILL_M
IF_
A
A
RA
_
PIF
PI F
DR
DR
D
_D
P
EA_
A_
E_0 REA_
EA_
A_
EA_
E_0 REA_
SP
SP
E
_
SP_
R
R
R
AR
R
_A
_A
_A
A
_A
A
_A
_
0_
_
_0_
0
E_0
E_0
E_0
E_0
E_0
_
RE_
E
(AS T_DEB CORE
(AS T_DEB _COR
(AS T_DEB _COR
(AS T_DEB _COR
(AS T_DEB _COR
(AS T_DEB _COR
_C
_C
_
_
G
UG
UG
UG
UG
UG
SIS EBUG
UG
UG
UG
U
EB
(AS _DEB
)
_D
T_D
ved
T
IST
SIS
SIS
SIS
SIS
SIS
SIS
SIS
SIS
ser
ASS
(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
EC GEN
N
DE
BU
OR
_R _PDE
_R
CD
CD
_R
G_ RE_0
_0
RE
DE G_CO
CO
BU
BU
AS T_DE
d)
rve
T_
SIS
SIS
se
(re
AS
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
P
GS
BU
DE
_P
CD
_R
_0
RE
CO
G_
U
DEB
T_
S IS
AS
31 0
0x000000 Reset
C
EX
E_
R
FO
BE
C_
TP
AS
_L
_0
RE
CO
G_
U
DEB
T_
S IS
AS
31 0
0 Reset
IVE
CT
OD E_A
_M UL
E
U G OD
EB _M
G
_0 BU
RE DE
_D
CO _0_
E
BU OR
DE G_C
G_
U
SIS EB
d)
AS T_D
rve
T_
SIS
se
(re
AS
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EN
K_
L
_C
UG
EB
)
ed
_D
rv
ST
se
SI
(re
AS
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
G_
BU
DE
)
ed
T_
rv
IS
se
S
(re
AS
31 28 27 0
0 0 0 0 0x2109130 Reset
19.1 Introduction
ESP32-C6 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-C6 has two working modes, which are Typical AES and
DMA-AES.
19.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.
– 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 are written and read via DMA. An interrupt will be
generated when operation completes.
The AES accelerator is activated by setting the PCR_AES_CLK_EN bit and clearing the PCR_AES_RST_EN bit
in the PCR_AES_CONF_REG register. Additionally, users also need to clear PCR_DS_RST_EN bit to reset Digital
Signature (DS).
Users can choose the working mode for AES accelerator by configuring the AES_DMA_ENABLE_REG register
according to Table 19-1 below.
Users can choose the length of cryptographic keys and encryption / decryption by configuring the
AES_MODE_REG register according to Table 19-2 below.
For detailed introduction on these two working modes, please refer to Section 19.4 and Section 19.5
below.
Notice:
ESP32-C6’s Digital Signature (DS) module will call the AES accelerator. Therefore, users cannot access the
AES accelerator when Digital Signature (DS) module is working.
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/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/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.
19.4.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 19-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.
19
Key Endianness
Table 19-5. Key Endianness Type for AES-128 Encryption and Decryption
w[0] ~ w[3] are “the first Nk words of the expanded key” as specified in Section 5.2 Key Expansion in NIST FIPS
197.
Table 19-6. Key Endianness Type for AES-256 Encryption and Decryption
623
1 Column “Bit” specifies the bytes of each word stored in w[0] ~ w[7].
ESP32-C6 TRM (Version 1.0)
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.
GoBack
19 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
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 write 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 19-9 below.
Function : TEXT-PADDING( )
Input : X, bit string.
Output : Y = TEXT-PADDING(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
TEXT-PADDING(X) = X;
If 0 < t <= 127, define a 128-bit block, Xn∗ , and let Xn∗ = Xn ||0128−t , then
TEXT-PADDING(X) = X1 ||X2 || · · · ||Xn−1 ||Xn∗ = X||0128−t
19.5.2 Endianness
Under the DMA-AES working mode, the transmission of source data and result data for AES accelerator is
solely controlled by DMA. Therefore, the AES accelerator cannot control the Endianness of the source data
and result data, but does have requirement on how these data should be stored in memory and on the length
of the data.
For example, let us assume DMA needs to write the following data into memory at address 0x0280.
– 0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20
• Data Length:
– Equals to 2 blocks.
Then, this data will be stored in memory as shown in Table 19-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 19-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.
• Select block cipher mode by configuring the AES_BLOCK_MODE_REG register. For details, see
Table 19-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 4
GDMA Controller (GDMA).
6. Clear interrupt by writing 1 to the AES_INT_CLEAR_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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
19.8 Registers
The addresses in this section are relative to the AES accelerator base address provided in Table 5-2 in Chapter
5 System and Memory.
)
-7
:0
(n
EG
_R
_n
KEY
S_
AE
31 0
0x000000000 Reset
)
-3
:0
(m
EG
_R
m
N_
_I
XT
TE
S_
AE
31 0
0x000000000 Reset
AES_TEXT_IN_m_REG (m: 0-3) 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: 0-3) Represents the result text data when the AES accelerator oper-
ates in the Typical AES working mode. (RO)
E
)
OD
ed
M
rv
se
S_
(re
AE
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_
)
ed
M
rv
D
se
S_
(re
AE
31 1 0
0x00000000 0 Reset
E
OD
M
K_
OC
)
ed
BL
rv
se
S_
(re
AE
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 acceler-
ator operates under the DMA-AES working mode. For details, see Section 19.5.4. (R/W)
NC
rv
I
se
S_
(re
AE
31 1 0
0x00000000 0 Reset
AES_INC_SEL Configures the Standard Incrementing Function for CTR block operation.
0: INC32
1: INC128
(R/W)
ER
G
d)
IG
ve
TR
r
se
S_
(re
AE
31 1 0
0x00000000 x Reset
E
)
AT
ed
ST
rv
se
S_
(re
AE
31 2 1 0
IT
EX
A_
d)
DM
ve
r
se
S_
(re
AE
31 1 0
0x00000000 x Reset
R
EA
L
_C
)
ed
NT
rv
I
se
S_
(re
AE
31 1 0
0x00000000 x Reset
NA
_E
)
ed
NT
rv
I
se
S_
(re
AE
31 1 0
0x00000000 0 Reset
20.1 Introduction
Elliptic Curve Cryptography (ECC) is an approach to public-key cryptography based on the algebraic structure
of elliptic curves. ECC allows smaller keys compared to RSA cryptography while providing equivalent
security.
ESP32-C6’s ECC Accelerator can complete various calculations based on different elliptic curves, thus
accelerating the ECC algorithm and ECC-derived algorithms (such as ECDSA).
20.2 Features
ESP32-C6’s ECC Accelerator has the following features:
• Two different elliptic curves, namely P-192 and P-256 defined in FIPS 186-3
20.3 Terminology
This section covers terminology used to describe ECC Accelerator.
The ECC algorithm is based on elliptic curves over prime fields, which can be represented as:
y 2 = x3 + ax + b mod p
where,
• p is a prime number,
• In affine coordinates:
y 2 = x3 + ax + b mod p
• In a Jacobian coordinates:
Y 2 = X 3 + aXZ 4 + bZ 6 mod p
y = Y /Z 3 mod p
Y =y
Z=1
ECC’s memory blocks store input data and output data of the ECC operation.
ESP32-C6’s ECC operates on data of 256 bits. This data (D[255 : 0]) can be divided into eight 32-bit data
blocks D[n][31 : 0](n = 0, 1, · · · , 7). Data blocks with the smaller serial number correspond to the lower binary
bits. To be specific:
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]
Write data means writing data to an ECC memory block and using this data as the input to the ECC algorithm.
To be specific, write data to an ECC memory block means writing D[n][31 : 0](n = 0, 1, · · · , 7) to the “starting
address of this ECC memory block + 4 × n” successively:
• ···
Note:
When the key size of 192 bits is used, you need to append 0 before 192 bits of data and write 256 bits of data.
Read data means reading data from the starting address of an ECC memory block and using this data as the
output from the ECC algorithm. To be specific, read data from an ECC memory block means reading
D[n][31 : 0](n = 0, 1, · · · , 7) from the “starting address of this ECC memory block + 4 × n” successively:
• ···
Note:
When the key size of 192 bits is used, only read the low 192 bits (6 blocks) of data.
ESP32-C6’s ECC performs Base Point Calculation (including Base Point Verification and Base Point
Multiplication) using the affine coordinates and Jacobian Calculation (including Jacobian Point Verification and
Jacobian Point Multiplication) using the Jacobian coordinates.
Detailed descriptions about different working modes are provided in the following sections.
(Qx , Qy ) = k · (Px , Py )
where,
Base Point Verification can be used to verify if a point (Px , Py ) is on a selected elliptic curve.
20.4.2.3 Base Point Verification + Base Point Multiplication (Point Verif + Multi Mode)
In this working mode, ECC first verifies if Point (Px , Py ) is on the selected elliptic curve. If so, the following
multiplication is performed:
(Qx , Qy ) = k · (Px , Py )
where,
• Output:
(Qx , Qy , Qz ) = k · (Px , Py , 1)
where,
Jacobian Point Verification can be used to verify if a point (Qx , Qy , Qz ) is on a selected elliptic curve.
20.4.2.6 Base Point Verification + Jacobian Point Multiplication (Point Verif + Jacobian
Point Multi Mode)
In this working mode, ECC first verifies if Point (Px , Py ) is on the selected elliptic curve. If so, the following
multiplication is performed:
(Qx , Qy , Qz ) = k · (Px , Py , 1)
where,
• Output:
20.6 Interrupts
ESP32-C6’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, fields ECC_CALC_DONE_INT_RAW and ECC_CALC_DONE_INT_ST will be cleared.
2. Choose the key size and working mode as described in Section 20.4.
5. Wait for the ECC_CALC_DONE_INT interrupt, which indicates the completion of the ECC calculation.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
20.9 Registers
The addresses in this section are relative to ECC Accelerator base address provided in Table 5-2 in Chapter 5
System and Memory.
W
RA
T_
IN
E_
ON
_D
LC
d)
ve
CA
r
C_
se
(re
EC
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
E _I
ON
_D
LC
)
ed
CA
rv
C_
se
(re
EC
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
(re
EC
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
R
CL
T_
IN
E_
ON
_D
LC
d)
ve
CA
r
C_
se
(re
EC
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
N
_O
R CE
FO
T
UL
E_
ES
T
GA
ST T TH E
_R
C_ SE NG OD
K_
E
ON
EC _RE LE _M
OD
C
LO
TI
C Y_ TY
_M
CA
EC _SE EN
_C
EC _KE URI
T
FI
C K_
EM
d)
AR
OR
RI
C C
ve
EC CL
VE
M
W
r
C_
C_
C_
C_
se
(re
EC
EC
EC
EC
31 30 9 8 7 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 0 0 0 0 0 0 Reset
ECC_START Configures whether to start calculation of ECC Accelerator. This bit will be self-cleared
after the calculation is done.
0: No effect
1: Start calculation of ECC Accelerator
(R/W/SC)
ECC_VERIFICATION_RESULT Represents the verification result of ECC Accelerator, valid only when
calculation is done. (R/SS)
TE
)
ed
DA
rv
C_
se
(re
EC
31 28 27 0
0 0 0 0 0x2201240 Reset
• Hash result only accessible by configurable hardware peripheral (in downstream mode)
• Required keys for the Digital Signature (DS) peripheral (in downstream mode)
After the reset signal being released, the HMAC module will check whether the DS key exists in the eFuse. If
the key exists, the HMAC module will enter downstream digital signature mode and finish the DS 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 6
eFuse Controller. 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 21.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 by 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, please repeat the above steps again.
Before starting the DS module, users need to obtain the parameter decryption key for the DS module through
HMAC calculation. For more information, please see Chapter 24 Digital Signature (DS). 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 mode and complete the HMAC calculation based on the chosen key.
listed in Table 21-1. Additionally, another purpose specifies a key which may be used for re-enabling JTAG as
well as for serving as DS 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 totally have 6 keys in eFuse, so the value of x is
0 ~ 5) from 6 eFuse Controller. Take upstream mode as example, if there is no
EFUSE_KEY_PURPOSE_HMAC_UP in EFUSE_KEY_PURPOSE_0 ~ 5, it means there is no upstream used key in
eFuse. 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 6 eFuse Controller 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 DS.
The correct purpose has to be written to register HMAC_SET_PARA_PURPOSE_REG (see Section 21.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 KEY_PURPOSE_3 is 6
(EFUSE_KEY_PURPOSE_HMAC_DOWN_JTAG). Based on Table 21-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.
(a) Set the peripheral clock bits for HMAC and SHA peripherals in register
SYSTEM_PERIP_CLK_EN1_REG, and clear the corresponding peripheral reset bits in register
SYSTEM_PERIP_RST_EN1_REG. For information on those registers, please see Chapter 5 System
and Memory.
(a) Write the key purpose m to register HMAC_SET_PARA_PURPOSE_REG. The possible key purpose
values are shown in Table 21-1. For more information, please refer to Section 21.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 21.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 DS) 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 DS 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.
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 21.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 DS 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 DS module when the HMAC module is in use.
As shown in Figure 21-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.
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 21.2.5.
In Figure 21-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 21.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).
The abbreviations given in Column Access are explained in Section Access Types for Registers.
21.5 Registers
The addresses in this section are relative to HMAC Accelerator base address provided in Table 5-2 in Chapter 5
System and Memory.
T
AR
ST
T_
d)
E
_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
D
EN
A_
R
PA
T_
)
E
ed
_S
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
ed
_S
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
NG
_I
XT
TE
T_
d)
E
_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
ND
_E
XT
TE
T_
)
E
ed
_S
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
ND
E
T_
UL
R ES
T_
)
E
ed
_S
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: Not exit
1: Exit upstream mode and clear calculation results.
(WO)
AG
JT
E_
AT
ID
AL
NV
_I
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
DS
E_
AT
ID
AL
INV
T_
)
E
ed
_S
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
K
EC
CH
EY_
UR
d)
_Q
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
E
AT
ST
Y_
US
)
ed
_B
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_BUSY_STATE Represents whether or not HMAC is in a busy state. Before configuring HMAC,
please make sure HMAC is in an IDLE state.
0: Idle
1: HMAC is still working on the calculation
(RO)
PU
ed
_
rv
AC
se
HM
(re
31 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
HMAC_PURPOSE_SET Configures the HMAC purpose, refer to the Table 21-1. (WO)
T
SE
Y_
)
KE
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
AD
_P
XT
TE
T_
d)
E
_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
K
OC
BL
E_
ON
T_
)
E
ed
_S
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_ONE_BLOCK Write 1 to indicate there is only one block which already contains padding
bits and there is no need for padding. (WO)
R L
CT
G_
TA
_J
FT
d)
O
_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
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
)
ed
_D
rv
AC
se
HM
(re
31 30 29 0
0 0 0x20200618 Reset
22.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.
22.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-C6’s Digital Signature (DS) module also calls the RSA accelerator when working. Therefore, users
cannot access the RSA accelerator when the Digital Signature (DS) module is working.
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.
To represent the numbers used as operands, let us define a base-b positional notation, as follows:
b = 232
N
n=
32
Z = (Zn−1 Zn−2 · · · Z0 )b
X = (Xn−1 Xn−2 · · · X0 )b
Y = (Yn−1 Yn−2 · · · Y0 )b
M = (Mn−1 Mn−2 · · · M0 )b
r = (rn−1 rn−2 · · · r0 )b
Each of the 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 22.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.
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.
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
N
storage, 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 ,
• 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 22-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.
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.
22.6 Registers
The addresses in this section are relative to the RSA accelerator base address provided in Table 5-2 in Chapter
5 System and Memory.
E
M
RI
_P
M
A_
RS
31 0
0x000000 Reset
E
)
OD
ed
M
rv
A_
se
(re
RS
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
P
EX
OD
M
T_
AR
ST
)
T_
ed
SE
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
UL
M
OD
M
T_
AR
ST
d)
T_
ve
SE
r
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
UL
M
T_
AR
ST
)
T_
ed
SE
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
QU
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
I M
_T
NT
TA
NS
d)
ve
CO
r
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
E
BL
NA
_E
CH
AR
)
ed
SE
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
A
SE
rv
A_
se
(re
RS
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)
N
EA
CL
Y_
ER
d)
ve
QU
r
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PT
RU
ER
I NT
R_
EA
)
ed
CL
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
A
EN
)
T_
ed
IN
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
DA
rv
A_
se
(re
RS
31 30 29 0
0 0 0x20200618 Reset
23.1 Introduction
ESP32-C6 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-C6 has two working modes, which are Typical SHA and DMA-SHA.
23.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 and
PCR_HMAC_RST_EN bits to reset Digital Signature (DS) and HMAC Accelerator (HMAC).
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 23-1.
Users can choose hash algorithms by configuring the SHA_MODE_REG register. For details, please see Table
23-2.
Notice:
ESP32-C6’s Digital Signature (DS) and HMAC Accelerator (HMAC) modules also call the SHA accelerator.
Therefore, users cannot access the SHA accelerator when these modules are working.
23.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.
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-C6 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.
• 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-C6 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-C6 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.
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 4 GDMA Controller (GDMA).
DMA-SHA process
• Select a hash algorithm by configuring the SHA_MODE_REG register. For details, please refer to
Table 23-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_CLEAR_IRQ_REG register.
Table 23-3. The Storage and Length of Message Digest from Different Algorithms
23.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_CLEAR_IRQ_REG
register to 1.
When working in the Typical SHA mode, SHA completes the calculation quick fast, so interrupt is not
necessary. Therefore, SHA does not support interrupt in the Typical SHA mode.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
23.6 Registers
The addresses in this section are relative to the SHA accelerator base address provided in Table 5-2 in Chapter
5 System and Memory.
RT
d)
A
ve
ST
r
A_
se
(re
SH
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
N
TI
)
N
ed
CO
rv
A_
se
(re
SH
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
BU
rv
A_
se
(re
SH
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 RT
ST
A_
d)
DM
ve
r
A_
se
(re
SH
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UE
IN
NT
CO
A_
)
ed
DM
rv
A_
se
(re
SH
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
)
ed
CL
rv
A_
se
(re
SH
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
ed
IN
rv
A_
se
(re
SH
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
)
ed
T
DA
rv
A_
se
(re
SH
31 30 29 0
0 0 0x20190402 Reset
E
)
OD
ed
M
rv
A_
se
(re
SH
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
M
NU
K_
OC
BL
A_
)
ed
M
rv
_D
se
A
(re
SH
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)
_n
M
A_
SH
31 0
0x000000 Reset
24.1 Overview
A Digital Signature (DS) 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-C6 includes a Digital Signature (DS) module providing hardware acceleration of messages’ signatures
based on RSA. HMAC is used as the key derivation function to output the DS_KEY key using eFuse as the
input key. Subsequently, the DS module uses DS_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.
24.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 (DS_KEY ) which
can only be calculated by the DS 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 DS 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 6
eFuse Controller and 21 HMAC Accelerator (HMAC) peripheral.
The input message X will be sent directly to the DS 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.
• || 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 DS peripheral in this encrypted format, decrypted by the hardware, and
then used for RSA signature calculation. Detailed description of how to generate C is provided in Section
24.3.3.
The DS 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 22.3.1
Large-number Modular Exponentiation in Chapter 22 RSA Accelerator (RSA).
Note:
1. The software preparation (left side in the Figure 24-1) is a one-time operation before any signature is calculated,
while the hardware calculation (right side in the Figure 24-1) repeats for every signature calculation.
Users need to follow the steps shown in the left part of Figure 24-1 to calculate C. Detailed instructions are as
follows:
• Step 1: Prepare operands Y and M whose lengths should meet the requirements in Section 24.3.2.
Define [L]32 = N
32 − 1 (i.e., for RSA 3072, [L]32 == [0x60-1]32 ). Prepare [HM AC_KEY ]256 and calculate
[DS_KEY ]256 based on DS_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 19 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 , [DS_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
r]3072 , [Box]
of C, and correspond to the ciphertext of [Y ]3072 , [M ]3072 , [r]3072 , [Box]384 respectively.
The DS operation at the hardware level can be divided into the following three stages:
The decryption process is the inverse of Step 6 in figure 24-1. The DS 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, DS_KEY , IV ), where IV (i.e., [IV ]128 ) is defined by the
user. [DS_KEY ]256 is provided by the HMAC module, derived from HM AC_KEY stored in eFuse.
[DS_KEY ]256 , as well as [HM AC_KEY ]256 are not readable by users.
With P, the DS 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 DS module will perform two checks: MD check and padding check. Padding check is not shown in
Figure 24-1, as it happens at the same time as MD check.
• MD check: The DS 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.
• Padding check: The DS module checks if [β]64 complies with the aforementioned PKCS#7 format.
Only when [β]64 complies with the format does the padding check pass.
The DS module will only perform subsequent operations if MD check passes. If padding check fails, a
warning is generated, but it does not affect the subsequent operations.
The DS 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 DS
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
DS_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.
• If the software reads any value from 1 to 15 in DS_QUERY_KEY_WRONG_REG, it indicates that HMAC
was called, but the DS module did not successfully get the DS_KEY value from the HMAC
peripheral. This may indicate that the HMAC operation has been interrupted due to a software
concurrency problem.
4. Configure register: Write IV block to register DS_IV_m_REG (m: 0 ~ 3). For more information on the IV
block, please refer to Chapter 19 AES Accelerator (AES).
• Write b
ri (i ∈ {0, 1, . . . , 95}) to DS_RB_MEM.
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 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 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 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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
24.6 Registers
The addresses in this section are relative to Digital Signature base address provided in Table 5-2 in Chapter 5
System and Memory.
)
-3
:0
(m
EG
_R
m
V_
_I
DS
31 0
0x000000000 Reset
T
AR
ST
)
ed
T_
rv
E
_S
se
(re
DS
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_
ve
E
r
_S
se
(re
DS
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
SH
NI
FI
d)
T_
ve
E
r
_S
se
(re
DS
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
Y_
)
ER
ed
rv
U
_Q
se
(re
DS
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
K EY
Y_
)
ER
ed
rv
U
_Q
se
(re
DS
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
RO D
ER BA
R
D_ NG_
)
_M DI
ed
DS PAD
rv
se
_
(re
DS
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
AT
rv
_D
se
(re
DS
31 30 29 0
0 0 0x20200618 Reset
25.1 Overview
The ESP32-C6 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.
25.2 Features
• General XTS-AES algorithm, compliant with IEEE Std 1619-2007
• Configurable Anti-DPA
The Manual Encryption block can encrypt instructions/data which will then be written to the external flash as
ciphertext via SPI1.
In the System Registers (HP_SYS) peripheral (see 17 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 6 eFuse Controller.
25.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 users.
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 25-1. In each case, the Key can be uniquely determined by Key A .
Notes:
“YES” indicates that the block exists; “NO” indicates that the block does not exist; “0256 ” indicates a bit string
that consists of 256-bit zeros. Note that using 0256 as Key is not secure. We strongly recommend to configure
a valid key.
For more information on key purposes, please refer to Table 6-2 Structure in Chapter 6 eFuse Controller.
• 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 a 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 that 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 the 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.
Assume a word in the target memory space is stored in address, define offset = address%64, n = offset/4,
then the word will be stored in register XTS_AES_PLAIN_n_REG.
For example, when the size is 32, all registers in the register block will be used. The mapping between offset
and registers now is shown in Table 25-2.
The Manual Encryption block is operational only under certain conditions. The operating conditions
are:
Note:
Even though the CPU can skip cache and get the encrypted instruction/data directly by reading the external
memory, users can by no means access Key.
The Auto Decryption block is operational only under certain conditions. The operating conditions are:
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.
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. Users can by no means obtain the de-
cryption Key during the process.
• When the Auto Decryption block is disabled, it does not have any effect on the contents stored in the exter-
nal 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 25.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 above steps according to the amount of plaintext instructions/data that need to be encrypted.
25.6 Anti-DPA
ESP32-C6 XTS_AES supports Anti-DPA.
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 to 0, Anti-DPA is disabled. The higher the value of Anti_DP A_level is,
the stronger the Anti-DPA ability is.
• Configure whether or not to enable Anti-DPA when the XTS-AES algorithm is calculating D:
Note:
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 significantly impacted
when the Anti-Attack level >= 4.
• When Anti-DPA is disabled during the calculation of D, the read and write bandwidth will be significantly impacted
when the Anti-Attack level >= 6.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
25.8 Registers
The addresses in this section are relative to External Memory Encryption and Decryption base address
provided in Table 5-2 in Chapter 5 System and Memory.
_n
IN
LA
_P
ES
A
S_
XT
31 0
0x000000 Reset
ZE
SI
I NE
_L
)
ed
ES
rv
A
se
S_
(re
XT
32 2 1 0
N
IO
AT
IN
ST
E
_D
d)
ES
ve
A
r
se
S_
(re
XT
31 1 0
0x00000000 0 Reset
S
ES
R
DD
L_A
CA
SI
HY
_P
)
ed
ES
rv
A
se
S_
(re
XT
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)
N ER
_E IST
PA EG
EL
_D _R
EV
_D CT
_L
LC LE
TY
CA SE
RI
CU
T_ A_
YP DP
SE
CR T_
T_
S_ YP
YP
AE CR
CR
d)
S_ S_
S_
ve
XT AE
AE
r
se
S_
S_
(re
XT
XT
31 5 4 3 2 0
ES
rv
A
se
S_
(re
XT
31 1 0
0x00000000 x Reset
SE
EA
EL
_R
d)
ES
ve
A
r
se
S_
(re
XT
31 1 0
0x00000000 x Reset
XTS_AES_RELEASE Configures whether or not to grant SPI1 access to the encrypted result.
0: No effect
1: Grant SPI1 access
(WO)
OY
TR
ES
_D
)
ed
ES
rv
A
se
S_
(re
XT
31 1 0
0x00000000 x Reset
ES
rv
A
se
S_
(re
XT
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)
E
AT
_D
)
ed
ES
rv
A
se
S_
(re
XT
31 30 29 0
0 0 0x20200111 Reset
26.1 Introduction
The ESP32-C6 contains a true random number generator, which generates 32-bit random numbers that can
be used for cryptographical operations, among other things.
26.2 Features
The random number generator in ESP32-C6 generates true random numbers, which means random numbers
generated from a physical process, rather than by means of an algorithm. No number generated within the
specified range is more or less likely to appear than any other number.
• Thermal noise comes from the high-speed ADC or SAR ADC or both. Whenever the high-speed ADC or
SAR ADC is enabled, bit streams will be generated and fed into the random number generator through an
XOR logic gate as random seeds.
• RC_FAST_CLK is an asynchronous clock source and it increases the RNG entropy by introducing circuit
metastability.
Random bit
SAR ADC
seeds XOR
XOR
Random LPPERI_RNG_DATA_REG
Number
Generator
High Speed Random bit
ADC seeds
Random bit
RC_FAST_CLK
seeds
When there is noise coming from the SAR ADC, the random number generator is fed with a 2-bit entropy in
one clock cycle of RC_FAST_CLK, which is generated from an internal RC oscillator (see Chapter 8 Reset and
Clock for details). Thus, it is advisable to read the LPPERI_RNG_DATA_REG register at a maximum rate of 1
MHz to obtain the maximum entropy.
When there is noise coming from the high-speed ADC, the random number generator is fed with a 2-bit
entropy in one APB clock cycle, which is normally 80 MHz. Thus, it is advisable to read the
LPPERI_RNG_DATA_REG register at a maximum rate of 5 MHz to obtain the maximum entropy.
A data sample of 2 GB, which is read from the random number generator at a rate of 5 MHz with only the
high-speed ADC being enabled, has been tested using the Dieharder Random Number Testsuite (version
3.31.1). The sample passed all tests.
• SAR ADC can be enabled by using the DIG ADC controller. For details, please refer to Chapter 39
On-Chip Sensor and Analog Signal Processing.
• High-speed ADC is enabled automatically when the Wi-Fi or Bluetooth module is enabled.
Note:
1. Note that, when the Wi-Fi module is enabled, the value read from the high-speed ADC can be saturated in some
extreme cases, which lowers the entropy. Thus, it is advisable to also enable the SAR ADC as the noise source
for the random number generator for such cases.
2. Enabling RC_FAST_CLK increases the RNG entropy. However, to ensure maximum entropy, it’s recommended to
always enable an ADC source as well.
When using the random number generator, read the LPPERI_RNG_DATA_REG register multiple times until
sufficient random numbers have been generated. Ensure the rate at which the register is read does not
exceed the frequencies described in section 26.3 above.
26.6 Register
31 0
0x00000000 Reset
27.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-C6 has three UART controllers,
including two regular UARTs and one low-power LP UART. These UARTs are compatible with various UART
devices, and support Infrared Data Association (IrDA) and RS485 communication.
Each of the two regular UART controllers has a group of registers that function identically. In this chapter, the
two regular UART controllers are referred to as UARTn, in which n denotes 0 or 1. LP UART is the cut-down
version of regular UART, with a separate group of registers. For differences between UART and LP UART,
please refer to Table 27-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 a 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-C6 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.
27.2 Features
Table 27-1 lists the feature comparison between UART and LP UART:
CLOCK
UART_CLKDIV_REG
UART_SCLK_SEL
UART_SCLK Domain
XTAL_CLK
1 CTS ctsn_in
RC_FAST_CLK Clock source Hardware
Divider
PLL_F80M_CLK 0 RTS Flow Control rtsn_out
APB_CLK Domain
Receiver
Start_Detect UART_RXD_INV
fifo_wdata 1
UART0
apb_rdata Rx_FIFO fifo_wr Rx_FIFO_Ctrl Rx_FIFO Rx_FSM 0
rxd_in
Baudrate_Detect
... UART_LOOPBACK
wake_up
Wakeup_Ctrl
Figure 27-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: an 80 MHz PLL_F80M_CLK, RC_FAST_CLK, and external
crystal clock XTAL_CLK (for details, please refer to Chapter 8 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 27-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.
The receiver contains an RX FIFO (i.e. Rx_FIFO in Figure 27-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 Light-sleep mode (see Chapter 12
Low-Power Management for more details), a wake_up signal can be generated in four ways and sent to RTC,
which then wakes up the ESP32-C6 chip. For more information about wakeup, please refer to Section
27.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. Usually,
the UART Core’s clock frequency is lower than the APB_CLK’s frequency, and can be divided by the largest
divisor when higher than the frequency needed to generate the baud rate. The frequency of the UART Core’s
clock can also be at most twice higher than the APB_CLK. 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 Section27.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
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.
IN P U T _F REQ
U ART _CLKDIV + U ART _CLKDIV
16
_F RAG
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 27-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 27-2 below, to make the output timing more
uniform:
To support IrDA (see Section 27.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 27-1 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 rising
edges, and UART_NEGEDGE_MIN_CNT stores the minimum pulse width between two falling edges. These
four fields are read by software to determine the transmitter’s baud rate.
Figure 27-3. The Timing Diagram of Weak UART Signals Along Falling Edges
1. Normally, to avoid sampling erroneous data along rising or falling edges in a 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
2. If UART signals are weak along falling edges as shown in Figure 27-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 rising edges, use UART_NEGEDGE_MIN_CNT to determine the
transmitter’s baud rate as follows:
fclk
Buart =
(UART_NEGEDGE_MIN_CNT + 1)/2
Figure 27-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 27.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 remains logical low for one NULL
character transmission, and a UART_BRK_DET_INT interrupt will be triggered to detect that a Break condition
has been completed.
The receiver can detect the current bus state through the timeout interrupt UART_RXFIFO_TOUT_INT. The
UART_RXFIFO_TOUT_INT interrupt will be triggered when the bus is in the idle state for more than
UART_RX_TOUT_THRHD bit time on current baud rate after the receiver has received at least one byte. You can
use this interrupt to detect whether all the data from the transmitter has been sent.
Figure 27-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 APB_CLK frequency is suggested not to be lower than 8 MHz.
27.4.6 RS485
The two regular 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 27-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 27-6, DE is connected to dtrn_out of UART (please refer to Section
27.4.9.1 for more details).
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 27-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.
27.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 27-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.
Figure 27-7. 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 27-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.
27.4.8 Wake-up
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-C6.
• 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 rising edges is equal to or greater than
(UART_ACTIVE_THRESHOLD + 3).
• 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,
UART_WK_CHAR1, UART_WK_CHAR2, UART_WK_CHAR3, and UART_WK_CHAR4. These four characters
can be formed into different character sequences by configuring UART_CHAR_NUM and
UART_WK_CHAR_MASK, as shown in Table 27-2. Once the sequence is detected, the chip will be woken
up. For the last configuration in Table 27-2, UART will detects for CHAR0 ~ CHAR4 in order.
After the chip is woken up by UART, it is necessary to clear the wake_up signal by transmitting data to UART in
Active mode or resetting the whole UART, otherwise the number of rising edges required for the next wakeup
will be reduced.
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
Figure 27-9 shows the hardware flow control of a UART controller. Hardware flow control uses output signal
rtsn_out and input signal dsrn_in. Figure 27-10 illustrates how these signals are connected between UART on
ESP32-C6 (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.
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.
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 27-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.
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.
• 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 27.6. Those without the _SYNC suffix
in Section 27.6 are configuration registers that require no clock domain crossing.
To initialize UARTn:
• Write 1 to PCR_UARTn_RST_EN.
• Clear PCR_UARTn_RST_EN.
• 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.
• Read data from RX FIFO via UART_RXFIFO_RD_BYTE, and obtain the number of bytes received in RX FIFO
via UART_RXFIFO_CNT.
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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
27.7 Registers
27.7.1 UART Registers
The addresses in this section are relative to UART Controller base address provided in Table 5-2 in Chapter 5
System and Memory.
YTE
_B
RD
O_
IF
d)
XF
ve
_R
r
RT
se
(re
UA
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D
RH
N
TH
_E
T_
UT
U
TO
TO
)
RT d)
X_
X_
ed
UA rve
_R
_R
rv
RT
se
se
(re
(re
UA
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)
RT XF N_ T_ RA W W
R X_ NE ITY _I W W
RA
UA T_G BR IDL RA _IN W
R X_ K_ T_ RR RA
R X_ _P _E T_ T_
R LI K_ E_ W T_
_ F I T_ T
_R W
UA _S XO ET IN _IN
AW
UA T_T BR _IN _E NT_
UA T_R _C _IN RA AW
UA T_T 85 RM _IN _IN
NT A
UA _B IFO IN RA W
_R FO RR R W
FU Y_ AW
_I _R
RT W_ _D NE NE
RT XFI _E NT_ RA
R S4 _F SH ET
R SR HG T_ _R
XF _E _IN AW
R AR R _I W
R RM _O T W
R RK _T T_ W
R XF HG T_ W
LL INT
O_ PT R
UA T_C _D OU RAW
UA T_R 85 CH AW
UA T_P _E VF _RA
UA T_D _C _IN INT
IF M T_
_
R S4 D_ _R
R S4 _C AR
R TS ET T_
_
UA T_R CM INT
R T_ P_
F
UA T_A EU
R AK
)
ed
W
UA T_W
rv
se
R
(re
UA
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
ST
R X_ K_ T_ RR ST
R X_ _P _E T_ T_
T_
R W_ FF _I T_ T
UA _S XO ET IN _IN
UA T_T BR _IN _E NT_
UA T_T 85 RM _IN _IN
NT T
T
_I _S
UA T_R _C _IN ST T
RT W_ _D NE NE
R XF N T_ ST
_S
R S4 _F SH ET
RT XFI _E NT_ ST
R SR HG T_ _S
FU Y_ T
R X_ NE ITY _I
LL INT
O_ PT S
XF _E _IN T
UA T_P _E VF _ST
UA T_D _C _IN INT
UA T_S TCH DO DO
UA T_R 85 LA _D
IF M T_
UA T_B IFO _IN ST
_R FO RR S
UA T_C _D OU ST
UA T_R 85 CH T
R XF HG T_
R S4 D_ _S
R S4 _C AR
R LI K_ E_
R TS ET T_
R RM _O T
R RK _T T_
R AR R _I
UA T_R CM INT
R T_ P_
UA T_A EU
R AK
d)
ve
UA T_W
r
se
R
(re
UA
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
RT XF N_ T_ EN A A
R X_ NE ITY _I A A
EN
UA T_G BR IDL EN _IN A
R X_ K_ T_ RR EN
R X_ _P _E T_ T_
R LI K_ E_ A T_
_ F I T_ T
_E A
UA _S XO ET IN _IN
UA T_T BR _IN _E NT_
UA T_T 85 RM _IN _IN
NA
NT N
UA T_R _C _IN EN NA
UA _B IFO IN EN A
_R FO RR E A
FU Y_ NA
_I _E
RT W_ _D NE NE
RT XFI _E NT_ EN
R S4 _F SH ET
R SR HG T_ _E
XF _E _IN NA
R AR R _I A
LL INT
R RM _O T A
R RK _T T_ A
R XF HG T_ A
O_ PT E
UA T_C _D OU ENA
UA T_P _E VF _EN
UA T_F IFO _IN EN
UA T_D _C _IN INT
UA T_R 85 CH NA
UA T_S TCH DO DO
UA T_R 85 LA _D
IF M T_
_
R S4 D_ _E
R S4 _C AR
R TS ET T_
_
UA T_R CM INT
R T_ P_
F
UA T_A EU
R AK
d)
W
ve
UA T_W
r
se
R
(re
UA
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
RT XF N_ T_ CL R R
R X_ NE ITY _I R R
CL
UA T_G BR IDL CL _IN LR
R X_ _P _E T_ T_
R LI K_ E_ R T_
_ F I T_ T
R X_ K_ T_ RR C
_C R
UA _S XO ET IN _IN
UA T_T BR _IN _E NT_
UA T_T 85 RM _IN _IN
LR
NT L
UA T_R _C _IN CL LR
UA _B IFO IN CL R
_I _C
_R FO RR C R
FU Y_ LR
RT W_ _D NE NE
R S4 _F SH ET
R SR HG T_ _C
RT XFI _E NT_ CL
XF _E _IN LR
LL INT
R AR R _I R
R RM _O T R
O_ PT C
R RK _T T_ R
R XF HG T_ R
UA T_C _D OU CLR
UA T_P _E VF _CL
UA T_D _C _IN INT
UA T_S TCH DO DO
UA T_R 85 LA _D
IF M T_
UA T_R 85 CH LR
_
R S4 D_ _C
R S4 _C AR
R TS ET T_
_
UA T_R CM INT
R T_ P_
F
UA T_A EU
R AK
d)
W
ve
UA T_W
r
se
R
(re
UA
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
AG
FR
V_
V
DI
DI
)
)
LK
LK
ed
ed
_C
_C
rv
rv
RT
RT
se
se
(re
(re
UA
UA
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)
N
_E
ILT
ILT
_F
_F
H
H
TC
TC
)
ed
LI
LI
_G
_G
rv
RT
RT
se
(re
UA
UA
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
VF
M
UA T_R _IN DAT K
R IS R_ EN
R XD V _O
R RR AU N
R XD _ S
NU
R D X_ V
R D AC N
R D C V
UA T_E OB K_E
UA T_T _RX MA
_T _ EN
UA T_D _W D_
UA T_M RT ST
UA T_IR PB _E
UA T_IR A_W IN
UA T_IR A_T TL
RT _B X
UA T_IR A_R K
IT N
IT_
UA XD DPL
R W_ _R
RT DA X_
R XF _R
R OO W
AR Y_E
M
RK
R UT CL
R X_ N
RT DA V
R D X
R E S
_B
UA T_L FLO
UA T_IR _IN
UA _T _E
NU
Y
UA T_R IFO
UA T_A M_
_P IT
P
IT_
)
TO
RT AR
R XF
ed
_B
UA _P
_S
UA T_T
rv
RT
RT
se
R
(re
UA
UA
UA
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)
D
RH
RH
TH
H
Y_
_T
PT
LL
M
FU
_E
TS NV
R TS V
RT SR V
NV
O_
R TR R
R W_ N
UA T_R _IN
UA T_D _IN
UA T_D DT
FO
UA T_S _E
_C _I
_I
IF
d)
FI
R LK
XF
X
ve
UA T_C
_R
_T
r
RT
RT
se
R
(re
UA
UA
UA
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)
D
RH
N
H
_E
_T
OW
OW
FL
FL
d)
X_
X_
ve
_R
_R
r
RT
RT
se
(re
UA
UA
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 during
hardware flow control.
Measurement unit: byte. (R/W)
2
3
4
R1
AR
AR
AR
A
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
rv
RT
se
(re
UA
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
D
RH
OL
H
K
SH
M
AS
L
_T
SE
NU
UP
E
M
HR
E_
R_
R_
E_
_T
OD
AK
CH
CH
E
M
IV
W
K_
K_
K_
d)
CT
X_
ve
_W
_W
_W
_R
_A
r
RT
RT
RT
RT
RT
se
(re
UA
UA
UA
UA
UA
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)
ND
SE
ST EN
L_
F_ N_
IL
OF O
R ON _X F
ON OW L
_X _C
UA T_S OF ON
UA T_X CE OF
_X FL DE
UA T_F D_ FF
AR
R
UA T_F CE N
HA
R EN XO
R OR XO
R OR _X
RT W_ F_
CH
_C
UA T_S D_
F_
ON
)
R EN
OF
ed
UA T_S
_X
_X
rv
RT
RT
se
R
(re
UA
UA
UA
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 move
1: Move
(R/W)
UART_FORCE_XOFF Configures whether or not to stop the transmitter from sending data.
0: Not stop
1: Stop
(R/W)
LD
D
OL
HO
SH
ES
RE
R
TH
H
_T
F_
ON
)
OF
ed
_X
_X
rv
RT
RT
se
(re
UA
UA
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
)
ed
X
_T
rv
RT
se
(re
UA
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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
ID
)
_I
X_
ed
_R
_T
rv
RT
RT
se
(re
UA
UA
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 data byte data.
Measurement unit: bit time (the time to transmit 1 bit). (R/W)
UA T_D _EN _R _E M
M
R L1 TX TX U
NU
X_ N
UA T_D 85 BY_ Y_N
EN
Y_
R S 4 RX D L
DL
UA _R 85 X_
X_
N
RT S4 _R
_E
_T
S4 N
_R _E
85
UA _R 85
85
d)
RT L0
S4
RT S4
ve
_R
UA R _
r
RT
RT
se
(re
UA
UA
31 10 9 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 to enable the RS485 transmitter for data transmis-
sion when the RS485 receiver is busy.
0: Disable
1: Enable
(R/W)
RT X_ _C RE
X_ LK RE
LK N
N
SC _E
UA _R RST O
_E
_T SC O
RT X_ T_C
UA T_T RS
)
)
R X_
ed
ed
UA T_R
rv
rv
se
se
R
(re
(re
UA
31 28 27 26 25 24 23 0
0 0 0 0 0 0 1 1 0 Reset
T
T
CN
N
_C
O_
FO
IF
N
_D N
_D N
SR
)
)
RT XD
TR
FI
RT TS
RT TS
XF
RT XD
ed
ed
X
UA _C
UA _R
UA T_R
_R
UA T_T
_T
rv
rv
RT
RT
se
se
R
R
(re
(re
UA
UA
UA
UA
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)
DR
R
DD
AD
A
_W
_R
AM
AM
R
SR
_S
)
d)
X_
ed
ve
_T
_T
rv
r
RT
RT
se
se
(re
(re
UA
UA
31 17 16 9 8 7 0
DR
DR
AD
AD
_W
_R
AM
AM
SR
SR
)
)
X_
X_
ed
ed
_R
_R
rv
rv
RT
RT
se
se
(re
(re
UA
UA
31 17 16 9 8 7 0
UT
UT
_O
_O
X
TX
UR
U
)
T_
T_
ed
_S
_S
rv
RT
RT
se
(re
UA
UA
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
X_ IFO U Y
FU TY
_T AF _F T
AF _ LL
LL
RT X_ IFO MP
O_ P
IF EM
UA T_T AF _E
R X_ IFO
UA _R AF
d)
RT X_
ve
UA T_R
r
se
R
(re
UA
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
RE
ed
_P
rv
RT
se
(re
UA
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)
M
NU
E_
I DL
T_
OS
)
ed
_P
rv
RT
se
(re
UA
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)
TU
TO
P_
GA
)
X_
ed
_R
rv
RT
se
(re
UA
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 Reset
AR
CH
UM
D_
N
R_
CM
HA
d)
T_
ve
_C
_A
r
RT
RT
se
(re
UA
UA
31 16 15 8 7 0
UART_CHAR_NUM Configures the number of continuous AT_CMD characters a receiver can receive.
(R/W)
NT
_C
IN
M
E_
DG
E
OS
d)
ve
_P
r
RT
se
(re
UA
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)
TN
_C
IN
M
GE_
ED
EG
)
ed
_N
rv
RT
se
(re
UA
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
(re
UA
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
NT
_C
IN
_M
E
LS
H PU
)
IG
ed
_H
rv
RT
se
(re
UA
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
ed
_R
rv
RT
se
(re
UA
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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
E
AT
PD
_U
d)
EG
ve
_R
r
RT
se
(re
UA
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
RT
rv
A
se
_U
(re
LP
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
IS
EN _D
HD
T_ OW
HR
OU FL
_T
_T T_
UT
RX OU
TO
T_ _T
X_
AR RX
_R
d)
_U T_
RT
ve
LP AR
A
r
se
_U
_U
(re
LP
LP
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
LP_UART_RX_TOUT_FLOW_DIS Configures whether or not to stop the idle status counter when
hardware flow control is enabled.
0: Invalid. No effect
1: Stop
(R/W)
LP_UART_RX_TOUT_THRHD Configures the amount of time that the bus can remain idle before time-
out.
Measurement unit: bit time (the time to transmit 1 bit). (R/W)
LP AR RXF ON INT_ _R AW AW
AW
_U T_ _X F_ INT _R _R
_R
LP AR SW OF T_ INT INT
T_ W
NT
W
LP AR RXF CH INT AW W
IN RA
_U T_ IF _I R AW
T_ FIF ER T_R AW
UL _IN W
_U T_ _X DE _ E_
_I
RA
_U T_ R_ _ R A
L_ T_
_F TY RA
ET
FI EM IN W
LP AR PAR ER F_I AW
LP AR FRM O_ INT AW
LP AR GLI RK_ LE_ AW
LP AR BR O_T NT_ AW
LP AR SW H_ ONE ON
AR TX Y_ IN _R
LP AR CTS DE UT_ W
CH AW
RX O_ R_ A
_D
FO P T_
_U T_ K_ O RA
_U T_ _ OV _R
_U T_ IT R_ NT
_U T_ _ T_ IN
_U T_ IF G_ _R
_U T_ B ID _R
_U T_ TC D D
D_ _R
AR
LP AR X_ K_ NT
M INT
I
_U T_ B _
_C _
LP R X_ NE
AT UP
O
R
T_ KE
_U T_ D
LP AR TX_
AR WA
T
T
)
)
_U T_
_U T_
ed
ed
LP AR
LP AR
rv
rv
A
se
se
_U
_U
(re
(re
LP
LP
31 20 19 18 17 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
LP AR RXF ON INT_ _S T T
T
_U T_ _X F_ INT _S _S
_S
LP AR SW OF T_ INT INT
NT
IN ST
_U T_ _X DE _ E_
_I
ST
_U T_ R_ _ S T
_U T_ IF _I S T
L_ T_
ET
T_ FIF ER T_S T
LP AR DS CHG INT_ T_S
_F TY ST
LP AR SW H_ ONE ON
T_
AR TX Y_ IN _S
UL _IN
RX O_ R_ T
LP AR PAR ER F_I T
_D
LP AR FRM O_ INT T
FO P T_
LP AR GLI RK_ LE_ T
LP AR BR O_T NT_ T
LP AR RXF CH INT T
_U T_ K_ O ST
_U T_ _ OV _S
_U T_ IT R_ NT
_U T_ _ T_ IN
_U T_ IF G_ _S
_U T_ B ID _S
CH T
_U T_ TC D D
FI EM IN
D_ _S
AR
LP AR CTS DE UT_
LP AR X_ K_ NT
M INT
I
_U T_ B _
_C _
LP R X_ NE
AT UP
O
R
T_ KE
_U T_ D
LP AR TX_
AR WA
T
T
)
)
_U T_
_U T_
ed
ed
LP AR
LP AR
rv
rv
A
se
se
_U
_U
(re
(re
LP
LP
31 20 19 18 17 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
LP AR RXF ON INT_ _E NA NA
NA
_U T_ _X F_ INT _E _E
_E
LP AR SW OF T_ INT INT
NT
T_ A
A
IN EN
LP AR RXF CH INT NA A
_U T_ IF _I E NA
EN
_U T_ _X DE _ E_
_I
T_ FIF ER T_E NA
UL _IN A
_U T_ R_ _ E N
_F TY EN
L_ T_
ET
FI EM IN A
LP AR PAR ER F_I NA
LP AR SW H_ ONE ON
LP AR FRM O_ INT NA
LP AR GLI RK_ LE_ NA
LP AR BR O_T NT_ NA
AR TX Y_ IN _E
LP AR CTS DE UT_ A
RX O_ R_ N
AR A
_D
FO P T_
_U T_ K_ O EN
_U T_ IT R_ NT
_U T_ _ OV _E
_U T_ _ T_ IN
CH N
_U T_ IF G_ _E
_U T_ B ID _E
_U T_ TC D D
D_ _E
LP AR X_ K_ NT
M INT
I
_U T_ B _
_C _
LP R X_ NE
AT UP
O
R
T_ KE
_U T_ D
LP AR TX_
AR WA
T
T
)
)
_U T_
_U T_
ed
ed
LP AR
LP R
rv
rv
A
se
se
_U
_U
(re
(re
LP
LP
31 20 19 18 17 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
LP AR RXF ON INT_ _C LR LR
LR
_U T_ _X F_ INT _C _C
_C
LP AR SW OF T_ INT INT
NT
T_ R
R
IN CL
LP AR RXF CH INT LR R
_U T_ _X DE _ E_
_U T_ IF _I C LR
_I
CL
T_ FIF ER T_C LR
UL _IN R
_U T_ R_ _ C L
L_ T_
ET
_F TY CL
FI EM IN R
LP AR PAR ER F_I LR
LP AR SW H_ ONE ON
AR TX Y_ IN _C
LP AR FRM O_ INT LR
LP AR GLI RK_ LE_ LR
LP AR BR O_T NT_ LR
LP AR CTS DE UT_ R
RX O_ R_ L
_D
FO P T_
CH LR
_U T_ _ OV _C
_U T_ K_ O CL
_U T_ IT R_ NT
_U T_ _ T_ IN
_U T_ IF G_ _C
_U T_ B ID _C
_U T_ TC D D
D_ _C
AR
LP AR X_ K_ NT
M INT
I
_U T_ B _
_C _
LP R X_ NE
AT UP
O
R
T_ KE
_U T_ D
LP AR TX_
AR WA
T
T
d)
)
_U T_
_U T_
ed
ve
LP AR
LP AR
rv
A
r
se
se
_U
_U
(re
(re
LP
LP
31 20 19 18 17 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
AG
FR
V_
IV
I
KD
KD
L
L
_C
_C
)
d)
ed
RT
RT
ve
rv
A
r
se
se
_U
_U
(re
(re
LP
LP
31 24 23 20 19 12 11 0
LP_UART_CLKDIV Configures the integral part of the divisor for baud rate generation. (R/W)
LP_UART_CLKDIV_FRAG Configures the fractional part of the divisor for baud rate generation. (R/W)
N
_E
ILT
ILT
_F
_F
H
H
TC
TC
LI
LI
_G
_G
)
ed
RT
RT
rv
A
se
_U
_U
(re
LP
LP
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
VF
M
se T_ _I DA K
LP rve RXD NV T_O
EN
(re AR TXD X_ AS
NU
BA EN
LP rve ME TS T
(re AR SW O_ T
K_
_U T_ _R _M
se T_ _R RS
CK
RI EN
T_
_U T_ IF S
OP W_
LP AR RXF O_R
AR PA M
K
LP AR ) _CL
LP AR ) INV
BI
LP AR IS R
PA Y_
BR
LO LO
TY
W
_N
T_ RIT
_U T_ _
_U d _
OP
_U T_ IF
_U d M
AR D_
T_ _F
LP AR ERR
LP AR TXF
T
ST
AR TX
_U TX
BI
D
)
)
_U T_
_U T_
_U T_
T_
T_
T_
_U T_
ed
ed
LP AR
AR
AR
LP AR
rv
rv
se
se
_U
_U
_U
_U
(re
(re
LP
LP
LP
LP
LP
31 24 23 22 21 20 19 18 17 16 15 14 13 12 11 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 1 3 0 0 Reset
LP_UART_TXD_BRK Configures whether or not to send NULL characters when finishing data trans-
mission.
0: Not send
1: Send
(R/W)
LP_UART_TX_FLOW_EN Configures whether or not to enable flow control for the transmitter.
0: Disable
1: Enable
(R/W)
LP_UART_RXD_INV Configures whether or not to invert the level of LP UART RXD signal.
0: Not invert
1: Invert
(R/W)
LP_UART_TXD_INV Configures whether or not to invert the level of LP UART TXD signal.
0: Not invert
1: Invert
(R/W)
LP_UART_DIS_RX_DAT_OVF Configures whether or not to disable data overflow detection for the
LP UART receiver.
0: Enable
1: Disable
(R/W)
LP_UART_ERR_WR_MASK Configures whether or not to store the received data with errors into FIFO.
0: Store
1: Not store
(R/W)
LP_UART_MEM_CLK_EN Configures whether or not to enable clock gating for LP UART memory.
0: Disable
1: Enable
(R/W)
D
RH
RH
TH
H
Y_
_T
PT
L
UL
M
_F
_E
S_ V
LP AR RTS INV
AR DS INV
V
LP AR DT TR
LP AR SW EN
CT IN
IN
FO
FO
_U T_ _D
T_ R_
_U T_ R_
_U T_ _
_U T_ _
I
FI
LP AR CLK
XF
TX
_R
d)
)
_U T_
T_
ed
ed
RT
ve
LP AR
AR
rv
rv
A
r
se
se
se
_U
_U
_U
(re
(re
(re
LP
LP
LP
31 22 21 20 19 18 17 16 15 11 10 8 7 3 2 0
LP_UART_CTS_INV Configures whether or not to invert the level of LP UART CTS signal.
0: Not invert
1: Invert
(R/W)
LP_UART_DSR_INV Configures whether or not to invert the level of LP UART DSR signal.
0: Not invert
1: Invert
(R/W)
LP_UART_RTS_INV Configures whether or not to invert the level of LP UART RTS signal.
0: Not invert
1: Invert
(R/W)
LP_UART_DTR_INV Configures whether or not to invert the level of LP UART DTR signal.
0: Not invert
1: Invert
(R/W)
HD
HR
N
_E
_T
W
W
LO
LO
F
F
X_
X_
_R
_R
d)
)
ed
RT
RT
ve
rv
A
A
r
se
se
_U
_U
(re
(re
LP
LP
31 9 8 7 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 0x0 0 0 0 Reset
LP_UART_RX_FLOW_THRHD Configures the maximum number of data bytes that can be received
during hardware flow control.
Measurement unit: byte. (R/W)
2
3
4
1
AR
AR
AR
AR
CH
CH
CH
CH
K_
K_
K_
K_
_W
_W
_W
_W
RT
RT
RT
RT
A
A
_U
_U
_U
_U
LP
LP
LP
31 24 23 16 15 8 7
LP 0
RT
rv
A
se
_U
(re
LP
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
HD
D
OL
HR
K
SH
UM
AS
L
_T
SE
UP
RE
_M
_N
E_
H
E_
AR
AR
_T
OD
AK
CH
CH
E
M
IV
W
K_
K_
K_
CT
X_
_W
_W
_W
_R
_A
)
)
ed
ed
RT
RT
RT
RT
RT
rv
rv
A
A
se
se
_U
_U
_U
_U
_U
(re
(re
LP
LP
LP
LP
LP
31 28 27 26 25 21 20 18 17 13 12 10 9 0
LP_UART_ACTIVE_THRESHOLD Configures the number of RXD edge changes to wake up the chip
in wakeup mode 0. (R/W)
LP_UART_RX_WAKE_UP_THRHD Configures the number of received data bytes to wake up the chip
in wakeup mode 1. (R/W)
D
EN
_S
TI N
_S _E
LL
FF N
XO _CO
LP AR XO E_ FF
XO LO EL
AR SW FF N
LP AR FO _XO F
R
_U T_ RC N
_U T_ RC XO
_U T_ NO XO
T_ _F _D
_U T_ D F
HA
N_ W
A
LP AR SEN _XO
CH
LP AR FO E_
_C
N_
_U T_ D
FF
LP AR SEN
XO
O
_X
)
_U T_
T_
ed
RT
LP AR
AR
rv
A
se
_U
_U
_U
(re
LP
LP
LP
31 23 22 21 20 19 18 17 16 15 8 7 0
LP_UART_XONOFF_DEL Configures whether or not to remove flow control characters from the re-
ceived data.
0: Not move
1: Move
(R/W)
LP_UART_FORCE_XOFF Configures whether or not to stop the transmitter from sending data.
0: Not stop
1: Stop
(R/W)
LD
OL
HO
SH
ES
RE
HR
TH
_T
F_
ON
OF
_X
_X
d)
d)
)
ed
RT
RT
ve
ve
rv
A
A
r
r
se
se
se
_U
_U
(re
(re
(re
LP
LP
31 16 15 11 10 8 7 3 2 0
LP_UART_XON_THRESHOLD Configures the threshold for data in RX FIFO to send XON characters in
software flow control.
Measurement unit: byte. (R/W)
LP_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
X _B
_T
)
ed
RT
rv
A
se
_U
(re
LP
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
LP_UART_TX_BRK_NUM Configures the number of NULL characters to be sent after finishing data
transmission.
Valid only when LP_UART_TXD_BRK is 1. (R/W)
D
RH
M
NU
TH
E_
_
LE
DL
ID
_I
X_
X
_R
_T
d)
RT
RT
ve
A
r
se
_U
_U
(re
LP
LP
31 20 19 10 9 0
LP_UART_RX_IDLE_THRHD Configures the threshold to generate a frame end signal when the re-
ceiver takes more time to receive one data byte data.
Measurement unit: bit time (the time to transmit 1 bit). (R/W)
) EN
rv DL N
se T_ _E
ed 0_
(re AR DL1
)
_U T_
ed
LP AR
rv
se
_U
(re
LP
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
LP_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)
LP_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)
T_ _S CO E
_S K_ E
CL EN
AR RX ST_ R
EN
TX CL R
_U T_ R CO
K_
LP AR TX_ ST_
_U T_ R
LP AR RX_
)
)
_U T_
ed
ed
LP AR
rv
rv
se
se
_U
(re
(re
LP
31 28 27 26 25 24 23 0
0 0 0 0 0 0 1 1 0 Reset
T
T
N
N
_C
_C
FO
FO
RN
RN
T_ SN
T_ SN
I
LP AR RXD
I
XF
LP AR TXD
XF
DS
DT
AR RT
AR CT
_R
_T
)
)
_U T_
_U T_
_U T_
_U T_
ed
ed
ed
ed
RT
RT
LP AR
LP AR
rv
rv
rv
rv
A
A
se
se
se
se
_U
_U
_U
_U
(re
(re
(re
(re
LP
LP
LP
LP
31 30 29 28 24 23 19 18 16 15 14 13 12 8 7 3 2 0
1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 Reset
LP_UART_DSRN Represents the level of the internal LP UART DSR signal. (RO)
LP_UART_CTSN Represents the level of the internal LP UART CTS signal. (RO)
LP_UART_RXD Represents the level of the internal LP UART RXD signal. (RO)
LP_UART_DTRN Represents the level of the internal LP UART DTR signal. (RO)
LP_UART_RTSN Represents the level of the internal LP UART RTS signal. (RO)
LP_UART_TXD Represents the level of the internal LP UART TXD signal. (RO)
DR
DR
AD
AD
_W
_R
AM
AM
R
SR
_S
X_
TX
_T
)
d)
)
T_
ed
ed
RT
ve
AR
rv
rv
A
r
se
se
se
_U
_U
(re
(re
(re
LP
LP
31 17 16 12 11 8 7 3 2 0
DR
DR
AD
AD
_W
_R
AM
AM
SR
SR
X_
X_
_R
_R
)
)
ed
ed
ed
RT
RT
rv
rv
rv
A
A
se
se
se
_U
_U
(re
(re
(re
LP
LP
31 17 16 12 11 8 7 3 2 0
T
T
OU
OU
X_
X_
UR
UT
T_
T_
_S
_S
)
ed
RT
RT
rv
A
se
_U
_U
(re
LP
LP
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
TX FIF F Y
UL Y
T_ _A O_ PT
_F PT
FI _EM L
L
_A O UL
AR TX FIF EM
_U T_ A O_
FO
LP AR RX_ FIF
_U T_ A
LP AR RX_
d)
_U T_
ve
LP AR
r
se
_U
(re
LP
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
RT
rv
A
se
_U
(re
LP
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x901 Reset
LP_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)
M
NU
E_
DL
_I
ST
O
_P
)
ed
RT
rv
A
se
_U
(re
LP
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x901 Reset
LP_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)
T
OU
_T
AP
_G
X
_R
)
ed
RT
rv
A
se
_U
(re
LP
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 Reset
AR
CH
UM
D_
_N
CM
AR
T_
H
_C
_A
)
ed
RT
RT
rv
A
se
_U
_U
(re
LP
LP
31 16 15 8 7 0
LP_UART_CHAR_NUM Configures the number of continuous AT_CMD characters a receiver can re-
ceive. (R/W)
E
AT
_D
A RT
_U
LP
31 0
0x2201260 Reset
TE
DA
P
_U
EG
_R
)
ed
RT
rv
A
se
_U
(re
LP
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
EN
F_
se EP EN N EN
EO
UH C _ E EN
(re I_S D_ _E F_
K_
CI AR OF_ C_
C EA EC EO
C RC IDL N
UH I_E _E _BR
UH I_U _E _CR
UH I_H _R E_
C d _EN
_T RS E
UH I_R T0 E
CI X_ _C
C LK RX
C AR C
C N E
C NC N
X_ T
T
UH I_U T1_
UH I_L OD
UH rve ER
UH I_C T_
RS
T
d)
UH I_U )
C AR
C AR
E
ve
UH I_U
_
r
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)
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)
RE
UH I_C E_ K_ RE
UH I_C _D AD M_
N
UM N
T
_E
C AV EC M_
AR
_S _E
C RC HE SU
HE _S LE
UH I_T ) _ST
CK EQ
UH I_S CH NU
_C CK B
UH rve T_S T
CI HE ISA
se AI AR
C _ _
C d W
K
(re I_W ST
UH _T C
CI X_A
C W_
)
ed
X
UH I_S
rv
se
C
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)
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)
UH I_T 13_ SC N
UH I_T 11_ C_ N
SC N
N
CI X_ ES EN
CI X_D ESC EN
C X_ _E _E
C X_ _E EN
C X_ ES _E
_E _E
X_ _E EN
_E
UH I_R 11_ C_
UH I_T C0 SC
UH _R DB C_
C0 SC
_T B _
C X_ ES
UH I_R 13_
)
C X_
ed
UH I_R
rv
se
C
UH
(re
31 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 Reset
UHCI_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)
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)
FT
FT
NA
NA
HI
HI
_S
_E
_S
_E
UT
UT
UT
UT
UT
UT
EO
EO
EO
EO
EO
EO
M
M
TI
TI
TI
TI
TI
TI
O_
O_
O_
O_
O_
O_
IF
IF
IF
IF
IF
IF
)
XF
XF
XF
XF
XF
XF
ed
_R
_R
_R
_T
_T
_T
rv
se
CI
CI
CI
CI
CI
CI
UH
UH
UH
UH
UH
UH
(re
31 24 23 22 20 19 12 11 10 8 7 0
UHCI_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)
UHCI_RXFIFO_TIMEOUT_ENA Configures whether or not to enable the DMA data transmission time-
out.
0: Disable
1: Enable
(R/W)
D
OA
_L
UM
UM
_N
_N
d)
CK
CK
ve
_A
_A
r
se
CI
CI
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
UM
NU
N
N
_E
_N
_E
D_
ND
ND
ND
EN
SE
SE
SE
_S
S_
E_
S
E
AY
AY
GL
GL
LW
LW
d)
IN
IN
ve
_A
_A
_S
_S
r
se
CI
CI
CI
CI
UH
UH
UH
UH
(re
31 8 7 6 4 3 2 0
D0
OR
W
0_
_Q
ND
E
_S
CI
UH
31 0
0x000000 Reset
D1
OR
W
0_
_Q
ND
E
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
D1
OR
W
Q 1_
D_
EN
_S
CI
UH
31 0
0x000000 Reset
D0
OR
_W
2
_Q
ND
E
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
D0
OR
_W
Q3
D_
EN
_S
CI
UH
31 0
0x000000 Reset
1D
OR
W
3_
_Q
ND
E
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
D1
OR
W
4_
_Q
ND
E
_S
CI
UH
31 0
0x000000 Reset
D0
OR
W
5_
_Q
ND
SE
I_
C
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
D0
OR
W
6_
_Q
E ND
_S
CI
UH
31 0
0x000000 Reset
1D
OR
_W
6
_Q
END
_S
CI
UH
31 0
0x000000 Reset
AR
H
CH
_C
AR
C_
SC
CH
ES
_E
R_
R_
ER
PE
)
EP
EP
ed
E
_S
_S
_S
rv
se
CI
CI
CI
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)
0
R1
AR
HA
H
_C
_C
Q0
Q0
Q0
SE
SE
SE
C_
C_
C_
)
ed
ES
ES
S
_E
rv
_
se
CI
CI
CI
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
R 1
AR
HA
H
_C
_C
Q1
Q1
1
EQ
SE
SE
_S
C_
C_
)
SC
ed
ES
ES
_E
rv
I_
I_
se
CI
C
C
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)
R0
R1
A
HA
CH
_C
2_
Q2
EQ
EQ
SE
_S
_S
C_
)
SC
SC
ed
S
_E
_E
_E
rv
se
CI
CI
CI
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)
RS
TH
T_
)
ed
PK
rv
I_
se
C
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
CI X_S NG T_ INT AW
X_ AR NT W AW
UH I_T HU _IN Q_ T_R
_R T _I RA _R
UH I_T D_ RE RA W
C EN OF IN AW
C EN A_ T_ RA
W
AR NT AW
C X_ NG G_ IN
IN AW
C X_ S_ G_ W
RA
UH I_S _E L0_ T_R
UH I_R HU RE Q_
UH I_S D_ _IN T_
ST T_I _R
T_ _R
T_
C UT TR IN
UH I_O _C L1_
C PP TR
UH _A _C
)
CI PP
ed
UH I_A
rv
se
C
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
_R T _I ST _S
C X_ S_ G_ R_
C EN A_ F_ ST
C EN K IN T
ST
UH I_S LIN L0_ T_S
AR NT T
UH I_T D_ RE ER
IN T
UH I_S D_ _EO T_
ST T_I _S
T_ _S
T_
X_ AR NT
C UT TR IN
UH I_O _C L1_
C P P TR
UH I_A _C
)
C PP
ed
UH I_A
rv
se
C
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
_R T _I EN _E
UH I_T D_ RE ER A
UH I_S D_ _EO T_ A
C X_ S_ G_ R_
C EN A_ F_ EN
A
AR NT NA
C EN K IN N
IN NA
EN
UH I_S LIN L0_ T_E
ST T_I _E
T_ _E
T_
C UT TR IN
UH I_O _C L1_
C PP TR
UH I_A _C
d)
C PP
ve
UH I_A
r
se
C
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
_R T _I CL _C
UH I_T D_ RE ER R
C EN K IN LR
C X_ S_ G_ R_
C EN A_ F_ CL
R
AR NT LR
IN LR
UH I_S LIN L0_ T_C
CL
UH I_S D_ _EO T_
ST T_I _C
T_ _C
T_
C UT TR IN
UH I_O _C L1_
C PP TR
UH I_A _C
d)
C PP
ve
UH I_A
r
se
C
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
E
E
US
AT
ST
CA
E_
R_
OD
ER
EC
)
X_
ed
_D
_R
rv
se
CI
CI
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)
E
AT
ST
E_
OD
NC
)
ed
_E
rv
se
CI
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
TE
DA
_
CI
UH
31 0
0x2007170 Reset
28.1 Overview
The Serial Peripheral Interface (SPI) is a synchronous serial interface useful for communication with external
peripherals. The ESP32-C6 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.
28.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.
CPU-Controlled Transfer A data transfer that happens between CPU buffer SPI_W0_REG ~
SPI_W15_REG and SPI peripheral.
DMA-Controlled 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 trans-
action can be configured independently.
Slave Segmented Transfer A data transfer controlled by DMA in SPI slave mode. Such transfer
consists of multiple transactions (segments).
Full-duplex The sending line and receiving line between the master and the
slave are independent. Sending data and receiving data happen
at the same time.
Half-duplex Only one side, the master or the slave, sends data, and the other
side receives data. Sending data and receiving data can not hap-
pen simultaneously on one side.
4-line full-duplex 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.
4-line half-duplex 4-line here means: clock line, CS line, and two data lines. The
two data lines can not be used simultaneously.
3-line half-duplex 3-line here means: clock line, CS line, and one data line. The data
line is used to transmit or receive data.
1-bit SPI In one clock cycle, one bit can be transferred.
(2-bit) 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 com-
mand, or one bit of an address, or two bits of data can be trans-
ferred.
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.
(4-bit) 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 com-
mand, or one bit of an address, or four bits of data can be trans-
ferred.
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
address, 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.
28.3 Features
Some of the key features of GP-SPI2 are:
– QPI mode
– Master: up to 80 MHz
– Slave: up to 40 MHz
• Able to communicate with SPI devices, such as a sensor, a screen controller, as well as a flash or RAM
chip
Figure 28-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 7 IO MUX and GPIO Matrix (GPIO, IO MUX).
For more information about the data modes used when GP-SPI2 works as a master or a slave, see Section
28.5.8 and Section 28.5.9, respectively.
Master Slave
FSPI Signal 1-bit SPI 1-bit SPI
2-bit Dual SPI 4-bit Quad SPI QPI 2-bit Dual SPI 4-bit Quad SPI QPI
FD1 3-line HD2 4-line HD FD 3-line HD 4-line 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
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.
7 The two signals are used in parallel.
ESP32-C6 TRM (Version 1.0)
GoBack
28 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.
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
799
ESP32-C6 TRM (Version 1.0)
GoBack
28 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, the data in SPI_W0_REG ∼ SPI_W15_REG may be sent more
than once. Take each 256 bytes as a cycle:
* 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:
* 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 over-
written, 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.
• 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 28.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 28.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 4 GDMA Controller
(GDMA).
• 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 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 28-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.
Figure 28-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. For more information, see Section 28.8.
Figure 28-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.
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 28-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.
• —: 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 28-8. Users can enable QPI mode for
GP-SPI2 by setting the bit SPI_QPI_MODE in register SPI_USER_REG.
Control Registers for 1-bit Control Registers for 2-bit Control Registers for 4-bit
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
Control Registers for 1-bit Control Registers for 2-bit Control Registers for 4-bit
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 28-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.
• 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
28-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 clock (AHB_CLK), APB clock (APB_CLK, see Chapter 8 Reset and Clock) and module
clock (clk_spi_mst) for the GP-SPI2 module.
• Configure SPI CS setup time and hold time according to Section 28.6.
– In DMA-controlled mode,
* configure SPI_DMA_TX_ENA/SPI_DMA_RX_ENA,
* and start GDMA TX/RX engine, as described in Section 28.5.6 and Section 28.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 28.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 28-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 clock (AHB_CLK), APB clock (APB_CLK), and module clock (clk_spi_mst) for the
GP-SPI2 module.
5. Configure SPI CS setup time and hold time according to Section 28.6.
• In DMA-controlled mode,
– configure SPI_DMA_TX_ENA/SPI_DMA_RX_ENA,
– and start GDMA TX/RX engine, as described in Section 28.5.6 and Section 28.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 28-8. Connection of GP-SPI2 to Flash and External RAM in 4-bit Mode
Figure 28-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.
Figure 28-9. SPI Quad I/O Read Command Sequence Sent by GP-SPI2 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 28-10 shows how this feature works.
As shown in Figure 28-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 28-10) for
each CONF state. A GDMA TX link is used to connect all the CONF buffers and TX data buffers (Tx_bufi in
Figure 28-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 clock (AHB_CLK), APB clock (APB_CLK), and module clock (clk_spi_mst) for GP-SPI2
module.
5. Configure SPI CS setup time and hold time according to Section 28.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 same) to save time and chip resources.
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 28-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 28-12 and Table 28-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 28.6 for detailed configuration. The CS high time in each segment is about:
The CS high time in CONF state can be set from 62.5 µs to 3.2768 ms when fAHB_CLK is 80 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.
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 28-14 and Table 28-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:
• 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 28-14 and Table 28-15. Note that DUMMY state is
always in 1-bit mode and lasts for eight SPI_CLK cycles.
Master sends 0x06 CMD (En_QPI) to set GP-SPI2 slave to QPI mode and all the states of supported transfer
will be in 4-bit mode afterwards. If 0xDD CMD (Ex_QPI) is received, GP-SPI2 slave will be back to SPI
mode.
Other transfer types than these described in Table 28-14 and Table 28-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 28.9.
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 28-14 and Table 28-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.
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 28.5.6 and Section 28.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 28.5.6 and Section 28.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.
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 28.5.6 and Section 28.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 28-11 and Figure 28-12 show the recommended CS timing and register configuration to access external
RAM and flash.
Figure 28-11. 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
• 1: PLL_F80M_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 supported input clock frequency (fSPI_CLK ) of GP-SPI2 is fSPI_CLK <=
fAHB_CLK .
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.
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.
The I/O lines are mapped via GPIO Matrix or IO MUX. But there is no timing adjustment in IO MUX. The input
data and output data can be delayed for 1 or 2 IO MUX operating clock cycles at the rising or falling edge in
GPIO matrix. For detailed register configuration, see Chapter 7 IO MUX and GPIO Matrix (GPIO, IO MUX).
Figure 28-15 shows the timing compensation control for GP-SPI2 as master, including the following
paths:
• “CLK”: the output path of GP-SPI2 bus clock. The clock is sent out by SPI_CLK out control module,
passes through GPIO Matrix or IO MUX and then goes to an external SPI device.
• “IN”: data input path of GP-SPI2. The input data from an external SPI device passes through GPIO Matrix
or IO MUX, then is adjusted by the Timing Module and finally is stored into spi_rx_afifo.
• “OUT”: data output path of GP-SPI2. The output data is sent out to the Timing Module, passes through
GPIO Matrix or IO MUX and is then captured by an external SPI device.
Every input and output data is passing through the Timing Module and the module can be used to apply delay
in units of Tclk_spi_mst (one cycle of clk_spi_mst) on rising or falling edge.
Key Registers
Figure 28-16 shows a timing compensation example in GP-SPI2 as master. Note that DUMMY cycle length is
configurable to compensate the delay in I/O lines, so as to enhance the performance of GP-SPI2.
In Figure 28-16, “p1” is the point of input data of Timing Module, “p2” is the point of output data of Timing
Module. Since the input data FSPIQ is unaligned to FSPID, the read data of GP-SPI2 will be wrong without the
timing compensation.
To get the correct read data, follow the settings below. Assuming fclk_spi_mst equals to fSP I_CLK :
When GP-SPI2 works as slave, if the bit SPI_RSCK_DATA_OUT in register SPI_SLAVE_REG is set to 1, the
output data is sent at latch edge, which is half an SPI clock cycle earlier. This can be used for slave mode
timing compensation.
28.9 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_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 28-18 and Table 28-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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
28.11 Registers
The addresses in this section are relative to SPI base address provided in Table 5-2 in Chapter 5 System and
Memory.
N
LE
IT
_B
TE
)
NF
DA
ed
ed
I_ R
CO
UP
SP US
rv
rv
se
se
I_
I_
(re
(re
SP
SP
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. (WT)
• 0: Not synchronize
• 1: Synchronize
• 0: Not enable
• 1: Enable
An SPI operation will be triggered when the bit is set. This bit will be cleared once the operation
is done. Can not be changed by CONF_buf.
31 0
0 Reset
GH RT
RT
HI PA
PA
M I_H LE
O_ H
R_ OS Y_ID
I_ R_ DR ND
XT
IS IG
I_ _S ED E
se TE_ UAD
SP ed) UAL
SP CS ETU GE
GE
_N
SP CS _I_ DG
SP US AD MA
SP US MIS MY
I_ R_ MM
I_ d) ED
I_ d) NF
E
I_ _H P
I_ R_ O
I_ R_ SI
I_ CK _E
D
RI Q
I_ R_ M
I_ R_ M
se K D
OD
N
_
SP US MO
SP US DU
SP US DU
SP rve _I_
SP US CO
SP rve CO
SP RS UT
(re TSC OL
DI
FW E
US M
(re I_M
I_ RIT
)
(re US )
SP ed)
UT
I_ _O
I_ R_
se R_
ed
I_ d
SP rve
(re SIO
SP FW
DO
QP
SP US
SP CK
rv
rv
rv
se
se
se
I_
I_
I_
I_
(re
(re
SP
SP
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
• 0: Disable
• 1: Enable
• 0: Disable
• 1: Enable
This configuration is applicable when the SPI controller works as master or slave. Can be con-
figured in CONF state.
SPI_TSCK_I_EDGE Configures whether or not to change the polarity of TSCK in slave transfer. (R/W)
• 0: TSCK = SPI_CK_I
• 1: TSCK = !SPI_CK_I
SPI_CS_HOLD Configures whether or not to keep SPI CS low when SPI is in DONE state. (R/W)
• 1: Keep low
SPI_CS_SETUP Configures whether or not to enable SPI CS when SPI is in prepare (PREP) state.
(R/W)
• 0: Disable
• 1: Enable
SPI_RSCK_I_EDGE Configures whether or not to change the polarity of RSCK in slave transfer.
(R/W)
• 0: RSCK = !SPI_CK_I
• 1: RSCK = SPI_CK_I
SPI_FWRITE_DUAL Configures whether or not to enable the 2-bit mode of read-data phase in write
operations. (R/W)
• 0: Not enable
• 1: Enable
SPI_FWRITE_QUAD Configures whether or not to enable the 4-bit mode of read-data phase in write
operations. (R/W)
• 0: Not enable
• 1: Enable
SPI_USR_CONF_NXT Configures whether or not to enable the CONF state for the next transaction
(segment) in a configurable segmented transfer. (R/W)
• 0: this transfer will end after the current transaction (segment) is finished. Or this is not a
configurable segmented transfer.
• 1: this configurable segmented transfer will continue its next transaction (segment).
SPI_SIO Configures whether or not to enable 3-line half-duplex communication, where MOSI and
MISO signals share the same pin. (R/W)
• 0: Disable
• 1: Enable
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. (R/W)
• 0: Disable
• 1: Enable
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. (R/W)
• 0: Disable
• 1: Enable
SPI_USR_DUMMY_IDLE Configures whether or not to disable SPI clock in DUMMY state. (R/W)
• 0: Not disable
• 1: Disable
SPI_USR_MOSI Configures whether or not to enable the write-data (DOUT) state of an operation.
(R/W)
• 0: Disable
• 1: Enable
SPI_USR_MISO Configures whether or not to enable the read-data (DIN) state of an operation.
(R/W)
• 0: Disable
• 1: Enable
SPI_USR_DUMMY Configures whether or not to enable the DUMMY state of an operation. (R/W)
• 0: Disable
• 1: Enable
SPI_USR_ADDR Configures whether or not to enable the address (ADDR) state of an operation.
(R/W)
• 0: Disable
• 1: Enable
SPI_USR_COMMAND Configures whether or not to enable the command (CMD) state of an oper-
ation. (R/W)
• 0: Disable
• 1: Enable
NE
EN
D_
EL
EN
EN
CL
R_
CY
TL
ER
E
Y_
BI
_
TI
TI
R_
LL
M
P_
D_
UM
FU
DD
TU
OL
_W
D
A
)
_H
R_
R_
_S
ed
ST
US
US
CS
CS
rv
M
se
I_
I_
I_
I_
I_
(re
SP
SP
SP
SP
SP
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. (R/W)
• 0: Not end
• 1: End
N
_E
N
ND
E
LE
LU
_E
IT
VA
B
RR
D_
D_
E
AN
AN
Y_
PT
M
M
M
M
M
CO
CO
E
_R
d)
R_
R_
ST
ve
US
US
M
r
se
I_
I_
I_
(re
SP
SP
SP
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. (R/W)
• 0: Not end
• 1: End
R
DE
DE
SP rve R_ AD
D_ AD
AL
AL
T
SP rve _D D
L
OU
I_ d UA
se MD UA
OR
SP rve OR
I_ d ) DU
se DD QU
I_ PO OL
DU
EA QU
Y_
(re FC _Q
T_
T_
SP D_ _P
SP HO OL
(re A _
FR D_
Q_ L
L
M
R
BI
I_ MD
)
SP WP )
d)
SP FA )
)
I_ LD
(re PO
(re _B
I_ P
I_ DD
I_ EA
ed
I_ d
ed
ed
M
R_
DU
D
SP FC
SP FR
rv
rv
rv
rv
W
F
se
se
se
se
se
I_
I_
I_
I_
(re
(re
(re
SP
SP
SP
SP
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. (R/W)
• 0: Not output
• 1: Output
SPI_FADDR_DUAL Configures whether or not to enable 2-bit mode during address (ADDR) state.
(R/W)
• 0: Disable
• 1: Enable
SPI_FADDR_QUAD Configures whether or not to enable 4-bit mode during address (ADDR) state.
(R/W)
• 0: Disable
• 1: Enable
SPI_FCMD_DUAL Configures whether or not to enable 2-bit mode during command (CMD) state.
(R/W)
• 0: Disable
• 1: Enable
SPI_FCMD_QUAD Configures whether or not to enable 4-bit mode during command (CMD) state.
(R/W)
• 0: Disable
• 1: Enable
SPI_FREAD_DUAL Configures whether or not to enable the 2-bit mode of read-data (DIN) state in
read operations. (R/W)
• 0: Disable
• 1: Enable
SPI_FREAD_QUAD Configures whether or not to enable the 4-bit mode of read-data (DIN) state in
read operations. (R/W)
• 0: Disable
• 1: Enable
• 0: Low
• 1: High
• 0: Low
• 1: High
• 0: Output low
• 1: Output high
SPI_WP_POL Configures the output value of write-protect signal when SPI is in idle. (R/W)
• 0: Output low
• 1: Output high
• 0: MSB first
• 1: LSB first
SPI_WR_BIT_ORDER Configures the bit order in command (CMD), address (ADDR), and write-data
(MOSI) states. (R/W)
• 0: MSB first
• 1: LSB first
EN
I TL
_B
TA
DA
)
ed
S_
rv
M
se
I_
(re
SP
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
transfer or in CPU-controlled master transfer. Or configures the bit length of SPI RX transfer
in DMA-controlled slave transfer. (R/W)
This value shall be (expected bit_num - 1). Can be configured in CONF state.
OL
ED IVE
L
GE
_P
PO
E_ T
DL AC
CS
_
CS
_I P_
R_
SP CS DIS
S
SP CS DIS
SP CS DIS
SP CS DIS
CS IS
CK EE
E_
DI
SP CS IS
TE
I_ 1_D
I_ d)
I_ _D
I_ 2_
0_
I_ 5_
I_ 4_
I_ 3_
I_ _K
ed
ed
AV
AS
SP rve
SP CS
SP CK
rv
rv
SL
M
se
se
se
I_
I_
I_
(re
(re
(re
SP
SP
SP
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
• 0: Enable
• 1: Disable
SPI_SLAVE_CS_POL Configures whether or not invert SPI slave input CS polarity. (R/W)
• 0: Not change
• 1: Invert
SPI_CK_IDLE_EDGE Configures the level of SPI_CLK line when GP-SPI2 is in idle. (R/W)
• 0: Low
• 1: High
SPI_CS_KEEP_ACTIVE Configures whether or not to keep the SPI_CS line low. (R/W)
• 1: Keep low
S_ _EN
TR C EN
EN
G_ S_ R_
AN LR
SE AN CL
Y
PT
V_ TR _
SL G_ NS
EM
IF LL
SP DM FIF _R T
A_ SE TRA
T F FU
I_ A_ O_ ST
O_
I_ _A FO S
A_ _E T
SP RX AFI O_R
NA
OU O_
DM TX RS
RX NA
_ _
I_ _R SEG
SP SLV X_ N
_E
A_ FIF
I_ F_ IF
I_ _T E
SP SLV OF_
SP BU AF
DM IN
DM X
I_ A_
I_ A_
)
d)
I_ _E
ed
ve
SP DM
SP DM
SP RX
rv
r
se
se
I_
I_
I_
(re
(re
SP
SP
SP
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.
(RO)
• 0: Ready
• 1: Not ready
SPI_DMA_INFIFO_FULL Represents whether or not the DMA RX FIFO is ready for receiving data.
(RO)
• 0: Ready
• 1: Not ready
• 0: Disable
• 1: Enable
• if the size of DMA RX buffer is not 0, the data in following Wr_DMA transactions will be
received.
• if the size of DMA RX buffer is 0, the data in following Wr_DMA transactions will not be
received.
• 1: the data in the following transactions will not be updated, i.e. the old data is transmitted
repeatedly.
• 0: the data in this transaction will not be updated. But in the following transactions,
• 0: Disable
• 1: Enable
SPI_DMA_TX_ENA Configures whether or not to enable DMA-controlled send data transfer. (R/W)
• 0: Disable
• 1: Enable
SPI_RX_AFIFO_RST Configures whether or not to reset spi_rx_afifo as shown in Figure 28-4 and in
Figure 28-5. (WT)
• 0: Not reset
• 1: Reset
SPI_BUF_AFIFO_RST Configures whether or not to reset buf_tx_afifo as shown in Figure 28-4 and
in Figure 28-5. (WT)
• 0: Not reset
• 1: Reset
buf_tx_afifo is used to send data out in CPU-controlled master and slave transfer.
• 0: Not reset
• 1: Reset
A
AT
_D
UE
EN N
N
DM _B N_ N
A_ ITL EN
TL _E
TX
_E
RD A LE E
AL
V_ DM BIT N_
A_
BI EN
_V
M
SL R _ LE
IC
E_ T
I_ FT_ NF _D
I_ _W UF IT
CL OD OU
AG
13
SP SLV DB _B
SP SO CO AIT
M _
E_ ET
OD
SP K_ ATA
I_ _R UF
E
G_
I_ R_ _W
AV ES
OD
M
SP SLV RB
SE
CL _D
SP US FD
SL R
M
I_ _W
A_
)
)
I_ T_
I_ CK
K_
ed
ed
ed
SP SLV
DM
SP MS
SP RS
rv
rv
rv
se
se
se
I_
I_
I_
I_
I_
(re
(re
(re
SP
SP
SP
SP
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
• 0: Not use
• 1: Use
• 0: Not use
• 1: Use
• 0: Not use
• 1: Use
• 0: Not use
• 1: Use
• 0: Master
• 1: Slave
SPI_SOFT_RESET Configures whether to reset the SPI clock line, CS line, and data line via software.
(WT)
• 0: Not reset
• 1: Reset
SPI_USR_CONF Configures whether or not to enable the CONF state of current DMA-controlled
configurable segmented transfer. (R/W)
• 0: No effect, which means the current transfer is not a configurable segmented transfer.
SPI_MST_FD_WAIT_DMA_TX_DATA Configures whether or not to wait DMA TX data gets ready be-
fore starting SPI transfer in master full-duplex transfer. (R/W)
• 0: Not wait
• 1: Wait
D
AN
N
M
LE
R
OM
DD
IT
_B
_C
A
T_
ST
TA
AS
DA
LA
L
V_
V_
V_
SL
SL
SL
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
U_
_L
T_
T_
IV_
NT
EQ
N
)
KD
KC
KC
KC
K_
ed
CL
CL
CL
CL
CL
rv
se
I_
I_
I_
I_
I_
(re
SP
SP
SP
SP
SP
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. (R/W)
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.
EN
)
SP rve )
I_ d)
K_
ed
se d
(re 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
• 0: Disable
• 1: Enable
VE
TI
AC
K_
E
E
CL
E
OD
OD
OD
OD
H
G_
_M
_M
_M
_
)
)
IN
ed
ed
N0
N2
N3
N1
IM
rv
rv
DI
DI
DI
DI
I_T
se
se
I_
I_
I_
I_
(re
(re
SP
SP
SP
SP
SP
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
• 2: Input at the (SPI_DIN0_NUM + 1)th rising edge of clk_hclk plus one clk_spi_mst rising
edge cycle
• 3: Input at the (SPI_DIN0_NUM + 1)th rising edge of clk_hclk plus one clk_spi_mst falling
edge cycle
• 2: Input at the (SPI_DIN1_NUM + 1)th rising edge of clk_hclk plus one clk_spi_mst rising
edge cycle
• 3: Input at the (SPI_DIN1_NUM + 1)th rising edge of clk_hclk plus one clk_spi_mst falling
edge cycle
• 2: Input at the (SPI_DIN2_NUM + 1)th rising edge of clk_hclk plus one clk_spi_mst rising
edge cycle
• 3: Input at the (SPI_DIN2_NUM + 1)th rising edge of clk_hclk plus one clk_spi_mst falling
edge cycle
• 2: Input at the (SPI_DIN3_NUM + 1)th rising edge of clk_hclk plus one clk_spi_mst rising
edge cycle
• 3: Input at the (SPI_DIN3_NUM + 1)th rising edge of clk_hclk plus one clk_spi_mst falling
edge cycle
• 0: Disable
• 1: Enable
UM
UM
UM
UM
_N
_N
_N
_N
)
ed
N0
N2
N3
N1
rv
DI
DI
DI
DI
se
I_
I_
I_
I_
(re
SP
SP
SP
SP
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. (R/W)
SPI_DIN1_NUM Configures the delays to input signal FSPIQ based on the setting of
SPI_DIN1_MODE. (R/W)
SPI_DIN2_NUM Configures the delays to input signal FSPIWP based on the setting of
SPI_DIN2_MODE. (R/W)
SPI_DIN3_NUM Configures the delays to input signal FSPIHD based on the setting of
SPI_DIN3_MODE. (R/W)
UT MO E
E
SP DO 2_ ODE
0_ DE
DO 1_ D
OD
I_ UT MO
M
I_ UT M
SP DO 3_
)
I_ UT
ed
SP DO
rv
se
I_
(re
SP
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
• 1: Output with a delay of a SPI module clock cycle at its falling edge
• 1: Output with a delay of a SPI module clock cycle at its falling edge
• 1: Output with a delay of a SPI module clock cycle at its falling edge
• 1: Output with a delay of a SPI module clock cycle at its falling edge
_E A
NA
NT N
EN NA
_I E
NA RR NT_
T_ E
A
A
IN T_
EN
R_ _IN
_E E _I
SP SLV R_ F_ NE A NT_
E R RR
I_ _C 9 T_ E_ _E
I_ _C 8 T_ A _E
I_ _R B _IN DO A
I_ _W BU DO EN _I
I_ _C A D E_ E
SP SLV D_ MA NE INT_
SP SLV R_ NE S_ EN
SP SE ) ERR WF TY_
L _ _E
SP SLV D_ UF_ T_ NE
U L TY
I_ _W O N T_
I_ d _ O_ P
A_ UTF INT NA
FI O_ NA
I_ _R D DO _
SP rve MD FIF REM
_F MP
N
I_ _E QP _ A
I_ _E 7_ T_ A
SP DM X_ I_ ENA
SP LV N_ INT N
DM O I_ _E
SP SLV _D TR _I
SP SLV MD _IN EN
IN IF _E
E
FO E
I_ NS G_ RR
I_ A_ QP INT
se _C _A _
I_ T_ AF A
A
(re SLV RX IFO
SP MS _IN ENA
SP RA E _E
SP MS TX_ EN
I_T A_ GIC
I_ T_ T_
I_ P2 T_
SP DM MA
SP AP IN
S
I_ P1_
)
I_ G_
ed
SP AP
rv
S
se
I_
(re
SP
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
T_ R
R
IN CL
CL LR
CL
LR RR_ NT_
T_ C
R
R
IN T_
CL
R_ _IN
_C E _I
SP SLV R_ F_ NE R NT_
SP SLV MD IN CL INT LR
LR
NT L_ R
SP SLV MD A_ ON T_ R
SP SLV MD _IN ON INT LR
_I UL ER
ER RR
I_ _C 9_ T_ E_ _C
I_ _C 8 T_ R _C
I_ _C DM _D _I C
I_ _W BU DO CL _I
I_ _C A D E_ C
I_ _R BU _IN DO R
SP SLV D_ MA NE INT_
SP SE ) ERR WF TY_
L _ _E
SP SLV R_ NE S_ CL
SP SLV D_ F_ T_ NE
UL TY
N
I_ _W O N T_
I_ d _ O_ P
A_ UTF INT LR
FI O_ LR
I_ _R D DO _
SP rve MD FIF REM
_F MP
N
SP LV N_ INT LR
SP SLV MD _IN CLR
SP DM X_ I_ LR
DM O I_ _C
SP SLV _D TR _I
IN IF _C
C
FO E
I_ NS G_ RR
I_ _E QP _C
I_ A_ QP INT
I_ _E 7_ T_
se _C _A _
I_ T_ A R
A
(re SLV RX FIFO
SP MS _IN CLR
SP RA E _E
SP MS TX_ CL
I_T A_ GIC
I_ T_ T_
I_ P2 T_
SP DM MA
SP AP IN
S
I_ P1_
)
I_ G_
ed
SP AP
rv
S
se
I_
(re
SP
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
T_ W
W
RA AW
IN RA
RA
AW RR_ NT_
T_ R
W
W
IN T_
RA
R_ _IN
_R E _I
SP SLV MD A_ ON T_ W
SP SLV MD _IN ON INT AW
NT L_ R
A
_I UL ER
ER RR
I_ _C 9 T_ E_ _R
I_ _C 8 T_ W _R
I_ _R BU _IN DO W
I_ _C DM _D _I R
I_ _W BU DO RA _I
I_ _C A D E_ R
SP SLV D_ MA NE INT_
SP SE ) ERR WF TY_
SP SLV R_ NE S_ RA
L _ _E
SP SLV D_ F_ T_ NE
UL TY
N
I_ _W O N T_
A_ UTF INT AW
I_ d _ O_ P
FI O_ AW
I_ _R D DO _
I_ _E QP _ W
I_ _E 7_ T_ W
SP rve MD FIF REM
_F MP
N
SP DM X_ I_ RAW
DM O I_ _R
SP SLV _D TR _I
SP LV N_ INT A
SP SLV MD _IN RA
IN IF _R
R
FO E
I_ NS G_ RR
I_ A_ QP INT
se _C _A _
I_ T_ AF W
SP MS _IN RAW
A
(re SLV RX IFO
SP RA E _E
SP MS TX_ RA
I_T A_ GIC
I_ T_ T_
I_ P2 T_
SP DM MA
SP AP _IN
S
)
I_ G_
ed
I_ P1
SP AP
rv
S
se
I_
(re
SP
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
SPI_APP2_INT_RAW The raw interrupt status of SPI_APP2_INT interrupt. The value is only con-
trolled 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)
NT T
T
_I S
ST T
_S
T RR NT_
T_ S
IN T_
ST
R_ _IN
_S E _I
T_
NT L_ R
SP SLV MD IN ST INT T
T
I_ _W BU DO ST _IN
_I UL ER
I_ _C DM _D _I ST
ER RR
SP SLV MD _IN ON INT T
I_ _C 9_ T_ E_ _S
_S
I_ _C A D E_ S
SP LV _ A NE T_
SP SE ) ERR WF TY_
L_ _E
SP SLV MD A_ ON NT_
SP SLV R_ NE S_ _ST
SP SLV D_ UF_ T_ NE
UL TY
I_ _R B _IN DO
I_ d _ O_ P
I_ _W O N T
I_ _R DM DO _I
SP rve MD FIF REM
_F MP
N
A_ UTF INT T
FI O_ T
SP SLV R_ F_ NE
DM O I_ _S
SP SLV _D TR _I
SP LV N_ INT T
IN IF _S
SP SLV MD _IN ST
SP DM X_ I_ T
S
FO E
I_ NS G_ RR
I_ _E QP _S
I_ A_ QP INT
I_ _E 7_ T_
I_ _C 8 T_
se _C _A _
A
(re SLV RX FIFO
SP RA E _E
SP MS TX_ ST
SP MS _IN ST
I_T A_ GIC
I_ T_ T_
I_ P2 T_
I_ T_ A
SP DM MA
SP AP _IN
D
)
I_ G_
ed
I_ P1
SP AP
rv
S
se
I_
(re
SP
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
_S T
ET
NT E
SE ET
_I S
ET RR NT_
T_ S
T
T
IN T_
SE
R_ _IN
_S E _I
SP SLV R_ F_ NE T NT_
SP SLV MD IN SE INT ET
ET
NT L_ R
SP SLV MD A_ ON T_ T
SP SLV MD _IN ON INT ET
I_ _C DM _D _I SE
_I UL ER
ER RR
I_ _C 9_ T_ E_ _S
I_ _C 8 T_ T _S
I_ _W BU DO SE _I
I_ _R B _IN DO T
I_ _C A D E_ S
SP SLV D_ MA NE INT_
SP SE ) ERR WF TY_
L _ _E
SP SLV R_ NE S_ SE
SP SLV D_ UF_ T_ NE
UL TY
N
I_ _W O N T_
I_ d _ O_ P
A_ UTF INT ET
FI O_ ET
I_ _R D DO _
SP rve MD FIF REM
_F MP
N
I_ _E QP _S T
SP SLV MD _IN SET
SP DM X_ I_ ET
DM O I_ _S
SP SLV _D TR _I
SP LV N_ INT E
IN IF _S
S
FO E
I_ NS G_ RR
I_ A_ QP INT
I_ _E 7_ T_
se _C _A _
I_ T_ AF T
A
(re SLV RX IFO
SP RA E _E
SP MS _IN SET
SP MS TX_ SE
I_T A_ GIC
I_ T_ T_
I_ P2 T_
SP DM MA
SP AP _IN
S
)
I_ G_
ed
I_ P1
SP AP
rv
S
se
I_
(re
SP
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
31 0
0 Reset
E
ed
AT
rv
_D
se
I
(re
SP
31 28 27 0
0 0 0 0 0x2201300 Reset
29.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. The I2C bus can be connected to a single or multiple master devices and a single or multiple
slave devices. However, only one master device can access a slave at a time via the bus.
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. The master and the slave can send
or receive data according to the R/W bit. Whether to terminate the data transfer or not is determined by the
logic level of the acknowledge (ACK) bit. During data transfer, SDA changes only when SCL is low. Once 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 a RSTART condition, a slave address and a
R/W bit before changing its operation. The RSTART condition is used to change the transfer direction and the
mode of the devices (master mode or slave mode).
29.2 Features
The I2C controller of ESP32-C6 has the following features:
• Dual address mode, which uses slave address and slave memory or register address
The I2C controller runs either in master mode or slave mode, which is determined by I2C_MS_MODE. Figure
29-1 shows the architecture of a master, while Figure 29-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
29-3 and Figure 29-4 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 which generates I2C clocks, and a synchronization
module which 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 29-3. I2C Protocol Timing (Cited from Fig.31 in The I2C-bus specification Version 2.1)
Figure 29-4. I2C Timing Parameters (Cited from Table 5 in The I2C-bus 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.
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 than the FIFO depth,
which is 32 bytes in ESP32-C6 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 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 disabled by setting the I2C_SLAVE_SCL_STRETCH_CLR bit.
29.4.5 Synchronization
I2C registers are configured in APB_CLK domain, whereas the I2C controller is configured in 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 29-1.
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 29-5 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 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:
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 amount 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.
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 29-6, 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.
• 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 completed, and the CMD_Controller
stops executing commands. Once software refreshes data in command registers and the RAM, the
CMD_Controller can be restarted to execute commands from command register 0 again.
• RSTART: op_code = 6. The I2C controller sends a START bit or a 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 acknowledgement 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. 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 with 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 into 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, 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, 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, software continues reading from I2C_DATA_REG (slave).
Define the slave address as 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 address, which comprises
SLV_ADDR[6:0] and a R/W bit. In 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 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.
The design differences between LP_I2C and I2C master are as follows:
• The size of TX/RX RAM in LP_I2C is 16*8 bit, which means the TX�RX FIFO depth is 16 bytes.
• The clock source of APB_CLK in LP_I2C is CLK_AON_FAST. Configure LP_I2C_SCLK_SEL to select the
clock source for I2C_SCLK. When LP_I2C_SCLK_SEL is 0, select CLK_ROOT_FAST as clock source, and
when LP_I2C_SCLK_SEL is 1, select CLK _XTALD2 as the clock source. Configure LP_EXT_I2C_CK_EN
high to enable the clock source of I2C_SCLK. Adjust the timing registers accordingly when the clock
frequency changes.
See the programming examples of ESP32-C6 I2Cslave in 29.6 for that of LP_I2C.
29.6.1 I2Cmaster Writes to I2Cslave with a 7-bit Address in One Command Sequence
29.6.1.1 Introduction
Figure 29-7 shows how I2Cmaster writes N bytes of data to I2Cslave registers or RAM using 7-bit addressing. As
shown in figure 29-7 , 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 send 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 29.4.7.
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 29.4.10.
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 take 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 29.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 29.4.10.
If 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 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.
29.6.2 I2Cmaster Writes to I2Cslave with a 10-bit Address in One Command Sequence
29.6.2.1 Introduction
Figure 29-8 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 29.6.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.
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).
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 take I2Cslave
as 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 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 29.4.10.
11. If 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 29.4.10.
If 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 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.
29.6.3 I2Cmaster Writes to I2Cslave with Two 7-bit Addresses in One Command Sequence
29.6.3.1 Introduction
Figure 29-9 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 29.6.1, except that
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 29-9). 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 staring 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.
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 take I2Cslave
as 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 29.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 software has finished reading, you can set
14. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
29.6.4 I2Cmaster Writes to I2Cslave with a 7-bit Address in Multiple Command Sequences
29.6.4.1 Introduction
Figure 29-10. I2Cmaster Writing to I2Cslave with a 7-bit 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 29-10 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, 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 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 29.4.10.
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 ACK value and take I2Cslave
as 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.
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 transfer and repeat step 9.
14. If the command is a STOP, I2C stops 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.
29.6.5 I2Cmaster Reads I2Cslave with a 7-bit Address in One Command Sequence
29.6.5.1 Introduction
Figure 29-11 shows how I2Cmaster reads N bytes of data from an I2C slave using 7-bit addressing. cmd1 is a
WRITE command, and when this command 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 acknowledgements according to ack_value defined in the READ command upon receiving
a byte.
As illustrated in Figure 29-11, 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.
I2Cmaster writes received data into the controller RAM from addr0, whose original content (a the address of
I2Cslave and a R/W bit) is overwritten by byte0 marked red in Figure 29-11.
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, software should write data
to be sent to I2Cslave ’s TX RAM before I2Cmaster initiates transfer. Configuration below is applicable to
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 29.4.10.
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 take I2Cslave
as 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
29.4.10.
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 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 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.
29.6.6 I2Cmaster Reads I2Cslave with a 10-bit Address in One Command Sequence
29.6.6.1 Introduction
Figure 29-12 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 a 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 29.6.2.
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, software should write data
to be sent to I2Cslave ’s TX RAM before I2Cmaster initiates transfer. Configuration below is applicable to
scenario where I2C_SLAVE_SCL_STRETCH_EN (slave) is 1.
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 take I2Cslave
as 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 a 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.
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
29.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 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 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.
29.6.7 I2Cmaster Reads I2Cslave with Two 7-bit Addresses in One Command Sequence
29.6.7.1 Introduction
Figure 29-13. I2Cmaster Reading N Bytes of Data from addrM of I2Cslave with a 7-bit Address
Figure 29-13 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 a 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, software should write data
to be sent to I2Cslave ’s TX RAM before I2Cmaster initiates transfer. Configuration below is applicable to
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 29.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 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 ACK value and take I2Cslave
as 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.
12. I2Cslave receives memory address sent by I2Cmaster and adds the offset.
13. I2Cmaster sends a RSTART and the third byte in TX RAM, which is ((0x78 | I2C_SLAVE_ADDR[9:8])«1) and a
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
29.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 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 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.
29.6.8 I2Cmaster Reads I2Cslave with a 7-bit Address in Multiple Command Sequences
29.6.8.1 Introduction
Figure 29-14 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 29-11, 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
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, software should write data
to be sent to I2Cslave ’s TX RAM before I2Cmaster initiates transfer. Configuration below is applicable to
scenario where I2C_SLAVE_SCL_STRETCH_EN (slave) is 1.
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 take I2Cslave
as 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
29.4.10.
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 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 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 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 transfer and generates an I2C_TRANS_COMPLETE_INT (master) interrupt.
21. If the last command is an END, then repeat step 16 and proceed on to the next steps.
24. I2Cmaster executes the STOP command to stop transfer, and generates an I2C_TRANS_COMPLETE_INT
(master) interrupt.
29.7 Interrupts
• I2C_SLAVE_STRETCH_INT: Generated when one of the four stretching events occurs in slave mode.
• I2C_DET_START_INT: Triggered when the master or the slave detects a START signal.
• 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_RXFIFO_UDF_INT: Triggered when the I2C controller reads RX FIFO via the APB bus, but RX FIFO is
empty.
• I2C_TXFIFO_OVF_INT: Triggered when the I2C controller writes TX FIFO via the APB bus, but TX FIFO is
full.
• I2C_NACK_INT: Triggered when the ACK value received by the master is not as expected, or when the
ACK value received by the slave is 1.
• I2C_TIME_OUT_INT: Triggered when SCL stays high or low for more than 2I2C_T IM E_OU T _V ALU E clock
cycles during data transfer.
• I2C_ARBITRATION_LOST_INT: Triggered when the SDA’s output value does not match its input value
while the master’s SCL is high.
• I2C_END_DETECT_INT: Triggered when op_code of the master indicates an END command and an END
condition is detected.
• I2C_TXFIFO_WM_INT: I2C TX FIFO watermark interrupt. Triggered when I2C_FIFO_PRT_EN is 1 and the
pointers of TX FIFO are less than I2C_TXFIFO_WM_THRHD[4:0].
• I2C_RXFIFO_WM_INT: I2C RX FIFO watermark interrupt. Triggered when I2C_FIFO_PRT_EN is 1 and the
pointers of RX FIFO are greater than I2C_RXFIFO_WM_THRHD[4:0].
• I2C_SLAVE_ADDR_UNMATCH_INT: Triggered when the received slave address is inconsistent with the
internally configured slave address in slave mode.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
OD
E RI
_P
W
LO
)
L_
ed
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 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
M
TI
D_
L
HO
)
A_
ed
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
I2C_SDA_HOLD_TIME Configures the time to hold the data after the falling edge of SCL.
Measurement unit: i2c_sclk
(R/W)
A_
ed
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
D
R IO
PE
OD
H_
I
ER
G
HI
_P
T_
GH
AI
HI
W
d)
L_
L_
ve
SC
SC
r
se
C_
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
I M
_T
LD
O
_H
ART
ST
)
L_
ed
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_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)
E
I M
_T
UP
ET
_S
RT
TA
RS
)
L_
ed
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_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
T IM
D_
OL
H
OP_
ST
)
L_
ed
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
L_
ed
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)
C
I2
O_
_T
ST
d)
L_
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
2C
I
O_
_T
ST
N_
AI
M
)
L_
ed
SC
rv
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
EN N
T_ _E
C_ M PG _S HE N
I2 FS _U TO _C G_E
I2 AR RS ATE TAR CK
FO E_ EV L
C_ N AU W IN
RC OU EL
A_ RC _L VE
I2 CO X_ IT_R ST
SD FO CL LE
T
E_ T
EN
A
OU
C_ L_ _S _
C_ _T B C
C_ N F T
I2 X N N_
I2 SC LE ACK
I2 S S_S RST
I2 SLV _10 AD
I2 RX O RT
I2 TRA B_ IRS
O
A
C_ DR RO
C_ _F DE
I
C_ M _
C_ L F
C_ _ T
C_ K_ TI
C_ BI T
I2 TX_ SB_
I2 SA ULL
I2 CL RA
I2 AD _B
M
S
T
P
)
_
C_ DR
C_ _L
ed
I2 AD
rv
M
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 the
rx_fifo_cnt has reached the threshold.
(R/W)
I2C_TRANS_START Configures whether the slave starts sending the data in txfifo.
0: No effect
1: Start (WT)
I2C_TX_LSB_FIRST Configures 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)
E
LU
N
VA
E
T_
T_
OU
OU
E_
E_
)
ed
M
rv
TI
TI
se
C_
C_
(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 high or low level.
The actual period is 2^(reg_time_out_value).
Measurement unit: i2c_sclk
(R/W)
R
DD
BI
10
_A
R_
E
)
ed
AV
DD
rv
SL
A
se
C_
C_
(re
I2
I2
31 30 15 14 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_ADDR_10BIT_EN Configures to enable the slave 10-bit addressing mode in master mode.
0: No effect
1: Enable
(R/W)
EN
HD
HD
EN G_
HR
HR
O_ F
_T
IF _C
_T
NO _A ST
I2 RX IFO EN
I2 FIF IFO ST
M
M
NF DDR
C_ O _R
C_ F T_
C_ _F _R
_W
_W
I2 TX_ PR
FO
FO
d)
_
C_ O
FI
FI
ve
I2 FIF
RX
TX
r
se
C_
C_
C_
(re
I2
I2
I2
31 15 14 13 12 11 10 9 5 4 0
I2C_RXFIFO_WM_THRHD Configures the water mark threshold of RXFIFO in nonfifo access mode.
When I2C_FIFO_PRT_EN is 1 and RX FIFO counter is bigger than I2C_RXFIFO_WM_THRHD[4:0],
I2C_RXFIFO_WM_INT_RAW bit will be valid. (R/W)
I2C_TXFIFO_WM_THRHD Configures the water mark threshold of TXFIFO in nonfifo access mode.
When I2C_FIFO_PRT_EN is 1 and TC FIFO counter is bigger than I2C_TXFIFO_WM_THRHD[4:0],
I2C_TXFIFO_WM_INT_RAW bit will be valid. (R/W)
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 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)
ES
ES
HR
HR
ER N
N
LT E
_E
_T
_T
FI R_
ER
ER
L_ LTE
LT
LT
SC FI
FI
FI
)
C_ A_
A_
L_
ed
I2 SD
SD
SC
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)
M
NU
EN
V_
V_
SL
SL
PD N
N
L _ _E
_E
T_
T_
SC PD
RS
RS
)
C_ A_
L_
L_
ed
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 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)
RE H _ N
H_ R
EN
TC CL
ST TC _E
M
NU
L _ RE TL
E_ L_ CK L
AV SC _A _LV
T_
SC ST _C
EC
SL E_ TE CK
OT
C_ AV Y A
I2 SL E_B TE_
PR
H_
C_ AV Y
I2 SL E_B
TC
d)
RE
C_ AV
ve
ST
I2 SL
r
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 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 happens.
The stretch cause can be seen in I2C_STRETCH_CAUSE.
0: Disable
1: Enable
(R/W)
I2C_SLAVE_BYTE_ACK_CTL_EN Configures to enable the function for slave to control ACK level.
0: Disable
1: Enable
(R/W)
I2C_SLAVE_BYTE_ACK_LVL Set the ACK level when slave controlling ACK level function enables.
0: Low level
1: High level
(R/W)
T
AS
L
ED
E_
ST
se B_ SY SS
AT
US
LA
(re AR BU DRE
ST
CA
E_
NT
T
N_
SP RW
N
C_ d ST
H_
EC
C_ S_ D
AT
_C
_C
AI
I2 BU E_A
I2 rve LO
ST
TC
_R
RE E_
M
FO
FO
)
I2 SL )
L_
L_
RE
ed
ed
ed
ed
C_ AV
C_ AV
FI
FI
SC
SC
RX
ST
rv
rv
rv
rv
I2 SL
TX
se
se
se
se
C_
C_
C_
C_
C_
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)
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
OI
DR
DR
DR
_P
AD
AD
AD
AD
W
_W
_R
W
_R
_R
O_
FO
FO
FO
E
)
IF
AV
ed
ed
FI
FI
XF
F
RX
rv
rv
SL
TX
TX
R
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 RXFIFO. (RO)
I2C_RXFIFO_WADDR Represents the offset address of i2c module receiving data and writing to
RXFIFO. (RO)
I2C_TXFIFO_RADDR Represents the offset address of i2c module reading from TXFIFO. (RO)
I2C_TXFIFO_WADDR Represents the offset address of APB bus writing to TXFIFO. (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)
A
AT
RD
)
O_
ed
IF
rv
F
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
W
RA
I2 SC MA _IN _IN RAW T_
W
RX O_ F_ T_ IN AW
I2 RX DE S_ OST _R W
T W A
C_ CK V IN W AW
N
C_ FI TE D _ AW
C_ D_ A L NT RA
FI WM IN RA T_R
C_ FI TO _T W W
C_ IF OV IN E_ R
C_ L_ R C T_ _I
I2 AR TXF MP RAW W
C_ N T NT AW
M T_ W
AW
A
C_ E T W W
C_ T_ T L AT
NT W
C_ L_ IN T T
I
C_ IF UD T IN
C_ TE TI D _I
C_ T_ O _ R
_W _IN _RA
I2 TIM S_S RA _RA
_I RA
I2 MS S_C INT T_
I2 DE E_S CAL NM
_R
I2 BY RA O_U TE
FO _ O
_ N
_
T
H
_
C_ BI IF LE
C_ AV L_ U
C_ N T _I
I2 SL RA DR_
I2 TRA OU RT
N
R
_ A
_
T
C_ NE D
I2 GE E_A
FO
T
)
F
C_ AV
ed
rv
I2 SL
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 1 0 Reset
R
CL
I2 SC MA _IN _IN CLR T_
R
RX O_ F_ T_ IN LR
I2 RX DE S_ OST _C R
T R L
N
C_ CK V IN R LR
C_ D_ A L NT CL
FI WM IN CL T_C
C_ FI TE D _ LR
C_ IF OV IN E_ C
C_ L_ R C T_ _I
C_ FI TO _T R R
I2 NA O_O F_ CL T_C
I2 AR TXF MP LR R
N
C L
C_ N T NT LR
C_ T_ T L AT
M T_ R
C_ L_ IN T T
LR
I
C_ E T R R
C_ IF UD T IN
NT LR
C_ TE TI D _I
C_ T_ O _ C
_W _IN _CL
I2 TIM S_S CL _CL
I2 MS S_C INT T_
I2 DE E_S CAL NM
_C
I2 BY RA O_U TE
C
FO _ O
_ N
_
T
H
_
C_ BI IF LE
C_ AV L_ U
C_ N T _I
I2 SL RA DR_
I2 TRA OU RT
_I
N
R
_ A
_
T
C_ NE D
I2 GE E_A
FO
T
)
F
C_ AV
ed
rv
I2 SL
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
A
EN
I2 SC MA _IN _IN ENA T_
A NA
RX O_ F_ T_ IN NA
I2 RX DE S_ OST _EN A
N
C_ D_ A L NT EN
FI WM IN EN T_E
I A
C_ FI TO _T A A
C_ L_ R C T_ _I
C_ IF OV IN E_ E
C_ CK V IN A N
I2 RX ST_ _ST EN _EN
I2 AR TXF MP ENA A
N
C_ T_ O _ EN
C_ N T NT NA
M T_ A
C_ T_ T L AT
NA
C_ L_ IN T T
C_ E T A A
NT A
C_ IF UD T IN
C_ FI TE D _
C_ TE TI D _I
_W _IN _EN
I2 TIM S_S EN _EN
_I EN
I2 MS S_C INT T_
I2 DE E_S CAL NM
I2 BY RA O_U TE
_E
FO _ O
_ N
_
T
H
T
_
C_ BI IF LE
C_ AV L_ U
C_ N T _I
I2 SL RA DR_
I2 TRA OU RT
N
R
_ A
_
T
C_ NE D
I2 GE E_A
FO
T
)
F
C_ AV
ed
rv
I2 SL
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
ST
I2 SC MA _IN _IN ST T_
T
N
RX O_ F_ T_ IN T
C_ D_ A L NT ST
FI WM IN ST T_S
C_ IF OV IN E_ S
C_ L_ R C T_ _I
I2 RX DE S_ OST _ST
I2 TXF O_ CT_ ON NT_
I2 RX ST_ _ST ST _ST
I2 NA O_O F_ ST T_S
N
C_ T_ O _ ST
C_ T_ T L AT
C_ L_ IN T T
I
C_ IF UD T IN
C_ FI TE D _
C_ TE TI D _I
C_ N T NT T
_W _IN _ST
T
I2 TIM S_S ST _ST
_I ST
I2 MS S_C INT T_
I2 DE E_S CAL NM
_S
I2 Y A _U E
I2 AR TXF MP T
TR O T
M T_
_ N
S
_
T
H
T
_
NT
C_ FI TO _T
C_ BI IF LE
C_ AV L_ U
C_ CK V IN
C_ N T _I
I2 SL RA DR_
I2 TRA OU RT
N
R
_ A
_
T
C_ NE D
C_ E T
I2 GE E_A
FO
)
F
C_ AV
ed
rv
I2 SL
B
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
E
ON
_D
D0
D0
AN
AN
M
M
d)
M
M
ve
CO
CO
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
D1
AN
AN
M
M
)
ed
M
M
CO
CO
rv
se
C_
C_
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
ON
_D
D2
D2
AN
AN
M
M
)
ed
M
M
CO
CO
rv
se
C_
C_
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D3
AN
AN
M
M
)
ed
M
M
CO
CO
rv
se
C_
C_
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
ON
_D
D4
D4
AN
AN
M
M
)
ed
M
M
CO
CO
rv
se
C_
C_
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D5
AN
AN
M
M
)
ed
M
M
CO
CO
rv
se
C_
C_
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
ON
_D
D6
D6
AN
AN
M
M
)
ed
M
M
CO
CO
rv
se
C_
C_
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
D7
AN
AN
M
M
)
ed
M
M
CO
CO
rv
se
C_
C_
(re
I2
I2
31 30 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0x2201172 Reset
R
DD
_A
RT
TA
_S
FO
FI
TX
C_
I2
31 0
0 Reset
R
DD
_A
RT
TA
_S
IFO
R XF
C_
I2
31 0
0 Reset
D
IO
ER
_P
W
LO
L_
SC
)
ed
C_
rv
2
se
_I
(re
LP
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
LP_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
O
_H
DA
)
ed
_S
rv
2C
se
_I
(re
LP
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
LP_I2C_SDA_HOLD_TIME Configures the time to hold the data after the falling edge of SCL.
Measurement unit: i2c_sclk
(R/W)
E
M
TI
E_
PL
AM
_S
DA
)
ed
_S
rv
2C
se
_I
(re
LP
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
D
IO
ER
OD
_P
RI
GH
E
HI
_P
T_
GH
AI
I
_W
_H
CL
CL
d)
_S
_S
ve
2C
2C
r
se
_I
_I
(re
LP
LP
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
LP_I2C_SCL_HIGH_PERIOD Configures for how long SCL remains high in master mode.
Measurement unit: i2c_sclk
(R/W)
LP_I2C_SCL_WAIT_HIGH_PERIOD Configures the SCL_FSM’s waiting period for SCL high level in
master mode.
Measurement unit: i2c_sclk
(R/W)
E
I M
_T
LD
O
_H
A RT
ST
L_
SC
)
ed
C_
rv
2
se
_I
(re
LP
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
LP_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)
E
IM
_T
UP
ET
S
T_
AR
ST
_R
CL
d)
_S
ve
2C
r
se
_I
(re
LP
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
LP_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
M
TI
D_
HOL
O P_
ST
L_
SC
)
ed
C_
rv
2
se
_I
(re
LP
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
E
M
TI
P_
TU
SE
P_
TO
_S
CL
)
ed
_S
rv
2C
se
_I
(re
LP
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
LP_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)
I 2C
O_
_T
ST
L_
SC
)
ed
C_
rv
2
se
_I
(re
LP
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
_S
rv
2C
se
_I
(re
LP
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
LE EL
L
VE
L_ EV
N
SC _L
_E
LP rve AN _F T
LP 2C_ RBI ST TE
ed LE_ CK
ST T
T
se TR SB IRS
_I R EN ON
_I d S_ IRS
AR
_I A _R A
P A
LP 2C_ SM UPG
M L_
(re C_ L F
LP 2C_ LK_ ATI
_
_I TX SB
SA L
_I C TR
_I F F_
F U
LP 2C_ X_L
LP 2C_ ON
2C X_
_
)
LP 2C_ )
)
ed
_I C
_I R
LP 2C_
_
rv
rv
2
se
se
_I
(re
(re
LP
31 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 Reset
LP_I2C_RX_FULL_ACK_LEVEL Configures the ACK value that needs to be sent by master when
the rx_fifo_cnt has reached the threshold. (R/W)
E
LU
EN
VA
T_
T_
OU
OU
E_
E_
IM
IM
d)
_T
_T
ve
2C
2C
r
se
_I
_I
(re
LP
LP
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
LP_I2C_TIME_OUT_VALUE Configures the timeout threshold period for SCL stucking at high or low
level. The actual period is 2^(reg_time_out_value).
Measurement unit: i2c_sclk.
(R/W)
HD
HD
HR
HR
_T
_T
ST
LP rve X_F _R N
_I d IF ST
N
se R IFO E
M
_E
M
(re 2C_ ) O_R
(re 2C_ _F RT_
W
W
) IFO
O_
O_
_I TX _P
ed F
IF
IF
rv N
LP 2C_ IFO
XF
XF
se NO
)
)
ed
ed
_R
_I F
_T
LP 2C_
rv
rv
2C
2C
se
se
_I
_I
_I
(re
(re
LP
LP
LP
31 15 14 13 12 11 10 9 8 5 4 3 0
LP_I2C_FIFO_PRT_EN Configures 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)
ES
ES
HR
HR
ER N
N
ILT _E
_E
_T
_T
_F ER
ER
ER
CL ILT
ILT
ILT
_S _F
_F
_F
2C DA
DA
CL
d)
_I S
_S
_S
ve
LP 2C_
2C
2C
r
se
_I
_I
_I
(re
LP
LP
LP
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
N
_N
_E
LV
LV
S
_S
T_
ST
RS
_R
_
CL
L
SC
)
ed
_S
se d
ed
C_
rv
re rve
2C
rv
2
se
_I
_I
se
(re
LP
LP
re
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
LP_I2C_SCL_RST_SLV_EN Configures to send out SCL pulses when I2C master is IDLE. The number
of pulses equals to LP_I2C_SCL_RST_SLV_NUM[4:0]. (R/W/SC)
ST
LA
E_
T
AT
AS
ST
_L
NT
T
N_
TE
B_ SY
CN
ST
C
_C
AI
RE
TA
FO
_S
P_
IF
FI
2C US
ES
CL
CL
XF
X
)
d)
d)
LP ed)
_I B
ed
ed
ed
_R
_R
_S
_S
_T
ve
ve
LP 2C_
rv
rv
rv
rv
2C
2C
2C
2C
2C
r
r
se
se
se
se
se
se
_I
_I
_I
_I
_I
_I
(re
(re
(re
(re
(re
LP
LP
LP
LP
LP
31 30 28 27 26 24 23 22 18 17 13 12 8 7 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LP_I2C_RESP_REC Represents the received ACK value in master mode or slave mode.
0: ACK
1: NACK
(RO)
LP_I2C_ARB_LOST Represents whether the I2C controller loses control of SCL line.
0: No arbitration lost
1: Arbitration lost
(RO)
LP_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
R
DD
AD
AD
AD
_W
_R
_W
_R
FO
FO
FO
FO
FI
FI
FI
FI
RX
X
)
d)
d)
)
X
TX
ed
ed
_R
_T
ve
ve
C_
C_
rv
rv
2C
2C
r
r
2
2
se
se
se
se
_I
_I
_I
_I
(re
(re
(re
(re
LP
LP
LP
LP
31 19 18 15 14 13 10 9 8 5 4 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LP_I2C_RXFIFO_RADDR Represents the offset address of the APB reading from RXFIFO (RO)
LP_I2C_RXFIFO_WADDR Represents the offset address of i2c module receiving data and writing to
RXFIFO. (RO)
LP_I2C_TXFIFO_RADDR Represents the offset address of i2c module reading from TXFIFO. (RO)
LP_I2C_TXFIFO_WADDR Represents the offset address of APB bus writing to TXFIFO. (RO)
TA
DA
_R
FO
)
FI
ed
C_
rv
2
se
_I
(re
LP
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
W
XF _W _I _R T_ W
_I R D NS OS T_ W
IF M NT AW RA
W
2C F _O T_ E T_
_I A TX M RA AW
_I E _T ON F_ NT
_I N O DF _R T_
_I TX FO C ON IN
LP 2C_ AN INT INT RAW
W INT AW
AW
LP 2C_ ME ST AW AW
NT W
LP 2C_ FIF _U INT _IN
LP 2C_ XFI _TO T_T AW
_I RA
O_ _ _R
_R
_I TI S_ R _R
_I M S_ _IN NT
_I R S _S _R
_I TR _ F_ T_
_I TX FO _ O
_I B TR O T
M _
LP 2C_ CL_ AIN INT
LP 2C_ AN UT T_I
_I TR _O AR
_I S M T_
_
LP 2C_ CL_ AR
T
_I S ST
LP 2C_ ET_
d)
_I D
ve
LP 2C_
r
se
_I
(re
LP
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 1 0 Reset
R
XF _W _I _C T_ R
_I R D NS OS T_C R
IF M NT LR CL
_R IFO VF INT _IN CL
LP 2C_ ACK _OV _IN LR CLR
_I A TX M CL LR
_I TX FO C ON IN
LP 2C_ AN INT INT CLR
W INT LR
LR
LP 2C_ ME ST LR LR
LP 2C_ FIF _U INT _IN
NT R
LP 2C_ YTE ATI _UD E_I
LP 2C_ ST_ CO T_ _C
LP 2C_ XFI _TO T_T LR
_I CL
LP 2C_ RBI FIF PLE R
O_ _ _C
_C
_I TI S_ _C _C
_I M S_ _IN NT
_I R S _S _C
_I TR _ F_ T_
_I TX FO _ O
_I B TR O T
M _
LP 2C_ CL_ AIN INT
LP 2C_ AN UT T_I
_I TR _O AR
_I S M T_
LP 2C_ CL_ AR
T
_I S ST
LP 2C_ ET_
d)
_I D
ve
LP 2C_
r
se
_I
(re
LP
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
A
XF _W _I _E T_ A
_I R D NS OS T_ A
IF M NT NA EN
_R IFO VF INT _IN EN
A
2C F _O T_ E T_
_I E _T ON F_ NT
_I N O DF _E T_
_I A TX M EN A
_I TX FO C ON IN
LP 2C_ ST_ CO T_ _EN
A
W INT NA
NA
LP 2C_ ME ST NA NA
NT A
LP 2C_ FIF _U INT _IN
_I EN
LP 2C_ RBI FIF PLE A
O_ _ _E
_E
_I TI S_ E _E
_I M S_ _IN NT
_I TR _ F_ T_
_I R S _S _E
_I TX FO _ O
_I B TR O T
M _
LP 2C_ CL_ AIN INT
LP 2C_ AN UT T_I
_I TR _O AR
_I S M T_
_
LP 2C_ CL_ AR
T
_I S ST
LP 2C_ ET_
d)
_I D
ve
LP 2C_
r
se
_I
(re
LP
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
IF M NT T ST
_R IFO VF INT _IN ST
LP 2C_ ND_ RA _L IN _ST
LP 2C_ ACK _OV _IN T ST
XF _W _I _S T_
LP 2C_ XFI ETE _D T_ ST
2C F _O T_ E T_
_I E _T ON F_ NT
_I N O DF _S T_
_I R D NS OS T_
_I TX FO C ON IN
LP 2C_ ST_ CO T_ _ST
LP 2C_ FIF _U INT _IN
W INT T
T
LP 2C_ ME ST T T
_I ST
LP 2C_ XFI _TO T_T T
O_ _ _S
_S
_I TI S_ _S _S
_I M S_ _IN NT
_I A TX M ST
_I R S _S _S
_I TR _ F_ T_
_I TX FO _ O
_I B TR O T
M _
NT
LP 2C_ RBI FIF PLE
LP 2C_ CL_ AIN INT
LP 2C_ AN UT T_I
_I TR _O AR
_I S M T_
LP 2C_ CL_ AR
T
_I S ST
LP 2C_ ET_
)
_I D
ed
LP 2C_
rv
se
_I
(re
LP
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
E
ON
_D
D0
D0
AN
AN
M
M
OM
M
CO
d)
_C
ve
C_
2C
2
se
_I
_I
(re
LP
LP
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
D1
AN
AN
M
M
M
M
O
O
)
_C
ed
_C
rv
2C
2C
se
_I
_I
(re
LP
LP
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
E
ON
_D
D2
D2
AN
AN
M
M
M
M
O
CO
)
_C
ed
C_
rv
2C
2
se
_I
_I
(re
LP
LP
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
D3
AN
AN
M
M
M
M
O
O
)
_C
ed
_C
rv
2C
2C
se
_I
_I
(re
LP
LP
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
E
ON
_D
D4
D4
AN
AN
M
M
M
M
O
CO
d)
_C
ve
C_
2C
2
se
_I
_I
(re
LP
LP
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
D5
AN
AN
M
M
M
OM
O
)
_C
ed
_C
rv
2C
2C
se
_I
_I
(re
LP
LP
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
E
ON
_D
D6
D6
AN
AN
M
M
M
M
CO
CO
)
ed
C_
C_
rv
2
2
se
_I
_I
(re
LP
LP
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
D7
AN
AN
M
M
OM
MO
)
_C
ed
_C
rv
2C
2C
se
_I
_I
(re
LP
LP
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
0x2201143 Reset
R
DD
A
T_
AR
ST
O_
IF
XF
_T
2C
_I
LP
31 0
0 Reset
R
DD
A
T_
AR
ST
O_
IF
XF
_R
2C
_I
LP
31 0
0 Reset
30.1 Overview
ESP32-C6 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: 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-C6 provides separate transmit (TX) and receive
(RX) units for high performance.
30.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
receives 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.
Full-duplex There are two separate data lines. Transmitted and received data
are carried simultaneously.
Half-duplex 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.
A-law 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 config-
uration.
Normal PDM RX mode In this mode, pulse density modulation (PDM) data is received
and stored into memory via DMA. Used signals: 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
memory 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
standard is supported in this mode by user configuration.
PCM-to-PDM 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: WS and
DATA. PDM standard is supported in this mode by user configura-
tion.
30.3 Features
The I2S module has the following features:
– PDM standard
– Supports the following frequencies: 8 kHz, 16 kHz, 32 kHz, 44.1 kHz, 48 kHz, 88.2 kHz, 96 kHz, 128
kHz, and 192 kHz (Note that in slave mode, due to the frequency limitation of the clock source, the
maximum sampling frequency is limited by the data bit width and number of channels. For detailed
information, refer to Section 30.6)
Figure 30-1 shows the structure of ESP32-C6 I2S module, consisting of:
• 64 x 32-bit TX FIFO
• 64 x 32-bit RX FIFO
• Compress/Decompress units
I2S module supports direct memory access (DMA) to internal memory. For more information, see Chapter 4
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 fixed as output, and the SD line of the RX unit as
input. BCK and WS signal lines for TX unit and RX unit can be configured as master output mode or slave input
mode.
The signal bus of I2S module is shown at the right part of Figure 30-1. The naming of these signals in RX and
TX units follows the pattern: I2SA_B_C, such as I2SI_BCK_in.
– 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 7 IO
MUX and GPIO Matrix (GPIO, IO MUX).
• I2S_TX/RX_TDM_EN
• I2S_TX/RX_PDM_EN
• 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.
• I2S_TX/RX_PCM_BYPASS
Compared with Philips standard, TDM Philips standard supports multiple channels. See Figure 30-2.
Compared with MSB alignment standard, TDM MSB alignment standard supports multiple channels. See
Figure 30-3.
Compared with PCM standard, TDM PCM standard supports multiple channels. See Figure 30-4.
• 40 MHz XTAL_CLK
The serial clock (BCK) of the I2S TX/RX unit is divided from I2S_TX/RX_CLK, as shown in Figure 30-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.
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 corresponds to the value 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
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, then the TX unit keeps sending the last data frame and clock signal.
– Set I2S_TX_START.
– 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, then 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.
– Set I2S_RX_START.
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 30.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.
• Phase II: read the data to send (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 30-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 an 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-C6 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.
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 30-7 shows the complete process of TX data format
control.
Note:
• Most stereo I2S codecs can be controlled by setting the I2S module into 2-channel mode under TDM standard.
In TDM TX mode, the total number of TX channels supported is related to the channel valid data width for I2S
as follows:
Table 30-5. The Matching Between Valid Data Width and Number of TX Channel Supported
• 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., that data of 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 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-C6 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 30-6. 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 30.6 and Figure 30.6.
In normal PDM TX mode, 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
trol Option Field1 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
Transmit the value of “single”3 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 PCM-to-PDM 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.
fBCK
fSampling =
OSR
OSR = I2S_TX_PDM_SINC_OSR2 × 64
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 30.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, the total number of RX channels supported is related to the channel valid data width for I2S
as follows:
Table 30-9. The Matching Between Valid Data Width and Number of RX Channel Supported
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: this 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
30.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.
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.
ESP32-C6 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 30.9, and then set
I2S_TX_UPDATE.
8. Set I2S_TX_STOP_EN if needed. For more information, please refer to Section 30.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;
• 0: master RX mode
• 1: slave RX mode
4. Set needed RX data mode and RX channel mode as described in Section 30.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 get BCK and WS signals from the
master.
9. The received data is then stored to the specified address of ESP32-C6 memory according the
configuration of DMA. Then the corresponding interrupt set in step 6 is generated.
• I2S_RX_HUNG_INT: triggered when receiving data is timed out. For example, if 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), then this interrupt will be triggered.
• 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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
30.14 Registers
The addresses in this section are relative to I2S Controller base address provided in Table 5-2 in Chapter 5
System and Memory.
E_ T_R W
W
RX ON IN AW
IN AW
ON IN RA
RA
S_ D G_ _R
_D E_ T_
T_
I2 TX_ UN INT
S_ _H G_
I2 RX UN
d)
S_ H
ve
I2 TX_
r
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
ON IN ST
ST
RX ON IN T
IN T
S_ D G_ _S
E_ T_S
_D E_ T_
T_
I2 TX_ UN INT
S_ _H G_
I2 RX UN
)
ed
S_ H
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
E_ T_E A
A
RX ON IN NA
IN NA
ON IN EN
EN
S_ D G_ _E
_D E_ T_
T_
I2 TX_ UN INT
S_ _H G_
I2 RX UN
d)
S_ H
ve
I2 TX_
r
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
E_ T_C R
R
RX ON IN LR
IN LR
ON IN CL
CL
S_ D G_ _C
_D E_ T_
T_
I2 TX_ UN INT
S_ _H G_
I2 RX UN
)
ed
S_ H
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
S
E
AS
se _B AT T_
S_ _F T OD
N
ET ET
_S AL N
TO IGN
F
_L FI _P
OD
S_ _2 ID R
IA
T_ E
(re X D FS
YP
I2 RX S_ DE
ES RES
I2 RX TAR M
S_ _M CO
ND
I2 RX DM N
RX 4_ LE
I2 RX IT_ N
_
_B
E
S_ _W OR
S_ _B _E
S_ _U O
S_ d O
P_
S_ _S E
S_ _T _
S_ d E
_R _
I2 RX LAV
I2 RX ON
I2 rve ON
I2 RX DM
CM
RX IFO
C
P
)
(re RX )
I2 RX )
se _M
S_ _P
_P
_P
S_ _S
ed
I2 RX
RX
RX
RX
I2 RX
rv
R
se
S_
S_
S_
S_
S_
(re
I2
I2
I2
I2
I2
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 1 0 1 0x1 1 0 0 0 0 0 0 0 0 0 Reset
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_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)
S
IT
_B
TS
TH
M
BI
ID
PL
NU
N_
FT
W
OD
AM
S_
V_
HA
HI
_M
I
_S
_W
_S
_C
_D
LF
SB
TS
DM
M
CK
HA
D
BI
)
_M
_B
ed
_T
_T
X_
_
RX
RX
RX
RX
RX
rv
R
se
S_
S_
S_
S_
S_
S_
(re
I2
I2
I2
I2
I2
I2
31 30 29 28 24 23 18 17 13 12 7 6 0
I2S_RX_TDM_WS_WIDTH Configures the width of rx_ws_out (WS default level) in TDM mode. Width
of rx_ws_out (WS default level) in TDM mode = (I2S_RX_TDM_WS_WIDTH[6:0] + 1) x T_BCK.
(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)
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)
I2S_RX_MSB_SHIFT Configures the timing between WS signal and the MSB of data.
0: Align at rising edge
1: WS signal changes one BCK clock earlier
(R/W)
T_ N
EN
OU _E
se d) _D _M EN
_2 DE
R2
(re rve DM AC V_
AC O
S
_O
se P _D ON
NC
(re X_ DM _C
I
_S
S_ P M
I2 TX_ PD
DM
2
d)
(re ed)
d)
ed
ed
ed
ed
ed
_P
S_ M
ve
ve
I2 PC
rv
rv
rv
rv
rv
rv
TX
r
r
T
se
se
se
se
se
se
se
S_
S_
(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)
)
ed
ed
ed
_P
ve
rv
rv
rv
TX
r
se
se
se
se
S_
(re
(re
(re
(re
I2
31 26 25 23 22 20 19 10 9 0
S_ _T _P _ N N
_C AN1 EN
N
S_ _T _P _ N N
_P M_ AN EN
_T _ _ AN EN
S_ _T _P _ N N
N0 N
M
I2 RX DM DM HA 6_E
_E
I2 RX M DM HA 5_E
I2 RX M DM HA 7_E
HA _E
NU
DM CH 2_
DM PD CH 3_
RX DM DM CH 4_
S_ _T _C N9 N
S_ _T _C N1 N
S_ _T _C N1 N
S_ _T _C N1 N
S_ _T _C N1 N
S_ _T _P _ N
N_
S_ _T _C N1 N
S_ _T _P _ N
S_ _T _P N8 N
I2 RX DM HA 0_E
I2 RX DM HA 5_E
I2 RX DM HA 2_E
I2 RX DM HA 4_E
I2 RX DM HA 3_E
I2 RX DM DM HA
I2 RX DM HA 1_E
I2 RX DM DM _E
I2 RX DM HA _E
HA
C
C
C
C
S_ _T _C N1
_C
I2 RX M HA
OT
S_ _T _C
_T
M
I2 RX DM
TD
D
d)
S_ T
X_
_
ve
I2 RX
r
R
se
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: 0-7) 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 = 8-15) 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)
X_
rv
R
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)
D
E VL
I2 rve FT _E L
SS
L
se LE ILL PO
S_ B T T_
D
S_ d O A
se M _ N
ET ET
S_ d _A N
GN
CK
OD
I2 rve ON EQU
CM PA
I2 TX_ S_I DER
I2 TX_ AR MO
(re TX_ HAN DIA
ON
I2 X_ DA S
(re TX_ 4_F E_
ES RES
BA
N
LI
_F
M
I2 TX_ M_ N
_P BY
I2 TX_ IT_O N
PC _E
S_ S E_
L
S_ C EN
I2 TX_ _C
S_ T _E
S_ W R
N_
S_ B E
OP
S_ U O
S_ 2 D
S_ F T
TX M_
_R _
P
I2 X_ AV
I2 TX_ ON
I2 TX_ DM
I2 TX_ IG_
TX IFO
HA
TX TO
LO
T
L
D
)
I2 TX_ )
I2 TX_ )
S_ M
ed
ed
_C
S_ P
S_ S
S_ S
G_
I2 X_
_
rv
rv
TX
SI
T
se
se
S_
S_
S_
S_
S_
(re
(re
I2
I2
I2
I2
I2
31 28 27 26 24 23 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 1 0 1 1 0x0 1 0 0 0 0 0 0 0 0 0 Reset
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)
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_STOP_EN Configures whether to stop outputting BCK signal and WS signal when TX FIFO
is empty.
0: No effect
1: Stop
(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_CHAN_MOD Configures I2S TX channel mode. For more information, see Table 30-7. (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)
TS
BI
TS
TH
E_
M
BI
ID
HI Y
PL
NU
N_
_S DL
FT
W
OD
M
S_
IV_
SB O_
HA
SA
_W
_M _N
_C
D
F_
S_
K_
DM
DM
TX CK
AL
IT
C
I2 TX_ )
S_ d
_H
S_ B
_B
_B
_T
_T
I2 rve
TX
TX
TX
TX
TX
se
S_
S_
S_
S_
S_
(re
I2
I2
I2
I2
I2
31 30 29 28 24 23 18 17 13 12 7 6 0
I2S_TX_TDM_WS_WIDTH Configures the width of tx_ws_out (WS default level) in TDM mode. The
width of tx_ws_out (WS default level) in TDM mode = (I2S_TX_TDM_WS_WIDTH[6:0] +1) x T_BCK.
(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_TDM_CHAN_BITS Configures TX bit number for each channel in TDM mode. Bit number
expected = I2S_TX_TDM_CHAN_BITS + 1. (R/W)
I2S_TX_MSB_SHIFT Configures the timing between WS signal and the MSB of data.
0: Align at rising edge
1: WS signal changes one BCK clock earlier
(R/W)
UM
N
_N
_E
S_ T C 9 N
S_ T C 1 N
S_ T C 1 N
S_ T C 1 N
S_ T C 1 N
S_ T C 1 N
_C AN1 EN
N
I2 TX_ M_ HAN _EN
_T _C N N
I2 TX_ M_ HAN _EN
I2 X_ _ AN EN
I2 X_ _ AN EN
I2 TX_ M_ HAN EN
N0 N
I2 TX_ M_ HAN _E
I2 TX_ M_ HAN _E
I2 TX_ M_ HAN _E
I2 X_ _ AN E
I2 TX_ M_ HAN _E
AN
SK
I2 TX_ M_ HAN _E
_E
TX DM HA _E
DM H 4_
HA _E
DM H 2_
DM H _
DM H _
0
5
_
3
M
CH
S_ T C 6
S_ T C 3
S_ T C 5
S_ T C 8
S_ T C 4
S_ T C 7
S_ T C 1
I2 X_ _ AN
P_
T_
KI
DM H
TO
S_ T C
_S
I2 X_ _
M
DM
DM
D
D
D
D
D
D
D
D
D
)
ed
_T
_T
S_ T
I2 TX_
rv
TX
TX
T
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: 0-15) 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
30.9.2.1
1: Enable
(R/W)
I2S_TX_TDM_TOT_CHAN_NUM Configures the total number of channels in use in I2S TX TDM mode.
Total channel number in use = I2S_TX_TDM_TOT_CHAN_NUM + 1. (R/W)
DM
M
_D
M
M
_D
UT
T_
_D
_D
IN
OU
_O
IN
IN
K_
S_
S_
CK
D_
BC
)
d)
)
_W
_W
_B
_S
ed
ed
ed
ed
_
ve
RX
RX
RX
RX
RX
rv
rv
rv
rv
r
se
se
se
se
se
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 configura-
tion 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)
M
DM
DM
DM
_D
_D
M
UT
T_
T_
_D
UT
N_
OU
_O
OU
IN
_O
_I
S_
S_
CK
CK
D_
D1
)
)
_W
_W
ed
ed
ed
ed
ed
ed
_B
_B
_S
_S
rv
rv
rv
rv
rv
rv
TX
TX
TX
TX
TX
TX
se
se
se
se
se
se
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 config-
uration 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 configu-
ration values, please refer to I2S_TX_SD_OUT_DM. (R/W)
FT
NA
HI
_S
_E
UT
UT
UT
EO
EO
EO
M
M
TI
TI
TI
O_
O_
O_
IF
IF
IF
)
_F
_F
ed
_F
LC
rv
LC
LC
se
S_
S_
S_
(re
I2
I2
I2
31 12 11 10 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 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
ID
ed
_
rv
TX
se
S_
(re
I2
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
M
NU
M
D_
NU
OR
D_
W
OR
E_
_W
V
EI
ND
EC
SE
R
X_
X_
_R
_T
)
ed
TM
M
ET
rv
E
se
S_
S_
(re
I2
I2
31 20 19 10 9 0
TE
DA
rv
se
S_
(re
I2
31 28 27 0
0 0 0 0 0x2201070 Reset
Each unit includes two channels (ch0 and ch1) which can independently increment or decrement its pulse
counter value. The remainder of the chapter will mostly focus on channel 0 (ch0) as the functionality of the
two channels is identical.
1. One 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)
31.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
2. Configuration to Increment, Decrement, or Disable counter mode for control signal’s high and low
states
fAP B_CLK
• Maximum frequency of pulses: 2
Figure 31-2 shows PCNT’s architecture. As stated above, ctrl_ch0_un is the control signal for ch0 of unit n. Its
high and low states can be assigned different counter modes and used for pulse counting of the channel’s
input pulse signal sig_ch0_un on negative or positive edges. The available counter modes are as
follows:
• Increment mode: When a channel detects an active edge of sig_ch0_un (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 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 (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 before pulse_cnt
reaches PCNT_CNT_L_LIM_Un, then pulse_cnt freezes and its counter mode changes.
• Disable mode: Counting is disabled, and the counter value pulse_cnt freezes.
Table 31-1. Counter Mode. Positive Edge of Input Pulse Signal. Control Signal in Low State
Table 31-2. Counter Mode. Positive Edge of Input Pulse Signal. Control Signal in High State
Table 31-1 to Table 31-4 provide information on how to configure the counter mode for channel 0.
Each unit has one filter for all its control and input pulse signals. A filter can be enabled with the bit
PCNT_FILTER_EN_Un. The filter monitors the signals and ignores all the noise, i.e. the glitches with pulse
widths shorter than PCNT_FILTER_THRES_Un APB clock cycles in length.
As shown on Figure 31-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 reaches PCNT_CNT_H_LIM_Un, a high limit interrupt is triggered
Table 31-3. Counter Mode. Negative Edge of Input Pulse Signal. Control Signal in Low State
Table 31-4. Counter Mode. Negative Edge of Input Pulse Signal. Control Signal in High State
• Minimum count value: When pulse_cnt reaches PCNT_CNT_L_LIM_Un, a low limit interrupt is triggered
and
PCNT_CNT_THR_L_LIM_LAT_Un is high.
31.3 Applications
In each unit, channel 0 and channel 1 can be configured to work independently or together. The three
subsections below provide details of channel 0 incrementing independently, channel 0 decrementing
independently, and channel 0 and channel 1 incrementing together. For other working modes not elaborated
in this section (e.g. channel 1 incrementing/decremeting independently, or one channel incrementing while
the other decrementing), reference can be made to these three subsections.
Figure 31-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 31.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 31-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
31-3 in the following aspects:
Figure 31-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 31-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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
31.5 Registers
The addresses in this section are relative to Pulse Count Controller base address provided in Table 5-2 in
Chapter 5 System and Memory.
U0
U0
U0
U0
U0
_F _Z IM _ 0
E_
U0
E_
U0
PC T_T _H IM_ EN 0
E_
E_
_U
_E EN U0
NT HR _L EN _U
ILT ER _E U0
N HR _L 0_ U
U0 0
E_
OD
U0
OD
E_
E_
OD
_
OD
N_ _U
DE
ER O_ N_
N
OD
S_
_M
OD
OD
_M
M
NT HR R _E
_M
RE
L_
_M
_M
_M
1
_M
RL
RL
PC T_T _T ES
PC _T L S
RL
TR
H
E
OS
PC T_T NEG
CT
CT
OS
EG
_T
N HR HR
CT
HC
H
_H
_P
_L
ER
_N
_P
_L
PC _T _T
_
_
_
H0
H0
H0
H0
ILT
NT HR
H1
H1
H1
H1
_C
_C
_C
_C
_C
_C
_C
_C
_F
NT
NT
NT
NT
NT
NT
NT
NT
NT
N
PC
PC
PC
PC
PC
PC
PC
PC
PC
PC
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 0
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)
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)
U0
U0
0_
1_
ES
ES
HR
HR
_T
_T
NT
NT
_C
_C
NT
NT
PC
PC
31 16 15 0
0
0
_U
_U
IM
IM
_L
_L
H
L
T_
T_
N
N
_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 pulse_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 pulse_cnt reaches this value,
the counter will be cleared to 0.(R/W)
0
NT NT _C _U U2
PC T_P T_P NT 2 3
NT 0 1
N N _C _U U
_C _U _U
_U
PC T_C LSE SE ST_
SE SE ST
ST
PC T_P T_P NT 3
_P _P NT 1
N U AU _R
N U AU _R
UL AU _R
_R
N N _C _U
PC T_C LSE SE
N U AU
EN
PC T_P T_P
K_
)
)
ed
ed
N N
L
_C
PC T_C
rv
rv
NT
se
se
N
(re
(re
PC
PC
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 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
(re
PC
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)
U0
ER LAT U0
0
HR R L U0
ES LA 0
_U
E_
N HR _L _L 0
1_ T_
HR 0_ U
_C _T _L IM _U
NT T_T _TH IM_ AT_
NT _T ES AT_
OD
NT NT HR _L LAT
M
PC T_C T_T _H O_
O_
N N HR ER
PC T_C T_T _Z
_Z
N N HR
HR
PC T_C T_T
_T
)
ed
N N
PC T_C
_C
rv
se
N
(re
PC
PC
31 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
PCNT_CNT_THR_L_LIM_LAT_Un Represents the latched value of low limit event of PCNT_Un when
threshold event interrupt is valid.
0: others
1: the current pulse counter equals to thr_l_lim and low limit event is valid.
(RO)
PCNT_CNT_THR_H_LIM_LAT_Un Represents the latched value of high limit event of PCNT_Un when
threshold event interrupt is valid.
0: others
1: the current pulse counter equals to thr_h_lim and high limit event is valid.
(RO)
_U INT AW
W
VE _U IN AW
IN AW
RA
NT 1_ T_R
_E NT 2_ _R
0_ _R
T_
HR VE _U INT
_T _E NT 3_
NT HR VE U
_C _T _E T_
NT NT HR VEN
PC T_C T_T _E
N N HR
PC _C _T
NT NT
d)
ve
PC T_C
r
se
N
(re
PC
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
_U INT T
ST
VE _U IN T
IN T
NT 1_ T_S
_E NT 2_ _S
0_ _S
T_
HR VE _U INT
_T _E NT 3_
NT HR VE U
_C _T _E T_
NT NT HR VEN
PC T_C T_T _E
N N HR
PC _C _T
NT NT
)
ed
PC T_C
rv
se
N
(re
PC
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
0_ _E A
A
VE _U IN NA
IN NA
_U INT N
EN
NT 1_ T_E
_E NT 2_ _E
T_
HR VE _U INT
_T _E NT 3_
NT HR VE U
_C _T _E T_
NT NT HR VEN
PC T_C T_T _E
N N HR
PC T_C T_T
d)
N N
ve
PC T_C
r
se
N
(re
PC
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
_U INT LR
R
VE _U IN LR
IN LR
CL
NT 1_ T_C
_E NT 2_ _C
0_ _C
T_
HR VE _U INT
_T _E NT 3_
NT HR VE U
_C _T _E T_
NT NT HR VEN
PC T_C T_T _E
N N HR
PC _C _T
NT NT
d)
ve
PC T_C
r
se
N
(re
PC
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
32.1 Overview
While programming and debugging an ESP32-C6 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-C6 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-C6.
32.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
As shown in Figure 32-1, the USB Serial/JTAG controller consists of a USB PHY, a USB device interface, a JTAG
command processor, a 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 32-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.
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 32-2
Aside from general-purpose communication, the CDC-ACM interface can also be used to reset ESP32-C6 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.
Note that if the download mode flag is set when ESP32-C6 is reset, ESP32-C6 will reboot into download
mode. When this flag is cleared and the chip is reset, ESP32-C6 will boot from flash. For specific sequences,
please refer to Section 32.4. All these functions can also be disabled by programming various eFuses. Please
refer to Chapter 6 eFuse Controller 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_REG_SERIAL_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 can be read from the USB_SERIAL_JTAG_SET_LINE_CODE_W0_REG register. Similarly,
SET_CONTROL_LINE_STATE requests will trigger USB_SERIAL_JTAG_RTS_CHG_INT and
USB_SERIAL_JTAG_DTR_CHG_INT interrupts if they change the state of these lines. Software can then read
the specific state through the USB_SERIAL_JTAG_RTS and USB_SERIAL_JTAG_DTR bits. Note that as
described earlier, certain RTS/DTR sequences lead to hardware reset of ESP32-C6. Software can disable
hardware recognition of these DTR/RTS sequences by setting the
USB_SERIAL_JTAG_USB_UART_CHIP_RST_DIS bit, allowing software to interpret these signals freely.
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-C6.
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-C6 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
forms the basis of JTAG communication.
• CMD_RST will set the state of the SRST line as the indicated value. This can be used to reset ESP32-C6.
• 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-C6.
• 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. 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.
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 0-byte USB responses to be
sent. However, in the current implementation, some zero-0 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 following fixed structure, which describes the capabilities of the USB-to-JTAG adapter
(as shown in Table 32-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-C6 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 resetting 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.
32.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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
32.7 Registers
The addresses in this section are relative to USB Serial/JTAG controller base address provided in Table 5-2 in
Chapter 5 System and Memory.
ET
BY
R_
W
RD
G_
TA
_J
AL
)
RI
ed
SE
rv
B_
se
(re
US
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
FR L
A_ VAI
EE
A
NE P_D TA_
DO _E _DA
AT
P
_W L_ _E
AG RIA OUT
R_ IN
_
L_ G_ IAL
RIA JTA SER
JT SE
_
B_ IAL AG
US SER _JT
_
B_ IAL
d)
US SER
rve
SE
B_
se
(re
US
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
E
US SER _JT _DM UP_V NAB _EN
ID
E
RR
RID RID
GE
_P AL LE
VE
R
US SER _JT _PU PAD BRID
E
OV OVE
EL S_O
N
US SER _JT _DM ULL UE
L_ G_ PU OW
_P DO
_P HG_ S
UP
_E
_
AG D_ LUP
B_ IAL AG B_ G_
IN
HY PI N
ER
RIA JTA DP_ LLD
LL
JT EXC _P
US SER _JT _US JTA
PU
L
L_ G_ HG
U
_S
H
L
F_
B_ IAL AG B_
B_ IAL AG _P
LL
EF
EF
C
RE
US SER _JT _US
JT PA
X
R
VR
_J _E
_V
_V
_
G_
B_ IAL AG
B_ IAL AG
B_ IAL AG
B_ IAL AG
AG
B_ IAL AG
AG
TA
RIA TA
US SER _JT
JT
US SER _JT
_J
_
L_
B_ IAL
B_ IAL
RIA
RIA
d)
US SER
US SER
rve
SE
SE
SE
SE
B_
B_
B_
B_
se
(re
US
US
US
US
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
NA E
AL A ES X V
E
US _SE IAL TAG ES RX_ M
_E _O
TA TE TX M
B_ RI _JT _T T_R DP
RI JT _T T_T RC
BL
TE _U P
B R _J _T T_ D
_J G_ T_ _D
G_ ST _D
ST SB
US _SE IAL TAG ES RX_
SE AL_ AG ES X_
B R _J _T T_
US _SE IAL TAG ES
B R _J _T
US SE AL AG
B_ RI _JT
US _SE IAL
d)
B R
ve
US _SE
r
se
B
(re
US
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)
NE
K_
CL
G_
TA
_J
AL
d)
RI
ve
SE
r
B_
se
(re
US
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 _E
EM LK
M _C
B_ EM
US M
G_ B_
TA US
_J G_
AL A
RI JT
SE AL_
)
B_ RI
ed
US _SE
rv
se
B
(re
US
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
IS
_D
ST
R
P_
HI
_C
G_ R RT
TA DT UA
_J G_ B_
S
AL A S
RT
RI JT _U
SE AL_ AG
B_ RI _JT
US _SE IAL
d)
B R
ve
US _SE
r
se
B
(re
US
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
AT
M
PE
R
S
TY
FO
T
BI
Y_
R_
A_
IT
HA
AT
PA
BC
BD
B
T_
T_
T_
GE
GE
GE
G_
G_
G_
TA
TA
TA
_J
_J
_J
AL
AL
AL
)
RI
RI
RI
ed
SE
SE
SE
rv
B_
B_
B_
se
(re
US
US
US
31 24 23 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 Reset
TE
DA
UP
G_
FI
CON
G_
TA
_J
AL
)
RI
ed
SE
rv
B_
se
(re
US
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
R
IN_ IFO_ ESET D
_W
R
WR
ES RD
ES Y
ET_
JTA SER _OUT FIFO MPT
_
ET_
SE L_JT _SER _OU FIFO ULL
IFO SET
RE
_R
R
F
RE
_
_R
F
FIF
A
A
_A
F
AF
T_
RIA IN_A
_
_
_
L_
AG RIAL
L
L
IAL
IAL
SE
SE
SE
SE
AL AG_
_
AL AG_
_
G_
G
AG
TA
T
T
T
_J
J
_J
_J
_
L_
AL
L
RIA
A
RIA
d)
US SERI
US SERI
US SERI
US SERI
rve
SE
B_
B_
B_
B_
B_
B_
se
(re
US
US
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
W
W
RA T_R
RA
AD T_
RA
US SER _JT _ST KEN ESE YLO _IN
T_
T_
W
US SER _JT _CR 6_E INT _EP W
IN
G_ RAW CV_ T_RA
N
IN AW AW
AW
W
AD
T_
_R 1_
RA
US SER _JT _IN BUS RO_ AYLO
US SER _JT _OU CHG T_R NT_R
US SER _JT _RT CHG ODE T_R
PK
T_
US SER _JT _SE RR_ INT_ AW
_J INT _R _IN
US ER _JT PID ER INT W
W
A
_IN
AW
_IN
PA
RA
AG F_ OUT PTY
L_ G_ IAL _EM W
_E R_ _R
P
B_ IAL AG C1 RR_ IN
_R T_
_IN _I
SH
E
US SER _JT _US EP1_ ERO
LU
T
_
ZE
B_ IAL AG _TO _R
B_ IAL AG R_ _C
_C
IN
T_ _Z
B_ IAL AG C5 RR
_F
_
_
US SER _JT _GE LINE
IN
L
_
B_ IAL AG RIA
B_ IAL AG B_
B_ IAL AG S_
T_
B_ IAL AG UF
B_ IAL AG T_
B_ IAL AG T_
TA
JT SO
US SER _JT _SE
_
B_ IAL AG
B_ IAL AG
B_ IAL AG
B_ IAL AG
US SER _JT
_
B_ IAL
d)
US SER
rve
SE
S
B_
se
(re
US
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
ST
ST
US SER _JT _ST KEN ESE YLO _IN
T_
T_
IN
N
V_ _ST
AD
T_
_S 1_
T
T
ST
US SER _JT _IN BUS RO_ AYLO
US SER _JT _OU CHG T_S NT_S
US SER _JT _RT CHG ODE T_S
T
PK
US SER _JT _CR 6_E INT _EP
T_
_J INT _R _IN
US SER _JT _SE RR_ INT_ T
_IN
_IN
PA
ST
AG F_ OUT PTY
ZE _P
_E R_ _S
B_ IAL AG C1 RR_ IN
_R T_
_IN _I
IN T
T
EC
RIA JTA SER _IN _ST
US SER _JT _OU EP2 T_S
SH
US SER _JT _US EP1_ ERO
L_ G_ IAL _EM
LU
T
_
TO _R
B_ IAL AG R_ _C
_C
G_ ST
IN
T_ _Z
B_ IAL AG C5 RR
_F
_
_
US SER _JT _GE LINE
IN
L
_
B_ IAL AG RIA
B_ IAL AG B_
B_ IAL AG S_
T_
B_ IAL AG UF
B_ IAL AG T_
B_ IAL AG T_
TA
_
JT SO
US SER _JT _SE
_
B_ IAL AG
B_ IAL AG
B_ IAL AG
B_ IAL AG
B_ IAL AG
US SER _JT
_
B_ IAL
d)
US SER
rve
SE
S
B_
se
(re
US
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
A
A
EN T_E
EN
AD T_
EN
US SER _JT _ST KEN ESE YLO _IN
T_
T_
A
IN
US SER _JT _CR 6_E INT _EP A
G_ EN CV_ T_EN
N
AD
IN NA NA
NA
A
I
T_
EN
_E 1_
US SER _JT _IN BUS RO_ AYLO
US SER _JT _OU CHG T_E NT_E
US SER _JT _RT CHG ODE T_E
PK
T_
_J INT _R _IN
US SER _JT _SE RR_ INT_ NA
US ER _JT PID ER INT A
A
N
_IN
_IN
EN
PA
NA
AG F_ OUT PTY
P
_E R_ _E
B_ IAL AG C1 RR_ IN
_R T_
L_ G_ IAL _EM A
_IN _I
SH
E
US SER _JT _US EP1_ ERO
IN A
LU
T
_
ZE
B_ IAL AG _TO _R
B_ IAL AG R_ _C
_C
IN
T_ _Z
B_ IAL AG C5 RR
_F
_
_
US SER _JT _GE LINE
_
L
_
B_ IAL AG RIA
B_ IAL AG B_
B_ IAL AG S_
T_
B_ IAL AG UF
B_ IAL AG T_
B_ IAL AG T_
TA
JT SO
US SER _JT _SE
_
B_ IAL AG
B_ IAL AG
B_ IAL AG
B_ IAL AG
US SER _JT
_
B_ IAL
d)
US SER
rve
SE
S
B_
se
(re
US
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
R
R
CL T_C
AD T_
CL
CL
US SER _JT _ST KEN ESE YLO _IN
T_
T_
PK R
IN
US SER _JT _CR 6_E INT _EP R
N
R
I
T_
_C 1_
CL
US SER _JT _IN BUS RO_ AYLO
US SER _JT _OU CHG T_C NT_C
US SER _JT _RT CHG ODE T_C
T_
_J INT _R _IN
US SER _JT _SE RR_ INT_ LR
US ER _JT PID ER INT R
R
_IN
_IN
PA
IN LR
LR
CL
AG F_ OUT PTY
_E R_ _C
ZE _P
B_ IAL AG C1 RR_ IN
_R T_
_IN _I
SH
E
US SER _JT _US EP1_ ERO
L_ G_ IAL _EM
LU
T
_
TO _R
B_ IAL AG R_ _C
_C
IN
T_ _Z
B_ IAL AG C5 RR
_F
_
_
US SER _JT _GE LINE
IN
L
_
B_ IAL AG RIA
B_ IAL AG B_
B_ IAL AG S_
T_
B_ IAL AG UF
B_ IAL AG T_
B_ IAL AG T_
TA
_
JT SO
US SER _JT _SE
_
B_ IAL AG
B_ IAL AG
B_ IAL AG
B_ IAL AG
B_ IAL AG
US SER _JT
_
B_ IAL
d)
US SER
rve
SE
S
B_
se
(re
US
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
O_ TY
UT O_E LL
AG T_F O_F T
T
AG UT O_ ES
U IF SE
_ L
M
_I FIF CN
IF U
T
G_ IFO UL
JT _O FIF _R
_F EM
CN
_
F _F
B_ AL_ AG _ IFO
N_ O
US ERI _JT _IN T_F
_F
IF
AG _
S AL AG U
IN
B_ RI _JT _O
_O
US SE AL AG
B_ AL_ AG
TA
B_ RI _JT
US _SE _JT
US ERI _JT
_J
US _SE IAL
S L
AL
A
A
d)
US ERI
B_ RI
RI
B R
ve
US _SE
SE
S
r
se
B
(re
US
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
X
DE
IN
E_
R AM
_F
S OF
G_
TA
_J
AL
d)
RI
ve
SE
r
B_
se
(re
US
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
R
R
DD
DD
TE
A
_A
R_
TA
RD
_S
0_
0_
P0
EP
EP
_E
N_
N_
IN
I
I
G_
G_
G_
TA
TA
TA
_J
_J
_J
AL
AL
AL
)
RI
RI
RI
ed
SE
SE
SE
rv
B_
B_
B_
se
(re
US
US
US
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
R
R
DD
DD
TE
A
_A
R_
TA
RD
_W
_S
1_
P1
P1
P
_E
_E
_E
IN
IN
IN
G_
G_
G_
TA
TA
TA
_J
_J
_J
AL
AL
AL
d)
RI
RI
RI
ve
SE
SE
SE
r
B_
B_
B_
se
(re
US
US
US
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
R
DD
AD
TE
_A
R_
TA
RD
_S
2_
2_
P2
EP
EP
_E
N_
N_
IN
I
I
G_
G_
G_
TA
TA
TA
_J
_J
_J
AL
AL
AL
)
RI
RI
RI
ed
SE
SE
SE
rv
B_
B_
B_
se
(re
US
US
US
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
R
R
DD
DD
TE
A
_A
R_
TA
RD
_W
_S
3_
P3
P3
P
_E
_E
_E
IN
IN
IN
G_
G_
G_
TA
TA
TA
_J
_J
_J
AL
AL
AL
d)
RI
RI
RI
ve
SE
SE
SE
r
B_
B_
B_
se
(re
US
US
US
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
R
R
DD
DD
TE
A
A
R_
D_
TA
_W
_R
_S
P0
P0
P0
_E
_E
T_
UT
UT
OU
O
O
G_
G_
G_
TA
TA
TA
_J
_J
_J
AL
AL
AL
)
RI
RI
RI
ed
SE
SE
SE
rv
B_
B_
B_
se
(re
US
US
US
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
NT
_C
TA
DR
R
DD
DA
AD
E
A
C_
AT
R_
D_
RE
ST
W
_R
1_
1_
1_
P1
EP
EP
EP
E
T_
T_
T_
T_
OU
OU
OU
OU
G_
G_
G_
G_
TA
TA
TA
TA
_J
_J
_J
_J
AL
AL
AL
AL
)
RI
RI
RI
RI
ed
SE
SE
SE
SE
rv
B_
B_
B_
B_
se
(re
US
US
US
US
31 23 22 16 15 9 8 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
R
R
DD
DD
E
A
A
AT
R_
D_
ST
_W
_R
2_
P2
P2
EP
E
E
T_
T_
T_
U
OU
U
_O
_O
G_
AG
AG
TA
JT
JT
_J
L_
L_
AL
IA
IA
)
RI
ed
ER
ER
SE
rv
S
B_
B_
B_
se
(re
US
US
US
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
E
AT
_R
TE
_D
W
D
G_
TA
_J
AL
RI
SE
B_
US
31 0
0 Reset
AT
RM
PE
TS
TY
O
BI
_F
Y_
A_
IT
AR
AR
AT
H
BC
BD
BP
G_
G_
G_
TA
TA
TA
_J
_J
_J
AL
AL
AL
)
RI
RI
RI
ed
SE
SE
SE
rv
B_
B_
B_
se
(re
US
US
US
31 24 23 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 Reset
T
_S
ET
ES
_R
US
_B
SB
_U
AG
JT
L_
RIA
d)
rve
SE
B_
se
(re
US
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
ESP32-C6 contains two TWAI controllers named TWAI 0 and TWAI 1. Each controller can individually be
connected to a TWAI bus via an external transceiver. The TWAI controllers contain numerous advanced
features, and can be utilized in a wide range of use cases such as automotive products, industrial automation
controls, building automation, etc.
33.1 Features
Each of the two TWAI controllers on ESP32-C6 support the following features:
• Standard Frame Format (11-bit ID) and Extended Frame Format (29-bit ID)
– Normal
• Special transmissions:
– Self Reception (the TWAI controller transmits and receives messages simultaneously)
– Error Counters
Single Channel and Non-Return-to-Zero: 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 33.2.2 for more details).
Multi-cast: All nodes receive the same bits as they are connected to the same bus. Data is consistent across
all nodes unless there is a bus error (see Section 33.2.3 for more details).
Multi-master: Any node can initiate a transmission. If a transmission is already ongoing, a node will wait until
the current transmission is over before 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
• 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 33-1
illustrates the fields and sub-fields of different frames and formats.
Arbitration Field
When two or more nodes transmit a data or remote frame 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:
• 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 DLC (Data Length Code) which indicates the number of payload data
bytes for a data frame, or the number of requested data bytes for a remote frame. The DLC is transmitted 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 33-1. Data Frames and Remote Frames in SFF and EFF
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 33.2.3 for
more details). The following Figure 33-2 shows different fields of an error frame:
Overload Frames
An overload frame has the same bit fields as an error frame containing an Active Error Flag. The key difference
is in the cases that can trigger the transmission of an overload frame. Figure 33-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 33.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.
• For case 1, a maximum of two overload frames may be generated in order to delay the transmission of
the next data or remote frame.
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 or 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
r0 fields must be dominant.
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 an Passive Error Flag when it
detects an error. Error Passive nodes that have transmitted a data or remote frame must also include the
Suspend Transmission field in the subsequent Interframe Space.
Bus Off
A Bus Off node is not permitted to influence the bus in any way (i.e., is not allowed to transmit 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 whilst 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.
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.
• If the REC is greater than 127, the REC will be set to 127.
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 to
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 prescaled clock
signal in each node. Figure 33-5 illustrates the segments within a single Nominal Bit Time.
TWAI controllers will operate in time steps of one Time Quanta where the state of the TWAI bus is analyzed. If
the bus states in two consecutive Time Quantas are different (i.e., recessive to dominant or vice versa), it
means 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.
Segment Description
SS The SS (Synchronization Segment) is 1 Time Quantum long. If all nodes are perfectly syn-
chronized, the edge of a bit will lie in the SS.
Cont’d on next page
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 for Phase Errors, there are two forms of synchronization, known as Hard Synchronization and
Resynchronization. Hard Synchronization and Resynchronization obey the following rules:
Hard Synchronization
Hard Synchronization occurs on the recessive to dominant (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 a same effect as Hard Synchronization.
• When the magnitude of the Phase Error is greater to the SJW, PBS1/PBS2 are lengthened/shortened by
the SJW number of Time Quanta. This means it may take multiple bits of synchronization before the
Phase Error is entirely corrected.
Configuration Registers
The configuration registers store various configuration 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 33.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 33.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.
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-protect 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).
• Self-test 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 do not generate an ACK error even if it was not
acknowledged. This is commonly used when the TWAI controller does self-test.
• Listen-only Mode: The TWAI controller will be able to receive messages, but will remain completely
passive on the TWAI bus. Thus, the TWAI controller will not be able to transmit any messages,
acknowledgments, or error signals. The error counters will remain frozen. This mode is useful for TWAI
bus 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 being able to fully connect the TWAI bus (i.e., be able to transmit
or receive).
The following Table 33-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 8 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 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved SAM PBS2.2 PBS2.1 PBS2.0 PBS1.3 PBS1.2 PBS1.1 PBS1.0
Notes:
• PBS1: The number of Time Quanta in Phase Buffer Segment 1 is defined according to the following
equation: (8 x PBS1.3 + 4 x PBS1.2 + 2 x PBS1.1 + PBS1.0 + 1)�
• PBS2: The number of Time Quanta in Phase Buffer Segment 2 is defined according to the following
equation: (4 x PBS2.2 + 2 x PBS2.1 + PBS2.0 + 1)�
• SAM: Enables triple sampling if set to 1. This is useful for low/medium speed buses to filter spikes on the
bus line.
• 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 de-asserted 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 completed successfully, i.e., acknowledged without any errors. Any failed
messages will automatically be resent.
The Error Warning Interrupt (EWI) is triggered whenever there is a change to the TWAI_ERR_ST and
TWAI_BUS_OFF_ST bits of the TWAI_STATUS_REG (i.e., transition from 0 to 1 or vice versa). Thus, an EWI
could indicate one of the following events, depending on the values 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 Arbitration Lost Capture register (TWAI_ARB_LOST_CAP_REG). When the ALI occurs again, the
Arbitration Lost Capture register will no longer record new bit location until it is cleared (via CPU reading this
register).
The Bus Error Interrupt (BEI) is triggered whenever 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).
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 33.4.10).
Table 33-8. Buffer Layout for Standard Frame Format and Extended Frame Format
Table 33-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.
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 33-9.
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 2 3 3 4 4 4
Reserved FF RTR X X 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 FF bit is 1, and SFF when 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 anywhere from 0 to 8.
The Frame Identifier fields occupies 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 is shown in Table 33-10 ~ 33-11.
Bit 31-8 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 31-8 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).
The Frame Identifier fields for an EFF (29-bits) message is shown in Table 33-12 ~ 33-15.
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.28 ID.27 ID.26 ID.25 ID.24 ID.23 ID.22 ID.21
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.12 ID.11 ID.10 ID.9 ID.8 ID.7 ID.6 ID.5
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 2
Reserved ID.4 ID.3 ID.2 ID.1 ID.0 X X X2
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.
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 33-7.
message bit
1 = accepted
XNOR OR 0 = not accepted
acceptance code bit acceptance mask bit
AND
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 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 a data or remote
frame:
• SFF
– RTR bit
• EFF
– RTR bit
The following Figure 33-8 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 a 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 a data or remote frame:
• SFF
– RTR bit
• EFF
The following Figure 33-9 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
trigger interrupts, thus allowing the users to be notified of error state transitions (see section 33.4.3). The
following figure 33-10 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
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 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 1 2 3 3 3 3
Reserved ERRC.1 ERRC.0 DIR SEG.4 SEG.3 SEG.2 SEG.1 SEG.03
Notes:
• ERRC: The Error Code (ERRC) indicates the type of bus error: 00 for bit error, 01 for 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 transmitter, 1 for receiver.
• SEG: The Error Segment (SEG) indicates the segment of the TWAI message at which the bus error
occurred.
The following Table 33-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
0 1 1 0 1 reserved bit 1
0 1 0 0 1 reserved bit 0
Cont’d on next page
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 33-18 illustrates bits and fields of TWAI_ERR_CODE_CAP_REG whilst Figure 33-11 illustrates the bit
positions of a TWAI message.
Notes:
• BITNO: Bit Number (BITNO) indicates the nth bit of a TWAI message where arbitration was lost.
ESP32-C6’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 direclty by software.
• Hardware output:
1. Set the TWAI_HW_STANDBY_EN field in the TWAI_HW_CFG_REG register to enable standby function
for hardware.
2. Configure the TWAI_HW_STANDB_CNT_REG register. This register indicates the time required
before hardware trigger the standby signal after entering idle status, in which the value indicates the
number of cycles of the TWAI controller operating clock (40 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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
33.6 Registers
’|’ here means 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 5-2 in Chapter 5 System and
Memory.
E DE
ES _O MO E
_M LY_ E
OD MO
_R EN T_ D
ET N D
AI IST ES MO
TW I_L F_T R_
A EL TE
TW _S FIL
d)
AI X_
ve
TW I_R
r
se
A
TW
(re
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
TH
ID
W
P_
C
ES
M
PR
JU
D_
C_
)
AU
YN
ed
_B
_S
rv
se
AI
AI
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)
G2
G1
M
SA
SE
SE
E_
E_
E_
)
IM
M
ed
I
_T
_T
_T
rv
se
AI
AI
AI
TW
TW
TW
(re
31 8 7 6 4 3 0
IT
M
LI
G_
N
NI
AR
_W
)
RR
ed
_E
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x60 Reset
TWAI_ERR_WARNING_LIMIT 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_
T
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_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)
_1
O DE
_C
CE
AN
PT
E
CC
_A
AI
TW
1|
TE_
BY
d)
X_
ve
_T
r
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_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_
T
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_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)
_3
ODE
_C
CE
AN
EPT
CC
_A
AI
W
|T
3
TE_
BY
d)
X_
ve
_T
r
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_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)
K_0
AS
_M
CE
N
TA
EP
CC
_A
AI
W
|T
4
E_
T
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_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)
1
K_
AS
_M
CE
AN
PT
E
CC
_A
AI
W
|T
5
TE_
BY
d)
X_
ve
_T
r
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_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_
T
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_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)
_3
K
AS
_M
CE
AN
PT
E
CC
_A
AI
W
|T
7
T E_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_7 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_
T
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_8 Configures the 8th byte information of the data to be transmitted in Operation
mode. (WO)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_9 Configures the 9th byte information of the data to be transmitted in Operation
mode. (WO)
10
T E_
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_10 Configures the 10th byte information of the data to be transmitted in Operation
mode. (WO)
11
E_
YT
_B
)
ed
X
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_11 Configures the 11th byte information of the data to be transmitted in Operation
mode. (WO)
12
E_
T
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_12 Configures the 12th byte information of the data to be transmitted in Operation
mode. (WO)
FF
_O
CK
d)
LO
D
ve
_C
_C
r
se
AI
AI
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 LR
N
ND _C
_E
TA BY
_S D
W AN
_S ST
AI W_
)
ed
TW I_S
rv
se
A
TW
(re
31 2 1 0
0x0 0 0 Reset
N
_E
BY
ND
TA
_S
d)
W
ve
_H
r
se
AI
TW
(re
31 1 0
0x0 0 Reset
T
CN
T_
AI
W
Y_
DB
N
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.
AI BO SE_ UN
X_ _T UF
A EL VE Q
TW I_R _O _RE
TW I_A EA RR
_T RT B
RE X
A LR X
Q
TW I_C F_R
d)
A EL
ve
TW I_S
r
se
A
TW
(re
31 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
AI VE F_S TE
F_ T
A X_ T T
BU _S
TW I_O BU LE
TW I_T _S _S
ST
_R RR T
A X_ MP
X_ UN
A RR FF
A US ST
TW I_E _O
TW I_T CO
TW _B _
TW I_T ST
TW I_R ST
AI ISS
)
A X_
A X_
ed
TW I_M
rv
se
A
TW
(re
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 Reset
TWAI_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)
Espressif Systems 1074 ESP32-C6 TRM (Version 1.0)
Submit Documentation Feedback
33 Two-wire Automotive Interface (TWAI) GoBack
P
CA
T_
OS
_L
RB
d)
ve
_A
r
se
AI
TW
(re
31 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
ON
T
EN
TI
EC
M
E
EG
YP
IR
_D
_S
_T
TW CC
CC
CC
)
ed
_E
_E
_E
rv
se
AI
AI
AI
TW
TW
(re
31 8 7 6 5 4 0
TWAI_ECC_SEGMENT Represents the location of errors, see Table 33-16 for details. (RO)
X_
ed
_R
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_RX_ERR_CNT The RX error counter register, reflects value changes in reception status. (RO
| R/W)
T
CN
R_
ER
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_ERR_CNT The TX error counter register, reflects value changes in transmission status.
(RO | R/W)
R
NTE
OU
_C
GE
SA
ES
M
)
X_
ed
_R
rv
se
AI
TW
(re
31 7 6 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
ST
se RR OS T_ ST
T_
ST
IV ST
_R NT N_ ST
TW rve _P T_I ST
(re I_E _L _IN T_
IN
IN T T_
A d ASS NT_
AI _I AR T_
E_
A RB RR IN
X_ _S IN
TW _T _W _IN
TW I_A _E TE_
ST
AI R N
A US TA
T_
U
TW I_B _S
TW I_E RR
A US
d)
TW I_O )
A VE
R
X
ve
TW I_B
r
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 Reset
A
EN
TW rve _P T_I EN A
A
E_ A
se RR OS T_ EN
EN
X_ _E IN A
A d ASS NT_ A
T_
IV EN
N
(re I_E _L _IN T_
IN
IN NA T_
_R NT N_ E
AI _I AR T_
A RB RR IN
TW _T _W _IN
TW I_A _E TE_
A
EN
AI R N
A US TA
T_
U
TW I_B _S
TW I_E RR
A US
)
TW I_O )
A VE
ed
R
X
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
34.1 Overview
The ESP32-C6 features hardware support for the Secure Digital Input/Output (SDIO) device interface that
conforms to the SDIO Specification V2.00. This allows an SDIO host to access the ESP32-C6 via an SDIO bus
protocol.
The SDIO host can read ESP32-C6 SDIO interface registers directly or access shared memory via the Direct
Memory Access (DMA) engine, thus reducing processor’s overhead while keeping high performance.
34.2 Features
The SDIO 2.0 Slave Controller has the following features:
• Compatible with SD Physical Layer Specification V2.00 and SDIO V2.00 specifications
• Support for SPI, 1-bit SDIO, and 4-bit SDIO transfer modes
• Automatic padding data and discarding the padded data on the SDIO bus
• Interrupt vector between the host and slave for bidirectional interrupt
In the above figure, Host represents any host device that is compatible with SDIO Specification V2.00. It
interacts with the ESP32-C6 (configured as the SDIO slave) via the standard SDIO bus implementation.
The SDIO Device Interface block enables effective communication with the external Host by directly providing
SDIO interface registers and enabling DMA operation for high-speed data transfer over the Advanced
High-Performance Bus (AHB) without engaging the CPU.
• SD Specifications Part1 Physical Layer Specification Version 2.00 (referred to as Physical Layer
Specification V2.00 in this chapter)
• SD Specifications Part E1 SDIO Specification Version 2.00, January 30, 2007 (referred to as SDIO
Specification V2.00 in this chapter)
• Bus signal: The physical bus signals of the standard SDIO Specification V2.00, including
CS/DI/SCLK/DO/IRQ in the SPI transmission mode, CMD/CLK/DATA/IRQ in the SDIO 1-bit transmission
mode, and CMD/CLK/DAT[3:0] in the SDIO 4-bit transmission mode.
• Bus speed mode: full-speed card mode of 0 ~ 50 MHz clock range and low-speed card mode of 0 ~
400 kHz clock range.
• IO functions: 2 IO functions in addition to function 0. Function 0 is only used for CCCR, FBR, and CIS
operations. Function 1 and 2 can be used at the same time to transfer application data packets (such as
Wi-Fi packets and Bluetooth packets) and to access SLC Host registers.
For more information, please refer to Physical Layer Specification V2.00 and SDIO Specification V2.00.
IO_RW_DIRECT (CMD52) can be used to access registers and transfer data, but usually it is used to access
registers. Figure 34-2 shows its fields. For the meaning of each field, please refer to the SDIO Specification
V2.00.
IO_RW_EXTENDED (CMD53) is used to initiate the transfer of packets of an arbitrary length. Figure 34-3 shows
the its fields. For the meaning of each field, please refer to the SDIO Specification V2.00.
As defined in the SDIO Specification, CCCR are common control registers, FBR are control configuration
registers for each function, and CIS are status registers for storing card information, such as version, power
consumption, and manufacturer. The functions of these registers are optional, and their meanings are detailed
in the SDIO Specification.
The CCCR configuration of ESP32-C6 SDIO slave is shown in Table 34-1, and the FBR configuration is shown
Table 34-2.
Adress Register Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Set SDIO bit[3:0] using Set CCCR bit[3:0] using
0x00 CCCR/SDIO HINF_SDIO_VER[7:4] in HINF_SDIO_VER[3:0] in
Revision HINF_CFG_DATA1_REG HINF_CFG_DATA1_REG
Set SD bit[3:0] using
0
0x01 SD Specifica- HINF_SDIO_VER[11:8] in
(RFU)
tion Revision HINF_CFG_DATA1_REG
0 R/W 0
0x02 I/O Enable
(IOE[7:3]) (IOE[2:1]) (RFU)
0 R 0
0x03 I/O Ready
(IOR[7:3]) (IOR[2:1]) (RFU)
Cont’d on next page
Table 34-1. SDIO Slave CCCR Configuration – cont’d from previous page
Address Register Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
0 R/W R/W
0x04 Int Enable
(IEN[7:3]) (IEN[2:1]) (IENM)
0 R 0
0x05 Int Pending
(INT[7:3]) (INT[2:1]) (RFU)
0 W W
0x06 I/O Abort
(RFU) (RES) (AS[2:0])
R/W
1 R/W 0 R/W
0x07 Bus Interface (CD
(SCSI) (ECSI) (RFU) (Bus Width[1:0])
Control Disable)
0 0 R/W 1 0 1 1 1
0x08 Card Capability
(4BLS) (LSC) (E4MI) (S4MI) (SBS) (SRW) (SMB) (SDC)
Address 0x09: 0x0; Address 0x0A: 0x10; Address 0x0B: 0x0
0x09- Common CIS
(Pointer to card’s common CIS)
0x0B Pointer
0 0 0
0x0C Bus Suspend
(RFU) (BR) (BS)
0 0 0
0x0D Function Select
(DF) (RFU) (FS[3:0])
0 0
0x0E Exec Flags
(EX[7:1]) (EXM)
0 0
0x0F Ready Flags
(RF[7:1]) (RFM)
R/W (Supported range: 0 - 512)
0x10- FN0 Block Size
(I/O block size for Function 0)
0x11
0 R/W 1
0x12 Power Control
(RFU) (EMPC) (SMPC)
0 R/W Note a
0x13 High-Speed
(RFU) (EHS) (SHS)
a Set SHS using HINF_HIGHSPEED_ENABLE in HINF_CFG_DATA1_REG.
0
0x101
(Function 1 Extended standard SDIO Function interface code)
Cont’d on next page
Table 34-2. SDIO Slave FBR Configuration – cont’d from previous page
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
0 R/W 0
0x102
(RFU) (EPS) (SPS)
Address 0x109: 0x0; Address 0x10A: 0x11; Address 0x10B: 0x0
0x109-
(Pointer to Function 1 CIS)
0x10B
R/W (Supported range: 0 - 512)
0x110-
(I/O block size for Function 1)
0x111
0x2
0
0x200 (Function 2 Standard SDIO
0 0 (RFU)
Function interface code)
(Function (Function
2 CSA 2
enable) supports
CSA)
0
0x201
(Function 2 Extended standard SDIO Function interface code)
0 R/W 0
0x202
(RFU) (EPS) (SPS)
Address 0x209: 0x0; Address 0x20A: 0x12; Address 0x20B: 0x0
0x209-
(Pointer to Function 2 CIS)
0x20B
R/W (Supported range: 0 - 512)
0x210-
(I/O block size for Function 2)
0x211
For effective interaction, the host can access the registers that are in contiguous address from 0x40 to 0x3FF
in the slave via the I/O function 1/2. To access them, the host simply needs to set the Register Address field
of CMD52 or CMD53 to the low 10 bits of their address. Besides, CMD53 allows the host to access multiple
registers at one go for a higher transfer rate.
From SLCHOST_CONF_W0_REG and SLCHOST_CONF_W15_REG, there are 52 bytes of fields that the host and
slave can access and change, thus facilitating the information interaction.
The software on both the host and the slave sides can access the SLC Host register space at the same time,
so an upper-layer mechanism should be designed to avoid the error caused by such behavior.
When the host uses the address 0x400 - 0x1F7FF to continuously transmit multiple application data packets
(such as Wi-Fi packets), the address field in CMD53 should be set to increment mode and the OP Code field
to 1.
For example, if the host wants to use CMD53 to transfer (send or receive) three data blocks starting from the
base address 0x500, then it should:
• Set the Block Mode field in CMD53 to 1, indicating data unit is block
• Set the Register Address field to 0x500, indicating the base address is 0x500
When the packet is transmitted (slave sends to host, or slave receives from host) through CMD53, the slave
will determine whether all the valid data of the current packet has been transmitted so as to pad (when slave
sends to host) or discard (when slave receives from host) the invalid data. For more information about data
padding and discarding, please refer to Section 34.5.5.3.
When the host uses address 0x0 to transmit application data packets (such as Bluetooth packets), the
address field and OP Code field in CMD53 should be set to 0.
For example, if the host wants to use CMD53 to transfer (send or receive) three data blocks starting from the
fixed address 0x0, then it should:
• Set the Block Mode field in CMD53 to 1, indicating data unit is block
• Set the Register Address field to 0x0, indicating the fixed address is 0x0
When the packet is transmitted (slave sends to host, or slave receives from host) between the host and the
slave through CMD53, the slave will determine whether all the valid data of the current packet has been
transmitted so as to pad (when slave sends to host) or discard (when slave receives from host) the invalid
data. For more information about data padding and discarding, please refer to Section 34.5.5.3.
34.5.5 DMA
The SDIO Slave Controller uses a dedicated DMA to access data residing in RAM. As shown in Figure 34-1,
RAM is accessed over the AHB. For the RAM space accessible by the Controller, please refer to Chapter 5
System and Memory. To set the RAM address range that can be accessed for one transfer, please configure
the *SHAREMEM*_REG fields described in Section 34.8.
DMA has two channels, SLC0 and SLC1. They are used to transfer incremental-address packets and
fixed-address packets, respectively. For the convenience of users, the SDIO slave provides function 1/2 for
data transmission. The address range of I/O Function 1/2 is detailed in Section 34.5.4. It is recommended to
transmit incremental-address packets via SLC0 using function 1 and fixed-address packets via SLC1 using
function 2.
DMA accesses RAM over AHB. Users can configure whether the AHB interface can use burst operation and
which burst operation type to use by configuring the relevant fields in SDIO_SLCCONF0_REG and
SDIO_SLC_BURST_LEN_REG. For more information, please refer to Section 34.8.
The slave software can use the DMA engine by mounting linked lists. DMA sends the data from the RAM
address space configured in the RX (slave to host) linked list and stores the received data into the address
space configured in the TX (host to slave) linked list. A linked list consists of several descriptors.
Figure 34-6. DMA Linked List Descriptor Structure of the SDIO Slave
The TX linked list descriptor and the RX linked list descriptor have the same structure, which is shown in Figure
34-6. The descriptor consists of 3 words. The meaning of each field is as follows:
• owner (DW0) [31]: Indicates who is allowed to access the buffer that this descriptor points to.
0: CPU
1: DMA engine
Slave software should set this field to 1 when creating the descriptor. After the DMA write-back
permission is enabled and the corresponding buffer is used by the DMA, the field is cleared to 0.
packets from the slave, the slave software configures the field depending on whether this descriptor is
the last descriptor of the packet.
• length (DW0) [27:14]: Indicates the number of valid bytes in the corresponding buffer. When the DMA
engine is reading data from the buffer, it indicates the number of bytes that can be read; when DMA
engine is storing data in the buffer, it indicates the number of bytes of the stored data.
When the host sends a packet to the slave, the slave software should set this field to 0x0 while creating
the descriptor. DMA writes back the field after the corresponding buffer is used up; when the host
receives the packet from the slave and the slave creates the descriptor, the slave software should set
this field to the number of bytes that can be read by the corresponding buffer.
• size (DW0) [13:0]: Indicates the size of the corresponding buffer. Unit: byte.
Slave software should configure this field when creating the descriptor.
Note: This field must be word-aligned.
• next descriptor address (DW2): Address of the next descriptor. When the next descriptor does not exist,
the value is 0.
Slave software should configure this field when creating the descriptor.
For more information on DMA write-back linked list descriptor fields, please refer to Section 34.5.5.2.
The slave software can combine multiple descriptors into a linked list using the next descriptor address (DW2)
field. The SDIO slave DMA linked list is shown in Figure 34-7.
An example is provided below to facilitate understanding of the linked list and the eof bit. Suppose the slave
software creates a linked list that contains 3 descriptors; descriptor 0 points to 500 bytes data and its eof bit is
0; descriptor 1 points to 200 bytes data and its eof bit is 1; descriptor 2 points to 200 bytes data and its eof bit
is 1. If the first CMD53 needs to read 400 bytes data, then DMA sends the first 400 bytes data of descriptor 0
to the host. If the second CMD53 needs to read 400 bytes data, firstly DMA sends the remaining 100 bytes
data of descriptor 0 to the host. Secondly, it sends 200 bytes data of descriptor 1 to the host. Since the eof
bit of descriptor 1 is 1, DMA considers the valid data of the current CMD53 is over. So, lastly DMA sends 100
bytes invalid data 0x0 to the host. If the third CMD53 needs to read 400 bytes data, firstly DMA sends the 200
bytes data of descriptor 2 to the host. Since descriptor 2’s eof bit is 1, DMA considers the valid data of current
CMD53 is over. So, DMA sends 200 bytes invalid data 0x0 to the host.
In the process of sending packets from the host to the slave, when the buffer specified by a linked list
descriptor is full, or when a packet transmission ends, the DMA engine needs to jump to the next descriptor to
store subsequent data. Before the jump, DMA writes back the current descriptor. In DW0, DMA updates the
eof and length bits to the latest value. The value of the owner bit is determined by
SDIO_SLC0/1_TX_LOOP_TEST in SDIO_SLCCONF0_REG.
In the process of receiving packets from the slave, when the host reads all the data in the buffer specified by
a linked list descriptor, DMA engine needs to jump to the next descriptor to read subsequent data. Before the
jump, the slave software can set SDIO_SLC0/1_RX_AUTO_WRBACK in SDIO_SLCCONF0_REG to 1 so that the
DMA will write back the current descriptor. The value to write to the owner bit is determined by
SDIO_SLC0/1_RX_LOOP_TEST in SDIO_SLCCONF0_REG. Values of other bits in DW0 remain
unchanged.
In order to transfer data in blocks, both the host and the slave need to pad the data sent on the SDIO bus into
entire blocks. The slave will automatically pad data when sending the packet, and automatically discard the
padded data after receiving packets.
• When the host sends a data packet to the slave through CMD53 and the amount of data reaches the
length of the data packet, the SDIO slave considers that the valid data of the current data packet is over.
At this time, DMA will write back the current linked list descriptor, set the eof bit of the current descriptor
to 1, and generate SLC0/1_TX_SUC_EOF_INT interrupt. After it determines that the valid data is over, the
remaining data of the current packet will be considered as invalid data, and will not be received into the
buffer by DMA. The slave will not restart receiving data into the next buffer until the next CMD53.
– For incremental-address packets, the slave determines valid data based on the address. The data
with the address greater than or equal to 0x1F800 is considered as invalid data and will be
discarded. Therefore, the host should set the CMD53 start address field to 0x1F800 –
Packet_length (unit: byte). The data flow of incremental-address packets on SDIO bus is shown in
Figure 34-8.
Figure 34-8. Data Flow of Sending Incremental-address Packets From Host to Slave
– For fixed-address packets, the slave considers the first 3 bytes of the data packet as the packet
length (including the first 3 bytes, which will also be stored in the buffer specified by the linked list).
After the length of the received data reaches the packet length, the subsequent data will be
considered as invalid and discarded.
• When the host receives data packets (including incremental-address packets and fixed-address
packets) from the slave through CMD53 and DMA reads the last byte of a buffer and the eof bit of the
DMA linked list descriptor is 1, the SDIO slave will consider the valid data of the current packet is over. At
this time, DMA will write back the current descriptor and generate SLC0/1_RX_EOF_INT interrupt. After it
is determined that the valid data is over, the remaining bits of the current data packet will be padded with
invalid data 0x0, and will not be read from the buffer via DMA. The slave will restart to read data from the
buffer via DMA until the next CMD53.
Note: When the host receives either incremental-address or fixed-address data packets from the slave,
the eof bit of the DMA linked list descriptor is always considered as the basis for determining the end of
data, rather than the address 0x1F800. Therefore, when the host sends multiple CMD53s to obtain
multiple data packets, as long as the DMA does not encounter the eof bit is 1 in the descriptors, the
slave will obtain the data from buffers in sequence according to the linked list and then transmit them to
the host; when the DMA encounters the eof bit is 1, the data will be fetched from the corresponding
buffer, and then invalid data will be added to complete the current CMD53 command, and the next
CMD53 command will take data from the buffer pointed to by the next descriptor.
When the incoming data changes near the rising edge of the clock, the slave will perform sampling on the
falling edge of the clock, or vice versa, as Figure 34-9 shows.
By default, the MTMS (GPIO4) strapping value determines the slave’s sampling edge. However, users can
decide the sampling edge by configuring the SLCHOST_CONF_REG register, with priority from high to low: (1)
Set SLCHOST_FRC_POS_SAMP to sample the corresponding signal at the rising edge; (2) Set
SLCHOST_FRC_NEG_SAMP to sample the corresponding signal at the falling edge.
SLCHOST_FRC_POS_SAMP and SLCHOST_FRC_NEG_SAMP fields are five bits wide. The bits correspond to
the CMD line and four DATA lines (0-3). Setting a bit causes the corresponding line to be sampled for input at
the rising clock edge or falling clock edge.
The slave can also select which edge to drive the output lines, in order to accommodate for any latency
caused by the physical signal path. The output timing is shown in Figure 34-10.
By default, the MTDI (GPIO5) strapping value determines the slave’s output driving edge. However, users can
decide the output driving edge by configuring the following registers, with priority from high to low: (1) Set
SLCHOST_FRC_SDIO11 in SLCHOST_CONF_REG to output the corresponding signal at the falling clock edge;
(2) Set SLCHOST_FRC_SDIO22 in SLCHOST_CONF_REG to output the corresponding signal at the rising clock
edge; (3) Set HINF_HIGHSPEED_ENABLE in HINF_CFG_DATA1_REG and SLCHOST_HSPEED_CON_EN in
SLCHOST_CONF_REG, then set the EHS (Enable High-Speed) bit in CCCR at the host side to output the
corresponding signal at the rising clock edge.
SLCHOST_FRC_SDIO11 and SLCHOST_FRC_SDIO22 fields are five bits wide. The bits correspond to the CMD
line and four DATA lines (0-3). Setting a bit causes the corresponding line to output at the rising clock edge or
falling clock edge.
Notes on priority setting: The configuration of strapping pins has the lowest priority when controlling the
sampling edge or driving edge. The lower-priority configuration takes effect only when the higher-priority
configuration is not set. For example, the MTMS (GPIO4) strapping value determines the sampling edge only
when SCLHOST_FRC_POS_SAMP and SCLHOST_FRC_NEG_SAMP are not set.
34.6 Interrupt
The host and the slave can interrupt each other via the interrupt vector. There are 8 interrupt vectors between
the host and each DMA SLC channel of the slave. To send an interrupt to the other side, the enable bit of the
interrupt vector register should be set to 1.
– When a new RX linked list descriptor is coming after DMA processes the RX linked list descriptor
with the eof bit being 1
• SLC_FRHOST_BITn_INT (n: 0 ~ 15): The host interrupts the slave via the SLC0 channel if interrupt
vector Bit[7:0] is set or via the SLC1 channel if interrupt vector Bit[15:8] is set.
1. The slave CPU creates the linked list for the data packets that it will send to the host. For how to create a
linked list, please refer to Section 34.5.5.1.
2. The slave CPU updates the length of data that will be sent to the host using the register
SDIO_SLC0_LEN_CONF_REG.
3. The slave CPU starts DMA by writing the 32-bit address of the first descriptor in linked list to
SDIO_SLC0RX_LINK_ADDR_REG or SDIO_SLC1RX_LINK_ADDR_REG and then configuring
SDIO_SLC0_RXLINK_START or SDIO_SLC1_RXLINK_START to start DMA. For more information on DMA,
please refer to Section 34.5.5.
• SLCHOST_PKT_LEN_REG: Packet length accumulator register. The current value minus the value of
last time equals the packet length sent this time.
7. The host fetches packets from the slave through CMD53. During the transmission, when the slave
determines that the valid data of the current packet is over, the subsequent bits will be padded with
invalid data 0x0. For how to determine the end of valid data, please refer to Section 34.5.5.3.
8. After the packets is transmitted, the slave DMA sends an interrupt to the CPU, and the CPU can recycle
the buffer at this time.
Notes:
• It is not recommended to set all of the eof bits to 0 in the linked list. Otherwise, the DMA may send the
data of the next packet to the current command, which may cause errors. In cases where all of the eof
bits is set to 0, the slave software should align the length of each packet to the size of the data block by
padding data, to prevent the DMA from sending the data of the next packet to the current command.
When the host sends CMD53 to read data, it should accurately control the number of data blocks in
each packet, do not read more or less data blocks. Besides, the host should be able to identify the
padded data.
• It is recommended that a CMD53 command only should transmit one data packet and each data packet
should use only one linked list so as to avoid unknown exceptions caused by complex transmission.
• It is not recommended to send multiple packets through one linked list because it may be difficult for the
host and software to split between the data packets. In cases where this has to be done, the software
should set the eof bit when creating the linled list to divide the data packets so that the DMA can pad
data packets accordingly (it is recommended that the length of each data packet should be aligned to
the size of the data block to avoid data padding by DMA), and the host should be able to identify the
padded data.
The host obtains the number of available receiving buffers from the slave by accessing
SLCHOST_SLC0HOST_TOKEN_RDATA_REG or SLCHOST_SLC1HOST_TOKEN_RDATA_REG. The slave CPU
should update the value of the register after the receiving DMA linked list is prepared.
During the transmission of packets to the slave through the CMD53 command, when a buffer specified by a
linked list descriptor is written full, or when a packet transmission ends, the DMA will jump to the next buffer to
store subsequent data. When the slave determines that the valid data of the current packet is over, the
remaining data will be considered invalid and discarded, DMA will write back the current linked list descriptor,
set the eof bit of the current descriptor to 1, and the SLC0/1_TX_SUC _EOF_INT interrupt will be
generated.
For more information about DMA functions, linked list, and data discarding, please refer to Section
34.5.5.
To ensure sufficient receiving buffers, the slave CPU must constantly load buffers on the receiving linked list.
The process is shown in Figure 34-13.
The CPU first needs to append new buffer segments at the end of the linked list that is being used by DMA
and is available for receiving data.
The CPU then needs to notify the DMA that the linked list has been updated. This can be done by setting
SDIO_SLC0_TXLINK_RESTART or SDIO_SLC1_TXLINK_RESTART. Please note that when the CPU initiates DMA
to receive packets for the first time, SDIO_SLC0_TXLINK_START or SDIO_SLC1_TXLINK_START should be set to
1.
Notes: Use the *_RESTART field to restart DMA only in the two scenarios:
• DMA is suspended as a result of insufficient linked list descriptors. Users can restart it after descriptors
are added.
Lastly, the CPU refreshes any available buffer information by writing to the SDIO_SLC0TOKEN1_REG or
SDIO_SLC1TOKEN1_REG register.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
34.9 Registers
The addresses in this section are relative to SDIO 2.0 Slave Controller base address provided in Table 5-2 in
Chapter 5 System and Memory.
1
N
N1
_F
F
ID
D_
_
CE
_I
ER
VI
S
E
_D
_U
NF
NF
HI
HI
31 16 15 0
Y1 LE
ed O E E
AD B
(re _S SP D_ LE
rv _I D_ D
) RE NA
se DIO EE MO
HI _H HSP EN 2
E B
NF IG D Y
NF IG E A
HI _H _C EAD
HI rve AB LE
PS
E2
E1
_
se EN AB
R
_E
O R
NF D_ E
NF MP L
NF d L
E
HI _S _IO
HI _C C1_
HI _E AB
_V
C2
H
N
IO
O
d)
HI _S )
UN
NF UN
NF E
NF DI
NF DI
D
ve
HI _IO
_S
_F
HI _F
r
se
NF
NF
NF
(re
HI
HI
HI
31 25 24 23 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0x232 0 0 0 0 0 0 0 1 0 0 0 1 Reset
HINF_SDIO_IOREADY1 Configures the field IOR1 in SDIO CCCR and the field function 1 ready in SDIO
CIS.
0: The function 1 is not ready
1: The function 1 is ready
Please refer to SDIO Specification for details.
(R/W)
HINF_SDIO_IOREADY2 Configures the field IOR2 in SDIO CCCR and the field function 2 ready in
SDIO CIS.
0: The function 2 is not ready
1: The function 2 is ready
Please refer to SDIO Specification for details.
(R/W)
EN
R
T_
CL
IN
P_
1_
EU
TA
TE
TE
AK
DA
TA
RS
TA
W
se IO_
_S
O_
O_
_S
IP
_S )
d)
)
(re SD
NF d
ed
IN
DI
DI
H
HI rve
ve
_C
_P
_S
_E
rv
r
se
se
NF
NF
NF
NF
(re
(re
HI
HI
HI
HI
31 30 29 20 19 18 17 16 15 8 7 0
HINF_PIN_STATE Configures SDIO CIS address 318 and 574. Please refer to SDIO Specification for
details. (R/W)
HINF_CHIP_STATE Configures SDIO CIS address 312, 315, 568, and 571. Please refer to SDIO Spec-
ification for details. (R/W)
HINF_SDIO_WAKEUP_CLR Configures whether to clear wake up signal after the chip is waken up by
the SDIO slave.
0: No effect
1: Clear
(WT)
31 0
0xffffffff Reset
HINF_CIS_CONF_Wn Configures SDIO CIS address (39+4*n) ~ (36+4*n). Please refer to SDIO
Specification for details. (R/W)
N2
N2
_F
F
ID
D_
_
CE
_I
ER
VI
S
E
_D
_U
NF
NF
HI
HI
31 16 15 0
0
IG
NF
O
_C
C0
)
UN
ed
rv
_F
se
NF
(re
HI
31 8 7 0
HINF_FUNC0_CONFIG0 Represents SDIO CIS function 0 config0 (addr: 0x20f0) status. Please
refer to SDIO Specification for details. (RO)
X O R _C
IO LC RX_ O_ UR EN
OP ES CK
EN
RS EN
X_ O R C
IO LC X_ _R RS N
OP ES CK
R_ RS R
RS EN
R_ RS R
se 1_T LO _W RT_
SD _S 1_R NO BU T_E
se 0_T _LO _W RT
T_
_S 1_ AU E T_
SD _S 0_ _N _B ST_
SC BU CL
T_
_S 0_ A RE ST
BU T_
BU T_
_T T
T
_T T
T
XD _ O_
IO LC X_ R_ RS
ES
X A_ O
IO LC RX CR R
ES
se 0_T AT UT
SD _S 0_ S BU
S
se 1_T ATA UT
SD _S 1_R SC BU
IO LC RXD A_
(re LC XD _A
IO C XD _
TX ST
ST
IO d X_ T
A
SD S _ AT
SD rve 1_T RS
_S 1_T EN
SD _S _R AT
RS
0_ _R
_S 0_ E
_R
IO LC XD
IO C OK
IO LC XD
se LC X_
IO LC OK
LC RX
R
SD _S 0_T
SD _S 1_R
(re _S _R
SD _S 1_T
SD _S 0_
_S 0_
0
1
1
IO d)
SD ed)
SD ed)
SD _S )
IO LC
IO C
IO LC
IO LC
IO C
IO C
L
L
SD rve
SD _S
SD _S
SD _S
SD _S
SD _S
rv
rv
rv
rv
_
se
IO
IO
IO
IO
(re
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SDIO_SLC0_TX_RST Configures whether to reset TX (host to slave) FSM (finite state machine) in
SLC0.
0: No effect
1: Reset
(R/W)
SDIO_SLC0_TX_LOOP_TEST Configures whether SCL0 loops around when the slave buffer finishes
receiving packets from the host.
0: Not loop around
1: Loop around, and hardware will not change the owner bit in the linked list
(R/W)
SDIO_SLC0_RX_LOOP_TEST Configures whether SCL0 loops around when the slave buffer finishes
sending packets to the host.
0: Not loop around
1: Loop around, and hardware will not change the owner bit in the linked list
(R/W)
SDIO_SLC0_RX_AUTO_WRBACK Configures whether SCL0 changes the owner bit of RX linked list.
0: Not change
1: Change
(R/W)
SDIO_SLC0_RXDSCR_BURST_EN Configures whether SCL0 can use AHB burst operation when
reading the RX linked list from memory.
0: Only use single operation
1: Can use burst operation
(R/W)
SDIO_SLC0_RXDATA_BURST_EN Configures whether SCL0 can use AHB burst operation when read
data from memory.
0: Only use single operation
1: Can use burst operation
(R/W)
SDIO_SLC0_TXDSCR_BURST_EN Configures whether SCL0 can use AHB burst operation when read
the TX linked list from memory.
0: Only use single operation
1: Can use burst operation
(R/W)
SDIO_SLC0_TXDATA_BURST_EN Configures whether SCL0 can use AHB burst operation when
send data to memory.
0: Only use single operation
1: Can use burst operation
(R/W)
SDIO_SLC1_TX_LOOP_TEST Configures whether SCL1 loops around when the slave buffer finishes
receiving packets from the host.
0: Not loop around
1: Loop around, and hardware will not change the owner bit in the linked list
(R/W)
SDIO_SLC1_RX_LOOP_TEST Configures whether SCL1 loops around when the slave buffer finishes
sending packets to the host.
0: Not loop around
1: Loop around, and hardware will not change the owner bit in the linked list
(R/W)
SDIO_SLC1_RX_AUTO_WRBACK Configures whether SCL1 changes the owner bit of the RX linked
list.
0: Not change
1: Change
(R/W)
SDIO_SLC1_RXDSCR_BURST_EN Configures whether SCL1 can use AHB burst operation when read
the RX linked list from memory.
0: Only use single operation
1: Can use burst operation
(R/W)
SDIO_SLC1_RXDATA_BURST_EN Configures whether SCL1 can use AHB burst operation when read-
ing data from memory.
0: Only use single operation
1: Can use burst operation
(R/W)
SDIO_SLC1_TXDSCR_BURST_EN Configures whether SCL1 can use AHB burst operation when read
the TX linked list from memory.
0: Only use single operation
1: Can use burst operation
(R/W)
SDIO_SLC1_TXDATA_BURST_EN Configures whether SCL1 can use AHB burst operation when send
data to memory.
0: Only use single operation
1: Can use burst operation
(R/W)
NK TA T
LI _S AR
_S RT
P
LC RX K_ RK
RX K EST
TO
_S 0_ IN PA
0_ LIN R
IO LC RXL K_
SD _S 0_ LIN
IO LC RX
SD _S 0_
)
IO LC
ed
SD _S
rv
se
IO
(re
SD
31 30 29 28 27 0
1 0 0 0 0x0 Reset
SDIO_SLC0_RXLINK_START Configures whether to start SLC0 RX linked list operation from the ad-
dress indicated by SDIO_SLC0_RXLINK_ADDR.
0: No effect
1: Start the operation
(R/W/SC)
SDIO_SLC0_RXLINK_RESTART Configures whether to restart and continue SLC0 RX linked list op-
eration.
0: No effect
1: Restart the operation
(R/W/SC)
31 0
0x0 Reset
NK TA T
LI S AR
_S RT
P
LC TX K_ RK
TX K_ ST
TO
0_ LIN RE
_S 0_ IN A
IO LC XL K_P
SD _S 0_T LIN
IO LC X
SD _S 0_T
)
IO LC
ed
SD _S
rv
se
IO
(re
SD
31 30 29 28 27 0
1 0 0 0 0x0 Reset
SDIO_SLC0_TXLINK_START Configures whether to start SLC0 TX linked list operation from the ad-
dress indicated by SDIO_SLC0_TXLINK_ADDR.
0: No effect
1: Start the operation
(R/W/SC)
SDIO_SLC0_TXLINK_RESTART Configures whether to restart and continue SLC0 TX linked list op-
eration.
0: No effect
1: Restart the operation
(R/W/SC)
31 0
0x0 Reset
NK TA T
LI _S AR
_S RT
P
LC RX K_ RK
RX K ST
TO
1_ LIN RE
_S 1_ IN A
IO LC XL _P
SD _S 1_R INK
IO LC XL
SD _S 1_R
)
IO LC
ed
SD _S
rv
se
IO
(re
SD
31 30 29 28 27 0
1 0 0 0 0x100000 Reset
SDIO_SLC1_RXLINK_START Configures whether to start SLC1 RX linked list operation from the ad-
dress indicated by SDIO_SLC1_RXLINK_ADDR.
0: No effect
1: Start the operation
(R/W/SC)
SDIO_SLC1_RXLINK_RESTART Configures whether to restart and continue SLC1 RX linked list oper-
ation.
0: No effect
1: Restart the operation
(R/W/SC)
31 0
0x0 Reset
NK TA T
LI S AR
_S RT
P
LC XL K_ K
TX K_ ST
TO
_S 1_T IN AR
1_ IN RE
IO LC XL _P
SD _S 1_T INK
IO LC XL
SD _S 1_T
)
IO LC
ed
SD _S
rv
se
IO
(re
SD
31 30 29 28 27 0
1 0 0 0 0x0 Reset
SDIO_SLC1_TXLINK_START Configures whether to start SLC1 TX linked list operation from the ad-
dress indicated by SDIO_SLC1_TXLINK_ADDR.
0: No effect
1: Start the operation
(R/W/SC)
SDIO_SLC1_TXLINK_RESTART Configures whether to restart and continue SLC1 TX linked list oper-
ation.
0: No effect
1: Restart the operation
(R/W/SC)
31 0
0x0 Reset
E
N1 C OR
KE _IN M
TA
TO N1 C_
DA
R
0_ KE IN
_W
_W
LC TO N1_
N1
N1
KE
_S 0_ E
KE
IO LC OK
TO
TO
SD _S 0_T
0_
0_
)
IO d)
LC
IO LC
LC
ed
SD rve
_S
SD _S
_S
rv
se
se
IO
IO
(re
(re
SD
SD
31 28 27 16 15 14 13 12 11 0
SDIO_SLC0_TOKEN1 Represents the SLC0 accumulated number of buffers for receiving packets.
(RO)
TA
TO N1 C_
DA
R
1_ E IN
_W
W
LC OK 1_
1_
1
EN
_S 1_T EN
EN
K
IO LC OK
K
TO
TO
SD _S 1_T
1_
1_
)
IO d)
LC
IO LC
LC
ed
SD rve
_S
SD _S
_S
rv
se
se
IO
IO
(re
(re
SD
SD
31 28 27 16 15 14 13 12 11 0
SDIO_SLC1_TOKEN1 Represents SLC1 accumulated number of buffers for receiving packets. (RO)
LD LR
L
O_ N CH N
N
D_ TO N
T_ CH N
SE
VE EN
DI LE TIT _E
_E
HO _C
U E
IN IT _E
CM _A _
L_
LE _
_S 0_ S CH
T_ ST CH
IO LC X_ IT
OS X_ IT
SD _S 0_T _ST
_H 1_T ST
IO LC X_
IO LC RX
SD _S 1_R
SD _S 0_
)
d)
)
IO LC
IO LC
ed
ed
ve
SD _S
SD _S
rv
rv
r
se
se
se
IO
IO
(re
(re
(re
SD
SD
31 22 21 20 19 18 7 6 5 4 3 2 0
CE
LA
EP
_R
NO
N_
O KE
_T
C0
)
ed
SL
rv
O_
se
I
(re
SD
31 1 0
0x101b80d 0 Reset
N_ C RE
LE IN MO
TA
0_ N_ C_
DA
R
LC LE IN
W
_S 0_ _
N_
IO LC LEN
LE
SD _S 0_
0_
)
IO LC
LC
ed
SD _S
_S
rv
se
IO
IO
(re
SD
SD
31 23 22 21 20 19 0
SDIO_SLC0_LEN_WDATA Configures the length of the data that the slave wants to send. (WT)
31 0
0x0 Reset
R
DD
_A
ND
_E
EM
EM
HAR
_S
TX
0_
LC
_S
D IO
_S
IO
SD
31 0
0xffffffff Reset
R
DD
_A
RT
TA
_S
EM
EM
AR
SH
X_
R
0_
LC
_S
D IO
_S
IO
SD
31 0
0x0 Reset
R
DD
_A
ND
_E
EM
EM
AR
SH
X_
_R
C0
SL
O_
DI
_S
IO
SD
31 0
0xffffffff Reset
R
DD
_A
RT
TA
_S
EM
EM
AR
H
_S
TX
1_
LC
_S
D IO
_S
IO
SD
31 0
0x0 Reset
R
DD
_A
ND
_E
EM
EM
AR
SH
X_
T
1_
LC
_S
D IO
_S
IO
SD
31 0
0xffffffff Reset
R
DD
_A
RT
TA
_S
EM
EM
AR
SH
X_
R
1_
LC
_S
D IO
_S
IO
SD
31 0
0x0 Reset
R
DD
_A
ND
_E
EM
EM
AR
SH
X_
R
1_
LC
_S
D IO
_S
IO
SD
31 0
0xffffffff Reset
ST EN
EN
DA _B T_ N
_B RS N
TX TA RS LE
TA U LE
UR T_L
_L
0_ DA BU T_
LC RX A_ RS
_S 0_ AT BU
IO LC XD A_
SD _S 1_T AT
IO LC XD
SD _S 1_R
)
IO LC
ed
SD _S
rv
se
IO
(re
SD
31 4 3 2 1 0
0x0 1 1 1 1 Reset
NT AW
AW
AW W
T0 T_ W
AW
_S _F OS IT NT AW
OS BI _IN RAW
_F OS BIT IN AW
SD _S _FR OS BIT INT AW
NT W
_I _R
_R
_R RA
BI IN RA
_ I RA
IO LC H T_ 7_ AW
NE F_ AW
IO LC H T_ IN AW
RR INT
IO LC H T_ 5_ _R
_R
IO LC H T_B 4_I _R
LC RH T_ 3_ _R
IO LC H T_ 6_ R
NT _
T_ T1_ T_
SD _S _FR _ST T_ RAW
RH T_ 2 T_
se 0_T SU E_ AW
SD _S 0_ _ST _IN AW
SD _S _FR OS T_ _R
_E R_
IO LC X DF _R
IO LC H AR INT
CR ER
IO LC RX AR T_
X C N
SD _S 0_T _U INT
I
_S 0_ D IN
SD _S ) _DS R_
IO LC X_ F_
IO LC RX F_
IO d X SC
SD _S 0_ EO
SD _S 0_ OV
SD rve 0_T _D
IO C X_
IO LC X_
se LC RX
R
R
SD _S 0_T
(re _S 0_
SD _S 0_
d)
IO LC
IO LC
IO C
L
L
ve
SD _S
SD _S
rv
r
se
IO
IO
(re
SD
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NT T
T
_I _S
_S
_S ST
BI IN ST
T
_S _F OS IT NT T
OS BI _IN ST
_F OS BIT IN T
SD _S _FR OS BIT INT T
_I ST
RR INT
IO LC H T_ 5_ _S
_S
IO LC H T_B 4_I _S
LC RH T_ 3_ _S
IO LC H T_ 6_ S
NT _
T_ T1_ T_
IO LC H T_ 7_ T
NE F_ T
RH T_ 2 T_
IO LC H T_ IN T
T
T0 T_
NT
SD _S _FR OS BIT T_S
SD ed) _DO _EO T_S
SD _S _FR OS T_ _S
_E R_
SD _S _FR _ST T_ ST
se 0_T SU E_ T
SD _S 0_ _ST _IN T
(re LC TX_ ON T_S
IO LC X DF _S
IO LC H AR INT
CR ER
IO LC RX AR T_
X C N
SD _S 0_T _U INT
I
_S 0_ D IN
SD _S ) _DS R_
IO LC X_ F_
IO LC RX F_
IO d X SC
SD _S 0_ EO
SD _S 0_ OV
SD rve 0_T _D
IO C X_
IO LC X_
se LC RX
R
R
SD _S 0_T
(re _S 0_
SD _S 0_
)
IO LC
IO LC
IO C
ed
L
SD _S
SD _S
rv
rv
se
IO
IO
(re
SD
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NT NA
NA
NA A
T0 T_ A
NA
_S _F OS IT NT NA
T_ T1_ T_ A
_F OS BIT IN NA
_I _E
NT A
_E
_E EN
BI IN EN
OS BI _IN EN
_I EN
IO LC H T_ 7_ NA
RR INT
NE F_ NA
IO LC H T_ 5_ _E
_E
IO LC H T_B 4_I _E
IO LC H T_ IN NA
LC RH T_ 3_ _E
IO LC H T_ 6_ E
NT _
RH T_ 2 T_
IO LC H AR INT A
SD _S 0_ _ST _IN NA
SD _S _FR OS T_ _E
SD _S _FR _ST T_ EN
_E R_
IO LC X DF _E
CR ER
IO LC RX AR T_
X C N
SD _S 0_T _U INT
I
_S 0_ D IN
SD _S ) _DS R_
IO LC X_ F_
IO LC RX F_
IO d X SC
SD _S 0_ EO
SD _S 0_ OV
SD rve 0_T _D
IO C X_
IO LC X_
se LC RX
R
R
SD _S 0_T
(re _S 0_
SD _S 0_
)
IO LC
IO LC
IO C
ed
L
SD _S
SD _S
rv
rv
se
IO
IO
(re
SD
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NT LR
LR
LR R
T0 T_ R
LR
_I _C
_S _F OS IT NT LR
OS BI _IN CLR
_F OS BIT IN LR
_C
NT R
_C CL
BI IN CL
_I C L
RR INT
IO LC H T_ 5_ _C
_C
IO LC H T_B 4_I _C
IO LC H T_ 7_ LR
NE F_ LR
LC RH T_ 3_ _C
IO LC H T_ IN LR
IO LC H T_ 6_ C
NT _
T_ T1_ T_
RH T_ 2 T_
SD _S _FR OS BIT INT_
_I INT
SD _S 0_ _ST _IN LR
SD _S _FR OS T_ _C
_E R_
IO LC X DF _C
IO LC H AR INT
CR ER
IO LC RX AR T_
X C N
SD _S 0_T _U INT
I
_S 0_ D IN
SD _S ) _DS R_
IO LC X_ F_
IO LC RX F_
IO d X SC
SD _S 0_ EO
SD _S 0_ OV
SD rve 0_T _D
IO C X_
IO LC X_
se LC RX
R
R
SD _S 0_T
(re _S 0_
SD _S 0_
)
IO LC
IO LC
IO C
ed
L
SD _S
SD _S
rv
rv
se
IO
IO
(re
SD
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NT AW
AW
T8 T_ AW
SD _S _FR OS BIT _IN RAW
RH T_ 10 T_ W
SD _S _FR OS BIT _IN RAW
LC RH T_ 11_ T_ W
T_ T9_ T_ W
AW
NT W
AW W
_F OS BIT IN RA
_S _F OS IT IN A
_I _R
OS BI _IN RA
_R
_ I RA
_R RA
BI IN R
IO LC H T_B 12_ T_R
IO LC H T_ 15 AW
_R
NE F_ AW
IO LC H T_ NT W
RR INT
IO LC H T_ 14 T_
IO LC H T_ 13 T_
NT _
SD _S _FR ST T_IN AW
se 1_T SU _I AW
IO LC X_ R _R
(re LC X_ NE T_R
X_ C_ NT
IO LC X_ F_ _R
IO LC H AR T
CR ER
SD _S 1_T UD INT
_S 1_T D IN
DS _
IO d X_ CR
IO LC X_ F_
IO LC X_ F_
O
SD rve 1_T DS
SD _S 1_R EO
SD _S 1_R OV
se LC X_
IO LC X_
IO LC X_
(re _S 1_R
SD _S _R
SD _S 1_T
1
)
SD _S )
SD ed)
IO LC
IO LC
IO C
ed
L
SD _S
SD _S
rv
rv
se
IO
IO
(re
SD
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NT LR
LR
T8 T_ LR
SD _S _FR OS BIT _IN CLR
RH T_ 10 T_ R
SD _S _FR OS BIT _IN CLR
LC RH T_ 11_ T_ R
T_ T9_ T_ R
LR
NT LR
LR R
_F OS BIT IN CL
_I _C
_S _F OS IT IN L
_C
OS BI _IN CL
_C CL
BI IN C
IO LC H T_B 12_ T_C
_C
_I C
RR INT
IO LC H T_ 14 T_
IO LC H T_ 13 T_
IO LC H T_ 15 LR
NE F_ LR
IO LC H T_ NT R
NT _
SD _S _FR ST T_IN LR
se 1_T SU _I LR
IO LC X_ R _C
(re LC X_ NE T_C
X_ C_ NT
IO LC X_ F_ _C
IO LC H AR T
CR ER
SD _S 1_T UD INT
_S 1_T D IN
DS _
IO d X_ CR
IO LC X_ F_
IO LC X_ F_
O
SD rve 1_T DS
SD _S 1_R EO
SD _S 1_R OV
se LC X_
IO LC X_
IO LC X_
(re _S 1_R
SD _S _R
SD _S 1_T
1
)
SD _S )
SD ed)
IO LC
IO LC
IO C
ed
L
SD _S
SD _S
rv
rv
se
IO
IO
(re
SD
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
VE
VE
NT
NT
_I
I
T_
ST
OS
HO
H
TO
TO
0_
1_
)
)
LC
LC
ed
ed
_S
_S
rv
rv
se
se
IO
IO
(re
(re
SD
SD
31 24 23 16 15 8 7 0
NT T1
T1
T8 T_ 1
SD _S _FR OS BIT _IN ST1
RH T_ 10 T_ 1
SD _S _FR OS BIT _IN ST1
LC RH T_ 11_ T_ 1
T_ T9_ T_ 1
BI IN ST
_F OS BIT IN ST
T1
_S _F OS IT IN T
NT 1
_I _S
T1 1
_S
OS BI _IN ST
_I ST
_S ST
_S
RR INT
IO LC H T_ 14 T_
IO LC H T_ 13 T_
IO LC H T_ 15 1
NE F_ T1
NT _
IO LC H T_ NT 1
SD _S _FR OS BIT _ST
SD _S _FR OS T_I _ST
_I INT
IO LC X_ R _S
(re LC X_ NE T_S
X_ C_ NT
IO LC X_ F_ _S
IO LC H AR T
CR ER
SD _S 1_T UD INT
_S 1_T D IN
DS _
IO d X_ CR
IO LC X_ F_
IO LC X_ F_
O
SD rve 1_T DS
SD _S 1_R EO
SD _S 1_R OV
se LC X_
IO LC X_
IO LC X_
(re _S 1_R
SD _S _R
SD _S 1_T
1
)
SD _S )
SD ed)
IO LC
IO LC
IO C
ed
L
SD _S
SD _S
rv
rv
se
IO
IO
(re
SD
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
_E 1
1
NT NA
_I EN 1
IO LC H T_ 13 T_ 1
RH T_ 10 T_ A1
IO LC H T_B 12_ T_E 1
LC RH T_ 11_ T_ A1
NA
T_ T9_ T_ A1
T8 T_ A
SD _S _FR OS BIT _IN ENA
1
SD _S _FR OS BIT _IN ENA
_E 1
NA A1
NA
NT A
BI IN EN
_F OS BIT IN EN
_S _F OS IT IN N
_I _E
OS BI _IN EN
_E EN
IO LC H T_ 15 A
RR INT
NE F_ NA
IO LC H T_ 14 T_
IO LC H T_ NT A
NT _
IO LC H AR T 1
X_ C_ NT 1
(re LC X_ NE T_E
IO LC X_ F_ _E
CR ER
SD _S 1_T UD NT
_S 1_T D IN
DS _
IO d X_ CR
IO LC X_ F_I
IO LC X_ F_
O
SD rve 1_T DS
SD _S 1_R EO
SD _S 1_R OV
se LC X_
IO LC X_
IO LC X_
(re _S 1_R
SD _S _R
SD _S 1_T
1
)
SD _S )
SD ed)
IO LC
IO LC
IO C
ed
L
SD _S
SD _S
rv
rv
se
IO
IO
(re
SD
31 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
LC
ed
_S
rv
se
IO
(re
SD
31 20 19 0
SDIO_SLC0_LEN Represents the accumulated length of data that the slave wants to send. (RO)
P
_E
M
N
SA
20
CO
_S
11
S_
IO
IO
EG
D_
PO
D
N
EE
_S
_S
C_
C_
SP
RC
RC
R
R
_H
_F
_F
_F
T_
d)
d)
ST
ST
ST
ST
ve
ve
OS
O
O
r
r
CH
CH
CH
CH
CH
se
se
(re
(re
SL
SL
SL
SL
SL
31 28 27 26 20 19 15 14 10 9 5 4 0
SLCHOST_FRC_SDIO11 Configure 1 to bit[4] to force drive CMD signal at the falling clock edge.
Configures 1 to bit[3:0] corresponding bit to force drive DAT[3:0] signal corresponding bit at the
falling clock edge. (R/W)
SLCHOST_FRC_SDIO20 Configure 1 to bit[4] to force drive CMD signal at the rising clock edge.
Configures 1 to bit[3:0] corresponding bit to force drive DAT[3:0] signal corresponding bit at the
rising clock edge. (R/W)
SLCHOST_FRC_NEG_SAMP Configure 1 to bit[4] to force sample CMD signal at the falling clock
edge. Configures 1 to bit[3:0] corresponding bit to force sample DAT[3:0] signal corresponding
bit at the falling clock edge. (R/W)
SLCHOST_FRC_POS_SAMP Configure 1 to bit[4] to force sample CMD signal at the rising clock
edge. Configures 1 to bit[3:0] corresponding bit to force sample DAT[3:0] signal corresponding
bit at the rising clock edge. (R/W)
AW
R
T_ _IN RAW
W
OS LC OH T_BI _INT AW
_IN AW
T_
RA
RA
A
6 _ RA
R
IN
_R
T0 T_R
SL OST LC0 HO BIT INT_
OS IT1 T_
T_
SL OST LC0 HO BIT NT_
T_
W
W
KE
RA
F_ RA
5_
_
CH T_S 0_T OST T7_
AC
2
T_
3
4
UD NT_
T
IN
_P
C OH _BI
BI
I
_
_
_
EW
_R VF_
ST
ST
ST
T
S
S
S
N
SL OST LC0 HO
O
C0 X_O
X_
X_
O
O
O
_R
T_ 0_T
CH _S _T
CH _S _T
CH _S _T
CH _S _T
CH _S _T
T
_T
_
C0
SL OST LC0
0
OS LC
SL
SL
SL
CH _S
CH _S
T_
T_
d)
d)
d)
SL OST
SL OST
rve
rve
rve
OS
O S
CH
CH
CH
se
se
se
(re
(re
(re
SL
SL
SL
SL
31 24 23 22 18 17 16 15 8 7 6 5 4 3 2 1 0
W
RA
AW
T_ _IN RAW
W
_IN RAW
W
T W
AW
_IN AW
T_
RA
_T OST IT2_ _RA
T_ 1_T OST IT3_ T_RA
R
_IN
T0 T_R
SL OST LC1_ HOS BIT5 NT_
OS IT1 T_
T_
SL OST LC1_ HOS BIT4 NT_
W
ET
IN
IN
T_ _IN
RA
F_ RA
_I
_I
K
AC
T_
BI
X_ F_IN
B
OH _B
OH _B
T_
T_
T_
T_
EW
H
X
TO
TO
TO
TO
TO
TO
X
_R
_R
T_ 1_T
SL OST LC1_
C1
C1
OS LC
OS LC
SL
SL
SL
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
T_
d)
d)
d)
SL OST
SL OST
rve
rve
rve
OS
CH
CH
CH
se
se
se
(re
(re
(re
SL
SL
SL
31 26 25 24 18 17 16 15 8 7 6 5 4 3 2 1 0
ST
T_
ST
BI INT T
_IN ST
ST
OS LC OH T_BI _INT T
OH T_B _IN T
T
6_ ST
_IN
OS IT2 T_S
S
S
_S
SL OST LC0 HO BIT INT_
_
T_
SL OST LC0 HO BIT INT_
ST
F_ ST
CK
_
I
5_
_
CH T_S 0_T OST T7_
T0
2
T_
T3
4
UD NT_
PA
IN
C OH _BI
W_
_
_
_
T_
_R VF_
ST
ST
ST
T
S
T_ 0_T OS
S
NE
SL OST LC0 HO
C0 X_O
X_
X_
O
O
O
_R
T_ 0_T
CH _S _T
CH _S _T
CH _S _T
CH _S _T
CH _S _T
_T
C0
SL OST LC0
OS LC
SL
SL
SL
CH _S
CH _S
T_
d)
d)
d)
SL OST
SL OST
rve
rve
rve
OS
O S
CH
CH
CH
se
se
se
(re
(re
(re
SL
SL
SL
SL
31 24 23 22 18 17 16 15 8 7 6 5 4 3 2 1 0
ST
T_
ST
_IN T
T
IN
OS IT1 T_S
SL OST LC1_ HOS BIT4 NT_S
SL OST LC1_ HOS BIT6 T_S
T0 T_S
SL OST LC1_ HOS BIT5 NT_
T_
T_
T
IN
_I N
IN
T_ _IN
T_ _IN
KE
ST
_I
_I
F_ ST
AC
T_
BI
X_ F_IN
B
OH _B
OH _B
T_
T_
T_
T_
EW
H
X
TO
TO
TO
TO
TO
TO
X
_R
_R
T_ 1_T
SL OST LC1_
C1
C1
OS LC
OS LC
SL
SL
SL
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
T_
d)
d)
d)
SL OST
SL OST
rve
rve
rve
OS
CH
CH
CH
se
se
se
(re
(re
(re
SL
SL
SL
31 26 25 24 18 17 16 15 8 7 6 5 4 3 2 1 0
NF
ON
O
C
_C
T_
ST
OS
HO
CH
LC
SL
S
T_
T_
)
)
ed
ed
OS
OS
rv
rv
CH
CH
se
se
(re
(re
SL
SL
31 24 23 16 15 8 7 0
R
CL
LR
R
OS LC OH T_BI _INT LR
OH T_B _IN LR
T_
_IN LR
CL
CL
L
6_ CL
OS IT1 T_C
C
_IN
C
_C
T0 T_C
SL OST LC0 HO BIT INT_
T_
SL OST LC0 HO BIT NT_
ET
R
F_ CLR
T_ _IN
CL
CK
5_
_
CH T_S 0_T OST T7_
2
T_
3
4
UD NT_
PA
T
IN
C OH _BI
BI
W_
_
_
_
_R VF_
ST
ST
ST
T
S
S
S
NE
SL OST LC0 HO
O
C0 X_O
X_
X_
O
O
O
_R
T_ 0_T
CH _S _T
CH _S _T
CH _S _T
CH _S _T
CH _S _T
T
_T
_
C0
SL OST LC0
0
OS LC
SL
SL
SL
CH _S
CH _S
T_
T_
d)
d)
d)
SL OST
SL OST
rve
rve
rve
OS
OS
CH
CH
CH
se
se
se
(re
(re
(re
SL
SL
SL
SL
31 24 23 22 18 17 16 15 8 7 6 5 4 3 2 1 0
LR
R
_IN LR
R
T_
T R
LR
_IN LR
L
CL
_T OST IT2_ _CL
T_ 1_T OST IT3_ T_CL
SL OST LC1_ HOS BIT5 NT_C
OS IT1 T_C
SL OST LC1_ HOS BIT4 NT_C
_IN
T0 T_C
T_
ET
IN
IN
F_ CLR
T_ _IN
T_ _IN
CL
_I
_I
CK
T_
IN
BI
X_ F_IN
B
OH _B
OH _B
W_
T_
T_
T_
T_
SL OST LC1_ HOS
NE
C1 _OV
X_
H
TO
TO
TO
TO
TO
TO
X
_R
_R
T_ 1_T
SL OST LC1_
C1
C1
OS LC
OS LC
SL
SL
SL
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
CH _S
T_
d)
d)
d)
SL OST
SL OST
rve
ve
rve
OS
r
CH
CH
CH
se
se
se
(re
(re
(re
SL
SL
SL
31 26 25 24 18 17 16 15 8 7 6 5 4 3 2 1 0
A
EN
A
A
_I N N A
N
T_ _IN EN
EN
_IN EN
N
SL OST N1_S 0_T OST IT6_ _EN
IN
T0 T_E
OS IT1 T_
T_
T_
LC OH _B INT
A
IN
A
EN
KE
F_ EN
I
SL OST N1_S 0_T OST IT7_
AC