Esp32-C3 Technical Reference Manual en
Esp32-C3 Technical Reference Manual en
Version 1.1
Espressif Systems
Copyright © 2024
www.espressif.com
About This Document
The ESP32-C3 Technical Reference Manual is targeted at developers working on low level software projects
that use the ESP32-C3 SoC. It describes the hardware modules listed below for the ESP32-C3 SoC and other
products in ESP32-C3 series. The modules detailed in this document provide an overview, list of features,
hardware architecture details, any necessary programming procedures, as well as register descriptions.
• Release Status at a Glance on the very next page is a minimal list of all chapters from where you can
directly jump to a specific chapter.
• Use the Bookmarks on the side bar to jump to any specific chapters or sections from anywhere in the
document. Note this PDF document is configured to automatically display Bookmarks when open, which
is necessary for an extensive document like this one. However, some PDF viewers or browsers ignore
this setting, so if you don’t see the Bookmarks by default, try one or more of the following methods:
– Download this document, and view it with your local PDF viewer;
– Set your PDF viewer to always automatically display the Bookmarks on the left side bar when open.
• Use the native Navigation function of your PDF viewer to navigate through the documents. Most PDF
viewers support to go Up, Down, Previous, Next, Back, Forward and Page with buttons, menu, or hot
keys.
• You can also use the built-in GoBack button on the upper right corner on each and every page to go
back to the previous place before you click a link within the document. Note this feature may only work
with some Acrobat-specific PDF viewers (for example, Acrobat Reader and Adobe DC) and browsers with
built-in Acrobat-specific PDF viewers or extensions (for example, Firefox).
Release Status at a Glance
Note:
Check the link or the QR code to make sure that you use the latest version of this document:
https://www.espressif.com/sites/default/files/documentation/esp32-c3_technical_reference_
manual_en.pdf
Contents GoBack
Contents
1 ESP-RISC-V CPU 28
1.1 Overview 28
1.2 Features 28
1.3 Address Map 29
1.4 Configuration and Status Registers (CSRs) 29
1.4.1 Register Summary 29
1.4.2 Register Description 30
1.5 Interrupt Controller 39
1.5.1 Features 39
1.5.2 Functional Description 39
1.5.3 Suggested Operation 41
1.5.3.1 Latency Aspects 41
1.5.3.2 Configuration Procedure 41
1.5.4 Register Summary 42
1.5.5 Register Description 43
1.6 Debug 44
1.6.1 Overview 44
1.6.2 Features 45
1.6.3 Functional Description 45
1.6.4 Register Summary 45
1.6.5 Register Description 45
1.7 Hardware Trigger 48
1.7.1 Features 48
1.7.2 Functional Description 48
1.7.3 Trigger Execution Flow 49
1.7.4 Register Summary 49
1.7.5 Register Description 50
1.8 Memory Protection 54
1.8.1 Overview 54
1.8.2 Features 54
1.8.3 Functional Description 54
1.8.4 Register Summary 56
1.8.5 Register Description 56
Glossary 868
Abbreviations for Peripherals 868
Abbreviations Related to Registers 868
Access Types for Registers 869
List of Tables
1-1 CPU Address Map 29
1-3 ID wise map of Interrupt Trap-Vector Addresses 40
1-5 NAPOT encoding for maddress 49
2-1 Selecting Peripherals via Register Configuration 60
2-2 Descriptor Field Alignment Requirements 62
3-1 Internal Memory Address Mapping 89
3-2 External Memory Address Mapping 91
3-3 Module/Peripheral Address Mapping 94
4-1 Parameters in eFuse BLOCK0 97
4-2 Secure Key Purpose Values 100
4-3 Parameters in BLOCK1 to BLOCK10 101
4-4 Registers Information 105
4-5 Configuration of Default VDDQ Timing Parameters 107
5-1 Bits Used to Control IO MUX Functions in Light-sleep Mode 162
5-2 Peripheral Signals via GPIO Matrix 164
5-3 IO MUX Pin Functions 169
5-4 Power-Up Glitches on Pins 170
5-5 Analog Functions of IO MUX Pins 170
6-1 Reset Sources 186
6-2 CPU Clock Source 188
6-3 CPU Clock Frequency 188
6-4 Peripheral Clocks 189
6-5 APB_CLK Clock Frequency 190
6-6 CRYPTO_CLK Frequency 190
7-1 Default Configuration of Strapping Pins 191
7-2 Boot Mode Control 192
7-3 ROM Code Printing Control 193
8-1 CPU Peripheral Interrupt Configuration/Status Registers and Peripheral Interrupt Sources 196
9-1 Low-power Clocks 215
9-2 The Triggering Conditions for the RTC Timer 215
9-3 Predefined Power Modes 218
9-4 Wakeup Source 219
10-1 UNITn Configuration Bits 264
10-2 Trigger Point 265
10-3 Synchronization Operation 265
11-1 Alarm Generation When Up-Down Counter Increments 282
11-2 Alarm Generation When Up-Down Counter Decrements 282
14-1 ROM Address 308
14-2 Access Configuration to ROM (ROM0 and ROM1) 309
14-3 SRAM Address 309
14-4 Access Configuration to Internal SRAM0 310
14-5 Internal SRAM1 Split Regions 311
14-6 Access Configuration to the Instruction Region of Internal SRAM1 313
List of Figures
1-1 CPU Block Diagram 28
1-2 Debug System Overview 44
2-1 Modules with GDMA Feature and GDMA Channels 57
2-2 GDMA Engine Architecture 58
2-3 Structure of a Linked List 59
2-4 Relationship among Linked Lists 61
3-1 System Structure and Address Mapping 88
3-2 Cache Structure 92
3-3 Peripherals/modules that can work with GDMA 93
4-1 Shift Register Circuit (first 32 output) 103
4-2 Shift Register Circuit (last 12 output) 103
5-1 Diagram of IO MUX and GPIO Matrix 155
5-2 Architecture of IO MUX and GPIO Matrix 155
5-3 Internal Structure of a Pad 156
5-4 GPIO Input Synchronized on APB Clock Rising Edge or on Falling Edge 157
5-5 Filter Timing of GPIO Input Signals 157
6-1 Reset Types 185
6-2 System Clock 187
8-1 Interrupt Matrix Structure 194
9-1 Low-power Management Schematics 212
9-2 Power Management Unit Workflow 213
9-3 RTC Clocks 214
9-4 Wireless Clock 214
9-5 Digital System Regulator 216
9-6 Low-power voltage regulator 217
9-7 Brown-out detector 217
9-8 ESP32-C3 Boot Flow 222
10-1 System Timer Structure 262
10-2 System Timer Alarm Generation 263
11-1 Timer Units within Groups 280
11-2 Timer Group Architecture 281
12-1 Watchdog Timers Overview 297
12-2 Watchdog Timers in ESP32-C3 298
12-3 Super Watchdog Controller Structure 301
13-1 XTAL32K Watchdog Timer 303
14-1 Permission Control Overview 307
14-2 Split Lines for Internal SRAM1 310
14-3 An illustration of Configuring the Category fields 312
14-4 Two Ways to Access External Memory 316
15-1 Switching From Secure World to Non-secure World 405
15-2 Switching From Non-secure World to Secure World 406
15-3 World Switch Log Register 407
15-4 Nested Interrupts Handling - Entry 9 408
1 ESP-RISC-V CPU
1.1 Overview
ESP-RISC-V CPU is a 32-bit core based upon RISC-V ISA comprising base integer (I), multiplication/division
(M) and compressed (C) standard extensions. The core has 4-stage, in-order, scalar pipeline optimized for
area, power and performance. CPU core complex has an interrupt-controller (INTC), debug module (DM) and
system bus (SYS BUS) interfaces for memory and peripheral access.
1.2 Features
• Operating clock frequency up to 160 MHz
• Zero wait cycle access to on-chip SRAM and Cache for program and data access over IRAM/DRAM
interface
• Interrupt controller (INTC) with up to 31 vectored interrupts with programmable priority and threshold
levels
• Debug module (DM) compliant with RISC-V debug specification v0.13 with external debugger support
over an industry-standard JTAG/USB port
*default : Address not matching any of the specified ranges (IRAM, DRAM, DM) are accessed using AHB
bus.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
¹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
0x80000001 Reset
D
PI
IM
M
31 0
0x00000001 Reset
31 0
0x00000000 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
Note : Only lower bit is writable. Write to the higher bit is ignored as it is directly tied to the lower
bit.
)
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)
)
ed
rv
E
se
SE
OD
(re
BA
M
31 8 7 2 1 0
BASE Higher 24 bits of trap vector base address aligned to 256 bytes. (R/W)
H
TC
RA
SC
M
31 0
0x00000000 Reset
31 0
0x00000000 Reset
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. (R/W)
Possible exception IDs are:
Note : Exception ID 0x0 (instruction access misaligned) is not present because CPU always
masks the lowest bit of the address during instruction fetch.
Interrupt Flag This flag is automatically updated when CPU enters trap. (R/W)
If this is found to be set, indicates that the latest trap occurred due to interrupt. For exceptions
it remains unset.
Note : The interrupt controller is using up IDs in range 1-31 for all external interrupt sources.
This is different from the RISC-V standard which has reserved IDs in range 0-15 for core internal
interrupt sources.
31 0
0x00000000 Reset
Note : The value of this register is not valid for other exception IDs and interrupts.
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. (R/W)
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.
CO NT_
rv
se
U
CO
(re
31 2 1 0
0 1 1 Reset
• 0: Disabled
• 1: Enabled
CR
PC
M
31 0
0x00000000 Reset
]
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
IO 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
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 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 5-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 5.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 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 5-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 5.5 in Chapter IO MUX and GPIO Matrix (GPIO, IO MUX). (R/W)
For the complete list of interrupt registers and detailed configuration information, please refer to Chapter 8
Interrupt Matrix (INTERRUPT), section 8.4, register group ”CPU Interrupt Registers”.
2. Type (0-1):
3. Priority (1-15):
• Determines which interrupt, among multiple pending interrupts, the CPU will service first.
• Enabled interrupts with priorities zero or less than the threshold value in
INTERRUPT_CORE0_CPU_INT_THRESH_REG are masked.
• Interrupts with same priority are statically prioritized by their IDs, lowest ID having highest priority.
• 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 INTERRUPT_CORE0_CPU_INT_ENABLE_REG and then toggling same bit in
INTERRUPT_CORE0_CPU_INT_CLEAR_REG.
• saves the address of the current un-executed instruction in mepc for resuming execution later.
• updates the value of mcause with the ID of the interrupt being serviced.
• copies the state of MIE into MPIE, and subsequently clears MIE, thereby disabling interrupts globally.
Table 1-3 shows the mapping of each interrupt ID with the corresponding trap-vector address. In short, the
word aligned trap address for an interrupt with a certain ID = i can be calculated as (mtvec + 4i).
Note : ID = 0 is unavailable and therefore cannot be used for capturing interrupts. This is because the
corresponding trap vector address (mtvec + 0x00) is reserved for exceptions.
After jumping to the trap-vector, 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 instruction.
• copies the state of MPIE back into MIE, and subsequently clears MPIE. This means that if previously
MPIE was set, then, after MRET, MIE will be set, thereby enabling interrupts globally.
It is possible to perform software assisted nesting of interrupts inside an ISR as explained in 1.5.3.
The below listed points outline the functional behavior of the controller:
• Only if an interrupt has non-zero priority, higher or equal to the value in the threshold register, will it be
reflected in INTERRUPT_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 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
INTERRUPT_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 INTERRUPT_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 INTERRUPT_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
INTERRUPT_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.
For the complete list of interrupt registers and detailed configuration information, please refer to Chapter 8
Interrupt Matrix (INTERRUPT), section 8.4, register group ”CPU Interrupt Registers”.
For the complete list of interrupt registers and detailed configuration information, please refer to Chapter 8
Interrupt Matrix (INTERRUPT), section 8.4, register group ”CPU Interrupt Registers”.
1.6 Debug
1.6.1 Overview
This section describes how to debug and test software running on CPU core. Debug support is provided
through standard JTAG pins and complies to RISC-V External Debug Support Specification version 0.13.
Figure 1-2 below shows the main components of External Debug Support.
The user interacts with the Debug Host (eg. laptop), which is running a debugger (eg. gdb). The debugger
communicates with a Debug Translator (eg. OpenOCD, which may include a hardware driver) to communicate
with Debug Transport Hardware (eg. Olimex USB-JTAG adapter). The Debug Transport Hardware connects the
Debug Host to the ESP-RV 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 the core. Abstract commands provide access to its 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-RV core contains Trigger Module supporting 8 triggers. When trigger
conditions are met, cores will halt spontaneously and inform the debug module that they have halted.
System bus access block allows memory and peripheral register access without using RISC-V core.
1.6.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 eight Hardware Triggers (can be used as breakpoints/watchpoints) as described in Section 1.7.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
All the debug module registers are implemented in conformance to RISC-V External Debug Support
Specification version 0.13. Please refer 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 bit 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.
step When set and not in Debug Mode, the core will only execute a single instruction and then
enter Debug Mode. Interrupts are enabled* when this bit is set. If the instruction does not
complete due to an exception, the core will immediately enter Debug Mode before executing
the trap handler, with appropriate exception registers set. (R/W)
prv Contains the privilege level the core was operating in when Debug Mode was entered. A 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.
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
1
ch
at
cr
ds
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-7) 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 RISC-V Debug Specification v0.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 bit 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 doesn’t 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-5) 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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
d)
ve
t
r
ec
se
el
(re
ts
31 3 2 0
ta
dm
da
ty
31 28 27 26 0
• 0: Both Debug and M-mode can write the tdata1 and tdata2 registers at the selected tselect.
• 1: Only Debug Mode can write the tdata1 and tdata2 registers at the selected tselect. Writes
from other modes are ignored.
31 0
0x00000000 Reset
)
ed
ed
rv
rv
se
se
e
pt
te
(re
(re
m
m
31 8 7 6 1 0
• When CPU is taking a machine mode trap, the value of mte is automatically pushed into
this.
• When CPU is executing MRET, its value is popped back into mte, so this becomes 0.
• When CPU is taking a machine mode trap, its value is automatically pushed into mpte, so
this becomes 0 and triggers with action=0 are disabled globally.
• When CPU is executing MRET, the value of mpte is automatically popped back into this.
)
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. (R/W)
This bit is to be cleared manually.
action Write this for configuring the selected trigger to perform one of the available actions when
firing. (R/W)
Valid options are:
Note : Writing an invalid value will set this to the default value 0x0.
match Write this for configuring the selected trigger to perform one of the available matching op-
erations on a data/instruction address. (R/W) 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.
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 Address used by the selected trigger when performing match operation. (R/W)
This is decoded as NAPOT when match=1 in mcontrol.
For detailed understanding of the RISC-V PMP concept, please refer to RISC-V Instruction Set Manual, Volume
II: Privileged Architecture, Version 1.10.
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. Below are the current non-conformance with PMP description from RISC-V Privilege
specifications:
As per RISC-V Privilege specifications, PMP entries should be statically prioritized and the lowest-numbered
PMP entry that matches any address byte of an access will determine whether that access succeeds or fails.
This means, when any address matches more than one PMP entry i.e. overlapping regions among different
PMP entries, lowest number PMP entry will decide whether such address access will succeed or fail.
However, RISC-V CPU PMP unit in ESP32-C3 does not implement static priority. So, software should make
sure that all enabled PMP entries are programmed with unique regions i.e. without any region overlap among
them. If software still tries to program multiple PMP entries with overlapping region having contradicting
permissions, then access will succeed if it matches at least one of enabled PMP entries. An exception will be
generated, if access matches none of the enabled PMP entries.
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 address range and valid permissions in pmpcfg and
pmpaddr registers (refer 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 deafult. 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 lock bit is set, it can only be cleared through CPU reset.
When any instruction is being fetched from memory region without execute permissions, 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 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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
2.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 a high speed. The CPU is not involved in the GDMA transfer, and
therefore it becomes more efficient with less workload.
The GDMA controller in ESP32-C3 has six independent channels, i.e. three transmit channels and three
receive channels. These six channels are shared by peripherals with GDMA feature, namely SPI2, UHCI0
(UART0/UART1), I2S, AES, SHA, and ADC. Users can assign the six channels to any of these peripherals.
UART0 and UART1 use UHCI0 together.
The GDMA controller uses fixed-priority and round-robin channel arbitration schemes to manage peripherals’
needs for bandwidth.
2.2 Features
The GDMA controller has the following features:
2.3 Architecture
In ESP32-C3, 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 2-2 shows the basic architecture of
the GDMA engine.
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 engine reads data from or writes data to internal RAM via the 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 3 System and Memory.
Software can use the GDMA engine 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 2-3 shows the structure of a linked list. An outlink and an inlink have the same structure. A linked list is
formed by one or more descriptors, and each descriptor consists of three words. Linked lists should be in
internal RAM for the GDMA engine to be able to use them. The meaning of each field is as follows:
• Owner (DW0) [31]: Specifies who is allowed to access the buffer that this descriptor points to.
1’b0: CPU can access the buffer;
1’b1: The 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 is automatically cleared by hardware only 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.
• suc_eof (DW0) [30]: Specifies whether this descriptor is the last descriptor in the list.
1’b0: This descriptor is not the last one;
1’b1: This descriptor is the last one.
Software clears suc_eof bit in receive descriptors. When a frame or packet has been received, this bit in
the last receive descriptor is set by hardware, and this bit in the last transmit descriptor is set by software.
• Reserved (DW0) [29]: Reserved. Value of this bit does not matter.
• err_eof (DW0) [28]: Specifies whether the received data has errors.
This bit is used only when UHCI0 uses GDMA to receive data. When an error is detected in the received
frame or packet, this bit in the receive descriptor is set to 1 by hardware.
• Length (DW0) [23:12]: Specifies the number of valid bytes in the buffer that this descriptor points to.
This field in a transmit descriptor is written by software and indicates how many bytes can be read from
the buffer; this field in a receive descriptor is written by hardware automatically and indicates how many
valid bytes have been stored into the buffer.
• Size (DW0) [11:0]: Specifies the size of the buffer that this descriptor points to.
• Buffer address pointer (DW1): Address of the buffer. This field can only point to internal RAM.
• Next descriptor address (DW2): Address of the next descriptor. If the current descriptor is the last one
(suc_eof = 1), this value 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 2-1 illustrates
how to select the peripheral to be connected via registers. When a channel is connected to a peripheral, the
rest channels can not be connected to that peripheral.
GDMA_PERI_IN_SEL_CHn
Peripheral
GDMA_PERI_OUT_SEL_CHn
0 SPI2
1 Reserved
2 UHCI0
3 I2S
4 Reserved
5 Reserved
6 AES
7 SHA
8 ADC
9 ~ 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 engine has
specialized logic to make sure a DMA transfer can be continued or restarted: if it is still ongoing, it will make
sure to take the appended descriptors into account; if the transfer has already finished, it will restart with the
new descriptors. This is implemented in 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
2-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 0x3FC80000 ~ 0x3FCDFFFF
(please refer to Section 2.4.7), it passes 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.
2.4.6 EOF
The GDMA controller uses EOF (end of frame) flags to indicate the end of data frame or packet
transmission.
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 frame or packet has been received successfully, a
GDMA_IN_SUC_EOF_CHn_INT interrupt is generated. In addition, when GDMA channel is connected to
UHCI0, 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 frame or packet has been
received with errors.
Note: In this chapter, EOF of transmit descriptors refers to suc_eof, while EOF of receive descriptors refers to
both suc_eof and err_eof.
Table 2-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 to say, 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.
2.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 ~ 9. 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.
Please note that the overall throughput of peripherals with GDMA feature cannot exceed the maximum
bandwidth of the GDMA, so that requests from low-priority peripherals can be responded to.
• 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_ERR_EOF_CHn_INT: Triggered when an error is detected in the data frame or packet received
via receive channel n. This interrupt is used only for UHCI0 peripheral (UART0 or UART1).
• GDMA_IN_SUC_EOF_CHn_INT: Triggered when the suc_eof bit in a receive descriptor is 1 and the data
corresponding to this receive descriptor has been received (i.e. when the data frame or packet
corresponding to an inlink has beeen received) via receive channel n.
• GDMA_IN_DONE_CHn_INT: Triggered when all data corresponding to a receive descriptor has been
received via receive channel n.
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, UHCI0 (UART0 or UART1), I2S, AES, SHA, and
ADC). See details in individual chapters of these peripherals;
6. Wait for GDMA_OUT_EOF_CHn_INT interrupt, which indicates the completion of data transfer.
1. Set GDMA_IN_RST_CHn first to 1 and then to 0, to reset the state machine of GDMA’s receive channel
and FIFO pointer;
2. Load an inlink, and configure GDMA_INLINK_ADDR_CHn with address of the first receive descriptor;
5. Configure and enable the corresponding peripheral (SPI2, UHCI0 (UART0 or UART1), I2S, AES, SHA, and
ADC). See details in individual chapters of these peripherals;
6. Wait for GDMA_IN_SUC_EOF_CHn_INT interrupt, which indicates that a data frame or packet has been
received.
1. Set GDMA_OUT_RST_CHn first to 1 and then to 0, to reset the state machine of GDMA’s transmit channel
and FIFO pointer;
2. Set GDMA_IN_RST_CHn first to 1 and then to 0, to reset the state machine of GDMA’s receive channel
and FIFO pointer;
3. Load an outlink, and configure GDMA_OUTLINK_ADDR_CHn with address of the first transmit descriptor;
4. Load an inlink, and configure GDMA_INLINK_ADDR_CHn with address of the first receive descriptor;
8. Wait for GDMA_IN_SUC_EOF_CHn_INT interrupt, which indicates that a data transaction has been
completed.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
2.8 Registers
The addresses in this section are relative to GDMA base address provided in Table 3-3 in Chapter 3 System
and Memory.
GD A_ _ER NE 0_ 0_I T_ AW
GD A_ T_ F_C R_C H0 INT W
A_ S E H0 _R R W
M OU EO R _C _ RA
RA AW
IN T_ W
GD A_ T_T OV CH0 _IN _RA
GD A_ _DS TAL CH0 INT RA
E_ _C _IN AW
0_ _IN RA
T_ R
W
M IN DS M _C _R
M OU O_ F_ H0 T
CH H0 T_
M OU C _E Y_ _I
ON OF H0 _R
GD A_ FIF UD _C _IN
_D _E C NT
M IN O_ VF H0
GD A_ FIF _O F_C
M IN IFO D
GD A_ TF _U
M OU IFO
GD A_ TF
M OU
)
ed
GD A_
rv
se
M
GD
(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 0 0 0 0 0 0 0 0 0 0 0 Reset
GDMA_IN_DONE_CHn_INT_RAW The raw interrupt bit turns to high level when the last data pointed
by one receive descriptor has been received for RX channel 0. (R/WTC/SS)
GDMA_IN_SUC_EOF_CHn_INT_RAW The raw interrupt bit turns to high level for RX channel 0 when
the last data pointed by one receive descriptor has been received and the suc_eof bit in this
descriptor is 1. For UHCI0, the raw interrupt bit turns to high level when the last data pointed
by one receive descriptor has been received and no data error is detected for RX channel 0.
(R/WTC/SS)
GDMA_IN_ERR_EOF_CHn_INT_RAW The raw interrupt bit turns to high level when data error is de-
tected only in the case that the peripheral is UHCI0 for RX channel 0. For other peripherals, this
raw interrupt is reserved. (R/WTC/SS)
GDMA_OUT_DONE_CHn_INT_RAW The raw interrupt bit turns to high level when the last data
pointed by one transmit descriptor has been transmitted to peripherals for TX channel 0.
(R/WTC/SS)
GDMA_OUT_EOF_CHn_INT_RAW The raw interrupt bit turns to high level when the last data pointed
by one transmit descriptor has been read from memory for TX channel 0. (R/WTC/SS)
GDMA_IN_DSCR_ERR_CHn_INT_RAW The raw interrupt bit turns to high level when detecting re-
ceive descriptor error, including owner error, the second and third word error of receive de-
scriptor for RX channel 0. (R/WTC/SS)
GDMA_OUT_DSCR_ERR_CHn_INT_RAW The raw interrupt bit turns to high level when detecting
transmit descriptor error, including owner error, the second and third word error of transmit de-
scriptor for TX channel 0. (R/WTC/SS)
GDMA_IN_DSCR_EMPTY_CHn_INT_RAW The raw interrupt bit turns to high level when RX buffer
pointed by inlink is full and receiving data is not completed, but there is no more inlink for RX
channel 0. (R/WTC/SS)
GDMA_OUT_TOTAL_EOF_CHn_INT_RAW The raw interrupt bit turns to high level when data corre-
sponding a outlink (includes one descriptor or few descriptors) is transmitted out for TX channel
0. (R/WTC/SS)
GDMA_INFIFO_OVF_CHn_INT_RAW This raw interrupt bit turns to high level when level 1 FIFO of RX
channel 0 is overflow. (R/WTC/SS)
GDMA_INFIFO_UDF_CHn_INT_RAW This raw interrupt bit turns to high level when level 1 FIFO of RX
channel 0 is underflow. (R/WTC/SS)
GDMA_OUTFIFO_OVF_CHn_INT_RAW This raw interrupt bit turns to high level when level 1 FIFO of
TX channel 0 is overflow. (R/WTC/SS)
GDMA_OUTFIFO_UDF_CHn_INT_RAW This raw interrupt bit turns to high level when level 1 FIFO of
TX channel 0 is underflow. (R/WTC/SS)
GD A_ _ER NE 0_ 0_I T_ T
M OU EO R _C _ ST
IN UC OF_ _I T T
GD A_ T_T OV CH0 _IN _ST
A_ S E H0 _S S
T_ ST
0_ _IN ST
GD A_ T_ R_E OF INT T
GD A_ _DS CR PT H0 T
M IN O F_ _ T_
E_ _C _IN T
M OU C _E _ _S
M OU O_ F_ H0 T
M IN DS M _C _S
IN T_
CH H0 T_
M OU C _E Y_ _I
ON OF H0 _S
ST
GD A_ FIF UD _C _IN
_D _E C NT
M IN O_ VF H0
GD A_ FIF _O F_C
M IN IFO D
GD A_ TF _U
M OU IFO
GD A_ TF
M OU
d)
ve
GD A_
r
se
M
GD
31
(re 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
GDMA_IN_DONE_CHn_INT_ST The raw interrupt status bit for the GDMA_IN_DONE_CH_INT inter-
rupt. (RO)
GDMA_OUT_DONE_CHn_INT_ST The raw interrupt status bit for the GDMA_OUT_DONE_CH_INT in-
terrupt. (RO)
GDMA_OUT_EOF_CHn_INT_ST The raw interrupt status bit for the GDMA_OUT_EOF_CH_INT inter-
rupt. (RO)
GD A_ _ER NE 0_ 0_I T_ NA
GD A_ T_ F_C R_C H0 INT A
A_ S E H0 _E E A
M OU EO R _C _ EN
EN NA
GD A_ T_T OV CH0 _IN _EN
IN T_ A
GD A_ _DS TAL CH0 INT EN
0_ _IN EN
E_ _C _IN NA
T_ E
A
M OU O_ F_ H0 T
M IN DS M _C _E
CH H0 T_
M OU C _E Y_ _I
ON OF H0 _E
GD A_ FIF UD _C _IN
_D _E C NT
M IN O_ VF H0
GD A_ FIF _O F_C
M IN IFO D
GD A_ TF _U
M OU IFO
GD A _ TF
M OU
)
ed
GD A_
rv
se
M
GD
31 (re 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
GD A_ _ER NE 0_ 0_I T_ LR
GD A_ T_ F_C R_C H0 INT R
A_ S E H0 _C C R
M OU EO R _C _ CL
IN UC OF_ _I LR LR
M IN O F_ _ T_ R
M OU C _E _ _C R
CL LR
GD A_ T_T OV CH0 _IN _CL
IN T_ R
GD A_ T_ R_E RR CH0 NT_
GD A_ _DS TAL CH0 INT CL
GD A_ T_ R_E OF INT LR
GD A_ _DS CR PT H0 LR
0_ _IN CL
E_ _C _IN LR
T_ C
R
M IN DS M _C _C
M OU O_ F_ H0 T
CH H0 T_
M OU C _E Y_ _I
ON OF H0 _C
GD A_ FIF UD _C _IN
_D _E C NT
M IN O_ VF H0
GD A_ FIF _O F_C
M IN IFO D
GD A_ TF _U
M OU IFO
GD A_ TF
M OU
)
ed
GD A_
rv
se
M
GD
31 (re 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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_
d)
AH
M CL
ve
GD A _
A_
r
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 Set this bit, then clear this bit to reset the internal ahb FSM. (R/W)
GDMA_CLK_EN 0: Enable the clock only when application writes registers. 1: Force the clock on
for registers. (R/W)
31 0
0x2008250 Reset
_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
GD A_ DSC _B _EN
M IN TA S
GD A_ _DA RAN
M IN _T
GD A_ EM
d)
M M
ve
GD A _
r
se
M
GD
(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
GDMA_IN_RST_CHn This bit is used to reset GDMA channel 0 RX FSM and RX FIFO pointer. (R/W)
GDMA_IN_LOOP_TEST_CHn This bit is used to fill the owner bit of receive descriptor by hardware
of receive descriptor. (R/W)
GDMA_INDSCR_BURST_EN_CHn Set this bit to 1 to enable INCR burst transfer for RX channel 0
reading descriptor when accessing internal RAM. (R/W)
GDMA_IN_DATA_BURST_EN_CHn Set this bit to 1 to enable INCR burst transfer for RX channel 0
receiving data when accessing internal RAM. (R/W)
GDMA_MEM_TRANS_EN_CHn Set this bit 1 to enable automatic transmitting data from memory to
memory via GDMA. (R/W)
)
ed
ed
IN
A_
rv
rv
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 Set this bit to enable checking the owner attribute of the descrip-
tor. (R/W)
H 0
0
_C
CH
A
P_
AT
PO
RD
O_
O_
IF
IF
F
F
d)
IN
IN
ve
A_
A_
r
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
GDMA_INFIFO_RDATA_CHn This register stores the data popping from GDMA FIFO (intended for
debugging). (RO)
GDMA_INFIFO_POP_CHn Set this bit to pop data from GDMA FIFO (intended for debugging).
(R/W/SC)
T_
_A P_ H0
IN K_ AR T_C
0
M INL K_S STA H0
O_ 0
H
RE
UT CH
_C
GD A_ LIN RE _C
A_ IN T R
DR
M IN K_ RK
AD
GD A_ LIN PA
M IN K_
K_
GD A_ LIN
N
LI
)
ed
M IN
IN
GD A_
A_
rv
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 This register stores the 20 least significant bits of the first receive de-
scriptor’s address. (R/W)
GDMA_INLINK_AUTO_RET_CHn Set this bit to return to current receive descriptor’s address, when
there are some errors in current receiving data. (R/W)
GDMA_INLINK_STOP_CHn Set this bit to stop GDMA’s receive channel from receiving data.
(R/W/SC)
GDMA_INLINK_START_CHn Set this bit to enable GDMA’s receive channel from receiving data.
(R/W/SC)
GDMA_INLINK_PARK_CHn 1: the receive descriptor’s FSM is in idle state; 0: the receive descrip-
tor’s FSM is working. (RO)
OU LO _W _C _C 0
T_ OP RB H0 H0
A_ T_ TO DE EN H
0 C H H0
M OU AU O T_ _C
CH T_ _C
GD A_ T_ F_M RS EN
0
T_ ES K
M OU EO BU T_
RS _T AC
GD A_ T_ R_ URS
M OU SC B
GD A_ TD TA_
M OU DA
GD A_ T_
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 1 0 0 0 Reset
GDMA_OUT_RST_CHn This bit is used to reset GDMA channel 0 TX FSM and TX FIFO pointer. (R/W)
GDMA_OUT_AUTO_WRBACK_CHn Set this bit to enable automatic outlink-writeback when all the
data in TX buffer has been transmitted. (R/W)
GDMA_OUT_EOF_MODE_CHn EOF flag generation mode when transmitting data. 1: EOF flag for TX
channel 0 is generated when data need to transmit has been popped from FIFO in GDMA. (R/W)
GDMA_OUTDSCR_BURST_EN_CHn Set this bit to 1 to enable INCR burst transfer for TX channel 0
reading descriptor when accessing internal RAM. (R/W)
GDMA_OUT_DATA_BURST_EN_CHn Set this bit to 1 to enable INCR burst transfer for TX channel 0
transmitting data when accessing internal RAM. (R/W)
)
ed
ed
A_
rv
rv
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_OUT_CHECK_OWNER_CHn Set this bit to enable checking the owner attribute of the de-
scriptor. (R/W)
H0
H0
_C
_C
TA
SH
DA
PU
W
O_
O_
IF
IF
TF
TF
OU
OU
d)
ve
A_
A_
r
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 This register stores the data that need to be pushed into GDMA FIFO.
(R/W)
GDMA_OUTFIFO_PUSH_CHn Set this bit to push data into GDMA FIFO. (R/W/SC)
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
)
ed
GD A_
A_
rv
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 This register stores the 20 least significant bits of the first transmit
descriptor’s address. (R/W)
GDMA_OUTLINK_STOP_CHn Set this bit to stop GDMA’s transmit channel from transferring data.
(R/W/SC)
GDMA_OUTLINK_START_CHn Set this bit to enable GDMA’s transmit channel for data transfer.
(R/W/SC)
GDMA_OUTLINK_RESTART_CHn Set this bit to restart a new outlink from the last address. (R/W/SC)
GDMA_OUTLINK_PARK_CHn 1: the transmit descriptor’s FSM is in idle state; 0: the transmit de-
scriptor’s FSM is working. (RO)
_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 The register stores the byte number of the data in L1 RX FIFO for RX chan-
nel 0. (RO)
R_
H
DD
E _C
A
AT
H0
R_
ST
SC
_C
R_
_D
TE
SC
TA
NK
_D
_S
LI
)
ed
IN
IN
IN
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
GDMA_INLINK_DSCR_ADDR_CHn This register stores the lower 18 bits of the next receive descrip-
tor address that is pre-read (but not processed yet). If the current receive descriptor is the last
descriptor, then this field represents the address of the current receive descriptor. (RO)
0
CH
R_
DD
_A
ES
D
F_
EO
C_
U
_S
IN
A_
M
GD
31 0
0x000000 Reset
CH0
R_
DD
_A
ES
_D
OF
_E
RR
_E
IN
A_
M
GD
31 0
0x000000 Reset
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)
0
CH
0_
F
_B
CR
S
_D
NK
LI
IN
A_
M
GD
31 0
0 Reset
0H
_C
F1
_B
CR
DS
K_
N
LI
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)
_C 0
DE 2B H0
UN ER_ _C 0
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
CN
GD A_ T_ MA
O_
TF O_
M OU RE
IF
OU IF
TF
A _ TF
GD A_ T_
M OU
OU
M U
)
d)
ed
O
ve
GD A_
A_
GD A_
rv
r
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
GDMA_OUTFIFO_CNT_CHn The register stores the byte number of the data in L1 TX FIFO for TX
channel 0. (RO)
0
CH
R_
H0
DD
_C
_A
TE
0
TA
CR
CH
_S
DS
E_
CR
K_
AT
DS
ST
IN
TL
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
GDMA_OUTLINK_DSCR_ADDR_CHn This register stores the lower 18 bits of the next receive de-
scriptor address that is pre-read (but not processed yet). If the current receive descriptor is the
last descriptor, then this field represents the address of the current receive descriptor. (RO)
0
CH
R_
DD
A
S_
DE
F_
EO
T_
OU
A_
M
GD
31 0
0x000000 Reset
GDMA_OUT_EOF_DES_ADDR_CHn This register stores the address of the transmit descriptor when
the EOF bit in this descriptor is 1. (RO)
0
CH
R_
DD
_A
ES
_D
FR
B
F_
EO
T_
OU
A_
M
GD
31 0
0x000000 Reset
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)
0
CH
F0_
_B
CR
DS
K_
IN
TL
OU
A_
M
GD
31 0
0 Reset
H0
_C
F1
_B
CR
DS
K_
IN
TL
OU
A_
M
GD
31 0
0 Reset
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
GDMA_RX_PRI_CHn The priority of RX channel 0. The larger the value, the higher the priority. (R/W)
H0
_C
RI
_P
)
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
GDMA_TX_PRI_CHn The priority of TX channel 0. The larger the value, the higher the priority. (R/W)
0
CH
EL_
_S
N
_I
RI
)
PE
ed
A_
rv
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
)
PE
ed
A_
rv
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
3.1 Overview
The ESP32-C3 is an ultra-low-power and highly-integrated system with a 32-bit RISC-V single-core processor
with a four-stage pipeline that operates at up to 160 MHz. All internal memory, external memory, and
peripherals are located on the CPU buses.
3.2 Features
• Address Space
– 792 KB of internal memory address space accessed from the instruction bus
– 552 KB of internal memory address space accessed from the data bus
– 8 MB of external memory virtual address space accessed from the instruction bus
– 8 MB of external memory virtual address space accessed from the data bus
• Internal Memory
– 8 KB of RTC Memory
• External Memory
• Peripheral Space
– 35 modules/peripherals in total
• GDMA
– 7 GDMA-supported modules/peripherals
0x0000_0000
Reserved
0x3BFF_FFFF
Data bus 0x3C00_0000 8 MB
0x3C7F_FFFF External memory
0x3C80_0000
Reserved
0x3FC7_FFFF
0x3FC8_0000 384 KB Data bus
0x3FCD_FFFF Internal memory
0x3FCE_0000
Reserved
0x3FEF_FFFF
0x3FF0_0000 128 KB Data bus
ROM SRAM
0x3FF1_FFFF Internal memory
Cache 0x3FF2_0000
Reserved
0x3FFF_FFFF
0x4000_0000 384 KB Instruction bus
0x4005_FFFF Internal memory
0x4006_0000
Reserved
0x4037_BFFF
0x4037_C000 400 KB Instruction bus
MMU 0x403D_FFFF Internal memory
0x403E_0000
Reserved GDMA
0x41FF_FFFF
Instruction bus 0x4200_0000 8 MB
0x427F_FFFF External memory
0x4280_0000
Reserved
0x4FFF_FFFF Data/Instruction
0x5000_0000 8 KB bus
External RTC FAST Memory
memory 0x5000_1FFF Internal memory
0x5000_2000
Reserved
0x5FFF_FFFF Data/Instruction
0x6000_0000 836 KB bus Peripheral
0x600D_0FFF Peripherals
0x600D_1000
Reserved
0xFFFF_FFFF
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 are little-endian. The CPU can access data via the data bus using
single-byte, double-byte, 4-byte alignment. The CPU can also access data via the instruction bus, but only in
4-byte aligned manner.
• directly access the internal memory via both data bus and instruction bus;
• access the external memory which is mapped into the virtual address space via cache;
Figure 3-1 lists the address ranges on the data bus and instruction bus and their corresponding target
memory.
Some internal and external memory can be accessed via both data bus and instruction bus. In such cases,
the CPU can access the same memory using multiple addresses.
• Internal ROM (384 KB): The Internal ROM of the ESP32-C3 is a Mask ROM, meaning it is strictly read-only
and cannot be reprogrammed. Internal ROM contains the ROM code (software instructions and some
software read-only data) of some low level system software.
• Internal SRAM (400 KB): The Internal Static RAM (SRAM) is a volatile memory that can be quickly
accessed by the CPU (generally within a single CPU clock cycle).
– A part of the SRAM can be configured to operate as a cache for external memory access.
– Some parts of the SRAM can only be accessed via the CPU’s instruction bus.
– Some parts of the SRAM can be accessed via both the CPU’s instruction bus and the CPU’s data
bus.
• RTC Memory (8 KB): The RTC (Real Time Clock) memory implemented as Static RAM (SRAM) thus is
volatile. However, RTC memory has the added feature of being persistent in deep sleep (i.e., the RTC
memory retains its values throughout deep sleep).
– RTC FAST Memory (8 KB): RTC FAST memory can only be accessed by the CPU and can be
generally used to store instructions and data that needs to persist across a deep sleep.
Based on the three different types of internal memory described above, the internal memory of the ESP32-C3
is split into three segments: Internal ROM (384 KB), Internal SRAM (400 KB), RTC FAST Memory (8 KB).
However, within each segment, there may be different bus access restrictions (e.g., some parts of the
segment may only be accessible by the CPU’s Data bus). Therefore, each some segments are also further
divided into parts. Table 3-1 describes each part of internal memory and their address ranges on the data bus
and/or instruction bus.
Boundary Address
Bus Type Size (KB) Target
Low Address High Address
0x3FF0_0000 0x3FF1_FFFF 128 Internal ROM 1
Data bus
0x3FC8_0000 0x3FCD_FFFF 384 Internal SRAM 1
0x4000_0000 0x4003_FFFF 256 Internal ROM 0
0x4004_0000 0x4005_FFFF 128 Internal ROM 1
Instruction bus
0x4037_C000 0x4037_FFFF 16 Internal SRAM 0
Cont’d on next page
Note:
All of the internal memories are managed by Permission Control module. An internal memory can only be ac-
cessed when it is allowed by Permission Control, then the internal memory can be available to the CPU. For
more information about Permission Control, please refer to Chapter 14 Permission Control (PMS).
1. Internal ROM 0
Internal ROM 0 is a 256 KB, read-only memory space, addressed by the CPU only through the instruction bus
via 0x4000_0000 ~ 0x4003_FFFF, as shown in Table 3-1.
2. Internal ROM 1
Internal ROM 1 is a 128 KB, read-only memory space, addressed by the CPU through the instruction bus via
0x4004_0000 ~ 0x4005_FFFF or through the data bus via 0x3FF0_0000 ~ 0x3FF1_FFFF in the same order,
as shown in Table 3-1.
This means, for example, address 04004_0000 and 0x3FF0_0000 correspond to the same word,
0x4004_0004 and 0x3FF0_0004 correspond to the same word, 0x4004_0008 and 0x3FF0_0008
correspond to the same word, etc (the same ordering applies for Internal SRAM 1).
3. Internal SRAM 0
Internal SRAM 0 is a 16 KB, read-and-write memory space, addressed by the CPU through the instruction bus
via the range described in Table 3-1.
This memory managed by Permission Control, can be configured as instruction cache to store cache
instructions or read-only data of the external memory. In this case, the memory cannot be accessed by the
CPU. For more information about Permission Control, please refer to Chapter 14 Permission Control
(PMS).
4. Internal SRAM 1
Internal SRAM 1 is a 384 KB, read-and-write memory space, addressed by the CPU through the data bus or
instruction bus, in the same order, via the ranges described in Table 3-1.
RTC FAST Memory is a 8 KB, read-and-write SRAM, addressed by the CPU through the data/instruction bus via
the shared address 0x5000_0000 ~ 0x5000_1FFF, as described in Table 3-1.
The CPU accesses the external memory via the cache. According to the MMU (Memory Management Unit)
settings, the cache maps the CPU’s address to the external memory’s physical address. Due to this address
mapping, the ESP32-C3 can address up to 16 MB external flash.
Using the cache, ESP32-C3 is able to support the following address space mappings. Note that the
instruction bus address space (8MB) and the data bus address space (8 MB) is always shared.
• Up to 8 MB instruction bus address space can be mapped into the external flash. The mapped address
space is organized as individual 64-KB blocks.
• Up to 8 MB data bus (read-only) address space can be mapped into the external flash. The mapped
address space is organized as individual 64-KB blocks.
Table 3-2 lists the mapping between the cache and the corresponding address ranges on the data bus and
instruction bus.
Boundary Address
Bus Type Size (MB) Target
Low Address High Address
Data bus (read- 0x3C00_0000 0x3C7F_FFFF 8 Uniform Cache
only)
Instruction bus 0x4200_0000 0x427F_FFFF 8 Uniform Cache
Note:
Only if the CPU obtains permission for accessing the external memory, can it be responded for memory access.
For more detailed information about permission control, please refer to Chapter 14 Permission Control (PMS).
3.3.3.2 Cache
As shown in Figure 3-2, ESP32-C3 has a read-only uniform cache which is eight-way set-associative, its size is
16 KB and its block size is 32 bytes. When cache is active, some internal memory space will be occupied by
cache (see Internal SRAM 0 in Section 3.3.2).
The uniform 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 clear valid data in the cache. After this operation is completed, the
data will only be stored in the external memory. The CPU needs to access the external memory in order
to read this data. There are two types of invalidate-operation: automatic invalidation (Auto-Invalidate)
and manual invalidation (Manual-Invalidate). Manual-Invalidate is performed only on data in the specified
area in the cache, while Auto-Invalidate is performed on all data in the cache.
2. Preload: This operation is used 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 only locks the data 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 the Manual-Invalidate operations will only work 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 read and write Internal SRAM 1. Specifically, GDMA uses
address range 0x3FC8_0000 ~ 0x3FCD_FFFF to access Internal SRAM 1. Note that GDMA cannot access the
internal memory occupied by the cache.
As shown in Figure 3-3, these 7 vertical lines in turn correspond to these 7 peripherals/modules 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 peripheral/module 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 cannot enable the GDMA function at the same time.
These peripherals/modules can access any memory available to GDMA. For more information, please refer to
Chapter 2 GDMA Controller (GDMA).
Note:
When accessing a memory via GDMA, a corresponding access permission is needed, otherwise this access
may fail. For more information about permission control, please refer to Chapter 14 Permission Control (PMS).
3.3.5 Modules/Peripherals
The CPU can access modules/peripherals via 0x6000_0000 ~ 0x600D_0FFF shared by the data/instruction
bus.
Table 3-3 lists all the modules/peripherals and their respective address ranges. Note that the address space of
specific modules/peripherals is defined by ”Boundary Address” (including both Low Address and High
Address).
Boundary Address
Target Size (KB) Notes
Low Address High Address
UART Controller 0 0x6000_0000 0x6000_0FFF 4
Reserved 0x6000_1000 0x6000_1FFF
SPI Controller 1 0x6000_2000 0x6000_2FFF 4
SPI Controller 0 0x6000_3000 0x6000_3FFF 4
GPIO 0x6000_4000 0x6000_4FFF 4
Reserved 0x6000_5000 0x6000_6FFF
Reserved 0x6000_7000 0x6000_7FFF
Low-Power Management 0x6000_8000 0x6000_8FFF 4
IO MUX 0x6000_9000 0x6000_9FFF 4
Reserved 0x6000_A000 0x6000_FFFF
UART Controller 1 0x6001_0000 0x6001_0FFF 4
Reserved 0x6001_1000 0x6001_2FFF
I2C Controller 0x6001_3000 0x6001_3FFF 4
UHCI0 0x6001_4000 0x6001_4FFF 4
Reserved 0x6001_5000 0x6001_5FFF
Remote Control Peripheral 0x6001_6000 0x6001_6FFF 4
Reserved 0x6001_7000 0x6001_8FFF
LED PWM Controller 0x6001_9000 0x6001_9FFF 4
eFuse Controller 0x6001_A000 0x6001_AFFF 4
Reserved 0x6001_B000 0x6001_EFFF
Timer Group 0 0x6001_F000 0x6001_FFFF 4
Timer Group 1 0x6002_0000 0x6002_0FFF 4
Reserved 0x6002_1000 0x6002_2FFF
System Timer 0x6002_3000 0x6002_3FFF 4
SPI Controller 2 0x6002_4000 0x6002_4FFF 4
Reserved 0x6002_5000 0x6002_5FFF
SYSCON 0x6002_6000 0x6002_6FFF 4
Reserved 0x6002_7000 0x6002_AFFF
Two-wire Automotive Interface 0x6002_B000 0x6002_BFFF 4
Reserved 0x6002_C000 0x6002_CFFF
I2S Controller 0x6002_D000 0x6002_DFFF 4
Reserved 0x6002_E000 0x6003_9FFF
AES Accelerator 0x6003_A000 0x6003_AFFF 4
SHA Accelerator 0x6003_B000 0x6003_BFFF 4
RSA Accelerator 0x6003_C000 0x6003_CFFF 4
Cont’d on next page
4.1 Overview
ESP32-C3 contains a 4096-bit eFuse controller to store parameters. 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. If
read-protection for some data is not enabled, that data is readable from outside the chip. If read-protection is
enabled, that data can not be read from outside the chip. In all cases, however, some keys stored in eFuse
can still be used internally by hardware cryptography modules such as Digital Signature, HMAC, etc., without
exposing this data to the outside world.
4.2 Features
• 4096-bit One-time programmable storage
BLOCK0, which holds most parameters, has 9 bits that are readable but useless to users, and 60 further bits
are reserved for future use.
Table 4-1 lists all the parameters accessible (readable and usable) to users in BLOCK0 and their offsets, bit
widths, as well as information on whether their configuration is directly accessible by hardware, and whether
they are protected from programming.
The EFUSE_WR_DIS parameter is used to disable the writing of other parameters, while EFUSE_RD_DIS is
used to disable users from reading BLOCK4 ~ BLOCK10. For more information on these two parameters,
please see Section 4.3.1.1 and Section 4.3.1.2.
Programming-Protection
Bit Accessible
Parameters by EFUSE_WR_DIS Description
Width by Hardware
Bit Number
GoBack
EFUSE_SPI_BOOT_CRYPT_CNT 3 Y 4
abled.
Cont’d on next page
Espressif Systems
tion is disabled.
Represents whether UART secure download mode is en-
EFUSE_ENABLE_SECURITY_DOWNLOAD 1 N 18
abled.
EFUSE_UART_PRINT_CONTROL 2 N 18 Represents the UART boot message output mode.
Represents whether ROM code is forced to send a resume
EFUSE_FORCE_SEND_RESUME 1 N 18
GoBack
command during SPI boot.
Cont’d on next page
Espressif Systems
GoBack
4 eFuse Controller (EFUSE) GoBack
Table 4-2 lists all key purpose 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)
[60:65] N 20 N/A D7
EFUSE_SYS_DATA_PART0 78 N 20 N/A System data
BLOCK2 EFUSE_SYS_DATA_PART1 256 N 21 N/A System data
BLOCK3 EFUSE_USR_DATA 256 N 22 N/A User data
BLOCK4 EFUSE_KEY0_DATA 256 Y 23 0 KEY0 or user data
BLOCK5 EFUSE_KEY1_DATA 256 Y 24 1 KEY1 or user data
BLOCK6 EFUSE_KEY2_DATA 256 Y 25 2 KEY2 or user data
BLOCK7 EFUSE_KEY3_DATA 256 Y 26 3 KEY3 or user data
ESP32-C3 TRM (Version 1.1)
GoBack
4 eFuse Controller (EFUSE) GoBack
Among these blocks, BLOCK4 ~ 9 stores KEY0 ~ 5, respectively. 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 4-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 restrictions on writing to these parameters.
For more detailed information, please refer to Section 4.3.1.3 and Section 4.3.2.
4.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 4-1 and Table 4-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 while programmed bits always
remain 1.
4.3.1.2 EFUSE_RD_DIS
Only the eFuse blocks in BLOCK4 ~ BLOCK10 can be individually read protected to prevent any access from
outside the chip, as shown in column “Read Protection by EFUSE_RD_DIS Bit Number” of Table 4-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, then the eFuse block can be read by users; if the corresponding
EFUSE_RD_DIS bit is 1, then the parameter controlled by this bit is user protected.
Other parameters that are not in BLOCK4 ~ BLOCK10 can always be read by users.
When BLOCK4 ~ BLOCK10 are set to be read-protected, the data in these blocks are not readable by users,
but they can still be read by hardware cryptography modules, if the EFUSE_KEY_PURPOSE_n bit is set
accordingly.
Internally, eFuses use hardware encoding schemes to protect data from corruption, which are invisible for
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.
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 4-1 and 4-2 processes 32 data bytes using RS (44, 32). This coding
scheme encodes 32 bytes of data into 44 bytes:
• Bytes [32:43] are the encoded parity bytes stored in 8-bit flip-flops DFF1, DFF2, ..., DFF12 (gf_mul_n,
where n is an integer, is the result of multiplying a byte of data ...)
After that, the hardware burns into eFuse the 44-byte codeword consisting of the data bytes followed by the
parity bytes.
When the eFuse block is read back, the eFuse controller automatically decodes the codeword and applies
error correction if needed.
Because the RS check codes are generated on the entire 256-bit eFuse block, each block can only be written
once.
Programming BLOCK0
• EFUSE_PGM_DATA1_REG[24:21]
• EFUSE_PGM_DATA1_REG[31:27]
Programming BLOCK1
Programming BLOCK2 ~ 10
Programming process
3. Make sure the eFuse programming voltage VDDQ is configured correctly as described in Section 4.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/READ_DONE interrupt, please see the end of Section 4.3.3.
8. Trigger an eFuse read operation (see Section 4.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:
• BLOCK10: EFUSE_RD_RS_ERR1_REG[2:0][6:4]
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. Repeated programming of already programmed bits is strictly
forbidden, otherwise, programming errors will occur.
The eFuse Controller reads internal eFuses to update corresponding registers. This read operation happens
on system reset and can also be triggered manually by users as needed (e.g., if new eFuse values have been
3. Poll register EFUSE_CMD_REG until it is 0x0, or wait for a READ_DONE interrupt. Information on how to
identify a PGM/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 are any inconsistencies in the stored backup eFuse
parameters.
Registers EFUSE_RD_REPEAT_ERR0 ~ 3_REG indicate if there are any errors of programmed parameters
(except for EFUSE_WR_DIS) in BLOCK0 (value 1 indicates an error is detected, and the bit becomes invalid;
value 0 indicates no error).
Registers EFUSE_RD_RS_ERR0 ~ 1_REG store the number of corrected bytes as well as the result of RS
decoding during eFuse reading BLOCK1 ~ BLOCK10.
The values of above registers will be updated every time after the eFuse read registers 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:
1. 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/READ_DONE interrupt.
2. Configure the Interrupt Matrix to enable the CPU to respond to eFuse interrupt signals, see Chapter
8 Interrupt Matrix (INTERRUPT).
Note
When eFuse controller 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 initiated.
During the chip boot process, eFuse controller will update eFuse data into registers which can be accessed
by users automatically. Users can get programmed eFuse data by reading corresponding registers. Thus, it is
no need to update eFuse read 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. Thus, 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.
4.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.
4.5 Registers
The addresses in this section are relative to eFuse Controller base address provided in Table 3-3 in Chapter 3
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_
E
UA
US DI US LO L_ AD
CH
DI ICA JTA _I G
AN
E_ S_ B_ AD JTA
EF SE_ IS_ WN RIA LO
T
S_ C G CA
OO
AG M
LE
U D DO SE WN
G_ PIO
US DI US E_ D6
NS
JT D_
_B
AB
G
EF E_ S_ B_ DO
EF SE_ IS_ RC VE
PI
CH G
D_ OA
TA
M
N
EX AS_
U D O R
US RP W E
RA
PA NL
_J
RT HE
E
EF E_ S_T EL_
EF SE_ IS_ ES
C_
B_ I_
IS
S_ W
EF E_ 4 I A
US SP
_D
U D _R
DI DO
US DI _S
IS
F
_D
FT
E_ D_
EF E_ AG
E_ S_
T
SO
RD
)
)
US VD
US JT
US DI
ed
ed
EF SE_
EF SE_
E_
EF E_
E_
rv
rv
US
US
US
se
se
U
U
(re
(re
EF
EF
EF
EF
EF
31 27 26 25 24 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 0
EFUSE_DIS_FORCE_DOWNLOAD Represents whether the function that forces chip into download
mode is disabled. 1: Disabled. 0: Enabled. (RO)
EFUSE_JTAG_SEL_ENABLE Represents whether to use JTAG directly. 1: Use directly. 0: Not use
directly. (RO)
EFUSE_SOFT_DIS_JTAG Represents whether JTAG is disabled in the soft way. Odd count of bits
with a value of 1: Disabled. It can still be restarted via HMAC. Even count of bits with a value of
1: Enabled. (RO)
Note: The eFuse has a design flaw and does not move the pullup (needed to detect USB speed),
resulting in the PC thinking the chip is a low-speed device, which stops communication. For
detailed information, please refer to Chapter 30 USB Serial/JTAG Controller (USB_SERIAL_JTAG).
EFUSE_VDD_SPI_AS_GPIO Represents whether the VDD_SPI pin is used as a regular GPIO. 1: Used
as a regular GPIO. 0: Not used as a regular GPIO. (RO)
0
Y_ VO 2
VO 1
KE RE KE
RE KE
KE
T_ Y_ VO
OO KE RE
T
CN
_B T_ Y_
T_
RE OO KE
D2
_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
EFUSE_SECURE_BOOT_KEY_REVOKE0 Represents whether or not the first secure boot key is re-
voked. 1: Revoked. 0: Not revoked. (RO)
EFUSE_SECURE_BOOT_KEY_REVOKE2 Represents whether or not the third secure boot key is re-
voked. 1: Revoked. 0: Not revoked. (RO)
E
OK
EV
_R
VE
SI
EN ES
T_ GR
OO AG
0
D3
2
3
4
5
ED
_B T_
E_
E_
E_
E_
VE
RV
RE OO
UW
OS
OS
OS
OS
ER
SE
CU _B
ES
RP
RP
RP
RP
P
RE
_T
SE RE
_R
PU
PU
PU
PU
H
E_ CU
T4
T4
AS
Y_
Y_
Y_
Y_
RP
RP
KE
KE
KE
KE
US SE
FL
E_
E_
EF E_
E_
E_
E_
E_
E_
US
US
US
US
US
US
US
US
EF
EF
EF
EF
EF
EF
EF
EF
31 28 27 22 21 20 19 16 15 12 11 8 7 4 3 0
EFUSE_FLASH_TPUW Represents flash waiting time after power-up. Measurement unit: ms. If the
value is less than 15, the waiting time is the configurable value. Otherwise, the waiting time is
always 30 ms. (RO)
E
OD
M
D_
OA
NL
DO AD
W
DI _R T_C D7 G_ LO
E_ T4 IN VE JTA N
US RP PR ER L_ OW
E
E
OD
UM
NL D L
US RP US EC TRO
W VE NE
M
ES
8
DO SER AN
ER LE
ON
U U _R SE IT
D1
ON
D_
ED
_R
EF E_ T4 B_ UR
ES AB
VE
H
SI
OA
_C
RV
ND
ER
_R EN
NT
SE
E
EF E_ S_ _S
_V
T4 T_
RI
_S
RE
S_ E
RE
RP RS
US DI LE
_P
CE
4_
EF E_ AB
U
E_ R_
US ART
R
PT
EC
US EN
FO
US ER
U
R
_S
EF SE_
E_
E_
E_
EF _
SE
E
US
US
US
U
U
EF
EF
EF
EF
EF
EF
31 30 29 14 13 12 8 7 6 5 4 3 2 1 0
EFUSE_UART_PRINT_CONTROL Represents the UART boot message output mode. 00: Enabled.
01: Enabled when GPIO8 is low at reset. 10: Enabled when GPIO8 is high at reset. 11: Disabled.
(RO)
EFUSE_SECURE_VERSION Represents the values of version control register (used by ESP-IDF anti-
rollback feature). (RO)
EFUSE_ERR_RST_ENABLE Represents whether to enable the check for error registers of block0.
1: Enabled. 0: Disabled. (RO)
D4
E
E RV
ES
_R
T4
RP
)
ed
E_
rv
US
se
(re
EF
31 24 23 0
0 0 0 0 0 0 0 0 0x0000 Reset
_0
AC
_M
U SE
EF
31 0
0x000000 Reset
_1
AC
I_
P
M
_S
E_
SE
US
U
EF
EF
31 16 15 0
_1
NF
CO
D_
PA
_
PI
_S
SE
U
EF
31 0
0x000000 Reset
_2
RT
NF
PA
CO
_
TA
D_
DA
PA
_
I_
YS
SP
_S
E_
SE
US
U
EF
EF
31 18 17 0
EFUSE_SYS_DATA_PART0_0 Stores the first 14 bits of the zeroth part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART0_1 Stores the fist 32 bits of the zeroth part of system data. (RO)
2
0_
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART0_2 Stores the second 32 bits of the zeroth part of system data. (RO)
_0
T1
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_0 Stores the zeroth 32 bits of the first part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_1 Stores the first 32 bits of the first part of system data. (RO)
2
1_
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_2 Stores the second 32 bits of the first part of system data. (RO)
_3
T1
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_3 Stores the third 32 bits of the first part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_4 Stores the fourth 32 bits of the first part of system data. (RO)
5
1_
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_5 Stores the fifth 32 bits of the first part of system data. (RO)
_6
T1
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_6 Stores the sixth 32 bits of the first part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART1_7 Stores the seventh 32 bits of the first part of system data. (RO)
0A
AT
_D
SR
E_U
US
EF
31 0
0x000000 Reset
1
TA
DA
R_
S
_U
SE
U
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
4
TA
DA
R_
S
_U
SE
U
EF
31 0
0x000000 Reset
5
TA
DA
R_
US
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
0
TA
DA
0_
EY
_K
SE
U
EF
31 0
0x000000 Reset
1
TA
DA
0_
EY
E_K
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
4
TA
DA
0_
EY
_K
SE
U
EF
31 0
0x000000 Reset
5
A
AT
_D
Y0
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
0
TA
DA
1_
EY
_K
E
US
EF
31 0
0x000000 Reset
1
TA
DA
1_
EY
_K
E
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
4
TA
DA
1_
EY
E_K
US
EF
31 0
0x000000 Reset
5
TA
DA
1_
EY
K
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
0
TA
DA
2_
EY
_K
SE
U
EF
31 0
0x000000 Reset
A1
AT
_D
2
KEY
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
A 4
AT
_D
2
EY
_K
E
US
EF
31 0
0x000000 Reset
A 5
AT
_D
2
K EY
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
0
TA
DA
3_
EY
_K
SE
U
EF
31 0
0x000000 Reset
1
TA
DA
3_
KEY
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
4
TA
DA
3_
EY
E _K
US
EF
31 0
0x000000 Reset
5
TA
DA
3_
EY
E_K
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
0
TA
DA
4_
EY
_K
E
US
EF
31 0
0x000000 Reset
1
TA
DA
4_
EY
_K
E
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
4
TA
DA
4_
EY
E_K
US
EF
31 0
0x000000 Reset
5
TA
DA
4_
K EY
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
A0
AT
_D
5
EY
_K
SE
U
EF
31 0
0x000000 Reset
1
TA
DA
5_
KEY
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
A4
AT
_D
5
EY
_K
E
US
EF
31 0
0x000000 Reset
A5
AT
_D
Y5
KE
E_
US
EF
31 0
0x000000 Reset
31 0
0x000000 Reset
31 0
0x000000 Reset
_0
2
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_0 Stores the 0th 32 bits of the 2nd part of system data. (RO)
_1
2
RT
PA
_
TA
DA
_
YS
E_S
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_1 Stores the 1st 32 bits of the 2nd part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_2 Stores the 2nd 32 bits of the 2nd part of system data. (RO)
_3
2
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_3 Stores the 3rd 32 bits of the 2nd part of system data. (RO)
_4
T2
AR
_P
TA
DA
S_
SY
E_
US
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_4 Stores the 4th 32 bits of the 2nd part of system data. (RO)
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_5 Stores the 5th 32 bits of the 2nd part of system data. (RO)
_6
2
RT
PA
_
TA
DA
_
YS
_S
SE
U
EF
31 0
0x000000 Reset
EFUSE_SYS_DATA_PART2_6 Stores 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 Stores the 7th 32 bits of the 2nd part of system data. (RO)
R
ER
T_
YP
CR
EN
R
DI ICA JTA _I G_ RR
ER
RT HE _E CH RR
L_
E_ S_ B_ AD JTA _E
R
C_ _E RR E_
S_ C G CA E
ER
RR UA
RR
US DI US LO L_ AD
NS RR
U D DO SE WN RR
RR
T_
_E AN
EF E_ _ ES R _E
EF E_ S_ B_ DO _E
_E
OO
AG M
E
G_ PIO
_E
US DI US E_ D6
US DI _R ER L
JT D_
RA RR
_B
EF E_ 4 I_ AB
G
EF SE_ IS_ RC VE
CH G
D_ OA
TA
M
N
EX AS_
U D FO ER
RR
US RP W E
PA NL
_J
EF E_ S_T EL_
_E
B_ I_
IS
S_ W
A
US SP
_D
DI DO
US DI _S
IS
_D
FT
E_ D_
EF E_ AG
E_ S_
T
S
SO
RD
)
)
US VD
US JT
US DI
ed
ed
EF SE_
EF E_
E_
EF E_
E_
rv
rv
US
US
US
US
se
se
U
(re
(re
EF
EF
EF
EF
EF
31 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 in this filed set to 1 indicates that an error occurs in programming
EFUSE_RD_DIS. (RO)
EFUSE_DIS_ICACHE_ERR Any bit in this filed set to 1 indicates that an error occurs in programming
EFUSE_DIS_ICACHE. (RO)
EFUSE_DIS_USB_JTAG_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_DIS_USB_JTAG. (RO)
EFUSE_DIS_DOWNLOAD_ICACHE_ERR Any bit in this filed set to 1 indicates that an error occurs in
programming EFUSE_DIS_DOWNLOAD_ICACHE. (RO)
EFUSE_DIS_USB_SERIAL_JTAG_ERR Any bit in this filed set to 1 indicates that an error occurs in
programming EFUSE_DIS_USB_SERIAL_JTAG. (RO)
EFUSE_DIS_FORCE_DOWNLOAD_ERR Any bit in this filed set to 1 indicates that an error occurs in
programming EFUSE_DIS_FORCE_DOWNLOAD. (RO)
EFUSE_DIS_TWAI_ERR Any bit in this filed set to 1 indicates that an error occurs in programming
EFUSE_DIS_TWAI. (RO)
EFUSE_JTAG_SEL_ENABLE_ERR Any bit in this filed set to 1 indicates that an error occurs in pro-
gramming EFUSE_JTAG_SEL_ENABLE. (RO)
EFUSE_SOFT_DIS_JTAG_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_SOFT_DIS_JTAG. (RO)
EFUSE_DIS_PAD_JTAG_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_DIS_PAD_JTAG. (RO)
EFUSE_USB_EXCHG_PINS_ERR Any bit in this filed set to 1 indicates that an error occurs in pro-
gramming EFUSE_USB_EXCHG_PINS. (RO)
EFUSE_VDD_SPI_AS_GPIO_ERR Any bit in this filed set to 1 indicates that an error occurs in pro-
gramming EFUSE_VDD_SPI_AS_GPIO. (RO) 143
Espressif Systems ESP32-C3 TRM (Version 1.1)
Submit Documentation Feedback
4 eFuse Controller (EFUSE) GoBack
VO 1_ R
R
0_ R
RE KE ER
ER
KE ER
Y_ VO 2_
KE RE KE
R
ER
T_ Y_ VO
R
OO KE RE
NT
R
R
RR
RR
ER
_E
_B T_ Y_
_C
_E
_E
RE OO KE
0_
D2
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
EFUSE_WDT_DELAY_SEL_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_WDT_DELAY_SEL. (RO)
EFUSE_SPI_BOOT_CRYPT_CNT_ERR Any bit in this filed set to 1 indicates that an error occurs in
programming EFUSE_SPI_BOOT_CRYPT_CNT. (RO)
EFUSE_SECURE_BOOT_KEY_REVOKE0_ERR Any bit in this filed set to 1 indicates that an error oc-
curs in programming EFUSE_SECURE_BOOT_KEY_REVOKE0. (RO)
EFUSE_SECURE_BOOT_KEY_REVOKE1_ERR Any bit in this filed set to 1 indicates that an error occurs
in programming EFUSE_SECURE_BOOT_KEY_REVOKE1. (RO)
EFUSE_SECURE_BOOT_KEY_REVOKE2_ERR Any bit in this filed set to 1 indicates that an error oc-
curs in programming EFUSE_SECURE_BOOT_KEY_REVOKE2. (RO)
EFUSE_KEY_PURPOSE_0_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_KEY_PURPOSE_0. (RO)
EFUSE_KEY_PURPOSE_1_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_KEY_PURPOSE_1. (RO)
R
ER
E_
OK
EV
_R
RR VE
_E SI
EN ES
R
RR
R
R
R
R
ER
T_ GR
ER
ER
ER
ER
_E
0_
OO AG
RR
2_
4_
5_
3_
D3
ED
_B T_
_E
E_
E_
E_
E_
VE
RV
RE OO
UW
OS
OS
OS
OS
ER
SE
CU _B
ES
RP
RP
RP
RP
P
RE
_T
SE RE
_R
PU
PU
PU
PU
H
E_ CU
T4
T4
AS
Y_
Y_
Y_
Y_
RP
RP
KE
KE
KE
KE
US SE
FL
E_
E_
EF E_
E_
E_
E_
E_
E_
US
US
US
US
US
US
US
US
EF
EF
EF
EF
EF
EF
EF
EF
31 28 27 22 21 20 19 16 15 12 11 8 7 4 3 0
EFUSE_KEY_PURPOSE_2_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_KEY_PURPOSE_2. (RO)
EFUSE_KEY_PURPOSE_3_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_KEY_PURPOSE_3. (RO)
EFUSE_KEY_PURPOSE_4_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_KEY_PURPOSE_4. (RO)
EFUSE_KEY_PURPOSE_5_ERR Any bit in this filed set to 1 indicates that an error occurs in program-
ming EFUSE_KEY_PURPOSE_5. (RO)
EFUSE_SECURE_BOOT_EN_ERR Any bit in this filed set to 1 indicates that an error occurs in pro-
gramming EFUSE_SECURE_BOOT_EN. (RO)
EFUSE_FLASH_TPUW_ERR Any bit in this filed set to 1 indicates that an error occurs in programming
EFUSE_FLASH_TPUW. (RO)
R
ER
E_
OD
M
D_
NL RR
OA
DO SER AN RR OW D_E
H E D A
DI _R T_C D7_ G_ LO
R
R
ER
ER
D_ ER RR
ER
E_ T4 IN E TA N
E_
US RP PR R _ OW
E_
OA 8_ _E
L_
RR
M R
D1 RR
RR
RR
OD
UM
NL D L
US RP S EC TRO
W VE NE
VE _E
_E
_E
J
ES
5
ER LE
U U _R SE IT
N
ED
L
IO
_R
CO
EF E_ T4 _ R
ES AB
U
RS
RV
V
ND
T_
_R EN
VE
SE
E
IN
E
EF E_ S_ _S
T4 T_
_S
E_
RE
S_ E
PR
B
RP RS
US DI LE
R
CE
4_
U
EF SE_ AB
CU
E_ R_
US ART
R
PT
U EN
FO
US ER
SE
U
R
EF SE_
E_
E_
E_
E_
EF _ E
US
US
US
US
U
EF
EF
EF
EF
EF
EF
31 30 29 14 13 12 8 7 6 5 4 3 2 1 0
EFUSE_DIS_DOWNLOAD_MODE_ERR Any bit in this filed set to 1 indicates that an error occurs in
programming EFUSE_DIS_DOWNLOAD_MODE. (RO)
EFUSE_USB_PRINT_CHANNEL_ERR Any bit in this filed set to 1 indicates that an error occurs in
programming EFUSE_DIS_DOWNLOAD_MODE. (RO)
EFUSE_UART_PRINT_CONTROL_ERR Any bit in this filed set to 1 indicates that an error occurs in
programming EFUSE_UART_PRINT_CONTROL. (RO)
EFUSE_FORCE_SEND_RESUME_ERR Any bit in this filed set to 1 indicates that an error occurs in
programming EFUSE_FORCE_SEND_RESUME (RO)
EFUSE_SECURE_VERSION_ERR Any bit in this filed set to 1 indicates that an error occurs in pro-
gramming EFUSE_SECURE_VERSION. (RO)
EFUSE_ERR_RST_ENABLE_ERR Any bit in this filed set to 1 indicates that an error occurs in pro-
gramming EFUSE_ERR_RST_ENABLE. (RO)
RR
_E
D4
E
E RV
ES
_R
T4
RP
d)
ve
E_
r
US
se
(re
EF
31 24 23 0
0 0 0 0 0 0 0 0 0x0000 Reset
UM
M
_N
NU
RR
AI
UM
R_
UM
UM
UM
L
UM
_E
_F
M
AI
AI
ER
NU
N
M
M
_F
_N
_N
_N
N
_F
1_
_8
_8
A_
R_
R_
T1
L
L
L
RR
RR
RR
TA
RT
L
AI
AI
AI
PI
PI
R
AI
ER
DA
DA
_E
_E
_F
_F
_E
_F
PA
PA
_E
_S
_S
_F
4_
R_
R_
Y0
Y0
Y2
Y2
Y3
Y3
S_
S_
Y1
Y1
AC
AC
EY
US
US
KE
KE
KE
KE
KE
KE
KE
KE
)
SY
SY
M
M
ed
K
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
E_
rv
US
US
US
US
US
US
US
US
US
US
US
US
US
US
US
se
(re
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
EF
31 30 28 27 26 24 23 22 20 19 18 16 15 14 12 11 10 8 7 6 4 3 2 0
EFUSE_MAC_SPI_8M_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_SYS_PART1_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_USR_DATA_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_SYS_PART1_FAIL 0: Means no failure and that the data of system part1 is reliable 1: Means
that programming data of system part1 failed and the number of error bytes is over 6. (RO)
EFUSE_KEY0_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_USR_DATA_FAIL 0: Means no failure and that the user data is reliable 1: Means that pro-
gramming user data failed and the number of error bytes is over 6. (RO)
EFUSE_KEY1_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_KEY0_FAIL 0: Means no failure and that the data of key0 is reliable 1: Means that program-
ming key0 failed and the number of error bytes is over 6. (RO)
EFUSE_KEY2_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_KEY1_FAIL 0: Means no failure and that the data of key1 is reliable 1: Means that program-
ming key1 failed and the number of error bytes is over 6. (RO)
EFUSE_KEY3_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_KEY2_FAIL 0: Means no failure and that the data of key2 is reliable 1: Means that program-
ming key2 failed and the number of error bytes is over 6. (RO)
EFUSE_KEY4_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_KEY3_FAIL 0: Means no failure and that the data of key3 is reliable 1: Means that program-
ming key3 failed and the number of error bytes is over 6. (RO)
UM
_N
RR
UM
_E
_N
T2
IL
RR
L
AI
AR
FA
_E
_F
5_
_P
Y5
Y4
EY
YS
KE
KE
d)
_S
ve
E_
E_
E_
SE
r
US
US
US
se
U
(re
EF
EF
EF
EF
31 8 7 6 4 3 2 0
EFUSE_KEY5_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_KEY4_FAIL 0: Means no failure and that the data of KEY4 is reliable 1: Means that program-
ming KEY4 data failed and the number of error bytes is over 6. (RO)
EFUSE_SYS_PART2_ERR_NUM The value of this signal means the number of error bytes. (RO)
EFUSE_KEY5_FAIL 0: Means no failure and that the data of KEY5 is reliable 1: Means that program-
ming KEY5 data failed and the number of error bytes is over 6. (RO)
_F E_O PU
D
_P
OR N
EM C _
M OR CE
CE
E_ _F OR
US LK _F
EF _C M
E_ EM ME
EN
US M E_
EF E_ US
K_
CL
US EF
)
)
ed
ed
E_
EF SE_
rv
rv
US
se
se
U
(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_EFUSE_MEM_FORCE_PD Set this bit to force eFuse SRAM into power-saving mode. (R/W)
EFUSE_MEM_CLK_FORCE_ON Set this bit and force to activate clock signal of eFuse SRAM. (R/W)
EFUSE_EFUSE_MEM_FORCE_PU Set this bit to force eFuse SRAM into working mode. (R/W)
EFUSE_CLK_EN Set this bit and force to enable clock signal of eFuse memory. (R/W)
DE
CO
P_
d)
_O
ve
E
r
US
se
(re
EF
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
D
AD MD
UM
M
_C
RE _C
_N
E_ M
LK
US PG
)
ed
_B
EF E_
rv
E
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 The serial number of the block to be programmed. Value 0-10 corresponds to
block number 0-10, respectively. (R/W)
IV
PA
_D
_
UM
LK
LK
R
C
L
_C
C_
C_
C_
DA
DA
DA
OE
)
ed
E_
E_
E_
E_
rv
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 Controls the division factor of the rising clock of the programming voltage.
(R/W)
M
NU
T_
NI
I
A D_
RE
)
ed
E_
rv
US
se
(re
EF
31 24 23 0
0x12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
M
_ NU
ON
R_
W
)
)
ed
ed
_P
rv
rv
SE
se
se
U
(re
(re
EF
31 24 23 8 7 0
0 0 0 0 0 0 0 0 0x2880 0 0 0 0 0 0 0 0 Reset
E_
r
US
se
(re
EF
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x190 Reset
NT
_C
RR
_E
AT
E
PE
AT
RE
ST
d)
d)
ve
ve
E_
E_
r
r
US
US
se
se
(re
(re
EF
EF
31 18 17 10 9 4 3 0
EFUSE_REPEAT_ERR_CNT Indicates the number of error bits during programming BLOCK0. (RO)
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
_D
rv
E
US
se
(re
EF
31 28 27 0
0 0 0 0 0x2006300 Reset
5.1 Overview
The ESP32-C3 chip features 22 physical GPIO pins. Each pin can be used as a general-purpose I/O, or be
connected to an internal peripheral signal. Through GPIO matrix and IO MUX, peripheral input signals can be
from any IO pins, and peripheral output signals can be routed to any IO pins. Together these modules provide
highly configurable I/O.
5.2 Features
GPIO Matrix Features
• A full-switching matrix between the peripheral input/output signals and the pins.
• 42 peripheral input signals can be sourced from the input of any GPIO pins.
• The output of any GPIO pins can be from any of the 78 peripheral output signals.
• Supports signal synchronization for peripheral inputs based on APB clock bus.
IO MUX Features
• Provides one configuration register IO_MUX_GPIOn_REG for each GPIO pin. The pin can be configured to
• Supports some high-speed digital signals (SPI, JTAG, UART) bypassing GPIO matrix for better
high-frequency digital performance. In this case, IO MUX is used to connect these pins directly to
peripherals.
• Figure 5-1 shows the general work flow of IO MUX and GPIO matix.
• Figure 5-2 shows in details how IO MUX and GPIO matrix route signals from pins to peripherals, and from
peripherals to pins.
1. Only part of peripheral input signals (marked “yes” in column “Direct input through IO MUX” in Table 5-2)
can bypass GPIO matrix. The other input signals can only be routed to peripherals via GPIO matrix.
2. There are only 22 inputs from GPIO SYNC to GPIO matrix, since ESP32-C3 provides 22 GPIO pins in total.
3. The pins supplied by VDD3P3_CPU or by VDD3P3_RTC 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 5-2) can
5. There are only 22 outputs (GPIO pin X: 0 ~ 21) from GPIO matrix to IO MUX.
Figure 5-3 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 22 GPIO pins and can be controlled using IE, OE, WPU, and
WPD signals.
Note:
• 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.
Figure 5-4. GPIO Input Synchronized on APB Clock Rising Edge or on Falling Edge
Figure 5-4 shows the functionality of GPIO SYNC. In the figure, negative sync and positive sync mean GPIO
input is synchronized on APB clock falling edge and on APB clock rising edge, respectively.
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 filter for pin input signals by setting the register IO_MUX_GPIOn_FILTER_EN. Only
the signals with a valid width of more than two clock cycles can be sampled, see Figure 5-5.
3. Synchronize GPIO input. To do so, please set GPIO_PINx_REG corresponding to GPIO pin X as follows:
4. 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 MCLK input signal3 (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 0x1F, input signal is always 0.
• When GPIO_FUNCy_IN_SEL is set to 0x1E, input signal is always 1.
The output signal is routed from the peripheral into GPIO matrix and then into IO MUX. IO MUX must be
configured to set the chosen pin to GPIO function. This enables the output GPIO signal to be connected to
the pin.
Note:
There is a range of peripheral output signals (97 ~ 100) which are not connected to any peripheral, but to the input
signals (97 ~ 100 in Table 5-2) directly. These can be used to input a signal from one GPIO pin and output directly to
another GPIO pin.
• 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 5-2), clear
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 the 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 pinX.
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 driver strength, the more current can be sourced/sunk from the pin.
– 0: ~5 mA
– 1: ~10 mA
– 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:
• Recommended operation: use corresponding W1TS and W1TC registers, such as GPIO_OUT_W1TS/GPIO_OUT
_W1TC to set or clear the registers GPIO_OUT_REG.
Four out of the 125 peripheral outputs (output index: 55 ~ 58 in Table 5-2) support 1-bit second-order sigma
delta modulation. By default output is enabled for these four channels. This modulator can also output PDM
(pulse density modulation) signal with configurable duty cycle. The transfer function of this second-order
SDM modulator is:
After scaling, the clock cycle is equal to one pulse output cycle from the modulator.
GPIOSD_SDn_IN is a signed number with a range of [-128, 127] and is used to control the duty cycle 1 of PDM
output signal.
• GPIOSD_SDn_IN = 127, the duty cycle of the output signal is close to 100%.
The formula for calculating PDM signal duty cycle is shown as below:
GP IOSD_SDn_IN + 128
Duty_Cycle =
256
Note:
For PDM signals, duty cycle refers to the percentage of high level cycles to the whole statistical period (several pulse
cycles, for example 256 pulse cycles).
• Route one of SDM outputs to a pin via GPIO matrix, see Section 5.5.2.
• Configure the duty cycle of SDM output signal by setting the register GPIOSD_SDn_IN.
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 5.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. For the list of pin functions, please refer to Section 5.12.
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.
Note:
If IO_MUX_SLP_SEL is set to 0, pin functions remain the same in both normal execution and Light-sleep mode. Please
refer to Section 5.5.2 for how to enable output in normal execution.
Note:
• For digital pins (GPIO6 ~21), to maintain pin input/output status in Deep-sleep mode, users can set RTC_CNTL_DIG
_PAD_HOLDn in register RTC_CNTL_DIG_PAD_HOLD_REG to 1 before powering down. To disable the hold func-
tion after the chip is woken up, users can set RTC_CNTL_DIG_PAD_HOLDn to 0.
• For RTC pins (GPIO0 ~5), the input and output values are controlled by the corresponding bits of register
RTC_CNTL
_PAD_HOLD_REG, and users can set it to 1 to hold the value or set it to 0 to unhold the value.
• VDD3P3_RTC: the input power supply for both RTC and CPU
• 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 5-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 the “Output enable signal when GPIO_FUNCn_OEN_SEL = 0”, it indicates that
once the register 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 5-2 are valid input signals.
• Only the signals with a name assigned in the column ”Output signal” in Table 5-2 are valid output signals.
Direct Direct
Signal Default Output enable signal when
Input Signal Input via IO Output Signal Output via
No. value GPIO_FUNCn_OEN_SEL = 0
MUX IO MUX
0 SPIQ_in 0 yes SPIQ_out SPIQ_oe yes
1 SPID_in 0 yes SPID_out SPID_oe yes
2 SPIHD_in 0 yes SPIHD_out SPIHD_oe yes
3 SPIWP_in 0 yes SPIWP_out SPIWP_oe yes
4 - - - SPICLK_out_mux SPICLK_oe yes
5 - - - SPICS0_out SPICS0_oe yes
6 U0RXD_in 0 yes U0TXD_out 1’d1 yes
Submit Documentation Feedback
GoBack
23 - - - - 1’d1 no
24 - - - - 1’d1 no
Espressif Systems
37 - - - usb_jtag_tms 1’d1 no
38 - - - usb_jtag_tdi 1’d1 no
39 - - - usb_jtag_tdo 1’d1 no
40 - - - - 1’d1 no
41 - - - - 1’d1 no
42 - - - - 1’d1 no
43 - - - - 1’d1 no
44 - - - - 1’d1 no
ESP32-C3 TRM (Version 1.1)
GoBack
50 - - - ledc_ls_sig_out5 1’d1 no
51 rmt_sig_in0 0 no rmt_sig_out0 1’d1 no
Espressif Systems
60 - - - - 1’d1 no
61 - - - - 1’d1 no
62 - - - - 1’d1 no
63 FSPICLK_in 0 yes FSPICLK_out_mux FSPICLK_oe yes
166
72 - - - FSPICS4_out FSPICS4_oe no
73 - - - FSPICS5_out FSPICS5_oe no
74 twai_rx 1 no twai_tx 1’d1 no
75 - - - twai_bus_off_on 1’d1 no
76 - - - twai_clkout 1’d1 no
GoBack
77 - - - - 1’d1 no
78 - - - - 1’d1 no
Espressif Systems
87 - - - - 1’d1 no
88 - - - - 1’d1 no
89 - - - ant_sel0 1’d1 no
90 - - - ant_sel1 1’d1 no
167
91 - - - ant_sel2 1’d1 no
92 - - - ant_sel3 1’d1 no
93 - - - ant_sel4 1’d1 no
94 - - - ant_sel5 1’d1 no
95 - - - ant_sel6 1’d1 no
96 - - - ant_sel7 1’d1 no
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
ESP32-C3 TRM (Version 1.1)
GoBack
104 - - - - 1’d1 no
105 - - - - 1’d1 no
Espressif Systems
114 - - - - 1’d1 no
115 - - - - 1’d1 no
116 - - - - 1’d1 no
117 - - - - 1’d1 no
168
118 - - - - 1’d1 no
119 - - - - 1’d1 no
120 - - - - 1’d1 no
121 - - - - 1’d1 no
122 - - - - 1’d1 no
123 - - - CLK_OUT_out1 1’d1 no
124 - - - CLK_OUT_out2 1’d1 no
125 - - - CLK_OUT_out3 1’d1 no
ESP32-C3 TRM (Version 1.1)
GoBack
5 IO MUX and GPIO Matrix (GPIO, IO MUX) GoBack
Pin Pin Name Function 0 Function 1 Function 2 Function 3 DRV Reset Notes
No.
4 XTAL_32K_P GPIO0 GPIO0 - - 2 0 R
5 XTAL_32K_N GPIO1 GPIO1 - - 2 0 R
6 GPIO2 GPIO2 GPIO2 FSPIQ - 2 1 R
8 GPIO3 GPIO3 GPIO3 - - 2 1 R
9 MTMS MTMS GPIO4 FSPIHD - 2 1 R
10 MTDI MTDI GPIO5 FSPIWP - 2 1 R
12 MTCK MTCK GPIO6 FSPICLK - 2 1* G
13 MTDO MTDO GPIO7 FSPID - 2 1 G
14 GPIO8 GPIO8 GPIO8 - - 2 1 -
15 GPIO9 GPIO9 GPIO9 - - 2 3 -
16 GPIO10 GPIO10 GPIO10 FSPICS0 - 2 1 G
18 VDD_SPI GPIO11 GPIO11 - - 2 0 -
19 SPIHD SPIHD GPIO12 - - 2 3 -
20 SPIWP SPIWP GPIO13 - - 2 3 -
21 SPICS0 SPICS0 GPIO14 - - 2 3 -
22 SPICLK SPICLK GPIO15 - - 2 3 -
23 SPID SPID GPIO16 - - 2 3 -
24 SPIQ SPIQ GPIO17 - - 2 3 -
25 GPIO18 GPIO18 GPIO18 - - 3 0 USB,
G
26 GPIO19 GPIO19 GPIO19 - - 3 0* USB
27 U0RXD U0RXD GPIO20 - - 2 3 G
28 U0TXD U0TXD GPIO21 - - 2 4 -
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)
• 0* - IE = 0, WPU = 0. The USB pull-up value of GPIO19 is 1 by default, therefore, the pin’s pull-up resistor
is enabled. For more information, see the note below.
• 1* - If eFuse bit EFUSE_DIS_PAD_JTAG = 1, the pin MTCK is left floating after reset, i.e. IE = 1. If eFuse bit
EFUSE_DIS_PAD_JTAG = 0, the pin MTCK is connected to internal pull-up resistor, i.e. IE = 1, WPU = 1.
Note:
• R - Pins in VDD3P3_RTC domain, and part of them have analog functions, see Table 5-5.
• USB - GPIO18 and GPIO19 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.
• G - These pins have glitches during power-up. See details in Table 5-4.
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.
5.15 Registers
SEL
T_
_B
IO
GP
31 0
0x000000 Reset
G
RI
_O
TA
DA
T_
)
ed
OU
rv
O_
se
I
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_OUT_DATA_ORIG GPIO0 ~ 21 output value in simple GPIO output mode. The values of bit0
~ bit21 correspond to the output value of GPIO0 ~ GPIO21 respectively, and bit22 ~ bit25 are
invalid. (R/W/SS)
UT
ed
_O
rv
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_OUT_W1TS GPIO0 ~ 21 output set register. Bit0 ~ bit21 are corresponding to GPIO0 ~
21, and bit22 ~ bit25 are invalid. If the value 1 is written to a bit here, the correspond-
ing bit in GPIO_OUT_REG will be set to 1. Recommended operation: use this register to set
GPIO_OUT_REG. (WT)
C
1T
_W
)
UT
ed
_O
rv
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_OUT_W1TC GPIO0 ~ 21 output clear register. Bit0 ~ bit21 are corresponding to GPIO0 ~
21, and bit22 ~ bit25 are invalid. If the value 1 is written to a bit here, the corresponding
bit in GPIO_OUT_REG will be cleared. Recommended operation: use this register to clear
GPIO_OUT_REG. (WT)
TA
DA
E_
BL
)
NA
ed
E
rv
O_
se
I
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_ENABLE_DATA GPIO output enable register for GPIO0 ~ 21. Bit0 ~ bit21 are corresponding to
GPIO0 ~ 21, and bit22 ~ bit25 are invalid. (R/W/SS)
NA
ed
_E
rv
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_ENABLE_W1TS GPIO0 ~ 21 output enable set register. Bit0 ~ bit21 are corresponding to
GPIO0 ~ 21, and bit22 ~ bit25 are invalid. If the value 1 is written to a bit here, the corresponding
bit in GPIO_ENABLE_REG will be set to 1. Recommended operation: use this register to set
GPIO_ENABLE_REG. (WT)
C
1T
_W
LE
B
)
NA
ed
_E
rv
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_ENABLE_W1TC GPIO0 ~ 21 output enable clear register. Bit0 ~ bit21 are corresponding to
GPIO0 ~ 21, and bit22 ~ bit25 are invalid. If the value 1 is written to a bit here, the corresponding
bit in GPIO_ENABLE_REG will be cleared. Recommended operation: use this register to clear
GPIO_ENABLE_REG. (WT)
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
• bit 0: GPIO2
• bit 2: GPIO8
• bit 3: GPIO9
N_
rv
_I
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_IN_DATA_NEXT GPIO0 ~ 21 input value. Bit0 ~ bit21 are corresponding to GPIO0 ~ 21, and
bit22 ~ bit25 are invalid. Each bit represents a pin input value, 1 for high level and 0 for low level.
(RO)
T
RUP
ER
INT
S_
TU
d)
TA
ve
_S
r
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
S
1T
W
S_
TU
)
TA
ed
_S
rv
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_STATUS_W1TS GPIO0 ~ 21 interrupt status set register. Bit0 ~ bit21 are corresponding to
GPIO0 ~ 21, and bit22 ~ bit25 are invalid. If the value 1 is written to a bit here, the corresponding
bit in GPIO_STATUS_INTERRUPT will be set to 1. Recommended operation: use this register to
set GPIO_STATUS_INTERRUPT. (WT)
TA
ed
_S
rv
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_STATUS_W1TC GPIO0 ~ 21 interrupt status clear register. Bit0 ~ bit21 are corresponding to
GPIO0 ~ 21, and bit22 ~ bit25 are invalid. If the value 1 is written to a bit here, the corresponding
bit in GPIO_STATUS_INTERRUPT will be cleared. Recommended operation: use this register to
clear GPIO_STATUS_INTERRUPT. (WT)
NT
I
U_
CP
RO
)
ed
_P
rv
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
LE
SS
S
AB
_D AS
PA
NC ER
EN
YP
BY
SY RIV
P_
PE
IO n_P 1_B
A
2_
_W IG
N
EU
TY
F
_E
NC
ON
T_
AK
AD
NT
_P SY
IN
IO n_C
I
n_
n_
n_
n
GP INn
)
)
ed
ed
IN
IN
IN
IN
IN
I
P
_P
_P
_P
_P
rv
rv
O_
O_
se
se
IO
IO
IO
I
I
(re
(re
GP
GP
GP
GP
GP
GP
31 18 17 13 12 11 10 9 7 6 5 4 3 2 1 0
GPIO_PINn_SYNC2_BYPASS For the second stage synchronization, GPIO input data can be syn-
chronized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling
edge; 2 and 3: synchronized on rising edge. (R/W)
GPIO_PINn_PAD_DRIVER pin drive selection. 0: normal output; 1: open drain output. (R/W)
GPIO_PINn_SYNC1_BYPASS For the first stage synchronization, GPIO input data can be synchro-
nized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge;
2 and 3: synchronized on rising edge. (R/W)
GPIO_PINn_INT_TYPE Interrupt type selection. 0: GPIO interrupt disabled; 1: rising edge trigger; 2:
falling edge trigger; 3: any edge trigger; 4: low level trigger; 5: high level trigger. (R/W)
GPIO_PINn_WAKEUP_ENABLE GPIO wake-up enable bit, only wakes up the CPU from Light-sleep.
(R/W)
GPIO_PINn_INT_ENA Interrupt enable bits. bit13: CPU interrupt enabled; bit14: CPU non-maskable
interrupt enabled. (R/W)
XT
NE
T_
UP
RR
TE
IN
S_
TU
d)
TA
ve
_S
r
se
IO
(re
GP
31 26 25 0
0 0 0 0 0 0 0x00000 Reset
GPIO_STATUS_INTERRUPT_NEXT Interrupt source signal of GPIO0 ~ 21, could be rising edge in-
terrupt, falling edge interrupt, level sensitive interrupt and any edge interrupt. Bit0 ~ bit21 are
corresponding to GPIO0 ~ 21, and bit22 ~ bit25 are invalid. (RO)
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 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
GPIO_FUNCn_IN_SEL Selection control for peripheral input signal n, selects a pin from the 22 GPIO
matrix pins to connect this input signal. Or selects 0x1e for a constantly high input or 0x1f for a
constantly low input. (R/W)
GPIO_FUNCn_IN_INV_SEL Invert the input value. 1: invert enabled; 0: invert disabled. (R/W)
GPIO_SIGn_IN_SEL Bypass GPIO matrix. 1: route signals via GPIO matrix, 0: connect signals directly
to peripheral configured in IO MUX. (R/W)
UT EL EL
EL
_O _S _S
_S
EL
Cn EN INV
NV
_S
_I
UN n_O _
UT
_F C EN
IO UN _O
_O
GP _F Cn
Cn
)
IO UN
UN
ed
GP _F
_F
rv
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 Selection control for GPIO output n. If a value Y (0<=Y<128) is written to this
field, the peripheral output signal Y will be connected to GPIO output n. If a value 128 is written
to this field, bit n of GPIO_OUT_REG and GPIO_ENABLE_REG will be selected as the output value
and output enable. (R/W)
GPIO_FUNCn_OUT_INV_SEL 0: Do not invert the output value; 1: Invert the output value. (R/W)
GPIO_FUNCn_OEN_SEL 0: Use output enable signal from peripheral; 1: Force the output enable
signal to be sourced from bit n of GPIO_ENABLE_REG. (R/W)
GPIO_FUNCn_OEN_INV_SEL 0: Do not invert the output enable signal; 1: Invert the output enable
signal. (R/W)
EN
K_
)
ed
CL
rv
O_
se
I
(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
GPIO_CLK_EN Clock gating enable bit. If set to 1, the clock is free running. (R/W)
AT
ed
_D
rv
se
IO
(re
GP
31 28 27 0
0 0 0 0 0x2006130 Reset
2
T3
T1
UT
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 12 11 8 7 4 3 0
IO_MUX_CLK_OUTx If you want to output clock for I2S to CLK_OUT_outx, set IO_MUX_CLK_OUTx
to 0x0. CLK_OUT_outx can be found in Table 5-2. (R/W)
_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 Output enable of the pin in sleep mode. 1: output enabled; 0: output
disabled. (R/W)
IO_MUX_GPIOn_SLP_SEL Sleep mode selection of this pin. Set to 1 to put the pin in sleep mode.
(R/W)
IO_MUX_GPIOn_MCU_WPD Pull-down enable of the pin in sleep mode. 1: internal pull-down en-
abled; 0: internal pull-down disabled. (R/W)
IO_MUX_GPIOn_MCU_WPU Pull-up enable of the pin during sleep mode. 1: internal pull-up en-
abled; 0: internal pull-up disabled. (R/W)
IO_MUX_GPIOn_MCU_IE Input enable of the pin during sleep mode. 1: input enabled; 0: input
disabled. (R/W)
IO_MUX_GPIOn_FUN_WPU Pull-up enable of the pin. 1: internal pull-up enabled; 0: internal pull-up
disabled. (R/W)
IO_MUX_GPIOn_FUN_IE Input enable of the pin. 1: input enabled; 0: input disabled. (R/W)
IO_MUX_GPIOn_FUN_DRV Select the drive strength of the pin. 0: ~5 mA; 1: ~ 10 mA; 2: ~ 20 mA;
3: ~40mA. (R/W)
IO_MUX_GPIOn_MCU_SEL Select IO MUX function for this signal. 0: Select Function 0; 1: Select
Function 1; etc. (R/W)
IO_MUX_GPIOn_FILTER_EN Enable filter for pin input signals. 1: Filter enabled; 0: Filter disabled.
(R/W)
G
RE
E_
AT
_D
)
ed
UX
rv
se
_M
(re
IO
31 28 27 0
0 0 0 0 0x2006050 Reset
LE
CA
ES
PR
IN
n_
_
Dn
SD
)
_S
ed
D_
SD
rv
OS
se
IO
I
(re
GP
GP
31 16 15 8 7 0
GPIOSD_SDn_IN This field is used to configure the duty cycle of sigma delta modulation output.
(R/W)
GPIOSD_SDn_PRESCALE This field is used to set a divider value to divide APB clock. (R/W)
)
_C
ed
SD
rv
se
IO
(re
GP
31 30 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
GPIOSD_CLK_EN Clock enable bit of configuration registers for sigma delta modulation. (R/W)
EN
K_
CL
N_
CT P
IO
UN WA
_F _S
SD PI
d)
IO _S
ve
GP SD
r
se
IO
(re
GP
31 30 29 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
E
AT
_D
)
ed
SD
rv
se
IO
(re
GP
31 28 27 0
0 0 0 0 0x2006230 Reset
6.1 Reset
6.1.1 Overview
ESP32-C3 provides four types of reset that occur at different levels, namely CPU Reset, Core Reset, System
Reset, and Chip Reset. All reset types mentioned above (except Chip Reset) maintain the data stored in
internal memory. Figure 6-1 shows the scope of affected subsystems by each type of reset.
6.1.3 Features
• Support four reset levels:
– CPU Reset: Only 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 RTC, including CPU, peripherals, Wi-Fi,
Bluetooth® LE, and digital GPIOs.
– Software Reset: the CPU can trigger a software reset by configuring the corresponding registers,
see Chapter 9 Low-power Management.
Note:
If CPU is reset, PMS registers will be reset, too.
Table 6-1 lists possible reset sources and the types of reset they trigger.
6.2 Clock
6.2.1 Overview
ESP32-C3 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 6-2 shows the system clock structure.
6.2.3 Features
ESP32-C3 clocks can be classified in two types depending on their frequencies:
• High speed clocks for devices working at a higher frequency, such as CPU and digital peripherals
• Slow speed clocks for low-power devices, such as RTC module and low-power peripherals
– RC_FAST_CLK (17.5 MHz by default): internal fast RC oscillator with adjustable frequency
– RC_SLOW_CLK (136 kHz by default): internal low RC oscillator with adjustable frequency
As Figure 6-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 lower power
consumption. Users can set PLL_CLK, RC_FAST_CLK or XTAL_CLK as CPU_CLK clock source by configuring
register SYSTEM_SOC_CLK_SEL, see Table 6-2 and Table 6-3. By default, the CPU clock is sourced from
XTAL_CLK with a divider of 2, i.e. the CPU clock is 20 MHz.
SARADC Y
Temperature Y Y
Sensor
189
USB Y
CRYPTO Y
TWAI Controller Y
LEDC Y Y Y Y Y
SYS_TIMER Y Y
ESP32-C3 TRM (Version 1.1)
GoBack
6 Reset and Clock GoBack
APB_CLK
The frequency of APB_CLK is determined by the clock source of CPU_CLK as shown in Table 6-5.
CRYPTO_CLK
The frequency of CRYPTO_CLK is determined by the CPU_CLK source, as shown in Table 6-6.
PLL_F160M_CLK
LEDC_SCLK
LEDC module uses RC_FAST_CLK as clock source when APB_CLK is disabled. In other words, when the
system is in low-power mode, most peripherals will be halted (as APB_CLK is turned off), but LEDC can still
work normally via RC_FAST_CLK.
Wi-Fi and Bluetooth LE can only work 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.
LOW_POWER_CLK uses XTAL32K_CLK, XTAL_CLK, RC_FAST_CLK or RTC_SLOW_CLK (the low clock selected
by RTC) as its clock source for Wi-Fi and Bluetooth LE in low-power mode.
The clock sources for RTC_SLOW_CLK and RTC_FAST_CLK are low-frequency clocks. RTC module can
operate when most other clocks are stopped. RTC_SLOW_CLK derived from RC_SLOW_CLK, XTAL32K_CLK or
RC_FAST_DIV_CLK is used to clock Power Management module. RTC_FAST_CLK is used to clock On-chip
Sensor module. It can be sourced from a divided XTAL_CLK or from a divided RC_FAST_CLK.
7.1 Overview
ESP32-C3 has three strapping pins:
• GPIO2
• GPIO8
• GPIO9
These strapping pins are used to control the following functions during chip power-on or hardware
reset:
During power-on reset, RTC watchdog reset, brownout reset, analog super watchdog reset, and crystal clock
glitch detection reset (see Chapter 6 Reset and Clock), hardware 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 shut down. Software can read the latch status (strapping value) from GPIO_STRAPPING.
By default, GPIO9 is connected to the chip’s internal pull-up resistor. If GPIO9 is not connected or connected
to an external high-impedance circuit, the internal weak pull-up determines the default input level of this
strapping pin (see Table 7-1).
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-C3. After the reset is released, the
strapping pins work as normal-function pins.
Note:
The following section provides description of the chip functions and the pattern of the strapping pins values to in-
voke each function. Only documented patterns should be used. If some pattern is not documented, it may trigger
unexpected behavior.
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 Security 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 Security 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 (address: 0x42000000) are
0xaedb041d.
In Joint Download Boot mode, users can download binary files into flash using UART0 or USB interface. It is
also possible to download binary files into SRAM and execute it in this mode.
In SPI Download Boot mode, users can download binary files into flash using SPI interface. It is also possible
to download binary files into SRAM and execute it from SRAM.
• EFUSE_DIS_FORCE_DOWNLOAD
– If this eFuse is 0 (default), software can force switch the chip from SPI Boot mode to Joint
Download Boot mode by setting RTC_CNTL_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, Joint Download Boot mode is disabled. GPIO_STRAPPING will not be overwritten by
RTC_CNTL_FORCE_DOWNLOAD_BOOT.
• EFUSE_ENABLE_SECURITY_DOWNLOAD
If this eFuse is 1, Joint Download Boot mode only allows reading, writing, and erasing plaintext flash and
does not support any SRAM or register operations. Ignore this eFuse if Joint Download Boot mode is
disabled.
• EFUSE_DIS_DIRECT_BOOT
USB Serial/JTAG Controller can also force the chip into Joint Download Boot mode from SPI Boot mode, as
well as force the chip into SPI Boot mode from Joint Download Boot mode. For detailed information, please
refer to Chapter 30 USB Serial/JTAG Controller (USB_SERIAL_JTAG).
ROM code will print to pin U0TXD (default) or to USB Serial/JTAG Controller during power-on, depending on
the eFuse bit EFUSE_USB_PRINT_CHANNEL (0: USB; 1: UART). Note that if this eFuse bit is set to 0, i.e., USB
is selected, but USB Serial/JTAG Controller is disabled, then ROM code will not print.
8.1 Overview
The interrupt matrix embedded in ESP32-C3 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-C3 has 62 peripheral interrupt sources. To map them to 31 CPU interrupts, this interrupt matrix is
needed.
Note:
This chapter focuses on how to map peripheral interrupt sources to CPU interrupts. For more details about interrupt
configuration, vector, and ISA suggested operations, please refer to Chapter 1 ESP-RISC-V CPU.
8.2 Features
• Accept 62 peripheral interrupt sources as input
• Column “Configuration Register”: Registers used for routing the peripheral interrupt sources to CPU
peripheral interrupts
• Column “Status Register”: Registers used for indicating the interrupt status of peripheral interrupt
sources.
– Column “Status Register - Bit”: Bit position in status register, indicating the interrupt status.
Status Register
No. Chapter Source Configuration Register
Bit Name
0 reserved reserved reserved 0
1 reserved reserved reserved 1
2 reserved reserved reserved 2
3 reserved reserved reserved 3
4 reserved reserved reserved 4
5 reserved reserved reserved 5
6 reserved reserved reserved 6
7 reserved reserved reserved 7
8 reserved reserved reserved 8
9 reserved reserved reserved 9
10 reserved reserved reserved 10
Submit Documentation Feedback
GoBack
(RMT)
29 I2C Controller (I2C) I2C_EXT0_INTR INTERRUPT_CORE0_I2C_EXT0_INTR_MAP_REG 29
30 reserved reserved reserved 30
Espressif Systems
RUPT_CORE0_DMA_APBPERI_PMS_MONITOR_VIOLATE_INTR_MAP_REG
INTER-
56 Permission Control (PMS) PMS_IBUS_VIO_INTR 24
RUPT_CORE0_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_INTR_MAP_REG
INTER-
57 Permission Control (PMS) PMS_DBUS_VIO_INTR 25
RUPT_CORE0_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_INTR_MAP_REG
INTER-
58 Permission Control (PMS) PMS_PERI_VIO_INTR 26
RUPT_CORE0_CORE_0_PIF_PMS_MONITOR_VIOLATE_INTR_MAP_REG
GoBack
INTER-
59 Permission Control (PMS) PMS_PERI_VIO_SIZE_INTR 27
RUPT_CORE0_CORE_0_PIF_PMS_MONITOR_VIOLATE_SIZE_INTR_MAP_REG
60 reserved reserved reserved 28
8 Interrupt Matrix (INTERRUPT) GoBack
Status Register
Name
Bit
29
Configuration Register
reserved
reserved
Source
reserved
Chapter
No.
61
Espressif Systems 198 ESP32-C3 TRM (Version 1.1)
Submit Documentation Feedback
8 Interrupt Matrix (INTERRUPT) GoBack
Note:
For detailed information about how to configure CPU interrupts, see Chapter 1 ESP-RISC-V CPU.
• Source_X: stands for a peripheral interrupt source, wherein X means the number of this interrupt source
in Table 8-1.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
GoBack
INTERRUPT_CORE0_TG_T0_INT_MAP_REG TG_T0_INT mapping register 0x0080 R/W
INTERRUPT_CORE0_TG_WDT_INT_MAP_REG TG_WDT_INT mapping register 0x0084 R/W
Espressif Systems
GoBack
INTERRUPT_CORE0_CORE_0_PIF_PMS_MONITOR_VIOLATE_
PIF_PMS_MONITOR_VIOLATE mapping register 0x00E8 R/W
INTR_MAP_REG
Espressif Systems
GoBack
INTERRUPT_CORE0_CPU_INT_PRI_14_REG Priority configuration register for CPU interrupt 14 0x014C R/W
INTERRUPT_CORE0_CPU_INT_PRI_15_REG Priority configuration register for CPU interrupt 15 0x0150 R/W
Espressif Systems
GoBack
8 Interrupt Matrix (INTERRUPT) GoBack
8.5 Registers
The addresses in this section are relative to the interrupt matrix base address provided in Table 3-3 in Chapter
3 System and Memory.
AP
_M
_X
CE
UR
SO
0_
RE
CO
T_
)
UP
ed
RR
rv
se
TE
(re
IN
31 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
INTERRUPT_CORE0_SOURCE_X_MAP Map the interrupt source (SOURCE_X) into one CPU inter-
rupt. For the information of SOURCE_X, see Table 8-1. (R/W)
0
S_
TU
TA
_S
TR
IN
0_
RE
O
_C
PT
RU
R
TE
IN
31 0
0x000000 Reset
INTERRUPT_CORE0_INTR_STATUS_0 This register stores the status of the first 32 interrupt sources:
0 ~ 31. If the bit is 1 here, it means the corresponding source triggered an interrupt. (RO)
1
S_
U
AT
ST
R_
NT
I
0_
ORE
_C
PT
RU
R
TE
IN
31 0
0x000000 Reset
INTERRUPT_CORE0_INTR_STATUS_1 This register stores the status of the first 32 interrupt sources:
32 ~ 61. If the bit is 1 here, it means the corresponding source triggered an interrupt. (RO)
N
_E
K
CL
0_
RE
CO
T_
)
UP
ed
RR
rv
se
TE
(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 1 Reset
B LE
E NA
T_
IN
U_
CP
0_
RE
O
_C
PT
RU
T ER
IN
31 0
0 Reset
INTERRUPT_CORE0_CPU_INT_ENABLE Writing 1 to the bit here enables its corresponding CPU in-
terrupt. For more information about how to use this register, see Chapter 1 ESP-RISC-V CPU.
(R/W)
E
YP
_T
NT
_I
C PU
0_
RE
O
_C
PT
R RU
TE
IN
31 0
0 Reset
31 0
0 Reset
INTERRUPT_CORE0_CPU_INT_CLEAR Writing 1 to the bit here clears its corresponding CPU inter-
rupt. For more information about how to use this register, see Chapter 1 ESP-RISC-V CPU. (R/W)
US
AT
ST
P_
I
_E
NT
I
U_
CP
0_
RE
CO
T_
UP
RR
TE
IN
31 0
0 Reset
AP
M
n_
I_
PR
U_
CP
0_
RE
CO
T_
)
UP
ed
RR
rv
se
TE
(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
INTERRUPT_CORE0_CPU_PRI_n_MAP Set the priority for CPU interrupt n. The priority here can be
1 (lowest) ~ 15 (highest). For more information about how to use this register, see Chapter 1
ESP-RISC-V CPU. (R/W)
H
ES
R
TH
T_
IN
U_
CP
0_
O RE
_C
PT
d)
RU
ve
ER
r
se
T
(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
INTERRUPT_CORE0_CPU_INT_THRESH Set threshold for interrupt assertion to CPU. Only when the
interrupt priority is equal to or higher than this threshold, CPU will respond to this interrupt. For
more information about how to use this register, see Chapter 1 ESP-RISC-V CPU. (R/W)
E
AT
_D
PT
RU
ER
NT
I
0_
O RE
_C
PT
)
ed
RU
rv
R
se
TE
(re
IN
31 28 27 0
0 0 0 0 0x2007210 Reset
9 Low-power Management
9.1 Introduction
ESP32-C3 has an advanced Power Management Unit (PMU), which can flexibly power up different power
domains of the chip, to achieve the best balance among chip performance, power consumption, and wakeup
latency. To simplify power management for typical scenarios, ESP32-C3 has predefined four power modes,
which are preset configurations that power up different combinations of power domains. On top of that, the
chip also allows the users to independently power up any particular power domain to meet more complex
requirements.
9.2 Features
ESP32-C3’s low-power management supports the following features:
• Four predefined power modes to simplify power management for typical scenarios
• Up to 8 KB of retention memory
In this chapter, we first introduce the working process of ESP32-C3’s low-power management, then introduce
the predefined power modes of the chip, and at last, introduce the RTC boot of the chip.
• Power management unit: controls the power supply to Analog, RTC and Digital power domains.
• Power isolation unit: isolates different power domains, so any powered down power domain does not
affect the powered up ones.
• RTC timer: logs the status of the RTC main state machine in dedicated registers.
• 8 x 32-bit “always-on” retention registers: These registers are always powered up and are not affected by
any low-power modes, thus can be used for storing data that cannot be lost.
• 6 x “always-on” pins: These pins are always powered up and are not affected by any low-power modes,
which makes them suitable for working as wakeup sources when the chip is working in the low-power
modes (for details, please refer to Section 9.4.3), or can be used as regular GPIOs (for details, please
refer to Chapter 5 IO MUX and GPIO Matrix (GPIO, IO MUX)).
• RTC fast memory: 8 KB SRAM that works under CPU clock (CPU_CLK), which can be used as extended
memory.
ESP32-C3
Analog
VDD_SPI
xpd_rtc_reg
xpd_dig_reg CPU ROM
xpd_ex_crystal
PD Peripherals Internal SRAMx
xpd_rc_oscilator
Internal signal
Digital Core
Internal signal
xpd_cpu
Bluetooth LE Bluetooth LE
xpd_pd_peri
Link Controller Baseband
xpd_wireless
Power Management Wireless Mac and Baseband
Unit Fast Memory
Note:
• For more information about different power domains, please check Section 9.4.1.
• RTC main state machine: generates power gating, clock gating, and reset signals.
• Power controllers: power up and power down different power domains, according to the power gating
signals from the main state machine.
• Sleep / wakeup controllers: send sleep or wakeup requests to the RTC main state machine.
• Protection Timer: controls the transition interval between main state machine states.
In ESP32-C3’s power management unit, the sleep / wakeup controllers send sleep or wakeup requests to the
RTC main state machine, which then generates power gating, clock gating, and reset signals. Then, the power
controller and clock controller power up and power down different power domains and clock sources,
according to the signals generated by the RTC main state machine, so that the chip enters or exits the
low-power modes. The main workflow is shown in Figure 9-2.
Clock Protection
Controller
Power Controller …... Power Controller
Timer
done
state
main
state
state
main
main
state
main
wait
RTC Main State Machine
sleep accept
…...
sleep EN
Note:
1. Each power domain has its own power controller. For a complete list of all the available power controllers
controlling different power domains, please refer to Section 9.4.1.
2. For a complete list of all the available wakeup sources, please refer to Table 9-4.
ESP32-C3
Selection Signal
RC_SLOW_CLK
0
XTAL32K_CLK RTC_SLOW_CLK PMU
1 (Except RTC Registers)
RC_FAST_DIV_CLK 2
Selection Signal
RC_FAST_CLK
div n 1
Selection Signals
XTAL32K_CLK
RC_FAST_CLK
div n
LP_MUX
LOW_POWER_CLK
Wireless
RTC_SLOW_CLK
XTAL_CLK
Low-power Clock
When working under low-power modes, ESP32-C3’s XTAL_CLK and PLL are usually powered down to reduce
power consumption. However, the low-power clock remains on so the chip can operate properly under
low-power modes. For more detailed description about clocks, please refer to 6 Reset and Clock.
9.3.3 Timers
ESP32-C3’s low-power management uses RTC timer. The readable 48-bit RTC timer is a real-time counter
(using RTC slow clock) that can be configured to log the time when one of the following events happens. For
details, see Table 9-2.
The RTC timer updates two groups of registers upon any new trigger. The first group logs the time of the
current trigger, and the other logs the previous trigger. Detailed information about these two register groups is
shown below:
• Register group 0: logs the status of RTC timer at the current trigger.
– RTC_CNTL_TIME_HIGH0_REG
– RTC_CNTL_TIME_LOW0_REG
• Register group 1: logs the status of RTC timer at the previous trigger.
– RTC_CNTL_TIME_HIGH1_REG
– RTC_CNTL_TIME_LOW1_REG
On a new trigger, information on previous trigger is moved from register group 0 to register group 1 (and the
original trigger logged in register group 1 is overwritten), and this new trigger is logged in register group 0.
Therefore, only the last two triggers can be logged at any time.
It should be noted that any reset / sleep other than power-up reset will not stop or reset the RTC timer.
Also, the RTC timer can be used as a wakeup source. For details, see Section 9.4.3.
Note:
For more detailed description about power domains, please refer to Section 9.4.1.
ESP32-C3’s built-in digital system voltage regulator converts the external power supply (typically 3.3 V) to 1.1 V
for digital power domains. This regulator is controlled by the xpd_dig_reg signal. For details, see description
in 9-1. For the architecture of the ESP32-C3 digital system voltage regulator, see Figure 9-5.
ESP32-C3’s built-in low-power voltage regulator converts the external power supply (typically 3.3 V) to 1.1 V for
RTC power domains. Note when the pin CHIP_PU is at a high level, the low-power voltage regulator cannot be
turned off. Otherwise, the low power voltage regulator is off when chip enters Light-sleep and Deep-sleep
modes. In this case, the RTC domain is powered by an ultra low-power internal power source.
For the architecture of the ESP32-C3 low-power voltage regulator, see Figure 9-6.
The brownout detector checks the voltage of pins VDD3P3_RTC, VDD3P3_CPU, VDDA1, and VDDA2. If the
voltage of these pins drops below the predefined threshold (2.7 V by default), the detector would trigger a
signal to shut down some power-consuming blocks (such as LNA, PA, etc.) to allow extra time for the digital
system to save and transfer important data.
RTC_CNTL_BROWN_OUT_DET indicates the output level of brown-out detector. This register is low level by
default, and outputs high level when the voltage of the detected pin drops below the predefined
threshold.
RTC_CNTL_BROWN_OUT_RST_SEL configures the reset type. For more information regarding chip reset and
system reset, please refer to 6 Reset and Clock.
The brownout detector has ultra-low power consumption and remains enabled whenever the chip is powered
up. For the architecture of the ESP32-C3 brownout detector, see Figure 9-7.
• RTC
– Power management unit (PMU), including RTC timer, fast memory, Always-on registers
• Digital
– PD peripherals, including SPI2, GDMA, SHA, RSA, AES, HMAC, DS, Secure Boot
– Digital system
– CPU
• Analog
– RC_FAST_CLK
– XTAL_CLK
– PLL
– RF circuits
Power Domain
PD Digital Wireless FOSC_ XTAL_ RF
Power Mode PMU CPU PLL
Peripherals System Digital Circuits CLK CLK Circuits
Active ON ON ON ON ON ON ON ON ON
Modem-sleep ON ON ON ON* ON ON ON ON OFF
Light-sleep ON ON ON OFF* OFF* OFF* OFF OFF OFF
Deep-sleep ON OFF OFF OFF OFF OFF OFF OFF OFF
* Configurable
By default, ESP32-C3 first enters the Active mode after system resets, then enters different low-power modes
(including Modem-sleep, Light-sleep, and Deep-sleep) to save power after the CPU stalls for a specific time
(For example, when CPU is waiting to be wakened up by an external event). From modes Active to
Deep-sleep, the number of available functionalities 1 and power consumption2 decreases and wakeup latency
increases. Also, the supported wakeup sources for different power modes are different3 . Users can choose a
power mode based on their requirements of functionality, power consumption, wakeup latency, and available
wakeup sources.
Note:
2. For details on power consumption, please refer to the Current Consumption Characteristics in ESP32-C3 Datasheet.
3. For details on the supported wakeup sources, please refer to Section 9.4.3.
All the wakeup sources specified in Table 9-4 (except UART) can also be configured as the causes to reject
sleep.
Users can configure the reject to sleep option via the following registers.
• Configure the RTC_CNTL_SLEEP_REJECT_ENA field to enable or disable the option to reject to sleep:
ESP32-C3’s retention module stores CPU information to the Internal SRAM Block9 to Block12 before CPU
enters into sleep, and restore such information from Internal SRAM to CPU after CPU wakes up from sleep,
thus enabling the CPU to resume execution from the previous breakpoint.
• Retention DMA operates 128-bit wide data, and only supports address alignment of four words.
• Retention DMA’s link list is specifically designed that it can be used to execute both write and read
transactions. The configuration of Retention DMA is similar to that of GDMA:
1. First allocate enough memory in SRAM before CPU enters sleep to store 432 words*: CPU registers
(428 words) and configuration information (4 words).
2. Then configure the link list according to the memory allocated in the first step. See details in
Chapter 2 GDMA Controller (GDMA).
Note:
* Note that if the memory allocated is smaller than 432 words, then chip can only enter the Light_sleep mode
and cannot further power down CPU.
After configuration, users can enable the Retention function by configuring the RTC_CNTL_RETENTION_EN
field in Register RTC_CNTL_RETENTION_CTRL_REG to:
• Use Retention DMA to store CPU information before the chip enters sleep
• Restore information from Retention DMA to CPU after CPU wakes up.
1. Set RTC_CNTL_STAT_VECTOR_SEL_PROCPU to 1.
2. Calculate CRC for the RTC fast memory, and save the result in RTC_CNTL_STORE7_REG[31:0].
5. SPI boot and some of the initialization starts after the CPU is powered up. After that, calculate the CRC
for the RTC fast memory again. If the result matches with register RTC_CNTL_STORE7_REG[31:0], the
CPU jumps to the entry address.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
9.8 Registers
The addresses in this section are relative to low-power management base address provided in Table 3-3 in
Chapter 3 System and Memory.
RS T
E_ RS
C0
RT ed) W_ C_ RC CE_ U
PR FO E_ PD
T
RC NO
rv _S I2 FO R P
U_
se TL B_ C_ FO E_
OC RC PU
_R D
FO E_
C T B _I CE U
C T B _I F D
CP
PU E_P
(re _CN L_B _I2 2C_ ORC
ST
RT _CN L_B PLL OR _P
RT _CN L_B PLL 2C_ _P
P_ RC
RO
C T B _F CE
C T B OR _P
C_ TL BP _F _P
RA O
G_ RA T
_P
W P_F
_D W RS
RT _CN L_B _F CE
LL
TL G_ S_
C T TL OR
TA
CN _D SY
RT CN _X _F
_S
C_ TL W_
C_ TL TL
W
RT CN _S
_S
RT _CN L_X
C_ TL
TL
)
)
ed
ed
C T
RT _CN
RT _CN
CN
rv
rv
se
se
C_
C
C
(re
(re
RT
RT
31 30 29 28 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_DG_WRAP_FORCE_RST Set this bit to force reset the digital system in deep-sleep.
(R/W)
RTC_CNTL_DG_WRAP_FORCE_NORST Set this bit to disable force reset to digital system in deep-
sleep. (R/W)
RTC_CNTL_SW_SYS_RST Set this bit to reset the system via SW. (WO)
LO
L_
VA
P_
SL
L_
C NT
C_
RT
31 0
0x000000 Reset
RTC_CNTL_SLP_VAL_LO Sets the lower 32 bits of the trigger threshold for the RTC timer. (R/W)
N
_E
RM
LA
_A
ER
HI
M
L_
TI
VA
N_
P_
AI
SL
M
L_
L_
)
ed
NT
NT
rv
C
se
C_
C_
(re
RT
RT
31 17 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
RTC_CNTL_SLP_VAL_HI Sets the higher 16 bits of the trigger threshold for the RTC timer. (R/W)
TA
_S _O
TE
IM _X R
_S
_T ER S_
DA
TL IM SY
UP
_
E_
CN _T ER
C d IM
C_ TL IM
RT rve L_T
RT CN _T
C_ TL
RT _CN )
)
ed
se T
(re _CN
rv
se
C
(re
RT
31 30 29 28 27 26 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_TIMER_SYS_STALL Selects the triggering condition for the RTC timer. (R/W)
RTC_CNTL_TIMER_XTL_OFF Selects the triggering condition for the RTC timer. (R/W)
RTC_CNTL_TIMER_SYS_RST Selects the triggering condition for the RTC timer. (R/W)
RTC_CNTL_TIME_UPDATE Selects the triggering condition for the RTC timer. (WO)
WO
_L
E0
LU
A
_V
ER
M
TI
T L_
CN
C_
RT
31 0
0x000000 Reset
H
IG
_H
E0
LU
A
_V
ER
M
TI
L_
)
ed
NT
rv
C
se
C_
(re
RT
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
LR
L
_C
SE
SE
E_
NT U
DG
_I CA
RI
PU T_
P
AK T
B
EU
_W EC
_C EC
C_
_S _R N
TL LP _E
LP EJ
W EJ
RT
CN _S EP
_S _R
B2
TL LP
C_ TL LE
AP
RT _CN L_S
CN _S
L_
C_ TL
)
)
ed
ed
C T
T
RT _CN
CN
RT _CN
rv
rv
se
se
C_
C
C
(re
(re
RT
RT
RT
31 30 29 27 23 22 21 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
AI
N
T
_W
_E
AI
AI
W
LL
LL
F_
F_
AI
A
_W
BU
BU
ST
ST
SC
U_
U_
L_
L_
FO
CP
CP
PL
XT
L_
L_
L_
L_
L_
NT
NT
NT
NT
NT
C
C
C_
C_
C_
C_
C_
RT
RT
RT
RT
RT
31 24 23 14 13 6 5 1 0
40 80 0x10 1 1 Reset
RTC_CNTL_CPU_STALL_WAIT Sets the CPU stall waiting cycles (using the RTC fast clock). (R/W)
RTC_CNTL_FOSC_WAIT Sets the FOSC clock waiting cycles (using the RTC slow clock). (R/W)
RTC_CNTL_XTL_BUF_WAIT Sets the XTAL waiting cycles (using the RTC slow clock). (R/W)
RTC_CNTL_PLL_BUF_WAIT Sets the PLL waiting cycles (using the RTC slow clock). (R/W)
F
OF
S C_
FO
E_
MI
_T
IN
M
L_
)
ed
NT
rv
C
se
C_
(re
RT
31 24 23 0
0x1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_MIN_TIME_FOSC_OFF Sets the minimal cycles for FOSC clock (using the RTC slow
clock) when powered down. (R/W)
AL
_V
LP
_S
IN
M
L_
)
)
ed
ed
NT
rv
rv
C
se
se
C_
(re
(re
RT
31 16 15 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x80 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_MIN_SLP_VAL Sets the minimal sleep cycles (using the RTC slow clock). (R/W)
CE U
D
OR _P
_P
_F CE
OR OR
PU U
ET OR N
U
C_ P
ES _P T_E
_P _F
_P
I2 S_
U
EN PU
2C
_R ET S
_P
F_ U
TL ES _R
C_ d) KG C_
se d) XR PB
_I
2C
H
RT rve L_C _I2
(re rve _T _
_I
CN _R C
X
T
se TL FR
C_ d) AR
se T LL
C_ TL LI
RT N _G
(re CN _P
RT rve L_S
C_ TL
C_ TL
se d)
se d)
(re _CN )
)
C d
ed
C T
se T
(re rve
(re ve
RT rve
RT _CN
RT CN
RT CN
rv
C
r
se
C
(re
RT
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 0
0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_RESET_POR_FORCE_PD Set this bit to force not bypass I2C power-on reset. (R/W)
RTC_CNTL_RESET_POR_FORCE_PU Set this bit to force bypass I2C power-on reset. (R/W)
RTC_CNTL_GLITCH_RST_EN Set this bit to enable reset when the system detects a glitch. (R/W)
U
CP
CP
CP
RO
RO
U
RO
U
ET CP
CP
_P
_P CP
_P
_P
PU
ES O
U
LR
RO
EL RO
LR
_R PR
CP
OC
_C
_C
_S _P
_
RO
AG
ON G
PR
AG
OR G
T_ LA
_P
A
FL
K_
FL
CT FL
AL T_F
SE
T_
AS
VE T_
ET
U
SE
_H SE
M
) AT_ SE
CA
ES
T_
RE
se d) CD E
ed T E
R
T_
RT rve ) ESE
_R
rv _S _R
G_
SE
C_ d) LL
se TL LL
C_ d) TA
se T TA
se d R
RE
(re rve L_D
RT rve _A
(re CN _J
L_
se TL
C_ TL
se TL
)
(re _CN )
C_ d)
)
ed
C d
ed
se T
C T
T
RT rve
(re _CN
RT CN
(re CN
RT CN
CN
rv
rv
se
se
C_
C
(re
(re
RT
RT
31 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 Reset
RTC_CNTL_OCD_HALT_ON_RESET_PROCPU Set this bit to send CPU into halt state upon CPU re-
set. (R/W)
)
ed
CN
rv
C_
se
(re
RT
31 15 14 0
12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_WAKEUP_ENA Selects the wakeup source. For details, please refer to Table 9-4. (R/W)
A
EN
A
IN NA
NA
IN NA
NT A
EN
EN
T_
_I EN
T_ _E
_E
P_ _E
NA IN
T_
T_
ET T_
OU INT
EU INT
_E D_
_D _IN
NT A
N_ _
NA
AK T_
_I DE
W ER
d) TCH AL
_W EC
_E
_
RO TIM
LI _C
W 2K
NT
LP EJ
_B IN_
_G LL
_S _R
_S 3
_I
L
D
C_ d) DT
(re NTL BP
TL LP
TL TA
TL A
CN _M
RT rve L_W
C _B
CN _S
CN _X
C_ TL
C_ TL
C_ TL
C_ TL
)
)
ed
ed
ed
se T
e
RT _CN
RT _CN
RT CN
(re CN
RT CN
rv
rv
rv
rv
se
se
se
se
C_
C_
C
C
(re
(re
(re
RT
RT
RT
RT
31 21 20 19 18 17 16 15 14 11 10 9 8 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
W
RA
W
IN AW
AW
IN AW
NT W
RA
RA
T_
_ I RA
T_ _R
_R
P_ _R
AW IN
T_
T_
ET T_
OU INT
EU INT
_R D_
_D _IN
W
NT A
N_ _
AK T_
_I DE
W ER
RA
d) TCH AL
_W EC
_
RO TIM
T_
LI _C
W 2K
LP J E
IN
_B IN_
_G LL
_S _R
_S 3
T_
L
D
(re NTL BP
TL LP
TL TA
TL A
C_ d) D
CN _M
RT rve L_W
C _B
CN _S
CN _X
C_ TL
C_ TL
C_ TL
C_ TL
d)
)
ed
ed
se T
ve
e
RT _CN
RT _CN
RT CN
(re CN
RT CN
rv
rv
rv
r
se
se
se
se
C_
C_
C
C
(re
(re
(re
RT
RT
RT
RT
31 21 20 19 18 17 16 15 14 11 10 9 8 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_SLP_WAKEUP_INT_RAW Stores the raw interrupt triggered when the chip wakes up from
sleep. (RO)
RTC_CNTL_SLP_REJECT_INT_RAW Stores the raw interrupt triggered when the chip rejects to go
to sleep. (RO)
RTC_CNTL_BBPLL_CAL_INT_RAW Stores the raw interrupt upon the ending of a bb_pll call. (RO)
ST
T_
ST
ST
IN T
T
IN T
_I ST
T_ _S
_S
P_ _S
T IN
T_
T_
ET T_
OU INT
NT
EU INT
_S D_
_D _IN
NT A
N_ _
AK T_
_I DE
W ER
ST
d) TCH AL
_W EC
_
RO TIM
T_
LI _C
W 2K
LP EJ
IN
_B IN_
_G LL
_S _R
_S 3
T_
L
D
(re NTL BP
TL LP
TL TA
TL A
C_ d) D
CN _M
RT rve L_W
C _B
CN _S
CN _X
C_ TL
C_ TL
C_ TL
C_ TL
d)
)
ed
ed
se T
ve
e
RT _CN
RT _CN
RT CN
(re CN
RT CN
rv
rv
rv
r
se
se
se
se
C_
C_
C
C
(re
(re
(re
RT
RT
RT
RT
31 21 20 19 18 17 16 15 14 11 10 9 8 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_SLP_WAKEUP_INT_ST Stores the status of the interrupt triggered when the chip wakes
up from sleep. (RO)
RTC_CNTL_SLP_REJECT_INT_ST Stores the status of the interrupt triggered when the chip rejects
to go to sleep. (RO)
RTC_CNTL_MAIN_TIMER_INT_ST Stores the status of the RTC main timer interrupt. (RO)
RTC_CNTL_XTAL32K_DEAD_INT_ST Stores the status of the interrupt triggered when the XTAL32K
is dead. (RO)
RTC_CNTL_GLITCH_DET_INT_ST Stores the status of the interrupt triggered when a glitch is de-
tected. (RO)
RTC_CNTL_BBPLL_CAL_INT_ST Stores the status of the interrupt triggered upon the ending of a
bbpll call. (RO)
R
CL
R
IN LR
LR
IN LR
NT R
T_
CL
CL
_ I CL
T_ _C
_C
P_ _C
LR I N
T_
T_
ET T_
OU INT
EU INT
_C D_
_D _IN
NT A
N_ _
AK T_
_I DE
W ER
CL
d) TCH AL
_W EC
_
RO TIM
T_
LI _C
W 2K
LP J E
IN
_B IN_
_G LL
_S _R
_S 3
T_
L
D
(re NTL BP
TL LP
TL TA
TL A
C_ d) D
CN _M
RT rve L_W
C _B
CN _S
CN _X
C_ TL
C_ TL
C_ TL
C_ TL
)
)
ed
ed
ed
se T
e
RT _CN
RT _CN
RT CN
(re CN
RT CN
rv
rv
rv
rv
se
se
se
se
C_
C_
C
C
(re
(re
(re
RT
RT
RT
RT
31 21 20 19 18 17 16 15 14 11 10 9 8 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_SLP_WAKEUP_INT_CLR Clears the interrupt triggered when the chip wakes up from
sleep. (WO)
RTC_CNTL_BBPLL_CAL_INT_CLR Clears the interrupt triggered upon the ending of a bbpll call.
(WO)
31 0
0 Reset
1H
TC
RA
SC
L_
CNT
C_
RT
31 0
0 Reset
2H
TC
RA
SC
L_
CNT
C_
RT
31 0
0 Reset
31 0
0 Reset
TL TA 2K XT_ BAC RT
TA 2K DT K_ UP
C_ TL TA 2K T E N
RT _CN L_X L3 _AU O_R TUR
N O
CN _X L3 _E O_ STA
L3 _W _R FO
_X L3 _W CL K
RT _CN L_X L3 _AU O_R CE
_W _C ET
_E _F
RT _CN L_X L3 _AU _FO K
L
C T TA 2K T R
C T TA 2K T E
2K DT ES
C T TA 2K D 2
DT LK
SE
RT _CN L_X L3 _X 2K
K
O_
32
_3
32
C T TA NIT _3
32
C T TA 2K TA
PI
L_
L_
L_
AL
RT CN _X KI AL
_G
TE
TA
XT
C_ TL NC XT
TA
TA
TA
2K
_X
_
RT CN _E F_
S
_X
_X
L3
S
_
GM
C_ TL BU
DT
AC
RE
PD
TA
_W
_D
_D
_D
RT _CN L_D
_X
_X
TL
TL
TL
TL
TL
TL
se d)
)
ed
ed
C T
(re rve
CN
CN
CN
CN
CN
CN
RT CN
rv
rv
se
se
C_
C_
C_
C_
C_
C_
C_
(re
(re
RT
RT
RT
RT
RT
RT
RT
31 30 29 24 23 22 20 19 17 16 15 13 12 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0x0 3 0 3 3 0 0 1 0 0 0 0 0 0 0 Reset
RTC_CNTL_XTAL32K_WDT_CLK_FO Set this bit to FPU the XTAL32K watchdog clock. (R/W)
RTC_CNTL_XTAL32K_WDT_RESET Set this bit to reset the XTAL32K watchdog by SW. (R/W)
RTC_CNTL_XTAL32K_EXT_CLK_FO Set this bit to FPU the external clock of XTAL32K. (R/W)
RTC_CNTL_XTAL32K_AUTO_BACKUP Set this bit to switch to the backup clock when the XTAL32K
is dead. (R/W)
RTC_CNTL_XTAL32K_AUTO_RESTART Set this bit to restart the XTAL32K automatically when the
XTAL32K is dead. (R/W)
RTC_CNTL_XTAL32K_AUTO_RETURN Set this bit to switch back to XTAL32K when the XTAL32K is
restarted. (R/W)
RTC_CNTL_XTAL32K_XPD_FORCE Set this bit to allow the software to FPD the XTAL32K; Reset this
bit to allow the FSM to FPD the XTAL32K. (R/W)
RTC_CNTL_ENCKINIT_XTAL_32K Set this bit to apply an internal clock to help the XTAL32K to start.
(R/W)
RTC_CNTL_XTAL32K_GPIO_SEL Set this bit to select the XTAL32K. Clear this bit to select external
XTAL32K. (R/W)
E R
LT
FI
P_
EU
AK
_W
IO
GP
L_
d)
NT
ve
C
r
se
C_
(re
RT
31 30 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_GPIO_WAKEUP_FILTER Set this bit to enable the GPIO wakeup event filter. (R/W)
A
EN
_R C
LP EJE
T_
EC
_S R
HT P_
EJ
IG SL
R
P_
_L P_
EE
TL EE
SL
CN _D
L_
C_ TL
)
ed
NT
RT _CN
rv
C
se
C_
C
(re
RT
RT
31 30 29 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
IN G
AT IN
TI NG
G
_G AT
GA ATI
NG
RC PU CE OG
E_ G
GA ING
FO E_ OR _N
NG
RC NO
C_ RC _F CE
NO AT
TI
FO E_
_ C EN N
TL OS GL AL_ EL
CL FO D
EL
E_ OG
K_ RC
E_ K_ VL
PD
CN _F L_ B _S
_S
_ _ 3 56
_F C_ OB F
RC _N
) US CL L_
C V
C_ TL TA GL TC
E_
EL
TC
RT NTL NB TAL D2
C_ TL IG S EN
ed F _ SE
Q
FO CE
RT CN _X _ _R
S
C T AS K_R
RE
rv _E SE V_
L_ R
O
C T OS IV
C_ TL TA LK
TA FO
DF
C T IG S
DI
se TL FU DI
D
L
C_
_X C_
C_
C_ TL SC_
OS
TL OS
C T IG
N
FO
O
RT CN _D
_A
RT CN _F
_F
CN _F
RT CN _F
_
RT NTL
TL
C_ TL
TL
C_ TL
C_ d)
T
RT rve
RT _CN
CN
RT CN
CN
RT CN
RT CN
C
se
C_
C_
C_
C_
C_
C
(re
RT
RT
RT
RT
RT
31 30 29 28 27 26 25 24 17 16 15 14 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 0 172 0 0 3 0 0 1 0 0 0 1 1 0 0 0 Reset
RTC_CNTL_EFUSE_CLK_FORCE_GATING Set this bit to FPU the eFuse clock gating. (R/W)
RTC_CNTL_EFUSE_CLK_FORCE_NOGATING Set this bit to FPD the eFuse clock gating. (R/W)
RTC_CNTL_FOSC_DIV Set the FOSC_D256_OUT divider. 00: divided by 128, 01: divided by 256,
10: divided by 512, 11: divided by 1024. (R/W)
RTC_CNTL_DIG_XTAL32K_EN Set this bit to enable CK_XTAL_32K clock for the digital system.
(R/W)
RTC_CNTL_DIG_FOSC_D256_EN Set this bit to enable FOSC_D256_OUT clock for the digital sys-
tem. (R/W)
RTC_CNTL_DIG_FOSC_EN Set this bit to enable FOSC for the digital system. (R/W)
RTC_CNTL_XTAL_FORCE_NOGATING Set this bit to force no gating to crystal during sleep. (R/W)
RTC_CNTL_FOSC_FORCE_NOGATING Set this bit to disable force gating to crystal during sleep.
(R/W)
RTC_CNTL_XTAL_GLOBAL_FORCE_GATING Set this bit to force enable XTAL clock gating. (R/W)
RTC_CNTL_XTAL_GLOBAL_FORCE_NOGATING Set this bit to force bypass the XTAL clock gating.
(R/W)
DI
K_
K_
CL
CL
A_
A_
AN
AN
L_
L_
)
)
ed
ed
NT
NT
rv
rv
C
C
se
C_
se
C_
(re
(re
RT
RT
31 30 23 22 21 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
CE U
D
OR _P
_P
_F CE
EN
OR OR
L_
AT _F
A
UL OR
_C
AP
se d) EG AT
EG
DC
(re rve L_R UL
R
K_
G_
se T EG
SC
DI
(re _CN L_R
L_
L_
)
d)
)
ed
ed
ed
C T
T
ve
RT _CN
CN
CN
rv
rv
rv
r
se
C_
se
se
C_
C
(re
(re
(re
RT
RT
RT
31 30 29 28 27 22 21 14 13 8 7 6 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
RTC_CNTL_DIG_REG_CAL_EN Set this bit to enable digital regulator calibration by software. (R/W)
RTC_CNTL_REGULATOR_FORCE_PD Set this bit to FPD the low-power voltage regulator, which
means decreasing its voltage to 0.8 V or lower. (R/W)
RTC_CNTL_REGULATOR_FORCE_PU Set this bit to FPU the low-power voltage regulator, which
means increasing its voltage to higher than 0.8 V. (R/W)
)
ed
ed
NT
rv
rv
C
se
C_
se
(re
(re
RT
31 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
RTC_CNTL_PAD_FORCE_HOLD Set this bit to force RTC pad into hold state. (R/W)
_S WR CE U
_P FO PD
PE _F C PU
OR _P D
R_ CE
DD I_P OR _P
_F CE LP
RT _CN L_F I_F CE RCE U
RT _CN L_F TM CE U D
RT _CN L_W _WR P_F CE U
RT _CN L_W I_F P_F RCE D
CE U
D
_ _
se d) G_ RI OR _L
C T IF OR O _P
C T AS OR _P _P
C T G A OR _P
C T IF A O _P
V
R
_P
RI OR E_
P _F CE
DR
(re rve L_D _PE _F RCE
rv _D _T EN EN
PD N
_S M OR
(re _CN L_D TM _F D
I_ _E
_E
se TL PU D_ D_
C T AS EM _P
C T G OP OR
se T G EM O
DD ME _F
ER PD
W
(re CN _C I_P P_P
RT _CN L_D _T _F
_V P_ M
) _P P_
C T PU OP
RT NTL SL ME
C_ TL IF A
PI
ed G O
RT _CN L_W _WR
RT CN _C _T
C _L P_
C_ TL PU
C_ TL SL
C T G
RT CN _D
RT _CN L_C
RT _CN L_L
_V
C_ TL
TL
)
)
ed
ed
ed
C T
C T
RT _CN
RT _CN
RT _CN
CN
rv
rv
rv
se
se
C_
C
C
(re
(re
RT
RT
RT
31 30 29 28 27 26 23 22 21 20 19 18 17 16 15 14 13 12 11 10 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 Reset
RTC_CNTL_VDD_SPI_PWR_FORCE Set this bit to allow software to configure vdd_spi’s drive inten-
sity. (R/W)
RTC_CNTL_LSLP_MEM_FORCE_PD Set this bit to force the memories in the digital system not to
enter retention mode in sleep. (R/W)
RTC_CNTL_LSLP_MEM_FORCE_PU Set this bit to force the memories in the digital system into
retention mode in sleep. (R/W)
RTC_CNTL_FASTMEM_FORCE_LPD Set this bit to force the fast memory not to enter retention
mode in sleep. (R/W)
RTC_CNTL_FASTMEM_FORCE_LPU Set this bit to force the fast memory into retention mode in
sleep. (R/W)
RTC_CNTL_DG_PERI_PD_EN Set this bit to enable FPD digital peripherals in sleep. (R/W)
RTC_CNTL_DG_WRAP_PD_EN Set this bit to enable FPD digital system in sleep. (R/W)
TL LR D_ RC IS LD
LD LD
C_ TL PU OR _N _I SO
RI OR _IS O
_I ISO
TO TO N
D_ D_ LD O
CN _C PA FO E_ HO
PE _F CE OIS
HO HO
AU AU _E
RT _CN L_C I_F CE RCE OI
PA PA HO IS
RT CN _C _T CE OI SO
_F CE O
SO
CE O
_D _D AU E_ O
G_ G_ TO NO
C T G D_ RC HO
C T IF OR O _N
C_ TL G_ D_ RC UN
se d) G_ RI OR _N
C T PU OP _I SO
OR _N
RT _CN L_W I_F P_F RCE
RT CN _D PA FO E_
(re rve L_D _PE _F CE
(re _CN L_D _T _F SO
C_ TL G_ D_ RC
se T G OP OR
C T IF A O
RT CN _W WR P_F
C T G
RT _CN L_D
RT CN _D
C_ TL
)
)
ed
ed
ed
C T
RT _CN
RT _CN
rv
rv
rv
se
se
C
C
(re
(re
RT
RT
31 30 29 28 27 26 25 24 23 22 21 16 15 14 13 12 11 10 9 8 0
1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_CLR_DG_PAD_AUTOHOLD Set this bit to clear the auto-hold enabler for the digital
GPIOs. (WO)
RTC_CNTL_DG_PAD_AUTOHOLD_EN Set this bit to allow the digital GPIOs to enter the auto-hold
status. (R/W)
RTC_CNTL_DG_PAD_FORCE_NOISO Set this bit to disable the force isolation of the digital GPIOs.
(R/W)
RTC_CNTL_DG_PAD_FORCE_ISO Set this bit to force isolation of the digital GPIOs. (R/W)
RTC_CNTL_DG_PAD_FORCE_UNHOLD Set this bit the force unhold the digital GPIOs. (R/W)
RTC_CNTL_DG_PAD_FORCE_HOLD Set this bit the force hold the digital GPIOs. (R/W)
RTC_CNTL_DG_PERI_FORCE_ISO Set this bit to force isolation of the digital peripherals. (R/W)
RTC_CNTL_DG_PERI_FORCE_NOISO Set this bit to disable the force isolation of the digital periph-
erals. (R/W)
RTC_CNTL_WIFI_FORCE_ISO Set this bit to force isolation of the wireless circuits. (R/W)
RTC_CNTL_WIFI_FORCE_NOISO Set this bit to disable the force isolation of the wireless circuits.
(R/W)
RTC_CNTL_DG_WRAP_FORCE_ISO Set this bit to force isolation of the digital system. (R/W)
RTC_CNTL_DG_WRAP_FORCE_NOISO Set this bit to disable the force isolation of the digital system.
(R/W)
T_ N
H
TH
SE _E
EN
GT
RE OD
NG
EN
LP
U_ M
LE
_L
T_
T_
_S
ET
OC OO
SE
N
ES
_I
B
E
P
_R
SE
_P SH
_R
0
3
1
PU
AU
TG
TG
TG
TG
YS
C_ d) DT LA
N
R
_C
_P
_S
_S
_S
_S
S
_E
RT rve _W _F
_
DT
DT
DT
DT
DT
DT
DT
se TL DT
DT
W
_W
_W
_W
_W
_W
_W
(re CN _W
_W
L_
TL
TL
TL
TL
TL
TL
C_ TL
TL
)
ed
NT
CN
CN
CN
CN
CN
CN
RT N
CN
rv
C
se
C_
C_
C_
C_
C_
C_
C_
C_
(re
RT
RT
RT
RT
RT
RT
RT
RT
31 30 28 27 25 24 22 21 19 18 16 15 13 12 11 10 9 8 0
RTC_CNTL_WDT_FLASHBOOT_MOD_EN Set this bit to enable watchdog when the chip boots from
flash. (R/W)
RTC_CNTL_WDT_STG3 1: enable at the interrupt stage, 2: enable at the CPU stage, 3: enable at
the system stage, 4: enable at the system and RTC stage. (R/W)
RTC_CNTL_WDT_STG2 1: enable at the interrupt stage, 2: enable at the CPU stage, 3: enable at
the system stage, 4: enable at the system and RTC stage. (R/W)
RTC_CNTL_WDT_STG1 1: enable at the interrupt stage, 2: enable at the CPU stage, 3: enable at
the system stage, 4: enable at the system and RTC stage. (R/W)
RTC_CNTL_WDT_STG0 1: enable at the interrupt stage, 2: enable at the CPU stage, 3: enable at
the system stage, 4: enable at the system and RTC stage. (R/W)
31 0
200000 Reset
D
OL
H
1_
TG
_S
DT
W
L_
C NT
C_
RT
31 0
80000 Reset
LD
HO
2_
TG
_S
DT
W
L_
C NT
C_
RT
31 0
0x000fff Reset
31 0
0x000fff Reset
D
EE
_F
DT
L_W
)
ed
NT
rv
C
se
C_
(re
RT
31 30 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Y
KE
_W
DT
W
L_
C NT
C_
RT
31 0
0x000000 Reset
RTC_CNTL_WDT_WKEY If the register contains a different value than 0x50d83aa1, write protection
for the RTC watchdog (RWDT) is enabled. (R/W)
LR
TH
W FE LE _E
ST
_C
AG
ID
_S D_ AB ED
_R
_W
AG
FL
SE T
TL W DIS _FE
RE _IN
SS
T_
FL
AL
CN _S D_ TO
D_ ED
D_ ED
PA
T_
GN
C_ TL W U
RS
BY
W FE
SI
RT _CN L_S D_A
D_
D_
_S _
TL WD
C T W
W
RT CN _S
_S
_S
CN _S
C_ TL
TL
TL
C_ TL
d)
ve
RT _CN
CN
CN
RT _CN
r
se
C_
C_
C
C
(re
RT
RT
RT
RT
31 30 29 28 27 18 17 16 2 1 0
0 0 0 0 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_SWD_FEED_INT Receiving this interrupt leads to feeding the super watchdog via SW.
(RO)
RTC_CNTL_SWD_SIGNAL_WIDTH Adjusts the signal width sent to the super watchdog. (R/W)
RTC_CNTL_SWD_AUTO_FEED_EN Set this bit to enable automatic watchdog feeding upon inter-
rupts. (R/W)
31 0
0x000000 Reset
RTC_CNTL_SWD_WKEY Sets the write protection key of the super watchdog. (R/W)
C1
U_
CP
O
PR
LL_
TA
_S
SW
L_
d)
d)
NT
ve
ve
C
r
se
C_
se
(re
(re
RT
31 26 25 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 Reset
4H
TC
RA
SC
L_
C NT
C_
RT
31 0
0 Reset
31 0
0 Reset
6H
TC
RA
SC
L_
C NT
C_
RT
31 0
0 Reset
7H
TC
RA
SC
L_
C NT
C_
RT
31 0
0 Reset
E
DL
P
I
EU
N_
AK
I
E_
W
AT
R_
ST
FO
N_
Y_
AI
RD
M
L_
L_
)
d)
ed
ed
NT
NT
ve
rv
rv
C
r
se
se
se
C_
C_
(re
(re
(re
RT
RT
31 28 27 26 20 19 18 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
– in sleep modes.
– entering sleep modes. In this case, wait until RTC_CNTL_RDY_FOR_WAKEUP bit is set,
then you can wake up the chip.
(RO)
PI HO D
D
RT _CN L_G O_ 4_ LD
_G O_ 2_ LD
CN _G O_ 3_ LD
_H D
O_ 1_ L
OL
N0 L
PI PIN HO
C T PI PIN HO
TL PI PIN HO
C_ TL PI PIN HO
RT CN _G O_ 5_
C_ TL PI PIN
RT _CN L_G O_
C T PI
RT _CN L_G
)
ed
C T
RT _CN
rv
se
C
(re
RT
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
LD
HO
D_
PA
G_
DI
L_
C NT
C_
RT
31 0
0 Reset
RTC_CNTL_DIG_PAD_HOLD Set GPIO 6 to GPIO 21 to the holding state. (See bitmap to locate any
GPIO). (R/W)
A
EN
H_
RS SE EN
AS
E_ A
OS EN
T_ T_ T_
FL
T
T
W OU AN CLR
A
T_ L
AI
OU RS RS
AI
CL F_
EN
W
N_ T_ A_
T_ _R
RO N_ T_ T_
T_
T_
TL RO N_ T_ A
C_ TL RO N_ T_ T
_B W OU CN
OU PD
CN _B W OU EN
RT _CN L_B W OU DE
RS
IN
C T RO N_ T_
T_
N_ T_
T_
RT CN _B W OU
OU
W OU
OU
C_ TL RO N_
N_
RO N_
N_
RT _CN L_B W
_B W
W
C T RO
RO
TL RO
RO
RT _CN L_B
_B
CN _B
_B
TL
C_ TL
TL
)
ed
C T
RT _CN
CN
RT CN
CN
rv
C_
C_
C_
se
C
(re
RT
RT
RT
RT
31 30 29 28 27 26 25 16 15 14 13 4 3 0
RTC_CNTL_BROWN_OUT_RST_WAIT Configures the waiting cycles before the reset after a brown-
out. (R/W)
31 0
0x000000 Reset
H
IG
_H
E1
LU
A
_V
ER
M
TI
L_
d)
NT
ve
C
r
se
C_
(re
RT
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
OR
CT
FA
L K_
_C
K
32
AL
XT
L_
C NT
C_
RT
31 0
0x000000 Reset
RTC_CNTL_XTAL32K_CLK_FACTOR Configures the divider factor for the XTAL32K oscillator. (R/W)
T
UT
RE
AI
AI
W
EO
W
TH
T_
N_
E_
AR
I
UR
_T
BL
ST
DT
ET
A
RE
ST
_W
R
K_
K_
K_
K
32
32
32
32
AL
AL
AL
AL
XT
XT
XT
XT
L_
L_
L_
L_
NT
T
CN
CN
CN
C
C_
C_
C_
C_
RT
RT
RT
RT
31 28 27 20 19 4 3 0
RTC_CNTL_XTAL32K_RESTART_WAIT Defines the waiting cycles before restarting the XTAL32K os-
cillator. (R/W)
)
ed
ed
NT
rv
rv
C
se
se
C_
(re
(re
RT
31 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
S E
AU
_C
CT
JE
RE
L_
d)
T
ve
CN
r
se
C_
(re
RT
31 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
OO
B
D_
OA
NL
OW
_D
R CE
FO
L_
)
ed
NT
rv
C
se
C_
(re
RT
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_FORCE_DOWNLOAD_BOOT Set this bit to force the chip to boot from the download
mode. (R/W)
NT
rv
C
se
C_
(re
RT
31 17 16 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
S
1T
S
A_ TS
S
A _ TS
S _W
_W S
1T
1T
NA 1T
1
EN W1
EN 1
W
W
1T NA
T_ _W
_E _W
T_ _
_W T_E
IN NA
IN NA
NT A
_I EN
S
T_ _E
P_ _E
1T
NA IN
ET T_
OU INT
EU INT
W
_E D_
_D _IN
A_
NT A
N_ _
AK _
_I DE
W ER
T
EN
d) TCH AL
_W EC
_
RO TIM
T_
LI _C
W 2K
LP J E
RT _CN ) T_IN
_B IN_
_G LL
_S _R
_S 3L
D
(re NTL BP
TL LP
TL TA
TL A
C d D
CN _M
RT rve _W
C _B
CN _S
CN _X
C_ TL
C_ TL
C_ TL
se TL
C_ TL
)
)
ed
ed
ed
e
RT _CN
RT _CN
RT CN
(re _CN
rv
rv
rv
rv
se
se
se
se
C_
C
C
(re
(re
(re
RT
RT
RT
RT
31 21 20 19 18 17 16 15 14 11 10 9 8 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
C
1T
C
A_ TC
C
A_ TC
C _W
_W C
1T
1T
NA 1T
1
EN W1
EN 1
W
W
1T NA
T_ _W
_E _W
T_ _
_W T_E
IN NA
IN NA
NT A
C
_I EN
T_ _E
P_ _E
1T
NA IN
ET T_
OU INT
EU INT
W
_E D_
_D _IN
A_
NT A
N_ _
AK _
_I DE
W ER
T
EN
d) TCH AL
_W EC
_
RO TIM
T_
LI _C
W 2K
LP J E
RT _CN ) T_IN
_B IN_
_G LL
_S _R
_S 3L
D
(re NTL BP
TL LP
TL TA
TL A
C d D
CN _M
RT rve _W
C _B
CN _S
CN _X
C_ TL
C_ TL
C_ TL
se TL
C_ TL
)
)
ed
ed
ed
e
RT _CN
RT _CN
RT CN
(re _CN
rv
rv
rv
rv
se
se
se
se
C_
C
C
(re
(re
(re
RT
RT
RT
RT
31 21 20 19 18 17 16 15 14 11 10 9 8 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_SLP_WAKEUP_INT_ENA_W1TC Clear the interrupt enable bit when the chip wakes up
from sleep by writing 1 to clear. (W1TC). (WO)
RTC_CNTL_SLP_REJECT_INT_ENA_W1TC Clear the interrupt enable bit when the chip rejects to go
to sleep by writing 1 to clear (W1TC). (WO)
RTC_CNTL_WDT_INT_ENA_W1TC Clear the RTC watchdog interrupt enable bit by writing 1 to clear
(W1TC). (WO)
RTC_CNTL_SWD_INT_ENA_W1TC Clear the super watchdog interrupt enable bit by writing 1 to clear
(W1TC). (WO)
RTC_CNTL_BBPLL_CAL_INT_ENA_W1TC Clear the interrupt enable bit upon the ending of a bb_pll
call by writing 1 to clear (W1TC).(WO)
EL
_S
LK
EN
_C
N_
ON
IO
I
NT
NT
TE
TE
RE
RE
L_
L_
)
d)
d)
ed
ed
NT
T
ve
ve
CN
rv
rv
C
r
se
se
se
se
C_
C_
(re
(re
(re
(re
RT
RT
31 27 26 25 22 21 19 18 17 0
20 0 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_W EU EN LE
PI PIN WA UP NA E
LE
EU EN LE
EN LE
PI _W EU EN E
_G O_ 3_ KE _E BL
LR
O_ 4 K _ BL
N5 AK P_ AB
AB
AK P_ AB
P_ AB
TL PI PIN WA UP NA
_C
US
US
CN _G O_ 2_ KE _E
PE
E
PE
PE
P_ ATE
E
C_ TL PI PIN A UP
YP
AT
AT
YP
YP
TY
TY
TY
ST
ST
RT _CN L_G O_ 1_W AKE
_T
_T
EU G
_T
T_
T_
T_
AK K_
NT
NT
P_
NT
IN
IN
IN
C T PI PIN W
W CL
EU
_I
_I
2_
RT CN _G O_ 0_
5_
3_
_I
N0
O_ _
N4
N1
AK
C_ TL PI PIN
IN
IN
PI PIN
PI
PI
PI
PI
W
_P
_P
RT _CN L_G O_
O_
O_
O_
O_
_G O_
O_
O
O
C T PI
PI
PI
PI
PI
PI
PI
TL PI
PI
RT _CN L_G
_G
_G
_G
_G
_G
_G
CN _G
_G
TL
TL
TL
TL
TL
TL
C_ TL
TL
C T
RT _CN
CN
CN
CN
CN
CN
CN
RT CN
CN
C_
C_
C_
C_
C_
C_
C_
C_
C
RT
RT
RT
RT
RT
RT
RT
RT
RT
31 30 29 28 27 26 25 23 22 20 19 17 16 14 13 11 10 8 7 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RTC_CNTL_GPIO_WAKEUP_STATUS Indicates the RTC GPIO that woke up the chip, with Bit0 to Bit5
representing RTC GPIO 0 to RTC GPIO 5, respectively. For example, 010000 indicates it is the
RTC GPIO 4 that woke up the chip. (RO)
A R
_S
PD
_X
CE
R
FO
L_
d)
ed
NT
ve
rv
C
r
se
se
C_
(re
(re
RT
31 30 29 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 Reset
10.1 Overview
ESP32-C3 provides a 52-bit timer, which can be used to generate tick interrupts for 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 count values can be monitored by three
comparators COMP0, COMP1 and COMP2. See the timer block diagram on Figure 10-1.
Timer Counter0
(UNIT0)
Timer Comparator0
(COMP0)
Timer Counter1
(UNIT1)
Timer Comparator1
(COMP1)
Timer Comparator2
(COMP2)
10.2 Features
• Consist of two 52-bit counters and three 52-bit comparators
• Use CNT_CLK for counting, with an average frequency of 16 MHz in two counting cycles
• Support for 52-bit alarm values (t) and 26-bit alarm periods (δt)
– 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 can generate 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
• Can be configured to stall or continue running when CPU stalls or enters on-chip-debugging mode
Software operation such as configuring registers is clocked by APB_CLK. For more information about
APB_CLK, see Chapter 6 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 Table Peripheral Clock Gating and Reset in Chapter 16 System Registers (SYSREG).
Figure 10-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.
10.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:
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. Another alarm interrupt
also will be generated when the count value reaches (t1 + 2*δt). 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_TARGET
x_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 with the alarm value
(t) in target mode or with the alarm period (t1 + n*δt) in period mode.
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, or current count value is larger than the target value (t) within a
range (0 ~ 251 -1), an alarm interrupt also is generated immediately. The relationship between current count
value tc , the alarm value tt and alarm trigger point is shown below.
1. Software writes suitable values to configuration fields, see the first column in Table 10-3.
2. Software writes 1 to corresponding bits to start synchronization, see the second column in Table 10-3.
10.4.4 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, which means user now 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.
2. Read current count value, see Section 10.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.
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.
10.7 Registers
The addresses in this section are relative to system timer base address provided in Table 3-3 in Chapter 3
System and Memory.
EN
N
_E
L_
LL
AL
TA
ST
0_ RK N
RE N
S
IT O _E
0_
CO _E
0_
UN 1_W RK
EN
T2 OR _EN
E
OR N
OR
E
R_ IT WO
K_
_W K_
GE _W RK
C
ST d ME UN 0_
1_
AR T1 O
SY rve _TI ER_ IT
IT
_T GE _W
se ER M UN
UN
ER R 0
SY IM _TI _EN
T
(re IM _TI R_
IM _T E
R
ST ER RG
ST ER ME
ST d) E
ST ER LK
SY IM TA
A
SY rve _TI
SY IM _C
_
(re IM )
)
ST ER
se ER
ST ER
ed
SY IM
SY M
rv
I
se
ST
(re
SY
31 30 29 28 27 26 25 24 23 22 21 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
SYSTIMER_CLK_EN Register clock gating. 1: Register clock is always enabled for read and write
operations. 0: Only enable needed clock for register read or write operations. (R/W)
D
A LI
_V
AL E
_V AT
UE
T0 PD
NI _U
_U T0
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
SYSTIMER_TIMER_UNIT0_UPDATE Update timer UNIT0, i.e. read the UNIT0 count value to SYS-
TIMER_TIMER_UNIT0_VALUE_HI and SYSTIMER_TIMER_UNIT0_VALUE_LO. (WT)
I
_H
AD
LO
0_
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
31 0
0 Reset
HI
E_
ALU
_V
T0
NI
_U
ER
M
I
_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
LO
E_
LU
VA
0_
IT
N
_U
ER
I M
_T
ER
I M
ST
SY
31 0
0 Reset
AD
LO
0_
IT
N
_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_UNIT0_LOAD UNIT0 synchronization enable signal. Set this bit to reload the
values of SYSTIMER_TIMER_UNIT0_LOAD_HI and SYSTIMER_TIMER_UNIT0_LOAD_LO to UNIT0.
(WT)
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
SYSTIMER_TIMER_UNIT1_UPDATE Update timer UNIT1, i.e. read the UNIT1 count value to SYS-
TIMER_TIMER_UNIT1_VALUE_HI and SYSTIMER_TIMER_UNIT1_VALUE_LO. (WT)
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
31 0
0 Reset
I
_H
UE
AL
_V
T1
NI
_U
ER
M
I
_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
LO
E_
LU
VA
1_
IT
N
_U
ER
I M
_T
ER
I M
ST
SY
31 0
0 Reset
AD
LO
1_
IT
N
_U
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
SYSTIMER_TIMER_UNIT1_LOAD UNIT1 synchronization enable signal. Set this bit to reload the
values of SYSTIMER_TIMER_UNIT1_LOAD_HI and SYSTIMER_TIMER_UNIT1_LOAD_LO to UNIT1.
(WT)
I
_H
T0
GE
AR
_T
ER
IM
_T
)
ER
ed
IM
rv
se
ST
(re
SY
31 20 19 0
0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
O
_L
T0
GE
AR
_T
ER
IM
_T
ER
IM
ST
SY
31 0
0 Reset
D
IO
_P ER
ER
T0 IM
_P
GE _T
AR T0
T0
_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
D
OA
_L
P0
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
SYSTIMER_TIMER_COMP0_LOAD COMP0 synchronization enable signal. Set this bit to reload the
alarm value/period to COMP0. (WT)
I
_H
T1
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 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
D
OA
_L
P1
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
SYSTIMER_TIMER_COMP1_LOAD COMP1 synchronization enable signal. Set this bit to reload the
alarm value/period to COMP1. (WT)
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
T2
GE
AR
_T
ER
IM
_T
ER
I M
ST
SY
31 0
0 Reset
OD
_P ER
RI
T2 IM
PE
GE _T
2_
AR T2
T
_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
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
SYSTIMER_TIMER_COMP2_LOAD COMP2 synchronization enable signal. Set this bit to reload the
alarm value/period to COMP2. (WT)
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
0x2006171 Reset
11.1 Overview
General purpose timers can be used to precisely time an interval, trigger an interrupt after a particular interval
(periodically and aperiodically), or act as a hardware clock. As shown in Figure 11-1, the ESP32-C3 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. All general purpose timers are based
on 16-bit prescalers and 54-bit auto-reload-capable up-down counters.
Note that while the Main System Watchdog Timer registers are described in this chapter, their functional
description is included in the Chapter 12 Watchdog Timers (WDT). Therefore, the term ‘timers’ within this
chapter refers to the general purpose timers.
Figure11-2 is a diagram of timer T0 in a timer group. T0 contains a clock selector, a 16-bit integer divider as a
prescaler, a timer-based counter and a comparator for alarm generation.
To modify the 16-bit prescaler, please first configure the TIMG_T0_DIVIDER field, and then set
TIMG_T0_DIVIDER_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, or lower than the alarm value (within a defined range)
when the up-down counter decrements. Table 11-1 and Table 11-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. 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.
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
11.2.6 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.
• 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.
11.5 Registers
The addresses in this section are relative to Timer Group base address provided in Table 3-3 in Chapter 3
System and Memory.
ST
OA
_X EN
_R
L
OR E
EL
TA
UT AS
SE _
ER
ER
_U RM
_A RE
ID
M d ID
T0 LA
T0 C
IV
TI rve DIV
TI T N
G_ IN
_D
G_ A
G_ E
TI _T )
)
M 0_
M 0_
se 0_
M 0_
ed
T0
TI _T
(re _T
rv
G_
se
G
G
M
(re
TI
TI
TI
31 30 29 28 13 12 11 10 9 8 0
0 1 1 0x01 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TIMG_T0_USE_XTAL 1: Use XTAL_CLK as the source clock of timer group. 0: Use APB_CLK as the
source clock of timer group. (R/W)
TIMG_T0_ALARM_EN When set, the alarm is enabled. This bit is automatically cleared once an
alarm occurs. (R/W/SC)
TIMG_T0_DIVIDER_RST When set, Timer 0 ’s clock divider counter will be reset. (WT)
TIMG_T0_INCREASE When set, the Timer 0 time-base counter will increment every clock tick.
When cleared, the Timer 0 time-base counter will decrement. (R/W)
31 0
0x000000 Reset
TIMG_T0_LO After writing to TIMG_T0UPDATE_REG, the low 32 bits of the time-base counter of
Timer 0 can be read here. (RO)
I
_H
)
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 After writing to TIMG_T0UPDATE_REG, the high 22 bits of the time-base counter of
Timer 0 can be read here. (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
31 0
0x000000 Reset
TIMG_T0_ALARM_LO Timer 0 alarm trigger time-base counter value, low 32 bits. (R/W)
_
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 Timer 0 alarm trigger time-base counter value, high 22 bits. (R/W)
O
_L
AD
LO
0_
T
G_
M
TI
31 0
0x000000 Reset
TIMG_T0_LOAD_LO Low 32 bits of the value that a reload will load onto Timer 0 time-base counter.
(R/W)
I
_H
AD
LO
)
_
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 High 22 bits of the value that a reload will load onto Timer 0 time-base counter.
(R/W)
31 0
0x000000 Reset
TIMG_T0_LOAD Write any value to trigger a Timer 0 time-base counter reload. (WT)
RE T_ N
H
U_ ESE D_E
SE EN
EN
GT
GT
N
T_
L _E
EN
CP R O
EN
PP PU _M
TA TE
_L
_L
_X DA
_A C OT
ET
ET
_
SE UP
ES
DT O O
ES
W PR HB
_R
_U F_
R
0
M D G3
G_ T_ S
1
DT N
PU
TG
TG
TG
YS
M D LA
W CO
G_ _EN
ST
_C
_S
_S
_S
_S
TI W F
_
G_ T_
G_ T_
DT
DT
DT
DT
DT
DT
DT
d)
M D
ve
W
TI _W
TI W
G_
G_
G_
G_
G_
G_
G_
r
se
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 System reset signal length selection. 0: 100 ns, 1: 200 ns, 2:
300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 µs, 7: 3.2 µs. (R/W)
TIMG_WDT_CPU_RESET_LENGTH CPU reset signal length selection. 0: 100 ns, 1: 200 ns, 2: 300
ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 µs, 7: 3.2 µs. (R/W)
TIMG_WDT_STG3 Stage 3 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMG_WDT_STG2 Stage 2 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMG_WDT_STG1 Stage 1 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
TIMG_WDT_STG0 Stage 0 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. (R/W)
ST
ES
R
T_
PR
CN
K_
IV
L
_D
_C
DT
DT
)
ed
W
W
rv
G_
G_
se
M
M
(re
TI
TI
31 16 15 1 0
0x01 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TIMG_WDT_DIVCNT_RST When set, WDT ’s clock divider counter will be reset. (WT)
TIMG_WDT_CLK_PRESCALE MWDT clock prescaler value. MWDT clock period = MWDT’s clock
source period * TIMG_WDT_CLK_PRESCALE. (R/W)
LD
HO
0_
TG
_S
DT
W
G_
M
TI
31 0
26000000 Reset
LD
HO
1_
TG
_S
DT
W
G_
M
TI
31 0
0x7ffffff Reset
31 0
0x0fffff Reset
LD
HO
3_
TG
_S
DT
W
G_
M
TI
31 0
0x0fffff Reset
ED
_ FE
DT
W
G_
M
TI
31 0
0x000000 Reset
31 0
0x50d83aa1 Reset
TIMG_WDT_WKEY If the register contains a different value than its reset value, write protection is
enabled. (R/W)
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
LD
_V
TA
DA
G_
N
E
LI
LU
YC
VA
_C
I_
LI
L
CA
CA
C_
C_
)
ed
RT
RT
rv
G_
G_
se
M
M
(re
TI
TI
31 7 6 1 0
0x00000 0 0 0 0 0 0 0 Reset
NT
ES
_C
ST
R
TH
_R
T_
UT
UT
U
EO
EO
EO
IM
IM
IM
I_T
_T
_T
LI
LI
L
CA
CA
CA
C_
C_
C_
d)
RT
RT
RT
e
rv
G_
G_
G_
se
M
M
(re
TI
TI
TI
31 7 6 3 2 1 0
0x1ffffff 3 0 0 0 Reset
_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
TIMG_T0_INT_ENA The interrupt enable bit for the TIMG_T0_INT interrupt. (R/W)
TIMG_WDT_INT_ENA The interrupt enable bit for the TIMG_WDT_INT interrupt. (R/W)
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 for the TIMG_T0_INT interrupt. (R/SS/WTC)
TIMG_WDT_INT_RAW The raw interrupt status bit for 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 for the TIMG_T0_INT interrupt. (RO)
TIMG_WDT_INT_ST The masked interrupt status bit for 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
I
ed
NT
rv
G_
se
M
(re
TI
31 28 27 0
0 0 0 0 0x2006191 Reset
TI E
AC TIV
VE
S_ C
_I _A
LK _IS
_C LK
DT C
M IM N
W R_
TI _T _E
G_ E
d)
G K
M L
ve
TI _C
r
se
G
M
(re
TI
31 30 29 28 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 0 0 0 0 Reset
TIMG_CLK_EN Register clock gate signal. 0: The clock used by software to read and write registers
is on only when there is software operation. 1: The clock used by software to read and write
registers is always on. (R/W)
12.1 Overview
Watchdog timers are hardware timers used to detect and recover from malfunctions. They must be
periodically fed (reset) to prevent a timeout. A system/software that is behaving unexpectedly (e.g. is stuck in
a software loop or in overdue events) will fail to feed the watchdog thus trigger a watchdog timeout.
Therefore, watchdog timers are useful for detecting and handling erroneous system/software behavior.
As shown in Figure 12-1, ESP32-C3 contains three digital watchdog timers: one in each of the two timer
groups in Chapter 11 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 expiry, 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
12.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 first MWDT in timergroup 0 are enabled automatically in order to
detect and recover from booting errors.
ESP32-C3 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, their register
descriptions are provided in Chapter 11 Timer Group (TIMG) and Chapter 9 Low-power Management.
• Four stages, each with a programmable timeout value. Each stage can be configured and
enabled/disabled separately
• Three timeout actions (interrupt, CPU reset, or core reset) for MWDT and four timeout actions (interrupt,
CPU reset, core reset, or system reset) for RWDT upon expiry of each stage
• Write protection, to prevent RWDT and MWDT configuration from being altered inadvertently
Figure 12-2 shows the three watchdog timers in ESP32-C3 digital systems.
MWDTs can select between the APB clock (APB_CLK) or external clock (XTAL_CLK) as its clock source by
setting the TIMG_WDT_USE_XTAL field of the TIMG_WDTCONFIG0_REG register. The selected clock is
switched on by setting TIMG_WDT_CLK_IS_ACTIVE field of the TIMG_REGCLK_REG register to 1 and switched
off by setting it to 0. Then the selected clock is divided by a 16-bit configurable prescaler. The 16-bit prescaler
for MWDTs 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 an RTC slow clock (the RTC slow clock source
shown in Chapter 6 Reset and Clock).
MWDTs and RWDT are enabled by setting the TIMG_WDT_EN and RTC_CNTL_WDT_EN fields respectively.
When enabled, the 32-bit counters of each watchdog will increment on each source clock cycle until the
timeout value of the current stage is reached (i.e. expiry of the current stage). When this occurs, the current
counter value is reset to zero and the next stage will become active. If a watchdog timer is fed by software,
the timer will return to stage 0 and reset its counter value to zero. Software can feed a watchdog timer by
writing any value to TIMG_WDTFEED_REG for MDWTs and RTC_CNTL_WDT_FEED for RWDT.
Timer stages allow for a timer to have a series of different timeout values and corresponding expiry action.
When one stage expires, the expiry action is triggered, the counter value is reset to zero, and the next stage
becomes active. MWDTs/ 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 MWDTs are configured in TIMG_WDTCONFIGi_REG (where i ranges from 2 to
5), whilst timeout values for RWDT are configured using RTC_CNTL_WDT_STGj_HOLD field (where j ranges
from 0 to 3).
Please note that the timeout value of stage 0 for RWDT (Thold₀) is determined by the combination of
the
EFUSE_WDT_DELAY_SEL field of eFuse register EFUSE_RD_REPEAT_DATA1_REG and
RTC_CNTL_WDT_STG0_HOLD. The relationship is as follows:
Thold0 = RT C_CN T L_W DT _ST G0_HOLD << (EF U SE_W DT _DELAY _SEL + 1)
Upon the expiry of each stage, one of the following expiry actions will be executed:
• Trigger an interrupt
When the stage expires, an interrupt is triggered.
• System reset – Reset the main system, power management unit and RTC peripheral
When the stage expires the main system, power management unit and RTC peripheral (see details in
Chapter 9 Low-power Management) will all be reset. This action is only available in RWDT.
• Disabled
This stage will have no effects on the system.
For MWDTs, the expiry action of all stages is configured in TIMG_WDTCONFIG0_REG. Likewise for RWDT, the
expiry action is configured in RTC_CNTL_WDTCONFIG0_REG.
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, MWDTs 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, RTC_CNTL_WDT_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, MWDT in timer group 0 (see Figure 11-1 Timer Units within Groups), as well as
RWDT, are automatically enabled. Stage 0 for the enabled MWDT is automatically configured to reset the
system upon expiry, known as core reset. Likewise, stage 0 for RWDT is configured to system reset, which
resets the main system and RTC when it expires. After booting, TIMG_WDT_FLASHBOOT_MOD_EN and
RTC_CNTL_WDT_FLASHBOOT_MOD_EN should be cleared to stop the flash boot protection procedure for
both MWDT and RWDT respectively. After this, MWDT 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.
12.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
12.3.2.1 Structure
12.3.2.2 Workflow
In normal state:
• When trying to feed SWD, CPU needs to disable SWD controller’s write protection by writing 0x8F1D312A
to RTC_CNTL_SWD_WKEY. This prevents SWD from being fed by mistake when the system is operating
in sub-optimal state.
• If setting RTC_CNTL_SWD_AUTO_FEED_EN to 1, SWD controller can also feed SWD itself without any
interaction with CPU.
After reset:
12.4 Interrupts
For watchdog timer interrupts, please refer to Section 11.2.6 Interrupts in Chapter 11 Timer Group (TIMG).
12.5 Registers
MWDT registers are part of the timer submodule and are described in Section 11.4 Register Summary in
Chapter 11 Timer Group (TIMG). RWDT and SWD registers are part of the RTC submodule and are described in
Section 9.7 Register Summary in Chapter 9 Low-power Management.
13.1 Overview
The XTAL32K watchdog timer on ESP32-C3 is used to monitor the status of external crystal XTAL32K_CLK.
This watchdog timer can detect the oscillation failure of XTAL32K_CLK, change the clock source of RTC, etc.
When XTAL32K_CLK works as the clock source of RTC_SLOW_CLK (for clock description, see Chapter 6
Reset and Clock) and stops vibrating, the XTAL32K watchdog timer first switches to BACKUP32K_CLK derived
from RC_SLOW_CLK and generates an interrupt (if the chip is in Light-sleep and Deep-sleep mode, the CPU
will be woken up), and then switches back to XTAL32K_CLK after it is restarted by software.
XTAL32K
Interrupt
Watchdog
RTC_CNTL_XTAL32K_WDT_EN
Monitor
BACKUP32K_CLK_EN
&
XTAL32K_CLK
0 RTC_SLOW_CLK
RC_SLOW_CLK BACKUP32K_CLK
Divisor 1
13.2 Features
13.2.1 Interrupt and Wake-Up
When the XTAL32K watchdog timer detects the oscillation failure of XTAL32K_CLK, an oscillation failure
interrupt RTC_XTAL32K_DEAD_INT (for interrupt description, please refer to Chapter 9 Low-power
Management) is generated. At this point, the CPU will be woken up if in Light-sleep and Deep-sleep
mode.
13.2.2 BACKUP32K_CLK
Once the XTAL32K watchdog timer detects the oscillation failure of XTAL32K_CLK, it replaces XTAL32K_CLK
with BACKUP32K_CLK (with a frequency of 32 kHz or so) derived from RC_SLOW_CLK as RTC_SLOW_CLK, so
as to ensure proper functioning of the system.
13.3.1 Workflow
1. The XTAL32K watchdog timer starts counting when RTC_CNTL_XTAL32K_WDT_EN is enabled. The
counter based on RC_SLOW_CLK keeps counting until it detects the positive edge of XTAL_32K and is
then cleared. When the counter reaches RTC_CNTL_XTAL32K_WDT_TIMEOUT, it generates an interrupt
or a wake-up signal and is then reset.
2. If RTC_CNTL_XTAL32K_AUTO_BACKUP is set and step 1 is finished, the XTAL32K watchdog timer will
automatically enable BACKUP32K_CLK as the alternative clock source of RTC_SLOW_CLK, to ensure the
system’s proper functioning and the accuracy of timers running on RTC_SLOW_CLK (e.g. RTC_TIMER).
For information about clock frequency configuration, please refer to Section 13.3.2.
3. Software restarts XTAL32K_CLK by turning its XPD (meaning no power-down) signal off and on again via
the RTC_CNTL_XPD_XTAL_32K bit. Then, the XTAL32K watchdog timer switches back to XTAL32K_CLK
as the clock source of RTC_SLOW_CLK by clearing RTC_CNTL_XTAL32K_WDT_EN
(BACKUP32K_CLK_EN is also automatically cleared). If the chip is in Light-sleep and Deep-sleep mode,
the XTAL32K watchdog timer will wake up the CPU to finish the above steps.
f _back_clk/4 = f _rc_slow_clk/S
S = x0 + x1 + ... + x7
f_back_clk is the desired frequency of BACKUP32K_CLK, i.e. 32.768 kHz; f_rc_slow_clk is the actual
frequency of RC_SLOW_CLK; x0 ~x7 correspond to the pulse width in high and low state of four
BACKUP32K_CLK clock signals (unit: RC_SLOW_CLK clock cycle).
• Calculate the sum of divisor components S according to the frequency of RC_SLOW_CLK and the
desired frequency of BACKUP32K_CLK;
• Calculate the integer part of divisor component M = N /2. The integer part of divisor N are separated
into two parts because a divisor component corresponds to a pulse width in high or low state;
• Calculate the number of divisor components that equal M (xn = M) and the number of divisor
components that equal M + 1 (xn = M + 1) according to the value of M and S. (M + 1) is the fractional part
of divisor component.
For example, if the frequency of RC_SLOW_CLK is 163 kHz, then f _rc_slow_clk = 163000,
f _back_clk = 32768, S = 20, M = 2, and {x0 , x1 , x2 , x3 , x4 , x5 , x6 , x7 } = {2, 3, 2, 3, 2, 3, 2, 3}. As a result, the
frequency of BACKUP32K_CLK is 32.6 kHz.
14.1 Overview
ESP32-C3 includes a Permission Controller (PMS), which allocates the hardware resources (memory and
peripherals) to two isolated environments, thereby realizing the separation of privileged and unprivileged
environments.
• Privileged Environment:
– Performs all confidential operations, such as user authentication, secure communication, and data
encryption and decryption, etc.
• Unprivileged Environment:
– Performs other operations, such as user operation and different applications, etc.
Besides, ESP32-C3’s RISC-V CPU also has a Physical Memory Protection (PMP) unit, which can be used by
software to set memory access privileges (read, write, and execute permissions) for required memory regions.
However, the PMP unit has some limitations:
• Only supports up to 16 configurable PMP regions, which sometimes are not enough to fully support the
access management requirement of ESP32-C3’s rich peripherals and different types of memories.
To this, ESP32-C3 has specially implemented this Permission Controller to complete the Physical Memory
Protection unit.
ESP32-C3’s completed workflow of permission check can be described below (also see Figure 14-1):
• Fail: throw an exception and will not further check PMS permission
CPU
PMP
PMS World
Controller
For details about PMP, please refer to Section 1.8.1 in Chapter 1 ESP-RISC-V CPU. For details about World
Controller, please refer to Chapter 15 World Controller (WCL). This chapter only describes ESP32-C3’s PMS
mechanism.
14.2 Features
ESP32-C3’s extended permission control mechanism supports:
• When in the privileged environment: check the permission configuration registers for the privileged
environment
• When not in the unprivileged environment: check the permission configuration registers for the
unprivileged environment
Users can choose either of these two ways below to enter the chip into privileged environment:
Users can configure PMS_PRIVILEGE_MODE_SEL to choose between the above-mentioned two ways to
enter the chip into privileged environment:
• 0 (Default): via configuring the world controller. See details in Chapter 15 World Controller (WCL).
• 1: via configuring the CP’s privileged level. See details in Chapter 1 ESP-RISC-V CPU.
The following sections introduce how to configure the permission to different areas in the privileged
environment and the unprivileged environment.
• ROM: 384 KB in total, including 256 KB Internal ROM0 and 128 KB Internal ROM1
• SRAM: 400 KB in total, including 16 KB Internal SRAM0 and 384 KB Internal SRAM1
• RTC FAST Memory: 8 KB in total, which can be further split into two regions each with independent
permission configuration
This section describes how to configure the permission to each type of ESP32-C3’s internal memory.
14.4.1 ROM
ESP32-C3’s ROM can be accessed by CPU’s instruction bus (IBUS) and data bus (DBUS) when configured.
The ROM ranges accessible for IBUS and DBUS respectively are listed in Table 14-1.
ESP32-C3 uses the registers listed in Table 14-2 to configure the instruction execution (X), write (W) and read
(R) accesses of CPU’s IBUS and DBUS, in User mode and Machine mode. Note that access configuration to
ROM0 and ROM1 cannot be configured separately:
14.4.2 SRAM
ESP32-C3’s SRAM can be accessed by CPU’s instruction bus (IBUS) and data bus (DBUS) when configured.
The SRAM address ranges accessible for IBUS and DBUS respectively are listed in Table 14-3.
Here, we will first introduce how to configure the permission to Internal SRAM0 and then Internal SRAM1.
• 1: CPU
• 0: ICACHE
When the Internal SRAM0 is allocated to CPU, ESP32-C3 uses the registers listed in Table 14-4 to configure the
instruction execution (X), write (W) and read (R) accesses of CPU’s IBUS, in the privileged environment and
the unprivileged environment:
ESP32-C3’s Internal SRAM1 includes Block0 ~ Block2 (see details in Table 14-3) and can be:
• Further split into up to 6 regions with independent access management for more flexible permission
control.
ESP32-C3’s Internal SRAM1 can be further split into up to 6 regions with 5 split lines. Users can configure
different access to each region independently.
To be more specific, the Internal SRAM1 can be first split into Instruction Region and Data Region by
IRam0_DRam0_split_line:
• Instruction Region:
– And can be further split into three split regions by IRam0_split_line_0 and IRam0_split_line_1.
• Data Region:
– And can be further split into three split regions by DRam0_split_line_0 and DRam0_split_line_1.
ESP32-C3 allows users to configure the split lines to their needs with registers below:
– PMS_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_1_REG
• The first split line to further split the Instruction Region (IRam0_split_line_0):
– PMS_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_2_REG
• The second split line to further split the Instruction Region (IRam0_split_line_1):
– PMS_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG
• The first split line to further split the data Region (DRam0_split_line_0):
– PMS_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_4_REG
• The second split line to further split the data Region (DRam0_split_line_1):
– PMS_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_5_REG
• Configuring the Category_x field for the block in which the split line is to 0x1 or 0x2 (no difference)
• Configuring the Category_0 ~ Category_x-1 fields for all the preceding blocks to 0x0
• Configuring the Category_x+1 ~ Category_2 fields for all blocks afterwards to 0x3
For example, assuming you want to configure the split line in Block1, then first configure the Category_1
field for Block1 to 0x1 or 0x2; configure the Category_0 for Block0 to 0x0; and configure the Category_2
for Block2 to 0x3 (see illustration in Figure 14-3). On the other hand, when reading 0x1 or 0x2 from
Category_1, then you know the split line is in Block1.
2. Configure the position of the split line inside of the configured block by:
• Writing the [16:9] bits of the actual address at which you want to split the memory to the SPLITADDR
field for the block in which the split line is.
• Note that the split address must be aligned to 512 bytes, meaning you can only write the integral
multiples of 0x200 to the SPLITADDR field.
For example, if you want to split the instruction region at 0x3fc88000, then write the [16:9] bits of this
address, which is 0b01000000, to SPLITADDR.
3. The split address applies to both IBUS and DBUS address�For example, DBUS address 0x3fc88000 and
IBUS address 0x40388000 indicate the same location in SRAM1. The split address for both buses is
[16:9].
• Position:
– The split line that splitting the Instruction Region and Data Region can be configured anywhere
inside Internal SRAM1.
– The two split lines further splitting the Instruction Region into 3 split regions must stay inside the
Instruction Region.
– The two split lines further splitting the Data Region into 3 split regions must stay inside the Data
Region.
– When the two split lines inside the Data Region are not overlapping with each other, then the Data
Region is split into 3 split regions
– When the two split lines inside the Data Region are overlapping with each other, then the Data
Region is only split into 2 split regions
– When the two split lines inside the Data Region are not only overlapping with each other but also
with the split line that splits the Data Region and the Instruction Region, then the Data Region is not
split at all and only has one region.
Access Configuration
After configuring the split lines, users can then use the registers described in the Table 14-6 and Table 14-7
below to configure the access of CPU’s IBUS, DBUS and GDMA peripherals, in the privileged environment and
the unprivileged environment, to these split regions independently.
Instruction Region
Buses Environment Configuration Registers Access
instr_region_0 instr_region_1 instr_region_2
Data Region
Buses Environment Configuration Registers Access
data_region_0 data_region_1 data_region_2
For details on how to configure the split lines, see Section 14.4.2.2.
Note:
If enabled, the permission control module watches all the memory access and fires the panic handler if a permission
violation is detected. This feature automatically splits the SRAM memory into data and instruction segments and sets
Read/Execute permissions for the instruction part (below given splitting address) and Read/Write permissions for the
data part (above the splitting address). The memory protection is effective on all access through the IRAM0 and
DRAM0 buses. See details, see ESP-IDF api-reference Memory protection.
ESP32-C3’s RTC FAST Memory can be further split into 2 regions. Each split region can be configured
independently with different access.
Table 14-9. Split RTC FAST Memory into the Higher Region and the Lower Region
Access configuration for the higher and lower regions of the RTC FAST Memory is described below:
14.5 Peripherals
14.5.1 Access Configuration
ESP32-C3’s CPU can be configured with different read (R) and write (W) accesses to most of its modules and
peripherals independently, in the privileged environment and in the unprivileged environment, by configuring
respective registers
(PMS_CORE_0_PIF_PMS_CONSTRAN_n_REG).
Notes on PMS_CORE_0_PIF_PMS_CONSTRAN_n_REG:
• n can be 1 ~ 8, in which 1 ~ 4 are for the privileged environment and 5 ~ 8 are for the unprivileged
environment.
For example, users can configure PMS_CORE_0_PIF_PMS_CONSTRAIN_1_REG [1:0] to 0x2, meaning CPU is
granted with read access but not write access in the privileged environment to UART0. In this case, CPU won’t
be able to modify the UART0’s internal registers when in the privileged environment.
For example, the registers for ESP32-C3’s GDMA controller are allocated as:
As seen above, GDMA’s peripheral region is divided into 7 split regions (implemented in hardware), which can
be configured with different permission independently, thus achieving independent permission control for
each GDMA channel.
Users can configure CPU’s read (R) and write (W) accesses to a specific split region (Peri Regionn) in the
privileged environment and in the unprivileged environment by configuring
PMS_REGION_PMS_CONSTRAN_n_REG.
Notes on PMS_REGION_PMS_CONSTRAN_n_REG:
Where,
14.6.1.1 Address
ESP32-C3’s flash can be further split to achieve more flexible permission control. Each split region can be
configured with different access independently.
• Flash can be split into 4 regions, the length of each should be the integral multiples of 64 KB.
• Also, the starting address of each region should also be aligned to 64 KB.
The following registers can be used to configure how the flash is split.
Each split region for flash can be configured with different permission independently via the register described
in the Table below.
Access Configuration
Split Regions
Configuration Register Cache SPI
Flash Region n (n: 0 ~ 3) SYSCON_FLASH_ACEn_ATTR [1:0]A [3:2]B
A These bits are configured in order R/X. For example, configuring this field
to 2’b10 indicates CACHE is granted with the read access but no instruction
execution access to the Flash Region n.
B These bits are configured in order W/R. For example, configuring this field
to 2’b01 indicates SPI is granted with the read access but no write access to
the Flash Region n.
Both ESP32-C3’s DBUS and IBUS Cache virtual address regions can be further split into up to 4 regions. Users
can configure different access to each region independently.
Access Configuration
Split Regions
Configuration Register PrivilegedA UnprivilegedA
IBUS Region0C - - -
IBUS Region1 EXTMEM_IBUS_PMS_TBL_ATTR_REG [1:0]B [3:2]
IBUS Region2 EXTMEM_IBUS_PMS_TBL_ATTR_REG [5:4] [7:6]
IBUS Region3 C - - -
A These bits are configured in order R/X.
B For example, configuring this field to 2’b10 indicates CPU’s IBUS is granted read access
but no instruction execution access to IBUS region1 in the privileged environment.
C IBUS is not allowed to access Region0 and Region3, thus cannot be configured. All
attempts will be rejected.
Access Configuration
Split Regions
Configuration Register PrivilegedA UnprivilegedA
DBUS Region0C - - -
DBUS Region1 EXTMEM_DBUS_PMS_TBL_ATTR_REG [0]B [1]
DBUS Region2 EXTMEM_DBUS_PMS_TBL_ATTR_REG [2] [3]
DBUS Region3C - - -
A Only the read access can be configured.
B For example, configuring this field to 1’b1 indicates CPU’s DBUS is granted read access to
DBUS region1 in the privileged environment.
C DBUS is not allowed to access Region0 and Region3, thus cannot be configured. All
attempts will be rejected.
– All instruction execution or read attempts will be responded with 0 (for internal memory and
peripheral) or 0xdeadbeaf (for external memory)
Note that only the information of the first interrupt is logged. Therefore, it’s advised to handle interrupt signals
and clear interrupts in-time, so the information of the next interrupt can be logged correctly.
interrupt is enabled, it’s enabled for all internal ROM and SRAM memory, and cannot be only enabled for a
certain address field. This interrupt corresponds to the PMS_IBUS_VIO_INTR interrupt source described in
Table 8-1 from Chapter 8 Interrupt Matrix (INTERRUPT).
Table 14-23. Interrupt Registers for Unauthorized Access to Internal Memory via GDMA
For information about Interrupt upon unauthorized access to external memory via GDMA, please refer to
Chapter 2 GDMA Controller (GDMA)�
In particular, ESP32-C3 can also be configured to check the access alignment when PIF attempts to access
the peripheral regions and trigger Interrupt upon unauthorized alignment. See the detailed description in the
following section.
ESP32-C3 can be configured to check the access alignment to all modules/peripherals, and trigger Interrupt
upon non-word aligned access.
This interrupt corresponds to the PMS_PERI_VIO_SIZE_INTR interrupt source described in Table 8-1 from
Chapter 8 Interrupt Matrix (INTERRUPT).
Note that CPU can convert some non-word aligned access to word aligned access, thus avoiding triggering
alignment interrupt.
Table 14-25 below lists all the possible access alignments and their results (when the interrupt is enabled), in
which:
• INTR: interrupt
√
• : access succeeds and no interrupt.
Note that there isn’t a one-to-one correspondence between the lock registers and permission control
registers. See details in Table 14-27.
GoBack
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG IBUS Permission Config Register 0 0x00A8 R/WL
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_1_REG IBUS Permission Config Register 1 0x00AC R/WL
Espressif Systems
Version Register
PMS_CLOCK_GATE_REG_REG Clock Gate Config Register 0x0170 R/W
PMS_DATE_REG Sensitive Version Register 0x0FFC R/W
GoBack
Name Description Address Access
Configuration Registers
SYSCON_EXT_MEM_PMS_LOCK_REG External Memory Permission Lock Register 0x0020 R/W
Espressif Systems
GoBack
Espressif Systems
CK
LO
L_
SE
E_
OD
_M
GE
LE
VI
)
ed
PRI
rv
S_
se
PM
(re
Submit Documentation Feedback
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
GoBack
Espressif Systems
L
SE
E_
OD
_M
GE
LE
VI
)
ed
PRI
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
CK
LO
S_
CES
AC
_
AL
ER
PH
RI
PE
B_
)
ed
AP
rv
ESP32-C3 TRM (Version 1.1)
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_APB_PERIPHERAL_ACCESS_LOCK Set this bit to lock APB peripheral configuration register. (R/WL)
GoBack
Espressif Systems
T
RS
BU
T_
LI
SP
S_
ES
CC
_A
AL
ER
PH
RI
PE
B_
)
ed
AP
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
Submit Documentation Feedback
PMS_APB_PERIPHERAL_ACCESS_SPLIT_BURST Set this bit to support split function for AHB access to APB peripherals. (R/WL)
330
K
OC
_L
GE
SA
_U
AM
SR
L_
NA
ER
)
ed
NT
rv
I
S_
ESP32-C3 TRM (Version 1.1)
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_INTERNAL_SRAM_USAGE_LOCK Set this bit to lock internal SRAM Configuration Register. (R/WL)
GoBack
Espressif Systems
HE
C
CA
P U_
_C
GE
SA
_U
AM
SR
A L_
RN
TE
)
)
ed
ed
IN
rv
rv
S_
se
se
PM
(re
(re
31 4 3 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x7 1 Reset
Submit Documentation Feedback
RAM
_S
OG
_L
GE
SA
_U
AM
SR
L_
NA
ER
)
ed
NT
ESP32-C3 TRM (Version 1.1)
rv
I
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
GoBack
Espressif Systems
CK
LO
N_
AI
TR
NS
CO
S_
M
_P
I2
SP
I_
ER
BP
AP
A_
)
ed
DM
rv
S_
se
PM
(re
31 1 0
Submit Documentation Feedback
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_APBPERI_SPI2_PMS_CONSTRAIN_LOCK Set this bit to lock SPI2’s DMA permission configuration register. (R/WL)
332
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
3
1
S_
S_
S_
S_
PM
PM
_P
_P
E_
E_
E
E
OD
OD
OD
OD
_M
_M
_M
_M
_M
_M
_M
_M
AM
AM
RA
RA
SR
SR
S
_S
N_
N_
N_
IN
AI
AI
AI
RA
TR
TR
TR
ST
NS
NS
NS
N
CO
CO
CO
CO
S_
S_
S_
S_
M
PM
M
_P
_P
_P
2_
I2
I2
I
PI
SP
SP
SP
S
I_
I_
I_
I_
ER
ER
ER
ER
BP
BP
BP
BP
AP
AP
AP
AP
Submit Documentation Feedback
A_
A_
A_
A_
)
ed
DM
DM
DM
DM
rv
S_
S_
S_
S_
se
PM
PM
PM
PM
(re
31 8 7 6 5 4 3 2 1 0
Reset
GoBack
Espressif Systems
K
OC
_L
IN
RA
ST
ON
C
S_
PM
0_
HI
UC
I_
ER
BP
AP
A_
)
ed
DM
rv
S_
se
PM
(re
31 1 0
Submit Documentation Feedback
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_APBPERI_UCHI0_PMS_CONSTRAIN_LOCK Set this bit to lock UHCI0’s DMA permission configuration register. (R/WL)
334
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
3
1
S_
S_
S_
S_
PM
PM
_P
_P
E_
E_
E
E
OD
OD
OD
OD
_M
_M
_M
_M
_M
_M
_M
_M
AM
AM
RA
RA
SR
SR
_S
_S
N_
N_
N
IN
AI
AI
AI
RA
TR
TR
ST
ST
NS
NS
ON
ON
CO
CO
_C
C
S_
S_
S_
S
PM
PM
_P
_P
0_
0_
0
I0
HI
HI
HI
CH
UC
UC
UC
U
I_
I_
I_
I_
ER
ER
ER
ER
BP
BP
BP
BP
Submit Documentation Feedback
AP
AP
AP
AP
A_
A_
A_
A_
)
ed
DM
DM
DM
DM
rv
S_
S_
S_
S_
se
PM
PM
PM
PM
(re
31 8 7 6 5 4 3 2 1 0
335
GoBack
Espressif Systems
K
OC
_L
IN
RA
ST
ON
C
S_
M
_P
S0
I2
I_
ER
BP
AP
A_
)
ed
DM
rv
S_
se
PM
(re
31 1 0
Submit Documentation Feedback
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_APBPERI_I2S0_PMS_CONSTRAIN_LOCK Set this bit to lock I2S’s DMA permission configuration register. (R/WL)
336
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
3
1
S_
S_
S_
S_
PM
PM
_P
_P
E_
E_
E
E
OD
OD
OD
OD
_M
_M
_M
_M
_M
_M
_M
_M
AM
AM
RA
RA
SR
SR
S
_S
N_
N_
N_
IN
AI
AI
AI
RA
TR
TR
TR
ST
NS
NS
N
ON
CO
CO
CO
C
S_
S_
S_
S_
M
M
_P
_P
_P
_P
S0
S0
S0
S
I2
I2
I2
I
I_
I_
I_
I_
ER
ER
ER
ER
BP
BP
BP
BP
AP
AP
AP
AP
Submit Documentation Feedback
A_
A_
A_
A_
)
ed
DM
DM
DM
DM
rv
S_
S_
S_
S_
se
PM
PM
PM
PM
(re
31 8 7 6 5 4 3 2 1 0
GoBack
Espressif Systems
CK
LO
N_
RAI
ST
ON
C
S_
PM
S_
AE
I_
ER
BP
AP
A_
)
ed
DM
rv
S_
se
PM
(re
31 1 0
Submit Documentation Feedback
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_APBPERI_AES_PMS_CONSTRAIN_LOCK Set this bit to lock AES’s DMA permission configuration register. (R/WL)
338
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
3
1
S_
S_
S_
S_
PM
PM
_P
_P
E_
E_
DE
E
OD
OD
OD
O
_M
_M
_M
_M
_M
_M
_M
_M
AM
AM
AM
RA
SR
SR
SR
S
N_
N_
N_
N_
AI
AI
AI
RA
TR
TR
TR
ST
NS
NS
NS
ON
CO
CO
CO
C
S_
S_
S_
S
PM
PM
_P
_P
S_
S_
ES
ES
AE
AE
A
A
I_
I_
I_
I_
ER
ER
ER
ER
BP
BP
BP
BP
AP
AP
AP
AP
Submit Documentation Feedback
A_
A_
A_
A_
)
ed
DM
DM
DM
DM
rv
S_
S_
S_
S_
se
PM
PM
PM
PM
(re
31 8 7 6 5 4 3 2 1 0
GoBack
Espressif Systems
KC
LO
N_
AI
TR
NS
CO
S_
PM
A_
SH
I_
ER
BP
AP
A_
)
ed
DM
rv
S_
se
PM
(re
31 1 0
Submit Documentation Feedback
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_APBPERI_SHA_PMS_CONSTRAIN_LOCK Set this bit to lock SHA’s DMA permission configuration register. (R/WL)
340
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
3
1
S_
S_
S_
S_
PM
PM
_P
_P
E_
E_
DE
E
OD
OD
OD
O
_M
_M
_M
_M
_M
_M
_M
_M
AM
AM
AM
A
SR
SR
SR
SR
N_
N_
N_
N_
AI
AI
AI
AI
TR
TR
TR
TR
NS
NS
NS
ON
CO
CO
CO
C
S_
S_
S_
S_
PM
PM
_P
_P
A_
A_
HA
HA
SH
SH
S
S
I_
I_
I_
I_
ER
ER
ER
ER
BP
BP
BP
BP
AP
AP
AP
AP
Submit Documentation Feedback
A_
A_
A_
A_
)
ed
DM
DM
DM
DM
rv
S_
S_
S_
S_
se
PM
PM
PM
PM
(re
31 8 7 6 5 4 3 2 1 0
GoBack
Espressif Systems
CK
LO
N_
AI
TR
NS
CO
S_
MP
C_
DA
C_
AD
I_
ER
BP
AP
A_
)
ed
DM
rv
S_
se
PM
(re
Submit Documentation Feedback
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_DMA_APBPERI_ADC_DAC_PMS_CONSTRAIN_LOCK Set this bit to lock ADC_DAC’s DMA permission configuration register. (R/WL)
342
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
3
1
S_
S_
S_
S_
PM
PM
P
_P
E_
E_
E_
E
OD
OD
OD
OD
_M
_M
_M
_M
_M
_M
_M
_M
AM
AM
AM
RA
SR
SR
SR
_S
N_
N_
N_
N
AI
AI
AI
AI
TR
TR
TR
ST
NS
NS
NS
ON
CO
CO
CO
_C
S_
S_
S_
S
PM
PM
PM
_P
C_
C_
C
AC
DA
DA
DA
_D
C_
C_
DC
DC
AD
AD
A
A
I_
I_
I_
I_
ER
ER
ER
ER
Submit Documentation Feedback
BP
BP
BP
BP
AP
AP
AP
AP
A_
A_
A_
A_
)
ed
DM
DM
DM
DM
rv
S_
S_
S_
S_
se
PM
PM
PM
PM
(re
31 8 7 6 5 4 3 2 1 0
343
GoBack
Espressif Systems
K
OC
_L
OR
IT
ON
M
S_
PM
I_
ER
BP
AP
A_
)
ed
DM
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Submit Documentation Feedback
PMS_DMA_APBPERI_PMS_MONITOR_LOCK Set this bit to lock DMA access interrupt configuration register. (R/WL)
344
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
LR
TE N
_C
LA E
IO E_
_V LAT
OR O
IT _VI
ON R
M ITO
S_ ON
PM M
I_ S_
ER PM
BP I_
AP ER
A_ PBP
DM _ A
S_ MA
)
ed
PM _D
rv
se
S
PM
(re
31 2 1 0
Submit Documentation Feedback
0 0 0 0 0 0 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
PMS_DMA_APBPERI_PMS_MONITOR_VIOLATE_CLR Set this bit to clear DMA access interrupt status. (R/WL)
PMS_DMA_APBPERI_PMS_MONITOR_VIOLATE_EN Set this bit to enable interrupt upon illegal DMA access. (R/WL)
345
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
KC
LO
N_
AI
R
ST
ON
_C
NE
LI
T_
LI
SP
A_
DM
0_
AM
DR
0_
AM
IR
X_
E_
Submit Documentation Feedback
OR
ed
C
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
346
PMS_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_LOCK Set this bit to lock internal SRAM’s split lines configuration. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
1
Y_
Y_
Y_
DR
OR
OR
OR
D
TA
EG
EG
EG
LI
AT
AT
AT
P
_C
_C
_C
_S
AM
AM
AM
AM
SR
SR
SR
SR
A_
A_
A_
A_
DM
DM
DM
DM
0_
0_
0_
0_
M
AM
AM
AM
A
DR
DR
DR
DR
0_
0_
0_
0_
M
AM
M
RA
RA
RA
IR
_I
_I
_I
_
_X
_X
_X
_X
RE
RE
RE
)
OR
ed
ed
CO
CO
CO
C
rv
rv
S_
S_
S_
S_
se
se
PM
PM
PM
PM
(re
(re
Submit Documentation Feedback
31 22 21 14 13 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_0 Configures Block0’s category field for the instruction and data split line
347
IRAM0_DRAM0_Split_Line. (R/WL)
PMS_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_1 Configures Block1’s category field for the instruction and data split line
IRAM0_DRAM0_Split_Line. (R/WL)
PMS_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_2 Configures Block2’s category field for the instruction and data split line
IRAM0_DRAM0_Split_Line. (R/WL)
PMS_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR Configures the split address of the instruction and data split line IRAM0_DRAM0_Split_Line.
(R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
_2
_0
1
Y_
DR
RY
RY
OR
AD
GO
GO
EG
IT
TE
TE
PL
AT
CA
CA
_C
S
0_
0_
0_
_0
E_
E_
E_
E
IN
IN
IN
IN
_L
_L
_L
_
AM
AM
AM
A
SR
SR
SR
SR
0_
0_
0_
0_
M
AM
M
RA
RA
RA
IR
_I
_I
_I
_
_X
_X
_X
_X
RE
RE
RE
)
OR
ed
ed
CO
CO
CO
C
rv
rv
S_
S_
S_
S_
se
se
PM
PM
PM
PM
(re
(re
31 22 21 14 13 6 5 4 3 2 1 0
Submit Documentation Feedback
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_CORE_X_IRAM0_SRAM_LINE_0_CATEGORY_0 Configures Block0’s category field for the instruction internal split line IRAM0_Split_Line_0. (R/WL)
348
PMS_CORE_X_IRAM0_SRAM_LINE_0_CATEGORY_1 Configures Block1’s category field for the instruction internal split line IRAM0_Split_Line_0. (R/WL)
PMS_CORE_X_IRAM0_SRAM_LINE_0_CATEGORY_2 Configures Block2’s category field for the instruction internal split line IRAM0_Split_Line_0. (R/WL)
PMS_CORE_X_IRAM0_SRAM_LINE_0_SPLITADDR Configures the split address of the instruction internal split line IRAM0_Split_Line_0. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
_2
_0
1
Y_
R
RY
RY
DD
OR
GO
GO
TA
G
TE
TE
TE
LI
SP
CA
CA
CA
1_
1_
1_
1_
E_
E_
E_
E_
IN
IN
IN
IN
_L
_L
_L
_
AM
AM
AM
A
SR
SR
SR
SR
0_
0_
0_
0_
M
AM
M
RA
RA
RA
IR
_I
_I
_I
_
_X
_X
_X
_X
RE
RE
RE
)
OR
ed
ed
CO
CO
CO
C
rv
rv
S_
S_
S_
S_
se
se
PM
PM
PM
PM
(re
(re
31 22 21 14 13 6 5 4 3 2 1 0
Submit Documentation Feedback
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_CORE_X_IRAM0_SRAM_LINE_1_CATEGORY_0 Configures Block0’s category field for the instruction internal split line IRAM0_Split_Line_1. (R/WL)
PMS_CORE_X_IRAM0_SRAM_LINE_1_CATEGORY_1 Configures Block1’s category field for the instruction internal split line IRAM0_Split_Line_1. (R/WL)
349
PMS_CORE_X_IRAM0_SRAM_LINE_1_CATEGORY_2 Configures Block2’s category field for the instruction internal split line IRAM0_Split_Line_1. (R/WL)
PMS_CORE_X_IRAM0_SRAM_LINE_1_SPLITADDR Configures the split address of the instruction internal split line IRAM0_Split_Line_1. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
_2
_0
1
Y_
DR
RY
RY
OR
AD
GO
GO
EG
IT
TE
TE
PL
AT
CA
CA
_C
_S
0_
0_
_0
0
E_
E_
E_
E
IN
IN
IN
IN
_L
_L
_L
_L
AM
AM
AM
RA
SR
SR
SR
_S
A_
A_
A_
A
M
DM
DM
D
D
0_
0_
0_
0_
AM
AM
M
RA
RA
R
DR
_D
_D
_D
_
_X
_X
_X
_X
RE
RE
RE
)
OR
ed
ed
CO
CO
CO
C
rv
rv
S_
S_
S_
S_
se
se
PM
PM
PM
PM
(re
(re
Submit Documentation Feedback
31 22 21 14 13 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_CORE_X_DRAM0_DMA_SRAM_LINE_0_CATEGORY_0 Configures Block0’s category field for data internal split line DRAM0_Split_Line_0. (R/WL)
350
PMS_CORE_X_DRAM0_DMA_SRAM_LINE_0_CATEGORY_1 Configures Block1’s category field for data internal split line DRAM0_Split_Line_0. (R/WL)
PMS_CORE_X_DRAM0_DMA_SRAM_LINE_0_CATEGORY_2 Configures Block2’s category field for data internal split line DRAM0_Split_Line_0. (R/WL)
PMS_CORE_X_DRAM0_DMA_SRAM_LINE_0_SPLITADDR Configures the split address of data internal split line DRAM0_Split_Line_0. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
_2
_0
_1
R
RY
RY
RY
DD
GO
GO
GO
TA
TE
TE
TE
LI
P
CA
CA
CA
_S
1_
1_
1_
_1
E_
E_
E_
E
IN
IN
IN
IN
_L
_L
_L
_L
AM
AM
AM
RA
SR
SR
SR
_S
A_
A_
A_
A
M
DM
DM
D
D
0_
0_
0_
0_
AM
AM
M
RA
RA
R
DR
_D
_D
_D
_
_X
_X
_X
_X
RE
RE
RE
)
OR
ed
ed
CO
CO
CO
C
rv
rv
S_
S_
S_
S_
se
se
PM
PM
PM
PM
(re
(re
Submit Documentation Feedback
31 22 21 14 13 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_CORE_X_DRAM0_DMA_SRAM_LINE_1_CATEGORY_0 Configures Block0’s category field for data internal split line DRAM0_Split_Line_1. (R/WL)
351
PMS_CORE_X_DRAM0_DMA_SRAM_LINE_1_CATEGORY_1 Configures Block1’s category field for data internal split line DRAM0_Split_Line_1. (R/WL)
PMS_CORE_X_DRAM0_DMA_SRAM_LINE_1_CATEGORY_2 Configures Block2’s category field for data internal split line DRAM0_Split_Line_1. (R/WL)
PMS_CORE_X_DRAM0_DMA_SRAM_LINE_1_SPLITADDR Configures the split address of data internal split line DRAM0_Split_Line_1. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
K
OC
_L
IN
RA
ST
ON
C
S_
PM
0_
AM
IR
X_
E_
)
OR
ed
C
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Submit Documentation Feedback
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_LOCK Set this bit to lock the permission of CPU IBUS to internal SRAM. (R/WL)
352
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
S_
M
_P
AY
RR
AA
AT
ED
0
3
1
S_
S_
S_
S_
CH
S
PM
PM
PM
PM
CA
PM
E_
E_
E_
E_
E_
DE
OD
OD
OD
OD
OD
O
_M
_M
_M
_M
_M
_
_U
_U
_U
_U
_U
_U
AM
AM
AM
AM
M
RA
RO
SR
SR
SR
SR
S
_
N_
N_
N_
N_
IN
IN
AI
AI
AI
AI
A
A
TR
TR
TR
TR
TR
ST
NS
NS
NS
ON
ON
ON
CO
CO
CO
_C
_C
C
S_
S_
S_
S_
S
S
Submit Documentation Feedback
PM
PM
PM
PM
PM
PM
0_
0_
0_
0_
0_
0_
AM
AM
AM
M
RA
RA
RA
R
R
_I
_I
_I
_I
_I
_I
X
_X
_X
_X
E_
E_
E_
RE
RE
RE
)
)
OR
OR
OR
ed
ed
CO
CO
CO
C
C
rv
rv
S_
S_
S_
S_
S_
S_
se
se
353
PM
PM
PM
PM
PM
PM
(re
(re
31 21 20 18 17 15 14 12 11 9 8 6 5 3 2 0
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_U_MODE_PMS_0 Configures the permission of CPU’s IBUS to instruction region0 of SRAM from the
unpriviledged environment. (R/WL)
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_U_MODE_PMS_1 Configures the permission of CPU’s IBUS to instruction region1 of SRAM from the
unpriviledged environment. (R/WL)
ESP32-C3 TRM (Version 1.1)
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_U_MODE_PMS_2 Configures the permission of CPU’s IBUS to instruction region2 of SRAM from the
unpriviledged environment. (R/WL)
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_U_MODE_PMS_3 Configures the permission of CPU’s IBUS to data region of SRAM from the unpriv-
iledged environment. (R/WL)
GoBack
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_U_MODE_CACHEDATAARRAY_PMS_0 Configure the permission of CPU’s IBUS to SRAM0 from the un-
priviledged environment. (R/WL)
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_ROM_U_MODE_PMS Configure the permission of CPU’s IBUS to ROM from the unpriviledged environment.
(R/WL)
Espressif Systems
0
S_
M
_P
AY
RR
AA
AT
ED
0
3
1
S_
S_
S_
S_
CH
S
PM
CA
PM
_P
_P
_P
E_
E_
E_
DE
DE
DE
OD
OD
OD
O
_M
_M
_M
_M
_M
_M
_M
_M
_M
_M
_M
_M
AM
AM
AM
AM
AM
M
RO
SR
SR
SR
SR
SR
_
N_
N_
N_
N_
IN
N
AI
AI
AI
AI
AI
A
TR
TR
TR
TR
ST
ST
NS
NS
NS
ON
ON
ON
CO
CO
CO
_C
_C
S_
S_
S_
S_
Submit Documentation Feedback
S
PM
PM
PM
PM
PM
PM
0_
0_
0_
0_
0_
0_
AM
AM
AM
M
RA
RA
RA
R
R
_I
_I
_I
_I
_I
_I
X
_X
_X
_X
E_
E_
E_
RE
RE
RE
)
)
OR
OR
OR
ed
ed
CO
CO
CO
C
C
rv
rv
S_
S_
S_
S_
S_
S_
354
se
se
PM
PM
PM
PM
PM
PM
(re
(re
31 21 20 18 17 15 14 12 11 9 8 6 5 3 2 0
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_M_MODE_PMS_0 Configures the permission of CPU’s IBUS to instruction region0 of SRAM from the
privileged environment (R/WL)
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_M_MODE_PMS_1 Configures the permission of CPU’s IBUS to instruction region1 of SRAM from the
privileged environment (R/WL)
ESP32-C3 TRM (Version 1.1)
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_M_MODE_PMS_2 Configures the permission of CPU’s IBUS to instruction region2 of SRAM from the
privileged environment (R/WL)
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_M_MODE_PMS_3 Configures the permission of CPU’s IBUS to data region of SRAM from the privileged
environment (R/WL)
GoBack
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_M_MODE_CACHEDATAARRAY_PMS_0 Configures the permission of CPU’s IBUS to SRAM0 from the
privileged environment (R/WL)
PMS_CORE_X_IRAM0_PMS_CONSTRAIN_ROM_M_MODE_PMS Configures the permission of CPU’s IBUS to ROM from the privileged environment
(R/WL)
Espressif Systems
K
OC
_L
OR
IT
ON
M
S_
MP
0_
AM
IR
0_
E_
)
OR
ed
C
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Submit Documentation Feedback
PMS_CORE_0_IRAM0_PMS_MONITOR_LOCK Set this bit to lock CPU0’s IBUS interrupt configuration. (R/WL)
355
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
LR
TE N
_C
LA E
IO E_
_V LAT
OR O
IT _VI
ON R
M ITO
S_ ON
PM _M
0_ S
M PM
RA _
_I M0
_0 RA
RE _I
CO _0
S_ ORE
)
ed
PM _C
rv
se
S
PM
(re
31 2 1 0
Submit Documentation Feedback
0 0 0 0 0 0 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
PMS_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_CLR Set this bit to clear the interrupt triggered when CPU0’s IBUS tries to access SRAM or ROM unau-
thorized. (R/WL)
356
PMS_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_EN Set this bit to enable interrupt when CPU0’s IBUS tries to access SRAM or ROM unauthorized.
(R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
KC
LO
N_
AI
TR
NS
CO
S_
PM
0_
AM
DR
X_
E_
)
OR
ed
C
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Submit Documentation Feedback
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_LOCK Set this bit to lock the permission of CPU DBUS to internal SRAM. (R/WL)
357
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
3
2
0
3
1
1
S_
S_
S_
S_
S_
S_
S_
S_
S
PM
PM
S
PM
PM
PM
PM
_P
_P
P
_P
E_
E_
E_
E_
E_
E_
DE
E
E_
OD
OD
OD
OD
OD
OD
OD
OD
O
OD
_M
_M
_M
_M
_M
_M
_M
_M
M
_M
_M
_M
_M
_M
_U
_U
_U
_U
_M
_U
AM
AM
AM
M
OM
RA
RA
RA
RA
RA
RO
SR
SR
SR
_R
_S
_S
S
N_
N_
N_
N_
N_
N
IN
IN
IN
IN
AI
AI
AI
AI
AI
AI
RA
RA
A
TR
TR
TR
TR
TR
TR
TR
TR
ST
T
NS
NS
NS
NS
NS
NS
NS
NS
NS
ON
CO
CO
CO
CO
CO
CO
CO
C
_C
_C
S_
S_
S_
S_
S_
S_
S_
S_
S
S
PM
PM
PM
PM
PM
PM
PM
PM
_P
P
0_
0_
0_
0_
0_
0_
0_
0_
0_
0
AM
M
RA
RA
RA
RA
RA
RA
RA
RA
RA
DR
_D
_D
_D
_D
_D
_D
_D
_D
_D
X_
_X
_X
_X
_X
_X
_X
_X
_X
_X
E_
RE
RE
RE
RE
RE
RE
RE
RE
RE
)
)
Submit Documentation Feedback
OR
ed
ed
ed
CO
CO
CO
CO
CO
CO
CO
CO
CO
C
rv
rv
rv
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
se
se
se
PM
PM
PM
PM
PM
PM
PM
PM
PM
PM
(re
(re
(re
31 28 27 26 25 24 23 20 19 18 17 16 15 14 13 12 11 8 7 6 5 4 3 2 1 0
0 0 0 0 0x3 0x3 0 0 0 0 0x3 0x3 0x3 0x3 0 0 0 0 0x3 0x3 0x3 0x3 Reset
358
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_M_MODE_PMS_0 Configures the permission of CPU’s DBUS to instruction region of SRAM from the
privileged environment It’s advised to configure this field to 0. (R/WL)
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_M_MODE_PMS_1 Configures the permission of CPU’s DBUS to data region0 of SRAM from the privi-
leged environment (R/WL)
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_M_MODE_PMS_2 Configures the permission of CPU’s DBUS to data region1 of SRAM from the privi-
leged environment (R/WL)
ESP32-C3 TRM (Version 1.1)
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_M_MODE_PMS_3 Configures the permission of CPU’s DBUS to data region2 of SRAM from the priv-
ileged environment (R/WL)
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_U_MODE_PMS_0 Configures the permission of CPU’s DBUS to instruction region of SRAM from the
privileged environment It’s advised to configure this field to 0. (R/WL)
GoBack
Continued on the next page...
Espressif Systems
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_U_MODE_PMS_1 Configures the permission of CPU’s DBUS to data region0 of SRAM from the privi-
leged environment (R/WL)
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_U_MODE_PMS_2 Configures the permission of CPU’s DBUS to data region1 of SRAM from the privi-
leged environment (R/WL)
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_U_MODE_PMS_3 Configures the permission of CPU’s DBUS to data region2 of SRAM from the privi-
leged environment (R/WL)
Submit Documentation Feedback
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_ROM_M_MODE_PMS Configures the permission of CPU’s DBUS to ROM from the privileged environment
(R/WL)
PMS_CORE_X_DRAM0_PMS_CONSTRAIN_ROM_U_MODE_PMS Configures the permission of CPU’s DBUS to ROM from the unpriviledged environment.
359
(R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
CK
LO
R_
O
IT
ON
M
S_
MP
0_
AM
DR
0_
E_
)
OR
ed
C
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Submit Documentation Feedback
PMS_CORE_0_DRAM0_PMS_MONITOR_LOCK Set this bit to lock CPU’s DBUS interrupt configuration. (R/WL)
360
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
LR
TE N
_C
LA E
IO E_
_V LAT
OR O
IT _VI
ON R
M ITO
S_ ON
PM _M
0_ S
M PM
RA 0_
_D M
_0 RA
RE _D
CO _0
S_ ORE
)
ed
PM _C
rv
se
S
PM
(re
31 2 1 0
Submit Documentation Feedback
0 0 0 0 0 0 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
PMS_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_CLR Set this bit to clear the interrupt triggered when CPU0’s dBUS tries to access SRAM or ROM
unauthorized. (R/WL)
361
PMS_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_EN Set this bit to enable interrupt when CPU0’s dBUS tries to access SRAM or ROM unauthorized.
(R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
CK
LO
N_
AI
TR
NS
CO
S_
PM
F_
PI
0_
E_
)
OR
ed
C
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Submit Documentation Feedback
PMS_CORE_0_PIF_PMS_CONSTRAIN_LOCK Set this bit to lock CPU permission to different peripherals. (R/WL)
362
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
1
UX
I_
I_
1
SP
SP
_M
RT
RT
IO
C
G0
G0
GP
UA
UA
RT
IO
E_
E_
E_
E_
E_
E_
E_
OD
OD
OD
OD
OD
OD
OD
_M
_M
_M
_M
_M
_M
_M
M
M
_
N_
N_
N_
N_
N_
N_
IN
AI
AI
AI
AI
AI
AI
A
TR
TR
TR
TR
TR
TR
TR
NS
NS
NS
NS
NS
NS
ON
CO
CO
CO
CO
CO
CO
C
S_
S_
S_
S_
S_
S_
S_
M
PM
PM
PM
PM
PM
PM
P
IF_
F_
IF_
IF_
IF_
IF_
IF_
PI
_P
_P
_P
_P
_P
_P
0_
_0
_0
_0
_0
_0
_0
E_
RE
RE
RE
RE
RE
RE
)
)
OR
ed
ed
CO
CO
CO
CO
CO
CO
C
rv
rv
S_
S_
S_
S_
S_
S_
S_
se
se
PM
PM
PM
PM
PM
PM
PM
(re
(re
Submit Documentation Feedback
31 30 29 18 17 16 15 14 13 8 7 6 5 4 3 2 1 0
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_UART Configures CPU’s permission to access UART 0 from the privileged environment (R/WL)
363
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_G0SPI_1 Configures CPU’s permission to access SPI 1 from the privileged environment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_G0SPI_0 Configures CPU’s permission to access SPI 0 from the privileged environment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_GPIO Configures CPU’s permission to access GPIO from the privileged environment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_RTC Configures CPU’s permission to access eFuse Controller & PMU from the privileged environment
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_IO_MUX Configures CPU’s permission to access IO_MUX from the privileged environment (R/WL)
ESP32-C3 TRM (Version 1.1)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_UART1 Configures CPU’s permission to access UART 1 from the privileged environment (R/WL)
GoBack
Espressif Systems
P1
P
OU
OU
ER
T0
GR
GR
IM
EX
0
ER
ER
DC
ST
CI
C_
T
M
RM
UH
SY
LE
I2
TI
TI
E_
E_
E_
E_
E_
E_
E_
OD
OD
OD
OD
OD
OD
OD
_M
_M
_M
_M
_M
_M
_M
M
_M
_M
_M
N_
N_
N_
N_
IN
IN
AI
AI
AI
AI
AI
RA
RA
TR
TR
TR
TR
TR
T
ST
NS
NS
NS
NS
NS
NS
ON
CO
CO
CO
CO
CO
CO
C
S_
S_
S_
S_
S_
S_
S_
PM
PM
PM
PM
PM
PM
P
IF_
IF_
IF_
IF_
F_
IF_
IF_
I
_P
_P
_P
_P
_P
_P
_P
_0
_0
_0
_0
_0
_0
_0
RE
RE
RE
RE
RE
RE
RE
)
)
ed
ed
ed
ed
CO
CO
CO
CO
CO
CO
CO
rv
rv
rv
rv
S_
S_
S_
S_
S_
S_
S_
Submit Documentation Feedback
se
se
se
se
PM
PM
PM
PM
PM
PM
PM
(re
(re
(re
(re
31 30 29 28 27 26 25 18 17 16 15 12 11 10 9 8 7 6 5 4 3 0
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_I2C_EXT0 Configures CPU’s permission to access I2C 0 from the privileged environment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_UHCI0 Configures CPU’s permission to access UHCI 0 from the privileged environment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_RMT Configures CPU’s permission to access Remote Control Peripheral from the privileged environ-
ment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_LEDC Configures CPU’s permission to access LED PWM Controller from the privileged environment
(R/WL)
ESP32-C3 TRM (Version 1.1)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_TIMERGROUP Configures CPU’s permission to access Timer Group 0 from the privileged environment
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_TIMERGROUP1 Configures CPU’s permission to access Timer Group 1 from the privileged environment
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_SYSTIMER Configures CPU’s permission to access System Timer from the privileged environment
GoBack
(R/WL)
Espressif Systems
RL
CT
2
B_
I_
N
S1
AP
SP
CA
I2
E_
E_
E_
E_
OD
OD
OD
OD
_M
_M
_M
_M
M
_M
M
N_
N_
N_
IN
AI
AI
AI
RA
TR
TR
TR
T
NS
NS
NS
NS
CO
CO
CO
CO
S_
S_
S_
S_
PM
PM
PM
PM
F_
IF_
IF_
IF_
PI
_P
_P
_P
0_
_0
_0
_0
E_
RE
RE
RE
)
)
OR
ed
ed
ed
ed
CO
CO
CO
C
rv
rv
rv
rv
S_
S_
S_
S_
se
se
se
se
PM
PM
PM
PM
(re
(re
(re
(re
Submit Documentation Feedback
31 16 15 14 13 12 11 10 9 6 5 4 3 2 1 0
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_SPI_2 Configures CPU’s permission to access SPI 2 from the privileged environment (R/WL)
365
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_APB_CTRL Configures CPU’s permission to access APB Controller from the privileged environment
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_CAN Configures CPU’s permission to access Two-wire Automotive Interface from the privileged envi-
ronment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_I2S1 Configures CPU’s permission to access I2S 1 from the privileged environment (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
G
FI
I
ER
CE
DM
ON
P
_P
UP
VI
RA
C
_C
O_
AD
DE
EM
TO
RR
W
HE
PT
B_
B_
B_
YP
ST
TE
S
AC
RY
PM
AD
US
CR
US
AP
SY
IN
_C
C
E_
E_
E_
E_
E_
E_
E_
E_
E_
DE
OD
OD
OD
OD
OD
OD
OD
O
O
_M
_M
_M
_M
_M
_M
_M
_M
_M
_
M
_M
_M
_M
M
N_
N_
N_
N_
N_
N
IN
IN
IN
IN
AI
AI
AI
AI
AI
AI
RA
RA
RA
RA
TR
TR
TR
TR
TR
T
T
NS
NS
NS
NS
NS
NS
NS
NS
NS
NS
CO
CO
CO
CO
CO
CO
CO
CO
CO
CO
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
PM
PM
PM
PM
PM
PM
PM
PM
PM
P
IF_
IF_
IF_
IF_
IF_
IF_
IF_
IF_
IF_
IF_
P
_P
_P
_P
_P
_P
_P
_P
_P
_P
0_
_0
_0
_0
_0
_0
_0
_0
_0
_0
E_
RE
RE
RE
RE
RE
RE
RE
RE
RE
)
)
OR
ed
ed
ed
ed
CO
CO
CO
CO
CO
CO
CO
CO
CO
C
rv
rv
rv
rv
Submit Documentation Feedback
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
se
se
se
se
PM
PM
PM
PM
PM
PM
PM
PM
PM
PM
(re
(re
(re
(re
31 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0x3 0x3 0 0 0x3 0x3 0x3 0x3 0 0 0 0 0x3 0x3 0x3 0x3 0 0 Reset
366
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_USB_WRAP Configures CPU’s permission to access USB OTG External from the privileged environment
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_CRYPTO_PERI Configures CPU’s permission to access Accelerators from the privileged environment
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_CRYPTO_DMA Configures CPU’s permission to access GDMA from the privileged environment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_APB_ADC Configures CPU’s permission to access ADC Controller from the privileged environment
ESP32-C3 TRM (Version 1.1)
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_USB_DEVICE Configures CPU’s permission to access USB OTG Core from the privileged environment
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_SYSTEM Configures CPU’s permission to access System Registers from the privileged environment
GoBack
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_PMS Configures CPU’s permission to access PMS Registers from the privileged environment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_INTERRUPT Configures CPU’s permission to access Interrupt Matrix from the privileged environment
(R/WL)
Espressif Systems
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_CACHE_CONFIG Configures CPU’s permission to access Cache & XTS_AES from the privileged envi-
ronment (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_M_MODE_AD Configures CPU’s permission to access Debug Assist from the privileged environment (R/WL)
Submit Documentation Feedback
367
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
_0
1
UX
I_
PI
1
SP
_M
RT
RT
IO
0S
TC
G0
GP
UA
UA
IO
_G
_R
E_
E_
E_
E_
E_
DE
E
OD
OD
OD
OD
OD
OD
O
_M
M
U_
U_
U_
U_
U_
U_
_U
N_
N_
N_
N_
N_
N_
IN
AI
AI
AI
AI
AI
AI
A
TR
TR
TR
TR
TR
TR
TR
NS
NS
NS
NS
NS
NS
ON
CO
CO
CO
CO
CO
CO
C
S_
S_
S_
S_
S_
S_
S_
M
PM
PM
PM
PM
PM
PM
P
IF_
F_
IF_
IF_
IF_
IF_
IF_
PI
_P
_P
_P
_P
_P
_P
0_
_0
_0
_0
_0
_0
_0
E_
RE
RE
RE
RE
RE
RE
)
)
OR
ed
ed
CO
CO
CO
CO
CO
CO
C
rv
rv
S_
S_
S_
S_
S_
S_
S_
se
se
PM
PM
PM
PM
PM
PM
PM
(re
(re
Submit Documentation Feedback
31 30 29 18 17 16 15 14 13 8 7 6 5 4 3 2 1 0
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_UART Configures CPU’s permission to access UART 0 from the unpriviledged environment. (R/WL)
368
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_G0SPI_1 Configures CPU’s permission to access SPI 1 from the unpriviledged environment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_G0SPI_0 Configures CPU’s permission to access SPI 0 from the unpriviledged environment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_GPIO Configures CPU’s permission to access GPIO from the unpriviledged environment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_RTC Configures CPU’s permission to access eFuse Controller & PMU from the unpriviledged environ-
ment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_IO_MUX Configures CPU’s permission to access IO_MUX from the unpriviledged environment. (R/WL)
ESP32-C3 TRM (Version 1.1)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_UART1 Configures CPU’s permission to access UART 1 from the unpriviledged environment. (R/WL)
GoBack
Espressif Systems
P1
P
OU
OU
ER
T0
GR
GR
IM
EX
0
ER
ER
DC
ST
CI
C_
T
M
RM
UH
SY
LE
I2
TI
TI
E_
E_
E_
E_
E_
E_
DE
OD
OD
OD
OD
OD
OD
O
M
_M
_M
_M
U_
U_
U_
U
_U
_U
_U
N_
N_
N_
N_
IN
IN
IN
AI
AI
AI
AI
RA
RA
RA
TR
TR
TR
TR
ST
ST
NS
NS
NS
NS
NS
N
ON
CO
CO
CO
CO
CO
CO
C
S_
S_
S_
S_
S_
S_
S_
PM
PM
PM
PM
PM
PM
PM
IF_
IF_
IF_
IF_
IF_
IF_
IF_
_P
_P
_P
_P
_P
_P
_P
_0
_0
_0
_0
_0
_0
_0
RE
RE
RE
RE
RE
RE
RE
)
)
ed
ed
ed
ed
CO
CO
CO
CO
CO
CO
CO
rv
rv
rv
rv
S_
S_
S_
S_
S_
S_
S_
se
se
se
se
Submit Documentation Feedback
PM
PM
PM
PM
PM
PM
PM
(re
(re
(re
(re
31 30 29 28 27 26 25 18 17 16 15 12 11 10 9 8 7 6 5 4 3 0
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_I2C_EXT0 Configures CPU’s permission to access I2C 0 from the unpriviledged environment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_UHCI0 Configures CPU’s permission to access UHCI 0 from the unpriviledged environment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_RMT Configures CPU’s permission to access Remote Control Peripheral from the unpriviledged envi-
ronment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_LEDC Configures CPU’s permission to access LED PWM Controller from the unpriviledged environment.
(R/WL)
ESP32-C3 TRM (Version 1.1)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_TIMERGROUP Configures CPU’s permission to access Timer Group 0 from the unpriviledged environ-
ment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_TIMERGROUP1 Configures CPU’s permission to access Timer Group 1 from the unpriviledged environ-
ment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_SYSTIMER Configures CPU’s permission to access System Timer from the unpriviledged environment.
GoBack
(R/WL)
Espressif Systems
RL
CT
2
B_
I_
N
S1
AP
SP
CA
I2
E_
E_
E_
E_
OD
OD
OD
OD
M
M
U_
U_
U_
U_
N_
N_
N_
N_
AI
AI
AI
AI
TR
TR
TR
TR
NS
NS
NS
NS
CO
CO
CO
CO
S_
S_
S_
S_
PM
PM
PM
PM
F_
IF_
IF_
IF_
PI
_P
_P
_P
0_
_0
_0
_0
E_
RE
RE
RE
)
)
OR
ed
ed
ed
ed
CO
CO
CO
C
rv
rv
rv
rv
S_
S_
S_
S_
se
se
se
se
PM
PM
PM
PM
(re
(re
(re
(re
Submit Documentation Feedback
31 16 15 14 13 12 11 10 9 6 5 4 3 2 1 0
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_SPI_2 Configures CPU’s permission to access SPI 2 from the unpriviledged environment. (R/WL)
370
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_APB_CTRL Configures CPU’s permission to access APB Controller from the unpriviledged environment.
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_CAN Configures CPU’s permission to access Two-wire Automotive Interface from the unpriviledged
environment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_I2S1 Configures CPU’s permission to access I2S 1 from the unpriviledged environment. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
G
FI
I
ER
E
DM
ON
IC
T
P
_P
UP
RA
C
_C
EV
O_
AD
M
TO
RR
W
_D
HE
PT
TE
B_
B_
YP
TE
SB
AC
RY
YS
M
AD
CR
US
AP
IN
_U
_C
C
_P
_S
E_
E_
E_
E_
E_
E_
DE
DE
E
OD
OD
OD
OD
OD
OD
OD
OD
O
O
M
_M
_M
M
U_
U_
U_
U_
U_
U_
U_
U_
_U
_U
N_
N_
N_
N_
N_
N_
N_
N
IN
AI
AI
AI
AI
AI
AI
AI
AI
RA
RA
TR
TR
TR
TR
TR
T
T
NS
NS
NS
NS
NS
NS
NS
NS
NS
NS
CO
CO
CO
CO
CO
CO
CO
CO
CO
C
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
PM
PM
PM
PM
PM
PM
PM
PM
PM
P
IF_
IF_
IF_
IF_
IF_
IF_
IF_
IF_
IF_
IF_
P
_P
_P
_P
_P
_P
_P
_P
_P
_P
0_
_0
_0
_0
_0
_0
_0
_0
_0
_0
E_
RE
RE
RE
RE
RE
RE
RE
RE
RE
)
)
OR
ed
ed
ed
ed
CO
CO
CO
CO
CO
CO
CO
CO
CO
C
rv
rv
rv
rv
Submit Documentation Feedback
S_
S_
S_
S_
S_
S_
S_
S_
S_
S_
se
se
se
se
PM
PM
PM
PM
PM
PM
PM
PM
PM
PM
(re
(re
(re
(re
31 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0x3 0x3 0 0 0x3 0x3 0x3 0x3 0 0 0 0 0x3 0x3 0x3 0x3 0 0 Reset
371
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_USB_WRAP Configures CPU’s permission to access USB OTG External from the unpriviledged environ-
ment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_CRYPTO_PERI Configures CPU’s permission to access Accelerators from the unpriviledged environ-
ment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_CRYPTO_DMA Configures CPU’s permission to access GDMA from the unpriviledged environment.
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_APB_ADC Configures CPU’s permission to access ADC Controller from the unpriviledged environment.
ESP32-C3 TRM (Version 1.1)
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_USB_DEVICE Configures CPU’s permission to access USB OTG Core from the unpriviledged environ-
ment. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_SYSTEM Configures CPU’s permission to access System Registers from the unpriviledged environment.
GoBack
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_PMS Configures CPU’s permission to access PMS Registers from the unpriviledged environment.
(R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_U_MODE_INTERRUPT Configures CPU’s permission to access Interrupt Matrix from the unpriviledged environ-
ment. (R/WL)
Espressif Systems
E
E
OD
OD
_M
_M
M
_U
R_
DR
DD
AD
TA
LT
PL
P
_S
_S
ST
ST
FA
FA
TC
C
RT
_R
N_
IN
AI
A
TR
TR
NS
NS
CO
CO
S_
S_
PM
PM
IF_
F_
PI
_P
_
_0
_0
RE
RE
Submit Documentation Feedback
)
ed
CO
CO
rv
S_
S_
se
PM
PM
(re
31 22 21 11 10 0
PMS_CORE_0_PIF_PMS_CONSTRAIN_RTCFAST_SPLTADDR_M_MODE Configures the address to split RTC Fast Memory into two regions in unpriv-
iledgeddenvironment for CPU. Note you should use address offset, instead of absolute address. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_RTCFAST_SPLTADDR_U_MODE Configures the address to split RTC Fast Memory into two regions in privilege-
denvironment for CPU. Note you should use address offset, instead of absolute address. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
L
H
E_
E_
E_
E_
OD
OD
OD
OD
_M
_M
M
M
U_
U_
M
T_
T_
T_
T
AS
AS
AS
AS
CF
CF
CF
CF
RT
RT
RT
RT
N_
N_
N_
N_
AI
AI
AI
AI
TR
TR
TR
TR
NS
NS
NS
NS
CO
CO
CO
CO
S_
S_
S_
S_
PM
PM
PM
PM
F_
IF_
IF_
IF_
PI
_P
_P
_P
0_
_0
_0
_0
E_
RE
RE
RE
)
OR
ed
CO
CO
CO
C
rv
S_
S_
S_
S_
se
PM
PM
PM
PM
(re
Submit Documentation Feedback
31 12 11 9 8 6 5 3 2 0
PMS_CORE_0_PIF_PMS_CONSTRAIN_RTCFAST_M_MODE_L Configures the permission of CPU from unpriviledgeddenvironment to the lower region of
373
PMS_CORE_0_PIF_PMS_CONSTRAIN_RTCFAST_M_MODE_H Configures the permission of CPU from unpriviledgeddenvironment to the higher region
of RTC Fast Memory. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_RTCFAST_U_MODE_L Configures the permission of CPU from privilegedenvironment to the lower region of RTC
Fast Memory. (R/WL)
PMS_CORE_0_PIF_PMS_CONSTRAIN_RTCFAST_U_MODE_H Configures the permission of CPU from privilegedenvironment to the higher region of RTC
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
K
OC
_L
IN
RA
ST
ON
C
S_
PM
N_
IO
)
EG
ed
R
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Submit Documentation Feedback
PMS_REGION_PMS_CONSTRAIN_LOCK Set this bit to lock Core0’s permission to peripheral regions. (R/WL)
374
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
_0
_3
4
5
_6
_1
A_
A_
A_
EA
EA
EA
EA
RE
RE
RE
AR
AR
AR
_A
_A
_A
A
E_
E_
E_
E_
DE
E
OD
OD
OD
OD
OD
OD
O
_M
_M
_M
_M
_M
_M
_
M
_M
_M
_M
_M
M
N_
N_
N_
IN
IN
IN
AI
AI
AI
A
RA
RA
TR
TR
TR
ST
ST
ST
ST
NS
NS
NS
ON
ON
ON
ON
CO
CO
CO
_C
_C
_C
C
S_
S_
S_
S_
S
S
PM
PM
M
_P
_P
_P
_P
_P
N_
N_
ON
ON
ON
ON
ON
IO
O
GI
GI
GI
GI
GI
GI
)
EG
ed
RE
RE
RE
RE
RE
RE
R
rv
S_
S_
S_
S_
S_
S_
S_
se
PM
PM
PM
PM
PM
PM
PM
(re
31 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Submit Documentation Feedback
PMS_REGION_PMS_CONSTRAIN_M_MODE_AREA_0 Configures CPU’s permission to Peri Region0 from the privileged environment (R/WL)
375
PMS_REGION_PMS_CONSTRAIN_M_MODE_AREA_1 Configures CPU’s permission to Peri Region1 from the privileged environment (R/WL)
PMS_REGION_PMS_CONSTRAIN_M_MODE_AREA_2 Configures CPU’s permission to Peri Region2 from the privileged environment (R/WL)
PMS_REGION_PMS_CONSTRAIN_M_MODE_AREA_3 Configures CPU’s permission to Peri Region3 from the privileged environment (R/WL)
PMS_REGION_PMS_CONSTRAIN_M_MODE_AREA_4 Configures CPU’s permission to Peri Region4 from the privilegedenvironment (R/WL)
PMS_REGION_PMS_CONSTRAIN_M_MODE_AREA_5 Configures CPU’s permission to Peri Region5 from the privileged environment (R/WL)
PMS_REGION_PMS_CONSTRAIN_M_MODE_AREA_6 Configures CPU’s permission to Peri Region6 from the privileged environment (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
_0
3
_4
_5
_6
_1
A_
A_
EA
EA
EA
EA
EA
RE
RE
AR
AR
AR
AR
AR
A
A
E_
E_
E_
E_
E_
E_
E_
OD
OD
OD
OD
OD
OD
OD
M
_M
_M
_M
_M
M
U_
U_
U_
_U
_U
_U
U
N_
N_
N_
N
IN
IN
IN
AI
AI
AI
AI
A
RA
TR
TR
TR
TR
ST
ST
ST
NS
NS
NS
NS
ON
ON
ON
CO
CO
CO
CO
_C
_C
_C
S_
S_
S_
S_
S
S
PM
PM
M
_P
_P
_P
_P
_P
N_
N_
ON
ON
ON
ON
ON
IO
O
GI
GI
GI
GI
GI
GI
)
EG
ed
RE
RE
RE
RE
RE
RE
R
rv
S_
S_
S_
S_
S_
S_
S_
se
PM
PM
PM
PM
PM
PM
PM
(re
31 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Submit Documentation Feedback
PMS_REGION_PMS_CONSTRAIN_U_MODE_AREA_0 Configures CPU’s permission to Peri Region0 from the unpriviledged environment. (R/WL)
PMS_REGION_PMS_CONSTRAIN_U_MODE_AREA_1 Configures CPU’s permission to Peri Region1 from the unpriviledged environment. (R/WL)
376
PMS_REGION_PMS_CONSTRAIN_U_MODE_AREA_2 Configures CPU’s permission to Peri Region2 from the unpriviledged environment. (R/WL)
PMS_REGION_PMS_CONSTRAIN_U_MODE_AREA_3 Configures CPU’s permission to Peri Region3 from the unpriviledged environment. (R/WL)
PMS_REGION_PMS_CONSTRAIN_U_MODE_AREA_4 Configures CPU’s permission to Peri Region4 from the unpriviledged environment. (R/WL)
PMS_REGION_PMS_CONSTRAIN_U_MODE_AREA_5 Configures CPU’s permission to Peri Region5 from the unpriviledged environment. (R/WL)
PMS_REGION_PMS_CONSTRAIN_U_MODE_AREA_6 Configures CPU’s permission to Peri Region6 from the unpriviledged environment. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
0
R_
DD
_A
IN
RA
ST
ON
C
S_
M
N_P
IO
)
EG
ed
R
rv
S_
se
PM
(re
31 30 29 0
0 0 0 Reset
Submit Documentation Feedback
1
R_
DD
_A
IN
RA
ST
ON
C
S_
M
_P
ION
)
EG
ed
R
rv
S_
se
PM
ESP32-C3 TRM (Version 1.1)
(re
31 30 29 0
0 0 0 Reset
GoBack
Espressif Systems
2
R_
DD
_A
IN
RA
ST
ON
C
S_
M
N_P
IO
)
EG
ed
R
rv
S_
se
PM
(re
31 30 29 0
0 0 0 Reset
Submit Documentation Feedback
3
R_
DD
_A
IN
A
TR
NS
CO
S_
M
_P
ION
)
EG
ed
R
rv
S_
se
ESP32-C3 TRM (Version 1.1)
PM
(re
31 30 29 0
0 0 0 Reset
GoBack
Espressif Systems
4
R_
DD
_A
IN
RA
ST
ON
C
S_
M
N_P
IO
)
EG
ed
R
rv
S_
se
PM
(re
31 30 29 0
0 0 0 Reset
Submit Documentation Feedback
5
R_
DD
_A
IN
RA
ST
ON
C
S_
M
_P
ION
)
EG
ed
R
rv
S_
se
ESP32-C3 TRM (Version 1.1)
PM
(re
31 30 29 0
0 0 0 Reset
GoBack
Espressif Systems
6
R_
DD
_A
IN
RA
ST
ON
C
S_
M
N_P
IO
)
EG
ed
R
rv
S_
se
PM
(re
31 30 29 0
0 0 0 Reset
Submit Documentation Feedback
7
R_
DD
_A
IN
A
TR
NS
CO
S_
M
_P
ION
)
EG
ed
R
rv
S_
se
ESP32-C3 TRM (Version 1.1)
PM
(re
31 30 29 0
0 0 0 Reset
GoBack
Espressif Systems
K
OC
_L
OR
IT
ON
M
S_
PM
F_
PI
0_
E_
)
OR
ed
C
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Submit Documentation Feedback
PMS_CORE_0_PIF_PMS_MONITOR_LOCK Set this bit to lock CPU’s PIF interrupt configuration. (R/WL)
381
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
LR
TE N
_C
LA E
IO E_
_V LAT
OR O
IT _VI
ON R
M ITO
S_ ON
PM _M
IF_ S
_P PM
_0 IF_
RE _P
CO _0
S_ ORE
)
ed
PM _C
rv
se
S
PM
(re
31 2 1 0
Submit Documentation Feedback
0 0 0 0 0 0 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
PMS_CORE_0_PIF_PMS_MONITOR_VIOLATE_CLR Set this bit to clear the interrupt triggered when CPU’s PIF bus tries to access RTC memory or pe-
ripherals unauthorized. (R/WL)
382
PMS_CORE_0_PIF_PMS_MONITOR_VIOLATE_EN Set this bit to enable interrupt when CPU’s PIF bus tries to access RTC memory or peripherals unau-
thorized. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
R
AT EN
CL
OL _
E_
V I TE
D_ OLA
OR VI
W D_
ON OR
_N NW
OR O
IT _N
ON R
M ITO
S_ ON
PM _M
IF_ S
_P PM
_0 IF_
RE _P
CO _0
S_ ORE
)
ed
PM _C
rv
se
S
Submit Documentation Feedback
PM
(re
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 Reset
383
PMS_CORE_0_PIF_PMS_MONITOR_NONWORD_VIOLATE_CLR Set this bit to clear the interrupt triggered when CPU’s PIF bus tries to access RTC mem-
ory or peripherals using unsupported data type. (R/WL)
PMS_CORE_0_PIF_PMS_MONITOR_NONWORD_VIOLATE_EN Set this bit to enable interrupt when CPU’s PIF bus tries to access RTC memory or periph-
erals using unsupported data type. (R/WL)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
R
DD
_A
US
TR
AT
ST
IN
E_
E_
AT
AT
L
L
IO
IO
_V
_V
OR
OR
IT
IT
ON
ON
M
M
S_
S_
M
PM
_P
I_
I
ER
ER
BP
BP
AP
AP
A_
A_
)
PM ed)
ed
DM
DM
rv
rv
S_
S_
se
se
Submit Documentation Feedback
PM
(re
(re
31 27 26 3 2 1 0
0 0 0 0 0 0 0 0 0 Reset
384
PMS_DMA_APBPERI_PMS_MONITOR_VIOLATE_STATUS_ADDR Stores the address that triggered the unauthorized DMA address.
Note that this is an offset to 0x3c000000 and the unit is 16, which means the actual address should be 0x3c000000 +
PMS_DMA_APBPERI_PMS_MONITOR_VIOLATE_STATUS_ADDR * 16. (RO)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
EN
TE
R
BY
W
S_
S_
TU
TU
TA
TA
_S
_S
TE
TE
LA
LA
IO
IO
_V
_V
OR
OR
IT
IT
ON
ON
M
M
S_
S_
PM
PM
I_
I_
ER
ER
BP
BP
AP
AP
A_
A_
d)
DM
M
ve
D
Submit Documentation Feedback
S_
S_
se
PM
PM
(re
31 5 4 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
385
PMS_DMA_APBPERI_PMS_MONITOR_VIOLATE_STATUS_WR Store the direction of unauthorized GDMA access. 1: write, 0: read. (RO)
GoBack
Espressif Systems
E
OR
R W ST
LA S US RLD
R
NT S_ AD
DD
R
_I TU LO
_W
_A
TE TA _
US
OR O E_ US
AT
IO E_ AT
TA
ST
_V AT ST
_S
E_
S_ ON R_ ATE
AT
IT _VI AT
L
OL
ON R L
L
IO
M ITO VIO
0_ S N _VI
_V
OR
OR
O
IT
_I M0 MS NIT
PM _M IT
ON
M PM MO
M
RE _I M0 S_M
S_
RA _ _
PM
PM
_0 RA _P
0_
0_
M
M
RA
RA
CO _0 RA
_I
_I
S_ RE _I
_0
S_ E_0
0
PM _C E_
Submit Documentation Feedback
E
d)
OR
PM OR
S OR
O
ve
PM C
r
S_
S_
se
PM
PM
(re
31 29 28 5 4 3 2 1 0
0 0 0 0 0 0 0 0 Reset
386
PMS_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_INTR Stores the interrupt status of CPU’s unauthorized IBUS access. (RO)
PMS_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_WR Indicates the access direction. 1: write, 0: read. Note that this field is only valid when
PMS_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_LOADSTORE is 1. (RO)
PMS_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_WORLD Stores the privileged mode the CPU was in when the illegal access happened. 0x01:
privilegedenvironment, 0x10: unpriviledged environment. (RO)
ESP32-C3 TRM (Version 1.1)
PMS_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR Stores the address that CPU’s IBUS was trying to access unautho-
rized. Note that this is an offset to 0x40000000 and the unit is 4, which means the actual address should be 0x40000000 +
PMS_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR * 4. (RO)
GoBack
Espressif Systems
LD
R
OR
DD
W
_A
S_
US
TU
R
AT
TA
NT
ST
_S
_I
E_
TE
TE
AT
LA
LA
L
IO
IO
IO
_V
_V
_V
OR
OR
OR
IT
IT
IT
ON
ON
ON
M
M
S_
S_
S_
PM
PM
PM
0_
0_
0_
M
AM
M
RA
RA
DR
_D
_D
PM rve 0_
_0
_0
E_
RE
RE
)
S_ d)
(re OR
ed
CO
CO
Submit Documentation Feedback
C
rv
S_
S_
se
se
PM
PM
(re
31 28 27 4 3 2 1 0
0 0 0 0 0 0 0 0 Reset
387
PMS_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_WORLD Stores the privileged mode the CPU was in when the illegal access happened. 0x01:
privilegedenvironment, 0x10: unpriviledged environment. (RO)
PMS_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR Stores the address that CPU0’s dBUS was trying to access unauthorized.
Note that this is an offset to 0x3c000000 and the unit is 16, which means the actual address should be 0x3c000000 +
PMS_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR * 4. (RO)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
EN
TE
R
BY
W
S_
S_
TU
TU
TA
TA
_S
_S
TE
TE
LA
LA
IO
IO
_V
_V
OR
OR
IT
IT
ON
ON
M
M
S_
S_
PM
PM
0_
0_
M
AM
RA
DR
_D
0_
_0
E_
RE
d)
OR
Submit Documentation Feedback
CO
ve
C
r
S_
S_
se
PM
PM
(re
31 5 4 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
388
GoBack
Espressif Systems
0
HW D
T_
TE
RL
OR
RI
TU WO
IZ
R HP
HS
_H
S_
S_
NT S_
E_ US
TU
_I U
AT
T
TA
TA
TE TA
ST
_S
LA S
E_
IO E_
TE
OR LAT
_V LAT
LA
LA
IO
IO
IO
OR O
IT VI
ON _V
_V
_V
_
OR
OR
ON R
M ITO
IT
IT
IT
PM ON
ON
S_ ON
IF_ _M
PM _M
S_
S_
S
IF_ S
_0 _PM
PM
_P PM
_
_0 IF_
IF
IF
_P
_P
_P
RE _P
S_ E_0
_0
CO _0
RE
RE
S_ RE
)
PM OR
ed
CO
CO
O
C
PM _C
rv
S_
S_
Submit Documentation Feedback
se
S
PM
PM
PM
(re
31 8 7 6 5 4 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
389
PMS_CORE_0_PIF_PMS_MONITOR_VIOLATE_INTR Stores the interrupt status of PIF bus unauthorized access. (RO)
PMS_CORE_0_PIF_PMS_MONITOR_VIOLATE_STATUS_HSIZE Stores the data type of unauthorized access. 0: byte. 1: half-word. 2: word. (RO)
PMS_CORE_0_PIF_PMS_MONITOR_VIOLATE_STATUS_HWORLD Stores the privileged mode the CPU was in when the unauthorized access happened.
01: privileged environment 10: unpriviledged environment. (RO)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
R
DD
A
_H
US
AT
ST
E_
AT
L
IO
_V
OR
IT
ON
M
S_
PM
IF_
_P
_0
RE
CO
S_
Submit Documentation Feedback
PM
31 0
0 Reset
390
PMS_CORE_0_PIF_PMS_MONITOR_VIOLATE_STATUS_HADDR Stores the address that CPU’s PIF bus was trying to access unauthorized. (RO)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
LD
OR
ZE
SI
W
_H
H
S_
US
TU
TR
AT
TA
ST
IN
_S
E_
E_
D_ ATE
AT
AT
OL
OR IOL
OL
VI
VI
V
D_
ON D_
OR
OR
W
OR NW
W
ON
O
_N
ON _N
_N
OR
OR
IT
IT
IT
ON
PM ON
M
IF_ _M
M
S_
S_
S
PM
PM
F_
IF_
Submit Documentation Feedback
PI
_P
_P
0_
_0
_0
E_
RE
RE
)
OR
ed
CO
CO
C
rv
S_
S_
S_
se
PM
PM
PM
(re
31 5 4 3 2 1 0
391
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
PMS_CORE_0_PIF_PMS_MONITOR_NONWORD_VIOLATE_INTR Stores the interrupt status of PIF upsupported data type. (RO)
PMS_CORE_0_PIF_PMS_MONITOR_NONWORD_VIOLATE_STATUS_HSIZE Stores the data type when the unauthorized access happened. (RO)
PMS_CORE_0_PIF_PMS_MONITOR_NONWORD_VIOLATE_STATUS_HWORLD Stores the privileged mode the CPU was in when the unauthorized access
happened. 01: privileged environment 10: unpriviledged environment. (RO)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
DR
AD
_H
US
AT
ST
E_
AT
OL
VI
D_
OR
W
ON
_N
OR
IT
ON
M
S_
PM
IF_
_P
Submit Documentation Feedback
_0
RE
CO
S_
PM
31 0
392
0 Reset
PMS_CORE_0_PIF_PMS_MONITOR_NONWORD_VIOLATE_STATUS_HADDR Stores the address that CPU’s PIF bus was trying to access using unsup-
ported data type. (RO)
N
ESP32-C3 TRM (Version 1.1)
_E
)
LK
ed
C
rv
S_
se
PM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
GoBack
PMS_CLK_EN Set this bit to force the clock gating always on. (R/W)
Espressif Systems
TE
)
ed
DA
rv
S_
se
PM
(re
31 28 27 0
0 0 0 0 0x2010200 Reset
CK
LO
S_
M
_P
EM
M
T_
393
X
_E
)
ed
ON
rv
SC
se
(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
SYSCON_EXT_MEM_PMS_LOCK Set this bit to lock the permission configuration related to external memory. (R/W)
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
TR
AT
n_
CE
_A
SH
LA
_F
)
ed
ON
rv
SC
se
(re
SY
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 0xff Reset
_S
394
DR
AD
n_
CE
_A
H
L AS
_F
ON
SC
SY
31 0
0x000000 Reset
ESP32-C3 TRM (Version 1.1)
SYSCON_FLASH_ACE0_ADDR_S Configure the starting address of Flash Region n. The size of each region should be aligned to 64 KB. (R/W)
GoBack
Espressif Systems
ZE
SI
n_
CE
_A
SH
LA
_F
)
ed
ON
rv
SC
se
(re
SY
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1000 Reset
SYSCON_FLASH_ACEn_SIZE Configure the length of Flash Region n. The size of each region should be aligned to 64 KB. (R/W)
Submit Documentation Feedback
T_ R
T
395
CD
EC CL
IN
T_
EJ T_
EC
_R JEC
EJ
EM E
_R
R
_M _
EM
PI EM
M
_S M
I_
I_
P
ON S P
_S
)
SC _
ed
ON
SY ON
rv
SC
SC
se
(re
SY
SY
31 7 6 2 1 0
0 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
ESP32-C3 TRM (Version 1.1)
SYSCON_SPI_MEM_REJECT_INT Indicates exception accessing external memory and triggers an interrupt. (RO)
SYSCON_SPI_MEM_REJECT_CDE Stores the exception cause: invalid region, overlapping regions, illegal write, illegal read and illegal instruction execu-
tion. (RO)
GoBack
Espressif Systems
R
DD
_A
CT
E JE
_R
EM
M
P I_
_S
ON
SC
SY
31 0
0x000000 Reset
K
C
LO
S_
M
_P
B US
_I
)
ed
EM
rv
TM
se
(re
EX
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
ESP32-C3 TRM (Version 1.1)
EXTMEM_IBUS_PMS_LOCK Set this bit to lock IBUS’ access to Cache IBUS regions. (R/W)
GoBack
Espressif Systems
Y0
AR
ND
BOU
S_
MP
S_
BU
_I
)
ed
EM
rv
TM
se
(re
EX
31 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
1
Y
AR
ND
BOU
S_
MP
S_
BU
_I
)
ed
EM
rv
TM
se
(re
EX
31 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
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
Y2
AR
ND
OU
B
S_
P M
S_
BU
_I
)
ed
EM
rv
TM
se
(re
EX
31 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
GoBack
Espressif Systems
TR
TT
AT
_A
1_
T2
CT
SC
S
S_
S_
M
M
P
_P
S_
US
BU
B
_I
_I
)
ed
EM
EM
rv
TM
TM
se
(re
EX
EX
31 8 7 4 3 0
(R/W)
GoBack
Espressif Systems
CK
LO
S_
PM
S_
BU
_D
)
ed
EM
rv
TM
se
(re
EX
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
EXTMEM_DBUS_PMS_LOCK Set this bit to lock DBUS’ access to Cache DBUS regions. (R/W)
Submit Documentation Feedback
0
400
Y
AR
ND
B OU
S_
PM
S_
BU
_D
)
ed
EM
rv
TM
se
(re
EX
31 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
Y1
AR
ND
OU
B
S_
PM
S_
BU
_D
)
ed
EM
rv
TM
se
(re
EX
31 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
Y 2
AR
ND
OU
B
S_
PM
S_
BU
_D
)
ed
EM
rv
TM
se
(re
EX
31 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
ESP32-C3 TRM (Version 1.1)
GoBack
Espressif Systems
R
TT
TT
_A
_A
T2
T1
SC
SC
S_
S_
M
PM
_P
S_
US
BU
B
_D
_D
)
ed
EM
EM
rv
M
se
T
(re
EX
EX
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 Reset
GoBack
15 World Controller (WCL) GoBack
15.1 Introduction
ESP32-C3 allows users to allocate its hardware and software resources into Secure World (World0) and
Non-secure World (World1), thus protecting resources from unauthorized access (read or write), and from
malicious attacks such as malware, hardware-based monitoring, hardware-level intervention, and so on. CPUs
can switch between Secure World and Non-secure World with the help of the World Controller.
By default, all resources in ESP32-C3 are shareable. Users can allocate the resources into two worlds by
managing respective permission (For details, please refer to Chapter 14 Permission Control (PMS)). This
chapter only introduces the World Controller and how CPUs can switch between worlds with the help of World
Controller.
15.2 Features
ESP32-C3’s World Controller:
• Controls the CPUs to switch between the Secure World and Non-secure World
– Performs all security related operations, such user authentication, secure communication, and data
encryption and decryption, etc.
– Performs other operations, such as user operation and different applications, etc.
ESP32-C3’s CPU and slave devices are both configurable with permission to either Secure World and/or
Non-Secure World:
– By default, CPU runs in Secure World after power-up, then can be programmed to switch between
two worlds.
• All slave devices (including peripherals* and memories) can be configured to be accessible from the
Secure World and/or the Non-secure World:
– Secure World Access: this slave can be called from Secure World only, meaning it can be accessed
only when CPU is in Secure World;
– Non-secure World Access: this slave can be called from Non-secure World only, meaning it can be
accessed only when CPU is in Non-secure World.
– Note that a slave can be configured to be accessible from both Secure World and Non-secure
World simultaneously.
Note:
* World Controller itself is a peripheral, meaning it also can be granted with Secure World access and/or Non-secure
World access, just like all other peripherals. However, to secure the world switch mechanism, World Controller should
not be accessible from Non-secure world. Therefore, world controller should not be granted with Non-secure World
access, preventing any modification to world controller from the Non-secure World.
1. First, CPU notifies the slave about its own world information;
2. Second, slave checks if it can be accessed by CPU based on the CPU’s world information and its own
world permission configuration.
• if not allowed, then this slave will not respond to CPU and trigger an interrupt.
In this way, the resources in the Secure World will not be illegally accessible by the Non-secure World in an
unauthorized way.
Note that the following CPU interrupt-related CSR registers can only be written to in the Secure World, and can
only be read but not written to in the Non-secure World, thus ensuring that interrupts can only be controlled by
the Secure World.
ESP32-C3’s CPU only needs to complete the following steps to switch from Secure World to Non-secure
World:
1. Write 0x2 to Register WCL_CORE_0_WORLD_PERPARE_REG, indicating the CPU needs to switch to the
Non-secure World.
Note:
Afterwards, the World Controller keeps monitoring if CPU is executing the configured address of the
application in Non-secure World. CPU switches to the Non-secure World once it executes the configured
address, and executes the applications in the Non-secure World.
• Keeps monitoring until the CPU executes the configured address and switches to the Non-secure World.
• The World Controller can only switch from the Secure World to Non-secure World once per
configuration. Therefore, the World Controller needs to be configured again after each world switch to
prepare it for the next world switch.
However, it’s worth noting that you cannot call the application in Non-secure world immediately after
configuring the World Controller. For reasons such as CPU pre-indexed addressing and pipeline, it is possible
that the CPU has already executed the application in Non-secure World before the World Controller
configuration is effective, meaning the CPU runs unsecured application in the Secure World.
Therefore, you need to make sure the CPU only calls applications in the Non-secure world after the World
Controller configuration takes effect. This can be guaranteed by declaring the applications in the Non-secure
World as “noinline”.
CPU can only switch from Non-secure World to Secure World via Interrupts (or Exceptions). After configuring
the World Controller, the CPU can switch back from Non-secure World to Secure World upon the configured
Interrupt trigger.
The detailed steps to configure the World Controller to switch the CPU from Non-secure World to Secure
World are described below:
Note that this register must be configured to the mtvec CSR register of the CPU. When modifying the
CPU’s mtvec CSR registers, this register also must be updated. For details, please refer to Chapter 1
ESP-RISC-V CPU.
Note that, once configured, register WCL_CORE_0_ENTRY_CHECK_REG is always effective till it’s
disabled again, meaning you don’t need to configure this register every time after each world switch.
3. Configure WCL_CORE_0_MSTATUS_MIE_REG to enable updating the World Switch Log. Otherwise, this
log will not be updated for world switches. For detailed information about the World Switch Log, see
Section 15.5.
• WCL_CORE_0_FROM_ENTRY_n: logs the entry information before the world switch, in total of 6 bits.
• WCL_CORE_0_CURRENT_n: indicates if CPU is at the interrupt monitored at the current entry. When
CPU is at the interrupt monitored at Entry x,
– WCL_CORE_0_CURRENT_x is updated to 1;
1. At the beginning:
1. First, an interrupt occurs at Entry 9. At this time, CPU executes to the entry address of this interrupt. The
World Switch Log Table is updated as described in Figure 15-4:
At this time:
• WCL_CORE_0_STATUSTABLE9_REG
– Field WCL_CORE_0_FROM_ENTRY_9 is updated to 32, indicating there was not any interrupt
before this one;
2. Then another interrupt with higher priority occurs at Entry 1. At this time, CPU executes to the entry
address of this interrupt. The World Switch Log Table is updated again as described in Figure 15-5:
At this time:
• WCL_CORE_0_STATUSTABLE1_REG
• WCL_CORE_0_STATUSTABLE9_REG
3. Then the last interrupt with highest priority occurs at Entry 4. At this time, CPU executes to the entry
address of interrupt 4. The World Switch Log Table is updated again as described in Figure 15-6:
At this time:
• WCL_CORE_0_STATUSTABLE4_REG
• WCL_CORE_0_STATUSTABLE1_REG
2. Read 1 from Field WCL_CORE_0_FROM_ENTRY_4, and understand the CPU was at an interrupt
monitored at Entry 1.
3. Read 9 from Field WCL_CORE_0_FROM_ENTRY_1, and understand the CPU was at an interrupt
monitored at Entry 9.
4. Read 32 from WCL_CORE_0_FROM_ENTRY_9, and understand CPU wasn’t at any interrupt. Then read 1
from WCL_CORE_0_FROM_WORLD_9, and understand CPU was in Non-secure World at the beginning.
1. Save context.
2. Configure WCL_CORE_0_MSTATUS_MIE_REG register to enable updating the World Switch Log table.
• After entering the interrupt and exception vector, CPU will automatically turn off the global interrupt
enable to avoid interrupt nesting. After saving the context, the global interrupt enable can be turned
on again to respond to higher-level interrupts.
• 32: indicates all interrupts are handled, and return to a normal program,
(a) Update Field WCL_CORE_0_CURRENT_A of Entry A to 0, indicating the CPU is no longer at the
interrupt monitored at Entry A.
(b) Go to Step 7.
• If world switch required, then switch the CPU to the other world following instructions
described in Section 15.4, then go to Step 8.
Note:
Steps 6 and 7 should not be interrupted by any interrupts. Therefore, users need to disable all the interrupts before
these steps, and enable interrupts once done.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
15.7 Registers
The addresses in this section are relative to the World Controller base address provided in Table 3-3 in Chapter
3 System and Memory.
E
AS
_B
EC
TV
M
0_
E_
OR
_C
CL
W
31 0
0 Reset
WCL_CORE_0_MTVEC_BASE Configures the MTVEC base address, which should be kept consis-
tent with the MTVEC in RISC-V. (R/W)
IE
_M
US
AT
ST
_M
_0
RE
)
ed
O
_C
rv
se
CL
(re
W
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
WCL_CORE_0_MSTATUS_MIE Write 1 to enable World Switch Log Table. Only when the bit is set,
the world switching is recorded in the World Switch Log Table. This bit is cleared once CPU
switches from the Non-secure World to Secure World. (R/W)
31 0
0x000000 Reset
_n
_n
LD
RY
OR
n
NT
T_
_W
_E
EN
OM
OM
RR
CU
FR
FR
0_
0_
0_
E_
E_
E_
d)
OR
OR
OR
ve
_C
_C
_C
r
se
CL
CL
CL
(re
W
31 8 7 6 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 0 Reset
WCL_CORE_0_FROM_WORLD_n Stores the world info before CPU entering entry n. (R/W)
WCL_CORE_0_FROM_ENTRY_n Stores the previous entry info before CPU entering entry n.(R/W)
NT
RE
UR
_C
LE
AB
ST
TU
TA
_S
_0
E
OR
_C
CL
W
31 0
0 Reset
31 0
0 Reset
ER
PA
RE
_P
LD
OR
W
0_
E_
)
OR
ed
_C
rv
se
CL
(re
W
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
31 0
0 Reset
WCL_CORE_0_UPDATE Write any value to this field to indicate the completion of CPU configuration
for switching from Secure World to Non-Secure World. (WO)
31 0
0 Reset
WCL_CORE_0_WORLD_CANCEL Write any value to this filed to cancel the CPU configuration for
switching from Secure World to Non-Secure World. (WO)
0
AM
R
_I
LD
OR
W
0_
E_
d)
OR
ve
_C
r
se
CL
(re
W
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
WCL_CORE_0_WORLD_IRAM0 Stores the world info of CPU’s instruction bus. Only used for de-
bugging. (R/W)
IF
P
0_
M
RA
_D
LD
OR
_W
_0
RE
)
ed
O
_C
rv
se
CL
(re
W
31 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
WCL_CORE_0_WORLD_DRAM0_PIF Stores the world info of CPU’s data bus and peripheral bus.
Only used for debugging. (R/W)
SE
HA
_P
LD
OR
_W
_0
RE
d)
O
ve
_C
r
se
CL
(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
16.1 Overview
The ESP32-C3 integrates a large number of peripherals, and enables the control of individual peripherals to
achieve optimal characteristics in performance-vs-power-consumption scenarios. Specifically, ESP32-C3 has
various system configuration registers that can be used for the chip’s clock management (clock gating),
power management, and the configuration of peripherals and core-system modules. This chapter lists all
these system registers and their functions.
16.2 Features
ESP32-C3 system registers can be used to control the following peripheral blocks and core modules:
• Clock
• Software Interrupt
• Low-power management
• In register SYSCON_CLKGATE_FORCE_ON_REG:
– Setting different bits of the SYSCON_ROM_CLKGATE_FORCE_ON field forces on the clock gates of
different blocks of Internal ROM 0 and Internal ROM 1.
– Setting different bits of the SYSCON_SRAM_CLKGATE_FORCE_ON field forces on the clock gates
of different blocks of Internal SRAM.
– This means when the respective bits of this register are set to 1, the clock gate of the
corresponding ROM or SRAM blocks will always be on. Otherwise, the clock gate will turn on
automatically when the corresponding ROM or SRAM blocks are accessed and turn off
automatically when the corresponding ROM or SRAM blocks are not accessed. Therefore, it’s
recommended to configure these bits to 0 to lower power consumption.
• In register SYSCON_MEM_POWER_DOWN_REG:
– Setting different bits of the SYSCON_ROM_POWER_DOWN field sends different blocks of Internal
ROM 0 and Internal ROM 1 into retention state.
– Setting different bits of the SYSCON_SRAM_POWER_DOWN field sends different blocks of Internal
SRAM into retention state.
– The “Retention” state is a low-power state of a memory block. In this state, the memory block still
holds all the data stored but cannot be accessed, thus reducing the power consumption.
Therefore, you can send a certain block of memory into the retention state to reduce power
consumption if you know you are not going to use such memory block for some time.
• In register SYSCON_MEM_POWER_UP_REG:
– By default, all memory enters low-power state when the chip enters the Light-sleep mode.
– Setting different bits of the SYSCON_ROM_POWER_UP field forces different blocks of Internal ROM
0 and Internal ROM 1 to work as normal (do not enter the retention state) when the chip enters
Light-sleep.
– Setting different bits of the SYSCON_SRAM_POWER_UP field forces different blocks of Internal
SRAM to work as normal (do not enter the retention state) when the chip enters Light-sleep.
For detailed information about the controlling bits of different blocks, please see Table 16-1 below.
Memory Lowest Address1 Highest Address1 Lowest Address2 Highest Address2 Controlling Bit
ROM 0 0x4000_0000 0x4003_FFFF - - Bit0
ROM 1 0x4004_0000 0x4005_FFFF 0x3FF0_0000 0x3FF1_FFFF Bit1
SRAM Block 0 0x4037_C000 0x4037_FFFF - - Bit0
SRAM Block 1 0x4038_0000 0x4039_FFFF 0x3FC8_0000 0x3FC9_FFFF Bit1
SRAM Block 2 0x403A_0000 0x403B_FFFF 0x3FCA_0000 0x3FCB_FFFF Bit2
SRAM Block 3 0x403C_0000 0x403D_FFFF 0x3FCC_0000 0x3FCD_FFFF Bit3
• Setting the SYSTEM_RSA_MEM_PD bit to send the RSA memory into retention state. This bit has the
lowest priority, meaning it can be masked by the SYSTEM_RSA_MEM_FORCE_PU field. This bit is invalid
when the Digital Signature (DS) occupies the RSA.
• Setting the SYSTEM_RSA_MEM_FORCE_PU bit to force the RSA memory to work as normal when the
chip enters light sleep. This bit has the second highest priority, meaning it overrides the
SYSTEM_RSA_MEM_PD field.
• Setting the SYSTEM_RSA_MEM_FORCE_PD bit to send the RSA memory into retention state. This bit
has the highest priority, meaning it sends the RSA memory into retention state regardless of the
SYSTEM_RSA_MEM_FORCE_PU field.
• SYSTEM_CPU_PER_CONF_REG
• SYSTEM_SYSCLK_CONF_REG
• SYSTEM_BT_LPCK_DIV_FRAC_REG
• SYSTEM_CPU_INTR_FROM_CPU_0_REG
• SYSTEM_CPU_INTR_FROM_CPU_1_REG
• SYSTEM_CPU_INTR_FROM_CPU_2_REG
• SYSTEM_CPU_INTR_FROM_CPU_3_REG
• SYSTEM_CACHE_CONTROL_REG
• SYSTEM_PERIP_CLK_EN0_REG
• SYSTEM_PERIP_RST_EN0_REG
• SYSTEM_PERIP_CLK_EN1_REG
• SYSTEM_PERIP_RST_EN1_REG
ESP32-C3 features low power consumption. This is why some peripheral clocks are gated (disabled) by
default. Before using any of these peripherals, it is mandatory to enable the clock for the given peripheral and
release the peripheral from reset state. For details, see the table below:
The abbreviations given in Column Access are explained in Section Access Types for Registers.
The addresses below are relative to the base address of apb control provided in Table 3-3 in Chapter 3 System
and Memory.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
16.5 Registers
The addresses below are relative to the base address of system register provided in Table 3-3 in Chapter 3
System and Memory.
G
BU
DE
T_
SIS
AS
_
_EN
LK
_C
d)
)
ed
ve
rv
E
r
se
se
ST
(re
(re
SY
30 7 6 5 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTEM_CLK_EN_ASSIST_DEBUG Set this bit to enable the ASSIST_DEBUG clock. Please see
Chapter 17 Debug Assistant (ASSIST_DEBUG) for more information about ASSIST_DEBUG. (R/W)
UG
B
DE
T_
SIS
AS
N_
_E
ST
_R
)
)
ed
ed
M
rv
rv
E
se
se
ST
(re
(re
SY
31 8 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 1 0 0 0 0 0 0 Reset
SYSTEM_RST_EN_ASSIST_DEBUG Set this bit to reset the ASSIST_DEBUG clock. Please see Chap-
ter 17 Debug Assistant (ASSIST_DEBUG) for more information about ASSIST_DEBUG. (R/W)
N
K_ EN
N
EN
_E
_E
CL N
se SPI SAR CL _EN
CL LK_
EN
K_
DM DC EN
LK
E_ E
K
IC LK_
CL
_C
EN
3_ A K_
_ B_ R_ LK
A_ _C
_ I2_ K_ N
CL N
EN
se UAR CL EN
P_
IM C EN
P1
EM P CL _E
(re EM ) DEV _C
_C EN
K_
EM AP ME _C
_E
SY EM EXT _C EN
N
N
S_ _E
_E
OU
K_
_E
_T I01_ K_
ST _S 0_ LK
ST d _ M
LK
ST _ TI B
T1 K_
ST _ I0 _
ER LK
O
SY EM YS _AR
SY EM HC CLK
SY rve USB ME
LK
LK
CL
GR
GR
EM P CL
_C
ST d) _C
ST d) C_
se _ T_
ST _S T_
ST d) ER
ST d) ER
ST _S 2
ST _U T_
SY EM ADC
AN
1
(re EM AR
SY EM AR
SY rve ED
SY rve IM
SY ve M
SY EM RM
SY rve I2S
I
ST _U
ST _U
_C
se _L
se _T
se _T
ST d)
SY ed)
SY ed)
ed
ST _
se _
ST _
SY rve
SY EM
SY EM
EM
(re EM
(re EM
(re EM
SY EM
SY EM
rv
rv
rv
r
se
se
ST
ST
ST
(re
(re
(re
(re
SY
31 30 29 28 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 1 1 1 1 0 0 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 0 1 1 1 1 Reset
rv R O_ A_ _E N
se _C PT RS LK _E
LK N
ES LK N
N
ed YP S C N
_C _E
_A _C _E
_E
(re EM CRY TO_ S_C CLK
) TO HA LK
ST _ P D C_
N
_E
SY EM CRY TO_ EN
SY EM CRY TO_ MA
LK
ST _ P K_
ST _ P H
_C
SY EM CRY CL
NS
ST _ A_
SE
SY EM DM
_T
d)
d)
ST _
ve
ve
M
SY EM
E
r
r
se
se
ST
ST
(re
(re
SY
SY
31 11 10 9 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 Reset
ST
RS ST
T
ST
RS
_R
CE T
_ B_ R_ ST
A_ _R
T
_R
VI RS
3_ A T
P_
P1
se SPI SAR RS
EM AP ME _R
DM DC
DE _
T
OU
ST _S 0_ ST
RS
ST d) _ M
ST
ST _ TI B
ER ST
T
O
_ I2_ T
_T I01_ T
T1 T
SY EM YS _AR
SY EM UHC RST
SY rve USB ME
ST
RS
ST
EM P RS
SY EM EXT _R
EM P RS
GR
GR
_R
S_
se UAR RS
IM R
_R
ST d) 1_R
ST d) C_
ST _ I0
se _ T_
ST _S T_
ST d) ER
ST d) ER
ST _S 2
ST _ T_
SY EM ADC
AN
(re EM AR
SY EM AR
SY rve ED
SY rve IM
SY ve M
SY EM M
SY rve 2S
I
ST _U
ST _U
_C
R
se _L
se _T
se _T
ST d)
SY ed)
SY ed)
se _I
ed
ST _
ST _
SY rve
SY EM
SY EM
(re EM
EM
(re EM
(re EM
(re EM
SY EM
SY EM
rv
rv
rv
r
se
se
ST
ST
ST
(re
(re
(re
(re
SY
31 30 29 28 27 26 25 24 23 22 21 20 19 18 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
ES ST
) TO HA ST
ST
se _C PT RS ST
ST _ P D C_
_A _R
ed YP S R
_R
rv R O_ A_
SY EM CRY TO_ MA
ST
ST _ P H
ST _ P T
SY EM CRY TO_
R
SY EM CRY RS
S_
ST _ A_
EN
SY EM DM
S
_T
d)
d)
ST _
ve
ve
M
SY EM
E
r
r
se
se
ST
ST
(re
(re
SY
SY
31 11 10 9 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 Reset
E_ SE N
ON
CH RE _O
_I CH _CL ET
CL T
K_
EM ICA HE ES
CA E_ K
ST _ C R
SY EM DCA HE_
ST _ C
SY EM DCA
)
ed
ST _
SY EM
rv
se
ST
(re
SY
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 Reset
ON
E_
RC
UM
L FO
_N
SE _
AY
PU Q_ DE
EL
EL
RE MO
_S
_D
OD
_F T_
TI
AI
LL AI
RI
_W
_P U_W
PE
PU
EM P
_C
ST _C
_C
d)
ve
SY EM
EM
E
r
se
ST
ST
ST
(re
SY
SY
SY
31 8 7 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 1 1 0 Reset
SYSTEM_CPUPERIOD_SEL Set this field to select the CPU clock frequency. For details, please refer
to Table 6-4 in Chapter 6 Reset and Clock.(R/W)
SYSTEM_PLL_FREQ_SEL Set this bit to select the PLL clock frequency. For details, please refer to
Table 6-4 in Chapter 6 Reset and Clock. (R/W)
SYSTEM_CPU_WAIT_MODE_FORCE_ON Set this bit to force on the clock gate of CPU wait mode.
Usually, after executing the WFI instruction, CPU enters the wait mode, during which the clock
gate of CPU is turned off until any interrupts occur. In this way, power consumption is saved.
However, if this bit is set, the clock gate of CPU is always on and will not be turned off by the
WFI instruction. (R/W)
SYSTEM_CPU_WAITI_DELAY_NUM Sets the number of delay cycles to turn off the CPU clock gate
after the CPU enters the wait mode because of a WFI instruction. (R/W)
_S
_L LK EL TAL
_S _8 L
TC
EL M
ST _ LK EL N
SY EM LPC _S _E
_R
EM LPC _S _X
ST _ LK TC
SY EM LPC _R
ST _ LK
SY EM LPC
)
)
ed
ed
ST _
SY EM
rv
rv
se
se
ST
(re
(re
SY
31 29 28 27 26 25 24 23 0
0 0 0 0 0 0 1 0 Reset
SYSTEM_LPCLK_SEL_8M Set this bit to select RC_FAST_CLK div n clock as the low-power clock.
(R/W)
SYSTEM_LPCLK_SEL_XTAL Set this bit to select XTAL clock as the low-power clock. (R/W)
SYSTEM_LPCLK_SEL_XTAL32K Set this bit to select xtal32k clock as the low-power clock. (R/W)
EQ
L
R
T
SE
_F
CN
K_
L
V_
TA
CL
DI
_X
C_
E_
LK
R
_C
_P
_S
)
ed
M
rv
E
se
ST
ST
ST
(re
SY
SY
SY
31 19 18 12 11 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x1 Reset
SYSTEM_PRE_DIV_CNT This field is used to set the count of prescaler of XTAL_CLK. For details,
please refer to Table 6-4 in Chapter 6 Reset and Clock. (R/W)
SYSTEM_SOC_CLK_SEL This field is used to select SOC clock. For details, please refer to Table
6-2 in Chapter 6 Reset and Clock. (R/W)
RT
R
DD
EN
NI
A
ST
FI
A
_L
C_
C_
C_
RC
R
R
_C
_C
_C
_C
EM
EM
EM
EM
M
_M
M
_
_
TC
TC
TC
TC
_R
_R
_R
_R
)
ed
M
EM
rv
E
se
ST
ST
ST
ST
(re
SY
SY
SY
SY
31 30 20 19 9 8 7 0
SYSTEM_RTC_MEM_CRC_START Set this bit to start the CRC of RTC memory. (R/W)
SYSTEM_RTC_MEM_CRC_ADDR This field is used to set address of RTC memory for CRC. (R/W)
SYSTEM_RTC_MEM_CRC_LEN This field is used to set length of RTC memory for CRC based on
start address. (R/W)
SYSTEM_RTC_MEM_CRC_FINISH This bit stores the status of RTC memory CRC. High level means
finished while low level means not finished. (RO)
ES
_R
RC
_C
EM
_M
TC
_R
E M
ST
SY
31 0
0 Reset
SYSTEM_RTC_MEM_CRC_RES This field stores the CRC result of RTC memory. (RO)
0
U_
P
_C
M
RO
F
R_
NT
_I
PU
_C
)
ed
EM
rv
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTEM_CPU_INTR_FROM_CPU_0 Set this bit to generate CPU interrupt 0. This bit needs to be
reset by software in the ISR process. (R/W)
_1
PU
_C
M
RO
F
R_
NT
_I
PU
_C
)
ed
M
rv
E
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTEM_CPU_INTR_FROM_CPU_1 Set this bit to generate CPU interrupt 1. This bit needs to be
reset by software in the ISR process. (R/W)
_2
PU
_C
R OM
_F
TR
N
_I
PU
_C
d)
ve
EM
r
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTEM_CPU_INTR_FROM_CPU_2 Set this bit to generate CPU interrupt 2. This bit needs to be
reset by software in the ISR process. (R/W)
_3
PU
_C
MO
FR
R_
NT
_I
PU
_C
)
ed
M
rv
E
se
ST
(re
SY
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SYSTEM_CPU_INTR_FROM_CPU_3 Set this bit to generate CPU interrupt 3. This bit needs to be
reset by software in the ISR process. (R/W)
U
_P RCE PD
D _P
EM FO E_
_M M_ RC
SA E FO
_R A_M M_
EM RS E
ST _ _M
SY EM RSA
d)
ST _
ve
SY EM
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 1 Reset
SYSTEM_RSA_MEM_PD Set this bit to send the RSA memory into retention state. This bit has the
lowest priority, meaning it can be masked by the SYSTEM_RSA_MEM_FORCE_PU field. When
Digital Signature occupies the RSA, this bit is invalid. (R/W)
SYSTEM_RSA_MEM_FORCE_PU Set this bit to force the RSA memory to work as normal when
the chip enters light sleep. This bit has the second highest priority, meaning it overrides the
SYSTEM_RSA_MEM_PD field. (R/W)
SYSTEM_RSA_MEM_FORCE_PD Set this bit to send the RSA memory into retention state. This bit
has the highest priority, meaning it sends the RSA memory into retention state regardless of the
SYSTEM_RSA_MEM_FORCE_PU field. (R/W)
T
DE RYP
T
YP
NC
T
CR
YP
G0 L_E
T
CR
YP
A
CR
_
EN
DO OAD NU
CB
EN
B_
A
_M
L_
_D
_
UA
DO OAD
AD
AN
LO
NL
NL
M
N
W
I_
DO
SP
E_
E_
E_
E_
)
EM ABL
EM ABL
EM ABL
BL
ed
NA
N
N
rv
_E
_E
_E
_E
se
EM
ST
ST
ST
ST
(re
SY
SY
SY
SY
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
_ EN
LK
_C
d)
ve
E M
r
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 1 Reset
E
AT
_D
)
ed
EM
rv
se
ST
(re
SY
31 28 27 0
0 0 0 0 0x2007150 Reset
The addresses below are relative to the base address of apb control provided in Table 3-3 in Chapter 3 System
and Memory.
N
_O
_O
CE
CE
OR
OR
_F
_F
TE
TE
GA
GA
LK
LK
_C
_C
AM
OM
SR
_R
)
N_
ed
ON
rv
O
SC
SC
se
(re
SY
SY
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 0xf 3 Reset
SYSCON_ROM_CLKGATE_FORCE_ON Set 1 to configure the ROM clock gate to be always on; Set
0 to configure the clock gate to turn on automatically when ROM is accessed and turn off auto-
matically when ROM is not accessed. (R/W)
N
W
W
O
O
_D
_D
ER
ER
OW
W
O
_P
_P
AM
OM
R
_R
_S
d)
ve
ON
ON
r
SC
SC
se
(re
SY
SY
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 0 0 Reset
SYSCON_ROM_POWER_DOWN Set this field to send the internal ROM into retention state. (R/W)
SYSCON_SRAM_POWER_DOWN Set this field to send the internal SRAM into retention state. (R/W)
P
_U
_U
ER
ER
OW
OW
_P
_P
AM
M
RO
R
_S
)
_
ed
ON
ON
rv
SC
SC
se
(re
SY
SY
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 0xf 3 Reset
SYSCON_ROM_POWER_UP Set this field to force the internal ROM to work as normal (do not enter
the retention state) when the chip enters light sleep. (R/W)
SYSCON_SRAM_POWER_UP Set this field to force the internal SRAM to work as normal (do not
enter the retention state) when the chip enters light sleep. (R/W)
17.1 Overview
Debug Assistant is an auxiliary module that features a set of functions to help locate bugs and issues during
software debugging.
17.2 Features
• Read/write monitoring: Monitors whether the CPU bus has read from or written to a specified address
space. A detected read or write will trigger an interrupt.
• Stack pointer (SP) monitoring: Monitors whether the SP exceeds the specified address space. A
bounds violation will trigger an interrupt.
• Program counter (PC) logging: Records PC value. The developer can get the last PC value at the most
recent CPU reset.
• Bus access logging: Records the information about bus access. When the CPU or DMA writes a
specified value, the Debug Assistant module will record the address and PC value of this write operation,
and push the data to the SRAM.
17.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, Debug Assistant will record the PC
pointer and generate an interrupt. The threshold is configured by software.
17.3.3 PC Logging
In some cases, software developers want to know the PC at the last CPU reset. For instance, when the
program is stuck and 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 CPU reset, which can be then read for
software debugging.
2. Configure interrupts.
Assuming that Debug Assistant 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:
1. Configure ASSIST_DEBUG_CORE_0_AREA_DRAM0_0_MIN_REG to A.
2. Configure ASSIST_DEBUG_CORE_0_AREA_DRAM0_0_MAX_REG to B.
5. Configure interrupt matrix to map ASSIST_DEBUG_INT into CPU interrupt (please refer to Chapter 8
Interrupt Matrix (INTERRUPT)).
• Configure the permission for the Debug Assistant module to access the internal SRAM. Only if the
access permission is enabled, the Debug Assistant module is able to access the internal SRAM. For
more information please refer to Chapter 14 Permission Control (PMS)).
5. Configure the writing mode for recorded data: loop mode and non-loop mode.
• In loop mode, writing to 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.
For example, 10 writes (1 ~ 10) write to address space 0 ~ 4. After the 5th write writes to address 4,
the 6th write will start writing from address 0. The 6th to 10th writes will overwrite the previous data
written by 0 ~ 4 writes.
• In non-loop mode, when writing reaches the end address, it will stop at the end address, not
overwriting the previously recorded data.
For example, 10 writes (1 ~ 10) write to address space 0 ~ 4. After the 5th write writes to address 4,
the 6th to 10th writes will write at address 4. Only the data written by the last (10th) write will be
retained at address 4.
• Enable CPU or DMA bus access logging with ASSIST_DEBUG_LOG_ENA. CPU and DMA bus access
logging can be enabled at the same time.
When bus access logging is finished, the recorded data can be read from memory for decoding. The
recorded data is in two packet formats, namely CPU packet (corresponding to CPU bus) and DMA packet
(corresponding to DMA bus). The packet formats are shown in Table 17-1 and 17-2:
It can be seen from the data packet formats that the CPU packet size is 50 bits and DMA packet size 25 bits.
The packet formats contain the following fields:
• format – the packet type. 1: CPU packet; 3: DMA packet; other values: reserved.
• pc_offset – the offset of the PC register at time of access. Actual PC = pc_offset + 0x4000_0000.
Value Source
1 SPI2
2 reserved
3 reserved
4 AES
5 SHA
6 ADC
7 I2S0
8 reserved
9 LCD_CAM
10 reserved
11 UHCI0
12 reserved
13 LC
14 reserved
15 reserved
The packets are stored in the internal buffer first. When the buffered data reaches 125 bits, it will be expanded
to 128 bits and written to the internal SRAM. The written data format is shown in Table 17-4.
Bit[127:3] Bit[2:0]
Valid packets START_FLAG
Since the CPU packet size is 50 bits and the DMA packet size 25 bits, the recorded data in each record is at
least 25 bits and at most 75 bits. When the data stored in the internal buffer reaches 125 bits, it will be popped
into memory. There are cases where a packet is divided into two portions: the first portion is written to
memory, and the second portion is left in the buffer and will be popped into memory in the next write. The
data left in the buffer is called residual data. The value of START_FLAG records the number of residual bits left
from the last write to memory. The number of residual bits is START_FLAG * 25. START_FLAG also indicates the
starting bit of the first valid packet in the current write. As an example: Assume that four DMA writes have
generated four DMA packets to be stored in the buffer with a total of 100-bit data. Then, one CPU write occurs
and generates one 50-bit CPU packet. The buffer will pop the previously-recorded 100-bit data plus the first
25 bits in the CPU packet into SRAM. The remaining 25 bits in the CPU packet is left in the buffer, waiting for
the next write. START_FLAG in the next write will indicate that 25 bits in this write is from the last write.
In loop writing mode, if data is looped several times in the storage memory, the residual data will interfere with
packet parsing. Therefore, users need to filter out the residual data in order to determine the starting position
of the first valid packet with START_FLAG and ASSIST_DEBUG_LOG_MEM_CURRENT_ADDR_REG. Once the
starting position of the packet is identified, the subsequent data is continuous and users do not need to care
about the value of START_FLAG.
Note that if data in the buffer does not reach 125 bits, it will not be written to memory. All data should be
written to memory for packet parsing. This can be done by disabling bus access logging. When
ASSIST_DEBUG_LOG_ENA is set to 0, if there is data in the buffer, it will be padded with zeros from the left until
it becomes 128 bits long and written to the memory.
• Read and parse data from the starting address. Read 128 bits each time.
• Use START_FLAG to determine the starting bit of the first packet. Starting bit = START_FLAG * 25 + 3.
Note that START_FLAG is only used to locate the starting bit of the first packet. Once the starting bit is located,
START_FLAG should be filtered out in the subsequent data.
After packet parsing is completed, clear the ASSIST_DEBUG_LOG_MEM_FULL_FLAG flag bit by setting
ASSIST_DEBUG_CLR_LOG_MEM_FULL_FLAG.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
17.6 Registers
The addresses in this section are relative to Debug Assistant base address provided in Table 3-3 in Chapter 3
System and Memory.
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
G_
BU
DE
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
G_
BU
DE
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
G_
BU
DE
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
U G_
EB
D
T_
S IS
AS
31 0
0 Reset
IN
M
P_
_S
_0
RE
CO
U G_
EB
D
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
UG_
DEB
T_
IS
S
AS
31 0
0x000000 Reset
LE
AB
EN
P_
OO
_L
E
EM
OD
NA
_M
_E
G_
OG
OG
LO
_L
_L
G_
UG
UG
BU
EB
EB
DE
)
ed
_D
T_
T_
rv
ST
IS
IS
se
SI
S
S
(re
AS
AS
AS
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
ASSIST_DEBUG_LOG_ENA Enables the CPU bus or DMA bus access logging. bit[0]: CPU bus ac-
cess logging; bit[1]: reserved; bit[2]: DMA bus access logging. (R/W)
_0
TA
DA
G_
LO
UG_
EB
D
T_
S IS
AS
31 0
0 Reset
ZEI
_S
TA
DA
OG_
_L
UG
B
DE
)
ed
T_
rv
IS
se
S
(re
AS
31 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
31 0
0 Reset
ASSIST_DEBUG_LOG_MIN Configures the lower bound address of monitored address space. (R/W)
AX
M
G_
LO
UG_
EB
D
T_
S IS
AS
31 0
0 Reset
RT
TA
_S
EM
M
G_
LO
G_
BU
DE
T_
S IS
AS
31 0
0 Reset
31 0
0 Reset
ASSIST_DEBUG_LOG_MEM_END Configures the end address of the storage space for recorded
data. (R/W)
R
A DD
G_
IN
T
RI
_W
EM
M
G_
LO
U G_
EB
D
T_
S IS
AS
31 0
0 Reset
LA AG
_F FL
LL L_
G
FU UL
M_ _F
ME EM
G_ _M
LO OG
G_ _L
BU LR
DE G_C
U
SIS EB
d)
AS T_D
rve
T_
SIS
e
es
AS
(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
ASSIST_DEBUG_LOG_MEM_FULL_FLAG The value “1” means there is a data overflow that exceeds
the storage space. (RO)
C
EX
E_
OR
BEF
C_
TP
AS
_L
_0
RE
CO
U G_
EB
D
T_
S IS
AS
31 0
0 Reset
IVE
CT
OD E_A
_M UL
E
UG 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
TE
DA
_
G_
BU
DE
d)
ve
T_
r
IS
se
S
(re
AS
31 28 27 0
0 0 0 0 0x2008010 Reset
18.1 Introduction
ESP32-C3 integrates an SHA accelerator, which is a hardware device that speeds up SHA algorithm
significantly, compared to SHA algorithm implemented solely in software. The SHA accelerator integrated in
ESP32-C3 has two working modes, which are Typical SHA and DMA-SHA.
18.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.
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 18-1.
Users can choose hash algorithms by configuring the SHA_MODE_REG register. For details, please see Table
18-2.
Notice:
ESP32-C3’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.
18.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 task.
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 Section “5.1 Padding the Message” in FIPS PUB 180-4 Spec.
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 Section “2.1 Glossary of Terms and Acronyms” in FIPS
PUB 180-4 Spec.
Before hash task 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-C3 SHA also supports optional “interleaved” message digest calculation. Users can insert
new calculation (both Typical SHA and DMA-SHA) each time the SHA accelerator completes a sequence of
operations.
• In Typical SHA mode, this can be done after each individual message block.
• In DMA-SHA mode, this can be done after a full sequence of DMA operations is complete.
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-C3 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-C3 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 2 GDMA Controller (GDMA).
DMA-SHA process
• Select a hash algorithm by configuring the SHA_MODE_REG register. For details, please refer to
Table 18-2.
• If the current DMA-SHA calculation follows a previous calculation, firstly write the message digest
from the previous calculation to registers SHA_H_n_REG, then write 1 to register
SHA_DMA_CONTINUE_REG to start SHA accelerator;
5. Wait till the completion of the DMA-SHA calculation, which happens when:
• An SHA interrupt occurs. In this case, please clear interrupt by writing 1 to the SHA_INT_CLEAR_REG
register.
Table 18-3. The Storage and Length of Message Digest from Different Algorithms
18.4.4 Interrupt
SHA accelerator supports interrupt on the completion of message digest calculation when working in the
DMA-SHA mode. To enable this function, write 1 to register SHA_INT_ENA_REG. Note that the interrupt should
be cleared by software after use via setting the SHA_INT_CLEAR_REG register to 1.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
18.6 Registers
The addresses in this section are relative to the SHA accelerator base address provided in Table 3-3 in Chapter
3 System and Memory.
A
ST
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
UE
IN
NT
d)
CO
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
TE
TA
_S
SY
)
ed
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
SHA_BUSY_STATE Indicates the states of SHA accelerator. (RO) 1’h0: idle 1’h1: busy
ART
ST
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
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
PT
RU
ER
NT
_I
AR
d)
E
ve
CL
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
A
EN
T_
UP
RR
)
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
DA
rv
A_
se
(re
SH
31 30 29 0
0 0 0x20190402 Reset
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
SHA_MODE Defines the SHA algorithm. For details, please see Table 18-2. (R/W)
M
NU
K_
OC
BL
A_
d)
DM
ver
A_
se
(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
n
H_
A_
SH
31 0
0x000000 Reset
SHA_H_n Stores the nth 32-bit piece of the Hash value. (R/W)
31 0
0x000000 Reset
19.1 Introduction
ESP32-C3 integrates an Advanced Encryption Standard (AES) Accelerator, which is a hardware device that
speeds up AES Algorithm significantly, compared to AES algorithms implemented solely in software. The AES
Accelerator integrated in ESP32-C3 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.
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-C3’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
472
1 Column “Bit” specifies the bytes of each word stored in w[0] ~ w[7].
ESP32-C3 TRM (Version 1.1)
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 2
GDMA Controller (GDMA).
6. Clear interrupt by writing 1 to the AES_INT_CLR_REG register, if any AES interrupt occurred during the
computation.
7. Release the AES Accelerator by writing 0 to the AES_DMA_EXIT_REG register. After this, the content of
the AES_STATE_REG register becomes 0. Note that, you can release DMA earlier, but only after Step 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 3-3 in Chapter
3 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) Stores 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) Stores the result text data when the AES Accelerator operates 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 Defines the key length and encryption / decryption of the AES Accelerator. For details,
see Table 19-2. (R/W)
LE
AB
EN
A_
)
ed
M
rv
D
se
S_
(re
AE
31 1 0
0x00000000 0 Reset
AES_DMA_ENABLE Defines the working mode of the AES Accelerator. 0: Typical AES, 1: DMA-AES.
For details, see Table 19-1. (R/W)
E
OD
M
C K_
)
ed
LO
rv
B
se
S_
(re
AE
31 3 2 0
0x00000000 0 Reset
AES_BLOCK_MODE Defines the block cipher mode of the AES Accelerator operating under the
DMA-AES working mode. For details, see Table 19-7. (R/W)
31 0
0x00000000 Reset
AES_BLOCK_NUM Stores the Block Number of plaintext or ciphertext when the AES Accelerator
operates under the DMA-AES working mode. For details, see Section 19.5.4. (R/W)
L
SE
d)
C_
ve
IN
r
se
S_
(re
AE
31 1 0
0x00000000 0 Reset
AES_INC_SEL Defines the Standard Incrementing Function for CTR block operation. Set this bit to
0 or 1 to choose INC32 or INC128 . (R/W)
ER
GG
)
ed
RI
rv
T
se
S_
(re
AE
31 1 0
0x00000000 x Reset
E
)
AT
ed
ST
rv
se
S_
(re
AE
31 2 1 0
AES_STATE Stores the working status of the AES Accelerator. For details, see Table 19-3 for Typical
AES working mode and Table 19-8 for DMA AES working mode. (RO)
M
rv
D
se
S_
(re
AE
31 1 0
0x00000000 x Reset
AES_DMA_EXIT Set this bit to 1 to exit AES operation. This register is only effective for DMA-AES
operation. (WO)
R
CL
d)
T_
ve
IN
r
se
S_
(re
AE
31 1 0
0x00000000 x Reset
NA
E
)
ed
T_
IN
rv
se
S_
(re
AE
31 1 0
0x00000000 0 Reset
AES_INT_ENA Set this bit to 1 to enable AES interrupt and 0 to disable interrupt. (R/W)
20.1 Introduction
The RSA Accelerator provides hardware support for high precision computation used in various RSA
asymmetric cipher algorithms by significantly reducing their software complexity. Compared with RSA
algorithms implemented solely in software, this hardware accelerator can speed up RSA algorithms
significantly. Besides, the RSA Accelerator also supports operands of different lengths, which provides more
flexibility during the computation.
20.2 Features
The following functionality is supported:
• Large-number multiplication
The RSA Accelerator is only available after the RSA-related memories are initialized. The content of the
RSA_CLEAN
_REG register is 0 during initialization and will become 1 after the initialization is done. Therefore, it is advised
to wait until RSA_CLEAN_REG becomes 1 before using the RSA Accelerator.
Notice:
ESP32-C3’s Digital Signature (DS) module also calls the RSA accelerator. Therefore, users cannot access
the RSA accelerator when Digital Signature (DS) is working.
RSA Accelerator supports operands of length N = 32 × x, where x ∈ {1, 2, 3, . . . , 96}. The bit lengths of
arguments Z, X, Y , M , and r can be arbitrary N , but all numbers in a calculation must be of the same length.
The bit length of M ′ must be 32.
To represent the numbers used as operands, let us define a base-b positional notation, as follows:
b = 232
N
n=
32
Z = (Zn−1 Zn−2 · · · Z0 )b
X = (Xn−1 Xn−2 · · · X0 )b
Y = (Yn−1 Yn−2 · · · Y0 )b
M = (Mn−1 Mn−2 · · · M0 )b
r = (rn−1 rn−2 · · · r0 )b
Each of the n values in Zn−1 · · · Z0 , Xn−1 · · · X0 , Yn−1 · · · Y0 , Mn−1 · · · M0 , rn−1 · · · r0 represents one base-b
digit (a 32-bit word).
Zn−1 , Xn−1 , Yn−1 , Mn−1 and rn−1 are the most significant bits of Z, X, Y , M , while Z0 , X0 , Y0 , M0 and r0
are the least significant bits.
The following equation in the form compatible with the extended binary GCD algorithm can be written
as�
M −1 × M + 1 = R × R−1
M ′ = M −1 mod b
(c) Configure registers related to the acceleration options, which are described later in Section 20.3.4.
Users need to write data to each memory block only according to the length of the number; data
beyond this length are ignored.
5. Wait for the completion of computation, which happens when the content of RSA_IDLE_REG becomes 1
or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT_REG to clear the interrupt, if you have enabled the interrupt function.
After the computation, the RSA_MODE_REG register, memory blocks RSA_Y_MEM and RSA_M_MEM, as well
as the RSA_M_PRIME_REG remain unchanged. However, Xi in RSA_X_MEM and ri in RSA_Z_MEM
computation are overwritten, and only these overwritten memory blocks need to be re-initialized before
starting another computation.
The RSA Accelerator supports large-number modular multiplication with operands of 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_IDLE_REG becomes 1
or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT_REG to clear the interrupt, if you have enabled the interrupt function.
After the computation, the length of operands in RSA_MODE_REG, the Xi in memory RSA_X_MEM, the Yi in
memory RSA_Y_MEM, the Mi in memory RSA_M_MEM, and the M ′ in memory RSA_M_PRIME_REG remain
unchanged. However, the ri in memory RSA_Z_MEM has already been overwritten, and only this overwritten
memory block needs to be re-initialized before starting another computation.
3. Write Xi and Yi for ∈ {0, 1, . . . , n − 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 are ignored.
5. Wait for the completion of computation, which happens when the content of RSA_IDLE_REG becomes 1
or the RSA interrupt occurs.
7. Write 1 to RSA_CLEAR_INTERRUPT_REG to clear the interrupt, if you have enabled the interrupt function.
After the computation, the length of operands in RSA_MODE_REG and the Xi in memory RSA_X_MEM remain
unchanged. However, the Yi in memory RSA_Z_MEM has already been overwritten, and only this overwritten
memory block needs to be re-initialized before starting another computation.
To be more specific, when neither of these two options are configured for 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 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. The maximum value of α is N -1, which leads to the same
result when this option is not used for 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.
– The accelerator speeds up the calculation by simplifying the calculation concerning the 0 bits of Y .
Therefore, the higher the proportion of bits 0 against bits 1, the better the acceleration performance
is.
We provide an example to demonstrate the performance of the RSA Accelerator under different combinations
of SEARCH and CONSTANT_TIME configuration. Here we perform Z = X Y mod M with N = 3072 and Y =
65537. Table 20-1 below demonstrates the time costs under different combinations of SEARCH and
CONSTANT_TIME configuration. Here, we should also mention that, α is set to 16 when the SEARCH option is
enabled.
• The time cost is the biggest when none of these two options is configured for acceleration.
• The time cost is the smallest when both of these two options are configured for acceleration.
• The time cost can be dramatically reduced when either or both option(s) are configured for 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.
20.6 Registers
The addresses in this section are relative to the RSA accelerator base address provided in Table 3-3 in Chapter
3 System and Memory.
G
RE
E_
M
RI
_P
M
A_
RS
31 0
0x000000000 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 0 0 0 0 0 0 0 0 0 0 Reset
N
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
RSA_CLEAN The content of this bit is 1 when memories complete initialization. (RO)
OD
ed
M
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
AR
ST
T_
UL
M
d)
OD
ve
M
r
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
AR
ST
T_
)
UL
ed
M
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LE
ed
ID
rv
A_
se
(re
RS
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RSA_IDLE The content of this bit is 1 when the RSA accelerator is idle. (RO)
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
E
MI
_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
LE
AB
_ EN
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
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 0x000 Reset
RSA_SEARCH_POS Is used to configure the starting address when the acceleration option of
search is used. (R/W)
NA
E
T_
UP
RR
d)
TE
ve
IN
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
RSA_INTERRUPT_ENA Set this bit to 1 to enable the RSA interrupt. This option is enabled by default.
(R/W)
TE
)
ed
DA
rv
A_
se
(re
RS
31 30 29 0
0 0 0x20200618 Reset
• Hash result only accessible by configurable hardware peripheral (in downstream mode)
• Generates 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 they are the same, then the identity of B is authenticated
To calculate the HMAC value (the following steps should be done by the user):
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_HARD_DIS_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 4
eFuse Controller (EFUSE). After bit EFUSE_SOFT_DIS_JTAG is set, the key to re-enable JTAG can be
calculated in HMAC module’s downstream mode. JTAG is re-enabled when the result configured by the user is
the same as the HMAC result.
To re-enable JTAG:
1. Users 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.
2. Users write 1 to the HMAC_SOFT_JTAG_CTRL_REG register to enter JTAG re-enable compare mode.
3. Users write the 256-bit HMAC value which is calculated locally from the 32-byte 0x00 using SHA-256
and the generated key to register HMAC_WR_JTAG_REG by writing 8 times and 32-bit each time in
big-endian word order.
4. If the HMAC result matches the value that users calculated locally, then JTAG is re-enabled. Otherwise,
JTAG remains disabled.
5. After writing 1 to HMAC_SET_INVALIDATE_JTAG_REG or resetting the chip, JTAG will be disabled. If users
want to re-enable JTAG again, they need to repeat the above steps again.
Before starting the DS module, users need to obtain the parameter decryption key for the DS module through
HMAC calculation. For more information, please see Chapter 22 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.
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 EFUSE_KEY_PURPOSE_x (We totally have 6 keys in eFuse, so x = 0,1,2,..,5), registers from 4 eFuse
Controller (EFUSE). Take upstream as example, if there is no EFUSE_KEY_PURPOSE_HMAC_UP in
EFUSE_KEY_PURPOSE_0~5, means there is no upstream used key in efuse. You 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 (there are six blocks for
storing a key in eFuse. The numbers of those blocks range from 4 to 9, so y = 4,5,..,9. Hence, if we are
talking about key0, we mean eFuse block4), and 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 4 eFuse Controller (EFUSE) on how to program
eFuse keys.
2. Configure this eFuse key block to be read protected, so that users cannot read its value. A copy of this
key should be kept by any party who needs to verify this device.
Please note that the key whose purpose is EFUSE_KEY_PURPOSE_HMAC_DOWN_ALL can be used for both
re-enabling JTAG or 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, will the HMAC module 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 3 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 3-3 in Chapter 3
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
NE
_O
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
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
HMAC_SET_TEXT_ING Set this bit to show there are still some message blocks to be processed.
(WO)
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
E ND
T_
UL
S
RE
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 Set this bit to 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
HMAC_SET_INVALIDATE_JTAG Set this bit to clear calculation results when re-enabling JTAG in
downstream mode. (WO)
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
HMAC_SET_INVALIDATE_DS Set this bit to clear calculation results of the DS module in downstream
mode. (WO)
K
EC
CH
EY_
UR
)
ed
_Q
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
• 1: error.
E
AT
ST
Y_
US
d)
_B
ve
AC
r
se
HM
(re
31 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
HMAC_BUSY_STATE Indicates whether HMAC is in busy state. Before configuring HMAC, please
make sure HMAC is in IDLE state. (RO)
• 0: idle.
T
SE
S E_
PO
UR
)
ed
_P
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 Determines 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 Selects 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
_0
TA
DA
_R
AC
HM
31 0
0 Reset
AD
_P
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
HMAC_SET_TEXT_PAD Set this bit to indicate that padding is applied by software. (WO)
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
HMAC_SET_ONE_BLOCK Set this bit when there is only one block which already contins padding
bits. (WO)
RL
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
G
JTA
R_
_W
AC
HM
31 0
x Reset
HMAC_WR_JTAG Set this field to re-enable the JTAG comparing input register. (WO)
_D
rv
AC
se
HM
(re
31 30 29 0
0 0 0x20200618 Reset
22.1 Overview
A Digital Signature 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.
The ESP32-C3 includes a Digital Signature (DS) module providing hardware acceleration of messages’
signatures based on RSA. It uses pre-encrypted parameters to calculate a signature. The parameters are
encrypted using HMAC as a key-derivation function. In turn, the HMAC uses eFuses as an input key. The
whole process happens in hardware so that neither the decryption key for the RSA parameters nor the input
key for the HMAC key derivation function can be seen by users while calculating the signature.
22.2 Features
• RSA digital signatures with key length up to 3072 bits
Private key parameters are stored in flash as ciphertext. They are decrypted using a key (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 4
eFuse Controller (EFUSE) 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 should be 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 as a
hexadecimal constant such as [0x0C]8 . If necessary, the value [x]t can be right-padded with (s − t)
number of 0 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 you 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
22.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 20.3.1 Large
Number Modular Exponentiation in Chapter 20 RSA Accelerator (RSA).
Note:
1. The software preparation (left side in the Figure 22-1) is a one-time operation before any signature is calculated,
while the hardware calculation (right side in the Figure 22-1) repeats for every signature calculation.
You need to follow the steps shown in the left part of Figure 22-1 to calculate C. Detailed instructions are as
follows:
• Step 1: Prepare operands Y and M whose lengths should meet the requirements in Section 22.3.2.
N
Define [L]32 = 32 (i.e., for RSA 3072, [L]32 == [0x60]32 ). Prepare [HM AC_KEY ]256 and calculate
[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 22-1. The DS module will call AES accelerator to
decrypt C in CBC block mode and get the resulted plaintext. The decryption process can be
represented by P = AES-CBC-DEC (C, DS_KEY , IV ), where IV (i.e., [IV ]128 ) is defined by you.
[DS_KEY ]256 is provided by 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 22-1, as it happens at the same time with MD check.
• MD check: The DS module calls SHA-256 to calculate the hash value [CALC_M D]256 (i.e., 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 message is generated, but it does not affect the subsequent operations.
The DS module treats X (input by you) and Y , M , r (compiled) 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 get 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 HMAC on the hardware 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.
d i (i ∈ {0, 1, . . . , 11}) to DS_BOX_MEM.
• write Box
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. You 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. You 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.
22.6 Registers
The addresses in this section are relative to Digital Signature base address provided in Table 3-3 in Chapter 3
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
E
M
)
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
SY
BU
Y_
d)
ER
ve
U
r
_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
DS_QUERY_KEY_WRONG 1-15: HMAC was activated, but the DS peripheral did not successfully re-
ceive the DS_KEY from the HMAC peripheral. (The biggest value is 15); 0: HMAC is not called.
(RO)
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
DS_PADDING_BAD 1: The padding check fails; 0: The padding check passes. (RO)
E
AT
rv
_D
se
(re
DS
31 30 29 0
0 0 0x20200618 Reset
23.1 Overview
The ESP32-C3 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.
23.2 Features
• General XTS_AES algorithm, compliant with IEEE Std 1619-2007
• Encryption and decryption functions jointly determined by registers configuration, eFuse parameters,
and boot mode
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 (SYSREG) peripheral (see 16 System Registers (SYSREG)), the following four bits in
register SYSTEM_EXTERNAL_DEVICE_ENCRYPT_DECRYPT_CONTROL_REG are relevant to the external
memory encryption and decryption:
• SYSTEM_ENABLE_DOWNLOAD_MANUAL_ENCRYPT
• SYSTEM_ENABLE_DOWNLOAD_G0CB_DECRYPT
• SYSTEM_ENABLE_DOWNLOAD_DB_ENCRYPT
• 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 4 eFuse Controller (EFUSE).
23.4.2 Key
The Manual Encryption block and Auto Decryption block share the same Key when implementing 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 23-1. In each case, the Key can be uniquely determined by BlockA .
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 of key purposes, please refer to Table 4-2 Secure Key Purpose Values in Chapter 4 eFuse
Controller (EFUSE).
• Size: the size of the target memory space, indicating the number of bytes encrypted in one encryption
operation, which supports 16 or 32 bytes.
• Base address: the base_addr of the target memory space. It is a 24-bit physical address, with range of
0x0000_0000 ~ 0x00FF_FFFF. It should be aligned to size, i.e., base_addr%size == 0.
For example, if there are 16 bytes of instruction data need to be encrypted and written to address 0x130 ~
0x13F in the external flash, then the target space is 0x130 ~ 0x13F, size is 16 (bytes), and base address is
0x130.
The encryption of any length (must be multiples of 16 bytes) of plaintext instruction/data can be completed
separately in multiple operations, and each operation has its individual target memory space and the relevant
parameters.
For Auto Decryption blocks, these parameters are automatically determined by hardware. For Manual
Encryption blocks, these parameters should be configured by users.
Note:
The “tweak” defined in Section Data units and tweaks of IEEE Std 1619-2007 is a 128-bit non-negative integer
(tweak), which can be generated according to tweak = (base_addr & 0x00FFFF80). The lowest 7 bits and the
highest 97 bits in tweak are always zero.
Actually, the Manual Encryption block does not care where the plaintext comes from, but only where the
ciphertext will be stored. Because of the strict correspondence between plaintext and ciphertext, in order to
better describe how the plaintext is stored in the register block, we assume that the plaintext is stored in the
target memory space in the first place and replaced by ciphertext after encryption. Therefore, the following
description no longer has the concept of “plaintext”, but uses “target memory space” instead. Please note
that the plaintext can come from everywhere in actual use, but users should understand how the plaintext is
stored in the register block.
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 data to the registers block XTS_AES_PLAIN_n_REG (n: 0-7). For detailed information,
please refer to Section 23.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 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 Chapter 27 SPI Controller (SPI)).
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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
23.7 Registers
The addresses in this section are relative to External Memory Encryption and Decryption base address
provided in Table 3-3 in Chapter 3 System and Memory.
_n
IN
LA
_P
ES
A
S_
XT
31 0
0x000000 Reset
E
IZ
ES
IN
_L
)
ed
ES
rv
A
se
S_
(re
XT
31 1 0
0x00000000 0 Reset
• 0: 16 bytes;
• 1: 32 bytes. (R/W)
ES
rv
A
se
S_
(re
XT
31 1 0
0x00000000 0 Reset
XTS_AES_DESTINATION Configures the type of the external memory. Currently, it must be set to 0,
as the Manual Encryption block only supports flash encryption. Errors may occur if users write
1.
• 0: flash;
S
ES
R
DD
_A
L
I CA
YS
H
_P
)
ed
ES
rv
A
se
S_
(re
XT
31 30 29 0
XTS_AES_PHYSICAL_ADDRESS Physical address. (Note that its value should be within the range
between 0x0000_0000 and 0x00FF_FFFF). (R/W)
R
GE
G
RI
_T
)
ed
ES
rv
A
se
S_
(re
XT
31 1 0
0x00000000 x Reset
SE
EA
EL
_R
)
ed
ES
rv
A
se
S_
(re
XT
31 1 0
0x00000000 x Reset
R OY
ST
E
_D
d)
ES
ve
A
r
se
S_
(re
XT
31 1 0
0x00000000 x Reset
TE
TA
_S
)
ed
ES
rv
A
se
S_
(re
XT
31 2 1 0
• 0x2 (XTS_AES_DONE): encryption is completed, but the encrypted result is not accessible
to SPI;
ES
rv
A
se
S_
(re
XT
31 30 29 0
0 0 0x20200111 Reset
24.2
2. Functional Description
功能描述
24.2.1 Clock Glitch Detection
2.1 毛刺检测
The Clock Glitch Detection module on ESP32-C3 monitors input clock signals from XTAL_CLK. If it detects a
ESP32-S2
glitch, namely a 的毛刺检测模块将对输入芯片的 XTAL_CLK
clock pulse (a or b in the figure below) 时钟信号进行检测,当时钟的脉宽
with a width ,a 或
shorter than 3 ns, input clock signals :)小
from
于 3ns 时,将认为检测到毛刺,触发毛刺检测信号
XTAL_CLK are blocked. ,屏蔽输入的 XTAL_CLK 时钟信号。
a a
XTAL_CLK
b
2.2 中断及复位
24.2.2 Reset
当毛刺检测信号触发后,毛刺检测模块将向系统发送中断,GLITCH_DET_INT),如果
Once detecting a glitch on XTAL_CLK that affects the circuit’s normal operation, the Clock Glitch Detection
RTC_CNTL_GLITCH_RST_EN 使能,将触发系统级复位。
module triggers a system reset if RTC_CNTL_GLITCH_RST_EN bit is enabled. By default, this bit is set to
enable a reset.
25.1 Introduction
The ESP32-C3 contains a true random number generator, which generates 32-bit random numbers that can
be used for cryptographical operations, among other things.
25.2 Features
The random number generator in ESP32-C3 generates true random numbers, which means random number
generated from a physical process, rather than by means of an algorithm. No number generated within the
specified range is more or less likely to appear than any other number.
• Thermal noise comes from the high-speed ADC or SAR ADC or both. Whenever the high-speed ADC or
SAR ADC is enabled, bit streams will be generated and fed into the random number generator through an
XOR logic gate as random seeds.
• 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 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 (20 MHz), which is generated from an internal RC oscillator (see Chapter 6
Reset and Clock for details). Thus, it is advisable to read the RNG_DATA_REG register at a maximum rate of 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 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 34
On-Chip Sensor and Analog Signal Processing.
• High-speed ADC is enabled automatically when the Wi-Fi or Bluetooth modules 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 RNG_DATA_REG register multiple times until sufficient
random numbers have been generated. Ensure the rate at which the register is read does not exceed the
frequencies described in section 25.3 above.
25.6 Register
31 0
0x00000000 Reset
26.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-C3 has two UART controllers
compatible with various UART devices. They support Infrared Data Association (IrDA) and RS485
transmission.
Each of the two UART controllers has a group of registers that function identically. In this chapter, the two
UART controllers are referred to as UARTn, in which n denotes 0 or 1.
A UART is a character-oriented data link for asynchronous communication between devices. Such
communication does not add clock signals to the data sent. Therefore, in order to communicate successfully,
the transmitter and the receiver must operate at the same baud rate with the same stop bit(s) and parity
bit.
A UART data frame usually begins with one start bit, followed by data bits, one parity bit (optional) and one or
more stop bits. UART controllers on ESP32-C3 support various lengths of data bits and stop bits. These
controllers also support software and hardware flow control as well as GDMA for seamless high-speed data
transfer. This allows developers to use multiple UART ports at minimal software cost.
26.2 Features
Each UART controller has the following features:
• 512 x 8-bit RAM shared by TX FIFOs and RX FIFOs of the two UART controllers
• Parity bit
• RS485 protocol
• IrDA protocol
Figure 26-2 shows the basic structure of a UART controller. A UART controller works in two clock domains,
namely APB_CLK domain and Core Clock domain (the UART Core’s clock domain). The UART Core has three
clock sources: a 80 MHz APB_CLK, RC_FAST_CLK and external crystal clock XTAL_CLK (for details, please
refer to Chapter 6 Reset and Clock), which are selected by configuring UART_SCLK_SEL. The selected clock
source is divided by a divider to generate clock signals that drive the UART Core. The divisor is configured by
UART_CLKDIV_REG: UART_CLKDIV for the integral part, and UART_CLKDIV_FRAG for the fractional part.
A UART controller is broken down into two parts according to functions: a transmitter and a receiver.
The transmitter contains a TX FIFO, which buffers data to be sent. Software can write data to Tx_FIFO via the
APB bus, or move data to Tx_FIFO using 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 signal txd_out can be inverted by configuring the UART_TXD_INV field.
The receiver contains a RX FIFO, which buffers data to be processed. The levels of input signal rxd_in can be
inverted by configuring UART_RXD_INV field. Baudrate_Detect measures the baud rate of input signal rxd_in by
detecting its minimum pulse width. Start_Detect detects the start bit in a data frame. If the start bit is
detected, Rx_FSM stores data bits in the data frame into Rx_FIFO by Rx_FIFO_Ctrl. 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 automatically adding special characters to
outgoing data and detecting special characters in incoming data. When a UART controller is Light-sleep mode
(see Chapter 9 Low-power Management for more details), Wakeup_Ctrl counts up rising edges of rxd_in.
When the number is equal to or greater than (UART_ACTIVE_THRESHOLD + 3), a wake_up signal is generated
and sent to RTC, which then wakes up the ESP32-C3 chip.
When the frequency of the UART Core’s clock 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 value 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 Core Clock domain,
please follow procedures in Section26.5.
• clear SYSTEM_UARTn_RST to 0;
• write 1 to UART_RST_CORE;
• write 1 to SYSTEM_UARTn_RST;
• clear SYSTEM_UARTn_RST to 0;
• clear UART_RST_CORE to 0.
Note that it is not recommended to reset the APB clock domain module or UART Core only.
The two UART controllers on ESP32-C3 share 512 × 8 bits of FIFO RAM. As Figure 26-3 illustrates, RAM is
divided into 4 blocks, each has 128 × 8 bits. Figure 26-3 shows how many RAM blocks are allocated to TX
FIFOs and RX FIFOs of the two UART controllers by default. UARTn Tx_FIFO can be expanded by configuring
UART_TX_SIZE, while UARTn Rx_FIFO can be expanded by configuring UART_RX_SIZE. Some limits are
imposed:
• UART1 Tx_FIFO can be increased up to 3 blocks (from offset 128 to the end address);
• UART0 Rx_FIFO can be increased up to 2 blocks (from offset 256 to the end address);
Please note that starting addresses of all FIFOs are fixed, so expanding one FIFO may take up the default
space of other FIFOs. For example, by setting UART_TX_SIZE of UART0 to 2, the size of UART0 Tx_FIFO is
increased by 128 bytes (from offset 0 to offset 255). In this case, UART0 Tx_FIFO takes up the default space
for UART1 Tx_FIFO, and UART1’s transmitting function cannot be used as a result.
When neither of the two UART controllers is active, RAM could enter low-power mode by setting
UART_MEM_FORCE_PD.
UART0 Tx_FIFO and UART1 Tx_FIFO are reset by setting UART_TXFIFO_RST. UART0 Rx_FIFO and UART1
Rx_FIFO are reset by setting UART_RXFIFO_RST.
Data to be sent is written to TX FIFO via the APB bus or using 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_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 26-4, 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 26-4 below, to make the output timing more
uniform:
To support IrDA (see Section 26.4.7 for details), the fractional clock divider for IrDA data transmission
generates clock signals divided by 16 × UART_CLKDIV_REG. This divider works similarly as the one elaborated
above: it takes UART_CLKDIV/16 as the integer value and the lowest four bits of UART_CLKDIV as the fractional
value.
Automatic baud rate detection (Autobaud) on UARTs is enabled by setting UART_AUTOBAUD_EN. The
Baudrate_Detect module shown in Figure 26-2 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 26-5. 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. 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 26-5, 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 26-6 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 26.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 is still 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 26-7 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 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.
26.4.6 RS485
The two UART controllers support RS485 protocol. This protocol uses differential signals to transmit data, so it
can communicate over longer distances at higher bit rates than RS232. RS485 has two-wire half-duplex mode
and four-wire full-duplex mode. UART controllers support two-wire half-duplex transmission and bus snooping.
In a two-wire RS485 multidrop network, there can be 32 slaves at most.
As shown in Figure 26-8, in a two-wire multidrop network, an external RS485 transceiver is needed for
differential to single-ended conversion. 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 26-8, DE is connected to dtrn_out of UART (please refer to
Section 26.4.9.1 for more details).
transceiver
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 26-8, 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.
26.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 26-9, the IrDA
encoder converts a NRZ (non-return to zero code) signal to a RZI (return to zero inverted code) signal and
sends it to the external driver and infrared LED. This encoder uses modulated signals whose pulse width is
3/16 bits to indicate logic “0”, and low levels to indicate logic “1”. The IrDA decoder receives signals from the
infrared receiver and converts them to NRZ signals. In most cases, the receiver is high when it is idle, and the
encoder output polarity is the opposite of the decoder input polarity. If a low pulse is detected, it indicates
that a start bit has been received.
When IrDA function is enabled, one bit is divided into 16 clock cycles. If the bit to be sent is zero, then the
9th, 10th and 11th clock cycle are high.
Figure 26-9. 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 26-10, IrDA function is enabled by setting UART_IRDA_EN. When UART_IRDA_TX_EN is set (high), the
IrDA transceiver is enabled to send data and not allowed to receive data; when UART_IRDA_TX_EN is reset
(low), the IrDA transceiver is enabled to receive data and not allowed to send data.
26.4.8 Wake-up
UART0 and UART1 can be set as wake-up source. When a UART controller is in Light-sleep mode, Wakeup_Ctrl
counts up the rising edges of rxd_in. When the number of rising edges is is equal to or greater than
(UART_ACTIVE_THRESHOLD + 3), a wake_up signal is generated and sent to RTC, which then wakes up
ESP32-C3.
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 26-11 shows the hardware flow control of a UART controller. Hardware flow control uses output signal
rtsn_out and input signal dsrn_in. Figure 26-12 illustrates how these signals are connected between UART on
ESP32-C3 (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 a edge change of dsrn_in, a UART_DSR_CHG_INT
interrupt is generated. After this interrupt is detected, software can obtain the level of input signal dsrn_in by
reading UART_DSRN. If dsrn_in is high, it indicates that EU0 is ready to transmit data.
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.
Figure 26-13 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 receives more data than the capacity of RX FIFO.
• UART_RXFIFO_FULL_INT: Triggered when the receiver receives more data than what
UART_RXFIFO_FULL_THRHD specifies.
• UHCI_SEND_A_REG_Q_INT: Triggered when 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.
Read in Core Clock domain, synchronous registers implement the clock domain crossing design to ensure
that their values sampled in Core Clock domain are correct. These registers as listed in Table 26-1 are
configured as follows:
• Wait for UART_REG_UPDATE to become 0, which indicates the completion of last synchronization;
Register Field
UART_CLKDIV_REG UART_CLKDIV_FRAG[3:0]
UART_CLKDIV[11:0]
UART_CONF0_REG UART_AUTOBAUD_EN
UART_ERR_WR_MASK
UART_TXD_INV
UART_RXD_INV
UART_IRDA_EN
UART_TX_FLOW_EN
UART_LOOPBACK
UART_IRDA_RX_INV
UART_IRDA_TX_EN
UART_IRDA_WCTL
UART_IRDA_TX_EN
UART_IRDA_DPLX
UART_STOP_BIT_NUM
UART_BIT_NUM
UART_PARITY_EN
Cont’d on next page
Static registers, though also read in Core Clock domain, would not change dynamically when UART controllers
are at work, so they do not implement the clock domain crossing design. These registers must be configured
when the UART transmitter or receiver is not at work. In this case, software can turn off the clock for the UART
transmitter or receiver, so that static registers are not sampled in their metastable state. When software turns
on the clock, the configured values are stable to be correctly sampled. Static registers as listed in Table 26-2
are configured as follows:
• Turn off the clock for the UART transmitter by clearing UART_TX_SCLK_EN, or the clock for the UART
receiver by clearing UART_RX_SCLK_EN, depending on which one (transmitter or receiver) is not at work;
• Turn on the clock for the UART transmitter by writing 1 to UART_TX_SCLK_EN, or the clock for the UART
receiver by writing 1 to UART_RX_SCLK_EN.
Register Field
UART_RX_FILT_REG UART_GLITCH_FILT_EN
UART_GLITCH_FILT[7:0]
UART_SLEEP_CONF_REG UART_ACTIVE_THRESHOLD[9:0]
UART_SWFC_CONF0_REG UART_XOFF_CHAR[7:0]
UART_SWFC_CONF1_REG UART_XON_CHAR[7:0]
UART_IDLE_CONF_REG UART_TX_IDLE_NUM[9:0]
UART_AT_CMD_PRECNT_REG UART_PRE_IDLE_NUM[15:0]
UART_AT_CMD_POSTCNT_REG UART_POST_IDLE_NUM[15:0]
UART_AT_CMD_GAPTOUT_REG UART_RX_GAP_TOUT[15:0]
UART_AT_CMD_CHAR_REG UART_CHAR_NUM[7:0]
Cont’d on next page
Except those listed in Table 26-1 and Table 26-2, registers that can be configured by software are immediate
registers read in APB_CLK domain, such as interrupt and FIFO configuration registers.
To initialize URATn:
• clear SYSTEM_UARTn_RST;
• write 1 to UART_RST_CORE;
• write 1 to SYSTEM_UARTn_RST;
• clear SYSTEM_UARTn_RST;
• clear UART_RST_CORE;
• 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.
26.7 Registers
The addresses in this section are relative to UART Controller base address provided in Table 3-3 in Chapter 3
System and Memory.
Y TE
_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
CE U
D
RH
OR _P
_P
RH
_F RCE
H
TH
_T
T_
OW
EM FO
ZE
ZE
U
_M _
TO
FL
SI
I
RT EM
_S
)
)
X_
X_
X_
ed
ed
X
UA T_M
_R
_R
_R
_T
rv
rv
RT
RT
RT
RT
se
se
R
(re
(re
UA
UA
UA
UA
UA
31 28 27 26 25 16 15 7 6 4 3 1 0
UART_RX_SIZE This field is used to configure the amount of RAM allocated for RX FIFO. The default
number is 128 bytes. (R/W)
UART_TX_SIZE This field is used to configure the amount of RAM allocated for TX FIFO. The default
number is 128 bytes. (R/W)
UART_RX_FLOW_THRHD This field is used to configure the maximum amount of data bytes that can
be received when hardware flow control works. (R/W)
UART_RX_TOUT_THRHD This field is used to configure the threshold time that the receiver takes
to receive one byte, in the unit of bit time (the time it takes to transfer one bit). The
UART_RXFIFO_TOUT_INT interrupt will be triggered when the receiver takes more time to receive
one byte with UART RX_TOUT_EN set to 1. (R/W)
UART_MEM_FORCE_PD Set this bit to force power down UART RAM. (R/W)
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
UART_RXFIFO_FULL_INT_RAW This interrupt raw bit turns to high level when the receiver receives
more data than what UART_RXFIFO_FULL_THRHD specifies. (R/WTC/SS)
UART_TXFIFO_EMPTY_INT_RAW This interrupt raw bit turns to high level when the amount of data
in TX FIFO is less than what UART_TXFIFO_EMPTY_THRHD specifies. (R/WTC/SS)
UART_PARITY_ERR_INT_RAW This interrupt raw bit turns to high level when the receiver detects a
parity error in the data. (R/WTC/SS)
UART_FRM_ERR_INT_RAW This interrupt raw bit turns to high level when the receiver detects a data
frame error. (R/WTC/SS)
UART_RXFIFO_OVF_INT_RAW This interrupt raw bit turns to high level when the receiver receives
more data than the capacity of RX FIFO. (R/WTC/SS)
UART_DSR_CHG_INT_RAW This interrupt raw bit turns to high level when the receiver detects the
edge change of DSRn signal. (R/WTC/SS)
UART_CTS_CHG_INT_RAW This interrupt raw bit turns to high level when the receiver detects the
edge change of CTSn signal. (R/WTC/SS)
UART_BRK_DET_INT_RAW This interrupt raw bit turns to high level when the receiver detects a 0
after the stop bit. (R/WTC/SS)
UART_RXFIFO_TOUT_INT_RAW This interrupt raw bit turns to high level when the receiver takes more
time than UART_RX_TOUT_THRHD to receive a byte. (R/WTC/SS)
UART_SW_XON_INT_RAW This interrupt raw bit turns to high level when the receiver receives an
XON character and UART_SW_FLOW_CON_EN is set to 1. (R/WTC/SS)
UART_SW_XOFF_INT_RAW This interrupt raw bit turns to high level when the receiver receives an
XOFF character and UART_SW_FLOW_CON_EN is set to 1. (R/WTC/SS)
UART_GLITCH_DET_INT_RAW This interrupt raw bit turns to high level when the receiver detects a
glitch in the middle of a start bit. (R/WTC/SS)
UART_TX_BRK_DONE_INT_RAW This interrupt raw bit turns to high level when the transmitter com-
pletes sending NULL characters, after all data in TX FIFO are sent. (R/WTC/SS)
UART_TX_BRK_IDLE_DONE_INT_RAW This interrupt raw bit turns to high level when the transmitter
has kept the shortest duration after sending the last data. (R/WTC/SS)
UART_TX_DONE_INT_RAW This interrupt raw bit turns to high level when the transmitter has sent
out all data in FIFO. (R/WTC/SS)
UART_RS485_PARITY_ERR_INT_RAW This interrupt raw bit turns to high level when the receiver
detects a parity error from the echo of the transmitter in RS485 mode. (R/WTC/SS)
UART_RS485_FRM_ERR_INT_RAW This interrupt raw bit turns to high level when the receiver de-
tects a data frame error from the echo of the transmitter in RS485 mode. (R/WTC/SS)
UART_RS485_CLASH_INT_RAW This interrupt raw bit turns to high level when a collision is detected
between the transmitter and the receiver in RS485 mode. (R/WTC/SS)
UART_AT_CMD_CHAR_DET_INT_RAW This interrupt raw bit turns to high level when the receiver
detects the configured UART_AT_CMD_CHAR. (R/WTC/SS)
UART_WAKEUP_INT_RAW This interrupt raw bit turns to high level when the input RXD edge
changes more times than what (UART_ACTIVE_THRESHOLD + 3�specifies in Light-sleep mode.
(R/WTC/SS)
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
UART_RXFIFO_FULL_INT_CLR Set this bit to clear the UART_THE RXFIFO_FULL_INT interrupt. (WT)
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
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
UART_GLITCH_FILT When input pulse width is lower than this value, the pulse is ignored. (R/W)
M
SK
R LK R_ EN
R RR AU N
NU
R D X_ V
R D AC N
R D C V
UA _E OB K_E
UA T_D _E MA
UA T_T A_D EN
UA T_C _W D_
UA T_T A_E ST
UA _IR PB _E
UA T_IR A_W IN
UA T_IR A_T TL
UA T_S _B LX
UA T_IR A_R K
IT N
T_
R D _R
R D X_
R XF _R
RT OO W
AR Y_E
M
RT W_ RK
RT UT CL
R XD P
R TS V
R X_ N
S V
R XF V
RT XD V
R D X
R XD V
BI
W R
R SR V
_S TS
R TR N
UA T_C _IN
UA T_R _IN
UA T_L FLO
UA T_T _IN
UA T_T _IN
NU
UA T_R _IN
Y
_S DT
UA _D _IN
UA T_R IFO
UA T_A M_
P_
_P IT
_R
IT_
)
TO
RT AR
ed
R E
T
UA _M
_B
UA _P
rv
RT
RT
RT
RT
se
R
(re
UA
UA
UA
UA
31 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3 0 0 Reset
UART_PARITY This bit is used to configure the parity check mode. (R/W)
UART_STOP_BIT_NUM This field is used to set the length of stop bit. (R/W)
UART_SW_RTS This bit is used to configure the software RTS signal which is used in software flow
control. (R/W)
UART_SW_DTR This bit is used to configure the software DTR signal which is used in software flow
control. (R/W)
UART_TXD_BRK Set this bit to enable the transmitter to send NULL characters when the process of
sending data is done. (R/W)
UART_IRDA_TX_EN This is the start enable bit for IrDA transmitter. (R/W)
UART_IRDA_WCTL 1: The IrDA transmitter’s 11th bit is the same as 10th bit; 0: Set IrDA transmitter’s
11th bit to 0. (R/W)
UART_IRDA_TX_INV Set this bit to invert the level of IrDA transmitter. (R/W)
UART_IRDA_RX_INV Set this bit to invert the level of IrDA receiver. (R/W)
UART_LOOPBACK Set this bit to enable UART loopback test mode. (R/W)
UART_TX_FLOW_EN Set this bit to enable flow control function for the transmitter. (R/W)
UART_RXD_INV Set this bit to invert the level value of UART RXD signal. (R/W)
UART_CTS_INV Set this bit to invert the level value of UART CTS signal. (R/W)
UART_DSR_INV Set this bit to invert the level value of UART DSR signal. (R/W)
UART_TXD_INV Set this bit to invert the level value of UART TXD signal. (R/W)
UART_RTS_INV Set this bit to invert the level value of UART RTS signal. (R/W)
UART_DTR_INV Set this bit to invert the level value of UART DTR signal. (R/W)
UART_CLK_EN 1: Force clock on for register; 0: Support clock only when application writes regis-
ters. (R/W)
UART_ERR_WR_MASK 1: The receiver stops storing data into FIFO when data is wrong; 0: The
receiver stores the data even if the received data is wrong. (R/W)
UART_AUTOBAUD_EN This is the enable bit for baud rate detection. (R/W)
D
RH
OV IS
RH
T_ D
TH
F
TH
DA W_
Y_
L_
X_ LO
PT
IS UT N
UA T_R FL _EN
UL
_D TO _E
_R _F
M
RT X_ OW
_F
_E
R X_ UT
FO
FO
UA T_R TO
I
)
FI
R X_
XF
ed
X
UA T_R
_R
_T
rv
RT
RT
se
R
(re
UA
UA
UA
31 22 21 20 19 18 17 9 8 0
UART_RX_TOUT_FLOW_DIS Set this bit to stop accumulating idle_cnt when hardware flow control
works. (R/W)
UART_RX_FLOW_EN This is the flow enable bit for UART receiver. (R/W)
UART_RX_TOUT_EN This is the enable bit for UART receiver’s timeout function. (R/W)
N
_E
ON
RT ON _X F
LO EL
_C
_S O ON
UA T_X CE OF
UA T_F D_ FF
UA T_F CE N
_F D
W
R EN XO
R OR XO
R OR _X
W FF_
UA T_S D_
d)
R EN
ve
UA T_S
r
se
R
(re
UA
31 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UART_SW_FLOW_CON_EN Set this bit to enable software flow control. When UART receives
flow control characters XON or XOFF, which can be configured by UART_XON_CHAR or
UART_XOFF_CHAR respectively, UART_SW_XON_INT or UART_SW_XOFF_INT interrupts can be
triggered if enabled. (R/W)
UART_XONOFF_DEL Set this bit to remove flow control characters from the received data. (R/W)
UART_FORCE_XON Set this bit to force the transmitter to send data. (R/W)
UART_FORCE_XOFF Set this bit to stop the transmitter from sending data. (R/W)
UART_SEND_XON Set this bit to send an XON character. This bit is cleared by hardware automatically.
(R/W/SS/SC)
UART_SEND_XOFF Set this bit to send an XOFF character. This bit is cleared by hardware automat-
ically. (R/W/SS/SC)
D
OL
SH
E
HR
_T
VEI
)
CT
ed
_A
rv
RT
se
(re
UA
31 10 9 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0xf0 Reset
UART_ACTIVE_THRESHOLD UART is activated from Light-sleep mode when the input RXD edge
changes more times than the value of this field plus 3. (R/W)
D
OL
SH
R
RE
A
CH
TH
F_
F_
d)
OF
OF
ve
_X
_X
r
RT
RT
se
(re
UA
UA
31 17 16 9 8 0
UART_XOFF_THRESHOLD When the number of data bytes in RX FIFO is more than the value of this
field with UART_SW_FLOW_CON_EN set to 1, the transmitter sends an XOFF character. (R/W)
UART_XOFF_CHAR This field stores the XOFF flow control character. (R/W)
LD
HO
ES
AR
HR
H
_C
_T
ON
ON
)
ed
_X
_X
rv
RT
RT
se
(re
UA
UA
31 17 16 9 8 0
UART_XON_THRESHOLD When the number of data bytes in RX FIFO is less than the value of this
field with UART_SW_FLOW_CON_EN set to 1, the transmitter sends an XON character. (R/W)
UART_XON_CHAR This field stores the XON flow control character. (R/W)
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 This field is used to configure the number of 0 to be sent after the process of
sending data is done. It is active when UART_TXD_BRK is set to 1. (R/W)
HD
UM
HR
_N
_T
LE
LE
ID
ID
)
X_
X_
ed
_R
_T
rv
RT
RT
se
(re
UA
UA
31 20 19 10 9 0
UART_RX_IDLE_THRHD A frame end signal is generated when the receiver takes more time to re-
ceive one byte data than the value of this field, in the unit of bit time (the time it takes to transfer
one bit). (R/W)
UART_TX_IDLE_NUM This field is used to configure the duration time between transfers, in the unit
of bit time (the time it takes to transfer one bit). (R/W)
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 S4 RX DL
DL
UA _R 85 X_
X_
N
RT S4 _R
_E
_T
S4 N
_R _E
85
UA _R 85
85
)
RT L0
S4
RT S4
ed
_R
UA R
rv
_
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 Set this bit to enable the receiver could receive data when the transmitter
is transmitting data in RS485 mode. (R/W)
UART_RS485RXBY_TX_EN 1: enable RS485 transmitter to send data when RS485 receiver line is
busy. (R/W)
UART_RS485_RX_DLY_NUM This bit is used to delay the receiver’s internal data signal. (R/W)
UART_RS485_TX_DLY_NUM This field is used to delay the transmitter’s internal data signal. (R/W)
M
NU
RT ST LK_ N
CL OR N
B
A
UA _R SC _E
_S _C E
IV_
IV_
IV_
K_ E
L
EN
RT X_ LK
SE
_D
UA T_T SC
K_
K_
K_
K
)
R X_
CL
CL
CL
CL
ed
UA T_R
_S
_S
_S
_S
rv
RT
RT
RT
RT
se
R
(re
UA
UA
UA
UA
UA
31 26 25 24 23 22 21 20 19 12 11 6 5 0
UART_RST_CORE Write 1 and then write 0 to this bit, to reset UART TX/RX. (R/W)
T
T
N
N
_C
_C
FO
FO
N
N
_D N
_D N
I
SR
)
)
RT XD
TR
FI
RT TS
RT TS
XF
R XD
ed
ed
X
UA _C
UA T_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 26 25 16 15 14 13 12 10 9 0
1 1 1 0 0 0 0 1 1 0 0 0 0 0 Reset
UART_DSRN This bit represents the level of the internal UART DSR signal. (RO)
UART_CTSN This bit represents the level of the internal UART CTS signal. (RO)
UART_RXD This bit represents the level of the internal UART RXD signal. (RO)
UART_DTRN This bit represents the level of the internal UART DTR signal. (RO)
UART_RTSN This bit represents the level of the internal UART RTS signal. (RO)
UART_TXD This bit represents the level of the internal UART TXD signal. (RO)
DR
AD
W
DR
X_
AD
_T
R
PB
)
)
X_
ed
ed
_A
_T
rv
rv
RT
RT
se
se
(re
(re
UA
UA
31 21 20 11 10 9 0
UART_APB_TX_WADDR This field stores the offset address in TX FIFO when software writes TX FIFO
via APB. (RO)
UART_TX_RADDR This field stores the offset address in TX FIFO when TX FSM reads data via
Tx_FIFO_Ctrl. (RO)
R
DD
RA
DR
X_
AD
_R
W
PB
)
)
X_
ed
ed
_R
_A
rv
rv
RT
RT
se
se
(re
(re
UA
UA
31 21 20 11 10 9 0
UART_APB_RX_RADDR This field stores the offset address in RX FIFO when software reads data
from RX FIFO via APB. UART0 is 0x200. UART1 is 0x280. (RO)
UART_RX_WADDR This field stores the offset address in RX FIFO when Rx_FIFO_Ctrl writes RX FIFO.
(RO)
_O
_O
RX
X
UT
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
NT
_C
IN
E _M
LS
PU
OW
)
ed
_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
UART_LOWPULSE_MIN_CNT This field stores the value of the minimum duration time of the low
level pulse, in the unit of APB_CLK cycles. It is used in baud rate detection. (RO)
NT
_C
IN
_M
SE
UL
HP
)
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
UART_HIGHPULSE_MIN_CNT This field stores the value of the maximum duration time for the high
level pulse, in the unit of APB_CLK cycles. It is used in baud rate detection. (RO)
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 This field stores the count of RXD edge change. It is used in baud rate
detection. (RO)
NT
_C
IN
M
E_
EDG
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 This field stores the minimal input clock count between two positive
edges. It is used in 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 This field stores the minimal input clock count between two negative
edges. It is used in baud rate detection. (RO)
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 This field is used to configure the idle duration time before the first AT_CMD
is received by the receiver, in the unit of bit time (the time it takes to transfer one 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 This field is used to configure the duration time between the last AT_CMD
and the next data byte, in the unit of bit time (the time it takes to transfer one bit). (R/W)
U T
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
UART_RX_GAP_TOUT This field is used to configure the duration time between the AT_CMD char-
acters, in the unit of bit time (the time it takes to transfer one bit). (R/W)
AR
CH
UM
D_
N
R_
CM
HA
)
T_
ed
_C
_A
rv
RT
RT
se
(re
UA
UA
31 16 15 8 7 0
UART_AT_CMD_CHAR This field is used to configure the content of AT_CMD character. (R/W)
UART_CHAR_NUM This field is used to configure the number of continuous AT_CMD characterss
received by the receiver. (R/W)
E
AT
_D
RT
UA
31 0
0x2008270 Reset
D
UA T_R
_I
RT
R
UA
UA
31 30 29 0
0 1 0x000500 Reset
UART_UPDATE_CTRL This bit is used to control register synchronization mode. This bit must be
cleared before writing 1 to UART_REG_UPDATE to synchronize configured values to UART Core’s
clock domain. (R/W)
UART_REG_UPDATE When this bit is set to 1 by software, registers are synchronized to UART Core’s
clock domain. This bit is cleared by hardware after synchronization is done. (R/W/SC)
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, then write 0 to this bit to reset decode state machine. (R/W)
UHCI_RX_RST Write 1, then write 0 to this bit to reset encode state machine. (R/W)
UHCI_SEPER_EN Set this bit to separate the data frame using a special character. (R/W)
UHCI_HEAD_EN Set this bit to encode the data packet with a formatting header. (R/W)
UHCI_CRC_REC_EN Set this bit to enable UHCI to receive the 16 bit CRC. (R/W)
UHCI_UART_IDLE_EOF_EN If this bit is set to 1, UHCI will end the payload receiving process when
UART has been in idle state. (R/W)
UHCI_LEN_EOF_EN If this bit is set to 1, UHCI decoder stops receiving payload data when the
number of received data bytes has reached the specified value. The value is payload length
indicated by UHCI packet header when UHCI_HEAD_EN is 1 or the value is configuration value
when UHCI_HEAD_EN is 0. If this bit is set to 0, UHCI decoder stops receiving payload data
when 0xC0 has been received. (R/W)
UHCI_ENCODE_CRC_EN Set this bit to enable data integrity check by appending a 16 bit CCITT-CRC
to end of the payload. (R/W)
UHCI_CLK_EN 1: Force clock on for register; 0: Support clock only when application writes regis-
ters. (R/W)
UHCI_UART_RX_BRK_EOF_EN If this bit is set to 1, UHCI will end payload receive process when
NULL frame is received by UART. (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_SUM_EN This is the enable bit to check header checksum when UHCI receives a
data packet. (R/W)
UHCI_CHECK_SEQ_EN This is the enable bit to check sequence number when UHCI receives a
data packet. (R/W)
UHCI_CRC_DISABLE Set this bit to support CRC calculation. Data Integrity Check Present bit in
UHCI packet frame should be 1. (R/W)
UHCI_SAVE_HEAD Set this bit to save the packet header when UHCI receives a data packet. (R/W)
UHCI_TX_CHECK_SUM_RE Set this bit to encode the data packet with a checksum. (R/W)
UHCI_TX_ACK_NUM_RE Set this bit to encode the data packet with an acknowledgment when a
reliable packet is to be transmitted. (R/W)
UHCI_WAIT_SW_START The UHCI der will jump to ST_SW_WAIT status if this bit is set to 1. (R/W)
UHCI_SW_START If current UHCI_ENCODE_STATE is ST_SW_WAIT, the UHCI will start to send data
packet out when this bit is set to 1. (R/W/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 Set this bit to decode character 0xC0 when DMA receives data. (R/W)
UHCI_TX_DB_ESC_EN Set this bit to decode character 0xDB when DMA receives data. (R/W)
UHCI_TX_11_ESC_EN Set this bit to decode flow control character 0x11 when DMA receives data.
(R/W)
UHCI_TX_13_ESC_EN Set this bit to decode flow control character 0x13 when DMA receives data.
(R/W)
UHCI_RX_C0_ESC_EN Set this bit to replace 0xC0 by special characters when DMA sends data.
(R/W)
UHCI_RX_DB_ESC_EN Set this bit to replace 0xDB by special characters when DMA sends data.
(R/W)
UHCI_RX_11_ESC_EN Set this bit to replace flow control character 0x11 by special characters when
DMA sends data. (R/W)
UHCI_RX_13_ESC_EN Set this bit to replace flow control character 0x13 by special characters when
DMA sends data. (R/W)
FT
FT
NA
NA
HI
HI
_S
_E
_S
_E
UT
UT
UT
UT
UT
UT
EO
EO
EO
EO
EO
EO
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 This field stores the timeout value. UHCI will produce the
UHCI_TX_HUNG_INT interrupt when DMA takes more time to receive data. (R/W)
UHCI_TXFIFO_TIMEOUT_SHIFT This field is used to configure the maximum tick count. (R/W)
UHCI_TXFIFO_TIMEOUT_ENA This is the enable bit for TX FIFO receive timeout. (R/W)
UHCI_RXFIFO_TIMEOUT This field stores the timeout value. UHCI will produce the
UHCI_RX_HUNG_INT interrupt when DMA takes more time to read data from RAM. (R/W)
UHCI_RXFIFO_TIMEOUT_SHIFT This field is used to configure the maximum tick count. (R/W)
UHCI_RXFIFO_TIMEOUT_ENA This is the enable bit for DMA send timeout. (R/W)
D
OA
_L
UM
UM
_N
_N
)
CK
CK
ed
_A
_A
rv
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
UHCI_ACK_NUM This is the ACK number used in software flow control. (R/W)
UHCI_ACK_NUM_LOAD Set this bit to 1, and the value configured by UHCI_ACK_NUM would be
loaded. (WT)
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
UHCI_SINGLE_SEND_EN Set this bit to enable single_send mode to send short packets. (R/W/SC)
UHCI_ALWAYS_SEND_EN Set this bit to enable always_send mode to send short packets. (R/W)
31 0
0x000000 Reset
31 0
0x000000 Reset
D0
OR
W
Q 1_
D_
EN
_S
CI
UH
31 0
0x000000 Reset
D1
OR
W
1_
_Q
ND
SE
I_
C
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
D1
OR
_W
2
_Q
ND
E
_S
CI
UH
31 0
0x000000 Reset
D0
OR
_W
Q3
D_
EN
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
D0
OR
W
4_
_Q
ND
E
_S
CI
UH
31 0
0x000000 Reset
D1
OR
W
4_
_Q
ND
SE
I_
C
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
D1
OR
5_W
_Q
ND
E
_S
CI
UH
31 0
0x000000 Reset
D0
OR
_W
Q6
D_
EN
_S
CI
UH
31 0
0x000000 Reset
31 0
0x000000 Reset
0
1
AR
AR
CH
H
_C
AR
C_
SC
CH
ES
E
R_
R_
R_
PE
PE
PE
)
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 This field is used to define separators to encode data packets. The default
value is 0xC0. (R/W)
UHCI_SEPER_ESC_CHAR0 This field is used to define the first character of SLIP escape sequence.
The default value is 0xDB. (R/W)
UHCI_SEPER_ESC_CHAR1 This field is used to define the second character of SLIP escape se-
quence. 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
I_
_
se
CI
CI
C
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_ESC_SEQ0 This field is used to define a character that need to be encoded. The default
value is 0xDB that used as the first character of SLIP escape sequence. (R/W)
UHCI_ESC_SEQ0_CHAR0 This field is used to define the first character of SLIP escape sequence.
The default value is 0xDB. (R/W)
UHCI_ESC_SEQ0_CHAR1 This field is used to define the second character of SLIP escape se-
quence. The default value is 0xDD. (R/W)
0
1
AR
AR
CH
H
_C
1_
Q1
Q1
EQ
SE
SE
S
C_
C_
C_
d)
ES
S
ve
_E
_E
_
r
se
CI
CI
CI
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_ESC_SEQ1 This field is used to define a character that need to be encoded. The default value
is 0x11 that used as a flow control character. (R/W)
UHCI_ESC_SEQ1_CHAR0 This field is used to define the first character of SLIP escape sequence.
The default value is 0xDB. (R/W)
UHCI_ESC_SEQ1_CHAR1 This field is used to define the second character of SLIP escape se-
quence. The default value is 0xDE. (R/W)
0
1
AR
AR
CH
CH
2_
2_
Q2
EQ
EQ
SE
_S
_S
C_
)
SC
SC
ed
ES
_E
_E
rv
_
se
CI
CI
CI
UH
UH
UH
(re
31 24 23 16 15 8 7 0
UHCI_ESC_SEQ2 This field is used to define a character that need to be decoded. The default
value is 0x13 that used as a flow control character. (R/W)
UHCI_ESC_SEQ2_CHAR0 This field is used to define the first character of SLIP escape sequence.
The default value is 0xDB. (R/W)
UHCI_ESC_SEQ2_CHAR1 This field is used to define the second character of SLIP escape se-
quence. The default value is 0xDF. (R/W)
RS
H
_T
)
KT
ed
_P
rv
se
CI
UH
(re
31 13 12 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x80 Reset
UHCI_PKT_THRS This field is used to configure the maximum value of the packet length when
UHCI_HEAD_EN is 0. (R/W)
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
UHCI_RX_START_INT_RAW This is the interrupt raw bit for UHCI_RX_START_INT interrupt. The in-
terrupt is triggered when a separator has been sent. (R/WTC/SS)
UHCI_TX_START_INT_RAW This is the interrupt raw bit for UHCI_TX_START_INT interrupt. The inter-
rupt is triggered when UHCI detects a separator. (R/WTC/SS)
UHCI_RX_HUNG_INT_RAW This is the interrupt raw bit for UHCI_RX_HUNG_INT interrupt. The inter-
rupt is triggered when UHCI takes more time to receive data than configure value. (R/WTC/SS)
UHCI_TX_HUNG_INT_RAW This is the interrupt raw bit for UHCI_TX_HUNG_INT interrupt. The inter-
rupt is triggered when UHCI takes more time to read data from RAM than the configured value.
(R/WTC/SS)
UHCI_OUT_EOF_INT_RAW This is the interrupt raw bit for UHCI_OUT_EOF_INT interrupt. The inter-
rupt is triggered when there are some errors in EOF in the transmit descriptors. (R/WTC/SS)
UHCI_APP_CTRL0_INT_RAW This is the interrupt raw bit for UHCI_APP_CTRL0_INT interrupt. The
interrupt is triggered when UHCI_APP_CTRL0_IN_SET is set. (R/W)
UHCI_APP_CTRL1_INT_RAW This is the interrupt raw bit for UHCI_APP_CTRL1_INT interrupt. The
interrupt is triggered when UHCI_APP_CTRL1_IN_SET is set. (R/W)
_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
UHCI_RX_START_INT_ST This is the masked interrupt bit for UHCI_RX_START_INT interrupt when
UHCI_RX_START_INT_ENA is set to 1. (RO)
UHCI_TX_START_INT_ST This is the masked interrupt bit for UHCI_TX_START_INT interrupt when
UHCI_TX_START_INT_ENA is set to 1. (RO)
UHCI_RX_HUNG_INT_ST This is the masked interrupt bit for UHCI_RX_HUNG_INT interrupt when
UHCI_RX_HUNG_INT_ENA is set to 1. (RO)
UHCI_TX_HUNG_INT_ST This is the masked interrupt bit for UHCI_TX_HUNG_INT interrupt when
UHCI_TX_HUNG_INT_ENA is set to 1. (RO)
UHCI_APP_CTRL1_INT_ST This is the masked interrupt bit for UHCI_APP_CTRL1_INT interrupt when
UHCI_APP_CTRL1_INT_ENA is set to 1. (RO)
_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
UHCI_RX_START_INT_ENA This is the interrupt enable bit for UHCI_RX_START_INT interrupt. (R/W)
UHCI_TX_START_INT_ENA This is the interrupt enable bit for UHCI_TX_START_INT interrupt. (R/W)
UHCI_RX_HUNG_INT_ENA This is the interrupt enable bit for UHCI_RX_HUNG_INT interrupt. (R/W)
UHCI_TX_HUNG_INT_ENA This is the interrupt enable bit for UHCI_TX_HUNG_INT interrupt. (R/W)
_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
TE
US
TA
CA
_S
R_
DE
ER
CO
)
X_
ed
DE
_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 This field indicates the error type when DMA has received a packet with
error. 3’b001: Checksum error in the HCI packet; 3’b010: Sequence number error in the HCI
packet; 3’b011: CRC bit error in the HCI packet; 3’b100: 0xC0 is found but the received the HCI
packet is not end; 3’b101: 0xC0 is not found when the HCI packet has been received; 3’b110:
CRC check error. (RO)
E
AT
ST
E_
OD
NC
d)
ve
_E
r
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
D
EA
_H
_ RX
CI
UH
31 0
0x000000 Reset
UHCI_RX_HEAD This register stores the header of the current received packet. (RO)
31 0
0x2007170 Reset
27.1 Overview
The Serial Peripheral Interface (SPI) is a synchronous serial interface useful for communication with external
peripherals. The ESP32-C3 chip integrates three SPI controllers:
• SPI0,
• SPI1,
SPI0 and SPI1 controllers are primarily reserved for internal use. This chapter mainly focuses on the GP-SPI2
controller.
27.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 transfers 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 exchanges data with a slave.
One SPI transfer consists of one or more SPI transactions.
Single Transfer An SPI transfer consists of only one transaction.
CPU-Controlled Transfer A data transfer happens between CPU buffer SPI_W0_REG ~
SPI_W15_REG and SPI peripheral.
DMA-Controlled Transfer A data transfer happens between DMA and SPI peripheral, con-
trolled by DMA engine.
Configurable Segmented Transfer A data transfer controlled by DMA in SPI master mode. Such
transfer consists of multiple transactions (segments), and each
of transactions 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 first, and the
other side receives data. Sending data and receiving data can not
happen at the same time.
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.
27.3 Features
Some of the key features of GP-SPI2 are:
– QPI mode
– Master: up to 80 MHz
– Slave: up to 60 MHz
– DMA-controlled single transfer or segmented transfer in slave mode: data length is unlimited
• Able to communicate with SPI devices, such as a sensor, a screen controller, as well as a flash or RAM
chip
Figure 27-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 5 IO MUX and GPIO Matrix (GPIO, IO MUX).
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-C3 TRM (Version 1.1)
GoBack
27 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.
In slave mode:
• 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.
Table 27-6. Bit Order Control in GP-SPI2 Master and Slave Modes
The following sections provide detailed information about the transfer modes listed in the table above.
(consisting of only one transaction). CPU-controlled mode supports full-duplex communication and
half-duplex communication.
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 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_W8_REG[7:0] ~ SPI_W15_REG[31:24] may be sent
more than once. For instance, 66 bytes (byte0 ~ byte65) need to send out, the address of byte65
is the result of (65 % 64 = 1), i.e. byte65 is from SPI_W0_REG[15:8], and byte64 is from
SPI_W0_REG[7:0]. For this case, the content of SPI_W0_REG[15:0] may be sent more than once.
– When SPI_USR_MOSI_HIGHPART is set, i.e. high part mode is enabled, TX data is 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[7:0] ~ SPI_W15_REG[31:24] may be
sent more than once.
• 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_W8_REG[7:0] ~ SPI_W15_REG[31:24] may
be overwritten. For instance, 66 bytes (byte0 ~ byte65) are received, byte65 and byte64 will be
stored to the addresses of (65 % 64 = 1) and (64 % 64 = 0), i.e. SPI_W0_REG[15:8] and
SPI_W0_REG[7:0]. For this case, the content of SPI_W0_REG[15:0] may be overwritten.
– 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.
Note:
• TX/RX data address mentioned above both are byte-addressable. Address 0 stands for SPI_W0_REG[7:0], and
Address 1 for SPI_W0_REG[15:8], and so on. The largest address is SPI_W15_REG[31:24].
• 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 address of overflowing data is always 63 and only the content of
SPI_W15_REG[31:24] is overwritten.
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 in master and
slave modes.
• a configurable segmented transfer, consisting of several transactions (segments). GP-SPI2 supports this
transfer only in master mode. For more information, see Section 27.5.8.5.
• a slave segmented transfer, consisting of several transactions (segments). GP-SPI2 supports this
transfer only in slave mode. For more information, see Section 27.5.9.3.
A DMA-controlled transfer only needs to be triggered once by CPU. When such 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 2 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.
The only difference between DMA-controlled transfers in master mode and in slave mode is on the GDMA RX
control:
• When the bit SPI_RX_EOF_EN is set, the generation of GDMA_IN_SUC_EOF_CHn_INT also depends on
the length of transferred data.
It is recommended that the length of configured GDMA TX/RX buffer is equal to the length of real transferred
data.
• If the length of configured GDMA TX buffer is shorter than that of real transferred data, 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 the that of real transferred data, the TX buffer is
not fully used, and the remaining buffer is available 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 real transferred data, 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 real transferred data, 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 master mode, are controlled by this state machine
together with register configuration.
• SPI Buffer: SPI_W0_REG ~ SPI_W15_REG, see Figure 27-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
master mode, to generate SPI_CLK signal for data transfer and for slaves.
• SPI_CLK_out Mode Control: output the SPI_CLK signal for data transfer and for slaves.
• SPI_CLK_in Mode Control: capture the SPI_CLK signal from SPI master when GP-SPI2 works as a slave.
Figure 27-4 shows the data flow of GP-SPI2 in master mode. 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, and then 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 27.8.
Figure 27-5 shows the data flow in GP-SPI2 slave mode. Its control logic is as follows:
• In CPU/DMA-controlled full-duplex/half-duplex modes, when an external SPI master starts the SPI
transfer, data on the FSPI bus is captured, converted into unit of bytes by 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 in unit of bytes, otherwise the extra bits will be lost. The extra bits here
means the result of total data bits % 8.
• To transfer bits not in unit of bytes, consider implementing it in CMD state or ADDR state.
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 27-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.
• —: 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 27-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 27-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.
– If SPI_WR_BIT_ORDER is set, SPI_USR_COMMAND_VALUE[7:0] is sent first, and then the lower part
of SPI_USR_COMMAND_VALUE[15:8], i.e. SPI_USR_COMMAND_VALUE[SPI_USR_COMMAND
_BITLEN:8], is sent.
• If 7 < SPI_USR_ADDR_BITLEN < 16, the ADDR value is written to SPI_USR_ADDR_VALUE[31:16]. Address
value is sent as follows.
– If SPI_WR_BIT_ORDER is set, SPI_USR_ADDR_VALUE[31:24] is sent first, and then the lower part of
SPI_USR_ADDR_VALUE[23:16], i.e. SPI_USR_ADDR_VALUE[SPI_USR_ADDR_BITLEN + 8:16], is sent.
• If 15 < SPI_USR_ADDR_BITLEN < 24, the ADDR value is written to SPI_USR_ADDR_VALUE[31:8]. Address
value is sent as follows.
– If SPI_WR_BIT_ORDER is set, SPI_USR_ADDR_VALUE[31:16] is sent first, and then the lower part of
SPI_USR_ADDR_VALUE[15:8], i.e. SPI_USR_ADDR_VALUE[SPI_USR_ADDR_BITLEN - 8:8], is sent.
• If 23 < SPI_USR_ADDR_BITLEN < 32, the ADDR value is written to SPI_USR_ADDR_VALUE[31:0]. Address
value is sent as follows.
– If SPI_WR_BIT_ORDER is set, SPI_USR_ADDR_VALUE[31:8] is sent first, and then the lower part of
SPI_USR_ADDR_VALUE[7:0], i.e. SPI_USR_ADDR_VALUE[SPI_USR_ADDR_BITLEN - 24:0], is sent.
– If SPI_WR_BIT_ORDER is cleared, SPI_USR_ADDR_VALUE[31:8] is sent first, and then the higher part
of SPI_USR_ADDR_VALUE[7:0], i.e. SPI_USR_ADDR_VALUE[7:31 - SPI_USR_ADDR_BITLEN], is sent.
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
27-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 APB clock (APB_CLK, see Chapter 6 Reset and Clock) and module clock (clk_spi_mst) for
the GP-SPI2 module.
• Set SPI_DOUTDIN and clear SPI_SLAVE_MODE, to enable full-duplex communication in master mode.
• Configure SPI CS setup time and hold time according to Section 27.6.
– In DMA-controlled mode,
* configure SPI_DMA_TX_ENA/SPI_DMA_RX_ENA
* start GDMA TX/RX engine, as described in Section 27.5.6 and Section 27.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 27.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 27-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 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 27.6.
• In DMA-controlled mode,
– configure SPI_DMA_TX_ENA/SPI_DMA_RX_ENA
– start GDMA TX/RX engine, as described in Section 27.5.6 and Section 27.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 to access flash and external RAM in master half-duplex
mode.
Figure 27-8. Connection of GP-SPI2 to Flash and External RAM in 4-bit Mode
Figure 27-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 27-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 its each single transaction (segment) are configurable.
This feature enables GP-SPI2 to do as many as transactions (segments) as configured when such transfer is
triggered once by CPU. Figure 27-10 shows how this feature works.
As shown in Figure 27-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 27-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
27-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 are integer variables, which can
be any segment number.
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 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 27.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.
On GP-SPI2, 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 Table 27-9 Bitmap (BM) Table. 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 the 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 27-10 and Table 27-11 provide an example to show how to configure a CONF buffer for a transaction
(segment i) whose SPI_ADDR_REG, SPI_CTRL_REG, SPI_CLOCK_REG, SPI_USER_REG, SPI_USER1_REG
need to be updated.
Table 27-10. An Example of CONF bufferi in Segmenti
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 should be set to 1.
• SPI_CONF_BITLEN: GP-SPI2 CS setup time and hold time are programmable independently in each
segment, see Section 27.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 fAPB_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 slave mode, 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 27-12 and Table 27-13 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 omitted 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 slave mode. 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:
1. 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.
2. 0x2 (Rd_BUF): CPU-controlled read mode. Master receives the data sent by GP-SPI2. The data comes
from the related address of SPI_W0_REG ~ SPI_W15_REG.
3. 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.
4. 0x4 (Rd_DMA): DMA-controlled read mode. Master receives the data sent by GP-SPI2. The data comes
from GP-SPI2 GDMA TX buffer.
6. 0x8 (CMD8): only used to generate an SPI_SLV_CMD8_INT interrupt, which will not end GP-SPI2’s slave
segmented transfer.
7. 0x9 (CMD9): only used to generate an SPI_SLV_CMD9_INT interrupt, which will not end GP-SPI2’s slave
segmented transfer.
8. 0xA (CMDA): only used to generate an SPI_SLV_CMDA_INT interrupt, which will not end GP-SPI2’s slave
segmented transfer.
The detail function of CMD7, CMD8, CMD9, and CMDA commands is reserved for user definition. These
commands can be used as handshake signals, the passwords of some specific functions, the 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:
1. 0x0: CMD, ADDR, and DATA states all are in 1-bit mode.
2. 0x1: CMD and ADDR are in 1-bit mode. DATA is in 2-bit mode.
3. 0x2: CMD and ADDR are in 1-bit mode. DATA is in 4-bit mode.
4. 0x5: CMD is in 1-bit mode. ADDR and DATA are in 2-bit mode.
5. 0xA: CMD is in 1-bit mode, ADDR and DATA are in 4-bit mode. Or in QPI mode.
In addition, if the value of CMD[7:0] is 0x05, 0xA5, 0x06, or 0xDD, DUMMY and DATA states are omitted. The
definition of CMD[7:0] is as follows:
1. 0x05 (End_SEG_TRANS): master sends 0x05 command to end slave segmented transfer in SPI mode.
2. 0xA5 (End_SEG_TRANS): master sends 0xA5 command to end slave segmented transfer in QPI mode.
3. 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.
4. 0xDD (Ex_QPI): GP-SPI2 exits QPI mode when receiving the 0xDD command and the bit SPI_QPI_MODE
is cleared.
All the GP-SPI2 supported CMD values are listed in Table 27-12 and Table 27-13. 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 described in Table 27-12 and Table 27-13 are ignored. If the transferred data is not in
unit of byte, GP-SPI2 can send or receive these extra bits (total bits % 8), however, the correctness of the
data is not guaranteed. 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 27.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 27-12 and Table 27-13 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.
In slave mode, 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.
– start GDMA TX/RX engine, as described in Section 27.5.6 and Section 27.5.7.
GDMA_IN_SUC_EOF_CHn_INT when GDMA RX buffer is used, which means that data has been stored in
the related memory. Other interrupts described in Section 27.9 are optional.
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 27.5.6 and Section 27.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 27.5.6 and Section 27.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.
In slave mode, 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: one cycle of SPI_CLK.
In master mode, set the CS setup time by specifying SPI_CS_SETUP in SPI_USER_REG and
SPI_CS_SETUP_TIME in SPI_USER1_REG:
Figure 27-11 and Figure 27-12 show the recommended CS timing and register configuration to access external
RAM and flash.
Figure 27-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 master mode, to
generate SPI_CLK signal for data transfer and for slaves.
In master mode, 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 . And for other integral clock divisions, SPI_CLK_EQU_SYSCLK should be set to 0.
In slave mode, the supported input clock frequency (fSPI_CLK ) of GP-SPI2 is:
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 APB_CLK cycles at the rising or falling edge in GPIO matrix. For
detailed register configuration, see Chapter 5 IO MUX and GPIO Matrix (GPIO, IO MUX).
Figure 27-15 shows the timing compensation control for GP-SPI2 master mode, 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 27-16 shows a timing compensation example in GP-SPI2 master mode. 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 27-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 correct read data, follow the the settings below, assuing fclk_spi_mst equals to fSP I_CLK :
In GP-SPI2 slave mode, 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.
27.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. The interrupt may be one or more of the following ones:
• SPI_DMA_INFIFO_FULL_ERR_INT: triggered when GDMA RX FIFO length is shorter than the real
transferred data length.
• SPI_DMA_OUTFIFO_EMPTY_ERR_INT: triggered when GDMA TX FIFO length is shorter than the real
transferred data length.
• SPI_SLV_EX_QPI_INT: triggered when Ex_QPI is received correctly in GP-SPI2 slave mode and the SPI
transfer ends.
• SPI_SLV_EN_QPI_INT: triggered when En_QPI is received correctly in GP-SPI2 slave mode and the SPI
transfer ends.
• SPI_SLV_CMD7_INT: triggered when CMD7 is received correctly in GP-SPI2 slave mode and the SPI
transfer ends.
• SPI_SLV_CMD8_INT: triggered when CMD8 is received correctly in GP-SPI2 slave mode and the SPI
transfer ends.
• SPI_SLV_CMD9_INT: triggered when CMD9 is received correctly in GP-SPI2 slave mode and the SPI
transfer ends.
• SPI_SLV_CMDA_INT: triggered when CMDA is received correctly in GP-SPI2 slave mode and the SPI
transfer ends.
• SPI_TRANS_DONE_INT: triggered at the end of SPI bus transfer in both master and slave modes.
• SPI_SEG_MAGIC_ERR_INT: triggered when a Magic error occurs in CONF buffer during configurable
segmented transfer in master mode.
• SPI_SLV_CMD_ERR_INT: triggered when a received command value is not supported in GP-SPI2 slave
mode.
• SPI_APP2_INT: used and triggered by software. It is only used for user defined function.
• SPI_APP1_INT: used and triggered by software. It is only used for user defined function.
Table 27-16 and Table 27-17 show the interrupts used in GP-SPI2 master and slave modes. 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.
Note:
1. If GDMA_IN_SUC_EOF_CHn_INT is triggered, it means all the RX data of GP-SPI2 has been stored in the RX
buffer, and the TX data has been transferred to the slave.
2. SPI_TRANS_DONE_INT is triggered when CS is high, which indicates that master has completed the data ex-
change in SPI_W0_REG ~ SPI_W15_REG with slave in this mode.
3. If SPI_DMA_SEG_TRANS_DONE_INT is triggered, it means that the whole configurable segmented transfer (con-
sisting of several segments) has finished, i.e. the RX data has been stored in the RX buffer completely and all
the TX data has been sent out.
Note:
1. If GDMA_IN_SUC_EOF_CHn_INT is triggered, it means all the RX data has been stored in the RX buffer, and the
TX data has been sent to the slave.
2. SPI_TRANS_DONE_INT is triggered when CS is high, which indicates that master has completed the data ex-
change in SPI_W0_REG ~ SPI_W15_REG with slave in this mode.
3. SPI_SLV_WR_DMA_DONE_INT just means that the transmission on the SPI bus is done, but can not ensure that
all the push data has been stored in the RX buffer. For this reason, GDMA_IN_SUC_EOF_CHn_INT is recom-
mended.
4. Or wait for SPI_SLV_WR_BUF_DONE_INT.
7. Slave should set the total read data byte length in SPI_MS_DATA_BITLEN before the transfer begins. And set
SPI_RX_EOF_EN 0→1 before the end of the interrupt program.
8. Master and slave should define a method to end the segmented transfer, such as via GPIO interrupt and so on.
9. Master sends End_SEG_TRAN to end the segmented transfer or slave sets the total read data byte length in
SPI_MS_DATA_BITLEN and waits for GDMA_IN_SUC_EOF_CHn_INT.
10. Half-duplex Wr_BUF single transfer can be used in a DMA-controlled segmented transfer.
12. Half-duplex Rd_BUF single transfer can be used in a DMA-controlled segmented transfer.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
27.11 Registers
The addresses in this section are relative to SPI base address provided in Table 3-3 in Chapter 3 System and
Memory.
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_CONF_BITLEN Define the SPI CLK cycles of SPI CONF state. Can be configured in CONF state.
(R/W)
SPI_UPDATE Set this bit to synchronize SPI registers from APB clock domain into SPI module clock
domain. This bit is only used in SPI master mode. (WT)
SPI_USR User-defined command enable. An SPI operation will be triggered when the bit is set.
The bit will be cleared once the operation is done. 1: enable; 0: disable. Can not be changed
by CONF_buf. (R/W/SC)
E
LU
VA
R_
A DD
R_
US
I_
SP
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
SPI_DOUTDIN Set the bit to enable full-duplex communication. 1: enable; 0: disable. Can be
configured in CONF state. (R/W)
SPI_QPI_MODE 1: Enable QPI mode. 0: Disable QPI mode. This configuration is applicable when
the SPI controller works as master or slave. Can be configured in CONF state. (R/W/SS/SC)
SPI_TSCK_I_EDGE In slave mode, this bit can be used to change the polarity of TSCK. 0: TSCK =
SPI_CK_I. 1: TSCK = !SPI_CK_I. (R/W)
SPI_CS_HOLD Keep SPI CS low when SPI is in DONE state. 1: enable; 0: disable. Can be configured
in CONF state. (R/W)
SPI_CS_SETUP Enable SPI CS when SPI is in prepare (PREP) state. 1: enable; 0: disable. Can be
configured in CONF state. (R/W)
SPI_RSCK_I_EDGE In slave mode, this bit can be used to change the polarity of RSCK. 0: RSCK =
!SPI_CK_I. 1: RSCK = SPI_CK_I. (R/W)
SPI_CK_OUT_EDGE This bit together with SPI_CK_IDLE_EDGE is used to control SPI clock mode.
Can be configured in CONF state. For more information, see Section 27.7.2. (R/W)
SPI_USR_CONF_NXT Enable the CONF state for the next transaction (segment) in a configurable
segmented transfer. Can be configured in CONF state. (R/W)
• If this bit is set, it means this configurable segmented transfer will continue its next trans-
action (segment).
• If this bit is cleared, it means this transfer will end after the current transaction (segment)
is finished. Or this is not a configurable segmented transfer.
SPI_SIO Set the bit to enable 3-line half-duplex communication, where MOSI and MISO signals
share the same pin. 1: enable; 0: disable. Can be configured in CONF state. (R/W)
SPI_USR_DUMMY_IDLE If this bit is set, SPI clock is disabled in DUMMY state. Can be configured
in CONF state. (R/W)
SPI_USR_MOSI Set this bit to enable the write-data (DOUT) state of an operation. Can be config-
ured in CONF state. (R/W)
SPI_USR_MISO Set this bit to enable the read-data (DIN) state of an operation. Can be configured
in CONF state. (R/W)
SPI_USR_DUMMY Set this bit to enable the DUMMY state of an operation. Can be configured in
CONF state. (R/W)
SPI_USR_ADDR Set this bit to enable the address (ADDR) state of an operation. Can be configured
in CONF state. (R/W)
SPI_USR_COMMAND Set this bit to enable the command (CMD) state of an operation. Can be
configured in CONF state. (R/W)
N
_E
EN
ND
EL
_E
N
CL
LE
RR
CY
E
IT
_E
Y_
M
B
TI
TI
R_
LL
M
P_
D_
M
FU
DD
TU
DU
OL
_W
A
d)
_H
R_
R_
_S
ST
ve
US
US
CS
CS
r
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_USR_DUMMY_CYCLELEN The length of DUMMY state, in unit of SPI_CLK cycles. This value is
(the expected cycle number - 1). Can be configured in CONF state. (R/W)
SPI_MST_WFULL_ERR_END_EN 1: SPI transfer is ended when SPI RX AFIFO wfull error occurs in
GP-SPI master full-/half-duplex modes. 0: SPI transfer is not ended when SPI RX AFIFO wfull
error occurs in GP-SPI master full-/half-duplex modes. (R/W)
SPI_CS_SETUP_TIME The length of prepare (PREP) state, in unit of SPI_CLK cycles. This value
is equal to the expected cycles - 1. This field is used together with SPI_CS_SETUP. Can be
configured in CONF state. (R/W)
SPI_CS_HOLD_TIME Delay cycles of CS pin, in units of SPI_CLK cycles. This field is used together
with SPI_CS_HOLD. Can be configured in CONF state. (R/W)
SPI_USR_ADDR_BITLEN The bit length in address state. This value is (expected bit number - 1).
Can be configured in CONF state. (R/W)
ND
E
LU
TL
_E
VA
BI
RR
D_
D_
E
AN
AN
Y_
PT
M
M
M
M
M
CO
CO
RE
)
_
R_
R_
ed
ST
US
S
rv
_M
_U
se
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 1: SPI transfer is ended when SPI TX AFIFO read empty error
occurs in GP-SPI master full-/half-duplex modes. 0: SPI transfer is not ended when SPI TX
AFIFO read empty error occurs in GP-SPI master full-/half-duplex modes. (R/W)
SPI_USR_COMMAND_BITLEN The bit length of command state. This value is (expected bit number
- 1). Can be configured in CONF state. (R/W)
OR ER
R
DE
SP rve R_ AD
D_ AD
AL
AL
T
SP rve _D D
IT_ RD
OU
I_ d UA
se MD UA
I_ d ) DU
se DD QU
I_ PO OL
DU
EA QU
_B _O
Y_
(re FC _Q
SP D_ _P
SP HO OL
(re A _
FR D_
RD IT
Q_ L
L
M
R
I_ MD
)
d)
SP FA )
)
I_ _B
I_ LD
(re PO
I _ _P
I_ DD
I_ EA
ed
ed
ed
ed
M
e
SP WP
SP WR
DU
SP FC
SP FR
rv
rv
rv
rv
rv
F
se
se
se
se
se
I_
I_
I_
I_
(re
(re
(re
(re
SP
SP
SP
SP
31 27 26 25 24 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 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 Configure the output signal level in DUMMY state. Can be configured in CONF
state. (R/W)
SPI_FADDR_DUAL Apply 2-bit mode during address (ADDR) state. 1: enable; 0: disable. Can be
configured in CONF state. (R/W)
SPI_FADDR_QUAD Apply 4-bit mode during address (ADDR) state. 1: enable; 0: disable. Can be
configured in CONF state. (R/W)
SPI_FCMD_DUAL Apply 2-bit mode during command (CMD) state. 1: enable; 0: disable. Can be
configured in CONF state. (R/W)
SPI_FCMD_QUAD Apply 4-bit mode during command (CMD) state. 1: enable; 0: disable. Can be
configured in CONF state. (R/W)
SPI_FREAD_DUAL In read operations, read-data (DIN) state is in 2-bit mode. 1: enable; 0: disable.
Can be configured in CONF state. (R/W)
SPI_FREAD_QUAD In read operations, read-data (DIN) state is in 4-bit mode. 1: enable; 0: disable.
Can be configured in CONF state. (R/W)
SPI_Q_POL This bit is used to set MISO line polarity. 1: high; 0: low. Can be configured in CONF
state. (R/W)
SPI_D_POL This bit is used to set MOSI line polarity. 1: high; 0: low. Can be configured in CONF
state. (R/W)
SPI_HOLD_POL This bit is used to set SPI_HOLD output value when SPI is in idle. 1: output high;
0: output low. Can be configured in CONF state. (R/W)
SPI_WP_POL This bit is to set the output value of write-protect signal when SPI is in idle. 1: output
high; 0: output low. Can be configured in CONF state. (R/W)
SPI_RD_BIT_ORDER In read-data (MISO) state, 1: LSB first; 0: MSB first. Can be configured in CONF
state. (R/W)
SPI_WR_BIT_ORDER In command (CMD), address (ADDR), and write-data (MOSI) states, 1: LSB
first; 0: MSB first. Can be configured in CONF state. (R/W)
N
LE
IT
_B
TA
DA
d)
S_
ve
M
r
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 The value of this field is the configured SPI transmission data bit length in
master mode DMA-controlled transfer or CPU-controlled transfer. The value is also the config-
ured bit length in slave mode DMA RX controlled transfer. The register value shall be (bit_num -
1). Can be configured in CONF state. (R/W)
ED IVE P
E_ T WA
DL AC S
OL
_I P_ IN_
OL
GE
_P
CK EE P
_P
CS
I_ _K IN_
CS
R_
SP CS DIS
S
SP CS DIS
SP CS DIS
SP CS DIS
SP CS _D
CS IS
E_
DI
SP CS IS
TE
I_ 1_D
)
d)
I_ AD
I_ _D
I_ 2_
0_
I_ 5_
I_ 4_
I_ 3_
ed
AV
AS
ve
SP QU
SP CK
rv
SL
M
r
se
se
I_
I_
I_
I_
(re
(re
SP
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
SPI_CS0_DIS SPI CS0 pin enable bit. 1: disable CS0, 0: SPI_CS0 signal is from/to CS0 pin. Can
be configured in CONF state. (R/W)
SPI_CS1_DIS SPI CS1 pin enable bit. 1: disable CS1, 0: SPI_CS1 signal is from/to CS1 pin. Can be
configured in CONF state. (R/W)
SPI_CS2_DIS SPI CS2 pin enable bit. 1: disable CS2, 0: SPI_CS2 signal is from/to CS2 pin. Can
be configured in CONF state. (R/W)
SPI_CS3_DIS SPI CS3 pin enable bit. 1: disable CS3, 0: SPI_CS3 signal is from/to CS3 pin. Can
be configured in CONF state. (R/W)
SPI_CS4_DIS SPI CS4 pin enable bit. 1: disable CS4, 0: SPI_CS4 signal is from/to CS4 pin. Can
be configured in CONF state. (R/W)
SPI_CS5_DIS SPI CS5 pin enable bit. 1: disable CS5, 0: SPI_CS5 signal is from/to CS5 pin. Can
be configured in CONF state. (R/W)
SPI_CK_DIS 1: disable SPI_CLK output. 0: enable SPI_CLK output. Can be configured in CONF
state. (R/W)
SPI_MASTER_CS_POL In master mode, the bits are the polarity of SPI CS line, the value is equiva-
lent to SPI_CS ^ SPI_MASTER_CS_POL. Can be configured in CONF state. (R/W)
SPI_SLAVE_CS_POL Configure SPI slave input CS polarity. 1: invert. 0: not change. Can be con-
figured in CONF state. (R/W)
SPI_CK_IDLE_EDGE 1: SPI_CLK line is high when GP-SPI2 is in idle. 0: SPI_CLK line is low when
GP-SPI2 is in idle. Can be configured in CONF state. (R/W)
SPI_CS_KEEP_ACTIVE SPI CS line keeps low when the bit is set. Can be configured in CONF state.
(R/W)
SPI_QUAD_DIN_PIN_SWAP 1: SPI quad input swap enable. 0: SPI quad input swap disable. Can
be configured in CONF state. (R/W)
S_ _EN
TR C EN
EN
G_ S_ R_
AN LR
SE AN CL
V_ TR _
SL G_ NS
SP DM FIF _R T
A_ SE TRA
I_ A_ O_ ST
I_ _A FO S
A_ _E T
SP RX AFI O_R
NA
DM TX RS
RX NA
_ _
I_ _R SEG
SP SLV X_ N
_E
I_ F_ IF
I_ _T E
SP SLV OF_
SP BU AF
DM X
I_ A_
)
I_ _E
ed
ed
SP DM
SP RX
rv
rv
se
se
I_
I_
(re
(re
SP
SP
31 30 29 28 27 26 22 21 20 19 18 17 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
SPI_DMA_RX_ENA Set this bit to enable SPI DMA controlled receive data mode. (R/W)
SPI_DMA_TX_ENA Set this bit to enable SPI DMA controlled send data mode. (R/W)
SPI_RX_AFIFO_RST Set this bit to reset spi_rx_afifo as shown in Figure 27-4 and in Figure 27-5.
spi_rx_afifo is used to receive data in SPI master and slave transfer. (WT)
SPI_BUF_AFIFO_RST Set this bit to reset buf_tx_afifo as shown in Figure 27-4 and in Figure 27-5.
buf_tx_afifo is used to send data out in CPU-controlled master and slave transfer. (WT)
SPI_DMA_AFIFO_RST Set this bit to reset dma_tx_afifo as shown in Figure 27-4 and in Figure 27-5.
dma_tx_afifo is used to send data out in DMA-controlled slave transfer. (WT)
EN N
N
DM _B N_ N
LU
A_ ITL EN
TL _E
_E
RD A LE E
VA
V_ DM BIT N_
BI EN
C_
SL R _ LE
E_ T
I
I_ _W UF IT
CL OD OU
AG
13
SP SLV DB F_B
E
M _
E_ ET
OD
SP K_ ATA
E
G_
I_ FT_ NF
I_ _R U
AV ES
OD
M
SP SLV RB
SE
SP SO CO
CL _D
SL R
M
I_ _W
A_
d)
I_ CK
I_ R_
K_
ed
ed
ve
SP SLV
DM
SP US
SP RS
rv
rv
r
se
se
se
I_
I_
I_
I_
I_
(re
(re
(re
SP
SP
SP
SP
31 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
SPI_CLK_MODE SPI clock mode control bits. Can be configured in CONF state. (R/W)
• 1: support SPI clock mode 1 and 3. Output data B[0]/B[7] at the first edge.
• 0: support SPI clock mode 0 and 2. Output data B[1]/B[6] at the first edge.
SPI_RSCK_DATA_OUT Save half a cycle when TSCK is the same as RSCK. 1: output data at RSCK
posedge. 0: output data at TSCK posedge. (R/W)
SPI_SLV_RDDMA_BITLEN_EN If this bit is set, SPI_SLV_DATA_BITLEN is used to store the data bit
length of Rd_DMA transfer. (R/W)
SPI_SLV_WRDMA_BITLEN_EN If this bit is set, SPI_SLV_DATA_BITLEN is used to store the data bit
length of Wr_DMA transfer. (R/W)
SPI_SLV_RDBUF_BITLEN_EN If this bit is set, SPI_SLV_DATA_BITLEN is used to store data bit length
of Rd_BUF transfer. (R/W)
SPI_SLV_WRBUF_BITLEN_EN If this bit is set, SPI_SLV_DATA_BITLEN is used to store data bit length
of Wr_BUF transfer. (R/W)
SPI_SLAVE_MODE Set SPI work mode. 1: slave mode. 0: master mode. (R/W)
SPI_SOFT_RESET Software reset enable bit. If this bit is set, the SPI clock line, CS line, and data
line are reset. Can be configured in CONF state. (WT)
SPI_USR_CONF 1: enable the CONF state of current DMA-controlled configurable segmented trans-
fer, which means the configurable segmented transfer is started. 0: This is not a configurable
segmented transfer. (R/W)
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 Configure the transferred data bit length in SPI slave full-/half-duplex
modes. (R/W/SS)
E
PR
U_
L
T_
T_
T_
IV_
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 mode, 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 In master mode, this field must be floor((SPI_CLKCNT_N + 1)/2 - 1). floor() here is
to down round a number, floor(2.2) = 2. In slave mode, it must be 0. Can be configured in CONF
state. (R/W)
SPI_CLKDIV_PRE In master mode, this is pre-divider of SPI_CLK. Can be configured in CONF state.
(R/W)
E
T IV
K_ K_ L
EN AC
CL CL SE
I_ T_ K_
SP MS CL
)
I_ T_
ed
SP MS
rv
se
I_
(re
SP
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
SPI_MST_CLK_ACTIVE Set this bit to power on the SPI module clock. (R/W)
SPI_MST_CLK_SEL This bit is used to select SPI module clock source in master mode. 1:
PLL_F80M_CLK. 0: XTAL_CLK. (R/W)
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
SPI_DIN0_MODE Configure the input mode for FSPID signal. Can be configured in CONF state.
(R/W)
SPI_DIN1_MODE Configure the input mode for FSPIQ signal. Can be configured in CONF state.
(R/W)
SPI_DIN2_MODE Configure the input mode for FSPIWP signal. Can be configured in CONF state.
(R/W)
SPI_DIN3_MODE Configure the input mode for FSPIHD signal. Can be configured in CONF state.
(R/W)
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 Configure the delays to input signal FSPID based on the setting of
SPI_DIN0_MODE. Can be configured in CONF state. (R/W)
SPI_DIN1_NUM Configure the delays to input signal FSPIQ based on the setting of SPI_DIN1_MODE.
Can be configured in CONF state. (R/W)
SPI_DIN2_NUM Configure the delays to input signal FSPIWP based on the setting of
SPI_DIN2_MODE. Can be configured in CONF state. (R/W)
SPI_DIN3_NUM Configure the delays to input signal FSPIHD based on the setting of
SPI_DIN3_MODE. Can be configured in CONF state. (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
SPI_DOUT0_MODE Configure the output mode for FSPID signal. Can be configured in CONF state.
(R/W)
• 1: output with a delay of a SPI module clock cycle at its falling edge
SPI_DOUT1_MODE Configure the output mode for FSPIQ signal. Can be configured in CONF state.
(R/W)
• 1: output with a delay of a SPI module clock cycle at its falling edge
SPI_DOUT2_MODE Configure the output mode for FSPIWP signal. Can be configured in CONF
state. (R/W)
• 1: output with a delay of a SPI module clock cycle at its falling edge
SPI_DOUT3_MODE Configure the output mode for FSPIHD signal. Can be configured in CONF state.
(R/W)
• 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 bit for SPI_APP2_INT interrupt. The value is only controlled by appli-
cation. (R/W/WTC)
SPI_APP1_INT_RAW The raw bit for SPI_APP1_INT interrupt. The value is only controlled by appli-
cation. (R/W/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
F0
BU
I_
SP
31 0
0 Reset
31 0
0 Reset
31 0
0 Reset
F3
BU
I_
SP
31 0
0 Reset
F4
BU
I_
SP
31 0
0 Reset
31 0
0 Reset
31 0
0 Reset
F7
BU
I_
SP
31 0
0 Reset
F8
BU
I_
SP
31 0
0 Reset
31 0
0 Reset
31 0
0 Reset
1
F1
BU
I_
SP
31 0
0 Reset
2
F1
BU
I_
SP
31 0
0 Reset
31 0
0 Reset
31 0
0 Reset
5
F1
BU
I_
SP
31 0
0 Reset
TE
ed
DA
rv
se
I_
(re
SP
31 28 27 0
0 0 0 0 0x2007220 Reset
28.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, and sending 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
finishing communication, the master sends a STOP condition: pulling SDA up while SCL is high. If a master
both reads and writes data in one transfer, then it should send a 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).
28.2 Features
The I2C controller has the following features:
• Double addressing 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
28-1 shows the architecture of a master, while Figure 28-2 shows that of a slave. The I2C controller has the
following main parts:
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. SCL_Filter and
SDA_Filter remove noises on SCL input signals and SDA input signals respectively. The synchronization
module synchronizes signal transfer between different clock domains.
Figure 28-3 and Figure 28-4 are the timing diagram and corresponding parameters of the I2C protocol.
SCL_FSM generates the timing sequence conforming to the I2C protocol.
SCL_MAIN_FSM controls the execution of I2C commands and the sequence of the SDA line. CMD_Controller
is used for an I2C master to generate (R)START, STOP, WRITE, READ and END commands. TX RAM and RX
RAM store data to be transmitted and data received respectively. DATA_Shifter shifts data between serial and
parallel form.
Figure 28-3. I2C Protocol Timing (Cited from Fig.31 in The I2C-bus specification Version 2.1)
Figure 28-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 I2C_SCLK_SEL. When
I2C_SCLK_SEL is cleared, the clock source is XTAL_CLK. When I2C_SCLK_SEL is set, the clock source is
RC_FAST_CLK. The clock source is enabled by configuring I2C_SCLK_ACTIVE as high level, and then passes
through a fractional divider to generate I2C_SCLK according to the following equation:
I2C_SCLK_DIV _A
Divisor = I2C_SCLK_DIV _N U M + 1 +
I2C_SCLK_DIV _B
The frequency of XTAL_CLK is 40 MHz, while the frequency of RC_FAST_CLK is 17.5 MHz. Limited by timing
parameters, the derived clock I2C_SCLK should operate at a frequency 20 timers 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 32 bytes, it is not
necessary to enable clock stretching; when the slave receives 32 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.
After SCL has been stretched low, the cause of stretching can be read from the I2C_STRETCH_CAUSE bit.
Clock stretching is disabled by setting the I2C_SLAVE_SCL_STRETCH_CLR bit.
28.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 28-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 the 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 28-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 pulling SDA low and pulling SCL 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. However, it could be extended when SCL is pulled low by peripheral
devices or by an END command executed by the I2C controller, or when the clock is stretched.
This register is active only when the I2C controller works in master mode.
3. I2C_SCL_WAIT_HIGH_PERIOD: Specifies time for SCL to go high in I2C_SCLK cycles. Please make
sure that SCL could be pulled high within this time period. Otherwise, the high period of SCL may
be incorrect. This register is active only when the I2C controller works in master mode.
4. I2C_SCL_HIGH_PERIOD: Specifies the high period of SCL in 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
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 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 I2C_SCLK 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 28-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:
• RSTART: op_code = 6. The I2C controller sends a START bit or a RSTART bit defined by the I2C
protocol.
• WRITE: op_code = 1. The I2C controller sends a slave address, a register address (only in double
addressing mode) and data to the slave.
• READ: op_code = 3. The I2C controller reads data from 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.
• END: op_code = 4. The I2C controller pulls the SCL line down and suspends I2C communication.
This code also indicates that the command sequence has completed, and the CMD_Controller
stops executing commands. Once software refreshes data in command registers and the RAM, the
CMD_Controller can be restarted to execute commands from command register 0 again.
3. ack_value: Used to configure the level of the ACK bit sent by the I2C controller during a read operation.
This bit is ignored 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 one command sequence.
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 will
be sent to slaves. The data stored in TX RAM include slave addresses, read/write bits, register addresses (only
in double addressing 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. 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 double addressing 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 32 bytes. Set I2C_FIFO_PRT_EN.
In FIFO mode, RX RAM of a slave may also wrap around to receive data larger than 32 bytes. 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.
When working in slave mode, the I2C controller supports double addressing, where the first address is the
address of an I2C slave, and the second one is the slave’s memory address. When using double addressing,
RAM must be accessed in non-FIFO mode. Double addressing is enabled by setting
I2C_FIFO_ADDR_CFG_EN.
To start the I2C controller in slave mode, there are two ways:
• Set I2C_SLV_TX_AUTO_START_EN, and the slave starts automatic transfer upon an address match;
28.5.1 I2Cmaster Writes to I2Cslave with a 7-bit Address in One Command Sequence
28.5.1.1 Introduction
Figure 28-7 shows how I2Cmaster writes N bytes of data to I2Cslave ’s RAM using 7-bit addressing. As shown in
figure 28-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. Send a STOP. Once the I2Cmaster transfers a STOP bit, an I2C_TRANS_COMPLETE_INT interrupt is
generated.
4. Write I2Cslave address and data to be sent to TX RAM of I2Cmaster in either FIFO mode or non-FIFO mode
according to Section 28.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 a matching slave by default.
• Match: If the received ACK value matches ack_exp (master) (the expected ACK value), I2Cmaster
continues data transfer.
• Not match: If the received ACK value does not match ack_exp, I2Cmaster generates an
I2C_NACK_INT (master) interrupt and stops data transfer.
9. I2Cmaster sends data, and checks ACK value or not according to ack_check_en (master).
10. If data to be sent (N) is larger than 32 bytes, TX RAM of I2Cmaster may wrap around in FIFO mode. For
details, please refer to Section 28.4.10.
11. If data to be received (N) is larger than 32 bytes, RX RAM of I2Cslave may wrap around in FIFO mode. For
details, please refer to Section 28.4.10.
If data to be received (N) is larger than 32 bytes, 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
12. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
28.5.2 I2Cmaster Writes to I2Cslave with a 10-bit Address in One Command Sequence
28.5.2.1 Introduction
Figure 28-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 28.5.1, except that a 10-bit I2Cslave address
is formed from two bytes. Since a 10-bit I2Cslave address has one more byte than a 7-bit I2Cslave address,
byte_num and length of data in TX RAM increase by 1 accordingly.
5. Write I2Cslave address and data to be sent to TX RAM of I2Cmaster . The first byte of I2Cslave address
comprises ((0x78 | I2C_SLAVE_ADDR[9:8])«1) and a R/W bit. The second byte of I2Cslave address 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 checks ACK value or not according to ack_check_en (master).
10. If data to be sent is larger than 32 bytes, TX RAM of I2Cmaster may wrap around in FIFO mode. For details,
please refer to Section 28.4.10.
11. If data to be received is larger than 32 bytes, RX RAM of I2Cslave may wrap around in FIFO mode. For
details, please refer to Section 28.4.10.
If data to be received is larger than 32 bytes, 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.
28.5.3 I2Cmaster Writes to I2Cslave with Two 7-bit Addresses in One Command Sequence
28.5.3.1 Introduction
Figure 28-9 shows how I2Cmaster writes N bytes of data to I2Cslave ’s RAM using 7-bit double addressing. The
configuration and transfer process is similar to what is described in Section 28.5.1, except that in 7-bit double
addressing 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 28-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 I2Cslave address 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 checks ACK value or not according to ack_check_en (master).
12. If data to be sent is larger than 32 bytes, TX RAM of I2Cmaster may wrap around in FIFO mode. For details,
please refer to Section 28.4.10.
13. If data to be received is larger than 32 bytes, 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
I2C_SLAVE_STRETCH_INT_CLR (slave) to 1 to clear interrupt, and set I2C_SLAVE_SCL_STRETCH_CLR
(slave) to release the SCL line.
14. After data transfer completes, I2Cmaster executes the STOP command, and generates an
I2C_TRANS_COMPLETE_INT (master) interrupt.
28.5.4 I2Cmaster Writes to I2Cslave with a 7-bit Address in Multiple Command Sequences
28.5.4.1 Introduction
Figure 28-10. I2Cmaster Writing to I2Cslave with a 7-bit Address in Multiple Sequences
Given that the I2C Controller RAM holds only 32 bytes, when data are too large to be processed even by the
wrapped RAM, it is advised to transmit them in multiple command sequences. At the end of every command
sequence is an END command. When the controller executes this END command to pull SCL low, software
refreshes command sequence registers and the RAM for next the transfer.
Figure 28-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 signal 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 I2Cslave address and data to be sent to TX RAM of I2Cmaster in either FIFO mode or non-FIFO mode
according to Section 28.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.
28.5.5 I2Cmaster Reads I2Cslave with a 7-bit Address in One Command Sequence
28.5.5.1 Introduction
Figure 28-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 I2Cslave address. 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 28-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 I2Cslave address
and a R/W bit) is overwritten by byte0 marked red in Figure 28-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 I2Cslave address to TX RAM of I2Cmaster in either FIFO mode or non-FIFO mode according to Section
28.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 I2Cslave
address matches the address sent over SDA, and I2Cslave needs to send data.
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 32 bytes, 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.
28.5.6 I2Cmaster Reads I2Cslave with a 10-bit Address in One Command Sequence
28.5.6.1 Introduction
Figure 28-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 28.5.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 I2Cslave address 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 I2Cslave
address 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
28.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 32 bytes, 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.
28.5.7 I2Cmaster Reads I2Cslave with Two 7-bit Addresses in One Command Sequence
28.5.7.1 Introduction
Figure 28-13. I2Cmaster Reading N Bytes of Data from addrM of I2Cslave with a 7-bit Address
Figure 28-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 I2Cslave address and data to be sent to TX RAM of I2Cmaster in either FIFO or non-FIFO mode
according to Section 28.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 I2Cslave
address 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
28.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 32 bytes, 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.
28.5.8 I2Cmaster Reads I2Cslave with a 7-bit Address in Multiple Command Sequences
28.5.8.1 Introduction
Figure 28-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 Figure 28-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 I2Cslave
address 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
28.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 32 bytes, 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 32, then repeat step 14 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.
28.6 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 bit.
• 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].
The abbreviations given in Column Access are explained in Section Access Types for Registers.
28.8 Registers
The addresses in this section are relative to I2C Controller base address provided in Table 3-3 in Chapter 3
System and Memory.
OD
ERI
_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 This field is used to configure how long SCL remains low in master mode,
in I2C module clock cycles. (R/W)
E
IM
_T
LD
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 This field is used to configure the time to hold the data after the falling edge
of SCL, in I2C module clock cycles. (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
I2C_SDA_SAMPLE_TIME This field is used to configure how long SDA is sampled, in I2C module
clock cycles. (R/W)
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 This field is used to configure how long SCL remains high in master mode,
in I2C module clock cycles. (R/W)
I2C_SCL_WAIT_HIGH_PERIOD This field is used to configure the SCL_FSM’s waiting period for SCL
high level in master mode, in I2C module clock cycles. (R/W)
E
M
TI
D_
OL
_H
A RT
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 This field is used to configure the time between the falling edge of
SDA and the falling edge of SCL for a START condition, in I2C module clock cycles. (R/W)
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 This field is used to configure the time between the rising edge of
SCL and the falling edge of SDA for a RSTART condition, in I2C module clock cycles. (R/W)
E
IM
_T
LD
HO
O P_
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_STOP_HOLD_TIME This field is used to configure the delay after the STOP condition, in
I2C module clock cycles. (R/W)
E
M
TI
P_
TU
SE
O P_
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_STOP_SETUP_TIME This field is used to configure the time between the rising edge of
SCL and the rising edge of SDA, in I2C module clock cycles. (R/W)
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
I2C_SCL_ST_TO_I2C The maximum time that SCL_FSM remains unchanged. It should be no more
than 23. (R/W)
C
I2
O_
_T
ST
N_
AI
M
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
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 1 1 Reset
I2C_SAMPLE_SCL_LEVEL This bit is used to select the sampling mode. 0: samples SDA data on
the SCL high level; 1: samples SDA data on the SCL low level. (R/W)
I2C_RX_FULL_ACK_LEVEL This bit is used to configure the ACK value that need to be sent by
master when I2C_RXFIFO_CNT has reached the threshold. (R/W)
I2C_MS_MODE Set this bit to configure the I2C controller as an I2C Master. Clear this bit to con-
figure the I2C controller as a slave. (R/W)
I2C_TRANS_START Set this bit to start sending the data in TX FIFO. (WT)
I2C_TX_LSB_FIRST This bit is used to control the order to send data. 0: sends data from the most
significant bit; 1: sends data from the least significant bit. (R/W)
I2C_RX_LSB_FIRST This bit is used to control the order to receive data. 0: receives data from the
most significant bit; 1: receives data from the least significant bit. (R/W)
I2C_CLK_EN This field controls APB_CLK clock gating. 0: APB_CLK is gated to save power; 1:
APB_CLK is always on. (R/W)
I2C_ARBITRATION_EN This is the enable bit for I2C bus arbitration function. (R/W)
I2C_SLV_TX_AUTO_START_EN This is the enable bit for slave to send data automatically. (R/W)
I2C_ADDR_10BIT_RW_CHECK_EN This is the enable bit to check if the R/W bit of 10-bit addressing
is consistent with the I2C protocol. (R/W)
I2C_ADDR_BROADCASTING_EN This is the enable bit for 7-bit general call addressing. (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 This field is used to configure the timeout value for receiving a data bit in
I2C_SCLK clock cycles. The configured timeout value equals 2I2C_T IM E_OU T _V ALU E clock
cycles. (R/W)
R
DD
0B
_A
1
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_SLAVE_ADDR When the I2C controller is in slave mode, this field is used to configure the slave
address. (R/W)
I2C_ADDR_10BIT_EN This field is used to enable the 10-bit addressing mode in master mode. (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_FIFO_ADDR_CFG_EN When this bit is set to 1, the byte received after the I2C address byte
represents the offset address in the I2C Slave RAM. (R/W)
I2C_FIFO_PRT_EN The control enable bit of FIFO pointer in non-FIFO mode. This bit controls the
valid bits and TX/RX FIFO overflow, underflow, full and empty interrupts. (R/W)
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 When a pulse on the SCL input has smaller width than the value of this
field in I2C module clock cycles, the I2C controller ignores that pulse. (R/W)
I2C_SDA_FILTER_THRES When a pulse on the SDA input has smaller width than the value of this
field in I2C module clock cycles, the I2C controller ignores that pulse. (R/W)
M
NU
EL E
_S IV
A
IV_
V_
IV_
LK CT
DI
_D
_D
SC _A
_
)
C_ LK
LK
LK
LK
ed
I2 SC
SC
SC
SC
rv
se
C_
C_
C_
C_
(re
I2
I2
I2
I2
31 22 21 20 19 14 13 8 7 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 Reset
I2C_SCLK_SEL The clock selection bit for the I2C controller. 0: XTAL_CLK; 1: RC_FAST_CLK. (R/W)
I2C_SCLK_ACTIVE The clock switch bit for the I2C controller. (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 When the master is idle, set this bit to send out SCL pulses. The number of
pulses equals to I2C_SCL_RST_SLV_NUM[4:0]. (R/W/SC)
I2C_SCL_RST_SLV_NUM Configures the pulses of SCL generated in master mode. Valid when
I2C_SCL_RST_SLV_EN is 1. (R/W)
I2C_SCL_PD_EN The power down enable bit for the I2C output SCL line. 0: Not power down; 1:
Power down. Set I2C_SCL_FORCE_OUT and I2C_SCL_PD_EN to 1 to stretch SCL low. (R/W)
I2C_SDA_PD_EN The power down enable bit for the I2C output SDA line. 0: Not power down; 1:
Power down. Set I2C_SDA_FORCE_OUT and I2C_SDA_PD_EN to 1 to stretch SDA low. (R/W)
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 steup time. (R/W)
I2C_SLAVE_SCL_STRETCH_EN The enable bit for SCL clock stretching. 0: Disable; 1: Enable. The
SCL output line will be stretched low when I2C_SLAVE_SCL_STRETCH_EN is 1 and one of the
four stretching events occurs. The cause of stretching can be seen in I2C_STRETCH_CAUSE.
(R/W)
I2C_SLAVE_BYTE_ACK_CTL_EN The enable bit for slave to control the level of the ACK bit. (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 The received ACK value in master mode or slave mode. 0: ACK; 1: NACK. (RO)
I2C_SLAVE_RW When in slave mode, 0: master writes to slave; 1: master reads from slave. (RO)
I2C_ARB_LOST When the I2C controller loses control of the SCL line, this bit changes to 1. (RO)
I2C_BUS_BUSY 0: The I2C bus is in idle state; 1: The I2C bus is busy transferring data. (RO)
I2C_SLAVE_ADDRESSED When the I2C controller is in slave mode, and the address sent by the
master matches the address of the slave, this bit is at high level. (RO)
I2C_RXFIFO_CNT This field represents the number of data bytes to be sent. (RO)
I2C_STRETCH_CAUSE The cause of SCL clock stretching in slave mode. 0: stretching SCL low
when the master starts to read data; 1: stretching SCL low when TX FIFO is empty in slave mode;
2: stretching SCL low when RX FIFO is full in slave mode. (RO)
I2C_TXFIFO_CNT This field stores the number of data bytes received in RAM. (RO)
I2C_SCL_MAIN_STATE_LAST This field indicates the status of the state machine. 0: idle; 1: address
shift; 2: ACK address; 3: receive data; 4: transmit data; 5: send ACK; 6: wait for ACK. (RO)
I2C_SCL_STATE_LAST This field indicates the status of the state machine used to produce SCL. 0:
idle; 1: start; 2: falling edge; 3: low; 4: rising edge; 5: high; 6: stop. (RO)
NT
DR
OI
DR
DR
DR
_P
AD
AD
AD
AD
W
_W
_R
_W
_R
_R
FO
FO
FO
FO
E
d)
)
AV
ed
FI
FI
FI
FI
ve
RX
RX
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 This is the offset address of the APB reading from RX FIFO. (RO)
I2C_RXFIFO_WADDR This is the offset address of the I2C controller receiving data and writing to RX
FIFO. (RO)
I2C_TXFIFO_RADDR This is the offset address of the I2C controller reading from TX FIFO. (RO)
I2C_TXFIFO_WADDR This is the offset address of APB bus writing to TX FIFO. (RO)
TA
DA
_R
)
ed
FO
rv
FI
se
C_
(re
I2
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_FIFO_RDATA This field is used to read data from RX FIFO, or write data to TX FIFO. (R/W)
W
RX O_ F_ T_ IN AW
I2 RX DE S_ OST _R W
T W A
C_ CK V IN W AW
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
I2 SC MA _IN _IN RAW
I2 RX ST_ _ST RA _RA
M T_ W
AW
A
C_ E T W W
NT W
C_ L_ IN T T
C_ L_ R C 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 TRA _IN F_I _R
I2 TXF O_ _IN O_
I2 SC STA ET _IN
_R
I2 BY RA O_U TE
_ N
_
T
H
_
C_ BI IF LE
C_ T_ T L
C_ N T _I
I2 DE E_S CAL
I2 TRA OU RT
N
R
_ A
_
T
C_ AV L_
I2 SL RA
FO
T
)
F
C_ NE
ed
I2 GE
rv
se
C_
(re
I2
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 Reset
I2C_TXFIFO_WM_INT_RAW The raw interrupt bit for the I2C_TXFIFO_WM_INT interrupt. (R/SS/WTC)
I2C_TIME_OUT_INT_RAW The raw interrupt bit for the I2C_TIME_OUT_INT interrupt. (R/SS/WTC)
I2C_NACK_INT_RAW The raw interrupt bit for the I2C_NACK_INT interrupt. (R/SS/WTC)
I2C_SCL_ST_TO_INT_RAW The raw interrupt bit for the I2C_SCL_ST_TO_INT interrupt. (R/SS/WTC)
I2C_DET_START_INT_RAW The raw interrupt bit for the I2C_DET_START_INT interrupt. (R/SS/WTC)
R
RX O_ F_ T_ IN LR
I2 RX DE S_ OST _C R
T R L
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_ FI TO _T R R
I2 SC MA _IN _IN CLR
I2 NA O_O F_ CL T_C
N
C L
C_ N T NT LR
M T_ R
C_ L_ IN T T
LR
C_ L_ R C T_
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 TRA _IN F_I _C
I2 TXF O_ _IN O_
I2 SC STA ET _IN
_C
I2 BY RA O_U TE
C
_ N
_
T
H
_
C_ BI IF LE
C_ T_ T L
C_ N T _I
I2 DE E_S CAL
I2 TRA OU RT
_I
N
R
_ A
_
T
C_ AV L_
I2 SL RA
FO
T
)
F
C_ NE
ed
I2 GE
rv
se
C_
(re
I2
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
A NA
RX O_ F_ T_ IN NA
I2 RX DE S_ OST _EN A
A
C_ D_ A L NT EN
FI WM IN EN T_E
I A
C_ FI TO _T A A
C_ IF OV IN E_ E
C_ CK V IN A N
I2 SC MA _IN _IN ENA
I2 RX ST_ _ST EN _EN
N
C_ T_ O _ EN
C_ N T NT NA
M T_ A
NA
C_ L_ IN T T
C_ L_ R C 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 TRA _IN F_I _E
I2 TXF O_ _IN O_
I2 SC STA ET _IN
I2 BY RA O_U TE
_E
_ N
_
T
H
T
_
C_ BI IF LE
C_ T_ T L
C_ N T _I
I2 DE E_S CAL
I2 TRA OU RT
N
R
_ A
_
T
C_ AV L_
I2 SL RA
FO
T
d)
F
C_ NE
ve
I2 GE
r
se
C_
(re
I2
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_RXFIFO_WM_INT_ENA The interrupt enable bit for the I2C_RXFIFO_WM_INT interrupt. (R/W)
I2C_TXFIFO_WM_INT_ENA The interrupt enable bit for the I2C_TXFIFO_WM_INT interrupt. (R/W)
I2C_RXFIFO_OVF_INT_ENA The interrupt enable bit for the I2C_RXFIFO_OVF_INT interrupt. (R/W)
I2C_END_DETECT_INT_ENA The interrupt enable bit for the I2C_END_DETECT_INT interrupt. (R/W)
I2C_TIME_OUT_INT_ENA The interrupt enable bit for the I2C_TIME_OUT_INT interrupt. (R/W)
I2C_NACK_INT_ENA The interrupt enable bit for the I2C_NACK_INT interrupt. (R/W)
I2C_TXFIFO_OVF_INT_ENA The interrupt enable bit for the I2C_TXFIFO_OVF_INT interrupt. (R/W)
I2C_RXFIFO_UDF_INT_ENA The interrupt enable bit for the I2C_RXFIFO_UDF_INT interrupt. (R/W)
I2C_SCL_ST_TO_INT_ENA The interrupt enable bit for the I2C_SCL_ST_TO_INT interrupt. (R/W)
I2C_DET_START_INT_ENA The interrupt enable bit for the I2C_DET_START_INT interrupt. (R/W)
T
RX O_ F_ T_ IN T
C_ D_ A L NT ST
FI WM IN ST T_S
C_ IF OV IN E_ S
T
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_ L_ IN T T
C_ L_ R C 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 TRA _IN F_I _S
I2 TXF O_ _IN O_
I2 SC STA ET _IN
_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_ T_ T L
C_ CK V IN
C_ N T _I
I2 DE E_S CAL
I2 TRA OU RT
N
R
_ A
_
T
C_ AV L_
C_ E T
I2 SL RA
FO
)
F
C_ NE
ed
I2 GE
rv
B
se
C_
(re
I2
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
I2C_RXFIFO_WM_INT_ST The masked interrupt status bit for the I2C_RXFIFO_WM_INT interrupt.
(RO)
I2C_TXFIFO_WM_INT_ST The masked interrupt status bit for the I2C_TXFIFO_WM_INT interrupt.
(RO)
I2C_RXFIFO_OVF_INT_ST The masked interrupt status bit for the I2C_RXFIFO_OVF_INT interrupt.
(RO)
I2C_END_DETECT_INT_ST The masked interrupt status bit for the I2C_END_DETECT_INT interrupt.
(RO)
I2C_TIME_OUT_INT_ST The masked interrupt status bit for the I2C_TIME_OUT_INT interrupt. (RO)
I2C_TRANS_START_INT_ST The masked interrupt status bit for the I2C_TRANS_START_INT interrupt.
(RO)
I2C_NACK_INT_ST The masked interrupt status bit for the I2C_NACK_INT interrupt. (RO)
I2C_TXFIFO_OVF_INT_ST The masked interrupt status bit for the I2C_TXFIFO_OVF_INT interrupt.
(RO)
I2C_RXFIFO_UDF_INT_ST The masked interrupt status bit for the I2C_RXFIFO_UDF_INT interrupt.
(RO)
I2C_SCL_ST_TO_INT_ST The masked interrupt status bit for the I2C_SCL_ST_TO_INT interrupt.
(RO)
I2C_DET_START_INT_ST The masked interrupt status bit for the I2C_DET_START_INT interrupt. (RO)
I2C_GENERAL_CALL_INT_ST The masked interrupt status bit for the I2C_GENARAL_CALL_INT in-
terrupt. (RO)
D0
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
• ack_check_en, ack_exp and ack are used to control the ACK bit. For more information,
see Section 28.4.9.
(R/W)
I2C_COMMAND0_DONE When command 0 has been executed in master mode, this bit changes
to high level. (R/W/SS)
E
ON
_D
D1
D1
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
I2C_COMMAND1_DONE When command 1 has been executed in master mode, this bit changes to
high level. (R/W/SS)
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
I2C_COMMAND2_DONE When command 2 has been executed in master mode, this bit changes
to high Level. (R/W/SS)
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
I2C_COMMAND3_DONE When command 3 has been executed in master mode, this bit changes
to high level. (R/W/SS)
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
I2C_COMMAND4_DONE When command 4 has been executed in master mode, this bit changes
to high level. (R/W/SS)
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
I2C_COMMAND5_DONE When command 5 has been executed in master mode, this bit changes
to high level. (R/W/SS)
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
I2C_COMMAND6_DONE When command 6 has been executed in master mode, this bit changes
to high level. (R/W/SS)
E
ON
_D
D7
D7
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
I2C_COMMAND7_DONE When command 7 has been executed in master mode, this bit changes to
high level. (R/W/SS)
31 0
0x20070201 Reset
29.1 Overview
ESP32-C3 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-C3 provides separate transmit (TX) and receive
(RX) units for high performance.
29.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.
29.3 Features
• Supports master mode and slave mode
– 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 (192 kHz is not supported in 32-bit slave mode).
Figure 29-1 shows the structure of ESP32-C3 I2S module, consisting of:
• 64 x 32-bit TX FIFO
• 64 x 32-bit RX FIFO
• Compress/Decompress units
I2S module supports direct access (DMA) to internal memory, see Chapter 2 GDMA Controller (GDMA).
Both the TX unit and the RX unit have a three-line interface that includes 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 29-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, see Chapter 5 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 29-2.
Compared with MSB alignment standard, TDM MSB alignment standard supports multiple channels, see Figure
29-3.
Compared with PCM standard, TDM PCM standard supports multiple channels, see Figure 29-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 29-6.
I2S_TX/RX_CLK_SEL is used to select clock source for TX/RX unit, and I2S_TX/RX_CLK_ACTIVE 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
I2S_TX/RX_CLKM_DIV_NUM in register I2S_TX/RX_CLKM_CONF_REG as follows:
• When 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:
• When b <= a
2 , yn1 = 0, x = f loor([ ba ]) − 1, y = a%b, z = b;
• When b > a
2 , yn1 = 1, x = f loor([ a a- b ]) − 1, y = a%(a - b), z = a - b.
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. That
is:
fI2S_TX_CLK
fI2SO_BCK_out =
MO
Note:
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. That
is:
fI2S_RX_CLK
fI2SI_BCK_out =
MI
Note:
• In I2S slave mode, make sure fI2S_TX/RX_CLK >= 8 * fBCK . I2S module can output I2S_MCLK_out as the master
clock for peripherals.
Note:
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.
– 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_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.
In TX mode, I2S first reads data from 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 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, see
the table below.
When I2S reads data from DMA, the data endian under various data width is controlled by
I2S_TX_BIG_ENDIAN, see the table below.
Channel Valid Data Width Origin 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
ESP32-C3 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.
• 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 to:
– 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 complete. Figure 29-7 shows a 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, I2S supports up to 16 channels to output data. The total number of TX channels in use is
controlled by I2S_TX_TDM_TOT_CHAN_NUM. For example, if I2S_TX_TDM_TOT_CHAN_NUM is set to 5, six
channels in total (channel 0 ~ 5) will be used to transmit data, see Figure 29-8.
• 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.
ESP32-C3 I2S supports two PDM TX modes, namely, normal PDM TX mode and PCM-to-PDM TX mode.
In PDM TX mode, fetching data from DMA is controlled by I2S_TX_MONO and I2S_TX_MONO_FST_VLD, see
Table 29-5. Please configure the two bits according to the data stored in memory, be it the single-channel or
dual-channel data.
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 Left Channel Right Channel Control Select
Control Field1 Bit2
Option
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 PDM TX aster mode, the WS level of I2S module is controlled by I2S_TX_WS_IDLE_POL. The frequency of
WS signal is half of BCK frequency. The configuration of WS signal is similar to that of BCK signal, see Section
29.6 and Figure 29-9.
In PCM-to-PDM TX mode, the PCM data from DMA is converted to PDM data and then output in PDM signal
format. Configure I2S_PCM2PDM_CONV_EN to enable this mode.
• 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_WS_IDLE_POL = 1, i.e. both the left channel and right channel transmit the left channel data.
Left Right
WS(LRCK)
I2S_TX_CHAN_MOD = 2; I2S_TX_WS_IDLE_POL = 1;
In RX mode, I2S first reads data from peripheral interface, and then stores the data into memory via DMA,
according to the configured channel mode and data mode.
Note:
I2S_RX_TDM_EN and I2S_RX_PDM_EN must not be cleared or set simultaneously.
In TDM RX mode, I2S supports up to 16 channels to input data. The total number of RX channels in use is
controlled by I2S_RX_TDM_TOT_CHAN_NUM. For example, if I2S_RX_TDM_TOT_CHAN_NUM is set to 5,
channel 0 ~ 5 will be used to receive data.
• 0, 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
29.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 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.
Endian of Processed
Channel Storage Origin Data I2S_RX_BIG_ENDIAN
Data
Data Width
{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
ESP32-C3 I2S compresses/decompresses the storage data in 32-bit by A-law or by µ-law. By default, zeros
are filled into high bits.
At this point, the data format control is complete. 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 29.9, and then set the bit
I2S_TX_UPDATE.
8. Set I2S_TX_STOP_EN if needed. For more information, please refer to Section 29.8.1.
• In master mode, wait till I2S slave gets ready, then set I2S_TX_START to start transmitting data.
• In slave mode, set the bit I2S_TX_START. When the I2S master supplies BCK and WS signals, 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.
• 1: transmitter is in idle.
• 0: master RX mode
• 1: slave RX mode
4. Set needed RX data mode and RX channel mode as described in Section 29.10, and then set the bit
I2S_RX_UPDATE.
• 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-C3 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.
29.14 Registers
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
I2S_RX_DONE_INT_RAW The raw interrupt status bit for I2S_RX_DONE_INT interrupt. (RO/WTC/SS)
I2S_TX_DONE_INT_RAW The raw interrupt status bit for I2S_TX_DONE_INT interrupt. (RO/WTC/SS)
I2S_TX_HUNG_INT_RAW The raw interrupt status bit for I2S_TX_HUNG_INT interrupt. (RO/WTC/SS)
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
I2S_RX_DONE_INT_ST The masked interrupt status bit for I2S_RX_DONE_INT interrupt. (RO)
I2S_TX_DONE_INT_ST The masked interrupt status bit for I2S_TX_DONE_INT interrupt. (RO)
I2S_RX_HUNG_INT_ST The masked interrupt status bit for I2S_RX_HUNG_INT interrupt. (RO)
I2S_TX_HUNG_INT_ST The masked interrupt status bit for I2S_TX_HUNG_INT interrupt. (RO)
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_BIG_ENDIAN I2S RX byte endian. 1: low address data is saved to high address. 0: low
address data is saved to low address. (R/W)
I2S_RX_UPDATE Set 1 to update I2S RX registers from APB clock domain to I2S RX clock domain.
This bit will be cleared by hardware after register update is done. (R/W/SC)
I2S_RX_MONO_FST_VLD 1: The first channel data is valid in I2S RX mono mode. 0: The second
channel data is valid in I2S RX mono mode. (R/W)
I2S_RX_PCM_BYPASS Set this bit to bypass Compress/Decompress module for received data.
(R/W)
I2S_RX_STOP_MODE 0: I2S RX stops only when I2S_RX_START is cleared. 1: I2S RX stops when
I2S_RX_START is 0 or in_suc_eof is 1. 2: I2S RX stops when I2S_RX_START is 0 or RX FIFO is
full. (R/W)
I2S_RX_LEFT_ALIGN 1: I2S RX left alignment mode. 0: I2S RX right alignment mode. (R/W)
I2S_RX_24_FILL_EN 1: store 24-bit channel data to 32 bits (Extra bits are filled with zeros). 0: store
24-bit channel data to 24 bits. (R/W)
I2S_RX_WS_IDLE_POL 0: WS remains low when receiving left channel data, and remains high when
receiving right channel data. 1: WS remains high when receiving left channel data, and remains
low when receiving right channel data. (R/W)
I2S_RX_BIT_ORDER I2S RX bit order. 1: the lowest bit is received first. 0: the highest bit is received
first. (R/W)
I2S_RX_TDM_EN 1: Enable I2S TDM RX mode. 0: Disable I2S TDM RX mode. (R/W)
I2S_RX_PDM_EN 1: Enable I2S PDM RX mode. 0: Disable I2S PDM RX mode. (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_BCK_DIV_NUM Configure the divider of BCK in RX mode. Note this divider must not be
configured to 1. (R/W)
I2S_RX_BITS_MOD Configure the valid data bit length of I2S RX channel. 7: all the valid channel
data is in 8-bit mode. 15: all the valid channel data is in 16-bit mode. 23: all the valid channel
data is in 24-bit mode. 31: all the valid channel data is in 32-bit mode. (R/W)
I2S_RX_HALF_SAMPLE_BITS I2S RX half sample bits. This value x 2 is equal to the BCK cycles in
one WS period. (R/W)
I2S_RX_TDM_CHAN_BITS Configure RX bit number for each channel in TDM mode. Bit number
expected = this value + 1. (R/W)
I2S_RX_MSB_SHIFT Control the timing between WS signal and the MSB of data. 1: WS signal
changes one BCK clock earlier. 0: Align at rising edge. (R/W)
IV_
I
CT
EL
_D
RX SEL
_A
_S
M
LK
LK
K
S_ K_
CL
)
)
_C
_C
ed
ed
CL
X_
RX
rv
rv
M
R
se
se
S_
S_
S_
(re
(re
I2
I2
I2
I2
31 30 29 28 27 26 25 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 2 Reset
I2S_MCLK_SEL 0: Use I2S TX unit clock as I2S_MCLK_OUT. 1: Use I2S RX unit clock as
I2S_MCLK_OUT. (R/W)
T_ N
EN
OU _E
_D C_M _EN
_2 DE
R2
AC O
S
DM DA NV
_O
_P _ O
NC
TX DM _C
I
_S
S_ P M
I2 TX_ PD
DM
2
d)
d)
d)
_P
S_ M
ve
ve
ve
I2 PC
TX
r
r
se
se
se
S_
S_
(re
(re
(re
I2
I2
31 26 25 24 23 22 5 4 1 0
I2S_TX_PDM_DAC_2OUT_EN 0: 1-line DAC output mode. 1: 2-line DAC output mode. Only valid
when I2S_TX_PDM_DAC_MODE_EN is set. (R/W)
)
ed
ed
_P
rv
rv
TX
se
se
S_
(re
(re
I2
31 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_CHANn_EN (n = 8 - 15) 1: Enable the valid data input of I2S RX TDM channel n. 0:
Disable. Channel n only inputs 0. (R/W)
I2S_RX_TDM_TOT_CHAN_NUM The total number of channels in use in I2S RX TDM mode. Total
channel number in use = this value + 1. (R/W)
UM
N
F_
EO
)
ed
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
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 1: The left channel data is equal to right channel data in I2S TX mono mode
or TDM mode. 0: The invalid channel data is I2S_SINGLE_DATA in I2S TX mono mode or TDM
mode. (R/W)
I2S_TX_BIG_ENDIAN I2S TX byte endian. 1: low address data is saved to high address. 0: low
address data is saved to low address. (R/W)
I2S_TX_UPDATE Set 1 to update I2S TX registers from APB clock domain to I2S TX clock domain.
This bit will be cleared by hardware after register update is done. (R/W/SC)
I2S_TX_MONO_FST_VLD 1: The first channel data is valid in I2S TX mono mode. 0: The second
channel data is valid in I2S TX mono mode. (R/W)
I2S_TX_PCM_BYPASS Set this bit to bypass Compress/Decompress module for transmitted data.
(R/W)
I2S_TX_STOP_EN Set this bit to stop outputting BCK signal and WS signal when TX FIFO is empty.
(R/W)
I2S_TX_LEFT_ALIGN 1: I2S TX left alignment mode. 0: I2S TX right alignment mode. (R/W)
I2S_TX_24_FILL_EN 1: Sent 32 bits in 24-bit channel data mode. (Extra bits are filled with zeros).
0: Sent 24 bits in 24-bit channel data mode. (R/W)
I2S_TX_WS_IDLE_POL 0: WS remains low when sending left channel data, and remains high when
sending right channel data. 1: WS remains high when sending left channel data, and remains
low when sending right channel data. (R/W)
I2S_TX_BIT_ORDER I2S TX bit endian. 1: the lowest bit is sent first. 0: the highest bit is sent first.
(R/W)
I2S_TX_TDM_EN 1: Enable I2S TDM TX mode. 0: Disable I2S TDM TX mode. (R/W)
I2S_TX_PDM_EN 1: Enable I2S PDM TX mode. 0: Disable I2S PDM TX mode. (R/W)
I2S_TX_CHAN_MOD I2S TX channel configuration bits. For more information, see Table 29-6.
(R/W)
I2S_SIG_LOOPBACK Enable signal loop back mode with TX unit and RX unit sharing the same WS
and BCK signals. (R/W)
ST
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_
DM
DM
TX CK
CK
AL
IT
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_BCK_DIV_NUM Configure the divider of BCK in TX mode. Note this divider must not be
configured to 1. (R/W)
I2S_TX_BITS_MOD Set the bits to configure the valid data bit length of I2S TX channel. 7: all the
valid channel data is in 8-bit mode. 15: all the valid channel data is in 16-bit mode. 23: all the
valid channel data is in 24-bit mode. 31: all the valid channel data is in 32-bit mode. (R/W)
I2S_TX_HALF_SAMPLE_BITS I2S TX half sample bits. This value x 2 is equal to the BCK cycles in
one WS period. (R/W)
I2S_TX_TDM_CHAN_BITS Configure TX bit number for each channel in TDM mode. Bit number
expected = this value + 1.(R/W)
I2S_TX_MSB_SHIFT Control the timing between WS signal and the MSB of data. 1: WS signal
changes one BCK clock earlier. 0: Align at rising edge. (R/W)
I2S_TX_BCK_NO_DLY 1: BCK is not delayed to generate rising/falling edge in master mode. 0: BCK
is delayed to generate rising/falling edge in master mode. (R/W)
M
NU
VE
V_
I
CT
I
L
_D
SE
_A
M
K_
TX N
LK
LK
E
CL
)
)
K_
ed
ed
_C
_C
_
rv
rv
CL
TX
TX
se
se
S_
S_
S_
S_
(re
(re
I2
I2
I2
I2
31 30 29 28 27 26 25 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 2 Reset
_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_ _
DM
DM
DM
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) 1: 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
29.9.2.1. (R/W)
I2S_TX_TDM_TOT_CHAN_NUM Set the total number of channels in use in I2S TX TDM mode. Total
channel number in use = this value + 1. (R/W)
1
YN
Z
X
Y
IV_
IV_
V_
V_
I
I
_D
_D
_D
_D
M
KM
M
LK
LK
LK
CL
)
_C
_C
_C
ed
X_
RX
RX
RX
rv
R
se
S_
S_
S_
S_
(re
I2
I2
I2
I2
31 28 27 26 18 17 9 8 0
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)
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)
I2S_RX_CLKM_DIV_X For b <= a/2, the value of I2S_RX_CLKM_DIV_X is floor(a/b) - 1. For b > a/2,
the value of I2S_RX_CLKM_DIV_X is floor(a/(a - b)) - 1. (R/W)
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 29.6.
M
M
D
DM
D
T_
DM
_D
T_
OU
N_
IN
N_
OU
K_
K_
I
_I
S_
S_
C
BC
SD
)
)
W
W
_B
ed
ed
ed
ed
ed
X_
X_
X_
X_
RX
rv
rv
rv
rv
rv
R
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_SD_IN_DM The delay mode of I2S RX SD input signal. 0: bypass. 1: delay by rising edge.
2: delay by falling edge. 3: not used. (R/W)
I2S_RX_WS_OUT_DM The delay mode of I2S RX WS output signal. 0: bypass. 1: delay by rising
edge. 2: delay by falling edge. 3: not used. (R/W)
I2S_RX_BCK_OUT_DM The delay mode of I2S RX BCK output signal. 0: bypass. 1: delay by rising
edge. 2: delay by falling edge. 3: not used. (R/W)
I2S_RX_WS_IN_DM The delay mode of I2S RX WS input signal. 0: bypass. 1: delay by rising edge.
2: delay by falling edge. 3: not used. (R/W)
I2S_RX_BCK_IN_DM The delay mode of I2S RX BCK input signal. 0: bypass. 1: delay by rising
edge. 2: delay by falling edge. 3: not used. (R/W)
1
YN
Z
X
Y
IV_
IV_
IV_
IV_
_D
_D
_D
_D
KM
KM
M
LK
LK
L
L
d)
_C
_C
_C
_C
ve
TX
TX
TX
TX
r
se
S_
S_
S_
S_
(re
I2
I2
I2
I2
31 28 27 26 18 17 9 8 0
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)
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)
I2S_TX_CLKM_DIV_X For b <= a/2, the value of I2S_TX_CLKM_DIV_X is floor(a/b) - 1. For b > a/2,
the value of I2S_TX_CLKM_DIV_X is floor(a/(a - b)) - 1. (R/W)
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 29.6.
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_SD_OUT_DM The delay mode of I2S TX SD output signal. 0: bypass. 1: delay by rising
edge. 2: delay by falling edge. 3: not used. (R/W)
I2S_TX_SD1_OUT_DM The delay mode of I2S TX SD1 output signal. 0: bypass. 1: delay by rising
edge. 2: delay by falling edge. 3: not used. (R/W)
I2S_TX_WS_OUT_DM The delay mode of I2S TX WS output signal. 0: bypass. 1: delay by rising
edge. 2: delay by falling edge. 3: not used. (R/W)
I2S_TX_BCK_OUT_DM The delay mode of I2S TX BCK output signal. 0: bypass. 1: delay by rising
edge. 2: delay by falling edge. 3: not used. (R/W)
I2S_TX_WS_IN_DM The delay mode of I2S TX WS input signal. 0: bypass. 1: delay by rising edge.
2: delay by falling edge. 3: not used. (R/W)
I2S_TX_BCK_IN_DM The delay mode of I2S TX BCK input signal. 0: bypass. 1: delay by rising
edge. 2: delay by falling edge. 3: not used. (R/W)
HI
_S
_E
UT
UT
UT
EO
EO
EO
M
M
TI
TI
TI
O_
O_
O_
IF
IF
IF
)
_F
_F
ed
_F
LC
LC
rv
LC
se
S_
S_
S_
(re
I2
I2
I2
31 12 11 10 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0x10 Reset
I2S_LC_FIFO_TIMEOUT_SHIFT The bits are used to scale 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)
A
AT
_D
LE
NG
SI
S_
I2
31 0
0 Reset
E
DL
)
ed
_I
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
TE
DA
rv
se
S_
(re
I2
31 28 27 0
0 0 0 0 0x2007220 Reset
30.1 Overview
While programming and debugging an ESP32-C3 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„ as well as to negate the need for external devices, the ESP32-C3 contains
an USB Serial/JTAG Controller, which integrates the functionality of both an USB-to-serial converter as well as
those of an USB-to-JTAG adapter. As this device directly interfaces to an external USB host using only the two
data lines required by USB2.0, debugging the ESP32-C3 only requires two pins to be dedicated to this
functionality.
30.2 Features
• USB Full-speed device.
• Fixed function device, hardwired for CDC-ACM (Communication Device Class - Abstract Control Model)
and JTAG adapter functionality.
• 2 OUT Endpoints, 3 IN Endpoints in addition to Control Endpoint 0; Up to 64-byte data payload size.
• Internal PHY, so no or very few external components needed to connect to a host computer.
• JTAG interface allows fast communication with CPU debug core using a compact representation of JTAG
instructions.
• CDC-ACM supports host controllable chip reset and entry into download mode.
As shown in Figure 30-1, the USB Serial/JTAG Controller consists of an USB PHY, a USB device interface, a
JTAG command processor and a response capture unit, as well as the CDC-ACM registers. The PHY and part
of the device interface are clocked from a 48 MHz clock derived from the main PLL, the rest of the logic is
clocked from APB_CLK. The JTAG command processor is connected to the JTAG debug 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 is a USB 2.0 device, it only supports Full-speed (12 Mbps) and not
the High-speed (480 Mbps) mode the USB2.0 standard introduced.
Figure 30-2 shows the internal details of the USB Serial/JTAG controller on the USB side. The USB Serial/JTAG
Controller consists of an USB 2.0 Full Speed device. It contains a control endpoint, a dummy interrupt
endpoint, two bulk input endpoints as well as two bulk output endpoints. Together, these form an USB
Composite device, which consists of an 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 this. Additionally,
the ROM startup code of the SoC contains code allowing 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 but ignored (dummy)
GET_LINE_CODING Always returns 9600 baud, no parity, 8 databits, 1 stopbit
SET_CONTROL_LINE_STATE Set the state of the RTS/DTR lines, see Table 30-2
Aside from general-purpose communication, the CDC-ACM interface also can be used to reset the ESP32-C3
and optionally make it go into download mode in order to flash new firmware. This is done by setting the RTS
and DTR lines on the virtual serial port.
Note that if the download mode flag is set when the ESP32-C3 is reset, the ESP32-C3 will reboot into
download mode. When this flag is cleared and the chip is reset, the ESP32-C3 will boot from flash. For
specific sequences, please refer to Section 30.4. All these functions can also be disabled by programming
various eFuses, please refer to Chapter 4 eFuse Controller (EFUSE) for more details.
USB CDC-ACM serial data is sent to and received from the host in packets of 0 to 64 bytes in size. When
enough CDC-ACM data has accumulated in the host, the host will send a packet to the CDC-ACM receive
endpoint, and when the USB Serial/JTAG Controller has a free buffer, it will accept this packet. Conversely, the
host will check periodically if the USB Serial/JTAG Controller has a packet ready to be sent to the host, and if
so, receive this packet.
Firmware can get notified of new data from the host in one of two ways. First of all, the
USB_SERIAL_JTAG_SERIAL_OUT_EP_DATA_AVAIL bit will remain set to one 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 as well.
When data is available, it can be read by firmware by 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 debug device is automatically readied to receive a new data packet from
the host.
When the firmware has data to send, it can do so by putting it in the send buffer and triggering a flush,
allowing 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 one in this
register field indicates there is still free room in the buffer. While this is the case, firmware can fill the buffer by
writing bytes to the USB_SERIAL_JTAG_EP1_REG register.
Writing the buffer doesn’t immediately trigger sending data to the host. This does not happen until the buffer
is flushed; a flush causes the entire buffer to be readied for reception by the USB host at once. A flush can be
triggered in two ways: after the 64th byte is written to the buffer, the USB hardware will automatically flush the
buffer to the host. Alternatively, firmware can trigger a flush by writing a one 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 this happens, the USB_SERIAL_JTAG_SERIAL_IN_EMPTY_INT
interrupt will be triggered, indicating the send buffer can receive another 64 bytes.
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 signal the JTAG response capture unit that the state of the TDO
line (which is driven by the CPU debug logic) needs to be captured.
Of this 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 the SoC 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 to the indicated values and emit one clock pulse on TCK. If the CAP
bit is 1, it will also 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 to the indicated value. This can be used to reset the
ESP32-C3.
• 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 allowable to repeat the CMD_FLUSH
to get an even number of nibbles fitting an integer number of bytes.
• CMD_RSV is reserved in the current implementation. The ESP32-C3 will ignore this command when it
receives it.
• CMD_REP repeats the last (non-CMD_REP) command a certain number of times. It’s intended goal is to
compress command streams which repeat the same CMD_CLK instruction multiple times. A command
like CMD_CLK can be followed by multiple CMD_REP commands. The number of repetitions done by
one CMD_REP can be expressed as no_repetitions = (R1 × 2 + R0) × (4cmd_rep_count ), where
cmd_rep_count is how many CMD_REP instructions went directly before it. Note that the CMD_REP is
only intended to repeat a CMD_CLK command. Specifically, using it on a CMD_FLUSH command may
lead to an unresponsive USB device, needing an USB reset to recover.
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 does increase cmd_rep_count for 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 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. This way, as long as USB throughput is sufficient, the response capture unit can
always receive more data: while one of the buffers is waiting to be sent to the host, the other one can receive
more data. When the host has received data from its buffer and the response capture unit flushes its buffer,
the two buffers change position.
This also means that a command stream can cause at most 128 bytes of capture data to be 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 is paused and the device will not accept more commands before the
generated capture data is read out.
Note that in general, the logic of the response capture unit tries not to send zero-byte responses: for
instance, sending a series of CMD_FLUSH commands will not cause a series of zero-byte USB responses to
be sent. However, in the current implementation, some zero-byte responses may be generated in
extraordinary circumstances. It’s 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 APB_CLK, 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, meaning
the TCK clock rate will generally be 40 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. This structure
allows host software to automatically support future revisions of the hardware without needing an update.
The JTAG capabilities descriptor of the ESP32-C3 is as follows. Note that all 16-bit values are
little-endian.
On the firmware side, very little initialization should be needed either: the USB hardware is self-initializing 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 aside from the firmware optionally setting up an interrupt service
handler.
One thing to note is that there may be situations where the host is either not attached or the CDC-ACM virtual
port is not opened. In this case, the packets that are flushed to the host will never be picked up and the
transmit buffer will never be empty. It is important to detect this and time out, as this is the only way to reliably
detect that the port on the host side is closed.
Another thing to note is that the USB device is dependent on both the PLL for the 48 MHz USB PHY clock, as
well as APB_CLK. Specifically, an APB_CLK of 40 MHz or more is required for proper USB compliant operation,
although the USB device will still function with most hosts with an APB_CLK as low as 10 MHz. Behaviour
shown when this happens is dependent on the host USB hardware and drivers, and can include the device
being unresponsive and it disappearing when first accessed.
More specifically, the APB_CLK will be affected by clock gating the USB Serial/JTAG Controller, which may
happen in Light Sleep. Additionally, 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 either of these two modes,
it may be preferable to use an external JTAG debugger and 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: Most operating systems
only allow setting or resetting DTR and RTS separately, and 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. These are the recommended procedures:
The abbreviations given in Column Access are explained in Section Access Types for Registers.
30.6 Registers
The addresses in this section are relative to USB Serial/JTAG Controller base address provided in Table 3-3 in
Chapter 3 System and Memory.
E
T
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
E
R ID
IDE IDE
ER
LU E
VE VERR
L
OV
LLU N
AB
LLU N
LL E
IAL TAG_ _PU OW
S_
W
EN
EF_ LL_O
G_ HG_ S
P
RR
SE L_JT _DP_ LLDO
_P P
IN
P IN
D
A
D_
V
_P
_
EL
U
PA
P
U
Y_S
FH
_P
L
B_
EF
JTA PUL
JTA PAD
_
JTA EXC
RE
M
M
DP
PH
US
EX
VR
VR
D
D
_V
G_
G_
_
_
_
G_
G_
_
_
G
RIA TAG
AG
AG
AG
AG
TA
A
JTA
T
T
_J
J
J
_J
J
_J
_
_
_
_
L_
L_
L_
L_
AL
L
IAL
L
L
AL
L
A
RIA
RIA
RIA
R IA
R IA
US SERI
US SERI
US SERI
ER
ER
ER
)
SE
SE
E
SE
ed
S
S
S
S
S
S
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
rv
se
US
US
US
US
US
US
US
US
US
US
(re
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 1 0 0 0 0 1 0 0 0 0 0 0 0 Reset
USB_SERIAL_JTAG_PHY_SEL Select internal/external PHY. 1’b0: internal PHY, 1’b1: external PHY.
(R/W)
USB_SERIAL_JTAG_VREFL Control single-end input high threshold. 1.76 V to 2 V, step 80 mV. (R/W)
USB_SERIAL_JTAG_VREFH Control single-end input low threshold. 0.8 V to 1.04 V, step 80 mV.
(R/W)
NA E
E
_E _O
TA TE TX M
BL
TE _U P
_J G_ T_ _D
G_ ST _D
ST SB
AL A ES X
RI JT _T T_T
SE AL_ AG ES
B_ RI _JT _T
US _SE IAL TAG
B R _J
US SE AL
d)
B_ RI
ve
US _SE
r
se
B
(re
US
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
_ EN
LK
C
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
USB_SERIAL_JTAG_CLK_EN 1’h1: Force clock on for register. 1’h0: Support clock only when ap-
plication writes registers. (R/W)
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
TA AVAIL
E
RE
P_ ATA_
_F
_D
DA
EP
T_
_D N_E
ER _OU
E
_I
ON
L
IAL
RIA TAG ERIA
WR
S
_S
AL AG_
G_
JTA
T
_J
_J
L_
AL
d)
US SERI
US SERI
rve
SE
B_
B_
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
USB_SERIAL_JTAG_WR_DONE Set this bit to indicate writing byte data to UART Tx FIFO is done.
This bit then stays 0 until data in UART Tx FIFO is read by the USB Host. (WT)
USB_SERIAL_JTAG_SERIAL_IN_EP_DATA_FREE 1’b1: Indicate UART Tx FIFO is not full and data can
be written into in. After writing USB_SERIAL_JTAG_WR_DONE, this will be 1’b0 until the data is
sent to the USB Host. (RO)
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
EX
ND
I
E_
M
RA
_F
SOF
G_
TA
_J
AL
)
RI
ed
SE
rv
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
P
EP
_E
_E
_
IN
IN
IN
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
DR
R
DD
AD
E
A
AT
R_
D_
ST
W
_R
1_
1_
P1
EP
EP
_E
N_
N_
IN
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_
D_
TA
W
_R
_S
2_
P2
P2
EP
_E
_E
_
IN
IN
IN
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
DR
R
DD
AD
TE
_A
R_
TA
RD
_S
3_
3_
P3
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
DR
R
DD
AD
E
A
AT
R_
D_
ST
W
R
0_
0_
0_
EP
EP
EP
T_
T_
T_
OU
OU
OU
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 0 Reset
DR
R
AT
DD
AD
_D
E
A
AT
R_
D_
EC
ST
W
R
_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
DR
R
DD
AD
TE
A
R_
D_
TA
W
_R
_S
2_
P2
P2
EP
E
E
T_
T_
T_
OU
OU
OU
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
W
_J _CR _ER C_IN _RAW T_RA
AW
W
RA
NT
_R
T_
N
PK AW
INT
TA N_TO S_RE PAY AD_I
I
_IN
AW
_R
T_
LO
6_ _INT _EP1
_R
G_ _INT T_R _INT
O
T
W
_IN AW
L
IAL INT_ AW
B_ _ZER _PAY
INT
ID_ ERR_ T_RA
V_
Y
SE L_JT _SER _IN_ RAW
_R
EC
H_
L_ G_S AL_O MPT
_
_
O
INT
O
S
US
ER
IN_ W
E
A
FL
UT 2_Z
R
R
U
_R
ER
_
1
R
BU
G_ T_EP
AL AG_ _EP
ER
K
_
F
G_
C5
F
C1
I
OF
ER
JTA
OU
US
CR
O
L_ G_P
S
I
AL AG_
G_
AL AG_
G_
G
G
G
TA
TA
A
JTA
JTA
A
JTA
T
JT
T
T
_J
_J
_J
_J
_J
_
L_
_
AL
AL
AL
AL
AL
A
RIA
A
RIA
d)
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
rve
SE
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
se
(re
US
US
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 0 0 0 0 0 0 1 0 0 0 Reset
USB_SERIAL_JTAG_SOF_INT_RAW The raw interrupt bit turns to high level when a SOF frame is
received. (R/WTC/SS)
USB_SERIAL_JTAG_SERIAL_IN_EMPTY_INT_RAW The raw interrupt bit turns to high level when the
Serial Port IN Endpoint is empty. (R/WTC/SS)
USB_SERIAL_JTAG_PID_ERR_INT_RAW The raw interrupt bit turns to high level when a PID error is
detected. (R/WTC/SS)
USB_SERIAL_JTAG_CRC5_ERR_INT_RAW The raw interrupt bit turns to high level when a CRC5
error is detected. (R/WTC/SS)
USB_SERIAL_JTAG_CRC16_ERR_INT_RAW The raw interrupt bit turns to high level when a CRC16
error is detected. (R/WTC/SS)
USB_SERIAL_JTAG_STUFF_ERR_INT_RAW The raw interrupt bit turns to high level when a bit stuff-
ing error is detected. (R/WTC/SS)
ST
ST
NT
T_
T_
N
TA N_TO S_RE PAY AD_I
I
_ IN
_IN
_P ST
T
_
KT
LO
6_ _INT _EP1
_S
G_ F_INT T_R _INT
O
T
L
B_ _ZER _PAY
INT
T
T
RIA _INT ST
CV
TY
_S
_S
H_
T
_
_
INT
P
E
O
_S
INT
O
S
US
ER
C5 RR_
_
FL
G_ ST
UT 2_Z
U
RR
IN_
_
E
I
1
R
BU
_
L_
E
G_ T_EP
AL AG_ _EP
ER
K
L
_
F F
C1
JTA
PID
OU
O
US
CR
SE
O
S
_S
I
AL AG_
G_
AL AG_
AL AG_
G_
AL AG_
G
G
TA
TA
TA
JTA
T
JT
T
T
T
_J
_J
_J
_J
_J
_J
_J
_
L_
_
L_
AL
AL
AL
AL
AL
A
d)
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
rve
SE
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
se
(re
US
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 0 0 0 0 0 0 0 0 0 0 Reset
A
A
JTA STU EN_R ET_IN AD_ _EN
_J _CR _ER C_IN _EN T_EN
NA
A
EN
NT
_E
T_
N
INT
PK NA
TA N_TO S_RE PAY AD_I
I
A
_J _CR _ER NT_E P1_IN
NA
_E
T_
LO
_E
G_ _INT T_R _INT
O
T
L
A
A
E
B_ _ZER _PAY
INT
IAL INT_ NA
N
N
V_
_
Y
_J _PID ERR NT_E
EC
H_
L_ G_S AL_O MPT
_
_
O
INT
O
S
US
ER
IN_ A
I
I
R_
E
R_
N
_
FL
UT 2_Z
U
_E
_
1
R
BU
G_ T_EP
AL AG_ _EP
ER
K
_
F
6
G_
5
F
C1
I
C
OF
ER
JTA
OU
US
O
S
I
AL AG_
G_
G_
G
G
G
G
G
TA
TA
TA
TA
TA
JTA
A
JTA
T
JT
_J
_J
_J
_J
_
L_
_
AL
AL
AL
AL
AL
AL
AL
A
A
RIA
d)
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
rve
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
se
(re
US
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 0 0 0 0 0 0 0 0 0 0 Reset
R
_J _CR _ER C_IN _CLR T_CL
LR
LR
NT
_C
T_C
N
INT
TA N_TO S_RE PAY AD_I
PK LR
I
_IN
LR
_C
T_
LO
6_ _INT _EP1
_C
G_ _INT T_R _INT
O
T
L
R
_IN LR
B_ _ZER _PAY
INT
IAL INT_ LR
V_
ID_ ERR_ T_CL
Y
_C
EC
H_
L_ G_S AL_O MPT
_
_
O
INT
O
S
US
ER
IN_ R
E
L
FL
UT 2_Z
R
R
U
_C
ER
_
1
R
BU
G_ T_EP
AL AG_ _EP
ER
K
_
F
G_
C5
F
C1
I
OF
ER
JTA
OU
US
CR
O
L_ G_P
S
I
AL AG_
G_
AL AG_
G_
G
G
G
TA
TA
A
JTA
JTA
A
JTA
T
JT
T
T
_J
_J
_J
_J
_J
_
L_
_
AL
AL
AL
AL
AL
A
RIA
A
RIA
d)
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
US SERI
rve
SE
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
B_
se
(re
US
US
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 0 0 0 0 0 0 0 0 0 0 Reset
TE
DA
G_
TA
_J
AL
RI
SE
B_
US
31 0
0x2007300 Reset
ESP32-C3 contains a TWAI controller that can be connected to the TWAI bus via an external transceiver. The
TWAI controller contains numerous advanced features, and can be utilized in a wide range of use cases such
as automotive products, industrial automation controls, building automation, etc.
31.1 Features
The TWAI controller on ESP32-C3 supports the following features:
• Supports Standard Frame Format (11-bit ID) and Extended Frame Format (29-bit ID)
– Normal
• Special transmissions
– Self Reception (the TWAI controller transmits and receives messages simultaneously)
– Error Counters
Single Channel and Non-Return-to-Zero: The bus consists of a single channel to carry bits, and thus
communication 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 should treat the next bit as a stuffed bit. Bit stuffing is
applied to the following fields: SOF, arbitration field, control field, data field, and CRC sequence (see Section
31.2.2 for more details).
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 31.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 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 nodes that have not lost arbitration can all be transmitters.
• 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 31-1
illustrates the fields and sub-fields of different frames and formats.
Arbitration Field
When two or more nodes transmits a data or remote frame simultaneously, the arbitration field is used to
determine which node will win arbitration of the bus. In the arbitration field, if a node transmits a recessive bit
while detects a dominant bit, this indicates that another node has overridden its recessive bit. Therefore, the
node transmitting the recessive bit has lost arbitration of the bus and should immediately 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 form the de-stuffed contents (everything from the SOF to the end of the data field) of a data or
remote frame.
ACK Field
The ACK field primarily consists of an ACK Slot and an ACK Delim. The ACK field indicates that the receiver has
received an effective message from the transmitter.
Table 31-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, if the type
of bus error was a CRC error, then the error frame will start at the bit following the ACK Delim (see Section
31.2.3 for more details). The following Figure 31-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 31-3 below shows the bit fields of
an overload frame.
3. A dominant bit is detected at the eighth (last) bit of an Error Delimiter. Note that in this case, TEC and
REC will not be incremented (see Section 31.2.3 for more details).
Transmitting an overload frame due to one of the above cases must also satisfy the following rules:
• The start of an overload frame due to case 1 is only allowed to be started at the first bit time of an
expected intermission.
• The start of an overload frame due to case 2 and 3 is only allowed to be started one bit after detecting
the dominant bit.
• 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 the opposite bit is
detected (e.g., a dominant bit is transmitted but a recessive is detected). However, if the transmitted bit is
recessive and is located in the Arbitration Field or ACK Slot or Passive Error Flag, then detecting a dominant bit
will not be considered a Bit Error.
Stuff Error
A stuff error is detected when six consecutive bits of the same value are detected (which violats 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 is detected 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 each maintaining two error counters, 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, but can only transmit an Passive Error Flag
when it detects an error. Error Passive nodes that have transmitted a data or remote frame must also include
the Suspend Transmission field in the subsequent Interframe Space.
Bus Off
A Bus Off node is not permitted to influence the bus in any way (i.e., is not allowed to transmit 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 since the transmitter generates an Acknowledgment Error because of
not detecting a dominant bit in the ACK Slot, while detecting a dominant bit when sending a
passive error flag. 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 (getting ACK and no errors until the EOF is complete), the
TEC is decremented by 1, unless the TEC is already at 0.
8. When a receiver successfully receives a message (no errors before ACK Slot, and successful sending of
ACK), the REC is decremented.
• If the REC 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 31-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.
PBS1 PBS1 (Phase Buffer Segment 1) can be 1 to 16 Time Quanta long. PBS1 is meant to com-
pensate for the physical delay times within the network. PBS1 can also be lengthened for
synchronization purposes.
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 idel. 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 31.4.1).
Command Registers
The command register is used by the CPU to drive the TWAI controller to initiate certain actions such as
transmitting a message or clearing the Receive Buffer. The command register can only be modified when the
TWAI controller is in Operation Mode (see section 31.4.1).
Note that the Transmit Buffer registers, Receive Buffer registers, and the Acceptance Filter registers share the
same address range (offset 0x0040 to 0x0070). Their access is governed by the following rules:
• When the TWAI controller is in Reset Mode, all reads and writes to the address range maps to the
Acceptance Filter registers.
– All reads to the address range maps to the Receive Buffer registers.
– All writes to the address range maps to the Transmit Buffer registers.
Buffer until that message is cleared (using the Release Receive Buffer command bit). After being cleared, the
Receive Buffer will map to the next message in the Receive FIFO, and the space occupied by the previous
message in the Receive FIFO can be used to receive new messages.
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 RTR 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).
Notes:
• BRP: The TWAI Time Quanta clock is derived from the APB clock that is usually 80 MHz. The Baud Rate
Prescaler (BRP) field is used to define the prescaler according to the equation below, where tT q is the
Time Quanta clock cycle and tCLK is APB clock cycle:
tT q = 2 × tCLK × (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_RAW_REG, and deasserted when all bits in TWAI_INT_RAW_REG are cleared. The
majority of interrupt bits in TWAI_INT_RAW_REG are automatically cleared when the register is read, 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 Status Interrupt (BSI) is triggered whenever TWAI controller is switching between receive/transmit
status and idle status. When a BSI occurs, the current status of TWAI controller can be measured by reading
TWAI_RX_ST and TWAI_TX_ST in TWAI_STATUS_REG register.
Table 31-8. Buffer Layout for Standard Frame Format and Extended Frame Format
Table 31-8 illustrates the layout of the Transmit Buffer and Receive Buffer registers. Both the Transmit and
Receive Buffer registers share the same address space and are only accessible when the TWAI controller is in
Operation Mode. The CPU accesses Transmit Buffer registers for write operations, and Receive Buffer
registers for read operations . Both buffers share the exact same register layout and fields to represent a
message (received or to be transmitted). The Transmit Buffer registers are used to configure a TWAI message
to be transmitted. The CPU would write to the Transmit Buffer registers specifying the message’s frame type,
frame format, frame ID, and frame data (payload). Once the Transmit Buffer is configured, the CPU would then
initiate the transmission by setting the TWAI_TX_REQ bit in TWAI_CMD_REG.
• For a single-shot transmission, set both the TWAI_TX_REQ and the TWAI_ABORT_TX simultaneously.
The Receive Buffer registers map 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 message 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 31-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 is 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 31-10 ~ 31-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 31-12 ~ 31-15.
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.28 ID.27 ID.26 ID.25 ID.24 ID.23 ID.22 ID.21
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.20 ID.19 ID.18 ID.17 ID.16 ID.15 ID.14 ID.13
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ID.12 ID.11 ID.10 ID.9 ID.8 ID.7 ID.6 ID.5
Bit 31-8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 2
Reserved ID.4 ID.3 ID.2 ID.1 ID.0 X X X2
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
eight 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 up
to 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 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 the adequate
free space to store the received message in its entirety (either due to the message contents being larger than
the free space in the Receive FIFO, or the Receive FIFO being completely full).
• The 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 has the effect of reading all valid messages in the Receive FIFO and
clearing all overrun messages.
The Acceptance Filter configuration registers can only be accessed whilst the TWAI controller is in Reset
Mode, since they share the same address spaces with the Transmit Buffer and Receive Buffer registers.
The configuration registers consist of a 32-bit Acceptance Code Value and a 32-bit Acceptance Mask Value.
The Acceptance Code value specifies a bit pattern which each filtered bit of the message must match in order
for the message to be accepted. The Acceptance Mask Value is able to mask out certain bits of the Code
value (i.e., set as “Don’t Care” bits). Each filtered bit of the message must either match the acceptance code
or be masked in order for the message to be accepted, as demonstrated in Figure 31-7.
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 31-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 31-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 31.4.3). The
following figure 31-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 which segment of the TWAI message (i.e., bit position) the bus
error occurred at.
The following Table 31-17 shows how to interpret the SEG.0 to SEG.4 bits.
Bit SEG.4 Bit SEG.3 Bit SEG.2 Bit SEG.1 Bit SEG.0 Description
0 0 0 1 1 start of frame
0 0 0 1 0 ID.28 ~ ID.21
0 0 1 1 0 ID.20 ~ ID.18
0 0 1 0 0 bit SRTR
0 0 1 0 1 bit IDE
0 0 1 1 1 ID.17 ~ ID.13
0 1 1 1 1 ID.12 ~ ID.5
0 1 1 1 0 ID.4 ~ ID.0
0 1 1 0 0 bit RTR
0 1 1 0 1 reserved bit 1
0 1 0 0 1 reserved bit 0
0 1 0 1 1 data length code
0 1 0 1 0 data field
0 1 0 0 0 CRC sequence
1 1 0 0 0 CRC delimiter
1 1 0 0 1 ACK slot
1 1 0 1 1 ACK delimiter
1 1 0 1 0 end of frame
1 0 0 1 0 intermission
1 0 0 0 1 active error flag
1 0 1 1 0 passive error flag
1 0 0 1 1 tolerate dominant bits
1 0 1 1 1 error delimiter
1 1 1 0 0 overload flag
Notes:
Subsequent losses in arbitration will trigger the Arbitration Lost Interrupt, but will not be recorded in TWAI_ARB
LOST CAP_REG until the current Arbitration Lost Capture is read from the TWAI_ERR_CODE_CAP_REG.
Table 31-18 illustrates bits and fields of TWAI_ERR_CODE_CAP_REG whilst Figure 31-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.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
31.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
provided in Table 3-3 in Chapter 3 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
TWAI_RESET_MODE This bit is used to configure the operation mode of the TWAI Controller. 1:
Reset mode; 0: Operation mode (R/W)
TWAI_LISTEN_ONLY_MODE 1: Listen only mode. In this mode the nodes will only receive messages
from the bus, without generating the acknowledge signal nor updating the RX error counter.
(R/W)
TWAI_SELF_TEST_MODE 1: Self test mode. In this mode the TX nodes can perform a successful
transmission without receiving the acknowledge signal. This mode is often used to test a single
node with the self reception request command. (R/W)
TWAI_RX_FILTER_MODE This bit is used to configure the filter mode. 0: Dual filter mode; 1: Single
filter mode (R/W)
SC
ed UM
E
PR
J
D_
C_
)
AU
(re YN
ed
_B
_S
rv
rv
se
se
AI
AI
TW
TW
(re
31 16 15 14 13 12 0
TWAI_BAUD_PRESC Baud Rate Prescaler value, determines the frequency dividing ratio. (RO | R/W)
G2
G1
M
SA
SE
SE
E_
E_
E_
)
IM
IM
IM
ed
_T
_T
_T
rv
se
AI
AI
AI
TW
TW
TW
(re
31 8 7 6 4 3 0
TWAI_TIME_SAMP The number of sample points. 0: the bus is sampled once; 1: the bus is sampled
three times (RO | R/W)
IT
IM
_L
NG
NI
AR
_W
)
RR
ed
_E
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x60 Reset
TWAI_ERR_WARNING_LIMIT Error warning threshold. In the case when any of an error counter
value exceeds the threshold, or all the error counter values are below the threshold, an error
warning interrupt will be triggered (given the enable signal is valid). (RO | R/W)
_0
DE
O
_C
CE
AN
E PT
CC
_A
AI
W
|T
0
TE_
BY
d)
X_
ve
_T
r
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_0 Stored the 0th byte information of the data to be transmitted in operation mode.
(WO)
TWAI_ACCEPTANCE_CODE_0 Stored the 0th byte of the filter code in reset mode. (R/W)
_1
DE
O
_C
CE
N
TA
EP
CC
_A
AI
TW
1|
E_
T
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_1 Stored the 1st byte information of the data to be transmitted in operation mode.
(WO)
TWAI_ACCEPTANCE_CODE_1 Stored the 1st byte of the filter code in reset mode. (R/W)
_2
ODE
_C
CE
AN
PT
E
CC
_A
AI
W
|T
2
TE_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_2 Stored the 2nd byte information of the data to be transmitted in operation mode.
(WO)
TWAI_ACCEPTANCE_CODE_2 Stored the 2nd byte of the filter code in reset mode. (R/W)
_3
DE
O
_C
CE
N
TA
EP
CC
_A
AI
W
|T
3
E_
T
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_3 Stored the 3rd byte information of the data to be transmitted in operation mode.
(WO)
TWAI_ACCEPTANCE_CODE_3 Stored the 3rd byte of the filter code in reset mode. (R/W)
_0
K
AS
E_M
NC
TA
EP
CC
_A
AI
W
|T
4
T E_
BY
d)
X_
ve
_T
r
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_4 Stored the 4th byte information of the data to be transmitted in operation mode.
(WO)
TWAI_ACCEPTANCE_MASK_0 Stored the 0th byte of the filter code in reset mode. (R/W)
_1
K
AS
_M
CE
N
TA
EP
CC
_A
AI
W
|T
5
T E_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_5 Stored the 5th byte information of the data to be transmitted in operation mode.
(WO)
TWAI_ACCEPTANCE_MASK_1 Stored the 1st byte of the filter code in reset mode. (R/W)
2
K_
AS
E _M
NC
TA
EP
CC
_A
AI
W
|T
6
T E_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_6 Stored the 6th byte information of the data to be transmitted in operation mode.
(WO)
TWAI_ACCEPTANCE_MASK_2 Stored the 2nd byte of the filter code in reset mode. (R/W)
_3
K
AS
_M
CE
N
TA
EP
CC
_A
AI
W
|T
7
T E_
BY
)
X_
ed
_T
rv
AI
se
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_7 Stored the 7th byte information of the data to be transmitted in operation mode.
(WO)
TWAI_ACCEPTANCE_MASK_3 Stored the 3rd byte of the filter code in reset mode. (R/W)
8
T E_
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_8 Stored the 8th byte information of the data to be transmitted in operation mode.
(WO)
9
E_
T
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_9 Stored the 9th byte information of the data to be transmitted in operation mode.
(WO)
10
TE_
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_10 Stored the 10th byte information of the data to be transmitted in operation mode.
(WO)
11
T E_
BY
)
X_
ed
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_11 Stored the 11th byte information of the data to be transmitted in operation mode.
(WO)
12
E_
YT
_B
)
ed
X
_T
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_TX_BYTE_12 Stored the 12th byte information of the data to be transmitted in operation mode.
(WO)
LO
ed
D
_C
_C
rv
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_CD These bits are used to configure the divisor of the external CLKOUT pin. (R/W)
TWAI_CLOCK_OFF This bit can be configured in reset mode. 1: Disable the external CLKOUT pin;
0: Enable the external CLKOUT pin (RO | R/W)
AI BO SE_ UN
X_ _T UF
A EL VE Q
TW I_R _O _RE
TW I_A EA RR
_T RT B
RE X
A LR X
Q
TW I_C F_R
d)
A EL
ve
TW I_S
r
se
A
TW
(re
31 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TWAI_CLR_OVERRUN Set the bit to 1 to clear the data overrun status bit. (WO)
TWAI_SELF_RX_REQ Self reception request command. Set the bit to 1 to allow a message be
transmitted and received simultaneously. (WO)
AI VE F_S TE
F_ T
A X_ T T
BU _S
TW I_O BU LE
TW I_T _S _S
ST
_R RR T
A X_ MP
X_ UN
A RR FF
A US ST
TW I_E _O
TW I_T CO
TW I_B S_
TW I_T ST
TW I_R ST
)
A X_
A IS
A X_
ed
TW I_M
rv
se
A
TW
(re
31 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 Reset
TWAI_RX_BUF_ST 1: The data in the RX buffer is not empty, with at least one received data packet.
(RO)
TWAI_OVERRUN_ST 1: The RX FIFO is full and data overrun has occurred. (RO)
TWAI_TX_BUF_ST 1: The TX buffer is empty, the CPU may write a message into it. (RO)
TWAI_TX_COMPLETE 1: The TWAI controller has successfully received a packet from the bus. (RO)
TWAI_RX_ST 1: The TWAI Controller is receiving a message from the bus. (RO)
TWAI_ERR_ST 1: At least one of the RX/TX error counter has reached or exceeded the value set in
register TWAI_ERR_WARNING_LIMIT_REG. (RO)
TWAI_BUS_OFF_ST 1: In bus-off status, the TWAI Controller is no longer involved in bus activities.
(RO)
TWAI_MISS_ST This bit reflects whether the data packet in the RX FIFO is complete. 1: The current
packet is missing; 0: The current packet is complete (RO)
P
CA
T_
OS
_L
RB
d)
ve
_A
r
se
AI
TW
(re
31 5 4 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_ARB_LOST_CAP This register contains information about the bit position of lost arbitration.
(RO)
ON
T
EN
TI
EC
M
E
EG
YP
IR
_D
_S
_T
TW CC
CC
CC
)
ed
_E
_E
_E
rv
se
AI
AI
AI
TW
TW
(re
31 8 7 6 5 4 0
TWAI_ECC_SEGMENT This register contains information about the location of errors, see Table 31-
16 for details. (RO)
TWAI_ECC_DIRECTION This register contains information about transmission direction of the node
when error occurs. 1: Error occurs when receiving a message; 0: Error occurs when transmitting
a message (RO)
TWAI_ECC_TYPE This register contains information about error types: 00: bit error; 01: form error;
10: stuff error; 11: other type of error (RO)
X_
ed
_R
rv
se
AI
TW
(re
31 8 7 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0 Reset
TWAI_RX_ERR_CNT The RX error counter register, reflects value changes 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
TWAI_RX_MESSAGE_COUNTER This register reflects the number of messages available within the
RX FIFO. (RO)
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
TWAI_RX_INT_ST Receive interrupt. If this bit is set to 1, it indicates there are messages to be
handled in the RX FIFO. (RO)
TWAI_TX_INT_ST Transmit interrupt. If this bit is set to 1, it indicates the message transmission is
finished and a new transmission is able to start. (RO)
TWAI_ERR_WARN_INT_ST Error warning interrupt. If this bit is set to 1, it indicates the error status
signal and the bus-off status signal of Status register have changed (e.g., switched from 0 to 1
or from 1 to 0). (RO)
TWAI_OVERRUN_INT_ST Data overrun interrupt. If this bit is set to 1, it indicates a data overrun
interrupt is generated in the RX FIFO. (RO)
TWAI_ERR_PASSIVE_INT_ST Error passive interrupt. If this bit is set to 1, it indicates the TWAI Con-
troller is switched between error active status and error passive status due to the change of
error counters. (RO)
TWAI_ARB_LOST_INT_ST Arbitration lost interrupt. If this bit is set to 1, it indicates an arbitration lost
interrupt is generated. (RO)
TWAI_BUS_ERR_INT_ST Error interrupt. If this bit is set to 1, it indicates an error is detected on the
bus. (RO)
TWAI_BUS_STATE_INT_ST Bus state interrupt. If this bit is set to 1, it indicates the status of TWAI
controller has changed. (RO)
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 _B _S
TW I_E RR
AI 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
32.1 Overview
The LED PWM Controller is a peripheral designed to generate PWM signals for LED control. It has specialized
features such as automatic duty cycle fading. However, the LED PWM Controller can also be used to generate
PWM signals for other purposes.
32.2 Features
The LED PWM Controller has the following features:
• Automatic duty cycle fading (i.e. gradual increase/decrease of a PWM’s duty cycle without interference
from the processor) with interrupt generation on fade completion
Note that the four timers are identical regarding their features and operation. The following sections refer to the
timers collectively as Timerx (where x ranges from 0 to 3). Likewise, the six PWM generators are also identical
in features and operation, and thus are collectively referred to as PWMn (where n ranges from 0 to 5).
The four timers can be independently configured (i.e. configurable clock divider, and counter overflow value)
and each internally maintains a timebase counter (i.e. a counter that counts on cycles of a reference clock).
Each PWM generator selects one of the timers and uses the timer’s counter value as a reference to generate
its PWM signal.
Figure 32-2 illustrates the main functional blocks of the timer and the PWM generator.
LEDC_APB_CLK_SEL[1:0]
APB_CLK
1
RC_FAST_CLK
2
XTAL_CLK 3 LEDC_IDLE_LV_CHn
PWMn
Timerx LEDC_CLK_DIV_TIMERx
0 0 sig_outn
LEDC_DUTY_CHn
LEDC_TIMERx_PAUSE 1
LEDC_HPOINT_CHn1
32.3.2 Timers
Each timer in LED PWM Controller internally maintains a timebase counter. Referring to Figure 32-2, this clock
signal used by the timebase counter is named ref_pulsex. All timers use the same clock source LEDC_CLKx,
which is then passed through a clock divider to generate ref_pulsex for the counter.
LED PWM registers configured by software are clocked by APB_CLK. For more information about APB_CLK,
see Chapter 6 Reset and Clock. To use the LED PWM peripheral, the APB_CLK signal to the LED PWM has to
be enabled. The APB_CLK signal to LED PWM can be enabled by setting the SYSTEM_LEDC_CLK_EN field in
the register SYSTEM_PERIP_CLK_EN0_REG and be reset via software by setting the SYSTEM_LEDC_RST field
in the register SYSTEM_PERIP_RST_EN0_REG. For more information, please refer to Table 16-1 in Chapter 16
System Registers (SYSREG).
Timers in the LED PWM Controller choose their common clock source from one of the following clock signals:
APB_CLK, RC_FAST_CLK and XTAL_CLK (see Chapter 6 Reset and Clock for more details about each clock
signal). The procedure for selecting a clock source signal for LEDC_CLKx is described below:
The LEDC_CLKx signal will then be passed through the clock divider.
The LEDC_CLKx signal is passed through a clock divider to generate the ref_pulsex signal for the counter. The
frequency of ref_pulsex is equal to the frequency of LEDC_CLKx divided by the divisor LEDC_CLK_DIV (see
Figure 32-2).
The divisor LEDC_CLK_DIV is a fractional value. Thus, it can be a non-integer. LEDC_CLK_DIV is configured
according to the following equation.
B
LEDC_CLK_DIV = A + 256
When the fractional part B is zero, LEDC_CLK_DIV is equivalent to an integer divisor (i.e. an integer prescaler).
In other words, a ref_pulsex clock pulse is generated after every A number of LEDC_CLKx clock pulses.
However, when B is nonzero, LEDC_CLK_DIV becomes a non-integer divisor. The clock divider implements
non-integer frequency division by alternating between A and (A+1) LEDC_CLKx clock pulses per ref_pulsex
clock pulse. This will result in the average frequency of ref_pulsex clock pulse being the desired frequency
(i.e. the non-integer divided frequency). For every 256 ref_pulsex clock pulses:
• A number of B ref_pulsex clock pulses will consist of (A+1) LEDC_CLKx clock pulses
• A number of (256-B) ref_pulsex clock pulses will consist of A LEDC_CLKx clock pulses
• The ref_pulsex clock pulses consisting of (A+1) pulses are evenly distributed amongst those consisting
of A pulses
Figure 32-3 illustrates the relation between LEDC_CLKx clock pulses and ref_pulsex clock pulses when
dividing by a non-integer LEDC_CLK_DIV .
To change the timer’s clock divisor at runtime, first configure the LEDC_CLK_DIV_TIMERx field, and then set
the LEDC_TIMERx_PARA_UP field to apply the new configuration. This will cause the newly configured values
to take effect upon the next overflow of the counter. The LEDC_TIMERx_PARA_UP field will be automatically
cleared by hardware.
Each timer contains a 14-bit timebase counter that uses ref_pulsex as its reference clock (see Figure 32-2).
The LEDC_TIMERx_DUTY_RES field configures the overflow value of this 14-bit counter. Hence, the maximum
resolution of the PWM signal is 14 bits. The counter counts up to 2LEDC_T IM ERx_DU T Y _RES − 1, overflows
and begins counting from 0 again. The counter’s value can be read, reset, and suspended by software.
The counter can trigger LEDC_TIMERx_OVF_INT interrupt (generated automatically by hardware without
configuration) every time the counter overflows. It can also be configured to trigger LEDC_OVF_CNT_CHn_INT
interrupt after the counter overflows LEDC_OV F _N U M _CHn + 1 times. To configure
LEDC_OVF_CNT_CHn_INT interrupt, please:
5. Set LEDC_TIMERx_DUTY_RES to enable the timer and wait for a LEDC_OVF_CNT_CHn_INT interrupt
Referring to Figure 32-2, the frequency of a PWM generator output signal (sig_outn) is dependent on the
frequency of the timer’s clock source LEDC_CLKx, the clock divisor LEDC_CLK_DIV, and the duty resolution
(counter width) LEDC_TIMERx_DUTY_RES:
fLEDC_CLKx
fPWM =
LEDC_CLK_DIV · 2LEDC_TIMERx_DUTY_RES
Based on the formula above, the desired duty resolution can be calculated as follows:
fLEDC_CLKx
LEDC_TIMERx_DUTY_RES = log2
fPWM · LEDC_CLK_DIV
Table 32-1 lists the commonly-used frequencies and their corresponding resolutions.
To change the overflow value at runtime, first set the LEDC_TIMERx_DUTY_RES field, and then set the
LEDC_TIMERx_PARA_UP field. This will cause the newly configured values to take effect upon the next
overflow of the counter. If LEDC_OVF_CNT_EN_CHn field is reconfigured, LEDC_PARA_UP_CHn should be set
to apply the new configuration. In summary, these configuration values need to be updated by setting
LEDC_TIMERx_PARA_UP or LEDC_PARA_UP_CHn. LEDC_TIMERx_PARA_UP and LEDC_PARA_UP_CHn will be
automatically cleared by hardware.
As shown in Figure 32-2, each PWM generator has a comparator and two multiplexers. A PWM generator
compares the timer’s 14-bit counter value (Timerx_cnt) to two trigger values Hpointn and Lpointn. When the
timer’s counter value is equal to Hpointn or Lpointn, the PWM signal is high or low, respectively, as described
below:
Figure 32-4 illustrates how Hpointn or Lpointn are used to generate a fixed duty cycle PWM output
signal.
For a particular PWM generator (PWMn), its Hpointn is sampled from the LEDC_HPOINT_CHn field each time
the selected timer’s counter overflows. Likewise, Lpointn is also sampled on every counter overflow and is
calculated from the sum of the LEDC_DUTY_CHn[18:4] and LEDC_HPOINT_CHn fields. By setting Hpointn and
Lpointn via the LEDC_HPOINT_CHn and LEDC_DUTY_CHn[18:4] fields, the relative phase and duty cycle of the
PWM output can be set.
The bits LEDC_DUTY_CHn[3:0] are used to dither the duty cycles of the PWM output signal (sig_outn) by
periodically altering the duty cycle of sig_outn. When LEDC_DUTY_CHn[3:0] is set to a non-zero value, then
for every 16 cycles of sig_outn, LEDC_DUTY_CHn[3:0] of those cycles will have PWM pulses that are one timer
tick longer than the other (16- LEDC_DUTY_CHn[3:0]) cycles. For instance, if LEDC_DUTY_CHn[18:4] is set to
10 and LEDC_DUTY_CHn[3:0] is set to 5, then 5 of 16 cycles will have a PWM pulse with a duty value of 11 and
the rest of the 16 cycles will have a PWM pulse with a duty value of 10. The average duty cycle after 16 cycles
is 10.3125.
• LEDC_DUTY_CYCLE_CHn sets the number of counter overflow cycles for every Lpointn
increment/decrement. In other words, Lpointn will be incremented/decremented after
LEDC_DUTY_CYCLE_CHn counter overflows.
• LEDC_DUTY_NUM_CHn sets the maximum number of increments/decrements before duty cycle fading
stops.
32.3.5 Interrupts
• LEDC_OVF_CNT_CHn_INT: Triggered when the timer counter overflows for (LEDC_OVF_NUM_CHn + 1)
times and the register LEDC_OVF_CNT_EN_CHn is set to 1.
• LEDC_TIMERx_OVF_INT: Triggered when an LED PWM timer has reached its maximum counter value.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
32.5 Registers
The addresses in this section are relative to LED PWM Controller base address provided in Table 3-3 in Chapter
3 System and Memory.
CH Hn
N_ _C
n
n
_S _CH
_E ET
Hn
Hn
IG LV_ Hn
NT ES
_C
UT n
_C
N
DC _O CH
_S E_ _C
_C _R
_E
EL
UM
DC DL UP
VF NT
LE _I A _
N
_O _C
ER
F_
DC VF
DC AR
)
IM
ed
V
LE C_O
_O
LE C_P
_T
rv
DC
se
D
(re
LE
LE
LE
LE
31 17 16 15 14 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LEDC_TIMER_SEL_CHn This field is used to select one of the timers for channel n.
LEDC_IDLE_LV_CHn This bit is used to control the output value when channel n is inactive (when
LEDC_SIG_OUT_EN_CHn is 0). (R/W)
LEDC_PARA_UP_CHn This bit is used to update the listed fields below for channel n, and will be
automatically cleared by hardware. (WT)
• LEDC_HPOINT_CHn
• LEDC_DUTY_START_CHn
• LEDC_SIG_OUT_EN_CHn
• LEDC_TIMER_SEL_CHn
• LEDC_DUTY_NUM_CHn
• LEDC_DUTY_CYCLE_CHn
• LEDC_DUTY_SCALE_CHn
• LEDC_DUTY_INC_CHn
• LEDC_OVF_CNT_EN_CHn
LEDC_OVF_NUM_CHn This field is used to configure the maximum times of overflow minus 1.
LEDC_OVF_CNT_EN_CHn This bit is used to count the number of times when the timer selected by
channel n overflows. (R/W)
LEDC_OVF_CNT_RESET_CHn Set this bit to reset the timer-overflow counter of channel n. (WT)
n
n
CH n
CH
CH
Hn
C_ CH
n
E_
E_
_C
IN T_
L
CL
Y_ AR
UM
CA
CY
UT ST
_S
_D TY_
Y_
Y_
TY
UT
UT
DC U
DU
LE C_D
_D
_D
C_
DC
DC
D
D
LE
LE
LE
LE
31 30 29 20 19 10 9 0
LEDC_DUTY_SCALE_CHn This field configures the step size of the duty cycle change during fading.
(R/W)
LEDC_DUTY_NUM_CHn This field controls the number of times the duty cycle will be changed.
(R/W)
LEDC_DUTY_INC_CHn This bit determines whether the duty cycle of the output signal on channel
n increases or decreases. 1: Increase; 0: Decrease. (R/W)
LE
_S
LK
EN
_C
K_
PB
)
ed
L
_C
A
rv
C_
DC
se
D
(re
LE
LE
31 30 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LEDC_APB_CLK_SEL This field is used to select the common clock source for all the 4 timers.
1: Force clock on for register. 0: Support clock only when application writes registers. (R/W)
Hn
_C
NT
I
PO
d)
ve
_H
r
DC
se
(re
LE
31 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00 Reset
LEDC_HPOINT_CHn The output value changes to high when the selected timer for this channel has
reached the value specified by this field. (R/W)
Hn
C
Y_
UT
)
ed
D
rv
C_
se
D
(re
LE
31 19 18 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
LEDC_DUTY_CHn This field is used to change the output duty by controlling the Lpoint. The output
value turns to low when the selected timer for this channel has reached the Lpoint. (R/W)
D
rv
C_
se
D
(re
LE
31 19 18 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0x000 Reset
LEDC_DUTY_R_CHn This field stores the current duty cycle of the output signal on channel n. (RO)
S
UP
RE
x
ER
A_
Y_
US
UT
LE C_T ) PAR
x_ T
ER RS
TI
PA
D
V_
D d x_
IM x_
x_
I
_D
LE rve ER
_T ER
ER
LK
)
se IM
DC IM
M
ed
TI
_C
(re C_T
rv
C_
DC
se
D
(re
LE
LE
LE
31 26 25 24 23 22 21 4 3 0
LEDC_TIMERx_DUTY_RES This field is used to control the range of the counter in timer x. (R/W)
LEDC_CLK_DIV_TIMERx This field is used to configure the divisor for the divider in timer x. The
least significant eight bits represent the fractional part. (R/W)
LEDC_TIMERx_RST This bit is used to reset timer x. The counter will show 0 after reset. (R/W)
NT
C
x_
ER
)
IM
ed
_T
rv
DC
se
(re
LE
31 14 13 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
LEDC_TIMERx_CNT This field stores the current counter value of timer x. (RO)
31
31
0
0
0
0
0
0
0
0
Espressif Systems
0
0
(R/WTC/SS)
0
0
is set to 1. (RO)
0
0
(re (re
0
0
se se
rv rv
32 LED PWM Controller (LEDC)
ed ed
0
0
) )
0
0
0
0
LEDC_OVF_CNT_CHn_INT_ST This
0
0
0
0
is
0
0
LEDC_DUTY_CHNG_END_CHn_INT_ST This
change of duty has finished. (R/WTC/SS)
0
16
0
16
the
is
0
0
15
15
LE LE
D D
818
0
0
14
14
LE C_O LE C_O
the
D VF D VF
0
0
13
13
LE C_O _C LE C_O _C
D VF NT D VF NT
0
0
12
12
masked
LE C_O _C _C LE C_O _C _C
D VF NT H5 D VF NT H5
0
0
11
11
masked
10
10
9
9
0
0
interrupt
8
8
0
0
DC U NT H1_ T_ D U NT H1 T_ W
7
7
0
0
interrupt
D U CH H0 T_ D U CH H0 T_ W
6
6
0
0
status
5
5
0
0
4
4
status
0
0
bit
3
3
0
0
bit
DC U CH _E _C _I S D U CH _E _C _I R
2
2
0
0
for
1
1
for
LE C_T ER NG ND H2 INT_ T LE C_T ER NG ND H2 INT_ AW
DC IM 3_ _E _C _I ST D IM 3_ _E _C _ R
0
0
the
LEDC_DUTY_CHNG_END_CHn_INT interrupt when LEDC_DUTY_CHNG_END_CHn_INT_ENA
the
LEDC_OVF_CNT_CHn_INT_RAW Interrupt raw bit for channel n. Triggered when the ovf_cnt has
LEDC_TIMERx_OVF_INT_ST This is the masked interrupt status bit for the LEDC_TIMERx_OVF_INT
LEDC_DUTY_CHNG_END_CHn_INT_RAW Interrupt raw bit for channel n. Triggered when the gradual
LEDC_TIMERx_OVF_INT_RAW Triggered when the timerx has reached its maximum counter value.
_T ER OV NT H0 T_ T _T ER OV NT H0 T_ AW
IM 1_O F_ _S _ ST IM 1_O F_ _R _ RA
0 Reset
0 Reset
0_ F_ _S 0_ F_ _R
T
31
31
0
0
0
0
0
0
(R/W)
(R/W)
0
0
Espressif Systems
0
0
0
0
interrupt. (WT)
0
0
(re (re
0
0
se se
rv rve
32 LED PWM Controller (LEDC)
ed
0
0
) d)
0
0
0
0
0
0
0
0
0
0
LEDC_DUTY_CHNG_END_CHn_INT_ENA The
0
16
0
16
0
0
15
15
LE LE
D D
819
0
0
14
14
LE C_O LE C_O
D VF D VF
0
0
13
13
LE C_O _C LE C_O _C
DC VF NT D VF NT
0
0
12
12
LE _O _C _C LE C_O _C _C
interrupt
D VF NT H5 D VF NT H5
0
0
11
11
10
10
9
9
0
0
8
8
0
0
enable
D U NT H1 T_ R D U NT H1 T_ A
Register 32.12. LEDC_INT_CLR_REG (0x00CC)
7
7
0
0
6
6
0
0
5
5
0
0
D U CH _E _C R D U CH _E _C A
4
4
0
0
3
3
0
0
2
2
0
0
for
1
1
0
0
0
0
_T ER OV NT H0 T_ LR _T ER OV NT H0 T_ NA
IM 1_O F_ _C _ CL IM 1_O F_ _E _ EN
0 Reset
0 Reset
0_ F_ _C 0_ F_ _E
TE
DA
DC_
LE
C_
D
LE
31 0
0x19061700 Reset
33.1 Overview
The RMT (Remote Control) module is designed to send and receive infrared remote control signals. A variety
of remote control protocols are supported. The RMT module converts pulse codes stored in the module’s
built-in RAM into output signals, or converts input signals into pulse codes and stores them back in RAM.
Optionally, the RMT module modulates its output signals with a carrier wave, or demodulates and filters its
input signals.
The RMT module has four channels, numbered from zero to three. Channels 0 ~ 1 (TX channels) are
dedicated to transmit signals, and channels 2 ~ 3 (RX channels) to receive signals. Each TX/RX channel has
the same functionality controlled by a dedicated set of registers and is able to independently either transmit or
receive data. TX channels are indicated by n which is used as a placeholder for the channel number, and by m
for RX channels.
33.2 Features
• Two TX channels
• Two RX channels
• Wrap TX mode
• Wrap RX mode
• Continuous TX mode
The RMT module has four independent channels, two of which are TX channels and the other two are RX
channels. Each TX channel has its own clock-divider counter, state machine, and transmitter. Each RX channel
also has its own clock-divider counter, state machine, and receiver. The four channels share a 192 x 32-bit
RAM.
Figure 33-2 shows the format of pulse code in RAM. Each pulse code contains a 16-bit entry with two fields,
level and period.
• Period: points out how many clk_div clock cycles the level lasts for, see Figure 33-1.
A zero (0) period is interpreted as a transmission end-marker. If the period is not an end-marker, its value is
limited by APB clock and RMT clock:
The RAM is divided into four 48 x 32-bit blocks. By default, each channel uses one block, block zero for
channel zero, block one for channel one, and so on.
If the data size of one single transfer is larger than this block size of TX channel n or RX channel m, users can
configure the channel
Setting RMT_MEM_SIZE_CHn/m > 1 allows channel n/m to use the memory of subsequent channels, block
(n/m) ~ block (n/m + RMT_MEM_SIZE_CHn/m -1). If so, the subsequent channels n/m + 1 ~ n/m +
RMT_MEM_SIZE_CHn/m - 1 can not be used once their RAM blocks are occupied.
Note that the RAM used by each channel is mapped from low address to high address. In such mode,
channel 0 is able to use the RAM blocks for channels 1, 2 and 3 by setting RMT_MEM_SIZE_CH0, but channel
3 can not use the blocks for channels 0, 1, or 2. Therefore, the maximum value of RMT_MEM_SIZE_CHn
should not exceed (4 - n) and the maximum value of RMT_MEM_SIZE_CHm should not exceed (2 - m).
The RMT RAM can be accessed via APB bus, or read by the transmitter and written by the receiver. To avoid
any possible access conflict between the receiver and the APB bus, RMT can be configured to designate the
RAM block’s owner, be it the receiver or the APB bus, by configuring RMT_MEM_OWNER_CHm. If this
ownership is violated, a flag signal RMT_CHm_OWNER_ERR will be generated.
APB bus is able to access RAM in FIFO mode and in Direct Address (NONFIFO) mode, depending on the
configuration of RMT_FIFO_MASK:
When the RMT module is inactive, the RAM can be put into low-power mode by setting
RMT_MEM_FORCE_PD.
33.3.3 Clock
The clock source of RMT can be APB_CLK, RC_FAST_CLK or XTAL_CLK, depending on the configuration of
RMT_SCLK_SEL. RMT clock can be enabled by setting RMT_SCLK_ACTIVE. RMT working clock (rmt_sclk) is
obtained by dividing the selected clock source with a fractional divider, see Figure 33-1. The divider is:
RMT_DIV_CNT_CHn/m is used to configure the divider coefficient of internal clock divider for RMT channels.
The coefficient is normally equal to the value of RMT_DIV_CNT_CHn/m, except value 0 that represents
coefficient 256. The clock divider can be reset by clearing RMT_REF_CNT_RST_CHn/m. The clock generated
from the divider can be used by the counter (see Figure 33-1).
33.3.4 Transmitter
When RMT_TX_START_CHn is set, the transmitter of channel n starts reading and sending pulse codes from
the starting address of its RAM block. The codes are sent starting from low-address entry.
When an end-marker (a zero period) is encountered, the transmitter stops the transmission, returns to idle
state and generates an RMT_CHn_TX_END_INT interrupt. Setting RMT_TX_STOP_CHn to 1 also stops the
transmission and immediately sets the transmitter back to idle.
The output level of a transmitter in idle state is determined by the “level” field of the end-marker or by the
content of RMT_IDLE_OUT_LV_CHn, depending on the configuration of RMT_IDLE_OUT_EN_CHn.
To implement the above-mentioned configurations, please set RMT_CONF_UPDATE_CHn first. For more
information, see Section 33.3.6.
To transmit more pulse codes than can be fitted in the channel’s RAM, users can enable wrap TX mode by
setting RMT_MEM_TX_WRAP_EN_CHn. In this mode, the transmitter sends the data from RAM in loops till an
end-marker is encountered.
For example, if RMT_MEM_SIZE_CHn = 1, the transmitter starts sending data from the address 48 * n, and then
the data from higher RAM address. Once the transmitter finishes sending the data from (48 * (n + 1) - 1), it
continues sending data from 48 * n again till an end-marker is encountered. Wrap mode is also applicable for
RMT_MEM_SIZE_CHn > 1.
When the size of transmitted pulse codes is larger than or equal to the value set by RMT_TX_LIM_CHn, an
RMT_CHn_TX_THR_EVENT_INT interrupt is triggered. In wrap mode, RMT_TX_LIM_CHn can be set to a half or
a fraction of the size of the channel’s RAM block. When an RMT_CHn_TX_THR_EVENT_INT interrupt is
detected by software, the already used RAM region can be updated with new pulse codes. In this way the
transmitter can seamlessly send unlimited pulse codes in wrap mode.
33.3.4.3 TX Modulation
Transmitter output can be modulated with a carrier wave by setting RMT_CARRIER_EN_CHn. The carrier
waveform is configurable.
In a carrier cycle, high level lasts for (RMT_CARRIER_HIGH_CHn + 1) rmt_sclk cycles, while low level lasts for
(RMT_CARRIER_LOW_CHn + 1) rmt_sclk cycles. When RMT_CARRIER_OUT_LV_CHn is set, carrier wave is
added on the high-level of output signals; while RMT_CARRIER_OUT_LV_CHn is cleared, carrier wave is added
on the low-level of output signals.
Carrier wave can be added on all output signals during modulation, or just added on valid pulse codes (the
data stored in RAM), depending on the configuration of RMT_CARRIER_EFF_EN_CHn:
To implement the modulation configuration, please set RMT_CONF_UPDATE_CHn first. For more information,
see Section 33.3.6.
This continuous TX mode can be enabled by setting RMT_TX_CONTI_MODE_CHn. In this mode, the
transmitter sends the pulse codes from RAM in loops.
• If an end-marker is encountered, the transmitter starts transmitting the first data again.
• If no end-marker is encountered, the transmitter starts transmitting the first data again after the last data
is transmitted.
In an end-marker, if its period[14:0] is 0, then the period of the previous data must satisfy the following
requirement:
6 × Tapb_clk + 12 × Trmt_sclk < period × Tclk_div (2)
The period of the other data only need to satisfy relation (1).
To implement the above-mentioned configuration, please set RMT_CONF_UPDATE_CHn first. For more
information, see Section 33.3.6.
RMT module supports multiple channels transmitting data simultaneously. To use this function, follow the
steps below.
1. Configure RMT_TX_SIM_CHn to choose which multiple channels are used to transmit data
simultaneously.
Once the last channel is configured, these channels start transmitting data simultaneously. Due to hardware
limitations, there is no guarantee that two channels can start sending data exactly at the same time. The
interval between two channels starting transmitting data is within 3 x Tclk_div .
To configure RMT_TX_SIM_EN, please set RMT_CONF_UPDATE_CHn first. For more information, see Section
33.3.6.
33.3.5 Receiver
When the receiver becomes active, it starts counting from the first edge of the signal, detecting signal levels
and counting clock cycles the level lasts for. Each cycle count is then written back to RAM.
When the receiver detects no change in a signal level for a number of clock cycles more than the value set by
RMT_IDLE_THRES_CHm, the receiver will stop receiving data, return to idle state, and generate an
RMT_CHm_RX_END_INT interrupt.
Please note that RMT_IDLE_THRES_CHm should be configured to a maximum value according to your
application, otherwise a valid received level may be mistaken as a level in idle state.
If RAM block of this RX channel is used up by the received data, the receiver will stop receiving data, and
generate an RMT_CHm_ERR_INT interrupt triggered by RAM FULL event.
To implement configuration above, please set RMT_CONF_UPDATE_CHm first. For more information, see
Section 33.3.6.
To receive more pulse codes than can be fitted in the channel’s RAM, users can enable wrap RX mode for
channel m by configuring RMT_MEM_RX_WRAP_EN_CHm. In wrap mode, the receiver stores the received
data to RAM block of this channel in loops.
Receiving ends, when the receiver detects no change in a signal level for a number of clock cycles more than
the value set by RMT_IDLE_THRES_CHm. The receiver then returns to idle state and generates an
RMT_CHm_RX_END_INT interrupt.
For example, if RMT_MEM_SIZE_CHm is set to 1, the receiver starts receiving data and stores the data to
address 48 * m, and then to higher RAM address. When the receiver finishes storing the received data to
address (48 * (m + 1) - 1), the receiver continues receiving data and storing data to the address 48 * m again,
till no change is detected on a signal level for more than RMT_IDLE_THRES_CHm clock cycles. Wrap mode is
also applicable for RMT_MEM_SIZE_CHm > 1.
An RMT_CHm_RX_THR_EVENT_INT is generated when the size of received pulse codes is larger than or equal
to the value set by RMT_RX_LIM_CHm. In wrap mode, RMT_RX_LIM_CHM can be set to a half or a fraction of
the size of the channel’s RAM block. When an RMT_CHm_RX_THR_EVENT_INT interrupt is detected by
software, the system will be notified to copy out data stored in already used RMT RAM region, and then the
region can be updated by subsequent data. In this way an arbitrary amount of data can be seamlessly
received.
To implement the configuration above, please set RMT_CONF_UPDATE_CHm first. For more information, see
Section 33.3.6.
33.3.5.3 RX Filtering
Users can enable the receiver to filter input signals by setting RMT_RX_FILTER_EN_CHm for each channel.
The filter samples input signals continuously, and detects the signals which remain unchanged for a
continuous RMT_RX_FILTER_THRES_CHm rmt_sclk cycles as valid, otherwise, the signals are rejected. Only
the valid signals can pass through this filter. The filter removes pulses with a length of less than
RMT_RX_FILTER_THRES_CHn rmt_sclk cycles.
To implement the configuration above, please set RMT_CONF_UPDATE_CHm first. For more information, see
Section 33.3.6.
33.3.5.4 RX Demodulation
Users can enable demodulation function on input signals or on filtered output signals by setting
RMT_CARRIER_EN_CHm. RX demodulation can be applied to high-level carrier wave or low-level carrier wave,
depending on the configuration of RMT_CARRIER_OUT_LV_CHm:
If the high-level of a signal lasts for less than RMT_CARRIER_HIGH_THRES_CHm clk_div cycles, or the
low-level lasts for less than RMT_CARRIER_LOW_THRES_CHm clk_div cycles, such level is detected as a
carrier wave and then is filtered out.
To implement the configuration above, please set RMT_CONF_UPDATE_CHm first. For more information, see
Section 33.3.6.
All the bits/fields listed in the second column of Table 33-1 should follow this rule.
33.3.7 Interrupts
• RMT_CHn/m_ERR_INT: triggered when channel n/m does not read or write data correctly. For example,
if the transmitter still tries to read data from RAM when the RAM is empty, or the receiver still tries to write
data into RAM when the RAM is full, this interrupt will be triggered.
• RMT_CHn_TX_THR_EVENT_INT: triggered when the amount of data the transmitter has sent matches the
value of RMT_CHn_TX_LIM_REG.
• RMT_CHm_RX_THR_EVENT_INT: triggered each time when the amount of data received by the receiver
reaches the value set in RMT_CHm_RX_LIM_REG.
• RMT_CHn_TX_LOOP_INT: Triggered when the loop counting reaches the value set by
RMT_TX_LOOP_NUM_CHn.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
33.5 Registers
The addresses in this section are relative to RMT base address provided in Table 3-3 in Chapter 3 System and
Memory.
A
AT
nD
CH
T_
RM
31 0
0x000000 Reset
RMT_CHnDATA Read and write data for channel n via APB FIFO. (RO)
31 0
0x000000 Reset
RMT_CHmDATA Read and write data for channel m via APB FIFO. (RO)
_S D_ ST CH n
TX _R _R E_ H
n
TA R _C n
) _E CH Hn
T_ EM EM OD N_C
CH
_C C n
n
ed R _ C
RT ST_ H
Hn Hn
T _C X_ _C n
N_
CH
RM _AP ON WR Hn
rv IE EN V_
FF n
RM _TX _T _LV CH
RM _M _M I_M _E
n
se RR _ _L
_E
E_
T B T AP
T EM UT _
CH
T
T LE UT n
RM _M _O _EN
n
RM _CA ) DAT
RM _ID _O CH
CH
E_
T LE P_
T R _
IZ
T_
T d P
R
R
RM rve F_U
_S
RM _ID TO
CN
RM CA IE
T_ RR
EM
)
T _S
V_
se N
ed
(re _CO
RM _TX
DI
M
rv
T_
T_
se
T
RM
RM
RM
RM
(re
31 25 24 23 22 21 20 19 18 16 15 8 7 6 5 4 3 2 1 0
RMT_MEM_RD_RST_CHn Set this bit to reset RAM read address accessed by the transmitter for
channel n. (WT)
RMT_APB_MEM_RST_CHn Set this bit to reset RAM W/R address accessed by APB FIFO for channel
n. (WT)
RMT_TX_CONTI_MODE_CHn Set this bit to enable continuous TX mode for channel n. (R/W)
In this mode, the transmitter starts its transmission from the first data, and in the following trans-
mission:
• if an end-marker is encountered, the transmitter starts transmitting data from the first data
again;
• if no end-marker is encountered, the transmitter starts transmitting the first data again when
the last data is transmitted.
RMT_MEM_TX_WRAP_EN_CHn Set this bit to enable wrap TX mode for channel n. In this mode, if
the TX data size is larger than the channel’s RAM block size, the transmitter continues transmitting
the first data to the last data in loops. (R/W)
RMT_IDLE_OUT_LV_CHn This bit configures the level of output signal for channel n when the trans-
mitter is in idle state. (R/W)
RMT_IDLE_OUT_EN_CHn This is the output enable-bit for channel n in idle state. (R/W)
RMT_TX_STOP_CHn Set this bit to stop the transmitter of channel n sending data out. (R/W/SC)
RMT_DIV_CNT_CHn This field is used to configure the divider for clock of channel n. (R/W)
RMT_MEM_SIZE_CHn This register is used to configure the maximum number of memory blocks
allocated to channel n. (R/W)
RMT_CARRIER_EN_CHn This is the carrier modulation enable-bit for channel n. 1: Add carrier mod-
ulation on the output signal. 0: No carrier modulation is added on output signal. (R/W)
RMT_CARRIER_OUT_LV_CHn This bit is used to configure the position of carrier wave for channel
n. (R/W)
Hm Hm
_C _C
Hm
ed _EN _LV
m
CH
_C
m
R T
IE OU
CH
E_
ES
(re ARR R_
IZ
T_
R
TH
_S
CN
C IE
E_
T_ RR
EM
RM ed)
V_
DL
RM _CA
DI
M
rv
rv
I
T_
T_
T_
se
se
T
RM
RM
RM
(re
31 30 29 28 27 26 25 23 22 8 7 0
RMT_DIV_CNT_CHm This field is used to configure the clock divider of channel m. (R/W)
RMT_MEM_SIZE_CHm This field is used to configure the maximum number of memory blocks al-
located to channel m. (R/W)
RMT_CARRIER_EN_CHm This is the carrier modulation enable-bit for channel m. 1: Add carrier
modulation on output signal. 0: No carrier modulation is added on output signal. (R/W)
RMT_CARRIER_OUT_LV_CHm This bit is used to configure the position of carrier wave for channel
m. (R/W)
Hm
Hm
_C
CH T_ Hm
_C
T_ EM EM R_C m
m
m
EN
_E R_ ST m
RM _M _M NE _CH
CH
m CH
ES
N_ RS _C
RX _W _R H
P_
E_
HR
T B W N
RA
AT
RM AP _O _E
_T
W
T_ d) PD
ER
T_ EM ER
X_
RM rve F_U
ILT
RM _M FILT
_R
_F
EM
)
se N
ed
T _
(re _CO
RX
RM RX
M
rv
T_
T_
se
T
RM
RM
RM
31 (re 16 15 14 13 12 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0xf 0 1 0 0 0 Reset
RMT_RX_EN_CHm Set this bit to enable the receiver to start receiving data in channel m. (R/W)
RMT_MEM_WR_RST_CHm Set this bit to reset RAM write address accessed by the receiver for
channel m. (WT)
RMT_APB_MEM_RST_CHm Set this bit to reset RAM W/R address accessed by APB FIFO for chan-
nel m. (WT)
RMT_MEM_OWNER_CHm This bit marks the ownership of channel m’s RAM block. (R/W/SC)
RMT_RX_FILTER_EN_CHm Set this bit to enable the receiver’s filter for channel m. (R/W)
RMT_RX_FILTER_THRES_CHm When receiving data, the receiver ignores the input pulse when its
width is shorter than this register value in units of rmt_sclk cycles. (R/W)
RMT_MEM_RX_WRAP_EN_CHm Set this bit to enable wrap RX mode for channel m. In this mode,
if the RX data size is larger than channel m’s RAM block size, the receiver stores the RX data from
the first address to the last address in loops. (R/W)
K N
AS E_O
AP _C CE U
FI _F D
_M RC
T_ EM OR _P
B_ LK _P
M
FO O
NU
_S E
RM _M _F CE
IV
A
IV_
IV_
V_
SC ACT
T EM OR
EL
I
_D
_D
_D
N
RM M _F
_
_E
LK
LK
LK
LK
LK
T_ EM
)
ed
K
SC
SC
SC
SC
CL
RM _M
rv
T_
T_
T_
T_
T_
T_
se
T
RM
RM
RM
RM
RM
RM
RM
(re
31 30 27 26 25 24 23 18 17 12 11 4 3 2 1 0
RMT_APB_FIFO_MASK 1’h1: Access memory directly. 1’h0: Access memory by FIFO. (R/W)
RMT_MEM_CLK_FORCE_ON Set this bit to enable the clock for RMT memory. (R/W)
RMT_SCLK_DIV_A The numerator of the fractional part of the fractional divider. (R/W)
RMT_SCLK_DIV_B The denominator of the fractional part of the fractional divider. (R/W)
RMT_CLK_EN The enable signal of RMT register clock gate. 1: Power up the drive clock of registers.
0: Power down the drive clock of registers. (R/W)
0
T_ T_ 2
RE CN S H3
T_ 1
CN RS H
RS CH
CH
T_ F_ T_R T_C
F_ T_ T_C
RM _RE CN RS
T F_ T_
RM RE CN
T_ F_
)
ed
RM _RE
rv
se
T
RM
(re
31 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RMT_REF_CNT_RST_CH0 This bit is used to reset the clock divider of channel 0. (WT)
RMT_REF_CNT_RST_CH1 This bit is used to reset the clock divider of channel 1. (WT)
RMT_REF_CNT_RST_CH2 This bit is used to reset the clock divider of channel 2. (WT)
RMT_REF_CNT_RST_CH3 This bit is used to reset the clock divider of channel 3. (WT)
Hn
_R Hn _CH
Hn
CH
Hn
_C
_C
R_
EM _C R
_C
DR
DR
M TY ER
ER
EX
AD
B_ MP R_
AD
D_
R_
AP _E _W
_W
_R
DD
n
EM
T_ EM EM
EM
CH
A
_R
_M
RM M M
E_
T_ B_
B_
EM
AT
PB
RM _AP
AP
ST
M
A
T_
T_
T_
T_
T
RM
RM
RM
RM
RM
31 24 23 22 21 20 12 11 9 8 0
0x0 0 0 0 0 0 0 Reset
RMT_MEM_RADDR_EX_CHn This field records the memory address offset when transmitter of
channel n is using the RAM. (RO)
RMT_APB_MEM_WADDR_CHn This field records the memory address offset when writes RAM over
APB bus. (RO)
RMT_APB_MEM_RD_ERR_CHn This status bit will be set if the offset address is out of memory size
(overflows) when reads RAM via APB bus. (RO)
RMT_MEM_EMPTY_CHn This status bit will be set when the TX data size is larger than the memory
size and the wrap TX mode is disabled. (RO)
RMT_APB_MEM_WR_ERR_CHn This status bit will be set if the offset address is out of memory size
(overflows) when writes via APB bus. (RO)
RMT_APB_MEM_RADDR_CHn This field records the memory address offset when reads RAM over
APB bus. (RO)
Hm
Hm
m
CH
NE m C
_C
CH
W CH R_
R_
R
X_
_O LL_ _ER
ER
DD
_E
R_
EM U D
DR
M _F _R
_R
m
AD
T_ EM EM
EM
CH
_W
RM M M
_M
E_
T_ B_
EM
)
)
AT
PB
ed
ed
ed
RM _AP
ST
M
rv
rv
rv
A
T_
T_
T_
se
se
se
T
RM
RM
RM
RM
(re
(re
(re
31 28 27 26 25 24 22 21 20 12 11 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
RMT_MEM_WADDR_EX_CHm This field records the memory address offset when the receiver of
channel m is using the RAM. (RO)
RMT_APB_MEM_RADDR_CHm This field records the memory address offset when reads RAM over
APB bus. (RO)
RMT_MEM_OWNER_ERR_CHm This status bit will be set when the ownership of memory block is
wrong. (RO)
RMT_MEM_FULL_CHm This status bit will be set if the receiver receives more data than the memory
can fit. (RO)
RMT_APB_MEM_RD_ERR_CHm This status bit will be set if the offset address is out of memory
size (overflows) when reads RAM via APB bus. (RO)
T 1_ R T_ NT _ W
T 2 R _E T_ T_ W
W
RM _CH ER _IN RAW _IN RAW
RM _CH _ER _IN VE INT RA
RM _CH _ER HR VEN _IN RA
RA
T 3 _T E NT T_
T_
RM _CH TX HR VE AW
RM _CH _TX HR_ VE _IN
RM _CH _RX HR INT AW
ND T_ AW
TX D NT W
AW
NT W
0_ _EN _I _RA
T 1_ _T _E _R
T 0 _T _E NT
_I RA
T 2 _T P_ _R
_E _IN _R
_R
RM _CH _ER INT RAW
CH X ND T
T_ 1_T _E _IN
T_ 3_ R_ _R
T 0 R_ T_
T 2 _ T_
T 3 _L P_
RM _CH _TX OO
T 0 _L
RM CH X
T_ 1_T
d)
RM _CH
ve
r
se
T
RM
31 (re 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
ST
RM _CH ER _IN ST _IN T
T 1_ R T_ NT _S
T 2 R _E T_ T_
T 3 _T E NT T_
T_
RM _CH _TX HR_ VE _IN
RM _CH TX HR VE T
RM _CH _RX HR INT T
ND T_ T
0_ _EN _I _ST
T
T 1_ _T _E _S
T 0 _T _E NT
_I ST
T 2 _T P_ _S
_E _IN _S
_S
RM _CH _RX OO INT
TX D NT
CH X ND T
NT
RM _CH _ER INT ST
T_ 1_T _E _IN
T_ 3_ R_ _S
T 0 R_ T_
T 2 _ T_
T 3 _L P_
RM _CH _TX OO
T 0 _L
RM _CH TX
T 1_
d)
RM _CH
ver
se
T
RM
(re
31 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 1_ R T_ NT _ A
T 2 R _E T_ T_ A
A
RM _CH ER _IN EN _IN ENA
RM _CH _ER _IN VE INT EN
RM _CH _ER HR VEN _IN EN
EN
T 3 _T E NT T_
A T_
RM _CH _TX HR_ VE _IN
RM _CH TX HR VE NA
RM _CH _RX HR INT NA
ND T_ NA
TX D NT A
NA
NT A
0_ _EN _I _EN
T 1_ _T _E _E
T 0 _T _E NT
_I EN
T 2 _T P_ _E
_E _IN _E
_E
T_ 3_ R_ _E A
T_ 1_T _E _IN A
RM CH RX IN NA
RM _CH _RX OO INT
CH X ND T
RM _CH _ER INT EN
T 2 _ _
T 3 _L P_
T
RM _CH _TX OO
T 0 _L
RM _CH TX
T 1_
d)
RM _CH
ve
r
se
T
RM
31 (re 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T 1_ R T_ NT _C R
T 2 R _E T_ T_ R
R
RM _CH ER _IN CLR _IN LR
RM _CH _ER _IN VE INT CL
RM _CH _ER HR VEN _IN CL
CL
T 3 _T E NT T_
T_
RM _CH _TX HR_ VE _IN
RM _CH TX HR VE LR
RM _CH _RX HR INT LR
ND T_ LR
TX D NT R
LR
NT R
0_ _EN _I _CL
T 1_ _T _E _C
T 0 _T _E NT
_I CL
T 2 _T P_ _C
_E _IN _C
_C
RM _CH _ER INT CLR
CH X ND T
T_ 1_T _E _IN
T_ 3_ R_ _C
T 0 R_ T_
T 2 _ T_
T 3 _L P_
RM _CH _TX OO
T 0 _L
RM _CH TX
T 1_
d)
RM _CH
ver
se
T
RM
31
(re 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
Hn
CH
_C
H_
W
IG
LO
_H
R_
ER
E
RI
RI
R
R
CA
CA
T_
T_
RM
RM
31 16 15 0
RMT_CARRIER_LOW_CHn This field is used to configure carrier wave’s low level clock period for
channel n. (R/W)
RMT_CARRIER_HIGH_CHn This field is used to configure carrier wave’s high level clock period for
channel n. (R/W)
m
CH
CH
S_
S_
RE
E
HR
TH
_T
H_
OW
IG
_H
_L
ER
ER
RI
RI
R
R
CA
CA
T_
T_
RM
RM
31 16 15 0
Hn n
_C H
EN _C
T_ SET
Hn
_C
CN RE
M
P_ T_
NU
Hn
OO UN
P_
_C
_L O
TX _C
OO
IM
T_ OP
)
_L
_L
ed
RM _LO
TX
TX
rv
T_
T_
se
T
RM
RM
RM
(re
31 21 20 19 18 9 8 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x80 Reset
RMT_TX_LIM_CHn This field is used to configure the maximum entries that channel n can send out.
(R/W)
RMT_TX_LOOP_NUM_CHn This field is used to configure the maximum loop count when continuous
TX mode is enabled. (R/W)
RMT_TX_LOOP_CNT_EN_CHn This bit is the enable bit for loop counting. (R/W)
RMT_LOOP_COUNT_RESET_CHn This bit is used to reset the loop count when continuous TX mode
is enabled. (WT)
H0
IM H1
T_ _S _EN
_S _C
_C
RM _TX IM
TX IM
)
T _S
ed
RM _TX
rv
se
T
RM
(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
RMT_TX_SIM_CH0 Set this bit to enable channel 0 to start sending data synchronously with other
enabled channels. (R/W)
RMT_TX_SIM_CH1 Set this bit to enable channel 1 to start sending data synchronously with other
enabled channels. (R/W)
RMT_TX_SIM_EN This bit is used to enable multiple of channels to start sending data synchronously.
(R/W)
EG
_R
M
LI
X_
_R
d)
m
CH
ve
r
T_
se
RM
(re
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 0x80 Reset
RMT_RX_LIM_CHm This field is used to configure the maximum entries that channel m can receive.
(R/W)
TE
DA
T_
)
ed
M
rv
R
T_
se
RM
(re
31 28 27 0
0 0 0 0 0x2006231 Reset
34.1 Overview
ESP32-C3 provides the following on-chip sensor and analog signal processing peripherals:
• Two 12-bit Successive Approximation ADCs (SAR ADCs): SAR ADC1 and SAR ADC2, for measuring analog
signals from six channels.
• One temperature sensor for measuring the internal temperature of the ESP32-C3 chip.
• DIG ADC controller: drives Digital_Reader0 and Digital_Reader1 to sample channel voltages of SAR ADC1
and SAR ADC2, respectively. This DIG ADC controller supports high-performance multi-channel scanning
and DMA continuous conversion.
• PWDET controller: monitors RF power. Note this controller is only for RF internal use.
Note:
The DIG ADC controller of SAR ADC2 for ESP32-C3 does not work properly and it is suggested to use SAR ADC1. For
more information, please refer to ESP32-C3 Series SoC Errata.
34.2.2 Features
• Each SAR ADC has its own ADC Reader module (Digital_Reader0 or Digital_Reader1), which can be
configured and operated separately.
– Provides separate control modules for one-time sampling and multi-channel scanning.
– One-time sampling and multi-channel scanning can be run independently on each ADC.
– Supports threshold monitoring. An interrupt will be triggered when the sampled value is greater
than the pre-set high threshold or less than the pre-set low threshold.
– Supports DMA
As shown in Figure 34-1, the SAR ADC module consists of the following components:
• SAR ADC2: measures the voltage from one channel, or measures the internal signals such as vdd33.
– Divided Clocks:
* SAR_CLK: operating clock for SAR ADC1, SAR ADC2, Digital_Reader0, and Digital_Reader1. Note
that the divider (sar_div) of SAR_ADC must be no less than 2.
• Arbiter: this arbiter determines which controller is selected as the ADC2’s working controller, DIG ADC
controller or PWDET controller.
• Digital_Reader0 (driven by DIG ADC FSM): reads data from SAR ADC1.
• Digital_Reader1 (driven by DIG ADC FSM): reads data from SAR ADC2.
• DIG ADC FSM: generates the signals required throughout the ADC sampling process.
• Threshold monitorx: threshold monitor 1 and threshold monitor 2. The monitorx will trigger a interrupt
when the sampled value is greater than the pre-set high threshold or less than the pre-set low threshold.
In order to sample an analog signal, an SAR ADC must first select the analog pin or internal signal to measure
via an internal multiplexer. A summary of all the analog signals that may be sent to the SAR ADC module for
processing by either ADC1 or ADC2 are presented in Table 34-1.
When the SAR ADCs convert an analog voltage, the resolution (12-bit) of the conversion spans voltage range
from 0 mV to Vref . Vref is the SAR ADC’s internal reference voltage. The output value of the conversion (data)
is mapped to analog voltage Vdata using the following formula:
Vref
Vdata = × data
4095
In order to convert voltages larger than Vref , input signals can be attenuated before being input into the SAR
ADCs. The attenuation can be configured to 0 dB, 2.5 dB, 6 dB, and 12 dB.
The clock of the DIG ADC controller is quite fast, thus the sample rate is high. For more information, see
Section ADC Characteristics in ESP32-C3 Series Datasheet.
If the timer-triggered multi-channel scanning is selected, follow the configuration below. Note that in this
mode, the scan sequence is performed according to the configuration entered into pattern table.
• Configure APB_SARADC_TIMER_TARGET to set the trigger target for DIG ADC timer. When the timer
counting reaches two times of the pre-configured cycle number, a sampling operation is triggered. For
the working clock of the timer, see Section 34.2.3.4.
• When the timer times out, it drives DIG ADC FSM to start sampling according to the pattern table;
• Sampled data is automatically stored in memory via DMA. An interrupt is triggered once the scan is
completed.
Note:
Any SAR ADC can not be configured to perform both one-time sampling and multi-channel scanning at the same time.
Therefore, if a pattern table is configured to use any SAR ADC for multi-channel scanning, then this SAR ADC can not
be configured to perform one-time sampling.
Two clocks can be used as the working clock of DIG ADC controller, depending on the configuration of
APB_SARADC_CLK_SEL:
• 0: Select APB_CLK.
If ADC_CTRL_CLK is selected, users can configure the divider by APB_SARADC_CLKM_DIV_NUM. Note that
due to speed limits of SAR ADCs, the operating clock of Digital_Reader0, SAR ADC1, Digital_Reader1, and SAR
ADC2 is SAR_CLK, the frequency of which affects the sampling precision. The lower the frequency, the higher
the precision. SAR_CLK is divided from ADC_CTRL_CLK. The divider coefficient is configured by
APB_SARADC_SAR_CLK_DIV.
The ADC needs 25 SAR_CLK clock cycles per sample, so the maximum sampling rate is limited by the
SAR_CLK frequency.
DIG ADC controller supports direct memory access via peripheral DMA, which is triggered by DIG ADC timer.
Users can switch the DMA data path to DIG ADC by configuring APB_SARADC_APB_ADC_TRANS via software.
For specific DMA configuration, please refer to Chapter 2 GDMA Controller (GDMA).
Overview
Wherein:
• Timer: a dedicated timer for DIG ADC controller, to generate a sample_start signal.
• pr: the pointer to pattern table entries. FSM sends out corresponding signals based on the configuration
of the pattern table entry that the pointer points to.
• Configure APB_SARADC_TIMER_EN to enable the DIG ADC timer. The timeout event of this timer triggers
an sample_start signal. This signal drives the FSM module to start sampling.
• When the FSM module receives the sample_start signal, it starts the following operations:
– Select SAR ADC1 or SAR ADC2 as the working ADC, configure the ADC channel and attenuation,
based on the pattern table entry that the current pr points to.
– According to the configuration information, output the corresponding en_pad and atten signals to
the analog side.
• When the FSM receives the reader_done signal from ADC Reader (Digital_Reader0 or Digital_Reader1), it
will
– stop sampling,
– transfer the data to the filter, and then threshold monitor transfers the data to memory via DMA,
– update the pattern table pointer pr and wait for the next sampling. Note that if the pointer pr is
smaller than APB_SARADC_SAR_PATT_LEN (table_length), then pr = pr + 1, otherwise, pr is cleared.
Pattern Table
There is one pattern table in the controller, consisting of the APB_SARADC_SAR_PATT_TAB1_REG and
APB_SARADC_SAR_PATT_TAB2_REG registers, see Figure 34-3 and Figure 34-4:
)
ed
rv
d0
d2
d3
se
d1
(re
cm
cm
cm
cm
31 24 23 18 17 12 11 6 5 0
d6
d5
d4
d7
se
(re
cm
cm
cm
cm
31 24 23 18 17 12 11 6 5 0
Each register consists of four 6-bit pattern table entries. Each entry is composed of three fields that contain
working ADC, ADC channel and attenuation information, as shown in Table 34-5.
el
el
s
_s
n
r_
te
ch
sa
at
5 4 2 1 0
x xx x x
el
se
_s
n
r_
te
ch
sa
at
5 4 2 1 0
0 2 3
atten write the value of 3 to this field, to set the attenuation to 12 dB.
ch_sel write the value of 2 to this field, to select channel 2 (see Table 34-1).
sar_sel write the value of 0 to this bit, to select SAR ADC1 as the working ADC.
el
se
_s
n
r_
te
ch
sa
at
5 4 2 1 0
1 0 1
atten write the value of 1 to this field, to set the attenuation to 2.5 dB.
ch_sel write the value of 0 to this field, to select channel 0 (see Table 34-1).
sar_sel write the value of 1 to this bit, to select SAR ADC2 as the working ADC.
• Configure APB_SARADC_SAR_PATT_LEN to 1, i.e., set pattern table length to (this value + 1 = 2). Then
pattern table entries cmd0 and cmd1 will be used.
• Enable the timer, then DIG ADC controller starts scanning the two channels in cycles, as configured in
the pattern table entries.
The ADC eventually passes 32-bit data to the DMA, see the figure below.
ed
ed
el
el
rv
rv
s
_s
r_
se
se
ta
ch
sa
da
re
re
31 17 16 15 13 12 11 0
xx x xxx x x x
The DIG ADC controller provides two filters for automatic filtering of sampled ADC data. Both filters can be
configured to any channel of either SAR ADC and then filter the sampled data for the target channel. The
filter’s formula is shown below:
(k − 1)dataprev datain
datacur = + − 0.5
k k
• datacur : the filtered data value.
Note that x is used here as the placeholder of filter index. 0: filter 0; 1: filter 1.
DIG ADC controller contains two threshold monitors that can be configured to monitor on any channel of SAR
ADC1 and SAR ADC2. A high threshold interrupt is triggered when the ADC sample value is larger than the
pre-configured high threshold, and a low threshold interrupt is triggered if the sample value is lower than the
pre-configured low threshold.
• Configure APB_SARADC_THRESx_CHANNEL to select the SAR ADC and the channel to monitor.
Note that x is used here as the placeholder of monitor index. 0: monitor 0; 1: monitor 1.
SAR ADC2 can be controlled by two controllers, namely, DIG ADC controller and PWDET controller. To avoid
any possible conflicts and to improve the efficiency of SAR ADC2, ESP32-C3 provides an arbiter for SAR
ADC2. The arbiter supports fair arbitration and fixed priority arbitration.
• In fixed priority arbitration, users can set APB_SARADC_ADC_ARB_APB_PRIORITY (for DIG ADC
controller) and APB_SARADC_ADC_ARB_WIFI_PRIORITY (for PWDET controller), to configure the
priorities for these controllers. A larger value indicates a higher priority.
The arbiter ensures that a higher priority controller can always start a conversion (sample) when required,
regardless of whether a lower priority controller already has a conversion in progress. If a higher priority
controller starts a conversion whilst the ADC already has a conversion in progress from a lower priority
controller, the conversion in progress will be interrupted (stopped). The higher priority controller will then start
its conversion. A lower priority controller will not be able to start a conversion whilst the ADC has a conversion
in progress from a higher priority controller.
Therefore, certain data flags are embedded into the output data value to indicate whether the conversion is
valid or not.
• The data flag for DIG ADC controller is the {sar_sel, ch_sel} bits in DMA data, see Figure 34-8.
• The data flag for PWDET controller is the two higher bits of the sampling result.
34.3.2 Features
The temperature sensor has the following features:
• Supports software triggering and, once triggered, the data can be read continuously
• Wait for APB_SARADC_TSENS_XPD_WAIT clock cycles till the reset of temperature sensor is released,
the sensor starts measuring the temperature;
• Wait for a while and then read the data from APB_SARADC_TSENS_OUT. The output value gradually
approaches the actual temperature linearly as the measurement time increases.
The actual temperature (°C) can be obtained by converting the output of temperature sensor via the following
formula:
T (°C) = 0.4386 ∗ V ALU E–27.88 ∗ of f set–20.52
VALUE in the formula is the output of the temperature sensor, and the offset is determined by the temperature
offset. The temperature offset varies in different actual environment (the temperature range). For details, refer
to Table 34-2.
34.4 Interrupts
• APB_SARADC_ADC1_DONE_INT: Triggered when SAR ADC1 completes one data conversion.
• APB_SARADC_THRESx_HIGH_INT: Triggered when the sampling value is higher than the high threshold
of monitor x.
• APB_SARADC_THRESx_LOW_INT: Triggered when the sampling value is lower than the low threshold of
monitor x.
The abbreviations given in Column Access are explained in Section Access Types for Registers.
34.6 Register
The addresses in this section are relative to the ADC controller base address provided in Table 3-3 in Chapter
3 System and Memory.
R
EA
E
CE
ED
CL
CL
EN
OR
CE
CY
IV
P_
GA
_L
D
_F
OR
B_
T_
K_
K_
TT
AR
AT
AR
_F
PA
CL
CL
_P
_S
_S RT
RT
T_
R_
R_
R_
PD
AR
DC TA
TA
AI
SA
SA
SA
_W
_S
RA _S
_X
C_
C_
C_
DC
DC
DC
SA DC
AD
AD
AD
(re ARA
RA
RA
B_ RA
AP ed)
d)
ed
ed
ve
SA
SA
SA
SA
SA
AP _SA
rv
rv
rv
S
r
B_
B_
B_
B_
B_
B_
se
se
se
se
B
(re
(re
(re
AP
AP
AP
AP
AP
AP
31 30 29 28 27 26 24 23 22 18 17 15 14 7 6 5 2 1 0
1 0 0 0 0 0 0 0 0 0 0 0 7 4 1 0 0 0 0 0 0 Reset
APB_SARADC_START_FORCE 0: select FSM to start SAR ADC. 1: select software to start SAR ADC.
(R/W)
APB_SARADC_START Write 1 here to start the SAR ADC by software. Valid only when
APB_SARADC_START_FORCE = 1. (R/W)
APB_SARADC_SAR_CLK_DIV SAR ADC clock divider. This value should be no less than 2. (R/W)
APB_SARADC_SAR_PATT_LEN Configure how many pattern table entries will be used. If this field
is set to 1, then pattern table entries (cmd0) and (cmd1) will be used. (R/W)
APB_SARADC_SAR_PATT_P_CLEAR Clear the pointer of pattern table entry for DIG ADC controller.
(R/W)
IT
M
IM
NU
T
_L
GE
S_
M
AR
EA
N
NU
1_ V
V
AR IN
_E
_T
IN
_M
S_
_S 2_
ER
ER
EA
AX
DC A R
M
_M
_M
TI
TI
RA _S
C_
C_
SA DC
DC
DC
AD
AD
B_ RA
RA
RA
)
AP _SA )
ed
B d
R
AP rve
SA
SA
SA
SA
rv
B_
B_
B_
B_
se
se
(re
(re
AP
AP
AP
AP
31 25 24 23 12 11 10 9 8 1 0
0 0 0 0 0 0 0 0 10 0 0 0 255 0 Reset
R1
R
TO
TO
AC
AC
_F
_F
ER
ER
ILT
ILT
F
F
C_
C_
AD
AD
)
ed
R
R
SA
SA
rv
B_
B_
se
(re
AP
AP
31 29 28 26 25 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
1
AB
_T
TT
PA
R_
SA
C_
AD
)
ed
R
SA
rv
B_
se
(re
AP
31 24 23 0
0 0 0 0 0 0 0 0 0x0000 Reset
2
AB
_T
TT
PA
R_
SA
C_
AD
)
ed
R
SA
rv
B_
se
(re
AP
31 24 23 0
0 0 0 0 0 0 0 0 0x0000 Reset
L
M S LE
NE
ST P
TI E_ P
N
T
E_ AM
AN
NE IM SAM
TE
CH
AT
_O NET E_
E_
E_
DC O IM
M
RA 2_ ET
TI
TI
NE
NE
SA DC ON
_O
_O
B_ RA 1_
AP SA DC
DC
DC
B_ RA
RA
RA
)
ed
AP _SA
SA
SA
rv
B_
B_
se
B
(re
AP
AP
AP
31 30 29 28 25 24 23 22 0
0 0 0 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
OR CE
Y
TY
IT
IT
CE
CE
R
RB RA OR
OR
RI
I_ O
OR
_W RIO
IF _F
_A _G PRI
RI
_W NT
P
_F
F
RB _P
_
I_
B_ d) _A _A APB
PB
IF
_ A FI X
_A
_
_
_A ARB
RB
DC RB
RB
_A
_A
_
RA ADC
DC
B_ RA ADC
AP rve DC DC
DC
se RA _A
_A
_
_
B_ ADC
DC
DC
(re SA DC
DC
RA
(re ARA
d)
)
ed
ed
R
ve
SA
SA
SA
AP SA
rv
rv
S
r
B_
B_
B_
se
se
se
(re
(re
AP
AP
AP
AP
31 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 Reset
L1
NE
NE
ET
AN
N
HA
ES
H
_C
_C
_R
ER
ER
ER
ILT
ILT
ILT
F
F
C_
C_
C_
AD
AD
AD
)
)
ed
ed
R
R
SA
SA
SA
rv
rv
B_
B_
B_
se
se
(re
(re
AP
AP
AP
31 30 26 25 22 21 18 17 0
0 0 0 0 0 0 13 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TA
DA
1_
DC
A RA
_S
APB
C_
AD
)
ed
R
SA
rv
B_
se
(re
AP
31 17 16 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
TA
DA
2_
ADC
C_
AD
)
ed
R
SA
rv
B_
se
(re
AP
31 17 16 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
EL
NN
H
OW
A
IG
CH
H
_L
0_
0_
S0
ES
ES
RE
R
TH
TH
TH
C_
C_
C_
AD
AD
AD
)
)
ed
ed
R
R
SA
SA
SA
rv
rv
B_
B_
B_
se
se
(re
(re
AP
AP
AP
31 30 18 17 5 4 3 0
0 0 0x1fff 0 13 Reset
L
NE
AN
GH
OW
H
HI
_C
_L
1_
S1
S1
ES
RE
RE
R
TH
TH
TH
C_
C_
C_
AD
AD
AD
)
)
ed
ed
R
R
SA
SA
SA
rv
rv
B_
B_
B_
se
se
(re
(re
AP
AP
AP
31 30 18 17 5 4 3 0
0 0 0x1fff 0 13 Reset
LL
EN
HR 0_
_A
1_
_T ES
ES
DC HR
HR
(re ARA C_T
_T
DC
S D
B_ RA
RA
d)
)
ed
e
AP _SA
SA
rv
rv
B_
se
se
B
(re
AP
AP
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
APB_SARADC_THRES_ALL_EN Enable the threshold monitoring for all configured channels. (R/W)
1_ W_ T_ A
W T_ A
_E A
_T ES HIG _IN NA
NA
ES LO IN EN
RA _T ES HIG INT A
LO IN EN
NT N
SA DC HR 0_ E_ EN
_I E
HR 0_ H_ T_
DC HR 1_ H _E
B_ RA _T ES N NT_
AP _SA ADC HR _DO E_I
B R _T 2 N
AP _SA ADC ADC DO
B R _ 1_
AP _SA ADC ADC
B R _
AP _SA ADC
d)
B R
ve
AP _SA
r
se
B
(re
AP
31 30 29 28 27 26 25 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
1_ W_ T_ W
W T_ W
NT AW
_T ES HIG _IN AW
AW
ES LO IN RA
RA _T ES HIG INT W
LO IN RA
SA DC HR 0_ E_ RA
_I R
DC HR 1_ H _R
_R
HR 0_ H_ T_
B_ RA _T ES N NT_
AP _SA ADC HR _DO E_I
B R _T 2 N
AP _SA ADC ADC DO
B R _ 1_
AP _SA ADC ADC
B R _
AP _SA ADC
d)
B R
ve
AP _SA
r
se
B
(re
AP
31 30 29 28 27 26 25 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
T
SA DC HR 0_ E_ ST
_I S
DC HR 1_ H _S
HR 0_ H_ T_
_S
1_ W_ T_
W T_
B_ RA _T ES N NT_
RA _T ES HIG INT
AP _SA ADC HR _DO E_I
B R _T 2 N
AP _SA ADC ADC DO
B R _ 1_
AP _SA ADC ADC
B R _
AP _SA ADC
)
ed
B R
AP _SA
rv
se
B
(re
AP
31 30 29 28 27 26 25 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
1_ W_ T_ R
W T_ R
NT LR
_T ES HIG _IN LR
LR
ES LO IN CL
RA _T ES HIG INT R
LO IN CL
_I C
SA DC HR 0_ E_ CL
DC HR 1_ H _C
_C
HR 0_ H_ T_
B_ RA _T ES N NT_
AP _SA ADC HR _DO E_I
B R _T 2 N
AP SA DC DC DO
B_ RA _A 1_
AP _SA ADC ADC
B R _
AP SA DC
B_ RA
d)
ve
AP _SA
r
se
B
(re
AP
31 30 29 28 27 26 25 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reset
UM
_F
N
ET
_R NS
F_
ES
DC RA
O
_E
_A _T
PB DC
DC
_A _A
_A
DC PB
PB
RA _A
A
C_
SA DC
AD
B_ RA
)
ed
R
AP _SA
SA
rv
B_
se
B
(re
AP
AP
31 30 29 16 15 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 Reset
APB_SARADC_APB_ADC_TRANS When this bit is set, DIG ADC controller uses DMA. (R/W)
M
NU
B
A
IV_
IV_
IV_
EL
_D
_D
_D
N
DC K_S
_E
KM
KM
LK
LK
L
CL
CL
SA C_C
_C
_C
C_
C_
DC
D
AD
AD
AP ARA
RA
RA
)
ed
R
SA
SA
SA
rv
S
B_
B_
B_
B_
B_
se
(re
AP
AP
AP
AP
31 23 22 21 20 19 14 13 8 7 0
V
_D
IN
T
LK
N_
OU
U
_C
_P
I
S_
S_
NS
NS
EN
EN
SE
SE
TS
TS
T
T
C_
C_
C_
C_
AD
AD
AD
AD
)
)
ed
ed
R
R
SA
SA
SA
SA
rv
rv
B_
B_
B_
B_
se
se
(re
(re
AP
AP
AP
AP
31 23 22 21 14 13 12 8 7 0
0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0x0 Reset
T
L
AI
E
_W
_S
PD
LK
_C
X
S_
NS
EN
SE
TS
_T
C_
DC
AD
(re ARA
)
)
ed
ed
R
SA
rv
rv
S
B_
B_
se
se
(re
AP
AP
31 16 15 13 12 11 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 Reset
APB_SARADC_TSENS_XPD_WAIT The wait time before temperature sensor is powered up. (R/W)
G
CF
I_
L
CA
C_
AD
)
ed
R
SA
rv
B_
se
(re
AP
31 17 16 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x8000 Reset
31 0
0x2007171 Reset
Developer Zone
• ESP-IDF Programming Guide for ESP32-C3 – Extensive documentation for the ESP-IDF development framework.
• ESP-IDF and other development frameworks on GitHub.
https://github.com/espressif
• ESP32 BBS Forum – Engineer-to-Engineer (E2E) Community for Espressif products where you can post questions,
share knowledge, explore ideas, and help solve problems with fellow engineers.
https://esp32.com/
• The ESP Journal – Best Practices, Articles, and Notes from Espressif folks.
https://blog.espressif.com/
• See the tabs SDKs and Demos, Apps, Tools, AT Firmware.
https://espressif.com/en/support/download/sdks-demos
Products
• ESP32-C3 Series SoCs – Browse through all ESP32-C3 SoCs.
https://espressif.com/en/products/socs?id=ESP32-C3
• ESP32-C3 Series Modules – Browse through all ESP32-C3-based modules.
https://espressif.com/en/products/modules?id=ESP32-C3
• ESP32-C3 Series DevKits – Browse through all ESP32-C3-based devkits.
https://espressif.com/en/products/devkits?id=ESP32-C3
• ESP Product Selector – Find an Espressif hardware product suitable for your needs by comparing or applying filters.
https://products.espressif.com/#/product-selector?language=en
Contact Us
• See the tabs Sales Questions, Technical Enquiries, Circuit Schematic & PCB Design Review, Get Samples
(Online stores), Become Our Supplier, Comments & Suggestions.
https://espressif.com/en/contact-us/sales-questions
Glossary
REG Register.
SYSREG System registers are a group of registers that control system reset, memory,
clocks, software interrupts, power management, clock gating, etc.
ISO Isolation. If a peripheral or other chip component is powered down, the pins,
if any, to which its output signals are routed will go into a floating state. ISO
registers isolate such pins and keep them at a certain determined value, so
that the other non-powered-down peripherals/devices attached to these pins
are not affected.
NMI Non-maskable interrupt is a hardware interrupt that cannot be disabled or ig-
nored by the CPU instructions. Such interrupts exist to signal the occurrence
of a critical error.
W1TS Abbreviation added to names of registers/fields to indicate that such regis-
ter/field should be used to set a field in a corresponding register with a similar
name. For example, the register GPIO_ENABLE_W1TS_REG should be used
to set the corresponding fields in the register GPIO_ENABLE_REG.
W1TC Same as W1TS, but used to clear a field in a corresponding register.
Most frequently used access types and their combinations are as follows:
R Read. User application can read from this register/field; usually combined with other
access types.
RO Read only. User application can only read from this register/field.
HRO Hardware Read Only. Only hardware can read from this register/field; used for storing
default settings for variable parameters.
W Write. User application can write to this register/field; usually combined with other
access types.
WO Write only. User application can only write to this register/field.
SS Self set. On a specified event, hardware automatically writes 1 to this register/field;
used with 1-bit fields.
SC Self clear. On a specified event, hardware automatically writes 0 to this register/field;
used with 1-bit and multi-bit fields.
SM Self modify. On a specified event, hardware automatically writes a specified value to
this register/field; used with multi-bit fields.
RS Read to set. If user application reads from this register/field, hardware automatically
writes 1 to it.
RC Read to clear. If user application reads from this register/field, hardware automatically
writes 0 to it.
RF Read from FIFO. If user application writes new data to FIFO, the register/field auto-
matically reads it.
WF Write to FIFO. If user application writes new data to this register/field, it automatically
passes the data to FIFO via APB bus.
WS Write any value to set. If user application writes to this register/field, hardware auto-
matically sets this register/field.
W1S Write 1 to set. If user application writes 1 to this register/field, hardware automatically
sets this register/field.
W0S Write 0 to set. If user application writes 0 to this register/field, hardware automatically
sets this register/field.
WC Write any value to clear. If user application writes to this register/field, hardware au-
tomatically clears this register/field.
W1C Write 1 to clear. If user application writes 1 to this register/field, hardware automatically
clears this register/field.
W0C Write 0 to clear. If user application writes 0 to this register/field, hardware automati-
cally clears this register/field.
WT Write 1 to trigger an event. If user application writes 1 to this field, this action triggers
an event (pulse in the APB bus) or clears a corresponding WTC field (see WTC).
WTC Write to clear. Hardware automatically clears this field if user application writes 1 to
the corresponding WT field (see WT).
W1T Write 1 to toggle. If user application writes 1 to this field, hardware automatically inverts
the corresponding field; otherwise - no effect.
W0T Write 0 to toggle. If user application writes 0 to this field, hardware automatically
inverts the corresponding field; otherwise - no effect.
WL Write if a lock is deactivated. If the lock is deactivated, user application can write to
this register/field.
varies The access type varies. Different fields of this register might have different access
types.
Introduction
A field in a register is reserved if the field is not open to users, or produces unpredictable results if configured
to values other than defaults.
1. Read the value of the register, modify only the fields you want to configure and then write back the value
so that reserved fields are untouched.
OR
2. Modify only the fields you want to configure and write back the default value of the reserved fields. The
default value of a field is provided in the ”Reset” line of a register diagram. For example, the default value
of Field_A in Register X is 1.
)
ed
ed
Fi _B
_C
A
rv
rv
d_
se
se
ld
d
el
el
e
(re
(re
Fi
Fi
31 20 19 16 15 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Reset
Suppose you want to set Field_A, Field_B, and Field_C of Register X to 0×0, 0×1, and 0×2, you can:
• Use option 1 and fill in the reserved fields with the value you have just read. Suppose the register reads
as 0×0000_0003. Then, you can modify the fields you want to configure, thus writing 0×0002_0002 to
the register.
• Use option 2 and fill in the reserved fields with their defaults, thus writing 0×0002_0002 to the register.
• RAW (Raw Interrupt Status) register: This register indicates the raw interrupt status. Each bit in the register
represents a specific internal interrupt source. When an interrupt source triggers, its RAW bit is set to 1.
• ENA (Enable) register: This register is used to enable or disable the internal interrupt sources. Each bit in
the ENA register corresponds to an internal interrupt source.
By manipulating the ENA register, you can mask or unmask individual internal interrupt source as needed.
When an internal interrupt source is masked (disabled), it will not generate an interrupt signal, but its
value can still be read from the RAW register.
• ST (Status) register: This register reflects the status of enabled interrupt sources. Each bit in the ST
register corresponds to a specific internal interrupt source. The ST bit being 1 means that both the
corresponding RAW bit and ENA bit are 1, indicating that the interrupt source is triggered and not
masked. The other combinations of the RAW bit and ENA bit will result in the ST bit being 0.
• CLR (Clear) register: The CLR register is responsible for clearing the internal interrupt sources. Writing 1
to the corresponding bit in the CLR register clears the interrupt source.
Revision History