Figure 118. UART Serial Data Format .................................................................................................. 355
Figure 119. UART Clock CK_UART and Data Frame Timing ............................................................... 356
List of Figures
Rev. 1.1016 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
1
Overview
Introduction
This user manual provides detailed information including how to use the devices, system and
bus architecture, memory organization and peripheral instructions. The target audiences for this
document are software developers, application developers and hardware developers. For more
information regarding pin assignment, package and electrical characteristics, please refer to the
datasheet.
The devices are high performance and low power consumption 32-bit microcontrollers based
around an Arm® Cortex®-M0+ processor core. The Cortex®-M0+ is a next-generation processor
core which is tightly coupled with Nested Vectored Interrupt Controller (NVIC), SysTick timer,
and including advanced debug support.
The devices operate at a frequency of up to 40 MHz for HT32F52220/52230 with a Flash
accelerator to obtain maximum efciency. It provides up to 32 KB of embedded Flash memory for
code/data storage and 4 KB of embedded SRAM memory for system operation and application
program usage. A variety of peripherals, such as ADC, I2C, USART, UART, SPI, GPTM, SCTM,
SW-DP (Serial Wire Debug Port), etc., are also implemented in the device series. Several power
saving modes provide the exibility for maximum optimization between wakeup latency and power
consumption, an especially important consideration in low power applications.
The above features ensure that the devices are suitable for use in a wide range of applications,
especially in areas such as white goods application control, power monitors, alarm systems,
consumer products, handheld equipment, data logging applications, motor control and so on.
Introduction
Rev. 1.1017 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Features
▄
Core
● 32-bit Arm® Cortex®-M0+ processor core
● Up to 40MHz operating frequency for HT32F52220/52230
● Asynchronous serial communication operating baud-rate up to (f
● Capability of full duplex communication
● Fully programmable characteristics of serial communication including: word length, parity bit,
stop bit and bit order
● Error detection: Parity, overrun, and frame error
▄
Debug Support
● Serial Wire Debug Port – SW-DP
● 4 comparators for hardware breakpoint or code / literal patch
● 2 comparators for hardware watchpoints
▄
Package and Operation Temperature
● 24/28-pin SSOP, 33-pin QFN package
● Operation temperature range: -40 °C to +85 °C
/2) MHz for master mode and (f
PCLK
/16) MHz and synchronous operating rate up to
PCLK
/3) MHz for slave mode
PCLK
/16) MHz
PCLK
Introduction
Rev. 1.1020 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Device Information
Table 1. Features and Peripheral List
PeripheralsHT32F52220HT32F52230
Main Flash (KB)1631
Option Bytes Flash (KB)11
SRAM (KB)44
GPTM1
Timers
Communication
EXTI16
12-bit ADC
Number of channels
GPIOUp to 23
CPU frequencyUp to 40 MHz
Operating voltage2.0 V ~ 3.6 V
Operating temperature-40 °C ~ +85 °C
Package24/28-pin SSOP, 33-pin QFN
SCTM2
BFTM1
WDT1
SPI1
USART1
UART1
I2C1
Introduction
1
8 Channels
Rev. 1.1021 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Block Diagram
TX, RX
RTS/TXE
CTS/SCK
TX, RX
SWCLK SWDIO
AF
SW-DP
Cortex® -M0+
Processor
NVIC
Interrupt request
AF
AF
PA; PB
IO Port
GPIO
System
Bus Matrix
USART
UART
AFIO
EXTI
BOOT
AF
Flash Memory
Interface
FMC
Control Registers
AHB Peripherals
SRAM Controller
AHB to APB
Bridge
APB
Powered by V
Flash
Memory
CKCU/RSTCU
Control Registers
SRAM
WDT
SPI
I2C
GPTM
BFTM
SCTM0 ~ 1
DD15
V
DD
DD
V
SS
AF
XTALIN
XTALOUT
CLDO
AF
MOSI, MISO
SCK, SEL
AF
SDA SCL
AF
CH3 ~ CH0
AF
SCTM0 ~
SCTM1
Introduction
CAP.
POR
/PDR
HSE
4 ~ 16
MHz
HSI
8 MHz
Clock and reset control
LDO
1.5 V
BOD
LVD
Powered by V
PLL
Power control
V
AF
ADC_IN0
...
ADC_IN11
V
DDA
V
SSA
Power supply:
Bus:
Control signal:
Alternate function:
12-bit SAR
ADC
Powered by V
AF
ADC
PWRCU
DDA
Powered by V
DD15
Powered by V
LSI
32 kHz
DD
V
AF
WAKEUP
nRST
DD
SS
Figure 1. Block Diagram
Rev. 1.1022 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
2
Document Conventions
The conventions used in this document are shown in the following table.
Table 2. Document Conventions
NotationExampleDescription
0x0x5a05
0xnnnn_nnnn 0x2000_010032-bit Hexadecimal address or data.
bb0101
NAME [n]ADDR [5]
NAME [m:n]ADDR [11:5]
Xb10X1Don’t care notation which means any value is allowed.
RW
RO
RC
WC
W0C
WO
Reserved
SERDYIE
HSIRDY
SERDYF
PLLRDYIE
RW 0RW 0
32
RO 1RO 0
WC 0WC 0
RXCF
RO 0 W0C 0
WO 0WO 0
LLRDY
RO 0
HSERDY
10
PDF
BAK_PORF
RC 0RC 1
32
PLLRDYF
10
PARF
3130
DB_CKSRC
1
Reserved
1918
WordData length of a word is 32-bit.
Half-wordData length of a half-word is 16-bit.
ByteData length of a byte is 8-bit.
The number string with a 0x prefix indicates a hexadecimal
number.
The number string with a lowercase b prex indicates a binary
number.
Specic bit of NAME. NAME can be a register or eld of register.
For example, ADDR [5] means bit 5 of ADDR register (eld).
Specific bits of NAME. NAME can be a register or field of
register. For example, ADDR [11:5] means bit 11 to 5 of ADDR
register (eld).
Software can read and write to this bit.
Software can only read this bit. A write operation will have no
effect.
Software can only read this bit. Read operation will clear it to 0
automatically.
Software can read this bit or clear it by writing 1. Writing a 0 will
have no effect.
Software can read this bit or clear it by writing 0. Writing a 1 will
have no effect.
Software can only write to this bit. A read operation always
returns 0.
Reserved bit(s) for future use. Data read from these bits is not
0
well defined and should be treated as random data. Normally
these reserved bits should be set to a 0 value. Note that
reserved bit must be kept at reset value.
Document Conventions
Rev. 1.1023 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
3
System Architecture
The system architecture of devices that includes the Arm® Cortex®-M0+ processor, bus architecture
and memory organization will be described in the following sections. The Cortex®-M0+ is a next
generation processor core which offers many new features. Integrated and advanced features make
the Cortex®-M0+ processor suitable for market products that require microcontrollers with high
performance and low power consumption. In brief, The Cortex®-M0+ processor includes AHB-Lite
bus interface. All memory accesses of the Cortex®-M0+ processor are executed on the AHB-Lite
bus according to the different purposes and the target memory spaces. The memory organization
uses a Harvard architecture, pre-dened memory map and up to 4 GB of memory space, making
the system exible and extendable.
Arm® Cortex®-M0+ Processor
The Cortex®-M0+ processor is a very low gate count, highly energy efficient processor that is
intended for microcontroller and deeply embedded applications that require an area optimized,
low-power processor. The processor is based on the ARMv6-M architecture and supports Thumb®
instruction sets; single-cycle I/O port; hardware multiplier and low latency interrupt respond time.
Some system peripherals listed below are also provided by Cortex®-M0+:
▄
Internal Bus Matrix connected with AHB-Lite Interface, Single-cycle I/O port and Debug
Accesses Port (DAP)
▄
Nested Vectored Interrupt Controller (NVIC)
▄
Optional Wakeup Interrupt Controller (WIC)
▄
Breakpoint and Watchpoint Unit
▄
Optional Memory Protection Unit (MPU)
▄
Serial Wire debug Port (SW-DP)
▄
Optional Micro Trace Buffer Interface (MTB)
The following gure shows the Cortex®-M0+ processor block diagram. For more information, refer
to the Arm® Cortex®-M0+ Technical Reference Manual.
System Architecture
Rev. 1.1024 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
®
Cortex
-M0+ Components
Execution Trace Interface
Interrupts
‡ Wakeup
Interrupt
Controller (WIC)
‡ Optional Componect
Figure 2. Cortex®-M0+ Block Diagram
Bus Architecture
The HT32F52220/HT32F52230 series consists of one master and four slaves in the bus architecture.
The Cortex®-M0+ AHB-Lite bus is the master while the internal SRAM access bus, the internal
Flash memory access bus, the AHB peripherals access bus and the AHB to APB bridges are the
slaves. The single 32-bit AHB-Lite system interface provides simple integration to all system
regions include the internal SRAM region and the peripheral region. All of the master buses are
based on 32-bit Advanced High-performance Bus-Lite (AHB-Lite) protocol. The following gure
shows the bus architecture of the HT32F52220/HT32F52230 series.
Cortex-M0+ Processor
Nested
Vectored
Interrupt
Controller
(NVIC)
Cortex®-M0+
Processor
Core
‡ Memory
Protection
Unit
AHB-Lite Interface
to System
Bus Matrix
Debug
‡ Breakpoint
and
Watchpoint
Unit
‡ Debugger
Interface
‡ Single-cycle
I/O Port
‡ Debug
Access Port
(DAP)
‡ Serial Wire or JTAG
Debug Port
System Architecture
Rev. 1.1025 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
GPIO
Cortex® -M0+
Processor
NVIC
Interrupt request
Figure 3. Bus Architecture
Memory Organization
I/O Port
System
Flash Memory
Interface
FMC
Control Registers
Bus Matrix
AHB Peripherals
SRAM Controller
AHB to APB
Bridge
Control Registers
Flash
Memory
CKCU/RSTCU
SRAM
APB IPs
System Architecture
The Arm® Cortex®-M0+ processor accesses and debug accesses share the single external
interface to external AHB peripheral. The processor accesses take priority over debug accesses.
The maximum address range of the Cortex®-M0+ is 4 GB since it has 32-bit bus address width.
Additionally, a pre-defined memory map is provided by the Cortex®-M0+ processor to reduce
the software complexity of repeated implementation of different device vendors. However, some
regions are used by the Arm® Cortex®-M0+ system peripherals. Refer to the Arm® Cortex®-M0+
Technical Reference Manual for more information. The following gure shows the memory map
of HT32F52220/HT32F52230 series of devices, including Code, SRAM, peripheral, and other predened regions.
Rev. 1.1026 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Memory Map
0xFFFF_FFFF
0xE010_0000
0xE000_0000
0x4010_0000
Peripheral
SRAM
Code
0x4008_0000
0x4000_0000
0x2000_1000
0x2000_0000
0x1FF0_0400
0x1FF0_0000
0x1F00_0800
0x1F00_0000
0x000_8000
Reserved
Private peripheral bus
Reserved
AHB peripherals
APB peripherals
Reserved
Up to
4 KB on-chip SRAM
Reserved
Option byte alias
Reserved
Boot loader
Reserved
512 KB
512 KB
4 KB
1 KB
2 KB
0x400F_FFFF
0x400B_4000
0x400B_0000
0x4008_A000
0x4007_7000
0x4007_6000
0x4007_5000
0x4006_F000
0x4006_E000
0x4006_B000
0x4006_A000
0x4006_9000
0x4006_8000
0x4004_9000
0x4004_8000
0x4003_5000
0x4003_4000
0x4002_5000
0x4002_4000
0x4002_3000
0x4002_2000
0x4001_1000
0x4001_0000
0x4000_5000
0x4000_2000
0x4000_1000
0x4000_0000
Reserved
GPIO A ~ B
Reserved
CKCU/RSTCU0x4008_8000
Reserved0x4008_2000
FMC0x4008_0000
Reserved
BFTM
Reserved
SCTM10x4007_4000
Reserved
GPTM
Reserved
PWRCU
Reserved
WDT
Reserved
I2C
Reserved
SCTM0
Reserved
EXTI
Reserved
AFIO
Reserved
ADC
Reserved
SPI0x4000_4000
Reserved
UART
USART
System Architecture
AHB
APB
Up to
32 KB on-chip Flash
0x0000_0000
Up to
32 KB
Figure 4. Memory Map
Rev. 1.1027 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Table 3. Register Map
Start AddressEnd AddressPeripheralBus
0x4000_00000x4000_0FFFUSART
0x4000_10000x4000_1FFFUART
0x4000_20000x4000_3FFFReserved
0x4000_40000x4000_4FFFSPI
0x4000_50000x4001_9FFFReserved
0x4001_00000x4001_0FFFADC
0x4001_10000x4002_1FFFReserved
0x4002_20000x4002_2FFFAFIO
0x4002_30000x4002_3FFFReserved
0x4002_40000x4002_4FFFEXTI
0x4002_50000x4003_3FFFReserved
0x4003_40000x4003_4FFFSCTM0
0x4003_50000x4004_7FFFReserved
0x4004_80000x4004_8FFFI2C
0x4004_90000x4006_7FFFReserved
0x4006_80000x4006_8FFFWDT
0x4006_90000x4006_9FFFReserved
0x4006_A0000x4006_AFFFPWRCU
0x4006_B0000x4006_DFFFReserved
0x4006_E0000x4006_EFFFGPTM
0x4006_F0000x4007_3FFFReserved
0x4007_40000x4007_4FFFSCTM1
0x4007_50000x4007_5FFFReserved
0x4007_60000x4007_6FFFBFTM
0x4007_70000x4007_FFFFReserved
0x4008_00000x4008_1FFFFMC
0x4008_20000x4008_7FFFReserved
0x4008_80000x4008_9FFFCKCU/RSTCU
0x4008_A0000x400A_FFFFReserved
0x400B_00000x400B_1FFFGPIOA
0x400B_20000x400B_3FFFGPIOB
0x400B_40000x400F_FFFFReserved
System Architecture
APB
AHB
Rev. 1.1028 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Embedded Flash Memory
The HT32F52220/HT32F52230 series provides up to 32 KB on-chip Flash memory which is
located at address 0x0000_0000. It supports byte, half-word, and word access operations. Note that
the Flash memory only supports read operations for the bus access. Any write operations to the
Flash memory will cause a bus fault exception. The Flash memory has up to capacity of 32 pages.
Each page has a memory capacity of 1 KB and can be erased independently. A 32-bit programming
interface provides the capability of changing bits from 1 to 0. A data storage or rmware upgrade
can be implemented using several methods such as In System Programming (ISP), In Application
Programming (IAP) or In Circuit Programming (ICP). For more information, refer to the Flash
Memory Controller section.
Embedded SRAM Memory
The HT32F52220/HT32F52230 series contain up to 4 KB on-chip SRAM which is located at
address 0x2000_0000. It support byte, half-word and word access operations.
AHB Peripherals
The address of the AHB peripherals ranges from 0x4008_0000 to 0x400F_FFFF. Some peripherals
such as Clock Control Unit, Reset Control Unit and Flash Memory Controller are connected to the
AHB bus directly. The AHB peripherals clocks are always enabled after a system reset. Access to
registers for these peripherals can be achieved directly via the AHB bus. Note that all peripheral
registers in the AHB bus support only word access.
System Architecture
APB Peripherals
The address of APB peripherals ranges from 0x4000_0000 to 0x4007_FFFF. An APB to AHB
Bridge provides access capability between the CPU and the APB peripherals. Additionally, the
APB peripheral clocks are disabled after a system reset. Software must enable the peripheral clock
by setting the APBCCRn register in the Clock Control Unit before accessing the corresponding
peripheral register. Note that the APB to AHB Bridge will duplicate the half-word or byte data to
word width when a half-word or byte access is performed on the APB peripheral registers. In other
words, the access result of a half-word or byte access on the APB peripheral register will vary
depending on the data bit width of the access operation on the peripheral registers.
Rev. 1.1029 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
4
Flash Memory Controller (FMC)
Introduction
The Flash Memory Controller, FMC, provides all the necessary ash operation functions and pre-
fetch buffer for the embedded on-chip Flash memory. Figure below shows the block diagram of the
FMC which includes programming interface, control register, pre-fetch buffer and access interface.
Since the Flash memory access speed is slower than the CPU, a wide access interface with the
pre-fetch buffer is provided to the Flash memory in order to reduce the CPU waiting time which
will cause the CPU instruction execution delays. The Flash memory word program and page erase
functions are also provided for instruction/data storage.
Peripheral Bus
AHB
System Bus
Flash Memory Controller
Control Register
Pre-fetch Buffer
Wait State
Control
Addressing
Data
Programming
Control
Flash Memory Controller (FMC)
Flash
Information
Block
Main Flash
Memory
Figure 5. Flash Memory Controller Block Diagram
Features
▄
Up to 32 KB of on-chip Flash memory for storing instruction/data and options
● 32 KB (instruction/data + Option Byte)
● 16 KB (instruction/data + Option Byte)
▄
Page size of 1K Byte, totally up to 32 pages depending on the main Flash size
▄
Wide access interface with pre-fetch buffer to reduce instruction execution delay
▄
Page erase and mass erase capability
▄
32-bit word programming
▄
Interrupt function to indicate the end of Flash memory operation or an error occurs
▄
Flash read protection to prevent illegal code/data access
▄
Page erase/program protection to prevent unexpected operation
Rev. 1.1030 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Functional Descriptions
Flash Memory Map
The following figure is the Flash memory map of the system. The address ranges from
0x0000_0000 to 0x1FFF_FFFF (0.5 GB). The address from 0x1F00_0000 to 0x1F00_07FF is
mapped to Boot Loader Block (2 KB). Additionally, the region addressed from 0x1FF0_0000 to
0x1FF0_03FF is the alias of Option Byte block (1 KB) which is located at the last page of the main
Flash physically. The memory mapping on system view is shown as below.
0x1FFF_FFFF
0x1FF0_0400
0x1FF0_0000
0x1F00_0800
Reserved
Option Byte
Reserved
Flash Memory Controller (FMC)
1 KB
0x1F00_0000
0x0000_8000
Figure 6. Flash Memory Map
0x0000_0000
Boot Loader Block
Reserved
Main Flash Block
User Application
2 KB
32 KB
or
16 KB
Rev. 1.1031 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Memory Architecture
The Flash memory consists of up to 32 KB main Flash with 1 KB per page and 2 KB Information
Block for Boot Loader. The main Flash memory contains a total of 32 pages (or 16 pages for 16 KB
device) which can be erased individually. The following table shows the base address, size and
protection setting bit of each page.
Table 4. Flash Memory and Option Byte
BlockNameAddressPage Protection BitSize
Page 00x0000_0000 ~ 0x0000_03FFOB_PP [0]1 KB
Page 10x0000_0400 ~ 0x0000_07FFOB_PP [1]1 KB
Page 20x0000_0800 ~ 0x0000_0BFFOB_PP [2]1 KB
Page 30x0000_0C00 ~ 0x0000_0FFFOB_PP [3]1 KB
..........
Main Flash
Block
Page 280x0000_7000 ~ 0x0000_73FFOB_PP [28]1 KB
Page 290x0000_7400 ~ 0x0000_77FFOB_PP [29]1 KB
Page 300x0000_7800 ~ 0x0000_7BFFOB_PP [30]1 KB
Page 31
(Option Byte)
Information Block Boot Loader0x1F00_0000 ~ 0x1F00_07FFNA2 KB
Notes:
1. The Information Block stores boot loader – this block can not be programmed or erased by user.
2. The Option Byte is always located at last page of main Flash block.
When the CPU clock, HCLK, is greater than the access speed of the Flash memory, the wait state
cycles must be inserted during the CPU fetch instructions or load data from Flash memory. The
wait state can be changed by setting the WAIT [2:0] of the Flash Cache and Pre-fetch Control
Register, CFCR. In order to match the wait state requirement, the following two rules should be
considered.
▄
HCLK clock is switched from low speed to high speed frequency:
Change the wait state setting rst and then switch the HCLK clock.
▄
HCLK clock is switched from high speed to low speed frequency:
Switch the HCLK clock rst and then change the wait state setting.
The following table shows the relationship between the wait state cycle and HCLK. The default
wait state is 0 since the High Speed Internal oscillator, HSI, which operates at a frequency of 8MHz
is selected as the HCLK clock source after system reset.
Table 5. Relationship between Wait State Cycle and HCLK
Wait State CycleHCLK
00 MHz < HCLK ≤ 20 MHz
120 MHz < HCLK ≤ 40 MHz
Rev. 1.1032 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Booting Conguration
The system provides two kinds of boot modes which can be selected using the BOOT pin. The
BOOT pin is sampled during a power-on reset or system reset. Once the logic value is decided, the
rst 4 words of vector will be remapped to the corresponding source according to the boot modes.
The boot mode is shown in the following table.
Table 6. Boot Modes
Boot modes selection pin
BOOT
0Boot LoaderThe Vector source is Boot Loader
1Main FlashThe Vector source is main Flash
The Vector Mapping Control Register, VMCR, is provided to change the vector remapping setting
temporarily after the chip reset. The reset initial value of the VMCR register is determined by the
BOOT pin status which will be sampled during the reset duration.
ModeDescriptions
Flash Memory Controller (FMC)
Boot Setting
0xC
Hard Fault Handler
0x8
0x4
NMI Handler
Program Counter
Initial Stack Point0x0
Figure 7. Vector Remapping
+ 0xC
+ 0x8
+ 0x4
0x0000 0000
1 : Main Flash0 : Boot Loader
+ 0xC
+ 0x8
+ 0x4
0x1F00 0000
Rev. 1.1033 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Page Erase
The FMC provides a page erase function which is used to initialize the contents of the specific
Flash memory page. Each page can be erased independently without affecting the contents of other
pages. The following steps show the access sequence of the register for a page erase operation.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write the page address to the TADR register.
▄
Write the page erase command to the OCMR register (CMD [3:0] = 0x8).
▄
Commit the page erase command to the FMC by setting the OPCR register (set OPM [3:0]=0xA).
▄
Wait until all the operations have been completed by checking the OPCR register value (OPM
[3:0] equals to 0xE).
▄
Read and verify the page if required.
Note that a correct target page address must be conrmed. The software may run out of control
if the target erase page is being used to fetch code or access data. The FMC will not provide any
notification when this happens. Additionally, the page erase operation will be ignored on the
protected pages. A Flash Operation Error interrupt will be triggered by the FMC if the OREIEN bit
in the OIER register is set. The software can check the PPEF bit in the OISR register to detect this
condition in the interrupt handler. The following gure shows the page erase operation ow.
Flash Memory Controller (FMC)
No
No
Start
Is OPM equal to 0xE or 0x6 ?
Yes
Set TADR, OCMR
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Yes
Finish
Figure 8. Page Erase Operation Flowchart
Rev. 1.1034 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Mass Erase
The FMC provides a mass erase function which is used to initialize all the main Flash memory
contents to a high state. The following steps show the mass erase operation register access
sequence.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write the mass erase command to the OCMR register (CMD [3:0] = 0xA).
▄
Commit the mass erase command to the FMC by setting the OPCR register (set OPM [3:0]=0xA).
▄
Wait until all operations have been nished by checking the value of the OPCR register (OPM
[3:0] equals to 0xE).
▄
Read and verify the Flash memory if required.
Since all Flash data will be reset as 0xFFFF_FFFF, the mass erase operation can be implemented
by the program that runs in the SRAM or by the debugging tool that access the FMC register
directly. The software function that is executed on the Flash memory should not trigger a mass
erase operation. The following gure shows the mass erase operation ow.
Flash Memory Controller (FMC)
No
No
Start
Is OPM equal to 0xE or 0x6 ?
Yes
Set OCMR = 0xA
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Yes
Finish
Figure 9. Mass Erase Operation Flowchart
Rev. 1.1035 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Word Programming
The FMC provides a 32-bit word programming function which is used to modify the specic Flash
memory word contents. The following steps show the word programming operation register access
sequence.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE, or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write the word address to the TADR register. Write the word data to the WRDR register.
▄
Write the word program command to the OCMR register (CMD [3:0] = 0x4).
▄
Commit the word program command to the FMC by setting the OPCR register (set OPM [3:0]=0xA).
▄
Wait until all operations have been nished by checking the value of the OPCR register (OPM
[3:0] equals to 0xE).
▄
Read and verify the Flash memory if required.
Note that the word programming operation can not be applied to the same address twice.
Successive word programming operations to the same address must be separated by a page erase
operation. Additionally, the word programming operation will be ignored on protected pages.
A Flash operation error interrupt will be triggered by the FMC if the OREIEN bit in the OIER
register is set. The software can check the PPEF bit in the OISR register to detect this condition in
the interrupt handler. The following gure shows the word programming operation ow.
Flash Memory Controller (FMC)
No
No
Start
Is OPM equal to 0xE or 0x6 ?
Yes
Set TADR, WRDR
and OCMR
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Yes
Finish
Figure 10. Word Programming Operation Flowchart
Rev. 1.1036 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Option Byte Description
The Option Byte region can be treated as an independent Flash memory in which the base address
is 0x1FF0_0000. The following table shows the functional description and the Option Byte
0: Flash Page n Erase / Program Protection is enabled
1: Flash Page n Erase / Program Protection is disabled
OB_PP [n] (n = 31 ~ 127)
Reserved
OB_CP [0]: Flash Security Protection
0: Flash Security protection is enabled
1: Flash Security protection is disabled
OB_CP [1]: Option Byte Protection
0: Option Byte protection is enabled
1: Option Byte protection is disabled
OB_CP [31:2]: Reserved
OB_CK [31:0]: Flash Option Byte Checksum
OB_CK should be set as the sum of the 5 words Option
Byte contents, of which the offset address is from 0x000
to 0x010 (0x000 + 0x004 + 0x008 + 0x00C + 0x010),
when the OB_PP or OB_CP register content is not equal
to 0xFFFF_FFFF. Otherwise, both page erase/program
protection and security protection will be enabled.
Flash Memory Controller (FMC)
0xFFFF_FFFF
0xFFFF_FFFF
0xFFFF_FFFF
0xFFFF_FFFF
0xFFFF_FFFF
0xFFFF_FFFF
Rev. 1.1037 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Page Erase/Program Protection
The FMC provides the page erase/program protection function to prevent unexpected operation of
the Flash memory. The page erase (CMD [3:0] = 0x8 in the OCMR register) or word program (CMD
[3:0] = 0x4) command will not be accepted by the FMC on the protected pages. When the page
erase or word programming command is sent to the FMC on a protected page, the PPEF bit in the
OISR register will then be set by the FMC and the Flash operation error interrupt will be triggered
to the CPU by the FMC if the OREIEN bit in the OIER register is set. The page protection function
can be enabled for each page independently by setting the OB_PP registers in the Option Byte. The
following table shows the access permission of the main Flash page when the page protection is
enabled.
Table 8. Access Permission of Protected Main Flash Page
Operation
ReadOO
ProgramXX
Page EraseXX
Mass EraseOO
Mode
Flash Memory Controller (FMC)
ISP/IAPICP/Debug mode
Notes:
1. The write protection is based on specific pages. The above access permission only
affects the pages of which the protection function has been enabled. Other pages are not
affected.
2. The Main Flash page protection is congured by the OB_PP [126:0] eld. The Option Byte
is physically located at the last page of the main Flash. The Option Byte page protection is
congured by the OB_CP [1] bit.
3. The page erase on the Option Byte area can be used to disable the page protection of the
main Flash.
4. The page protection of the Option Byte can only be disabled by a mass erase operation.
The following steps show the page erase/program protection register access sequence.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write the OB_PP address to the TADR register (TADR = 0x1FF0_0000).
▄
Write the WRDR register, which indicates the protection function of corresponding page is
enabled or disabled (0: Enabled, 1: Disabled).
▄
Write the word program command to the OCMR register (CMD [3:0] = 0x4).
▄
Commit the word program command to the FMC by setting the OPCR register (set OPM [3:0] =
0xA).
▄
Wait until all operations have been nished by checking the value of the OPCR register (OPM
[3:0] equals to 0xE).
▄
Read and verify the Option Byte if required.
▄
The OB_CK eld in the Option Byte must be updated according to the Option Byte checksum
rule.
▄
Apply a system reset to activate the new OB_PP setting.
Rev. 1.1038 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Security Protection
The FMC provides a Security protection function to prevent an illegal code/data access of the
Flash memory. This function is useful for protecting the software / rmware from the illegal users.
The function is activated by conguring the Option Byte OB_CP [0] bit. Once the function has
been enabled, all the main Flash data access through ICP/Debug mode, programming and page
erase operation will not be allowed except via the user’s application. However, the mass erase
operation will still be accepted by the FMC in order to disable this security protection function.
The following table shows the access permission of the Flash memory when the security protection
is enabled.
Table 9. Access Permission When Security Protection is Enabled
Operation
ReadOX (read as 0)
ProgramO
Page EraseO
Mass EraseOO
Mode
User application
(Note 1)
(Note 1)
(Note 1)
Flash Memory Controller (FMC)
ICP/Debug mode
X
X
Notes:
1. User application means the software that is executed or booted from the main Flash
memory with the JTAG/SW debugger being disconnected. However, the Option Byte
block and page 0 are still in protection and the Program/Page Erase operation cannot be
executed.
2. The Mass erase operation can erase the Option Byte block and disable the security
protection.
The following steps show the security protection register access sequence:
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the pervious operation has been nished.
▄
Write the OB_CP address to the TADR register (TADR = 0x1FF0_0010).
▄
Write the data into the WRDR register to set the OB_CP [0] eld to 0.
▄
Write the word program command to the OCMR register (CMD [3:0] = 0x4).
▄
Commit the word program command to the FMC by setting the OPCR register (set OPM = 0xA).
▄
Wait until all operations have been nished by checking the value of the OPCR register (OPM
[3:0] equals to 0xE).
▄
Read and verify the Option Byte if required.
▄
The OB_CK eld in the Option Byte must be updated according to the Option Byte checksum
rule.
▄
Apply a system reset to active the new OB_CP setting.
Rev. 1.1039 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Register Map
The following table shows the FMC registers and reset values.
OISR0x018Flash Operation Interrupt and Status Register0x0001_0000
0x020
PPSR
CPSR0x030Flash Security Protection Status Register0xXXXX_XXXX
VMCR0x100Flash Vector Mapping Control Register0x0000_000X
MDID0x180Flash Manufacturer and Device ID Register0x0376_XXXX
PNSR0x184Flash Page Number Status Register0x0000_00X0
PSSR0x188Flash Page Size Status Register0x0000_0400
CFCR0x200Flash Pre-fetch Control Register0x0000_0011
CIDR00x310Custom ID Register 00xXXXX_XXXX
CIDR10x314Custom ID Register 10xXXXX_XXXX
CIDR20x318Custom ID Register 20xXXXX_XXXX
CIDR30x31CCustom ID Register 30xXXXX_XXXX
0x024
0x028
0x02C
Flash Page Erase/Program Protection Status Register
Flash Memory Controller (FMC)
0xXXXX_XXXX
0xXXXX_XXXX
0xXXXX_XXXX
0xXXXX_XXXX
Note:
“X” means various reset values which depend on the Device, Flash value, Option Byte value,
or power on reset setting.
Rev. 1.1040 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Register Descriptions
Flash Target Address Register – TADR
This register species the target address of the page erase and word programming operations.
Offset:0x000
Reset value: 0x0000_0000
3130292827262524
TADB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
2322212019181716
TADB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
15141312111098
TADB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
76543210
TADB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
BitsFieldDescriptions
[31:0]TADBFlash Target Address Bits
For programming operations, the TADR register specifies the address where the
data is written. Since the programming length is 32-bit, the TADR should be set as
word-aligned (4 bytes). The TADB [1:0] bits will be ignored during programming
operations. For page erase operations, the TADR register contains the page address
which is going to be erased. Since the page size is 1 KB, the TADB [9:0] bits will
be ignored in order to limit the target address as 1 Kbyte-aligned. For 32 KB main
Flash addressing, the TADB [31:16] bits should be zero while the TADB [31:15] bits
should be zero for 16 KB main Flash addressing. The region of which the address
ranges from 0x1FF0_0000 to 0x1FF0_03FF is the 1KB Option Byte. This eld for the
available Flash address must be under 0x1FFF_FFFF. Otherwise, the Invalid Target
Address interrupt will occur if the corresponding interrupt enable bit is set.
Flash Memory Controller (FMC)
Rev. 1.1041 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Write Data Register – WRDR
This register species the data to be written for programming operation.
Offset:0x004
Reset value: 0x0000_0000
3130292827262524
WRDB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
2322212019181716
WRDB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
15141312111098
WRDB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
76543210
WRDB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
Flash Memory Controller (FMC)
BitsFieldDescriptions
[31:0]WRDBFlash Write Data Bits
The data value for programming operation.
Rev. 1.1042 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Operation Command Register – OCMR
This register is used to specify the Flash operation commands that include word program, page erase and mass
erase.
Offset:0x00C
Reset value: 0x0000_0000
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedCMD
Type/ResetRW 0 RW 0 RW 0 RW 0
BitsFieldDescriptions
[3:0]CMDFlash Operation Command
The following table shows the denitions of the operation command bits, CMD [3:0],
which specify the Flash memory operation. If an invalid command is set and the
IOCMIEN bit is set to 1, an Invalid Operation Command interrupt will occur.
CMD [3:0]Description
0x0Idle (default)
0x4Word program
0x8Page erase
0xAMass erase
OthersReserved
Flash Memory Controller (FMC)
Rev. 1.1043 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Operation Control Register – OPCR
This register is used for controlling the command commitment and checking the status of the FMC operations.
Offset:0x010
Reset value: 0x0000_000C
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedOPMReserved
Type/ResetRW 0 RW 1 RW 1 RW 0
Flash Memory Controller (FMC)
BitsFieldDescriptions
[4:1]OPMOperation Mode
The following table shows the operation modes of the FMC. User can commit the
command which is set by the OCMR register to the FMC according to the address
alias setting in the TADR register. The contents of the TADR, WRDR, and OCMR
registers should be prepared before setting this register. After all the operations
have been finished, the OPM field will be set as 0xE by the FMC hardware.
The Idle mode can be set when all the operations have been nished for power
saving purpose. Note that the operation status should be checked before the next
operation is executed to the FMC. The contents of the TADR, WRDR, OCMR,
and OPCR registers should not be changed until the previous operation has been
nished.
OPM [3:0]Description
0x6Idle (default)
0xACommit command to main Flash
0xEAll operation nished on main Flash
OthersReserved
Rev. 1.1044 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Operation Interrupt Enable Register – OIER
This register is used to enable or disable the FMC interrupt function. The FMC generates interrupts to the
controller when corresponding interrupt enable bits are set.
Offset:0x014
Reset value: 0x0000_0000
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedOREIENIOCMIENOBEIENITADIENORFIEN
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0
BitsFieldDescriptions
[4]OREIENOperation Error Interrupt Enable
0: Operation error interrupt is disabled
1: Operation error interrupt is enabled
0: Invalid Operation Command interrupt is disabled
1: Invalid Operation Command interrupt is enabled
[2]OBEIENOption Byte Check Sum Error Interrupt Enable
0: Option Byte Check Sum Error interrupt is disabled
1: Option Byte Check Sum Error interrupt is enabled
[1]ITADIENInvalid Target Address Interrupt Enable
0: Invalid Target Address interrupt is disabled
1: Invalid Target Address interrupt is enabled
[0]ORFIENOperation Finished Interrupt Enable
0: Operation Finish interrupt is disabled
1: Operation Finish interrupt is enabled
Flash Memory Controller (FMC)
Rev. 1.1045 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Operation Interrupt and Status Register – OISR
This register indicates the FMC interrupt status which is used to check if a Flash operation has been nished or
an error occurs. The status bits, bit [4:0], are available when the corresponding bits in the OIER register are set.
Offset:0x018
Reset value: 0x0001_0000
3130292827262524
Reserved
Type/Reset
2322212019181716
ReservedPPEFRORFF
Type/ResetRO 0 RO 1
15141312111098
Reserved
Type/Reset
76543210
ReservedOREFIOCMFOBEFITADFORFF
Type/ResetWC 0 WC 0 WC 0 WC 0 WC 0
BitsFieldDescriptions
[17]PPEFPage Erase/Program Protected Error Flag
0: Page Erase/Program Protected Error does not occur
1: Operation error occurs due to an invalid erase/program operation applied to a
protected page
This bit is reset by hardware once a new ash operation command is committed.
[16]RORFFRaw Operation Finished Flag
0: The last ash operation command is not nished
1: The last ash operation command is nished
The RORFF bit is directly connected to the Flash memory for debugging purpose.
[4]OREFOperation Error Flag
0: No Flash operation error occurred
1: The last ash operation is failed
This bit will be set when any Flash operation error occurs such as an invalid
command, program error and erase error, etc. The ORE interrupt occurs if the
OREIEN bit in the OIER register is set. Reset this bit by writing 1.
[3]IOCMFInvalid Operation Command Flag
0: No invalid ash operation command was set
1: An invalid ash operation command has been written into the OCMR register
The IOCM interrupt will occur if the IOCMIEN bit in the OIER register is set. Reset
this bit by writing 1.
[2]OBEFOption Byte Checksum Error Flag
0: Option Byte checksum is correct
1: Option Byte checksum is incorrect
The OBE interrupt will occur if the OBEIEN bit in the OIER register is set. This bit
is cleared to 0 by software writing 1 into it. However, the Option Byte Checksum
Error Flag can not be cleared by software until the interrupt condition is cleared,
which means that the Option Byte check sum value has to be correctly modied
or the corresponding interrupt control is disabled. Otherwise, the interrupt will be
continually generated.
Flash Memory Controller (FMC)
Rev. 1.1046 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
BitsFieldDescriptions
[1]ITADFInvalid Target Address Flag
0: The target address is valid
1: The target address is invalid
The data in the TADR eld must be in the range from 0x0000_0000 to 0x1FFF_
FFFF. Otherwise, an ITAD interrupt will occur if the ITADIEN bit in the OIER register
is set. Reset this bit by writing 1.
[0]ORFFOperation Finished Flag
0: No ash operation is nished
1: Last Flash operation is nished
The ORF interrupt will occur if the ORFIEN bit in the OIER register is set. Reset this
bit by writing 1.
Flash Memory Controller (FMC)
Rev. 1.1047 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Page Erase/Program Protection Status Register – PPSR
This register indicates the page protection status of the Flash page erase/program protection functions.
Offset:0x020 (0) ~ 0x02C (3)
Reset value: 0xXXXX_XXXX
3130292827262524
PPSBn
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
2322212019181716
PPSBn
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
15141312111098
PPSBn
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
76543210
PPSBn
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
Flash Memory Controller (FMC)
BitsFieldDescriptions
[127:0]PPSBnPage Erase/Program Protection Status Bits (n = 0 ~ 127)
PPSB[n] = OB_PP[n]
0: The corresponding page n is protected
1: The corresponding page n is not protected
The content of this register is not dynamically updated and will only be reloaded
from the Option Byte when any kind of reset occurs. The erase or program function
of the specific page is not allowed when the corresponding bits of the PPSR
registers are reset. The reset value of PPSR [127:0] is determined by the Option
Byte OB_PP [127:0] bits. Each page erase/program protection status bit protects
one page. The other remained bits of the OB_PP field and PPSR registers are
reserved.
Rev. 1.1048 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Security Protection Status Register – CPSR
This register indicates the Flash Memory Security protection status. The content of this register is not dynamically
updated and will only be reloaded by the Option Byte loader which is active when any kind of reset occurs.
Offset:0x030
Reset value: 0xXXXX_XXXX
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedOBPSBCPSB
Type/ResetRO X RO X
BitsFieldDescriptions
[1]OBPSBOption Byte Page Erase/Program Protection Status Bit
0: The Option Byte page is protected
1: The Option Byte page is not protected
The reset value of the OPBSB bit is determined by the Option Byte OB_CP [1] bit.
[0]CPSBFlash Memory Security Protection Status Bit
0: Flash Memory Security protection is enabled
1: Flash Memory Security protection is not enabled
The reset value of the CPSB bit is determined by the Option Byte OB_CP [0] bit.
Flash Memory Controller (FMC)
Rev. 1.1049 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Vector Mapping Control Register – VMCR
This register is used to control the vector mapping. The reset value of the VMCR register is determined by the
external BOOT pin during the power-on reset period.
Offset:0x100
Reset value: 0x0000_000X
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedVMCBReserved
Type/ResetRW X
BitsFieldDescriptions
[1]VMCBVector Mapping Control Bit
The VMCB bit is used to control the mapping source of the first 4-word vectors
addressed from 0x0 to 0xC. The following table shows the vector mapping setting.
BOOTVMCB [1]Descriptions
Low0
High1
The reset value of the VMCB bit is determined by the BOOT pin status during the
power-on reset and system reset. The vector mapping setting can be changed
temporarily by conguring the VMCB bit when the application program is executed.
Boot Loader mode
The vector mapping source is the boot loader area.
Main Flash mode
The vector mapping source is the main Flash area.
Flash Memory Controller (FMC)
Rev. 1.1050 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Manufacturer and Device ID Register – MDID
This register is used to store the manufacture ID and device part number information which can be used as the
product identity.
Offset:0x180
Reset value: 0x0376_xxxx
3130292827262524
MFID
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 1 RO 1
2322212019181716
MFID
Type/ResetRO 0 RO 1 RO 1 RO 1 RO 0 RO 1 RO 1 RO 0
15141312111098
ChipID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
76543210
ChipID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
BitsFieldDescriptions
[31:16]MFIDManufacturer ID
Read as 0x0376
[15:0]ChipIDChip ID
Read the last 4 digital codes of the MCU device part number.
Flash Memory Controller (FMC)
Rev. 1.1051 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Page Number Status Register – PNSR
This register is used to indicate the Flash memory page number.
Offset:0x184
Reset value: 0x0000_00XX
3130292827262524
PNSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
2322212019181716
PNSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
15141312111098
PNSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
76543210
PNSB
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
Flash Memory Controller (FMC)
BitsFieldDescriptions
[31:0]PNSBFlash Page Number Status Bits
0x0000_0010: Totally 16 pages for the on-chip Flash memory device
0x0000_0020: Totally 32 pages for the on-chip Flash memory device
0x0000_0040: Totally 64 pages for the on-chip Flash memory device
0x0000_0080: Totally 128 pages for the on-chip Flash memory device
0x0000_00FF: Totally 255 pages for the on-chip Flash memory device
Rev. 1.1052 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Page Size Status Register – PSSR
This register is used to indicate the page size in bytes.
Offset:0x188
Reset value: 0x0000_0400
3130292827262524
PSSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
2322212019181716
PSSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
15141312111098
PSSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 1 RO 0 RO 0
76543210
PSSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
Flash Memory Controller (FMC)
BitsFieldDescriptions
[31:0]PSSBFlash Page Size Status Bits
0x200: The page size is 512 Bytes per page
0x400: The page size is 1 KB per page
0x800: The page size is 2 KB per page
Rev. 1.1053 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Device ID Register – DID
This register is used to store the device part number information which can be used as the product identity.
Offset:0x18C
Reset value: 0x000X_XXXX
3130292827262524
Reserved
Type/Reset
2322212019181716
ReservedChipID
Type/ResetRO X RO X RO X RO X
15141312111098
ChipID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
76543210
ChipID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
Flash Memory Controller (FMC)
BitsFieldDescriptions
[19:0]ChipIDChip ID
Read the complete 5 digital codes of the MCU device part number.
Rev. 1.1054 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Flash Pre-fetch Control Register – CFCR
This register is used to control the FMC pre-fetch module.
Offset:0x200
Reset value: 0x0000_0011
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedPFBEReservedWAIT
Type/ResetRW 1RW 0 RW 0 RW 1
Flash Memory Controller (FMC)
BitsFieldDescriptions
[4]PFBEPre-fetch Buffer Enable Bit
0: Pre-fetch buffer is disabled
1: Pre-fetch buffer is enabled (default)
The pre-fetch buffer is enabled in default. When the pre-fetch buffer is disabled,
the instruction and data are directly provided by the Flash memory.
[2:0]WAITFlash Wait State Setting
The WAIT[2:0] eld is used to set the HCLK wait clock during a non-sequential
address Flash access. The actual wait clock is given by (WAIT[2:0] - 1). Since
a wide access interface with a pre-fetch buffer is provided, the wait state of
sequential Flash access is very close to zero.
WAIT [2:0] Wait StatusAllowed HCLK Range
00100 MHz < HCLK ≤ 20 MHz
010120 MHz < HCLK ≤ 40 MHz
OthersReserved Reserved
Rev. 1.1055 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Custom ID Register n – CIDRn ( n = 0 ~3)
This register is used to store the custom ID information which can be used as the custom identity.
Offset:0x310 (0) ~ 0x31C (3)
Reset value: Various depending on Flash Manufacture Privilege Information Block.
3130292827262524
CID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
2322212019181716
CID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
15141312111098
CID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
76543210
CID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
Flash Memory Controller (FMC)
BitsFieldDescriptions
[31:0]CIDnCustom ID
Read as the CIDn[31:0] (n=0 ~ 3) field in the Custom ID registers in Flash
Manufacture Privilege Block.
Rev. 1.1056 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
PWR_CTRL
LSI
LDOOFF
DMOSON
SLEEPDEEP
nRST
V
DD15
V
DD
V
DD15
1.5 V Domain
V
DD
Domain
LVD: Low Voltage Detector
POR/PDR: Power On Reset/Power Down Reset
LDO: Voltage Regulator
DMOS: Depletion MOS
SLEEPING
LCM
WKUP1
WAKEUP
WKUP2
WKUP4
LVD
HSI
HSE
DMOS
LDO
CPU
Memories
Digital
Peripheral
APB
INTF
3.3 V
POR/PDR
1.5 V
POR/PDR
PLL
V
LDOOUT
HT32F52220/HT32F52230
5
Power Control Unit (PWRCU)
Introduction
The power consumption can be regarded as one of the most important issues for many embedded
system applications. Accordingly the Power Control Unit, PWRCU, provides many types of power
saving modes such as Sleep, Deep-Sleep1, Deep-Sleep2, and Power-Down modes. These modes
reduce the power consumption and allow the application to achieve the best trade-off between the
conicting demands of CPU operating time, speed and power consumption. The dash line in the
Figure 11 indicates the power supply source of two digital power domains.
Power Control Unit (PWRCU)
Figure 11. PWRCU Block Diagram
Rev. 1.1057 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Features
▄
Two power domains: VDD 3.3 V and V
▄
Four power saving modes: Sleep, Deep-Sleep1, Deep-Sleep2 and Power-Down modes.
▄
Internal Voltage regulator supplies 1.5 V voltage source.
▄
Additional Depletion MOS supplies 1.5 V voltage source with low leakage and low operating
current.
▄
A power reset is generated when one of the following events occurs:
● Power-on / Power-down reset (POR / PDR reset).
● When exiting Power-Down mode.
● The control bits BODEN = 1, BODRIS=0 and the supply power VDD ≤ V
▄
BOD Brown Out Detector can issue a system reset or an interrupt when VDD power source is
lower than the Brown Out Detector voltage V
▄
LVD Low Voltage Detector can issue an interrupt or wakeup event when VDD is lower than a
programmable threshold voltage V
1.5 V power domains.
DD15
BOD
.
LVD
Power Control Unit (PWRCU)
.
BOD
.
Functional Descriptions
VDD Power Domain
LDO Power Control
The LDO will be automatically switched off when one of the following conditions occurs:
▄
The Power-Down or Deep-Sleep 2 mode is entered.
▄
The control bits BODEN = 1, BODRIS = 0 and the supply power VDD ≤ V
▄
The supply power VDD ≤ V
The LDO will be automatically switched on by hardware when the supply power VDD > V
of the following conditions occurs:
▄
Resume operation from the power saving mode – LVD wakeup and WAKEUP pin rising edge.
▄
Detect a falling edge on the external reset pin (nRST).
▄
The control bit BODEN = 1 and the supply power VDD > V
To enter the Deep-Sleep1 mode, the PWRCU will request the LDO to operate in a low current
mode, LCM. To enter the Deep-Sleep 2 mode, the PWRCU will turn off the LDO and turn on the
DMOS to supply an alternative 1.5 V power.
Voltage Regulator
The voltage regulator, LDO, Depletion MOS, DMOS, Low voltage Detector, LVD, High Speed
Internal oscillator, HSI, and Low Speed Internal RC oscillator, LSI, are operated under the VDD
power domain. The LDO can be configured to operate in either normal mode (LDOOFF = 0,
LDOLCM = 0, I
= Low current mode) to supply the 1.5 V power. An alternative 1.5 V power source is the output
of the DMOS which has low static and driving current characteristics. It is controlled using the
DMOSON bit in the PWRCR register. The DMOS output has weak output current and regulation
capability and only operate in the Deep-Sleep 2 mode for data retention purposes in the V
power domain.
= High current mode) or low current mode (LDOOFF = 0, LDOLCM =1, I
OUT
PDR
BOD
.
BOD
if any
POR
.
OUT
DD15
Rev. 1.1058 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Power On Reset (POR) / Power Down Reset (PDR)
The device has an integrated POR/PDR circuitry that allows proper operation starting from/down
to 2.0 V. The device remains in Power-Down mode when VDD is below a specied threshold V
without the need for an external reset circuit. For more details the power on / power down reset
threshold voltage, refer to the electrical characteristics of the corresponding datasheet.
V
,
PDR
DD
V
POR
Hysteresis
V
PDR
Power Control Unit (PWRCU)
POR Delay Time
t
RESET
RSTD
Figure 12. Power On Reset / Power Down Reset Waveform
Low Voltage Detector / Brown Out Detector
The Low Voltage Detector, LVD, can detect whether the supply voltage VDD is lower than a
programmable threshold voltage V
. It is selected by the LVDS bits in the LVDCSR register.
LV D
When a low voltage on the VDD power pin is detected, the LVDF ag will be active and an interrupt
will be generated and sent to the MCU core if the LVDEN and LVDIWEN bits in the LVDCSR
register are set. For more details concerning the LVD programmable threshold voltage V
to the electrical characteristics of the corresponding datasheet.
The Brown Out Detector, BOD, is used to detect if the VDD supply voltage is equal to or lower
than V
is lower than V
. When the BODEN bit in the LVDCSR register is set to 1 and the VDD supply voltage
BOD
then the BODF ag is active. The PWRCU will regard this as a power down
BOD
reset situation and then immediately disable the internal LDO regulator when the BODRIS bit is
cleared to 0 or issue an interrupt to notify the CPU to execute a power down procedure when the
BODRIS bit is set to 1. For more details concerning the Brown Out Detector voltage V
the electrical characteristics of the corresponding datasheet.
Time
LV D
, refer to
BOD
, refer
High Speed Internal Oscillator
The High Speed Internal Oscillator, HSI, is located in the VDD power domain. When exiting from
the Deep-Sleep mode, the HSI clock will be congured as the system clock for a certain period
by setting the PSRCEN bit to 1 This bit is located in the Global Clock Control Register, GCCR, in
the Clock Control Unit, CKCU. The system clock will not be switched back to the original clock
source used before entering the Deep-Sleep mode until the original clock source, which may be
either sourced from the PLL or HSE stabilizes. Also the system will force the HSI oscillator to be
the system clock after a wake up from Power-Down mode since a 1.5 V power on reset will occur.
Rev. 1.1059 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
High Speed External Oscillator
The High Speed External Oscillator, HSE, is located in the VDD power domain. The HSE crystal
oscillator can be switched on or off using the HSEEN bit in the Global Clock Control Register,
GCCR. The HSE clock can then be used directly as the system clock source or be used as the PLL
input clock.
Isolation Cells
When the device resumes operation from the 1.5 V power, either by Hardware or Software, access
to the PWRCU registers in the VDD power domain are disabled by the isolation cells which protect
these registers against possible parasitic write accesses. To resume access operations, users must
disable these isolation cells by setting the VDDISO bit to 1 in the LPCR register of the Clock
Control Unit.
1.5 V Power Domain
The main functions that include the APB interface for the VDD domain, CPU core logic, AHB/APB
peripherals and memories and so on are located in this power domain. Once the 1.5 V is powered
up, the POR will generate a reset sequence on 1.5 V power domain. Subsequently, to enter the
expected power saving mode, the associated control bits including the LDOOFF, DMOSON and
LDOLCM bits must be congured. Then, once a WFI or WFE instruction is executed, the device
will enter an expected power saving mode which will be discussed in the following section.
Power Control Unit (PWRCU)
Operation Modes
Run Mode
In the Run mode, the system operates with full functions and all power domains are active. There
are two ways to reduce the power consumption in this mode. The rst is to slow down the system
clock by setting the AHBPRE eld in the CKCU AHBCFGR register, and the second is to turn
off the unused peripherals clock by setting the APBCCR0 and APBCCR1 registers or slow down
peripherals clock by setting the APBPCSR0 and APBPCSR1 registers to meet the application
requirement. Reducing the system clock speed before entering the sleep mode will also help to
minimize power consumption.
Additionally, there are several power saving modes to provide maximum optimization between
device performance and power consumption.
Table 11. Operation Mode Denitions
Mode nameHardware Action
RunAfter system reset, CPU fetches instructions to execute.
Sleep
Deep-Sleep1~2
Power-DownShut down the 1.5 V power domain
1. CPU clock will be stopped.
2. Peripherals, Flash and SRAM clocks can be stopped by setting.
1. Stop all clocks in the 1.5 V power domain.
2. Disable HSI, HSE, and PLL.
3. Turning on the LDO low current mode or DMOS to reduce the 1.5 V power
domain current.
Rev. 1.1060 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Sleep Mode
By default, only the CPU clock will be stopped in the Sleep mode. Clearing the FMCEN or
SRAMEN bit in the CKCU AHBCCR register to 0 will have the effect of stopping the Flash
clock or SRAM clock after the system enters the Sleep mode. If it is not necessary for the CPU to
access the Flash memory and SRAM in the Sleep mode, it is recommended to clear the FMCEN
and SRAMEN bits in the AHBCCR register to minimize power consumption. To enter the Sleep
mode, it is only CPU executes a WFI or WFE instruction and lets the SLEEPDEEP signal to 0. The
system will exit from the Sleep mode via any interrupt or event trigger. The accompanying table
provides more information about the power saving modes.
Table 12. Enter/Exit Power Saving Modes
Mode Entry
Mode
Sleep
Deep-Sleep1100
Deep-Sleep21X1
Power-Down110
Notes:
1. Wakeup event means EXTI line in event mode, LVD, and WAKEUP pin rising edge.
2. If the system allows the LVD activity to wake it up after the system has entered the power saving mode,
CPU
Instruction
WFI or WFE
(Takes effect)
CPU
SLEEPDEEP
0XX
LDOOFF DMOSON
WFI: Any interrupt
WFE:
Any wakeup event
Any interrupt (NVIC on) or
Any interrupt with SEVONPEND = 1 (NVIC off)
Any EXTI in event mode or
LVD wakeup
WAKEUP pin rising edge
LVD wakeup
WAKEUP pin rising edge
LVD wakeup
WAKEUP pin rising edge or
External reset (nRST)
(2)
(2)
(2)
the LVDEWEN and LVDEN bits in the LVDCSR register must be set to 1 to make sure that the system
can be waked up by a LVD event and then the LDO regulator can be turned on when system is woken
up from the Deep-Sleep2 and Power-Down modes.
or
or
or
Mode Exit
(1)
or
Power Control Unit (PWRCU)
Deep-Sleep Mode
To enter Deep-Sleep mode, configure the registers as shown in the preceding table and execute
the WFI or WFE instruction. In the Deep-Sleep mode, all clocks including PLL and high speed
oscillator, known as HSI and HSE, will be stopped. In addition, Deep-Sleep1 turns the LDO into
low current mode while Deep-Sleep2 turns off the LDO and uses a DMOS to keep 1.5 V power.
Once the PWRCU receives a wakeup event or an interrupt as shown in the preceding Mode-Exiting
table, the LDO will then operate in normal mode and the high speed oscillator will be enabled.
Finally, the CPU will return to Run mode to handle the wakeup interrupt if required. A Low
Voltage Detection also can be regarded as a wakeup event if the corresponding wakeup control bit
LVDEWEN in the LVDCSR register is enabled. The last wakeup event is a transition from low to
high on the external WAKEUP pin sent to the PWRCU to resume from Deep-Sleep mode. During
the Deep-Sleep mode, retaining the register and memory contents will shorten the wakeup latency.
Rev. 1.1061 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Power-Down Mode
The Power-Down mode is derived from the Deep-Sleep mode of the CPU together with the
additional control bits LDOOFF and DMOSON. To enter the Power-Down mode, users can
congure the registers shown in the preceding Mode-Entering table and execute the WFI or WFE
instruction. A LVD wakeup, a low to high transition on the external WAKEUP pin or an external
reset (nRST) signal will force the MCU out of the Power-Down mode. In the Power-Down mode,
the 1.5 V power supply will be turned off. The remaining active power supplies are the 3.3 V power
(VDD/V
DDA
).
After a system reset, the PORSTF bit in the GRSR register in the Reset Control Unit, RSTCU, the
PDF and PORF bits in the PWRSR register should be checked by software to conrm if the device
is being resumed from the Power-Down mode, an power on reset or other reset events (nRST, WDT,
…). If the device has entered the Power-Down mode under the correct rmware procedure, then the
PDF bit will be set. The system information could be saved in the VDD power domain registers and
be retrieved when the 1.5 V power domain is powered on again. More information about the PDF
and PORF bits in the PWRSR register and PORSTF bit in the RSTCU GRSR register is shown in
the following table.
Power Control Unit (PWRCU)
Table 13. Power Status After System Reset
PORFPDFPORSTFDescription
101
001
011Restart from the Power-Down mode.
11xReserved
Register Map
The following table shows the PWRCU registers and reset values. Note all the registers in this unit
are located in the V
Table 14. PWRCU Register Map
RegisterOffsetDescriptionReset Value
PWRSR0x100Power Control Status Register0x0000_0001
PWRCR0x104Power Control Register0x0000_0000
PWRTEST 0x108VDD Power Domain Test Register0x0000_0027
LVDCSR0x110Low Voltage/Brown Out Detect Control and Status Register 0x0000_0000
power domain.
DD
Power-up for the rst time after the VDD power domain is reset:
Power on reset when VDD is applied for the rst time or executing
software reset command on the VDD domain.
Restart from unexpected loss of the 1.5 V power or other reset
(nRST, WDT, …)
Rev. 1.1062 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Register Descriptions
Power Control Status Register – PWRSR
This register indicates the power control status.
Offset:0x100
Reset value: 0x0000_0001 (Reset only by VDD domain power on reset)
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
ReservedWUPF
Type/ResetRC 0
76543210
ReservedPDFPORF
Type/ResetRC 0 RC 1
BitsFieldDescriptions
[8]WUPFExternal WAKEUP Pin Flag
0: The Wakeup pin is not asserted
1: The Wakeup pin is asserted
This bit is set by hardware when the WAKEUP pin asserts and is cleared by software
read. Software should read this bit to clear it after a system wake up from the power
saving mode.
[1]PDFPower Down Flag
0: Wakeup from abnormal V
1: Wakeup from Power-Down mode. The loss of V
This bit is set by hardware when the system has successfully entered the PowerDown mode. This bit is cleared by software read.
[0]PORFPower On Reset Flag
0: VDD Power Domain reset does not occur
1: VDD Power Domain reset occurs
This bit is set by hardware when VDD power on reset occurs, either a hardware
power on reset or software reset. The bit is cleared by software read. This bit must
be cleared after the system is first powered on, otherwise it will be impossible to
detect when a VDD Power Domain reset has been triggered. When this bit is read
as 1, a read software loop must be implemented until the bit returns again to 0.
This software loop is necessary to conrm that the VDD Power Domain is ready for
access.
shutdown (Loss of V
DD15
is unexpected)
DD15
is under expectation.
DD15
Power Control Unit (PWRCU)
Rev. 1.1063 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Power Control Register – PWRCR
This register provides power control bits for the different kinds of power saving modes.
Offset:0x104
Reset value: 0x0000_0000 (Reset only by VDD domain power on reset)
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
DMOSSTSReserved V15RDYSCReservedWUPIENWUPEN
Type/ResetRO 0RW 0RW 0 RW 0
76543210
DMOSONReservedLDOOFFLDOLCMReservedPWRST
Type/ResetRW 0RW 0 RW 0WO 0
Power Control Unit (PWRCU)
BitsFieldDescriptions
[15]DMOSSTSDepletion MOS Status
This bit is set to 1 if the DMOSON bit in this register has been set to 1.
This bit is cleared to 0 if the DMOSON bit has been set to 0 or if a POR/PDR reset
occurred.
[12]V15RDYSC V
[9]WUPIENExternal WAKEUP Pin Interrupt Enable
Ready Source Selection.
DD15
0: VDDISO bit in the LPCR register located in the CKCU
1: V
POR
DD15
Setting this bit to determine what control signal of isolation cells is used to disable
the isolation function of the V
to VDD power domain level shifter.
DD15
0: Disable WAKEUP pin interrupt function
1: Enable WAKEUP pin interrupt function
The software can set the WUPIEN bit to 1 to assert the LPWUP interrupt in the NVIC
unit when both the WUPEN and WUPF bits are set to1.
The Software can set the WUPEN bit as 1 to enable the WAKEUP pin function
before entering the power saving mode. When WUPEN = 1, a rising edge on the
WAKEUP pin wakes up the system from the power saving mode. As the WAKEUP
pin is active high, this bit will set an input pull down mode when the bit is high. The
WAKEUP pin alternate function should rst be selected by conguring the PBCFG12
bit eld in the GPBCFGHR register to 0x0F before the WAKEUP pin is used. The
corresponding pull-up function on the WAKEUP pin should also be disabled by
clearing the PBPU[12] bit in the PBPUR register to 0 while the pull-down function
should be enabled by setting the PBPD[12] bit in the PBPDR register to 1.
Note: This bit is reset by a VDD Power Domain reset. Because this bit is located in
the VDD Power Domain, after reset activity there will be a delay until the bit is
active. The bit will not be active until the system reset nished and the VDD
Power Domain ISO signal has been disabled. This means that the bit cannot
be immediately set by software after a system reset finished and the VDD
Power Domain ISO signal disabled. The necessary delay time is a minimum
of three 32kHz clock periods until the bit reset activity has nished.
[7]DMOSONDMOS Control
0: DMOS is OFF
1: DMOS is ON
A DMOS is implemented to provide an alternative voltage source for the 1.5 V power
domain when the CPU enters the Deep-Sleep mode (SLEEPDEEP = 1). The control
bit DMOSON is set by software and cleared by software or VDD power domain reset.
If the DMOSON bit is set to 1, the LDO will automatically be turned off when the
CPU enters the Deep-Sleep mode.
[3]LDOOFFLDO Operating Mode Control
0: The LDO operates in a low current mode when CPU enters the Deep-Sleep
mode (SLEEPDEEP = 1). The V
1: The LDO is turned off when the CPU enters the Deep-Sleep mode
(SLEEPDEEP=1). The V
Note: This bit is only available when the DMOSON bit is cleared to 0.
[2]LDOLCMLDO Low Current Mode
0: The LDO is operated in normal current mode
1: The LDO is operated in low current mode
Note: This bit is only available when CPU is in the run mode. The LDO output
current capability will be limited at 10mA below and lower static current when
the LDOLCM bit is set. It is suitable for CPU is operated at lower speed
system clock to get a lower current consumption. This bit will be clear to 0
when the LDO is power down or VDD power domain reset.
[0]PWRSTVDD Power Domain Software Reset
0: No action
1: VDD Power Domain Software Reset is activated
It will reset the PWRCU registers.
DD15
power is available.
DD15
power is not available.
Power Control Unit (PWRCU)
Rev. 1.1065 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
V
Power Domain Test Register – PWRTEST
DD
This register species a read-only value for the software to recognize whether VDD Power Domain is ready for
access.
Offset:0x108
Reset value: 0x0000_0027
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
PWRTEST
Type/ResetRO 0 RO 0 RO 1 RO 0 RO 0 RO 1 RO 1 RO 1
BitsFieldDescriptions
[7:0]PWRTESTVDD Power Domain Test Bits
A constant 0x27 will be read when the VDD Power Domain is ready for CPU access.
Power Control Unit (PWRCU)
Rev. 1.1066 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Low Voltage / Brown Out Detect Control and Status Register – LVDCSR
This register species ags, enable bits and option bits for low voltage detector.
Offset:0x110
Reset value: 0x0000_0000 (Reset only by VDD domain power on reset)
0: LVD event wakeup is disabled
1: LVD event wakeup is enabled
Setting this bit to 1 will enable the LVD event wakeup function to wake up the
system when a LVD condition occurs which result in the LVDF bit being asserted. If
the system requires to be waked up from the Deep-Sleep or Power-Down mode by
a LVD condition, this bit must be set to 1.
[20]LVDIWENLVD Interrupt Wakeup Enable
0: LVD interrupt wakeup is disabled
1: LVD interrupt wakeup is enabled
Setting this bit to 1 will enable the LVD interrupt function. When a LVD condition
occurs and the LVDIWEN bit is set to 1, a LVD interrupt will be generated and sent
to the CPU NVIC unit.
[19]LVDFLow Voltage Detect Status Flag
0: VDD is higher than the specic voltage level
1: VDD is equal to or lower than the specic voltage level
When the LVD condition occurs, the LVDF ag will be asserted. When the LVDF ag
is asserted, a LVD interrupt will be generated for CPU if the LVDIWEN bit is set to 1.
However, if the LVDEWEN bit is set to 1 and the LVDIWEN bit is cleared to 0, only
a LVD event will be generated rather than a LVD interrupt when the LVDF ag is
asserted.
[22], [18:17] LVDS [2:0]Low Voltage Detect Level Selection
For more details concerning the LVD programmable threshold voltage, refer to the
electrical characteristics of the corresponding datasheet.
Rev. 1.1067 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
BitsFieldDescriptions
[16]LVDENLow Voltage Detect Enable
0: Disable Low Voltage Detect
1: Enable Low Voltage Detect
Setting this bit to 1 will generate a LVD event when the VDD power is lower than
the voltage set by LVDS bits. Therefore when the LVD function is enabled before
the system is into the Deep-Sleep2 (DMOS is turn on and LDO is power down) or
Power-Down mode (DMOS and LDO is power down), the LVDEWEN bit has to
be enabled to avoid the LDO does not activate in the meantime when the CPU is
woken up by the low voltage detection activity.
[3]BODFBrow Out Detect Flag
0: VDD > V
1: VDD ≤ V
[1]BODRISBOD Reset or Interrupt Selection
0: Reset the whole chip
1: Generate Interrupt
[0]BODENBrown Out Detector Enable
0: Disable Brown Out Detector
1: Enable Brown Out Detector
BOD
BOD
Power Control Unit (PWRCU)
Rev. 1.1068 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
6
Clock Control Unit (CKCU)
Introduction
The Clock Control unit (CKCU) provides functions of high speed internal RC oscillator (HSI),
High speed external crystal oscillator (HSE), Low speed internal RC oscillator (LSI), Phase Lock
Loop (PLL), HSE clock monitor, clock prescaler, clock multiplexer and clock gating. The clock of
AHB, APB, and CPU are derived from system clock (CK_SYS) which can come from HSI, HSE,
LSI or PLL. The Watchdog Timer uses the LSI as the clock source.
A variety of internal clocks can also be wired out through the CKOUT pin for debugging purpose.
The clock monitor can be used to detect the HSE clock failure. Once the HSE clock does not
normally function, which could be broken down or removed, etc., the CKCU will force to switch
the system clock source to the HSI clock to prevent system halt.
Clock Control Unit (CKCU)
Rev. 1.1069 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
SPI, USART, UART,
HT32F52220/HT32F52230
8 MHz
HSI RC
HSIEN
4-16 MHz
HSE XTAL
HSEEN
Reserved
32 kHz
LSI RC
(Note1)
LSIEN
CKOUTSRC[2:0]
CKOUT
Legend:
HSE = High Speed External clock
HSI = High Speed Internal clock
LSI = Low Speed Internal clock
PLLSRC
1
0
CK_HSI
CK_HSE
CK_LSI
000
001
010
011
100
101
110
PLLEN
PLL
WDTSRC
1
0
CK_REF
HCLKC/16
CK_SYS/16
CK_HSE/16
CK_HSI/16
Reserved
CK_LSI
CK_PLL
WDTEN
CKREFEN
f
= 40 MHz (Recommended)
CK_PLL,max
SW[2:0]
00x
f
CK_SYS,max
011
CK_SYS
010
111
110
Clock
Monitor
CK_WDT
= 40 MHz
AHB Prescaler
1,2,4,8,16,32
CKREFPRE
CM0PEN
CK_AHB
FMCEN
CM0PEN
SRAMEN
CM0PEN
BMEN
CM0PEN
APBEN
Prescaler
1 ~ 32
Peripherals
Prescaler
ADCEN
GPIOAEN
GPIOBEN
CM0PEN
(control by HW)
Clock
1,2,4,8
PCLK
PCLK/2
PCLK/4
PCLK/8
Divider
2
8
00
01
10
11
Prescaler
1,2,3,4,8...
ADC
SPIEN
EXTIEN
CK_REF
STCLK
(to SysTick)
CK_GPIO
( to GPIO port)
FCLK
( Free running clock)
HCLKC
®
( to Cortex
-M0+)
HCLKF
( to Flash)
HCLKS
( to SRAM)
HCLKBM
( to Bus Matrix)
HCLKAPB
( to APB Bridge)
PCLK ( AFIO, ADC,
I2C, GPTM, BFTM,
EXTI, WDT)
CK_ADC IP
Clock Control Unit (CKCU)
Figure 13. CKCU Block Diagram
Rev. 1.1070 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Features
▄
4 ~ 16 MHz external crystal oscillator (HSE)
▄
Internal 8 MHz RC oscillator (HSI) with conguration option calibration and custom trimming
capability.
▄
PLL with selectable clock source (from HSE or HSI) for system clock.
▄
Internal 32 kHz RC oscillator (LSI) for Watchdog Timer or system clock.
▄
HSE clock monitor
Function Descriptions
High Speed External Crystal Oscillator – HSE
The high speed external crystal oscillator (HSE) with a frequency range from 4MHz to 16MHz
produces a highly accurate clock source to the system clock. The related hardware conguration is
shown in the following gure. The crystal with specic frequency must be placed across the two
HSE pins (XTALIN / XTALOUT) and the external components such as resistors and capacitors are
necessary to make it oscillate properly.
Clock Control Unit (CKCU)
The following guidelines are provided to improve the stability of the crystal circuit PCB layout.
▄
The crystal oscillator should be located as close as possible to the MCU so that the trace lengths
are kept as short as possible to reduce any parasitic capacitances.
▄
Shield any lines in the vicinity of the crystal by using a ground plane to isolate signals and
reduce noise.
▄
Keep frequently switching signal lines away from the crystal area to prevent crosstalk.
OSC_EN
XTALOUTXTALIN
Rext
Crystal
4 MHz ~ 16 MHz
CL1CL2
Figure 14. External Crystal, Ceramic, and Resonators for HSE
Rev. 1.1071 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
The HSE crystal oscillator can be switched on or off using the HSEEN bit in the Global Clock
Control Register (GCCR). The HSERDY f lag in the Global Clock Status Register (GCSR) will
indicate if the high-speed external crystal oscillator is stable. When switching on the HSE
oscillator, the HSE clock will still not be released until this HSERDY bit is set by the hardware. The
specic delay period is well-known as “Start-up time”. As the HSE becomes stable, an interrupt
will be generated if the related interrupt enable bit, HSERDYIE, in the Global Clock Interrupt
Register (GCIR) is set. The HSE clock can then be used directly as the system clock source or be
used as the PLL input clock.
High Speed Internal RC Oscillator – HSI
The high speed internal 8 MHz RC oscillator (HSI) is the default selection of the clock source for
the CPU when the device is powered up. The HSI RC oscillator provides a clock source in a lower
cost because no external components are required. The HSI RC oscillator can be switched on or off
using the HSIEN bit in the Global Clock Control Register (GCCR). The HSIRDY ag in the Global
Clock Status Register (GCSR) will indicate if the internal RC oscillator is stable. The start-up time
of the HSI oscillator is shorter than the HSE crystal oscillator. An interrupt can be generated if the
related interrupt enable bit, HSIRDYIE, in the Global Clock Interrupt Register (GCIR) is set as the
HSI becomes stable. The HSI clock can also be used as the PLL input clock.
Clock Control Unit (CKCU)
The frequency accuracy of the high speed internal RC oscillator, HSI, can be calibrated via
the trimming operations. However, it is still less accurate than the HSE crystal oscillator. The
considerations of the applications, environments and cost will determine the selection of the
oscillators.
The software program could congure the PSRCEN bit (Power Saving Wakeup RC Clock Enable)
to 1 to force the HSI clock to be the system clock when wake-up from the Deep-Sleep or Power-
Down mode. Subsequently, the system clock is switched back to the original clock source (HSE or
PLL) if the original clock source ready ag is asserted. This function can reduce the wakeup time
when using the HSE or PLL output clock as the system clock.
Rev. 1.1072 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Phase Locked Loop – PLL
This PLL can provide 4 ~ 48 MHz clock output which is 1~12 multiples of a fundamental reference
frequency of 4 ~ 16 MHz. The rationale of the clock synthesizer relies on the digital Phase Locked
Loop (PLL) which includes a reference divider, a feedback divider, a digital phase frequency
detector (PFD), a current-controlled charge pump, a built-in loop filter and a voltage-controlled
oscillator (VCO) to achieve a stable phase-locked state.
VCO
= 48 ~ 96 MHz
out
Clock Control Unit (CKCU)
CLK
in
Ref. Divider
(NR)
/2
PDCP
Feedback Divider 2
(NF2)
B3~B0
Figure 15. PLL Block Diagram
The frequency of the PLL output clock can be determined by the following formula:
Considering the duty cycle of 50%, both input and output frequencies are divided by 2. If a
given CLKin frequency used as the PLL input generates a specific PLL output frequency, it is
recommended to load a larger value into the NF2 eld to increase the PLL stability and reduce
the jitter with expense of the settling time. The output and feedback divider 2 setup values are
described in Table 15 and Table 16. All the conguration bits (S1 ~ S0, B3 ~ B0) in Table 15 and
Table 16 are defined in the PLL Configuration Register (PLLCFGR) and PLL Control Register
(PLLCR) in the section of Register Denition. Note that the VCO
range from 48 MHz to 96 MHz. If the selected conguration exceeds this range, the PLL output
frequency will not be guaranteed to match the above PLL
VCO
Loop
Filter
Feedback Divider 1
(NF1)
/4
NF1×NF2
NR×NO1×NO2
Output Divider 1
(NO1)
/2
= CLKin×= CLKin×
4×NF2
2×2×NO2
formula.
OUT
Output Divider 2
frequency should be in the
OUT
(NO2)
S1~S0
NF2
NO2
PLL
out
= 4 ~ 48 MHz
The PLL can be switched on or off using the PLLEN bit in the Global Clock Control Register
(GCCR). The PLLRDY ag in the Global Clock Status Register (GCSR) will indicate if the PLL
clock is stable. An interrupt can be generated if the related interrupt enable bit PLLRDYIE in the
Global Clock Interrupt Register (GCIR) is set as the PLL becomes stable.
Rev. 1.1073 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Table 15. Output Divider2 Value Mapping
Output divider 2 setup bits S[1:0]
(POTD bits in the PLLCFGR register)
Table 16. Feedback Divider2 Value Mapping
Feedback divider2 setup bits B[3:0]
(PFBD bits in the PLLCFGR register)
NO2 (Output divider 2 value)
001
012
104
118
NF2 (Feedback divider 2 value)
000016
00011
00102
00113
01004
01015
01106
01117
10008
10019
101010
101111
110012
:
:
111115
Clock Control Unit (CKCU)
:
:
Low Speed Internal RC Oscillator – LSI
The low speed internal RC oscillator with a frequency of about 32 kHz produces a low power clock
source for the Watchdog Timer or system clock. The LSI oscillator offers a low cost clock source
because no external component is required to make it oscillates. The LSI RC oscillator is always
enable. The LSI frequency accuracy is shown in the datasheet. The LSIRDY flag in the Global
Clock Status Register (GCSR) will indicate if the LSI clock is stable. An interrupt can be generated
if the related interrupt enable bit LSIRDYIE in the Global Clock Interrupt Register (GCIR) is set as
the LSI becomes stable.
Clock Ready Flag
The CKCU provides the corresponding clock ready ags for the HSI, HSE, PLL and LSI oscillators
to indicate whether these clocks are stable. Before using them as the system clock source or other
purpose, it is necessary to confirm the specific clock ready flag is set. Software can check the
specific clock is ready or not by polling the corresponding clock ready status bits in the GCSR
register. Additionally, the CKCU can trigger an interrupt to notify that the specic clock is ready
if the corresponding interrupt enable bit in the GCIR register is set. Software should clear the
interrupt status bit in the GCIR register in the interrupt service routine.
Rev. 1.1074 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
System Clock (CK_SYS) Selection
After the system reset occurs, the default system clock source, CK_SYS, will be the high speed
internal RC oscillator, HSI. The CK_SYS may come from the HSI, HSE, LSI or PLL output clock
and it can be switched from one clock source to another by conguring the System Clock Switch
bits SW in the Global Clock Control Register, GCCR. The system will still run under the original
clock until the destination clock gets ready when the SW value is changed. The corresponding
clock ready status bits in the Global Clock Status Register GCSR will indicate whether the selected
clock is ready to use or not. The CKCU also contains the clock source status bits in the Clock
Source Status Register CKST to indicate which clock is currently used as the system clock. If a
clock source or the PLL output clock is used as the system clock source, it is not possible to stop it.
More details about the clock enable function are described in the following .
If any event in the following occurs, the HSI will be enabled .
▄
Enable PLL and congure its source clock to HSI. (PLLEN, PLLSRC)
▄
Enable Clock monitor. (CKMEN)
▄
Congure clock switch register to HSI. (SW)
▄
Congure HSI enable register to 1. (HSIEN)
Clock Control Unit (CKCU)
If any event in the following occurs, the HSE will be enabled.
▄
Enable PLL and congure its source clock to HSE. (PLLEN, PLLSRC)
▄
Congure clock switch register to HSE. (SW)
▄
Congure HSE enable register to 1. (HSEEN)
If any event in the following occurs, the PLL will be enabled.
▄
Enable USB Enable register. (USBEN)
▄
Congure clock switch register to PLL (SW)
▄
Congure PLL enable register to 1. (PLLEN)
The system clock selection programming guide is listed in the following.
1. Enable any clock source which will become the system clock or PLL input clock.
2. Conguring the PLLSRC register will has no operation until the ready ags of both HSI and
HSE are asserted.
3. Configuring the SW register to change the system clock source will take effect after the
corresponding ready flag of the clock source is asserted. Note that the system clock will be
forced to HSI if the clock monitor is enabled and the PLL output clock or HSE clock congured
as the system clock is stuck at 0 or 1.
Rev. 1.1075 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
HSE Clock Monitor
The HSE Clock Monitor main function is enabled by the HSE Clock Monitor Enable bit CKMEN
in the Global Clock Control Register, GCCR. The HSE clock monitor function should be enabled
after the HSE oscillator start-up delay and disabled when the HSE oscillator is stopped. Once the
HSE oscillator failure is detected, the HSE oscillator will automatically be disabled. The HSE clock
stuck ag CKSF in the Global Clock Interrupt Register GCIR will be set and the HSE oscillator
failure interrupt will be generated if the clock failure interrupt enable bit CKSIE in the GCIR is
set. This failure interrupt is connected to the CPU Non-Maskable Interrupt, NMI. When the HSE
oscillator failure occurs, the HSE will be turned off and the system clock will be switched to the
HSI automatically by the hardware. If the HSE is used as the clock input of the PLL circuit and the
PLL output clock is used as the system clock, the PLL circuit will also be turned off as well as the
HSE when the failure happens.
Clock Output Capability
The device has the clock output capability to allow the clocks to be output on the specic external
output pin CKOUT. The configuration registers of the corresponding GPIO port must be well
configured in the Alternate Function I/O, AFIO, section to output the selected clock signal.
There are six output clock signals to be selected via the device clock output source selection bits
CKOUTSRC in the Global Clock Conguration Register, GCFGR.
Clock Control Unit (CKCU)
Table 17. CKOUT Clock Source
CKOUTSRC[2:0]Clock Source
000CK_REF = CK_PLL / (CKREFPRE + 1) / 2
001CK_AHB / 16
010CK_SYS / 16
011CK_HSE / 16
100CK_HSI / 16
101Reserved
110CK_LSI
Rev. 1.1076 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Register Map
The following table shows the CKCU register and reset value.
MCUDBGCR 0x304MCU Debug Control Register0x0000_0000
Clock Control Unit (CKCU)
Rev. 1.1077 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Register Descriptions
Global Clock Conguration Register – GCFGR
This register species the clock source for the PLL/USART/Watchdog Timer/CKOUT.
Offset:0x000
Reset value: 0x0000_0102
3130292827262524
LPMODReserved
Type/ResetRO 0 RO 0 RO 0
2322212019181716
Reserved
Type/Reset
15141312111098
CKREFPRE
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0RW 1
76543210
Reserved
Type/ResetRW 0 RW 1 RW 0
ReservedPLLSRC
CKOUTSRC
BitsFieldDescriptions
[31:29]LPMODLower Power Mode Status
000: When Chip is in running mode
001: When Chip wants to enter Sleep mode
010: When Chip wants to enter Deep Sleep mode1
011: When Chip wants to enter Deep Sleep mode2
100: When Chip wants to enter Power Down mode
Others: Reserved
Set and reset by software to control the PLL clock source.
Clock Control Unit (CKCU)
Rev. 1.1078 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
BitsFieldDescriptions
[2:0]CKOUTSRC CKOUT Clock Source Selection
000: CK_REF is selected
where CK_REF = CK_PLL / (CKREFPRE+1) / 2
001: (HCLKC / 16) is selected
010: (CK_SYS / 16) is selected
011: (CK_HSE / 16) is selected
100: (CK_HSI / 16) is selected
101: Reserved
110: CK_LSI is selected
111: Reserved
Set and reset by software.
Clock Control Unit (CKCU)
Rev. 1.1079 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Global Clock Control Register – GCCR
This register species the clock enable bits.
Offset:0x004
Reset value: 0x0000_0803
3130292827262524
Reserved
Type/Reset
2322212019181716
ReservedPSRCENCKMEN
Type/ResetRW 0 RW 0
15141312111098
ReservedHSIENHSEENPLLENHSEGAIN
Type/ResetRW 1 RW 0 RW 0 RW 0
76543210
ReservedSW
Type/ResetRW 0 RW 1 RW 1
Clock Control Unit (CKCU)
BitsFieldDescriptions
[17]PSRCENPower Saving Wakeup RC Clock Enable
0: No action
1: Use Internal 8 MHz RC clock (HSI) as system clock after power down wakeup.
The software can set the PSRCEN bit high before entering the power saving mode
in order to reduce the waiting time after a wakeup. When the PSRCEN bit is set to
1, the HSI will be used as the CK_SYS clock source after waking up from the power
saving mode. This means that the instruction can be executed early before the
original clock CK_SYS source is stable since the HSI clock is provided to CPU. After
the original CK_SYS clock source is ready, the CK_SYS clock will automatically be
switched back to the original selected clock source from the HSI clock.
When the hardware detects that the HSE clock is stuck at a low or high state, the
internal hardware will switch the system clock to the internal high speed RC clock,
HSI.
[11]HSIENInternal High Speed Oscillator Enable
0: Internal 8 MHz RC oscillator is disabled
1: Internal 8 MHz RC oscillator is enabled
Set and reset by software. This bit can not be reset if the HSI clock is used as
system clock.
[10]HSEENExternal High Speed Oscillator Enable
0: External 4 ~ 16 MHz crystal oscillator is disabled
1: External 4 ~ 16 MHz crystal oscillator is enabled
Set and reset by software. This bit can not be reset if the HSE clock is used as the
system clock or the PLL input clock.
Rev. 1.1080 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
BitsFieldDescriptions
[9]PLLENPLL Enable
0: PLL is disabled
1: PLL is enabled
Set and reset by software. This bit cannot be reset if the PLL clock is used as the
system clock.
[8]HSEGAINExternal High Speed Oscillator Gain Selection
0: HSE is in low gain mode
1: HSE is in high gain mode
[2:0]SWSystem Clock Switch
00x: CK_PLL clock out as system clock
010: CK_HSE as system clock
011: CK_HSI as system clock
110: Reserved
111: CK_LSI as system clock
Other: CK_HSI as system clock
These bits are set and reset by software and used to select the CK_SYS source.
When switching the system clock using the SW bits, the system clock will not be
immediately switched and a certain delay is necessary. The system clock source
selected by the SW bits can be indicated in the CKSWST bits in the clock source
status register CKST to make sure which clock is currently used as the system
clock.
Note that the HSI oscillator will be forced as the system clock when the HSE clock
failure is detected as the HSE clock monitor function is enabled.
Clock Control Unit (CKCU)
Rev. 1.1081 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Global Clock Status Register – GCSR
This register indicates the clock ready status.
Offset:0x008
Reset value: 0x0000_0028
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedLSIRDYReservedHSIRDYHSERDYPLLRDYReserved
Type/ResetRO 1RO 1 RO 0 RO 0
Clock Control Unit (CKCU)
BitsFieldDescriptions
[5]LSIRDYInternal Low Speed Oscillator Ready Flag
0: Internal 32 kHz RC oscillator is not ready
1: Internal 32 kHz RC oscillator is ready
Set by hardware to indicate whether the LSI oscillator is stable to be used.
[3]HSIRDYInternal High Speed Oscillator Ready Flag
0: Internal 8 MHz RC oscillator is not ready
1: Internal 8 MHz RC oscillator is ready
Set by hardware to indicate whether the HSI oscillator is stable to be used.
[2]HSERDYExternal High Speed Oscillator Ready Flag
0: External 4 ~ 16 MHz crystal oscillator is not ready
1: External 4 ~ 16 MHz crystal oscillator is ready
Set by hardware to indicate whether the HSE oscillator is stable to be used.
[1]PLLRDYPLL Clock Ready Flag
0: PLL is not ready
1: PLL is ready
Set by hardware to indicate whether the PLL output clock is stable to be used.
Rev. 1.1082 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Global Clock Interrupt Register – GCIR
This register species the interrupt enable and ag bits.
0: SCTM1 counter continues to count even if the core is halted
1: SCTM1 counter stops counting when the core is halted
Set and reset by software.
[22]DBSCTM0SCTM0 Debug Mode Enable
0: SCTM0 counter continues to count even if the core is halted
1: SCTM0 counter stops counting when the core is halted
Set and reset by software.
[18]DBURUART Debug Mode Enable
0: Same behavior as in normal mode
1: UART FIFO timeout is frozen when the core is halted
Set and reset by software.
[16]DBBFTMBFTM Debug Mode Enable
0: BFTM counter continues to count even if the core is halted
1: BFTM counter stops counting when the core is halted
Set and reset by software.
[14]DBDSLP2Debug Deep-Sleep2
0: LDO = Off (but turn on DMOS), FCLK = Off, and HCLK = Off in Deep-Sleep2
1: LDO = On, FCLK = On, and HCLK = On in Deep-Sleep2
Set and reset by software.
[12]DBI2CI2C Debug Mode Enable
0: Same behavior as in normal mode
1: I2C timeout is frozen when the core is halted
Set and reset by software.
[10]DBSPISPI Debug Mode Enable
0: Same behavior as in normal mode
1: SPI FIFO timeout is frozen when the core is halted
Set and reset by software.
Rev. 1.1096 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
BitsFieldDescriptions
[8]DBUSRUSART Debug Mode Enable
0: Same behavior as in normal mode
1: USART FIFO timeout is frozen when the core is halted
Set and reset by software.
[6]DBGPTMGPTM Debug Mode Enable
0: GPTM counter continues to count even if the core is halted
1: GPTM counter stops counting when the core is halted
Set and reset by software.
[3]DBWDTWatchdog Timer Debug Mode Enable
0: Watchdog Timer counter continues to count even if the core is halted
1: Watchdog Timer counter stops counting when the core is halted
Set and reset by software.
[2]DBPDDebug Power-Down Mode
0: LDO = Off, FCLK = Off, and HCLK = Off in Power-Down mode
1: LDO = On, FCLK = On, and HCLK = On in Power-Down mode
Set and reset by software.
[1]DBDSLP1Debug Deep-Sleep1
0: LDO = Low power mode, FCLK = Off, and HCLK = Off in Deep-Sleep1
1: LDO = On, FCLK = On, and HCLK = On in Deep-Sleep1
Set and reset by software.
[0]DBSLPDebug Sleep Mode
0: LDO = On, FCLK = On, and HCLK = Off in Sleep mode
1: LDO = On, FCLK = On, and HCLK = On in Sleep mode
Set and reset by software.
Clock Control Unit (CKCU)
Rev. 1.1097 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
7
Reset Control Unit (RSTCU)
Introduction
The Reset Control Unit, RSTCU, has three kinds of reset, the power on reset, system reset and
APB unit reset. The power on reset, known as a cold reset, resets the full system during a power
up. A system reset resets the processor core and peripheral IP components with the exception of
the debug port controller. The resets can be triggered by an external signal, internal events and the
reset generators. More information about these resets will be described in the following section.
V
DD15
1.5 V Core
Brown Out
Detector
RESET
VDDDomain
POR
POR15
BODRST
V
DD
nRST
V
Power POR
DD
WDTRST
SYSRESETREQ
POR
Generator
RSTCU
Filter
Filter
Filter
WDT_RSTn
Filter
PWRST
Reset
Reset Control Unit (RSTCU)
®
-M0+
Cortex
PORRESETn
Delay
----
PWRCU reset
WDT reset
SYSRESETREQ
SYSRESETn
PORRESETn
NVIC
SYSRESETREQ
HRESETnCORERESTn
HRESETn
CM0+ Core
System Components
(BusMatrix, PMU)
System Debug
Components
USARTRST
Reset
Generator
Figure 16. RSTCU Block Diagram
USART reset
Rev. 1.1098 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Functional Descriptions
Power On Reset
The Power on reset, POR, is generated by either an external reset or the internal reset generator.
Both types have an internal lter to prevent glitches from causing erroneous reset operations. By
referring to Figure 17, the POR15 active low signal will be de-asserted when the internal LDO
voltage regulator is ready to provide 1.5 V power. In addition to the POR15 signal, the Power
Control Unit, PWRCU, will assert the BODF signal as a Power Down Reset, PDR, when the
BODEN bit in the LVDCSR register is set and the brown-out event occurs. For more details about
the PWRCU function, refer to the PWRCU chapter.
V
DD
V
DD15
Reset Control Unit (RSTCU)
t
1
PORESTn
SYSRESTn
* This timing is dependent on the internal LDO regulator output capacitor value.
Figure 17. Power On Reset Sequence
System Reset
A system reset is generated by a power on reset (PORRESETn), a Watchdog Timer reset (WDT_
RSTn), nRST pin or a software reset (SYSRESETREQ) event. For more information about
SYSRESETREQ event, refer to the related chapter in the Cortex®-M0+ reference manual.
AHB and APB Unit Reset
The AHB and APB unit reset can be divided into hardware and software resets. A hardware
reset can be generated by either power on reset or system reset for all AHB and APB units.
Each functional IP connected to the AHB and APB buses can be reset individually through the
associated software reset bits in the RSTCU. For example, the application software can generate a
USART reset via the USRRST bit in the APBPRSTR0 register.
t
2
t1= 25us *Typical.
= 100us
t
t
3
2
= 150us
t
3
Rev. 1.1099 of 366November 09, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52220/HT32F52230
Register Map
The following table shows the RSTCU registers and reset values.