Figure 218. CRC Data Bit and Byte Reversal Example ........................................................................ 651
List of Figures
Rev. 1.30 25 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 48 MHz with a Flash accelerator to obtain maximum
efciency. It provides up to 128 KB of embedded Flash memory for code/data storage and 16 KB
of embedded SRAM memory for system operation and application program usage. A variety of
peripherals, such as ADC, I2C, USART, UART, SPI, I2S, GPTM, MCTM, SCI, CRC-16/32, RTC,
WDT, PDMA, EBI, USB2.0 FS, 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.
Introduction
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.
● Translate the AHB transactions into the appropriate external device protocol
● Individual chip select signal for per memory bank
● Programmable timing to support a wide range of devices
● Automatic translation when AHB transaction width and external memory interface width is
different
● Write buffer to decrease the stalling of the AHB write burst transaction
● Support multiplexed and non-multiplexed address and data line congurations
● Multiplexed address and data line congurations
● Up to 21 address lines
● Up to 16-bit data bus width
▄
Universal Serial Bus Device Controller – USB
● Complies with USB 2.0 full-speed (12Mbps) specication
● On-chip USB full-speed transceiver
● 1 control endpoint (EP0) for control transfer
● 3 single-buffered endpoints for bulk and interrupt transfer
● 4 double-buffered endpoints for bulk, interrupt and isochronous transfer
● 1KB EP-SRAM used as the endpoint data buffers
▄
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
● 33-pin QFN, 48/64-pin LQFP package
● Operation temperature range: -40 ˚C to +85 ˚C
Introduction
Rev. 1.30 31 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Device Information
Table 1. Series Features and Peripheral List
PeripheralsHT32F52342HT32F52352
Main Flash (KB)64127.5
Option Bytes Flash (KB)0.50.5
SRAM (KB)816
Timers
Communication
PDMA6 channels
EBI1
CRC-16/321
EXTI16
12-bit ADC
Number of channels
Comparator2
GPIOUp to 51
CPU frequencyUp to 48 MHz
Operating voltage2.0 V ~ 3.6 V
Operating temperature-40 ˚C ~ +85 ˚C
Package33-pin QFN, 48/64-pin LQFP
MCTM1
GPTM2
SCTM2
BFTM2
RTC1
WDT1
USB1
SPI2
USART2
UART2
I2C2
I2S1
SCI (ISO7816-3)2
Introduction
1
12 Channels
Rev. 1.30 32 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Block Diagram
TX, RX
RTS/TXE
CTS/SCK
TX, RX
MCLK, BCLK
WS, SDO, SDI
CH0 ~CH2
CH0N ~ CH2N
CH3, BRK
SCTM
ADC_IN0
ADC_IN11
CN0, CP0
COUT0
CN1, CP1
COUT1
V
DDA
V
SSA
DDA
PA ~ PC[15:0], PD[3:0]
IO Port
GPIO
System
USART0 ~ 1
UART0 ~ 1
UART0
SCTM0 ~ 1
Powered by V
DD15
Bus Matrix
I2S
AFIO
EXTI
MCTM
ADC
CMP
BOOT
AF
Flash Memory
Interface
FMC
PDMA
Control
Control
Registers
Registers
AHB
Peripherals
SRAM
Controller
External Bus
Interafce
AHB to APB
Bridge
APB
CRC
-16/32
Powered by V
Flash
Memory
CKCU/RSTCU
Control Registers
USB
Control/Data
Registers
SRAM
USB
Device
WDT
SPI1 ~ 0
SPI1 ~ 0
I2C0 ~ 1
GPTM0 ~ 1
BFTM0 ~ 1
SCI0 ~ 1
SCI0 ~ 1
RTC
PWRCU
Backup Domain
V
BAK
PORB
BREG
DD15
Clock and reset control
Powered by V
Power control
V
BAK
LSI
32 kHz
LSE
32,768 Hz
AF
X32KIN
X32KOUT
POR
/PDR
HSE
4 ~ 16 MHz
HSI
8 MHz
LDO
1.5 V
BOD
LVD
PLL
f
: 48 MHz
Max
PWRSW
DD
V
DD
V
SS
AF
XTALIN
XTALOUT
CLDO
AD0~AD15
AF
A0~A20
CS0~CS3
OE, WR, ALE
AF
DP
DM
AF
MOSI, MISO
SCK, SEL
AF
SDA
SCL
AF
CH3 ~ CH0
AF
CLK, DIO,
DET
AFAF
RTCOUT
V
BAT
V
DD33
V
SS33
WAKEUP
nRST
Introduction
CAP.
SWCLK SWDIO
AF
SW-DP
Cortex®-M0+
Processor
NVIC
Interrupt request
PDMA
6 Channels
DMA request
AF
AF
AF
AF
...
AFAF
12-bit
SAR ADC
Analog
CMP
Powered by V
Power supply:
Bus:
Control signal:
Alternate funct ion:
AF
Figure 1. Block Diagram
Rev. 1.30 33 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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
RO 0W0C 0
LLRDY
PLLRDYIE
RW 0RW 0
32
HSERDY
RO 1RO 0
10
PDF
BAK_PORF
RC 0RC 1
32
PLLRDYF
WC 0WC 0
10
RXCF
WO 0WO 0
RO 0
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 prex 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).
Specic bits of NAME. NAME can be a register or eld 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 dened 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.30 34 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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.30 35 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
®
-M0+
Cortex
Components
Execution Trace Interface
Cortex®-M0+ Processor
Interrupts
‡ Wakeup
Interrupt
Controller (WIC)
‡ Optional Component
Nested
Vectored
Interrupt
Controller
(NVIC)
Figure 2. Cortex®-M0+ Block Diagram
Cortex®-M0+
Processor
Core
‡ Memory
Protection
Unit
Bus Matrix
AHB-Lite Interface
to System
Debug
‡ Breakpoint
and
Watchpoint
Unit
‡ Debugger
Interface
‡ Single-cycle
I/O Port
System Architecture
‡ Debug
Access Port
(DAP)
‡ Serial Wire or
JTAG Debug Port
Bus Architecture
The HT32F52342/52352 series consist of two masters and ve slaves in the bus architecture. The
Cortex®-M0+ AHB-Lite bus and Peripheral Direct Memory Access (PDMA) are the masters while
the internal SRAM access bus, the internal Flash memory access bus, the AHB peripherals access
bus, External Bus Interface (EBI) 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 HT32F52342/52352 series.
Rev. 1.30 36 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
GPIO
I/O Port
Cortex®-M0+
Processor
System
NVIC
Interrupt request
PDMA
6 Channels
DMA request
Figure 3. Bus Architecture
Flash Memory
Interface
PDMA
Control
Registers
Bus Matrix
FMC
Control
Registers
AHB
Peripherals
GPIO
A~D
CRC
-16/32
SRAM
Controller
Flash
Memory
CKCU/RSTCU
Control Registers
USB
Control/Data
Registers
SRAM
System Architecture
USB
Device
External Bus
Interafce
AHB to APB
Bridge
APB IPs
Memory Organization
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 HT32F52342/52352 series of devices, including Code, SRAM, peripheral, and other pre-dened
regions.
Rev. 1.30 37 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Memory Map
Peripheral
SRAM
Code
0xFFFF_FFFF
0xE010_0000
0xE000_0000
0x7000_0000
0x6000_0000
0x4010_0000
0x4008_0000
0x4000_0000
0x2000_4000
0x2000_0000
0x1FF0_0400
0x1FF0_0000
0x1F00_1000
0x1F00_0000
0x0001_0000
0x0000_0000
Reserved
Private peripheral bus
Reserved
EBI Selection Bank
Reserved
AHB peripherals
APB peripherals
Reserved
16 KB on-chip SRAM
Reserved
Option byte alias
Reserved
Boot loader
Reserved
Up to
128 KB on-chip Flash
64 MB x 4
512 KB
512 KB
16 KB
1 KB
4 KB
Up to
128 KB
0x400F_FFFF
0x400B_8000
0x400B_0000
0x400A_C000
0x400A_8000
0x4009_8000
0x4009_2000
0x4008_C000
0x4007_8000
0x4007_7000
0x4007_6000
0x4007_5000
0x4007_4000
0x4007_0000
0x4006_F000
0x4006_E000
0x4006_B000
0x4006_A000
0x4006_9000
0x4006_8000
0x4005_9000
0x4005_8000
0x4004_A000
0x4004_9000
0x4004_8000
0x4004_5000
0x4004_4000
0x4004_3000
0x4004_2000
0x4004_1000
0x4004_0000
0x4003_B000
0x4003_A000
0x4003_5000
0x4003_4000
0x4002_D000
0x4002_C000
0x4002_7000
0x4002_6000
0x4002_5000
0x4002_4000
0x4002_3000
0x4002_2000
0x4001_1000
0x4001_0000
0x4000_5000
0x4000_4000
0x4000_2000
0x4000_1000
0x4000_0000
Reserved
GPIO A ~ D
Reserved
USB SRAM0x400A_A000
USB
Reserved0x4009_A000
EBI
Reserved
PDMA0x4009_0000
Reserved
CRC0x4008_A000
CKCU/RSTCU0x4008_8000
Reserved0x4008_2000
FMC0x4008_0000
Reserved
BFTM1
BFTM0
Reserved
SCTM1
Reserved
GPTM1
GPTM0
Reserved
RTC & PWRCU
Reserved
WDT
Reserved
CMP
Reserved
I2C1
I2C0
Reserved
SPI1
SCI0
Reserved
UART1
USART1
Reserved
SCI1
Reserved
SCTM0
Reserved
MCTM
Reserved
I2S
Reserved
EXTI
Reserved
AFIO
Reserved
ADC
Reserved
SPI0
Reserved
UART0
USART0
System Architecture
AHB
APB
Figure 4. Memory Map
Rev. 1.30 38 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Table 3. Register Map
Start AddressEnd AddressPeripheralBus
0x4000_00000x4000_0FFFUSART0
0x4000_10000x4000_1FFFUART0
0x4000_20000x4000_3FFFReserved
0x4000_40000x4000_4FFFSPI0
0x4000_50000x4000_FFFFReserved
0x4001_00000x4001_0FFFADC
0x4001_10000x4002_1FFFReserved
0x4002_20000x4002_2FFFAFIO
0x4002_30000x4002_3FFFReserved
0x4002_40000x4002_4FFFEXTI
0x4002_50000x4002_5FFFReserved
0x4002_60000x4002_6FFFI2S
0x4002_70000x4002_BFFFReserved
0x4002_C0000x4002_CFFFMCTM
0x4002_D0000x4003_3FFFReserved
0x4003_40000x4003_4FFFSCTM0
0x4003_50000x4003_9FFFReserved
0x4003_A0000x4003_AFFFSCI1
0x4003_B0000x4003_FFFFReserved
0x4004_00000x4004_0FFFUSART1
0x4004_10000x4004_1FFFUART1
0x4004_20000x4004_2FFFReserved
0x4004_30000x4004_3FFFSCI0
0x4004_40000x4004_4FFFSPI1
0x4004_50000x4004_7FFFReserved
0x4004_80000x4004_8FFFI2C0
0x4004_90000x4004_9FFFI2C1
0x4004_A0000x4005_7FFFReserved
0x4005_80000x4005_8FFFComparator
0x4005_90000x4006_7FFFReserved
0x4006_80000x4006_8FFFWDT
0x4006_90000x4006_9FFFReserved
0x4006_A0000x4006_AFFFRTC/PWRCU
0x4006_B0000x4006_DFFFReserved
0x4006_E0000x4006_EFFFGPTM0
0x4006_F0000x4006_FFFFGPTM1
0x4007_00000x4007_3FFFReserved
0x4007_40000x4007_4FFFSCTM1
0x4007_50000x4007_5FFFReserved
0x4007_60000x4007_6FFFBFTM0
0x4007_70000x4007_7FFFBFTM1
0x4007_80000x4007_FFFFReserved
System Architecture
APB
Rev. 1.30 39 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Start AddressEnd AddressPeripheralBus
0x4008_00000x4008_1FFFFMC
0x4008_20000x4008_7FFFReserved
0x4008_80000x4008_9FFFCKCU/RSTCU
0x4008_A0000x4008_BFFFCRC
0x4008_C0000x4008_FFFFReserved
0x4009_00000x4009_1FFF
0x4009_20000x4009_7FFFReserved
0x4009_80000x4009_9FFFEBI Control Registers
0x4009_A0000x400A_7FFFReserved
0x400A_80000x400A_BFFFUSB
0x400A_C0000x400A_FFFFReserved
0x400B_00000x400B_1FFFGPIOA
0x400B_20000x400B_3FFFGPIOB
0x400B_40000x400B_5FFFGPIOC
0x400B_60000x400B_7FFFGPIOD
0x400B_80000x400F_FFFFReserved
PDMA Control
Registers
System Architecture
AHB
Rev. 1.30 40 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Embedded Flash Memory
The HT32F52342/52352 series provide up to 128 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 128 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 HT32F52342/52352 series contain up to 16 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 up 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.30 41 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
4
Flash Memory Controller (FMC)
Introduction
The Flash Memory Controller (FMC) provides functions of ash operation and pre-fetch buffer
for the embedded on-chip Flash memory. Figure below shows the block diagram of FMC which
includes programming interface, control register, pre-fetch buffer, and access interface. Since the
access speed of Flash memory is slower than the CPU, a wide access interface with pre-fetch buffer
is provided to the Flash memory in order to reduce the wait state (which will cause instruction
gaps) of the CPU. The functions of word program/page erase are also provided for instruction/data
storage of Flash memory.
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 128 KB of on-chip Flash memory for storing instruction/data and options
● 128 KB (instruction/data + Option Byte)
● 64 KB (instruction/data + Option Byte)
▄
Page size of 512 Bytes, totally up to 256 pages depending on the main Flash size
▄
Wide access interface with pre-fetch buffer to reduce instruction gaps
▄
Page erase and mass erase capability
▄
32-bit word programming
▄
Interrupt capability when ready or error occurs
▄
Flash read protection to prevent illegal code/data access
▄
Page erase/program protection to prevent unexpected operation
Rev. 1.30 42 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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_0FFF is
mapped to Boot Loader Block (4 KB). Besides, address 0x1FF0_0000 to 0x1FF0_01FF is the alias
of Option Byte block (0.5 KB) which locates at the last page of main Flash physically. The memory
mapping on system view is shown as below.
0x1FFF_FFFF
0x1FF0_0200
0x1FF0_0000
0x1F00_1000
Reserved
Option Byte
Reserved
Flash Memory Controller (FMC)
0.5 Kbytes
0x1F00_0000
0x0000_0000
Figure 6. Flash Memory Map
Boot Loader Block
Reserved
Main Flash Block
User Application
4 Kbytes
127.5 Kbytes
or
64 Kbytes
Rev. 1.30 43 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Memory Architecture
The Flash memory consists of up to 128 KB main Flash with 512 Bytes per page and 4 KB
Information Block for Boot Loader. The main Flash memory contains totally 256 pages (or 128
pages for 64 KB device) which can be erased individually. The following table shows the base
address, size, and protection setting bit of each page.
When the HCLK clock is greater than access speed of 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 WAIT [2:0] of Flash Cache and Pre-fetch Control Register (CFCR). In order to
t the requirement of wait state, the following two rules shall be considered.
▄
HCLK clock is changed from lower to higher: Change the wait state setting rst and then change
the HCLK clock.
▄
HCLK clock is changed from higher to lower: Change 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 HSI (8 MHz) is selected as HCLK clock source after system reset.
Table 5. Relationship Between Wait State Cycle and HCLK
Wait State CycleHCLK
00 MHz < HCLK <= 24 MHz
124 MHz < HCLK <= 48 MHz
Rev. 1.30 44 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Booting Conguration
The system provides two kinds of booting mode which can be selected through BOOT pin. The
value of BOOT pin is sampled during the power-on reset or system reset. Once the value is decided,
the rst 4 words of vector will be remapped to the corresponding source according to the booting
mode. The booting mode is shown in the following table.
Table 6. Booting Modes
Booting mode selection pin
BOOT
0Boot LoaderThe source of Vector is Boot Loader
1Main FlashThe source of Vector is main Flash
The Vector Mapping Control Register (VMCR) is provided to change the setting of the vector
remapping temporarily after the chip reset. The reset value of VMCR is determined by the value of
BOOT pin which will be sampled during the reset.
ModeDescriptions
Flash Memory Controller (FMC)
Boot Setting
0xC
Hard Fault Handler
0x8
0x4
NMI Handler
Program Counter
Initial Stack Point0x0
Figure 7. Vector Remapping
1 : Main Flash0 : Boot Loader
+ 0xC
+ 0x8
+ 0x4
0x0000 0000
+ 0xC
+ 0x8
+ 0x4
0x1F00 0000
Rev. 1.30 45 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Page Erase
The FMC provides a page erase function which is used to reset partial content of Flash memory.
Any page can be erased independently without affecting others. The following steps show the
access sequence of the register for page erase.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equals to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
Commit page erase command to FMC by setting OPCR register (set OPM [3:0] = 0xA).
▄
Wait until all the operations have been completed by checking the value of OPCR register (OPM
[3:0] equals to 0xE).
▄
Read and verify the page if required.
Note that a correct address of the target page must be conrmed. Software may run away if the
target erase page is being used for fetching code or accessing data and FMC will not notify when
this happens. Besides, the page erase will be ignored on the protected pages. A Flash Operation
Error interrupt will be triggered by FMC if the OREIEN bit in the OIER register is set. Software
can check the PPEF bit in the OISR register to detect this condition in the interrupt handler. The
following gure displays the ow of page erase operation.
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.30 46 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Mass Erase
The FMC provides a complete erase function which is used for resetting all the main Flash memory
content. The following steps show the sequence of the register access for mass erase.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equals to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write mass erase command to OCMR register (CMD [3:0] = 0xA).
▄
Commit mass erase command to FMC by setting OPCR register (set OPM [3:0] = 0xA).
▄
Wait until all operations have been nished by checking the value of 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 done by the
program that runs in the SRAM or by the debugging tool that access FMC register directly. The
software function that is executed on the Flash memory shall not trigger a mass erase operation.
The following gure displays the ow of mass erase operation.
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.30 47 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Word Programming
The FMC provides a 32 bits word programming function which is used for modifying the Flash
memory content. The following steps show the sequence of register access for word programming.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equals to 0xE, or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write word address to TADR register. Write data to WRDR register.
▄
Write word program command to OCMR register (CMD [3:0] = 0x4).
▄
Commit word program command to FMC by setting OPCR register (set OPM [3:0] = 0xA).
▄
Wait until all operations have been nished by checking the value of 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 operation to the same address must be separated by a page erase
operation. Besides, the word program will be ignored on protected pages. A Flash operation
error interrupt will be triggered by FMC if the OREIEN bit in the OIER register is set. Software
can check the PPEF bit in the OISR register to detect this condition in the interrupt handler. The
following gure displays the ow of word programming operation.
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.30 48 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Option Byte Description
The Option Byte can be treated as an independent Flash memory which base address is
0x1FF0_0000. The following table shows the function description and memory map of Option
Byte.
1: Option Byte protection is disabled
OB_CP [31:2]
Reserved
Flash Option Byte Checksum
OB_CK [31:0]
OB_CK should be set as the content value sum of 5
registers which offset address is form 0x000 to 0x010 in
Option Byte (0x000 + 0x004 + 0x008 + 0x00C + 0x010)
when the OB_PP or OB_CP register’s 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
Page Erase/Program Protection
FMC provides functions of page erase/program protection to prevent unexpected operation of 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 FMC on the protected pages, the PPEF bit in the OISR
register will then be set by FMC and the Flash operation error interrupt will be triggered to CPU
by 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 of the Option Byte. The following table
shows the access permission of the main Flash page when the page protection is enabled.
Rev. 1.30 49 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Table 8. Access Permission of Protected Main Flash Page
Mode
Operation
ReadOO
ProgramXX
Page EraseXX
Mass EraseOO
Notes:
1. Note that the setting of write protection is based on page. The above access permission
only affects the pages that enable protection function. Other pages are not affected.
2. Main Flash page protection is configured by OB_PP [126:0]. Option Byte is physically
located at the last page of main Flash. Option Byte page protection is congured by the
OB_CP [1] bit.
3. The page erase on Option Byte area can disable the page protection of main Flash.
4. The page protection of Option Byte can only be disabled by a mass erase operation.
The following steps show the register access sequence for page erase/program protection
procedure.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equals to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write OB_PP address to TADR register (TADR = 0x1FF0_0000).
▄
Write WRDR register which indicates the protection function of corresponding page is enabled
or disabled (0: Enabled, 1: Disabled).
▄
Write word program command to OCMR register (CMD [3:0] = 0x4).
▄
Commit word program command to FMC by setting OPCR register (set OPM [3:0] = 0xA).
▄
Wait until all operations have been nished by checking the value of OPCR register (OPM [3:0]
equals to 0xE).
▄
Read and verify the Option Byte if required.
▄
Program the OB_CK Option Byte as sum of 5 words 0x000 ~ 0x010 according to the checksum
rule of Option Byte.
▄
Apply a system reset to active the new OB_PP setting.
ISP/IAPICP/Debug Mode
Flash Memory Controller (FMC)
Rev. 1.30 50 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Security Protection
FMC provides function of Security protection to prevent illegal code/data access of Flash memory.
This function is useful for protecting the software / rmware from the illegal users. The function is
activated by setting the Option Byte OB_CP [0]. Once the function has been enabled, all the main
Flash data access through ICP/Debug mode, programming, and page erase will not be allowed
except the user’s application. But the mass erase operation will still be accepted by FMC in order to
disable this function. The following table shows the access permission of Flash memory when the
security protection is enabled.
Table 9. Access Permission When Security Protection is Enabled
Mode
Operation
ReadOX (read as 0)
ProgramO
Page EraseO
Mass EraseOO
Notes:
1. User application means the software that is executed or booted from main Flash memory
with the JTAG/SW debugger being disconnected. But Option Byte block and page 0 are
still in protection and can not Program/Page Erase.
2. Mass erase operation can erase Option Byte block and disable security protection.
User Application
(Note 1)
(Note 1)
(Note 1)
Flash Memory Controller (FMC)
ICP/Debug Mode
X
X
The following steps show the register access sequence for Security protection procedure.
▄
Check OPCR register to conrm that no Flash memory operation is ongoing (OPM [3:0] equal to
0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write OB_CP address to TADR register (TADR = 0x1FF0_0010).
▄
Write WRDR register, set OB_CP [0] as 0.
▄
Write word program command to OCMR register (CMD [3:0] = 0x4).
▄
Commit word program command to FMC by setting OPCR register (set OPM = 0xA).
▄
Wait until all operations have been nished by checking the value of OPCR register (OPM [3:0]
equals to 0xE).
▄
Read and verify the Option Byte if required.
▄
Program the OB_CK Option Byte as sum of 5 words 0x000 ~ 0x010 according to the checksum
rule of Option Byte.
▄
Apply a system reset to active the new OB_CP setting.
Rev. 1.30 51 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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_0200
CFCR0x200Flash Cache & Pre-fetch Control Register0x0000_0051
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.30 52 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Register Descriptions
Flash Target Address Register – TADR
This register species the target address of page erase and word programming operation.
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 species the address where the
data is written. Since the programming length is 32 bits, the TADR shall be set
as word-aligned (4 bytes). The TADB [1:0] 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 512 Byte, the TADB
[8:0] will be ignored in order to limit the target address as 512 Byte-aligned. For
128 KB main Flash addressing, TADB [31:17] should be zero and TADB [31:16]
should be zero for 64 KB. Address from 0x1FF0_0000 to 0x1FF0_03FF is the 1KB
Option Byte. This eld for available Flash address, it must be under 0x1FFF_FFFF.
Otherwise, the Invalid Target Address interrupt will be occurred if the corresponding
interrupt enable bit is set.
Flash Memory Controller (FMC)
Rev. 1.30 53 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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.30 54 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Operation Command Register – OCMR
This register is used to specify the Flash operation commands that include read, read ID, 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 definitions of CMD [3:0] which specify the Flash
operation. If an invalid command is set and IOCMIEN = 1, the Invalid Operation
Command interrupt will be occurred.
CMD [3:0]Description
0x0Idle (default)
0x4Word program
0x8Page erase
0xAMass erase
OthersReserved
Flash Memory Controller (FMC)
Rev. 1.30 55 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 mode of FMC. User can commit command
which is set by the OCMR register to main flash according to the address alias
setting in TADR. The content of TADR, WRDR, and OCMR registers shall be
prepared before setting this register. After all the operation has been nished, the
OPM eld will be set as 0xE or 0xF by the FMC hardware. The Idle mode can be
set when all the operations have been finished for power saving. Note that the
operation status should be checked before the next action is applied to the FMC.
The content of 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.30 56 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Operation Interrupt Enable Register – OIER
This register is used to enable or disable interrupt function of FMC. The FMC generates interrupt 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 does not generate an interrupt
1: Operation error generates an interrupt
0: Invalid Operation Command does not generate an interrupt
1: Invalid Operation Command generates an interrupt
[2]OBEIENOption Byte Check Sum Error Interrupt Enable
0: Option Byte Check Sum Error does not generate an interrupt
1: Option Byte Check Sum Error generates an interrupt
[1]ITADIENInvalid Target Address Interrupt Enable
0: Invalid Target Address does not generate an interrupt
1: Invalid Target Address generates an interrupt
[0]ORFIENOperation Finished Interrupt Enable
0: Operation Finish does not generate an interrupt
1: Operation Finish generates an interrupt
Flash Memory Controller (FMC)
Rev. 1.30 57 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Operation Interrupt and Status Register – OISR
This register indicates the status of the FMC interrupt to check if an 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 is not occurred
1: Operation error since an invalid erase/program operation is 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
RORFF is directly connected from Flash memory for debugging purpose.
[4]OREFOperation Error Flag
0: No ash operation error occurred
1: The last ash operation is failed
This bit will be set when any error of flash operation such as invalid command,
program error and erase error, etc. is occurred. 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 is set into the OCMR register.
The IOCM interrupt will be occurred if the IOCMIEN bit in the OIER register is set.
Reset this bit by writing 1.
[2]OBEFOption Byte Check Sum Error Flag
0: Check sum of Option Byte is correct
1: Check sum of Option Byte is incorrect
The OBE interrupt will be occurred if the OBEIEN bit in the OIER register is set. But
the Option Byte Check Sum Error Flag has to wait the interrupt condition is cleared
then reset this bit by software writes 1 , that means the Option Byte check sum
value has to modied to correct. Otherwise, the interrupt will be continually kept or
the software disables the interrupt enable bit to release the interrupt request.
Flash Memory Controller (FMC)
Rev. 1.30 58 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
BitsFieldDescriptions
[1]ITADFInvalid Target Address Flag
0: The target address is valid
1: The target address TADR is invalid
TADR eld must be below 0x1FFF_FFFF. The ITAD interrupt will be occurred if the
ITADIEN bit in the OIER register is set. Reset this bit by writing 1.
[0]ORFFOperation Finished Flag
0: No operation nished interrupt occurred
1: Last ash operation command is nished
The ORF interrupt will be occurred if the ORFIEN bit in the OIER register is set.
Reset this bit by writing 1.
Flash Memory Controller (FMC)
Rev. 1.30 59 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Page Erase/Program Protection Status Register – PPSR
This register indicates the status of Flash page erase/program protection.
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 pages are protected
1: The corresponding pages are 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 specic pages 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]. Since the maximum page number of the main flash is various and
dependent on the chip specification. Therefore, the every page erase/program
protection status bit may protect one or two pages and dependent on the chip
specication. The other remained bits of OB_PP and PPSR registers are reserved.
Rev. 1.30 60 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Security Protection Status Register – CPSR
This register indicates the status of the Flash Security protection. 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 OPBSB is determined by the Option Byte, OB_CP [1].
[0]CPSBFlash Security Protection Status Bit
0: Flash Security protection is enabled
1: Flash Security protection is not enabled
The reset value of CPSB is determined by the Option Byte, OB_CP [0].
Flash Memory Controller (FMC)
Rev. 1.30 61 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Vector Mapping Control Register – VMCR
This register is used to control the mapping of vector. The reset value of VMCR is determined by booting power
on the reset setting BOOT pin.
Offset:0x100
Reset value: 0x0000_000X
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedVMCBReserved
Type/ResetRW X 1
BitsFieldDescriptions
[1]VMCBVector Mapping Control Bit
The VMCB bits is used to control the mapping source of first 4-word vector
(address 0x0 ~ 0xC). The following table shows the vector mapping setting.
BOOTVMCB [1]Descriptions
Low0
High1
The reset value of VMCB is determined by the pins status of BOOT during power
on reset and system reset. The setting of the vector mapping can be changed
temporarily by setting the VMCB bit when the application is running.
Boot Loader mode
The source of the vector mapping is the boot loader area.
Main Flash mode
The source of the vector mapping is the main Flash area.
Flash Memory Controller (FMC)
Rev. 1.30 62 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Manufacturer and Device ID Register – MDID
This register species 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.30 63 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Page Number Status Register – PNSR
This register species the page number of Flash memory.
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.30 64 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Page Size Status Register – PSSR
This register species the page size in bytes.
Offset:0x188
Reset value: 0x0000_0200
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 0 RO 1 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]PSSBStatus Bits of Flash Page Size
0x200: That means the page size is 512 Byte per page.
0x400: That means the page size is 1 KB per page.
0x800: That means the page size is 2 KB per page.
Rev. 1.30 65 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Flash Cache & Pre-fetch Control Register – CFCR
This register is used for controlling the pre-fetch module of FMC.
Offset:0x200
Reset value: 0x0000_13D1
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
ReservedCEReserved
Type/ResetRW 10011
76543210
ReservedPFBEReservedWAIT
Type/Reset11 0 RW 1RW 0 RW 0 RW 1
Flash Memory Controller (FMC)
BitsFieldDescriptions
[12]CEBranch Cache Enable Bit
0 = Cache is disabled.
1 = Cache is enabled (default).
[4]PFBEPre-fetch Buffer Enable Bit
0: Pre-fetch buffer is disabled. The Instruction/Data is provided by Flash
memory directly.
1: Pre-fetch buffer is enabled (default).
[2:0]WAITFlash Wait State Setting
The WAIT [2:0] is used to set the count of the HCLK wait clock during nonsequential address Flash access. The actual wait clock is (WAIT [2:0] - 1). Since
the wide access interface with 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 ≤ 24 MHz
010124 MHz < HCLK ≤ 48 MHz
OthersReservedReserved
Rev. 1.30 66 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Custom ID Register n – CIDRn, n = 0 ~ 3
This register species 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.30 67 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 three digital power domains.
V
DD
V
BAT
nRST
WAKEUP
RTCOUT
PWRSW
RTC
LSI
V
BAK
WKUP1
WKUP2
WKUP3
PORB
PWR_CTRL
LDOOFF
LCM
DMOSON
WKUP4
SLEEPDEEP
SLEEPING
V
DD
VDDDomain
LDO
DMOS
HSE
CPUMemories
POR/PDR
POR/PDR
1.5 V Domain
PLL
HSI
3.3 V
LVD
1.5 V
Power Control Unit (PWRCU)
V
DD15
LDOOUT
V
LSE
PORB: V
BREG: Backup Registers
BREG
Backup Domain
Power On Reset
BAK
Figure 11. PWRCU Block Diagram
LDO: Voltage Regulator
DMOS: Depletion MOS
APB
INTF
LVD: Low Voltage Detector
POR/PDR: Power On Reset/Power Down Reset
Digital
Peripheral
Rev. 1.30 68 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Features
▄
Three power domains: Backup, VDD and 1.5 V power domains.
▄
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
▄
Switch Battery power (V
▄
40 bytes of backup registers powered by V
the Power-Down mode.
.
BOD
.
LVD
) for backup domain when VDD is lower than V
BAT
for data storage of user application data when in
BAK
BOD
PDR
Power Control Unit (PWRCU)
.
voltage.
Functional Descriptions
Backup Domain
Power Switch
The Backup Domain is powered by the VDD power source or the battery power source, V
is selected by the power switch PWRSW. The operating voltage range of the Back Domain is
from 2.0 V to 3.6 V. If VDD is lower than V
automatically switched from VDD to V
in the backup domain can operate normally. This means that the backup register contents will be
retained, the RTC circuitry will operate normally and the low speed oscillators can keep running.
Backup Domain Reset
The Backup Domain reset sources include the Backup Domain Power-On-Reset (PORB) and
the Backup Domain software reset which is activated by setting the BAKRST bit in the BAKCR
register. The PORB signal forces the device to stay in the reset mode until the V
V
. The application software can set the PORBDN bit in the BAKCR register to disable PORB
PORB
circuit to save the current consumption in the Backup Domain. Also the application software can
trigger Backup Domain software reset by setting the BAKRST bit in the BAKCR register. All
registers of PWRCU and RTC will be reset only by the Backup Domain reset.
, which
BAT
, then the power source of the Back Domain will be
PDR
. Therefore, even if VDD is powered down, all the circuitry
BAT
is greater than
BAK
Rev. 1.30 69 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
LSE, LSI and RTC
The Real Time Clock circuitry clock source can be derived from either the Low Speed Internal
RC oscillator, LSI, or the Low Speed External Crystal oscillator, LSE. Before entering the power
saving mode by executing WFI/WFE instruction, the MCU needs to setup the compare register
with an expected wakeup time and enable the wakeup function to achieve the RTC timer wakeup
event. After entering the power saving mode for a certain amount of time, the Compare Match
ag, CMFLAG, will be asserted to wakeup the device when the compare match event occurs. The
details of the RTC conguration for wakeup timer will be described in the RTC chapter.
Backup Registers and Isolation Cells
Ten 32-bit registers, up to 40 bytes, are located in the Backup Domain for user application data
storage. These registers are powered by V
core power is switched off. The Backup Registers are only reset by the Backup Domain power-onreset, PORB, or the Backup Domain software reset, BAKRST. When the device resumes operation
from the 1.5 V power, either by Hardware or Software, access to the Backup registers and the RTC
registers 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
BKISO bit to 1 in the LPCR register of the Clock Control Unit.
which constantly supplies power when the 1.5 V
BAK
Power Control Unit (PWRCU)
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 V
DD33
≤ V
PDR
BOD
.
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 - RTC wakeup, 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
BOD
.
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.
VDD Power Domain
Voltage Regulator
The voltage regulator, LDO, Depletion MOS, DMOS, Low voltage Detector, LVD and High Speed
Internal oscillator, HSI are operated under the VDD power domain. The LDO can be congured to
operate in either normal mode (LDOOFF = 0, SLEEPDEEP = 0, I
current mode (LDOOFF = 0, SLEEPDEEP=1, I
= Low current mode) to supply the 1.5 V power.
OUT
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 BAKCR 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.
DD15
= High current mode) or low
OUT
POR
if any
Rev. 1.30 70 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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.30 71 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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.
1.5 V Power Domain
The main functions that include the APB interface for the backup 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 (Refer to PORB) on 1.5 V power domain.
Subsequently, to enter the expected power saving mode, the associated control bits including
the LDOOFF, DMOSON, and SLEEPDEEP 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.
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.
Power Control Unit (PWRCU)
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.30 72 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 necessary to clear the SLEEPDEEP bit to 0 and execute a WFI or WFE instruction. 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, RTC, LVD, and WAKEUP pin rising edge
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
RTC wakeup or
CMP Wakeup or
LVD wakeup
WAKEUP pin rising edge or
USB resume
RTC wakeup or
LVD wakeup
WAKEUP pin rising edge
RTC wakeup or
LVD wakeup
WAKEUP pin rising edge or
External reset (nRST)
(2)
or
(2)
or
(2)
or
2. If the system allows the LVD activity to wake it up after the system has entered the power saving mode,
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.
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.
Mode Exit
(1)
or
Power Control Unit (PWRCU)
Rev. 1.30 73 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 RTC wakeup trigger event, 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 (V
After a system reset, the PORSTF bit in the RSTCU GRSR register, the PDF and BAKPORF bits
in the BAKSR register should be checked by software to conrm if the device is being resumed
from the Power-Down mode by a backup domain power on reset, an unexpected loss of the 1.5
V power 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 Backup Registers and be retrieved when the 1.5 V power domain is powered on
again. More information about the PDF and BAKPORF bits in the BAKSR register and PORSTF
bit in the RSTCU GRSR register is shown in the following table.
DD
/ V
) and the Backup Domain power (V
DDA
BAK
).
Power Control Unit (PWRCU)
Table 13. Power Status After System Reset
BAKPORF PDF PORSTFDescription
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
BAKSR0x100Backup Domain Status Register0x0000_0001
BAKCR0x104Backup Domain Control Register0x0000_0000
BAKTEST0x108Backup Domain Test Register0x0000_0027
LVDCSR0x110Low Voltage/Brown Out Detect Control and Status Register 0x0000_0000
BAKREG00x200Backup Register 00x0000_0000
BAKREG10x204Backup Register 10x0000_0000
BAKREG20x208Backup Register 20x0000_0000
BAKREG30x20CBackup Register 30x0000_0000
BAKREG40x210Backup Register 40x0000_0000
BAKREG50x214Backup Register 50x0000_0000
BAKREG60x218Backup Register 60x0000_0000
BAKREG70x21CBackup Register 70x0000_0000
BAKREG80x220Backup Register 80x0000_0000
BAKREG90x224Backup Register 90x0000_0000
Power-up for the rst time after the backup domain is reset:
Power on reset when V
software reset command on the backup domain.
Restart from unexpected loss of the 1.5 V power or other reset
(nRST, WDT,…)
backup power domain.
BAK
is applied for the rst time or executing
BAK
Rev. 1.30 74 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Register Descriptions
Backup Domain Status Register – BAKSR
This register indicates backup domain status.
Offset:0x100
Reset value: 0x0000_0001 (Reset only by Backup Domain reset)
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
ReservedWUPF
Type/ResetRC 0
76543210
ReservedPDFBAKPORF
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]BAKPORFBackup Domain Reset Flag
0: Backup Domain reset does not occur
1: Backup Domain reset occurs
This bit is set by hardware when Backup Domain reset occurs, either a Backup
Domain power on reset or Backup Domain software reset. The bit is cleared by
software read. This bit must be cleared after the system is rst powered, otherwise it
will be impossible to detect when a Backup 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 Backup Domain is
ready for access. It must be implemented after the Backup Domain is rst powered
up.
shutdown (Loss of V
DD15
is unexpected)
DD15
is under expectation.
DD15
Power Control Unit (PWRCU)
Rev. 1.30 75 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Backup Domain Control Register – BAKCR
This register provides power control bits for the Deep-Sleep and Power-Down modes.
Offset:0x104
Reset value: 0x0000_0000 (Reset only by Backup Domain reset)
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
DMOSSTSReserved V15RDYSCReservedWUPIENWUPEN
Type/ResetRO 0RW 0RW 0 RW 0
76543210
DMOSONReservedLDOOFFLDOLCMReservedBAKRST
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: BKISO bit in the LPCR register located in the CKCU
1: V
DD15
POR
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
corresponding register bits which should be properly setup are the PBPD[12] to 1 in
the PBPDR register, the PBPU [12] to 0 in the PBPUR register and the PBCFG12
[3:0] eld to 0x0F in the GPBCFGHR register.
Note: This bit is reset by a system reset or a Backup Domain reset. Because this
bit is located in the Backup Domain, after reset activity there will be a delay until
the bit is active. The bit will not be active until the system reset finished and the
Backup Domain ISO signal has been disabled. This means that the bit can not be
immediately set by software after a system reset nished and the Backup domain
ISO signal disabled. The delay time needed 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 PORB. 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]BAKRSTBackup Domain Software Reset
0: No action
1: Backup Domain Software Reset is activated - includes all the related RTC and
PWRCU registers.
power is available.
DD15
power is not available.
DD15
Power Control Unit (PWRCU)
Rev. 1.30 77 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Backup Domain Test Register – BAKTEST
This register specifies a read-only value for the software to recognize whether backup domain is ready for
access.
Offset:0x108
Reset value: 0x0000_0027
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
BAKTEST
Type/ResetRO 0 RO 0 RO 1 RO 0 RO 0 RO 1 RO 1 RO 1
BitsFieldDescriptions
[7:0]BAKTESTBackup Domain Test Bits
A constant 0x27 will be read when the Backup Domain is ready for CPU access.
Power Control Unit (PWRCU)
Rev. 1.30 78 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 Backup Domain 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: V
is higher than the specic voltage level
DDA
1: V
is equal to or lower than the specic voltage level
DDA
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.30 79 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 V
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]BODFBrown 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 is lower than
DDA
Power Control Unit (PWRCU)
Rev. 1.30 80 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Backup Register n – BAKREGn, n = 0 ~ 9
This register species backup register n for storing data during the VDD15 power-off period.
Offset:0x200 ~ 0x224
Reset value: 0x0000_0000 (Reset only by Backup Domain reset)
3130292827262524
BAKREGn
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
2322212019181716
BAKREGn
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
15141312111098
BAKREGn
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
76543210
BAKREGn
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
Power Control Unit (PWRCU)
BitsFieldDescriptions
[31:0]BAKREGnBackup Register n (n = 0 ~ 9)
These registers are used for data storage in general purpose. The contents of
BAKREGn registers will remain even if the V
power is lost.
DD15
Rev. 1.30 81 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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), Low speed
external crystal oscillator (LSE), 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 or PLL. Watchdog Timer and Real Time Clock
(RTC) use either LSI or LSE as their clock source.
A variety of internal clocks can also be wired out though CKOUT for debugging purpose. The
clock monitor can be used to get clock failure detection of HSE. Once the clock of HSE does not
function (could be broken down or removed or etc), CKCU will force to switch the system clock
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.
▄
32,768 Hz external crystal oscillator (LSE) for Watchdog Timer, RTC or system clock.
▄
Internal 32 kHz RC oscillator (LSI) for Watchdog Timer, RTC or system clock.
▄
HSE clock monitor
Function Descriptions
High Speed External Crystal Oscillator – HSE
The high speed external 4 to 16 MHz crystal oscillator (HSE) produces a highly accurate
clock source to the system clock. The related hardware configuration 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
Crystal
4 MHz ~ 16 MHz
CL1CL2
Figure 14. External Crystal, Ceramic, and Resonators for HSE
Rev. 1.30 84 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 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 HSI is shorter then 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 accuracy of the frequency of the high speed internal RC oscillator HSI can be calibrated via the
conguration options, but it is still less accurate than the HSE crystal oscillator. The applications,
the environments and the cost will determine the use of the oscillators.
Software could congure PSRCEN bit (Power Saving Wakeup RC Clock Enable) to 1 to force HSI
clock to be system clock when wake-up from Deep-Sleep or Power-Down mode. Subsequently, the
system clock will be 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 clock as the system clock.
Auto Trimming of High Speed Internal RC Oscillator – HSI
The frequency accuracy of the high speed internal RC oscillator HSI can vary from one chip to
another due to manufacturing process variations, this is why each device is factory calibrated by
HOLTEK for ±2% accuracy at VDD = 3.3 V and TA = 25°C. But the accuracy is not enough for
some applications and environments requirement. Therefore, this device provides the trimming
mechanism for HSI frequency calibration using more accurate external reference clock. The detail
block diagram is shown as Fig ure 15.
After reset, the factory trimming value is loaded in the HSICOARSE[4:0] and HSIFINE[7:0] bits
in the HSI Control Register (HSICR). The HSI frequency accuracy may be affected by the voltage
or temperature variation. If the application has to be driven by more accurate HSI frequency, the
HSI frequency can be manually trimmed using the HSIFINE[7:0] bits in the HSI Control Register
(HSICR) or automatically adjusted via the Auto Trimming Controller together with an external
reference clock in the application. The reference clock can be provided from the low speed external
crystal or ceramic resonator oscillator LSE with a 32,768 Hz frequency or a 1ms USB frame
synchronous signal.
Rev. 1.30 85 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Auto Trimming HSI Block Diagram
1
0
TMSEL
USB Frame Pulse
LSE
32.768KHz
1
Factory
Trimming Bits
0
TRIMEN
/32
1
0
REFCLKSEL
Fine [7:0]
Coarse [4:0]
1KHz
/1.024KHz
Fine-Trimming
Write Register
ATCEN
Auto Trimming
Controller
Fine-Trimming
Read Register
8MHz HSI
Oscillator
8MHZ
AT
Counter
Register
Clock Control Unit (CKCU)
AHB Bus
Figure 15. HSI Auto Trimming Block Diagram
Coarse-Trimming
Read Register
Rev. 1.30 86 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
2
2*2*2
2*1*
NO
NF
NO
NF
NONONR
NFNF
HT32F52342/HT32F52352
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 lter and a voltage-
controlled oscillator (VCO) to achieve a stable phase-locked state.
CLK
= 4 ~ 16MHz
Ref. Divider
in
(NR)
/2
PD
CPVCO
Loop
Filter
= 48 ~ 96 MHz
VCO
out
Output Divider 1
(NO1)
/2
Output Divider 2
(NO2)
S1~S0
PLL
out
= 4 ~ 48 MHz
Clock Control Unit (CKCU)
Feedback Divider 2
(NF2)
B3~B0
Figure 16. PLL Block Diagram
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 as the PLL input generates a specic 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 but
the expense of 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 Ta bl e 16 are dened
in the PLL Conguration Register (PLLCFGR) and PLL Control Register (PLLCR) in the section
of Register Denition. Note that the VCO
96 MHz. If the selected conguration exceeds this range, the PLL output frequency will not be
guaranteed to match the above PLL
Feedback Divider 1
(NF1)
/4
2*1
CK
OUT
formula.
OUT
*
2*4
CK
===
INININOUT
2
*
frequency should be in the range from 48 MHz to
The PLL can be switched on or off by 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.30 87 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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)
:
:
Rev. 1.30 88 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Low Speed External Crystal Oscillator – LSE
The low speed external crystal or ceramic resonator oscillator with 32,768 Hz frequency produces
a low power but highly accurate clock source for the Real-Time-Clock peripheral, Watchdog Timer
or system clock. The associated hardware configuration is shown in the following figure. The
crystal or ceramic resonator must be placed across the two LSE pins (X32KIN / X32KOUT) and
the external components such as resistors and capacitors are necessary to make it oscillate properly.
The LSE oscillator can be switched on or off by using the LSEEN bit in the RTC Control Register
(RTCCR). The LSERDY ag in the Global Clock Status Register (GCSR) will indicate if the LSE
clock is stable. An interrupt can be generated if the related interrupt enable bit LSERDYIE in the
Global Clock Interrupt Register (GCIR) is set as the LSE becomes stable.
Clock Control Unit (CKCU)
X32KIN
C
L1
32.768KHZ
Figure 17. External Crystal, Ceramic, and Resonators for LSE
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 Real-Time-Clock peripheral, Watchdog Timer or system clock. The LSI offers a low
cost clock source because no external component is required to make it oscillates. The LSI RC
oscillator can be switched on or off by using the LSIEN bit in the RTC Control Register (RTCCR).
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 flags for the HSI, HSE, PLL, LSI, and LSE
to indicate whether these clocks are stable. Before using them as the system clock source or
other purpose, it is necessary to conrm the specic clock ready ag is set. Software can check
the specific clock is ready or not by polling the individual clock ready status bits in GCSR
register. Additionally, the CKCU can trigger an interrupt to notify specific 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 by interrupt service routine.
X32KOUT
C
L2
Rev. 1.30 89 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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, LSE, LSI or PLL output
clock and it can be switched from one clock source to another by changing 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 bit 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 uses as the system clock source, it is not
possible to stop it. More details about the clock enable function is 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)
If any event in the following occurs, the HSE will be enabled.
Clock Control Unit (CKCU)
▄
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 after the ready ags of both HSI and HSE are asserted,
3. Conguring the SW register to change the system clock source will occur after the corresponding
ready ag 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 or HSE clock congured as the system clock is
stuck at 0 or 1.
Rev. 1.30 90 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
HSE Clock Monitor
The HSE clock monitor 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 event will be generated if the corresponding 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 whose
output 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
congured in the Alternate Function I/O, AFIO, section to output the selected clock signal. There
are seven 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
001HCLKC / 16
010CK_SYS / 16
011CK_HSE / 16
100CK_HSI / 16
101CK_LSE
110CK_LSI
Rev. 1.30 91 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Register Map
The following table shows the CKCU register and reset value.
HSIATCR0x044HSI Auto Trimming Counter Register0x0000_0000
LPCR0x300Low Power Control Register0x0000_0000
MCUDBGCR 0x304MCU Debug Control Register0x0000_0000
Clock Control Unit (CKCU)
0xXXXX_0000
where X is undened
Rev. 1.30 92 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Register Descriptions
Global Clock Conguration Register – GCFGR
This register species the clock source for PLL/USART/Watchdog Timer/CKOUT.
Offset:0x000
Reset value: 0x0000_0102
3130292827262524
LPMODReserved
Type/ResetRO 0 RO 0 RO 0
2322212019181716
USBPREReserved
Type/ResetRW 0 RW 0
15141312111098
CKREFPREReservedPLLSRC
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0RW 1
76543210
ReservedCKOUTSRC
Type/ResetRW 0 RW 1 RW 0
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.30 93 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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: CK_LSE is selected
110: CK_LSI is selected
111: Reserved
Set and reset by software.
Clock Control Unit (CKCU)
Rev. 1.30 94 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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 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 originally selected clock source from the HSI clock.
When the hardware detects that the HSE clock is stuck at low or high state, the
internal hardware will switch the system clock to internal high speed HSI RC clock.
[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 the
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.
[9]PLLENPLL Enable
0: PLL disabled
1: PLL enabled
Set and reset by software. This bit cannot be reset if the PLL clock is used as the
system clock.
Rev. 1.30 95 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
BitsFieldDescriptions
[8]HSEGAINExternal High Speed Oscillator Gain Selection
0: HSE in low gain mode
1: HSE 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: CK_LSE as system clock
111: CK_LSI as system clock
Other: CK_HSI as system clock
These bits are used to select the CK_SYS source. When switch the system clock
using the SW bit, the system clock will be not 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.30 96 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
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
ReservedLSIRDYLSERDYHSIRDYHSERDYPLLRDYReserved
Type/ResetRO 1 RO 0 RO 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 is stable to be used.
[4]LSERDYExternal Low Speed Oscillator Ready Flag
0: External 32,768 Hz crystal oscillator is not ready
1: External 32,768 Hz crystal oscillator is ready
Set by hardware to indicate whether the LSE 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 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 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 is stable to be used.
Rev. 1.30 97 of 656September 28, 2018
32-Bit Arm® Cortex®-M0+ MCU
HT32F52342/HT32F52352
Global Clock Interrupt Register – GCIR
This register species the interrupt enable and ag bits.