Data .............................................................................................................................................. 569
Buffer Status ................................................................................................................................. 571
Figure 216. Command Format .............................................................................................................. 568
Figure 217. Response Format .............................................................................................................. 568
Figure 218. Usual Data Format for Standard Bus – only DAT0 used ................................................... 569
Figure 219. Usual Data Format for Wide Bus – DAT0~DAT3 used ...................................................... 570
Figure 220. Wide Width Data Format for Standard Bus – only DAT0 used .......................................... 570
Figure 221. Wide Width Data Format for Wide Bus – DAT0 ~ DAT3 used .......................................... 570
List of Figures
Rev. 1.10 26 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
1
Overview
Introduction
This user manual provides detailed information including how to use the device, 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
HT32F12345 dat asheet.
The device is a high performance and low power consumption 32-bit microcontrollers based around
an Arm® Cortex®-M3 processor core. The Cortex®-M3 is a next-generation processor core which
is tightly coupled with Nested Vectored Interrupt Controller (NVIC), SysTick timer and including
advanced debug support.
The device operates at a frequency of up to 96 MHz with a Flash accelerator to obtain maximum
efciency. It provides 64 KB of embedded Flash memory for code/data storage and up to 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, PDMA, GPTM, MCTM, EBI, CRC-16/32,
USB2.0 FS, SDIO and SW-DP (Serial Wire Debug Port), etc., are also implemented in the device.
Several power saving modes provide the exibility for maximum optimization between wakeup
latency and power consumption, an especially important consideration in low power applications.
The above features ensure that the device is suitable for use in a wide range of applications,
especially in areas such as white goods application control, power monitors, alarm systems,
consumer products, handheld equipment, data logging applications, motor control and so on.
Introduction
Rev. 1.10 27 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Features
▄
Core
● 32-bit Arm
● Up to 96 MHz operation frequency
● Single-cycle multiplication and hardware division
● Translates the AHB transactions into the appropriate external device protocol
● 4 Memory bank regions and independent chip select control for each memory bank
● Accurate control of setup, strobe, hold and turn-around timing per memory bank
● Supports page mode read
● 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
● Both multiplexed and non-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 (12 Mbps) specication
● On-chip USB full-speed transceiver
● 1 control endpoint (EP0) for control transfer
● 3 single-buffered endpoint (EP1 ~ EP3) for bulk and interrupt transfer
● 4 double-buffered endpoint (EP4 ~ EP7) for bulk, interrupt and isochronous transfer
● 1 KB EP_SRAM used as the endpoint data buffers
▄
Secure Digital Input Output Interface – SDIO
● Supports two different data bus modes: 1-bit (default) and 4-bit
● Supports two different speed modes: Normal speed (default) and High speed
● SD clock frequency of up to 48 MHz
● SPI mode and MMC stream mode not supported
▄
Debug support
● Serial Wire Debug Port SW-DP
● 6 instruction comparator and 2 literal comparator for hardware breakpoint/watchpoint or code
patch
● 1-bit asynchronous trace (TRACESWO)
▄
Package and Operation Temperature
● 46-pin QFN, 48/64-pin LQFP package
● Operation temperature range: -40 ºC to 85 ºC
Introduction
Rev. 1.10 31 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Device Information
Table 1. Features and Peripheral List
Main Flash (KB)63
Option Bytes Flash (KB)1
SRAM (KB)16
Timers
Communication
PDMA12 channels
SDIO1
EBI1
CRC1
GPIOUp to 51
EXTI16
12-bit ADC
Number of channels
Comparator2
CPU frequencyUp to 96 MHz
Operating voltage2.0 V ~ 3.6 V
Operating temperature-40 °C ~ 85 °C
Package46-pin QFN, 48/64-pin LQFP
PeripheralsHT32F12345
MCTM2
GPTM2
BFTM2
RTC1
WDT1
USB1
USART2
UART2
SPI2
I2C2
I2S1
1
Max. 12 Channels
Introduction
Rev. 1.10 32 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
TPIUSW-DP
APB1
APB0
AHB
Peripherals
ICodeDCode
CortexTM-M3
Processor
System
NVIC
SRAM
Controller
FMC
Control
Registers
CKCU/
RSTCU
PDMA
Control
Registers
PDMA
12 Channels
DMA request
Interrupt request
USART0
UART0
AFIO
EXTI
SPI1
MOSI, MISO
SCK, SEL
Powered by V
DD
V
SS
V
DD
PLL
f
Max
: 96 MHz
POR
/PDR
CH3 ~ CH0
ETI
BOOT0
BOOT1
Clock and reset control
BOD
LVD
XTALIN
XTALOUT
CLDO
HSI
8 MHz
HSE
4 ~ 16 MHz
Power co ntrol
Bus Matrix
AFAF
AF
AF
AF
AFAF
AF
LDO
1.5 V
Powered by V
DD15
USB
Control/Data
Registers
SDA
SCL
AF
USART1
Power supply:
Bus:
Control signal:
Alternate function:
AF
MOSI, MISO
SCK, SEL
AF
TX, RX
RTS/TXE
CTS/SCK
TX, RX
RTS/TXE
CTS/SCK
CH0 ~CH2
CH0N ~ CH2N
CH3, ETI, BRK
AF
X32KIN
X32KOUT
AF
PORB
V
BAK
LSI
32 kHz
LSE
32.768kHz
BREG
V
BAK
Backup Domain
V
DD
V
BAT
V
SS
V
BAK
PWRSW
RTC
PWRCU
nRST
RTCOUT
WAKEUP
AFAF
GPTM0 ~ 1
Powered by V
DDA
V
DDA
V
SSA
CN0, CP0
COUT0
CN1, CP1
COUT1
ADC_IN0
...
ADC_IN11
AFAF
I2C0 ~ 1
ADC
12-Bit
SAR ADC
TRACESWO
BFTM0 ~ 1
AHB to APB
Bridge
External Bus
Interface
USB
Device
AF
DP
DM
WDT
AF
AD0~AD15
A0~A24
CS0~CS3
OE, WR
ALE, RDY
BL0~BL1
GPIO
A~D
PA~PC[15:0]
PD[2:0]
SPI0
AF
TX, RX
AF
UART1
TX, RX
I2S
MCLK, BCLK
WS, SDO, SDI
Powered by V
DD15
SDIO
SRAM
AF
CLK, CMD
DAT0 ~ 3
CAP.
SWCLK
SWDIO
MCTM0 ~ 1
USB PLL
f: 48 MHz
CMPCU
Flash
Memory
Analog
CMP0 ~ 1
Flash Memory
Interface
CRC
AF
HT32F12345
Block Diagram
Introduction
Figure 1. Block Diagram
Rev. 1.10 33 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
2
Document Conventions
Unless otherwise specied, this document uses the conventions which showed as follows.
Table 2. Document Conventions
NotationExampleDescription
0x0x5a05
0xnnnn_nnnn0x2000_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.
1918
RW
RO
RC
WC
W0C
WO
Reserved
WordData length of word is 32-bit.
Half-wordData length of half-word is 16-bit.
ByteData length of byte is 8-bit.
SERDYIE PLLRDYIE
RW 0 RW 0
32
HSIRDYHSERDY
RO 1 RO 0
10
PDFBAK_PORF
RC 0 RC 1
32
SERDYFPLLRDYF
WC 0 WC 0
10
RXCFPARF
RO 0 W0C 0
3130
DB_CKSRC
WO 0 WO 0
10
LLRDYReserved
RO 0
The number string with a 0x prefix indicates a
hexadecimal number.
The number string with a lowercase b prex indicates a
binary number.
Specic bit of NAME. NAME can be a register or eld of
register. For example, ADDR [5] means bit 5 of ADDR
register (eld).
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. Write operation has no
effort.
Software can read this bit. Read operation clears it to 0
automatically.
Software can read this bit or clear it by writing 1. Write a
0 will have no effect.
Software can read this bit or clear it by writing 0. Write a
1 will have no effect.
Software can only write to this bit. Read operation
always returns 0.
Reserved bit(s) for future use. Software should not
rely on the value of the reserved bit. In general case,
reserved bits are set to 0. Note that reserved bit must
be kept at reset value.
Document Conventions
Rev. 1.10 34 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
3
System Architecture
The system architecture of the device that includes the Arm® Cortex®-M3 processor, bus architecture
and memory organization will be described in the following sections. The Cortex®-M3 is a next
generation processor core which offers many new features. Integrated and advanced features make
the Cortex®-M3 processor suitable for high performance and low power microcontroller market.
In brief, Cortex®-M3 processor includes three AHB-Lite buses, ICode, DCode and System bus.
All memory accesses of Cortex®-M3 are performed on those three buses according to the different
purpose and target memory space. The memory organization with Harvard architecture, pre-
dened memory map and up to 4 GB memory space makes the system exible and extendable.
Arm® Cortex®-M3 Processor
Cortex®-M3 is a general purpose 32-bit processor core which very suitable for high performance
and low power microcontroller market. It offers many new features including a Thumb-2
instruction sets, hardware divide, low latency interrupt response time, atomic bit-banding access
and multiple buses for simultaneous accesses. Cortex®-M3 is based on ARMv7 architecture and
supports both Thumb and Thumb-2 instruction sets. Some system peripherals are also provided by
the Cortex®-M3 including:
▄
Internal Bus Matrix connected with ICode bus, DCode bus, System bus, Private Peripheral Bus
(PPB) and debug accesses (AHB-AP)
▄
Nested Vectored Interrupt Controller (NVIC)
▄
Flash Patch and Breakpoint (FPB)
▄
Data Watchpoint and Trace (DWT)
▄
Instrument Trace Macrocell (ITM)
▄
Memory Protection Unit (MPU)
▄
Serial Wire JTAG Debug Port (SWJ-DP)
▄
Embedded Trace Macrocell (ETM)
▄
Trace Port Interface Unit (TPIU)
The following gure shows the Cortex®-M3 block diagram. For more information, please refer to
Arm® Cortex®-M3 Technical Reference Manual.
System Architecture
Rev. 1.10 35 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
INTNMI
INTISR[239:0]
SLEEPING
SLEEPDEEP
SW/
JTAG
SW/
SWJ-DP
Interrupts
NVIC
Private Peripheral Bus
(internal)
AHB-AP
Sleep
Debug
CM3Core
Inar.Data
MPU
FPB
Cortex-M3
DWT
Bus
Matrix
Trigger
ITM
APB
i/f
ETM
TPIU
System Architecture
Trace port
(serial wire
or multi-pin)
Private
Peripheral
Bus
(external)
ROM
Table
I-code bus
D-code bus
System bus
Figure 2. Cortex®-M3 Block Diagram
Bus Architecture
The HT32F12345 device consists of four master and six slaves in the bus architecture. Cortex®-M3
ICode, DCode, System bus and Peripheral Direct Memory Access (PDMA) are the masters,
internal SRAM, internal Flash memory, AHB peripherals, external bus interface and two AHB
to APB bridges are the slaves. The ICode bus is used for instruction and vector fetches from Code
region (0x0000_0000 ~ 0x1FFF_FFFF) to Cortex-M3 core. The DCode bus is used for data load/
stores and debugging accesses of Code region. Similarly, the System bus is used for instruction/
vector fetches, data load/stores and debugging accesses of system regions. The system regions
include internal SRAM region and peripheral region. All of these master buses are based on 32-bit
Advanced High-performance Bus-Lite (AHB-Lite) protocol. The following gure shows the bus
architecture of the HT32F12345 device.
Rev. 1.10 36 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
ICodeDCode
Cortex®-M3
Processor
System
NVIC
Interrupt request
PDMA
12 Channels
DMA request
Figure 3. Bus Architecture
Bus Matrix
Flash Memory
Interface
PDMA
Control
Registers
FMC
Control
Registers
AHB
Peripherals
SRAM Controller
External Bus
Interafce
AHB to APB
Bridge
GPIO
A~D
CRC
-16/32
SDIO
Flash
Memory
Control Registers
SRAM
APB0 IPs
CKCU/RSTCU
USB
Control/Data
Registers
APB1 IPs
USB
Device
System Architecture
Memory Organization
Arm® Cortex®-M3 is structured in Harvard architecture which can use separate buses to fetch
instructions and load/store data. The instruction code and data bus share the same memory address
space but in different address ranges. The maximum addressing range of the Cortex®-M3 is 4 GB
since it has 32-bit bus address width. Additionally, a pre-dened memory map is provided by the
Cortex®-M3 to reduce the software complexity of repeated implementation of different device
venders. However, some regions are used by Arm® Cortex®-M3 system peripherals. Refer to Arm®
Cortex®-M3 Technical Reference Manual for more information. The following gure shows the
memory map of the device, including Code, SRAM, peripheral and other pre-dene regions.
Rev. 1.10 37 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Memory Map
Peripheral
SRAM
Code
0xFFFF_FFFF
0xE010_0000
0xE000_0000
0x7000_0000
0x6000_0000
0x4400_0000
0x4200_0000
0x4010_0000
0x4008_0000
0x4000_0000
0x2220_0000
0x2200_0000
0x2000_4000
0x2000_0000
0x1FF0_0400
0x1FF0_0000
0x1F00_2000
0x1F00_0000
0x0001_0000
Reserved
Private peripheral bus
Reserved
EBI Selection Bank
Reserved
APB/AHB bit band alias
Reserved
AHB peripherals
APB peripherals
Reserved
SRAM bit band alias
Reserved
16 KB on-chip SRAM
Reserved
Option byte alias
Reserved
Boot loader
Reserved
64 KB on-chip Flash
64 MB
x 4
32 MB
512 KB
512 KB
2 MB
16 KB
1 KB
8 KB
64 KB
0x400F_FFFF
0x400B_8000
0x400B_0000
0x400A_C000
0x400A_8000
0x400A_2000
0x400A_0000
0x4009_A000
0x4009_8000
0x4009_2000
0x4008_C000
0x4008_A000
0x4008_8000
0x4008_2000
0x4008_0000
0x4007_8000
0x4007_7000
0x4007_6000
0x4007_0000
0x4006_F000
0x4006_E000
0x4006_B000
0x4006_A000
0x4006_9000
0x4006_8000
0x4005_8000
0x4004_2000
0x4002_E000
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
GPIOA~D
Reserved
USB
Reserved
SDIO
Reserved
EBI
Reserved
PDMA0x4009_0000
Reserved
CRC-16/32
CKCU/RSTCU
Reserved
FMC
Reserved
BFTM1
BFTM0
Reserved
GPTM1
GPTM0
Reserved
RTC/PWRCU
Reserved
WDT
Reserved0x4005_9000
CMP
Reserved0x4004_A000
I2C10x4004_9000
I2C00x4004_8000
Reserved0x4004_5000
SPI10x4004_4000
Reserved
UART10x4004_1000
USART10x4004_0000
Reserved
MCTM1
MCTM0
Reserved
I2S
Reserved
EXTI
Reserved
AFIO
Reserved
ADC
Reserved
SPI0
Reserved
UART0
USART0
System Architecture
AHB
APB1
APB0
0x0000_0000
Figure 4. Memory Map
Rev. 1.10 38 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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_CFFFMCTM0
0x4002_D0000x4002_DFFFMCTM1
0x4002_E0000x4003_FFFFReserved
0x4004_00000x4004_0FFFUSART1
0x4004_10000x4004_1FFFUART1
0x4004_20000x4004_3FFFReserved
0x4004_40000x4004_4FFFSPI1
0x4004_50000x4004_7FFFReserved
0x4004_80000x4004_8FFFI2C0
0x4004_90000x4004_9FFFI2C1
0x4004_A0000x4005_7FFFReserved
0x4005_80000x4005_8FFFCMP
0x4005_90000x4006_7FFFReserved
0x4006_80000x4006_8FFFWDT
0x4006_90000x4006_9FFFReserved
0x4006_A0000x4006_AFFFRTC/PWRCU
0x4006_B0000x4006_DFFFReserved
0x4006_E0000x4006_EFFFGPTM0
0x4006_F0000x4006_FFFFGPTM1
0x4007_00000x4007_5FFFReserved
0x4007_60000x4007_6FFFBFTM0
0x4007_70000x4007_7FFFBFTM1
0x4007_80000x4007_FFFFReserved
System Architecture
APB0
APB1
Rev. 1.10 39 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Start AddressEnd AddressPeripheralBus
0x4008_00000x4008_1FFFFMC
0x4008_20000x4008_7FFFReserved
0x4008_80000x4008_9FFFCKCU/RSTCU
0x4008_A0000x4008_BFFFCRC-16/32
0x4008_C0000x4008_FFFFReserved
0x4009_00000x4009_1FFFPDMA Control Registers
0x4009_20000x4009_7FFFReserved
0x4009_80000x4009_9FFFEBI Control Registers
0x4009_A0000x4009_FFFFReserved
0x400A_00000x400A_1FFFSDIO
0x400A_20000x400A_7FFFReserved
0x400A_80000x400A_9FFFUSB Control Registers
0x400A_A0000x400A_BFFFUSB SRAM
0x400A_C0000x400A_FFFFReserved
0x400B_00000x400B_1FFFGPIOA
0x400B_20000x400B_3FFFGPIOB
0x400B_40000x400B_5FFFGPIOC
0x400B_60000x400B_7FFFGPIOD
0x400B_80000x400F_FFFFReserved
System Architecture
AHB
Rev. 1.10 40 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Embedded Flash Memory
The HT32F12345 device provides 64 KB on-chip Flash memory which is located at address
0x0000_0000. It supports bytes, halt-words and word access. Note that Flash memory only
supports read operation for Cortex®-M3 ICode or DCode bus access. Any write operation to the
Flash memory (via DCode bus) will cause a bus fault exception. The Flash memory has a capacity
of 64 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). The above programming
methods provide f lexibility to user for data storage and firmware upgrade purpose. For more
information, refer to the Flash Memory Controller section.
Embedded SRAM Memory
The HT32F12345 device contains up to 16 KB on-chip SRAM which is located at address
0x2000_0000. It supports bytes, half-words and full words access operations. In order to reduce
the time of read-modify-write operations, the Cortex®-M3 provides a bit-banding function to
perform a single atomic bit operation. Users can modify a single bit in SRAM bit-band region by
accessing the corresponding bit-band alias. For more information about bit-binding, refer to the
Arm® Cortex®-M3 Technical Reference Manual. The following formulas and examples show how
to access a bit in the bit-band region by calculate the bit-band alias.
System Architecture
Bit-band alias = Bit-band base + (byte offset × 32) + (bit number × 4)
For example, if you want to access bit 7 of address 0x2000_0200, the bit-band alias is:
Write to address 0x2200_401C causes the bit 7 of address 0x2000_0200 changed. On the contrary,
read address 0x2200_401C returns 0x01 or 0x00 according to the value of bit 7 at SRAM address
0x2000_0200.
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 peripheral clocks are always enabled after system reset. Access to
registers for these peripherals can be achieved directly via the AHB bus. Note that all peripheral
registers in AHB bus support only word access.
APB Peripherals
The address of APB peripherals ranges from 0x4000_0000 to 0x4007_FFFF. An APB to AHB
bridge provides access capability between the Cortex®-M3 and the APB peripherals. Additionally,
the APB peripheral clocks are disabled after a system reset. Software must enable peripheral clock
by setting up the APBCCRn registers in 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 APB peripheral register. In other
words, the access result of half-word or byte access on APB peripheral register will vary depending
on the data bit width of the access operation on the peripheral registers.
Rev. 1.10 41 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
4
Flash Memory Controller (FMC)
Introduction
The Flash Memory Controller, FMC, provides all the necessary functions, pre-fetch buffer and
branch cache for the embedded on-chip Flash memory. The 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 a pre-fetch buffer is provided to the Flash memory in order to reduce the CPU waiting timing
which will cause CPU instruction execution delay. The Flash memory word program / page erase
functions are also provided for instruction / data storage.
System Bus
I/D Code Bus
Flash Memory Controller
Control Register
Pre-fetch Buffer
Branch Cache
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
▄
64 KB of on-chip Flash memory for storing instruction / data and options
Wide access interface with pre-fetch buffer and branch cache to reduce instruction gaps
▄
Page erase and mass erase capability
▄
32-bit word programming
▄
Interrupt function to indicate end of Flash memory operations or an error occurs
▄
Flash read protection to prevent illegal code / data access
▄
Page erase / program protection to prevent unexpected operation
Rev. 1.10 42 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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 with a capacity of 4 KB. Additionally, the region addressed from
0x1FF0_0000 to 0x1FF0_03FF is the alias of Option Byte block with a capacity of 1 KB. The
memory mapping on system view is shown as below.
0x1FFF_FFFF
0x1FF0_0400
Flash Memory Controller (FMC)
Reserved
0x1FF0_0000
0x1F00_1000
0x1F00_0000
0x0000_0000
Figure 6. Flash Memory Map
Option Byte
Reserved
Boot Loader Block
Reserved
Main Flash Block
User Application
1 Kbytes
4 Kbytes
63 Kbytes
Rev. 1.10 43 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Memory Architecture
The Flash memory consists of 63 KB main Flash with 1 KB per page and an 4 KB Information
Block for the Boot Loader. The main Flash memory contains a total of 64 pages which can be
erased individually. The following table shows the base address, size and protection setting bit of
each page.
Table 4. Flash Memory and Option Byte
BlockNameAddressPage Protection BitSize
Page 00x0000_0000 ~ 0x0000_03FFOB_PP [0]1 KB
Page 10x0000_0400 ~ 0x0000_07FFOB_PP [1]1 KB
Page 20x0000_0800 ~ 0x0000_0BFFOB_PP [2]1 KB
Page 30x0000_0C00 ~ 0x0000_0FFFOB_PP [3]1 KB
.
.
.
Main Flash
Block
.
.
.
.
Page 600x0000_F000 ~ 0x0000_F3FFOB_PP [60]1 KB
Page 610x0000_F400 ~ 0x0000_F7FFOB_PP [61]1 KB
Page 620x0000_F800 ~ 0x0000_FBFFOB_PP [62]1 KB
Page 63
(Option Byte)
Information
Block
Notes:
1. Information Block stores boot loader, this block cannot be programmed or erased by user.
2. Option Byte is always located at last page of main Flash block.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
OB_CP [1]1 KB
Flash Memory Controller (FMC)
.
.
.
.
.
.
.
Wait State Setting
When the CPU clock, HCLK, is greater than the access speed of the Flash memory, the wait state
cycles must be inserted during the CPU fetch instructions or load data from Flash memory. The
wait state can be changed by setting the WAIT [2:0] bits of the Flash Cache and Pre-fetch Control
Register, CFCR. In order to match the wait state requirement, the following two rules shall be
considered.
▄
HCLK clock is changed from lower to higher:
Change the wait state setting rst and then switch the HCLK clock.
▄
HCLK clock is changed from higher to lower:
Switch the HCLK clock rst and then change the wait state setting.
The following table shows the relationship between the wait state cycle and HCLK. The default
wait state is 0 since the High Speed Internal oscillator HSI which operates at a frequency of 8 MHz is selected as the HCLK clock source after reset.
Table 5. Relationship between Wait State Cycle and HCLK
Wait State CycleHCLK
00 MHz < HCLK ≤ 24 MHz
124 MHz < HCLK ≤ 48 MHz
248 MHz < HCLK ≤ 72 MHz
372 MHz < HCLK ≤ 96 MHz
Rev. 1.10 44 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Booting Conguration
The system provides three kinds of booting mode which can be selected through BOOT0 and
BOOT1 pins. The BOOT0 and BOOT1 pins are sampled during a power-on reset or a system
reset. Once the logic value on these pins has been determined, the rst 4 words of vector will be
remapped to the corresponding source according to the booting mode. The booting modes are
shown in the following table.
Hard Fault Handler
0xC
NMI Handler
0x8
Program Counter
0x4
Initial Stack Point0x0
Table 6. Booting Modes
Booting mode selection pins
BOOT1BOOT0
00SRAMThe source of Vector is SBVT0 ~ SBVT3
01Boot LoaderThe source of Vector is Boot Loader
1XMain FlashThe source of Vector is main Flash
ModeDescriptions
The Vector Mapping Control Register (VMCR) is provided to change the setting of the vector
remapping setting temporarily after a device reset. The initial reset value of the VMCR register is
determined by the BOOT0 and BOOT1 pins which will be sampled during the reset duration.
Boot1 and Boot0 Setting
1x: Main Flash01: Boot Loader00: SRAM
+ 0xC
+ 0x8
+ 0x4
0x0000 0000
+ 0xC
+ 0x8
+ 0x4
0x1F00 0000
+ 0xC
+ 0x8
+ 0x4
SBVT3
SBVT2
SBVT1
SBVT00x4008 0300
Flash Memory Controller (FMC)
Figure 7. Vector Remapping
Rev. 1.10 45 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Page Erase
The FMC provides a page erase function which is used to initialize the contents of a Flash memory.
Any page can be erased independently without affecting others. The following steps show the
access sequence of the register for a page erase operation.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write the page address to TADR register
▄
Write the page erase command to OCMR register (CMD [3:0] = 0x8).
▄
Send the 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] equal to 0xE).
▄
Read and verify the page if required using DCODE access.
Note that a correct target page address must be conrmed. The software may run out of control
if the target erase page is being used for fetching code or access data. The FMC will not provide
any notication when this occurs. Additionally, the page erase operation will be ignored on the
protected pages. A Flash Operation Error interrupt will be triggered by the FMC if the OREIEN
bit in the OIER register is set. Software can check the PPEF bit in the OISR register to detect this
condition in the interrupt handler. The following gure shows the page erase operation ow.
Flash Memory Controller (FMC)
No
No
Start
Is OPM equal to 0xE or 0x6 ?
Yes
Set TADR, OCMR
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Yes
Finish
Figure 8. Page Erase Operation Flowchart
Rev. 1.10 46 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Mass Erase
The FMC provides a mass erase function which is used to initialize the complete Flash memory
contents to a high state. The following steps show the mass erase operation sequence.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write the mass erase command to the OCMR register (CMD [3:0] = 0xA).
▄
Send the mass erase command to the FMC by setting the OPCR register (set OPM [3:0] = 0xA).
▄
Wait until all operations have been completed by checking the value of the OPCR register
(OPM [3:0] equal to 0xE).
▄
Read and verify the Flash memory if required using DCODE access.
Since all Flash data will be reset as 0xFFFF_FFFF, the mass erase operation can be implemented
by an application that runs in the SRAM or by the debug tool that access the FMC register directly.
An application that executes on the Flash memory will not trigger a mass erase operation. The
following gure shows the mass erase operation ow.
Flash Memory Controller (FMC)
No
No
Start
Is OPM equal to 0xE or 0x6 ?
Yes
Set OCMR = 0xA
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Yes
Finish
Figure 9. Mass Erase Operation Flowchart
Rev. 1.10 47 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Word Programming
The FMC provides a 32-bit word programming function which is used to modify the Flash memory
contents. The following steps show the word programming register access sequence.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write the word address to the TADR register. Write data to WRDR register.
▄
Write the word program command to the OCMR register (CMD [3:0] = 0x4).
▄
Send the word program command to the FMC by setting the OPCR register (set OPM [3:0] = 0xA).
▄
Wait until all operations have been completed by checking the value of the OPCR register
(OPM [3:0] equal to 0xE).
▄
Read and verify the Flash memory if required using DCODE access.
Note that the word programming operation cannot be applied to the same address twice. Successive
word programming operation to the same address must be separated by a page erase operation.
Additional ly, the word programming operation will be ignored on protected pages. A Flash
Operation Error interrupt will be triggered by the FMC if the OREIEN bit in the OIER register is
set. Software can check the PPEF bit in the OISR register to detect this condition in the interrupt
handler. The following gure shows the word programming operation ow.
Flash Memory Controller (FMC)
No
No
Start
Is OPM equal to 0xE or 0x6 ?
Yes
Set TADR, WRDR
and OCMR
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Yes
Finish
Figure 10. Word Programming Operation Flowchart
Rev. 1.10 48 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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.
Table 7. Option Byte Memory Map
Option Byte OffsetDescriptionReset Value
Option Byte Base Address = 0x1FF0_0000
0x000
OB_PP
OB_CP0x010
OB_CK0x020
0x004
0x008
0x00C
OB_PP [n]: Main Flash Page Erase / program Protection
(n = 0 ~ 62 for page 0 ~ page 62)
0: Flash Page n Erase / Program Protection is
enabled
1: Flash Page n Erase / Program Protection is
disabled
(n = 63 ~ 127: Reserved)
OB_CP [0]: Flash Security Protection
0: Flash Security protection is enabled
1: Flash Security protection is disabled
OB_CP [1]: Option Byte Protection
0: Option Byte protection is enabled
1: Option Byte protection is disabled
OB_CP [31:2]: Reserved
OB_CK [31:0]: Flash Option Byte Checksum
OB_CK should be set as the sum of 5 words Option Byte
content, of which the offset address ranges form 0x000
to 0x010 (0x000 + 0x004 + 0x008 + 0x00C + 0x010),
when the OB_PP or OB_CP register content is not equal
to 0xFFFF_FFFF. Otherwise, both page erase / program
protection and security protection will be enabled.
Flash Memory Controller (FMC)
0xFFFF_FFFF
0xFFFF_FFFF
0xFFFF_FFFF
0xFFFF_FFFF
0xFFFF_FFFF
0xFFFF_FFFF
Rev. 1.10 49 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Page Erase / Program Protection
The FMC provides page erase / program protection functions to prevent inadvertent operations
on the Flash memory. The page erase or word programming command will not be accepted by
the FMC on the protected pages. When the page erase or word programming command is sent to
the FMC on a protected page, the PPEF bit in the OISR register will then be set by FMC. If the OREIEN bit in the OIER register is also set to 1 then the Flash operation error interrupt will be
triggered by the FMC. The page protection function can be individually enabled for each page by
conguring the OB_PP [127:0] bit eld in the Option Byte. The following table shows the access
permission of the main Flash page when the page protection is enabled.
Table 8. Access Permission of Protected Main Flash Page
Mode
Operation
DCODE ReadOOO
ProgramXXX
Page EraseXXX
Mass EraseOOO
Flash Memory Controller (FMC)
ISP/IAPICP/Debug ModeBoot from SRAM
Notes:
1. The write protection is based on specic pages. The above access permission only affects
the pages of which the protection function has been enabled. 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 page erase / program protection procedure register access sequence.
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the previous operation has been nished.
▄
Write the OB_PP address to the TADR register (TADR = 0x1FF0_0000).
▄
Write the data which indicates the protection function of corresponding page is enabled or disabled
into the WRDR register (0: Enabled, 1: Disabled).
▄
Write the word program command to the OCMR register (CMD [3:0] = 0x4).
▄
Commit the word program command to the FMC by setting the OPCR register (set OPM [3:0] =
0xA).
▄
Wait until all operations have been nished by checking the value of the OPCR register (OPM
[3:0] equal to 0xE).
▄
Read and verify the Option Byte if required using DCODE access.
▄
Before to activate the new OB_PP setting, the OB_CK must be updated according to the Option
Byte checksum rule.
▄
Apply a system reset to activate the new setting.
Rev. 1.10 50 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Security Protection
The FMC provides a security protection function to prevent illegal code / data access of the Flash
memory. This function is useful for protecting the software / rmware from the illegal users. The
function is activated by conguring the OB_CP [0] bit in the Option Byte. Once the function has
been enabled, all the main Flash DCODE access, programming and page erase operations will
not be allowed except for the user’s application. However, the mass erase operation will still be
accepted by the FMC in order to disable this security protection function. The following table
shows the access permission of Flash memory when the security protection is enabled.
Table 9. Access Permission When Security Protection is Enabled
Mode
Operation
DCODE ReadOX (read as 0)X (read as 0)
ProgramO
Page EraseO
Mass EraseOOO
Notes:
1. User application means the software that is executed or booted from the main Flash memory
with the JTAG/SW debugger being disconnected. However, the Option Byte block and
page 0 are still protected in which Programming and Page Erase operations cannot be
executed.
2. Mass erase operation can erase Option Byte block and disable security protection.
The following steps show the Security protection procedure register access sequence.
User Application
(1)
(1)
(1)
ICP / Debug ModeBoot from SRAM
XX
XX
Flash Memory Controller (FMC)
▄
Check the OPCR register to conrm that no Flash memory operation is in progress (OPM [3:0]
equal to 0xE or 0x6). Otherwise, wait until the pervious operation has been nished.
▄
Write the OB_CP address to the TADR register (TADR = 0x1FF0_0010).
▄
Write the data into the WRDR register to clear OB_CP [0] bit to 0.
▄
Write the word program command to the OCMR register (CMD [3:0] = 0x4).
▄
Send the word program command to the FMC by setting the OPCR register (set OPM = 0xA).
▄
Wait until all operations have been nished by checking the value of the OPCR register (OPM
[3:0] equals to 0xE).
▄
Read and verify the Option Byte if required using DCODE access.
▄
Before to activate the security protection function, the OB_CK eld must be update according to
the Option Byte checksum rule.
▄
Apply a system reset to activate the new setting.
Rev. 1.10 51 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Register Map
The following table shows the FMC registers and reset values.
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.10 52 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Register Descriptions
Flash Target Address Register – TADR
This register species the target address of the page erase and word programming operations.
Offset:0x000
Reset value:0x0000_0000
3130292827262524
TADB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
2322212019181716
TADB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
15141312111098
TADB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
76543210
TADB
Type/ResetRW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW 0
BitsFieldDescriptions
[31:0]TADBFlash Target Address Bits
For programming operations, the TADR register species the address where the
data is written. Since the programming length is 32-bit, the TADR should be set
as word-aligned (4 bytes). The TADB [1:0] will be ignored during programming
operations. For page erase operations, the TADR register contains the page
address which is going to be erased. Since the page size is 1 KB, the TADB [9:0]
will be ignored in order to limit the target address as 1 KB-aligned. For 64 KB
main Flash addressing, TADB [31:16] should be zero. The Option Byte which has
a 1 KB capacity ranges from 0x1FF0_0000 to 0x1FF0_03FF. This eld is used to
specify the Flash address which must be within the range from 0x0000_0000 to
0x1FFF_FFFF. Otherwise, an Invalid Target Address interrupt will be generated if
the corresponding interrupt enable bit is set.
Flash Memory Controller (FMC)
Rev. 1.10 53 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Write Data Register – WRDR
This register stores the data to be written into the TADR register 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.10 54 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Operation Command Register – OCMR
This register is used to specify the Flash operation commands that include word program, page erase and mass
erase.
Offset:0x00C
Reset value:0x0000_0000
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedCMD
Type/ResetRW 0 RW 0 RW 0 RW 0
BitsFieldDescriptions
[3:0]CMDFlash Operation Command
The following table shows the denitions of the operation command bits CMD [3:0]
which determine the Flash memory operation. If an invalid command is set and the
IOCMIEN is equal to 1, an Invalid Operation Command interrupt will be generated.
CMD [3:0]Description
0x0Idle – default
0x4Word program
0x8Page erase
0xAMass erase
OthersReserved
Flash Memory Controller (FMC)
Rev. 1.10 55 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Operation Control Register – OPCR
This register is used for controlling the command commitment and checking the status of the FMC operations.
Offset:0x010
Reset value:0x0000_000C
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedOPMReserved
Type/ResetRW 0 RW 1 RW 1 RW 0
Flash Memory Controller (FMC)
BitsFieldDescriptions
[4:1]OPMOperation Mode
The following table shows the operation modes of the FMC. User can commit the
command which is set by the OCMR register for the FMC according to the address
alias setting in the TADR register. The contents of the TADR, WRDR and OCMR
registers should be prepared before setting this register. After all the operations
have been finished, the OPM field will be set as 0xE by the FMC hardware.
The Idle mode can be set when all the operations have been nished for power
saving purpose. Note that the operation status should be checked before the next
operation is executed on the FMC. The content of the TADR, WRDR, OCMR and
OPCR registers should not be changed until the previous operation has been
nished.
OPM [3:0]Description
0x6Idle - default
0xACommit command to main Flash
0xEAll operation nished on main Flash
OthersReserved
Rev. 1.10 56 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Operation Interrupt Enable Register – OIER
This register is used to enable or disable the FMC interrupt function. 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.10 57 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Operation Interrupt and Status Register – OISR
This register indicates the status which is used 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 does not occur
1: Operation error occurs due to an invalid page erase / program operation
being applied to a protected page
This bit is reset by hardware once a new Flash operation command is committed.
[16]RORFFRaw Operation Finished Flag
0: The last ash operation command is has not yet nished
1: The last ash operation command has nished
This bit is directly connected to the 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 Flash operation error such as an invalid command,
program error and erase error, etc. occurs. 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 occur if the OBEIEN bit in the OIER register is set. However,
the Option Byte Check Sum Error Flag has to wait until the interrupt condition is
cleared, this bit will be reset by software writes 1, which means the Option Byte
check sum value has been modied to correct one. 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.10 58 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
BitsFieldDescriptions
[1]ITADFInvalid Target Address Flag
0: The target address is valid
1: The target address TADR is invalid
The data in the TADR field must be within the range from 0x0000_0000 to
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 Page Erase / program Protection Status Register – PPSR
This register indicates the page erase / program protection status of the Flash memory.
Offset:0x020 (0) ~ 0x02C (3)
Reset value:0xXXXX_XXXX
Flash Memory Controller (FMC)
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
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 the specific 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] bits. The other remained bits of OB_PP and PPSR registers
are reserved.
Rev. 1.10 59 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Security Protection Status Register – CPSR
This register indicates the Flash memory security protection status. The content of this register is not dynamically
updated and will only be reloaded by the Option Byte loader which is active when any kind of reset occurs.
Offset: 0x030
Reset value:0x0000_000X
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] bit.
[0]CPSBFlash Memory 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] bit.
Flash Memory Controller (FMC)
Rev. 1.10 60 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Vector Mapping Control Register – VMCR
This register is used to control the vector mapping. The reset value of the VMCR register is determined by the
external booting pins, BOOT0 and BOOT1, during the power-on reset period.
Offset:0x100
Reset value:0x0000_000X
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
Reserved
Type/Reset
76543210
ReservedVMCB
Type/ResetRW X RW X
BitsFieldDescriptions
[1:0]VMCBVector Mapping Control Bit
The VMCB bits are used to control the mapping source of first 4-word vector
addressed from 0x0 to 0xC. The following table shows the vector mapping setting.
BOOT1BOOT0 VMCB [1:0]Descriptions
LowLow00
LowHigh01
SRAM booting mode
The vector mapping source is SBVT0 ~ 3.
Boot Loader mode
The vector mapping source is the boot loader
area.
Flash Memory Controller (FMC)
HighLow10
HighHigh11
The reset value of the VMCB register is determined by the pins status of the
external booting pins BOOT1 and BOOT0 during power on reset and system reset.
The vector mapping setting can be changed temporarily by conguring the VMCB
bits when the application is running.
Rev. 1.10 61 of 590November 28, 2018
Main Flash mode
The vector mapping source is the main Flash
area.
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Manufacturer and Device ID Register – MDID
This register is used to store the manufacture ID and device part number information which can be used as the
product identity.
Offset:0x180
Reset value:0x0376_XXXX
3130292827262524
MFID
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 1 RO 1
2322212019181716
MFID
Type/ResetRO 0 RO 1 RO 1 RO 1 RO 0 RO 1 RO 1 RO 0
15141312111098
ChipID
Type/ResetRO 0 RO 0 RO 0 RO 1 RO X RO X RO X RO X
76543210
ChipID
Type/ResetRO 0 RO 1 RO 0 RO 1 RO 0 RO 0 RO 1 RO 0
BitsFieldDescriptions
[31:16]MFIDManufacturer ID
Read as 0x0376.
[15:0]ChipIDChip ID
Read the last 4 digital code of the MCU device part number.
Flash Memory Controller (FMC)
Rev. 1.10 62 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Page Number Status Register – PNSR
This register is used to indicate the Flash memory page number.
Offset:0x184
Reset value:0x0000_00XX
3130292827262524
PNSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
2322212019181716
PNSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
15141312111098
PNSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
76543210
PNSB
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
Flash Memory Controller (FMC)
BitsFieldDescriptions
[31:0]PNSBFlash Page Number Status Bits
0x0000_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
They indicated the total pages of the on-chip Flash memory device.
Rev. 1.10 63 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Page Size Status Register – PSSR
This register is used to indicate the page size in bytes.
Offset:0x188
Reset value:0x0000_0400
3130292827262524
PSSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
2322212019181716
PSSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
15141312111098
PSSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 1 RO 0 RO 0
76543210
PSSB
Type/ResetRO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO 0
Flash Memory Controller (FMC)
BitsFieldDescriptions
[31:0]PSSBFlash Page Size Status Bits
0x200: 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.10 64 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Device ID Register – DID
This register is used to store the device part number information which can be used as the product identity.
Offset:0x18C
Reset value:0x000X_XXXX
3130292827262524
Reserved
Type/Reset
2322212019181716
ReservedChipID
Type/ResetRO X RO X RO X RO X
15141312111098
ChipID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
76543210
ChipID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
Flash Memory Controller (FMC)
BitsFieldDescriptions
[19:0]ChipIDChip ID
Read the complete 5 digital code of the MCU device part number.
Rev. 1.10 65 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Flash Pre-fetch Control Register – CFCR
This register is used for controlling the FMC cache and pre-fetch module.
Offset:0x200
Reset value:0x0000_1091
3130292827262524
Reserved
Type/Reset
2322212019181716
Reserved
Type/Reset
15141312111098
ReservedCEReserved
Type/ResetRW 1
76543210
DCDBReservedPFBEReservedWAIT
Type/ResetRW 1RW 1RW 0 RW 0 RW 1
Flash Memory Controller (FMC)
BitsFieldDescriptions
[12]CEBranch Cache Enable Bit
0: Cache is disabled
1: Cache is enabled
[7]DCDBDCODE Data Cacheable Control Bit
0: DCODE Data Access is Cacheable
1: DCODE Data Access is Non-Cacheable
[4]PFBEPre-fetch Buffer Enable Bit
0: Pre-fetch buffer is disabled
1: Pre-fetch buffer is enabled
The pre-fetch buffer is enabled in default state. When the pre-fetch buffer is
disabled, the instruction and Data are provided by the Flash memory directly.
[2:0]WAITFlash Wait State Setting
The WAIT [2:0] are used to set the HCLK wait clock during non-sequential
address Flash access. The actual value of the wait clocks is given by (WAIT
[2:0] - 1). Since a wide access interface with a pre-fetch buffer and branch
cache 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
011248 MHz < HCLK ≤ 72 MHz
Others372 MHz < HCLK ≤ 96 MHz
Rev. 1.10 66 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
SRAM Booting Vector Register n – SBVTn, n = 0 ~ 3
These registers specify the initial values of Stack Point, Program Counter, NMI Handler address and Hard Fault
Handler address for the SRAM Booting mode.
Offset:0x300 (0) ~ 0x30C (3)
Reset value:Various depending on the address offset
3130292827262524
SBVTn
Type/ResetRW X RW X RW X RW X RW X RW X RW X RW X
2322212019181716
SBVTn
Type/ResetRW X RW X RW X RW X RW X RW X RW X RW X
15141312111098
SBVTn
Type/ResetRW X RW X RW X RW X RW X RW X RW X RW X
76543210
SBVTn
Type/ResetRW X RW X RW X RW X RW X RW X RW X RW X
BitsFieldDescriptions
[31:0]SBVTnSRAM Booting Vector n ( n = 0 ~ 3 )
The SRAM Booting Vector 0 ~ 3 provide a SRAM booting capability for
applications debugging. The contents of the SBVTn registers are re-mapped into
addresses 0x0 ~ 0xC of the Flash memory CODE area under SRAM booting
mode. Refer to the description of the VCMR register and BOOT1 / BOOT0 boot
pins. The following table shows the purpose and reset value of the SBVTn register.
The reset value provides a xed setting for program execution during the SRAM
booting mode. Those registers can be modied by the debugging tool in order to
change the program execution setting. The reset values of SBVTn will be reloaded
only by a power-on reset. Other reset sources will have no effect.
NameAddress Offset Purpose DescriptionsReset Value
SBVT00x300Stack point16 KB SRAM: 0x2000_4000
SBVT10x304Program counter0x2000_0155
SBVT20x308NMI handler address0x0000_0000
SBVT30x30C
This access width of the registers SBVT0 ~ SBVT3 must be 32 bits (Word access),
8 or 16 bits (Byte or Half-Word) access is not allowed.
Hard fault handler
address
0x0000_0000
Flash Memory Controller (FMC)
Rev. 1.10 67 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Custom ID Register n – CIDRn, n = 0 ~ 3
This register is used to store the custom ID information which can be used as the custom identity.
Offset:0x310 (0) ~ 0x31C (3)
Reset value:Various depending on Flash Manufacture Privilege Information Block
3130292827262524
CID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
2322212019181716
CID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
15141312111098
CID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
76543210
CID
Type/ResetRO X RO X RO X RO X RO X RO X RO X RO X
Flash Memory Controller (FMC)
BitsFieldDescriptions
[31:0]CIDnCustom ID
Read as the CIDn[31:0] (n = 0 ~ 3) field in the Custom ID registers in Flash
Manufacture Privilege Block.
Rev. 1.10 68 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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
V
BAK
PWRSW
WKUP1
WKUP2
LSI
LSE
WKUP3
PORB
BREG
Backup Domain
Power On Reset
BAK
RTC
PORB: V
BREG: Backup Registers
PWR_CTRL
LDO: Voltage Regulator
DMOS: Depletion MOS
LDOOFF
LCM
DMOSON
WKUP4
SLEEPDEEP
SLEEPING
V
DD
VDDDomain
LDO
DMOS
HSE
1.5 V Domain
CPUMemories
APB
INTF
LVD: Low Voltage Detector
POR/PDR: Power On Reset/Power Down Reset
PLL
HSI
3.3 V
POR/PDR
LVD
1.5 V
POR/PDR
Digital
Peripheral
CLDO
V
DD15
Power Control Unit (PWRCU)
Figure 11. PWRCU Block Diagram
Rev. 1.10 69 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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
▄
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
▄
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
voltage.
PDR
BOD
Power Control Unit (PWRCU)
.
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.
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.
, 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.10 70 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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.
LDO Power Control
The LDO will be automatically switched off when one of the following conditions occurs:
▄
The Power-Down or Deep-Sleep 2 mode is entered.
▄
The control bits BODEN = 1, BODRIS = 0 and the supply power VDD ≤ V
▄
The supply power VDD ≤ V
The LDO will be automatically switched on by hardware when the supply power VDD > V
of the following conditions occurs:
PDR
which constantly supplies power when the 1.5 V
BAK
.
BOD
POR
Power Control Unit (PWRCU)
if any
▄
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 operates in the Deep-Sleep 2
mode for data retention purposes in the V
power domain.
DD15
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 of the power on / power down reset
threshold voltage, refer to the electrical characteristics of the corresponding datasheet.
= High current mode) or low
OUT
PDR
,
Rev. 1.10 71 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
V
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.
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.
Time
LV D
, refer to
BOD
, refer
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.
Rev. 1.10 72 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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, DMOSONand 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 field 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
CPU clock will be stopped.
Peripherals, Flash and SRAM clocks can be stopped by setting.
Stop all clocks in the 1.5 V power domain.
Disable HSI, HSE and PLL.
Turning on the LDO low current mode or DMOS to reduce the 1.5 V power
domain current.
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.
Rev. 1.10 73 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Table 12. Enter / Exit Power Saving Modes
Mode
Instruction
Sleep
Deep-Sleep1100
Deep-Sleep21X1
Power-Down110
WFI or WFE
CPU
(Takes
effect)
Mode Entry
CPU
SLEEPDEEP
0XX
LDOOFF DMOSON
Mode Exit
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)
(2)
(2)
or
or
or
(1)
or
Power Control Unit (PWRCU)
Notes:
1. Wakeup event means EXTI line in event mode, RTC, LVD and WAKEUP pin rising edge
2. If the system allows the LVD activity to wake it up after the system has entered the power
saving mode, 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 an 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.
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. An RTC wakeup trigger event, an 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
DD
/ V
) and the Backup Domain power (V
DDA
BAK
).
Rev. 1.10 74 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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.
Table 13. Power Status after System Reset
BAKPORF PDF PORSTFDescription
101
001
011Restart from the Power-Down mode.
11xReserved
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, …)
is applied for the rst time or executing
BAK
Power Control Unit (PWRCU)
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
PWRCU Base Address = 0x4006_A000
BAKSR0x100Backup Domain Status Register0x0000_0001
BAKCR0x104Backup Domain Control Register0x0000_0000
BAKTEST0x108Backup Domain Test Register0x0000_0027
LVDCSR0x110
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
backup power domain.
BAK
Low Voltage / Brown Out Detect Control and
Status Register
0x0000_0000
Rev. 1.10 75 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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
Power Control Unit (PWRCU)
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 (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
Rev. 1.10 76 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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
DMOSONReservedLDOFTRMLDOOFFLDOLCMReservedBAKRST
Type/ResetRW 0RW 0 RW 0 RW 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
POR
DD15
Setting this bit to determine what control signal of isolation cells is used to disable
the isolation function of the V
to VDD power domain level shifter.
DD15
0: Disable WAKEUP pin interrupt function
1: Enable WAKEUP pin interrupt function
The software can set the WUPIEN bit to 1 to assert the LPWUP interrupt in the NVIC
unit when both the WUPEN and WUPF bits are set to1.
Rev. 1.10 77 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
BitsFieldDescriptions
[8]WUPENExternal WAKEUP Pin Enable
0: Disable WAKEUP pin function
1: Enable WAKEUP pin function
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 PCPD [15] to 1 in
the PCPDR register, the PCPU [15] to 0 in the PCPUR register and the PCCFG15
eld to 0x01 in the GPCCFGHR 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 nished 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 32 kHz 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.
[5:4]LDOFTRMLDO Output Voltage Fine Trim
00: The LDO default output voltage.
01: The LDO default output voltage offset -5 %
10: The LDO default output voltage offset +3 %
11: The LDO default output voltage offset +7 %
These bits will be clear to 0 when the LDO is power down or VDD power domain
reset.
[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 VDD15 power is not available
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 10 mA 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 Control Unit (PWRCU)
Rev. 1.10 78 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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.
Low Voltage / Brown Out Detect Control and Status Register – LVDCSR
This register species ags, enable bits and option bits for Low-voltage / Brown-out 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 flag 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.
[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 enters the Deep-Sleep2 (DMOS is turn on and LDO is power down) or
Power-Down mode (DMOS and LDO is power down), the LVDEWEN bit has to be
enabled to avoid the LDO does not activate in the meantime when the CPU is woken
up by the low voltage detection activity.
[3]BODFBrow Out Detect Flag
0: VDD > V
1: VDD ≤ V
[1]BODRISBOD Reset or Interrupt Selection
0: Reset the whole chip
1: Generate Interrupt
[0]BODENBrown Out Detector Enable
0: Disable Brown Out Detector
1: Enable Brown Out Detector
BOD
BOD
power is lower than
DDA
Power Control Unit (PWRCU)
Rev. 1.10 80 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Backup Register n – BAKREGn, n = 0 ~ 9
This register species backup register n for storing data during the V
power-off period.
DD15
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
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
Power Control Unit (PWRCU)
Rev. 1.10 81 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
6
Clock Control Unit (CKCU)
Introduction
The Clock Control unit (CKCU) provides functions of high speed internal RC oscillator (HSI),
clock multiplexer and clock gating. The clock of AHB, APB and CPU are derived from system
clock (CK_SYS) which can come from HSI, HSE, LSI, LSE or PLL. Watchdog Timer and Real
Time Clock (RTC) use either LSI or LSE as their clock source. The maximum operating frequency
of system clock f
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
source to HSI clock to prevent system halt.
Features
▄
4 to 16 MHz external crystal oscillator – HSE
▄
Internal 8 MHz RC oscillator (HSI) with conguration option calibration and custom trimming
capability
▄
PLL with selectable clock source, either from HSE or HSI, for system clock
▄
32,768 Hz external crystal oscillator (LSE) for Watchdog Timer or RTC or system clock
▄
Internal 32 kHz RC oscillator (LSI) for Watchdog Timer, RTC or system clock
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.
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.
Clock Control Unit (CKCU)
OSC_EN
XTALOUTXTALIN
Crystal
4 MHz ~ 16 MHz
CL1CL2
Figure 14. External Crystal, Ceramic and Resonators for HSE
Rev. 1.10 84 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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. While switching on the HSE, 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 than the HSE crystal oscillator. An interrupt can be generated if the related
interrupt enable bit HSIRDYIE in the Global Clock Interrupt Register (GCIR) is set as the HSI
becomes stable. The HSI clock can also be used as the PLL input clock.
Clock Control Unit (CKCU)
The 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 the Power Saving Wakeup RC Clock Enable bit PSRCEN to 1 to force
HSI clock to be system clock when wake-up from Deep-Sleep or Power-Down mode. Subsequently,
the system clock is back to the original clock source if the original clock source ready f lag is
asserted. This function can reduce the wakeup time when using HSE or PLL as 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 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 Figure 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 may be affected by voltage or
temperature variations. If the application has to be driven by a 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 (ATC) together with an
external reference clock in the application. The reference clock can be provided from the following
clock sources:
This PLL can provide 8 ~ 96 MHz clock output which is 2 ~ 24 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 (CP), a built-in loop filter and a
voltage-controlled oscillator (VCO) to achieve a stable phase-locked state.
CLK
= 4 ~ 16 MHz
Ref. Divider
IN
(NR)
/2
PD
CPVCO
Loop
Filter
= 128 ~ 192 MHz
VCO
out
Output Divider 1
(NO1)
Clock Control Unit (CKCU)
Output Divider 2
(NO2)
/2
S1 ~ S0
PLL
out
= 8 ~ 96 MHz
Feedback Divider 2
B4 ~ B0
Figure 16. PLL Block Diagram
Frequency of the PLL output clock can be determined by the following formula:
Considering the duty cycle with 50 %, both input frequency and output frequency is divided by 2.
Assume that 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 the expense of the settling time. The output and feedback divider 2 setup value are
described in Table 15 and Table 16. All the conguration bits (S1 ~ S0, B4 ~ B0) in Table 15 and
Table 16 are defined in the PLL Configuration Register (PLLCFGR) and PLL Control Register
(PLLCR) in the section of Register Denition. Note that VCO
from 128 MHz to 192 MHz. If the selected configuration exceeds this range, the PLL output
frequency cannot be guaranteed to match the above PLL
(NF2)
Feedback Divider 1
(NF1)
/4
NFNF
CKPLL
21
CK
NONONR
21
OUT
NF
24
CK
NO
222
frequency should be in the range
OUT
2
NF
INININOUT
2
NO
formula.
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.
This USB PLL can provide 4 ~ 48 MHz clock output for USB peripheral which is 2 ~ 24 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 (CP), a built-in loop lter
and a voltage-controlled oscillator (VCO) to achieve a stable phase-locked state.
CLK
= 4 ~ 16 MHz
Figure 17. USB PLL Block Diagram
Ref. Divider
IN
(NR)
/2
PD
Feedback Divider 2
(NF2)
B3 ~ B0
CPVCO
Loop
Filter
Feedback Divider 1
(NF1)
/4
= 48 ~ 96 MHz
VCO
out
Output Divider 1
(NO1)
/2
Output Divider 2
(NO2)
S1 ~ S0
PLL
out
= 4 ~ 48 MHz
Rev. 1.10 88 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Frequency of the PLL output clock can be determined by the following formula:
Considering the duty cycle with 50 %, both input frequency and output frequency is divided by
2. Assume that a given CLKIN frequency as USB PLL input generates a specic USB 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 the expense of the settling time. The output and feedback divider 2 value
are described in Table 15 and Table 16. All the conguration bits (S1 ~ S0, B3 ~ B0) in Ta bl e 17
and Ta ble 18 are dened in the PLL Conguration Register (PLLCFGR) and PLL Control Register
(PLLCR) in the section of Register Denition. Note that VCO
is ranged from 48 MHz to 96
OUT
MHz. If your configurations exceed this range, the output frequency of USB PLL will not be
promised to match the above PLL
formula.
OUT
The USB PLL can be switched on or off by using the USBPLLEN bit in the Global Clock Control
Register (GCCR). The USBPLLRDY ag in the Global Clock Status Register (GCSR) will indicate
if the USB PLL clock is stable. An interrupt can be generated if the related interrupt enable bit
USBPLLRDYIE in the Global Clock Interrupt Register (GCIR) is set as the USB PLL becomes
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 circuits of Real-Time-Clock peripheral,
Watchdog Timer or system clock. The associated hardware conguration 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.768 kHz
X32KOUT
C
L2
Figure 18. External crystal, Ceramic and Resonators for LSE
Low Speed Internal RC Oscillator – LSI
The low speed internal RC oscillator with frequency of about 32 kHz produces a low power clock
source for the circuits of Real-Time-Clock peripheral, Watchdog Timer or system clock. The LSI
offers a low 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 ag 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
CKCU provides the corresponding clock ready flags for the HIS, HSE, PLL, LSI and LSE to
indicate whether these clocks are stable. Before using them as system clock source or other
purpose, it is necessary to confirm the specific clock ready flag is set. Software can check if
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 is set. Software should clear the interrupt status bit
in the GCIR register by interrupt service routine.
Rev. 1.10 90 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
System Clock (CK_SYS) Selection
After the system reset occurs, the high speed internal RC oscillator HSI is selected as the system
clock (CK_SYS). 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 via the System Clock Switch bits (SW) in the
Global Clock Control Register (GCCR). The system will still run under the original clock until the
destination clock gets ready when the SW value is changed. The corresponding clock ready status
bits in the Global Clock Status Register (GCSR) will indicate whether the selected clock is ready to
use or not. The CKCU also contains the clock source status bits in the Clock Source Status Register
CKST to indicate which clock is currently used as system clock. If a clock source or the PLL output
clock is used as system clock, it is not possible to stop it. More detail about function of clock enable
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.
● 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.
Clock Control Unit (CKCU)
▄
Enable any source clock which will become system clock or PLL input clock.
▄
Conguring the PLLSRC register after the ready ags of both HSI and HSE are asserted.
▄
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 system clock is stuck at
0/1.
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). This function should be enabled after the HSE startup delay and be disabled when the HSE oscillator is stopped. Once the HSE failure is detected,
the HSE will automatically be disabled. The HSE Clock Stuck Flag CKSF in the Global Clock
Interrupt Register, GCIR, will be set and the HSE failure event will be generated if the Clock Fail
Interrupt Enable bit CKSIE in the GCIR register is set. This failure interrupt is connected to the
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.
Rev. 1.10 91 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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 section, AFIO, 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.
Table 19. CKOUT Clock Source
Register Map
The following table shows the CKCU register and reset value.
000: When Chip is in running mode
001: When Chip wants to enter Sleep mode
010: When Chip wants to enter Deep Sleep mode 1
011: When Chip wants to enter Deep Sleep mode 2
100: When Chip wants to enter Power Down mode
Others: Reserved
Set and reset by software to control PLL clock source.
[2:0]CKOUTSRCCKOUT 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 to control CKOUT clock source.
Global Clock Control Register – GCCR
This register species the clock enable bits.
Offset:0x004
Reset value: 0x0000_0803
Clock Control Unit (CKCU)
3130292827262524
Reserved
Type/Reset
2322212019181716
ReservedPSRCENCKMEN
Type/ResetRW 0 RW 0
15141312111098
ReservedHSIENHSEENPLLENHSEGAIN
Type/ResetRW 1RW 0 RW 0 RW 0
76543210
ReservedUSBPLLENSW
Type/ResetRW 0RW 0 RW 1 RW 1
BitsFieldDescriptions
[17]PSRCENPower Saving Wakeup RC Clock Enable
0: No action
1: Use Internal 8 MHz RC clock (HSI) as system clock after Deep Sleep 1/2
wakeup
The software can set the PSRCEN bit high before entering the Deep Sleep 1 or
Deep Sleep 2 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 Deep Sleep 1 or Deep Sleep 2 mode. This means that the
instruction can be executed before the original CK_SYS source is stable since the
HSI clock is provided to CPU. After the original clock source is ready, the CK_SYS
clock will automatically be switched back to the original.
When the hardware detects that the HSE clock stuck at a low or high state, the
internal hardware will switch the system clock to the internal high speed HSI RC
clock.
[11]HSIENInternal High Speed Clock Enable
0: Internal 8 MHz RC oscillator clock is disabled
1: Internal 8 MHz RC oscillator clock is enabled
Set and reset by software. This bit cannot be reset if HSI clock is used as system
clock.
Set and reset by software. This bit cannot be reset if the HSE clock is used as
system clock or the PLL input clock.
[9]PLLENPLL Enable
0: PLL is disabled
1: PLL is enabled
Set and reset by software to enable PLL. This bit cannot be reset if the PLL clock is
used as system clock.
[8]HSEGAINExternal High Speed Clock Gain Selection
0: HSE is in low gain mode
1: HSE is in high gain mode
[3]USBPLLEN USB PLL Enable
0: USB PLL is disabled
1: USB PLL is enabled
Set and reset by software to enable USB PLL. This bit cannot be reset if the PLL
clock is used as system clock.
[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
This bit eld is set and reset by software to select the CK_SYS clock source. The
HSI oscillator will be forced as the when the HSE oscillator clock failure is detected,
where the HSE is used directly or indirectly as system clock, as the clock monitor is
enabled.
Note: When switching the system clock using the SW bit, the system clock will not
be immediately switched and a certain delay is necessary. The system clock source
selected by the SW bits can be indicated in the CKSWST bits in the clock source
status register CKST to make sure which clock is currently used as the system
clock.
Clock Control Unit (CKCU)
Rev. 1.10 95 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
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
ReservedLSIRDYLSERDYHSIRDYHSERDYPLLRDYUSBPLLRDY
Type/ResetRO 1 RO 0 RO 1 RO 0 RO 0 RO 0
Clock Control Unit (CKCU)
BitsFieldDescriptions
[5]LSIRDYInternal Low Speed Clock Ready Flag
0: Internal 32 kHz RC oscillator clock is not ready
1: Internal 32 kHz RC oscillator clock is ready
Set by hardware to indicate whether the LSI is stable to be used.
[4]LSERDYExternal Low Speed Clock Ready Flag
0: External 32,768 Hz crystal oscillator clock is not ready
1: External 32,768 Hz crystal oscillator clock is ready
Set by hardware to indicate whether the LSE is stable to be used.
[3]HSIRDYInternal High Speed Clock Ready Flag
0: Internal 8 MHz RC oscillator clock is not ready
1: Internal 8 MHz RC oscillator clock is ready
Set by hardware to indicate whether the HSI is stable to be used.
[2]HSERDYExternal High Speed Clock Ready Flag
0: External 4 ~ 16 MHz crystal oscillator clock is not ready
1: External 4 ~ 16 MHz crystal oscillator clock 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 is stable to be used.
[0]USBPLLRDY USB PLL Clock Ready Flag
0: USB PLL is not ready
1: USB PLL is ready
Set by hardware to indicate whether the USB PLL is stable to be used.
Rev. 1.10 96 of 590November 28, 2018
32-Bit Arm® Cortex®-M3 MCU
HT32F12345
Global Clock Interrupt Register – GCIR
This register species interrupt enable and ag bits.