Page 5
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port A Output Data Register – PADOUTR ..................139 Port A Output Set/Reset Control Register – PASRR ..............140 Port A Output Reset Register – PARR ..................141 Port B Data Direction Control Register – PBDIRCR ..............142 Port B Input Function Enable Control Register –...
Page 6
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions ......................178 EXTI Source Selection Register 0 – ESSR0 ................178 EXTI Source Selection Register 1 – ESSR1 ................179 GPIO x Configuration Low Register – GPxCFGLR, x = A, B, C, D ..........180 GPIO x Configuration High Register –...
Page 7
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Map ........................205 Register Descriptions ......................206 ADC Conversion Control Register – ADCCR ................206 ADC Conversion List Register 0 – ADCLST0 ................208 ADC Conversion List Register 1 – ADCLST1 ................209 ADC Input Sampling Time Register –...
Page 11
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 18 Real Time Clock (RTC) ..................427 Introduction ........................427 Features ..........................427 Functional Descriptions ..................... 428 RTC Related Register Reset ......................428 Reading RTC Register ........................428 Low Speed Clock Configuration ....................428 RTC Counter Operation ........................
Page 12
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bus Error ............................453 Address Mask Enable ........................453 Address Snoop ..........................453 Operation Mode ..........................453 Conditions of Holding SCL Line ....................459 C Timeout Function ........................460 PDMA Interface ..........................460 Register Map ........................
Page 13
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Function Descriptions ......................500 Serial Data Format ........................500 Baud Rate Generation ........................501 Hardware Flow Control ......................... 502 IrDA ............................... 504 RS485 Mode ..........................506 Synchronous Master Mode ......................509 Interrupts and Status ........................511 PDMA Interface ..........................511...
Page 14
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Elementary Time Unit Counter ...................... 539 Guard Time Counter ........................541 Waiting Time Counter ........................542 Card Clock and Data Selection ..................... 543 Card Detection ..........................543 SCI Data Transfer Mode ....................... 544 Interrupt Generator ........................
Page 15
Cortex ® -M0+ MCU HT32F52342/HT32F52352 USB Endpoint 1 ~ 3 Control and Status Register – USBEPnCSR, n = 1 ~ 3 ....... 581 USB Endpoint 1 ~ 3 Interrupt Enable Register – USBEPnIER, n = 1 ~ 3 ........582 USB Endpoint 1 ~ 3 Interrupt Status Register –...
Page 16
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bus Turn-around and Idle Cycles ....................616 AHB Transaction Width Conversion ..................... 617 EBI Bank Access .......................... 619 PDMA Request ..........................620 Register Map ........................620 Register Descriptions ......................620 EBI Control Register – EBICR ...................... 620 EBI Status Register –...
Page 17
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 CRC Checksum Register – CRCCSR ..................654 CRC Data Register – CRCDR ...................... 655 Rev. 1.30 17 of 656 September 28, 2018...
Page 18
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 List of Tables Table 1. Series Features and Peripheral List ..................32 Table 2. Document Conventions ......................34 Table 3. Register Map ..........................39 Table 4. Flash Memory and Option Byte ....................44 Table 5.
Page 19
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Table 40. Compare Match Output Setup ....................407 Table 41. SCTM Register Map ......................410 Table 42. LSE Startup Mode Operating Current and Startup Time ............428 Table 43. RTCOUT Output Mode and Active Level Setting ..............430 Table 44.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Introduction Overview This user manual provides detailed information including how to use the devices, system and bus architecture, memory organization and peripheral instructions. The target audiences for this document are software developers, application developers and hardware developers. For more information regarding pin assignment, package and electrical characteristics, please refer to the datasheet.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Core ● 32-bit Arm ® Cortex ® -M0+ processor core ● Up to 48 MHz operating frequency ● 0.93 DMIPS/MHz (Dhrystone v2.1) ● Single-cycle multiplication ● Integrated Nested Vectored Interrupt Controller (NVIC) ●...
Page 28
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 ▄ Analog to Digital Converter – ADC ● 12-bit SAR ADC engine ● Up to 1 MSPS conversion rate ● Up to 12 external analog input channels ▄ Analog Comparator – CMP ●...
Page 29
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 ▄ Single Channel Generation and Capture Timers – SCTM ● One 16-bit up and auto-reload counter ● One channel for each timer ● 16-bit programmable prescaler allowing dividing the counter clock frequency by any factor between 1 and 65536 ●...
Page 30
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 ▄ Universal Asynchronous Receiver Transmitter – UART ● Asynchronous serial communication operating baud-rate up to (f /16) MHz PCLK ● Capability of full duplex communication ● Fully programmable characteristics of serial communication including: word length, parity bit, stop bit and bit order ●...
Page 31
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 ▄ External Bus Interface – EBI ● Programmable interface for various memory types ● Translate the AHB transactions into the appropriate external device protocol ● Individual chip select signal for per memory bank ●...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Device Information Table 1. Series Features and Peripheral List Peripherals HT32F52342 HT32F52352 Main Flash (KB) 127.5 Option Bytes Flash (KB) SRAM (KB) MCTM GPTM SCTM Timers BFTM USART Communication UART SCI (ISO7816-3)
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Document Conventions The conventions used in this document are shown in the following table. Table 2. Document Conventions Notation Example Description The number string with a 0x prefix indicates a hexadecimal 0x5a05 number.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 System Architecture The system architecture of devices that includes the Arm ® Cortex ® -M0+ processor, bus architecture and memory organization will be described in the following sections. The Cortex ® -M0+ is a next generation processor core which offers many new features.
Figure 2. Cortex ® -M0+ Block Diagram Bus Architecture The HT32F52342/52352 series consist of two masters and five slaves in the bus architecture. The Cortex -M0+ AHB-Lite bus and Peripheral Direct Memory Access (PDMA) are the masters while ® the internal SRAM access bus, the internal Flash memory access bus, the AHB peripherals access bus, External Bus Interface (EBI) and the AHB to APB bridges are the slaves.
Cortex -M0+ ® ® ® ® Technical Reference Manual for more information. The following figure shows the memory map of HT32F52342/52352 series of devices, including Code, SRAM, peripheral, and other pre-defined regions. Rev. 1.30 37 of 656 September 28, 2018...
Programming (IAP) or In Circuit Programming (ICP). For more information, refer to the Flash Memory Controller section. Embedded SRAM Memory The HT32F52342/52352 series contain up to 16 KB on-chip SRAM which is located at address 0x2000_0000. It support byte, half-word and word access operations. AHB Peripherals The address of the AHB peripherals ranges from 0x4008_0000 to 0x400F_FFFF.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Memory Controller (FMC) Introduction The Flash Memory Controller (FMC) provides functions of flash operation and pre-fetch buffer for the embedded on-chip Flash memory. Figure below shows the block diagram of FMC which includes programming interface, control register, pre-fetch buffer, and access interface.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Descriptions Flash Memory Map The following figure is the Flash memory map of the system. The address ranges from 0x0000_0000 to 0x1FFF_FFFF (0.5 GB). The address from 0x1F00_0000 to 0x1F00_0FFF is mapped to Boot Loader Block (4 KB).
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Memory Architecture The Flash memory consists of up to 128 KB main Flash with 512 Bytes per page and 4 KB Information Block for Boot Loader. The main Flash memory contains totally 256 pages (or 128 pages for 64 KB device) which can be erased individually.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Booting Configuration The system provides two kinds of booting mode which can be selected through BOOT pin. The value of BOOT pin is sampled during the power-on reset or system reset. Once the value is decided, the first 4 words of vector will be remapped to the corresponding source according to the booting mode.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Page Erase The FMC provides a page erase function which is used to reset partial content of Flash memory. Any page can be erased independently without affecting others. The following steps show the access sequence of the register for page erase.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Mass Erase The FMC provides a complete erase function which is used for resetting all the main Flash memory content. The following steps show the sequence of the register access for mass erase. ▄...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Word Programming The FMC provides a 32 bits word programming function which is used for modifying the Flash memory content. The following steps show the sequence of register access for word programming. ▄...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Option Byte Description The Option Byte can be treated as an independent Flash memory which base address is 0x1FF0_0000. The following table shows the function description and memory map of Option Byte.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Table 8. Access Permission of Protected Main Flash Page Mode ISP/IAP ICP/Debug Mode Operation Read Program Page Erase Mass Erase Notes: 1. Note that the setting of write protection is based on page. The above access permission only affects the pages that enable protection function.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Security Protection FMC provides function of Security protection to prevent illegal code/data access of Flash memory. This function is useful for protecting the software / firmware from the illegal users. The function is activated by setting the Option Byte OB_CP [0]. Once the function has been enabled, all the main Flash data access through ICP/Debug mode, programming, and page erase will not be allowed except the user’s application.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Write Data Register – WRDR This register specifies the data to be written for programming operation. offset: 0x004 Reset value: 0x0000_0000 WRDB Type/Reset 0 RW 0 RW 0 RW 0 RW...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Operation Command Register – OCMR This register is used to specify the Flash operation commands that include read, read ID, word program, page erase and mass erase. Offset: 0x00C Reset value: 0x0000_0000...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Operation Control Register – OPCR This register is used for controlling the command commitment and checking the status of the FMC operations. Offset: 0x010 Reset value: 0x0000_000C Reserved Type/Reset Reserved Type/Reset...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Operation Interrupt Enable Register – OIER This register is used to enable or disable interrupt function of FMC. The FMC generates interrupt to the controller when corresponding interrupt enable bits are set. Offset:...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Operation Interrupt and Status Register – OISR This register indicates the status of the FMC interrupt to check if an operation has been finished or an error occurs. The status bits (bit [4:0]) are available when the corresponding bits in the OIER register are set.
Page 59
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions ITADF Invalid Target Address Flag 0: The target address is valid 1: The target address TADR is invalid TADR field must be below 0x1FFF_FFFF. The ITAD interrupt will be occurred if the ITADIEN bit in the OIER register is set.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Security Protection Status Register – CPSR This register indicates the status of the Flash Security protection. The content of this register is not dynamically updated and will only be reloaded by the Option Byte loader (which is active when any kind of reset occurs).
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Vector Mapping Control Register – VMCR This register is used to control the mapping of vector. The reset value of VMCR is determined by booting power on the reset setting BOOT pin. Offset:...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Manufacturer and Device ID Register – MDID This register specifies the manufacture ID and device part number information which can be used as the product identity. Offset: 0x180 Reset value: 0x0376_XXXX...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Flash Cache & Pre-fetch Control Register – CFCR This register is used for controlling the pre-fetch module of FMC. Offset: 0x200 Reset value: 0x0000_13D1 Reserved Type/Reset Reserved Type/Reset Reserved Reserved Type/Reset Reserved...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Custom ID Register n – CIDRn, n = 0 ~ 3 This register specifies 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.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 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.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Three power domains: Backup, V 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.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 LSE, LSI and RTC The Real Time Clock circuitry clock source can be derived from either the Low Speed Internal RC oscillator, LSI, or the Low Speed External Crystal oscillator, LSE. Before entering the power...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Power On Reset (POR) / Power Down Reset (PDR) The device has an integrated POR/PDR circuitry that allows proper operation starting from/down to 2.0 V. The device remains in Power-Down mode when V is below a specified threshold V without the need for an external reset circuit.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 High Speed External Oscillator The High Speed External Oscillator, HSE, is located in the V power domain. The HSE crystal oscillator can be switched on or off using the HSEEN bit in the Global Clock Control Register (GCCR).
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Sleep Mode By default, only the CPU clock will be stopped in the Sleep mode. Clearing the FMCEN or SRAMEN bit in the CKCU AHBCCR register to 0 will have the effect of stopping the Flash clock or SRAM clock after the system enters the Sleep mode.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Power-Down Mode The Power-Down mode is derived from the Deep-Sleep mode of the CPU together with the additional control bits LDOOFF and DMOSON. To enter the Power-Down mode, users can configure the registers shown in the preceding Mode-Entering table and execute the WFI or WFE instruction.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Backup Domain Control Register – BAKCR This register provides power control bits for the Deep-Sleep and Power-Down modes. Offset: 0x104 Reset value: 0x0000_0000 (Reset only by Backup Domain reset) Reserved Type/Reset Reserved...
Page 77
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions WUPEN External 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.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Backup Domain Test Register – BAKTEST This register specifies a read-only value for the software to recognize whether backup domain is ready for access. Offset: 0x108 Reset value: 0x0000_0027 Reserved Type/Reset Reserved...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Low Voltage / Brown Out Detect Control and Status Register – LVDCSR This register specifies flags, enable bits and option bits for low voltage detector. Offset: 0x110 Reset value: 0x0000_0000 (Reset only by Backup Domain reset)
Page 80
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [16] LVDEN Low 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 power is lower than the voltage set by LVDS bits.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Backup Register n – BAKREGn, n = 0 ~ 9 This register specifies backup register n for storing data during the VDD15 power-off period. Offset: 0x200 ~ 0x224 Reset value: 0x0000_0000 (Reset only by Backup Domain reset)
The frequency accuracy of the high speed internal RC oscillator HSI can vary from one chip to another due to manufacturing process variations, this is why each device is factory calibrated by HOLTEK for ±2% accuracy at V = 3.3 V and T = 25°C.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Phase Locked Loop – PLL This PLL can provide 4 ~ 48 MHz clock output which is 1 ~ 12 multiples of a fundamental reference frequency of 4 ~ 16 MHz. The rationale of the clock synthesizer relies on the digital...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Low Speed External Crystal Oscillator – LSE The low speed external crystal or ceramic resonator oscillator with 32,768 Hz frequency produces a low power but highly accurate clock source for the Real-Time-Clock peripheral, Watchdog Timer or system clock.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 System Clock (CK_SYS) Selection After the system reset occurs, the default system clock source CK_SYS will be the high speed internal RC oscillator HSI. The CK_SYS may come from the HSI, HSE, LSE, LSI or PLL output clock and it can be switched from one clock source to another by changing the System Clock Switch bits, SW, in the Global Clock Control Register GCCR.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 HSE Clock Monitor The HSE clock monitor function is enabled by the HSE Clock Monitor Enable bit CKMEN in the Global Clock Control Register, GCCR. The HSE clock monitor function should be enabled after the HSE oscillator start-up delay and disabled when the HSE oscillator is stopped.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Map The following table shows the CKCU register and reset value. Table 18. CKCU Register Map Register Offset Description Reset Value GCFGR 0x000 Global Clock Configuration Register 0x0000_0102 GCCR 0x004 Global Clock Control Register...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Global Clock Control Register – GCCR This register specifies the clock enable bits. Offset: 0x004 Reset value: 0x0000_0803 Reserved Type/Reset Reserved PSRCEN CKMEN Type/Reset 0 RW Reserved HSIEN HSEEN PLLEN HSEGAIN Type/Reset...
Page 96
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions HSEGAIN External High Speed Oscillator Gain Selection 0: HSE in low gain mode 1: HSE in high gain mode [2:0] System Clock Switch 00x: CK_PLL clock out as system clock...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 AHB Clock Control Register – AHBCCR This register specifies the AHB clock enable control bits. Offset: 0x024 Reset value: 0x0000_0005 Reserved Type/Reset Reserved PDEN PCEN PBEN PAEN Type/Reset 0 RW 0 RW...
Page 102
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [10] USBEN USB Clock Enable 0: USB clock is disabled 1: USB clock is enabled Set and reset by software APBEN APB bridge Clock Enable 0: APB bridge clock is automatically disabled by hardware during Sleep mode 1: APB bridge clock is always enabled during Sleep mode Set and reset by software.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 APB Clock Control Register 0 – APBCCR0 This register specifies the APB peripherals clock enable bits. Offset: 0x02C Reset value: 0x0000_0000 Reserved SCI1EN Reserved I2SEN SCI0EN Type/Reset 0 RW Reserved Type/Reset EXTIEN...
Page 105
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions USR1EN USART1 Clock Enable 0: USART1 clock is disabled 1: USART1 clock is enabled Set and reset by software. USR0EN USART0 Clock Enable 0: USART0 clock is disabled 1: USART0 clock is enabled Set and reset by software.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 APB Clock Control Register 1 – APBCCR1 This register specifies the APB peripherals clock enable bits. Offset: 0x030 Reset value: 0x0000_0000 Reserved SCTM1EN SCTM0EN Reserved ADCCEN Type/Reset 0 RW Reserved CMPEN Reserved...
Page 107
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions GPTM0EN GPTM0 Clock Enable 0: GPTM0 clock is disabled 1: GPTM0 clock is enabled Set and reset by software. BKPREN Backup Domain Clock Enable for Registers Access 0: RTC clock is disabled 1: RTC clock is enabled Set and reset by software.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 HSI Control Register – HSICR This register is used to control the frequency trimming of the HSI RC oscillation. Offset: 0x040 Reset value: 0xXXXX_0000 where X is undefined Reserved HSICOARSE Type/Reset X RO...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Low Power Control Register – LPCR This register specifies the low power control. Offset: 0x300 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved USBSLEEP Type/Reset Reserved BKISO Type/Reset Bits Field Descriptions USBSLEEP USB Sleep Software Control Enable...
Page 117
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [16] DBBFTM0 BFTM0 Debug Mode Enable 0: BFTM0 counter continues to count even if the core is halted 1: BFTM0 counter stops counting when the core is halted Set and reset by software.
Page 118
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions DBPD Debug Power-Down Mode 0: LDO = Off, FCLK = Off, and HCLK = Off in Power-Down mode 1: LDO = On, FCLK = On, and HCLK = On in Power-Down mode Set and reset by software.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Reset Control Unit (RSTCU) Introduction The Reset Control Unit, RSTCU, has three kinds of reset, the power on reset, system reset and APB unit reset. The power on reset, known as a cold reset, resets the full system during a power up.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Descriptions Power On Reset The Power on reset, POR, is generated by either an external reset or the internal reset generator. Both types have an internal filter to prevent glitches from causing erroneous reset operations. By referring to Figure 19, the POR15 active low signal will be de-asserted when the internal LDO voltage regulator is ready to provide 1.5 V power.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Map The following table shows the RSTCU registers and reset values. Table 19. RSTCU Register Map Register Offset Description Reset Value RSTCU Base Address = 0x4008_8000 GRSR 0x100 Global Reset Status Register...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions NVICRSTF NVIC Reset Flag 0: No NVIC asserting system reset occurred 1: NVIC asserting system reset occurred This bit is set by hardware when a system reset occurs and reset by writing 1 into it or by hardware when a power on reset occurs.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CRCRST CRC Reset Control 0: No reset 1: Reset CRC This bit is set by software and cleared to 0 by hardware automatically. EBIRST EBI Reset Control 0: No reset 1: Reset EBI This bit is set by software and cleared to 0 by hardware automatically.
Page 124
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [24] SCI0RST Smart Card Interface 0 Reset Control 0: No reset 1: Reset Smart Card Interface This bit is set by software and cleared to 0 by hardware automatically.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 APB Peripheral Reset Register 1 – APBPRSTR1 This register specifies several APB peripherals software reset control bits. Offset: 0x10C Reset value: 0x0000_0000 Reserved SCTM1RST SCTM0RST Reserved ADCRST Type/Reset 0 RW Reserved CMPRST...
Page 126
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions GPTM0RST GPTM0 Reset Control 0: No reset 1: Reset GPTM0 This bit is set by software and cleared to 0 by hardware automatically. WDTRST Watchdog Timer Reset Control 0: No reset 1: Reset Watchdog Timer This bit is set by software and cleared to 0 by hardware automatically.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 General Purpose I/O (GPIO) Introduction There are up to 51 General Purpose I/O port, GPIO, named PA0 ~ PA15, PB0 ~ PB15, PC0 ~ PC15 and PD0 ~ PD3 for the device to implement the logic input/output functions. Each of the GPIO ports has related control and configuration registers to satisfy the requirement of specific applications.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Input/output direction control ▄ Schmitt Trigger Input function enable control ▄ Input weak pull-up/pull-down control ▄ Output push-pull/open drain enable control ▄ Output set/reset control ▄ Output drive current selection ▄...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 GPIO Locking Mechanism The GPIO also offers a lock function to lock the port until a reset event occurs. The PxLOCKR (x = A ~ D) registers are used to lock the port x and lock control options. The value 0x5FA0 is written...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Offset Description Reset Value PCDOUTR 0x020 Port C Data Output Register 0x0000_0000 PCSRR 0x024 Port C Output Set and Reset Control Register 0x0000_0000 PCRR 0x028 Port C Output Reset Control Register...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port A Input Function Enable Control Register – PAINER This register is used to enable or disable the GPIO Port A input function. Offset: 0x004 Reset value: 0x0000_3300 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port A Pull-Up Selection Register – PAPUR This register is used to enable or disable the GPIO Port A pull-up function. Offset: 0x008 Reset value: 0x0000_3300 Reserved Type/Reset Reserved Type/Reset PAPU Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port A Pull-Down Selection Register – PAPDR This register is used to enable or disable the GPIO Port A pull-down function. Offset: 0x00C Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset PAPD Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port A Open Drain Selection Register – PAODR This register is used to enable or disable the GPIO Port A open drain function. Offset: 0x010 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port A Output Set/Reset Control Register – PASRR This register is used to set or reset the corresponding bit of the GPIO Port A output data. Offset: 0x024 Reset value: 0x0000_0000 PARST...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port A Output Reset Register – PARR This register is used to reset the corresponding bit of the GPIO Port A output data. Offset: 0x028 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port B Data Direction Control Register – PBDIRCR This register is used to control the direction of GPIO Port B pin as input or output. Offset: 0x000 Reset value: 0x0000_0000 Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port B Input Function Enable Control Register – PBINER This register is used to enable or disable the GPIO Port B input function. Offset: 0x004 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port B Pull-Up Selection Register – PBPUR This register is used to enable or disable the GPIO Port B pull-up function. Offset: 0x008 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset PBPU Reserved...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port B Pull-Down Selection Register – PBPDR This register is used to enable or disable the GPIO Port B pull-down function. Offset: 0x00C Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset PBPD Reserved...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port B Open Drain Selection Register – PBODR This register is used to enable or disable the GPIO Port B open drain function. Offset: 0x010 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port B Output Set/Reset Control Register – PBSRR This register is used to set or reset the corresponding bit of the GPIO Port B output data. Offset: 0x024 Reset value: 0x0000_0000 PBRST...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port B Output Reset Register – PBRR This register is used to reset the corresponding bit of the GPIO Port B output data. Offset: 0x028 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port C Data Direction Control Register – PCDIRCR This register is used to control the direction of GPIO Port C pin as input or output. Offset: 0x000 Reset value: 0x0000_0000 Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port C Input Function Enable Control Register – PCINER This register is used to enable or disable the GPIO Port C input function. Offset: 0x004 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port C Pull-Up Selection Register – PCPUR This register is used to enable or disable the GPIO Port C pull-up function. Offset: 0x008 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset PCPU Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port C Pull-Down Selection Register – PCPDR This register is used to enable or disable the GPIO Port C pull-down function. Offset: 0x00C Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset PCPD Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port C Open Drain Selection Register – PCODR This register is used to enable or disable the GPIO Port C open drain function. Offset: 0x010 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port C Output Set/Reset Control Register – PCSRR This register is used to set or reset the corresponding bit of the GPIO Port C output data. Offset: 0x024 Reset value: 0x0000_0000 PCRST...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port C Output Reset Register – PCRR This register is used to reset the corresponding bit of the GPIO Port C output data. Offset: 0x028 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Data Direction Control Register – PDDIRCR This register is used to control the direction of GPIO Port D pin as input or output. Offset: 0x000 Reset value: 0x0000_0000 Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Input Function Enable Control Register – PDINER This register is used to enable or disable the GPIO Port D input function. Offset: 0x004 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Pull-Up Selection Register – PDPUR This register is used to enable or disable the GPIO Port D pull-up function. Offset: 0x008 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Pull-Down Selection Register – PDPDR This register is used to enable or disable the GPIO Port D pull-down function. Offset: 0x00C Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Open Drain Selection Register – PDODR This register is used to enable or disable the GPIO Port D open drain function. Offset: 0x010 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Output Current Drive Selection Register – PDDRVR This register specifies the GPIO Port D output driving current. Offset: 0x014 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset PDDV3 PDDV2...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Data Input Register – PDDINR This register specifies the GPIO Port D input data. Offset: 0x01C Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset Reserved PDDIN Type/Reset 0 RO...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Output Data Register – PDDOUTR This register specifies the GPIO Port D output data. Offset: 0x020 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset Reserved PDDOUT Type/Reset 0 RW...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Output Set/Reset Control Register – PDSRR This register is used to set or reset the corresponding bit of the GPIO Port D output data. Offset: 0x024 Reset value: 0x0000_0000 Reserved...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Port D Output Reset Register – PDRR This register is used to reset the corresponding bit of the GPIO Port D output data. Offset: 0x028 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Alternate Function Input/Output Control Unit (AFIO) Introduction In order to expand the flexibility of the GPIO or the usage of peripheral functions, each IO pin can be configured to have up to sixteen different functions such as GPIO or IP functions by setting the GPxCFGLR or GPxCFGHR register where x is the different port name.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ APB slave interface for register access ▄ EXTI source selection ▄ Configurable pin function for each GPIO, up to sixteen alternative functions on each pin ▄ AFIO lock mechanism Functional Descriptions External Interrupt Pin Selection The GPIO pins are connected to the 16 EXTI lines as shown in the accompanying figure.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Alternate Function Up to sixteen alternative functions can be chosen for each I/O pad by setting the PxCFGn [3:0] field in the GPxCFGLR or GPxCFGHR (n = 0~15, x = A~ D) registers. If the pin is selected as an unavailable item which is noted as a “N/A”...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 GPIO x Configuration Low Register – GPxCFGLR, x = A, B, C, D This low register specifies the alternate function of GPIO Port x. x = A, B, C, D Offset: 0x020, 0x028, 0x030, 0x038...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 GPIO x Configuration High Register – GPxCFGHR, x = A, B, C, D This high register specifies the alternate function of GPIO Port x. x = A, B, C, D Offset: 0x024, 0x02C, 0x034, 0x03C...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Nested Vectored Interrupt Controller (NVIC) Introduction In order to reduce the latency and increase the interrupt processing efficiency, a tightly coupled integrated section, which is named as Nested Vectored Interrupt Controller (NVIC) is provided by the Cortex -M0+.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Function Descriptions SysTick Calibration The SysTick Calibration Value Register (SCALIB) is provided by the NVIC to give a reference time base of 1ms for the RTOS tick timer or other purpose. The TENMS field in the SCALIB register...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 External Interrupt/Event Controller (EXTI) Introduction The External Interrupt/Event Controller, EXTI, comprises 16 edge detectors which can generate a wake-up event or interrupt requests independently. In interrupt mode there are five trigger types...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Function Descriptions Wakeup Event Management In order to wakeup the system from the power saving mode, the EXTI controller provides a function which can monitor external events and send them to the CPU core and the Clock Control Unit, CKCU.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 External Interrupt/Event Line Mapping All GPIO pins can be selected as EXTI trigger sources by configuring the EXTInPIN [3:0] field in the AFIO ESSRn (n= 0 ~ 1) register to trigger an interrupt or event. Refer to the AFIO section for more details.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions EXTI Interrupt Configuration Register n – EXTICFGRn, n = 0 ~ 15 This register is used to specify the debounce function and select the trigger type. Offset: 0x000 (0) ~ 0x03C (15)
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 EXTI Interrupt Control Register – EXTICR This register is used to control the EXTI interrupt. Offset: 0x040 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset EXTI15EN EXTI14EN EXTI13EN EXTI12EN EXTI11EN EXTI10EN EXTI9EN EXTI8EN...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 EXTI Interrupt Edge Flag Register – EXTIEDGEFLGR This register is used to indicate if an EXTI edge has been detected. Offset: 0x044 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset EXTI15EDF EXTI14EDF EXTI13EDF EXTI12EDF EXTI11EDF EXTI10EDF EXTI9EDF...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 EXTI Interrupt Wakeup Control Register – EXTIWAKUPCR This register is used to control the EXTI interrupt and wakeup function. Offset: 0x050 Reset value: 0x0000_0000 EVWUPIEN Reserved Type/Reset Reserved Type/Reset EXTI15WEN EXTI14WEN EXTI13WEN EXTI12WEN EXTI11WEN EXTI10WEN EXTI9WEN...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Analog to Digital Converter (ADC) Introduction A 12-bit multi-channel Analog to Digital Converter is integrated in the device. There are a total of 14 multiplexed channels including 12 external channels on which the external analog signal can be supplied and 2 internal channels.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ 12-bit SAR ADC engine ▄ Up to 1 MSPS conversion rate ▄ 12 external analog input channels ▄ 2 internal analog input channels for reference voltage detection ▄ Programmable sampling time for conversion channel ▄...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Function Descriptions ADC Clock Setup The ADC clock, CK_ADC is provided by the Clock Controller which is synchronous and divided by with the AHB clock known as HCLK. Refer to the Clock Control Unit chapter for more details.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Conversion (ex: Sequence Length=8) Cycle Cycle Start of Conversion Single sample End of Conversion Cycle End of Conversion Figure 28. One Shot Conversion Mode Continuous Conversion Mode In the Continuous Conversion Mode, repeated conversion cycle will restart automatically without requiring additional A/D start trigger signals after a channel group conversion has completed.
Page 201
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Discontinuous Conversion Mode The A/D converter will operate in the Discontinuous Conversion Mode for channels group when the A/D conversion mode bit field ADMODE [1:0] in the ADCCONV register is set to 0x3. The group to be converted can have up to 8 channels and can be arranged in a specific sequence by configuring the ADCLSTn registers where n ranges from 0 to 1.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Discontinuous Conversion Mode (ex: Sequence Length=8, Subgroup Length=3 ) Cycle Cycle Subgroup 0 Subgroup 1 Subgroup 2 Subgroup 0 Start of Conversion Single sample End of Conversion Subgroup End of Conversion Cycle End of Conversion Figure 30.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Sampling Time Setting The conversion channel sampling time can be programmed according to the input resistance of the input voltage source. This sampling time must be enough for the input voltage source to charge the internal sample and hold capacitor in A/D the converter to the input voltage level.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Interrupts When an A/D conversion is completed, an End of Conversion EOC event will occur. There are three kinds of EOC events which are known as single sample EOC, subgroup EOC and cycle EOC for A/D conversion.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions ADC Conversion Control Register – ADCCR This register specifies the mode setting, sequence length, and subgroup length of the ADC conversion mode. Note that once the content of ADCCR is changed, the conversion in progress will be aborted and the A/D converter will return to an idle state.
Page 207
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [1:0] ADMODE ADC Conversion Mode ADMODE [1:0] Mode Descriptions After a start trigger, the conversion will be One shot mode executed on the specific channels for the whole conversion sequence once.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 ADC Conversion Data Register y – ADCDRy, y = 0 ~ 7 This register is used to store the conversion data of the conversion sequence order No.y which is specified by the ADSEQy field in the ADCLSTn (n= 0 ~ 1) registers.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 ADC Trigger Source Register – ADCTSR This register contains the trigger source selection and the software trigger bit of the conversion. Offset: 0x074 Reset value: 0x0000_0000 Reserved Type/Reset 0 RW 0 RW...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 ADC Watchdog Control Register – ADCWCR This register provides the control bits and status of the ADC watchdog function. Offset: 0x078 Reset value: 0x0000_0000 Reserved ADUCH Type/Reset 0 RO 0 RO 0 RO...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 ADC Interrupt Status Register – ADCISR This register contains the ADC interrupt masked status bits. The corresponding interrupt status will be set to 1 if the associated interrupt event occurs and the related enable bit is set to 1.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 ADC Interrupt Clear Register – ADCICLR This register provides the clear bits used to clear the interrupt raw and masked status of the ADC. These bits are set to 1 by software to clear the interrupt status and automatically cleared to 0 by hardware after being set to 1.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Comparator (CMP) Introduction The two general purpose comparators (CMP) are implemented within the device. They can be configured either as standalone comparators or combined with the different kinds of peripheral IP. Each comparator is capable of asserting interrupts to the NVIC or wakeup the CPU Deep Sleep mode through EXTI wakeup event management unit.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Function Descriptions Comparator Inputs and Output The I/O pins used as comparator inputs or output must be configured in the AFIO controller registers. The detail comparator I/Os information will be referred in the pin assignment table in the datasheet.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Interrupts and Wakeup The comparator can generate an interrupt when its output waveform generates a rising or falling edge and its corresponding interrupt enables control bit is also set. For example, when a comparator output rising edge occurs, the comparator rising edge flag bit CMPRF in the Comparator Transition Flag Register CMPTFR will be set.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Power Mode and Hysteresis The comparator response time can be programmed to meet the trade-off between the power consumption and application requirement. The bit CMPSM in CMPCR register can be programmed as “1” to get the comparator in the low speed mode with low power consumption.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions Comparator Control Register n – CMPCRn, n = 0 or 1 This register contains the comparator function and comparator voltage reference control bits. Offset: 0x000 (n = 0), 0x100 (n = 1)
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Comparator Voltage Reference Value Register n – CVRVALRn, n = 0 or 1 The register is used to set the comparator voltage reference level. Offset: 0x004 (n = 0), 0x104 (n = 1)
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Comparator Interrupt Enable Register n – CMPIERn, n = 0 or 1 The register is used to enable the comparator n interrupt when the comparator output transition event occurs. Offset: 0x008 (n = 0), 0x108 (n = 1)
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Comparator Transition Flag Register n – CMPTFRn, n = 0 or 1 This register contains the comparator n transition detection enable bits and flags. Offset: 0x00C (n = 0), 0x10C (n = 1)
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 General-Purpose Timer (GPTM) Introduction The General-Purpose Timer consists of one 16-bit up/down-counter, four 16-bit Capture/ Compare Registers (CCRs), one 16-bit Counter-Reload Register (CRR) and several control/status registers. It can be used for a variety of purposes including general timer, input signal pulse width measurement or output waveform generation such as single pulse generation or PWM output.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ 16-bit up/down auto-reload counter ▄ 16-bit programmable prescaler that allows division of the counter clock frequency by any factor between 1 and 65536 ▄ Up to 4 independent channels for: ●...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Descriptions Counter Mode Up-Counting In this mode the counter counts continuously from 0 to the counter-reload value, which is defined in the CRR register, in a count-up direction. Once the counter reaches the counter-reload value, the Timer Module generates an overflow event and the counter restarts to count once again from 0.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Down-Counting In this mode the counter counts continuously from the counter-reload value, which is defined in the CRR register, to 0 in a count-down direction. Once the counter reaches 0, the Timer module generates an underflow event and the counter restarts to count once again from the counter-reload value.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Center-Align Counting In the center-aligned counting mode, the counter counts up from 0 to the counter-reload value and then counts down to 0 alternatively. The Timer module generates an overflow event when the counter counts to the counter-reload value in the up-counting mode and generates an underflow event when the counter counts to 0 in the down-counting mode.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Clock Controller The following describes the Timer Module clock controller which determines the clock source of the internal prescaler counter. ▄ Internal APB clock f CLKIN The default internal clock source is the APB clock f...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Trigger Controller The trigger controller is used to select the trigger source and setup the trigger level or edge trigger condition. For the internal trigger input, it can be selected by the Trigger Selection bits TRSEL in the TRCFR register.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Slave Controller The GPTM can be synchronized with an external trigger in several modes including the Restart mode, the Pause mode and the Trigger mode which is selected by the SMSEL field in the MDCFR register.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Pause Mode In the Pause Mode, the selected STI input signal level is used to control the counter start/stop operation. The counter starts to count when the selected STI signal is at a high level and stops counting when the STI signal is changed to a low level, here the counter will maintain its present value and will not be reset.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Trigger Mode After the counter is disabled to count, the counter can resume counting when a STI rising edge signal occurs. When an STI rising edge occurs, the counter will start to count from the current value in the counter.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Master Controller The GPTMs and MCTMs can be linked together internally for timer synchronization or chaining. When one GPTM is configured to be in the Master Mode, the GPTM Master Controller will generate a Master Trigger Output (MTO) signal which includes a reset, a start, a stop signal or a clock source which is selected by the MMSEL field in the MDCFR register to trigger or drive another GPTM or MCTM, if exists, which is configured in the Slave Mode.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Channel Controller The GPTM has four independent channels which can be used as capture inputs or compare match outputs. Each capture input or compare match output channel is composed of a preload register and a shadow register.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Capture Counter Value Transferred to CHxCCR When the channel is used as a capture input, the counter value is captured into the Channel Capture/Compare Register (CHxCCR) when an effective input signal transition occurs. Once the capture event occurs, the CHxCCIF flag in the INTSR register is set accordingly.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Pulse Width Measurement The input capture mode can be also used for pulse width measurement from signals on the GT_ CHx pins, TIx. The following example shows how to configure the GPTM operated in the input capture mode to measure the high pulse width and the input period on the GT_CH0 pin using channel 0 and channel 1.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Input Stage The input stage consists of a digital filter, a channel polarity selection, edge detection and a channel prescaler. The channel 0 input signal (TI0) can be chosen to come from the GT_CH0 signal or the Excusive-OR function of the GT_CH0, GT_CH1 and GT_CH2 signals.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Quadrature Decoder The Quadrature Decoder function uses two quadrantal inputs TI0 and TI1 derived from the GT_ CH0 and GT_CH1 pins respectively to interact to generate the counter value. The DIR bit is modified by hardware automatically during each input source transition. The input source can be either TI0 only, TI1 only or both TI0 and TI1, the selection made by setting the SMSEL field to 0x01, 0x02 or 0x03.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Output Stage The GPTM has four channels for compare match, single pulse or PWM output function. The channel output GT_CHxO is controlled by the CHxOM, CHxP and CHxE bits in the corresponding CHxOCFR, CHPOLR and CHCTR registers.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Counter Value CHxOM=0x03, CHxPRE=0 (Output toggle, preload disable) CHxCCR (New value 2) CHxCCR (New value 3) CHxCCR (New value 1) CHxCCR Time Update CHxCCR value CHxOREF (Update Event) Figure 56. Toggle Mode Channel Output Reference Signal (CHxPRE = 0)
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Update Management The Update event is used to update the CRR, the PSCR, the CHxACR and the CHxCCR values from the actual registers to the corresponding shadow registers. An update event occurs when the counter overflows or underflows, the software update control bit is triggered or an update event from the slave controller is generated.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Single Pulse Mode Once the timer is set to operate in the single pulse mode, it is not necessary to set the timer enable bit TME in the CTR register to 1 to enable the counter. The trigger to generate a pulse can be sourced from the STI signal rising edge or by setting the TME bit to 1 using software.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 In the Single Pulse mode, the STI active edge which sets the TME bit to 1 will enable the counter. However, there exist several clock delays to perform the comparison result between the counter value and the CHxCCR value. In order to reduce the delay to a minimum value, the user can set the CHxIMAE bit in each CHxOCFR register.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Asymmetric PWM Mode Asymmetric PWM mode allows two center-aligned PWM signals to be generated with a programmable phase shift. While the PWM frequency is determined by the value of the CRR register, the duty cycle and the phase-shift are determined by the CHxCCR and CHxACR register.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Timer Interconnection The timers can be internally connected together for timer chaining or synchronization. This can be implemented by configuring one timer to operate in the Master mode while configuring another timer to be in the Slave mode. The following figures present several examples of trigger selection for the master and slave modes.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Using one timer to trigger another timer start counting ▄ Configure GPTM0 to operate in the master mode to send its Update Event UEV as the trigger output (MMSEL = 0x02). ▄...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Starting two timers synchronously in response to an external trigger ▄ Configure GPTM0 to operate in the master mode to send its enable signal as a trigger output (MMSEL = 0x01). ▄...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Trigger ADC Start To interconnect to the Analog-to-Digital Converter, the GPTM can output the MTO signal or the channel compare match output signal CHxOREF (x = 0 ~ 3) to be used as an Analog-to-Digital Converter input trigger signal.
Page 262
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions UGDIS Update event interrupt generation disable control 0: Any of the following events will generate an update PDMA request or interrupt - Counter overflow/underflow - Setting the UEVG bit...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Timer Mode Configuration Register – MDCFR This register specifies the GPTM master and slave mode selection and single pulse mode. Offset: 0x004 Reset value: 0x0000_0000 Reserved SPMSET Type/Reset Reserved MMSEL Type/Reset 0 RW...
Page 264
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [18:16] MMSEL Master Mode Selection Master mode selection is used to select the MTO signal source which is used to synchronize the other slave timer. MMSEL [2:0] Mode Descriptions...
Page 265
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [10:8] SMSEL Slave Mode Selection SMSEL [2:0] Mode Descriptions The prescaler is clocked directly by the internal Disable mode clock. The counter uses the clock pulse generated from the interaction between the TI0 and Quadrature Decoder TI1 signals to drive the counter prescaler.
Page 269
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] TI0F Channel 0 Input Source TI0 Filter Setting These bits define the frequency divided ratio used to sample the TI0 signal. The Digital filter in the GPTM is an N-event counter where N is defined as how many valid transitions are necessary to output a filtered signal.
Page 271
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] TI1F Channel 1 Input Source TI1 Filter Setting These bits define the frequency divided ratio used to sample the TI1 signal. The Digital filter in the GPTM is an N-event counter where N is defined as how many valid transitions are necessary to output a filtered signal.
Page 273
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] TI2F Channel 2 Input Source TI2 Filter Setting These bits define the frequency divided ratio used to sample the TI2 signal. The Digital filter in the GPTM is an N-event counter where N is defined as how many valid transitions are necessary to output a filtered signal.
Page 275
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] TI3F Channel 3 Input Source TI3 Filter Setting These bits define the frequency divided ratio used to sample the TI3 signal. The Digital filter in the GPTM is an N-event counter where N is defined as how many valid transitions are necessary to output a filtered signal.
Page 277
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [8][2:0] CH0OM[3:0] Channel 0 Output Mode Setting These bits define the functional types of the output reference signal CH0OREF. 0000: No Change 0001: Output 0 on compare match 0010: Output 1 on compare match 0011: Output toggles on compare match 0100: Force inactive –...
Page 279
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [8][2:0] CH1OM[3:0] Channel 1 Output Mode Setting These bits define the functional types of the output reference signal CH1OREF. 0000: No Change 0001: Output 0 on compare match 0010: Output 1 on compare match 0011: Output toggles on compare match 0100: Force inactive –...
Page 281
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [8][2:0] CH2OM[3:0] Channel 2 Output Mode Setting These bits define the functional types of the output reference signal CH2OREF. 0000: No Change 0001: Output 0 on compare match 0010: Output 1 on compare match 0011: Output toggles on compare match 0100: Force inactive –...
Page 283
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [8][2:0] CH3OM[3:0] Channel 3 Output Mode Setting These bits define the functional types of the output reference signal CH3OREF 0000: No Change 0001: Output 0 on compare match 0010: Output 1 on compare match 0011: Output toggles on compare match 0100: Force inactive –...
Page 289
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CH1CCG Channel 1 Capture/Compare Generation A Channel 1 capture/compare event can be generated by setting this bit. It is cleared by hardware automatically. 0: No action 1: Capture/compare event is generated on channel 1 If Channel 1 is configured as an input, the counter value is captured into the CH1CCR register and then the CH1CCIF bit is set.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Timer Interrupt Status Register – INTSR This register stores the timer interrupt status. Offset: 0x07C Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved TEVIF Reserved UEVIF Type/Reset CH3OCF CH2OCF CH1OCF CH0OCF CH3CCIF...
Page 291
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CH0OCF Channel 0 Over-Capture Flag This flag is set by hardware and cleared by software. 0: No over-capture event is detected 1: Capture event occurs again when the CH0CCIFbit is already set and it is not yet cleared by software.
Page 292
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CH0CCIF Channel 0 Capture/Compare Interrupt Flag - Channel 0 is configured as an output: 0: No match event occurs 1: The contents of the counter CNTR have matched the content of the CH0CCR...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Basic Function Timer (BFTM) Introduction The Basic Function Timer Module, BFTM, is a 32-bit up-counting counter designed to measure time intervals, generate one shot or generate repetitive interrupts. The BFTM can operate in two modes which are repetitive and one shot modes.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Description The BFTM is a 32-bit up-counting counter which is driven by the BFTM APB clock, PCLK. The counter value can be changed or read at any time even when the timer is counting. The BFTM supports two operating modes known as the repetitive mode and one shot mode allowing the measurement of time intervals or the generation of periodic time durations.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 One Shot Mode By setting the OSM bit in BFTMCR register to 1, the BFTM will operate in the one shot mode. The BFTM starts to count when the CEN bit is set to 1 by the application program. The counter value will remain unchanged if the CEN bit is cleared to 0 by the application program.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Map The following table shows the BFTM registers and their reset values. Table 34. BFTM Register Map Register Offset Description Reset Value BFTMCR 0x000 BFTM Control Register 0x0000_0000 BFTMSR 0x004 BFTM Status Register...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Motor Control Timer (MCTM) Introduction The Motor Control Timer consists of one 16-bit up/down-counter, four 16-bit Capture/Compare Registers (CCRs), one 16-bit Counter-Reload Register (CRR), one 8-bit Repetition Counter (REPR) and several control/status registers. It can be used for a variety of purposes which include general time measurement, input signal pulse width measurement, output waveform generation for signals such as single pulse generation or PWM generation, including dead time insertion.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ 16-bit up/down auto-reload counter. ▄ 16-bit programmable prescaler that allows division the counter clock frequency by any factor between 1 and 65536. ▄ Up to 4 independent channels for: ●...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Descriptions Counter Mode Up-Counting In this mode the counter counts continuously from 0 to the counter-reload value, which is defined in the CRR register, in a count-up direction. Once the counter reaches the counter-reload value, the Timer Module generates an overflow event and the counter restarts to count once again from 0.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Down-Counting In this mode the counter counts continuously from the counter-reload value, which is defined in the CRR register, to 0 in a count-down direction. Once the counter reaches 0, the Timer module generates an underflow event and the counter restarts to count once again from the counter-reload value.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Center-aligned Counting In the center-aligned counting mode, the counter counts up from 0 to the counter-reload value and then counts down to 0 alternatively. The Timer Module generates an overflow event when the counter counts to the counter-reload value in the up-counting mode and generates an underflow event when the counter counts to 0 in the down-counting mode.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Repetition Down-counter Operation The update event 1 is usually generated at each overflow or underflow event occurrence. However, when the repetition operation is active by assigning a non-zero value into the REPR register, the update event is only generated if the REPR counter has reached zero.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Clock Controller The following describes the Timer Module clock controller which determines the internal prescaler counter clock source. ▄ Internal APB clock f CLKIN The default internal clock source is the APB clock f...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Trigger Controller The trigger controller is used to select the trigger source and setup the trigger level and edge trigger conditions. For the internal trigger input (ITIx), it can be selected by the Trigger Selection bits, TRSEL, in the TRCFR register.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Slave Controller The MCTM can be synchronised with an internal/external trigger in several modes including the Restart mode, the Pause mode and the Trigger mode which are selected by the SMSEL field in the MDCFR register.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Pause Mode In the Pause Mode, the selected STI input signal level is used to control the counter start/stop operation. The counter starts to count when the selected STI signal is at a high level and stops counting when the STI signal is changed to a low level.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Master Controller The MCTMs and GPTMs can be linked together internally for timer synchronisation or chaining. When one MCTM is configured to be in the Master Mode, the MCTM Master Controller will generate a Master Trigger Output (MTO) signal which can reset, restart, stop the Slave counter or be a clock source of the Slave Counter.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Channel Controller The MCTM has four independent channels which can be used as capture inputs or compare match outputs. Each capture input or compare match output channel is composed of a preload register and a shadow register. Data access of the APB bus is always implemented through the read/write preload register.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Capture Counter Value Transferred to CHxCCR When the channel is used as a capture input, the counter value is captured into the Channel Capture/Compare Register (CHxCCR) when an effective input signal transition occurs. Once the capture event occurs, the CHxCCIF flag in the INTSR register is set accordingly.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Pulse Width Measurement The input capture mode can be also used for pulse width measurement from signals on the MT_ CHx pins, TIx. The following example shows how to configure the MCTM when operated in the input capture mode to measure the high pulse width and the input period on the MT_CH0 pin using channel 0 and channel 1.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Input Stage The input stage consists of a digital filter, a channel polarity selection, edge detection and a channel prescaler. The channel 0 input signal TI0 can be chosen to come from the MT_CH0 signal or the Excusive-OR function of the MT_CH0, MT_CH1 and MT_CH2 signals.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Digital Filter The digital filters are embedded in the input stage and clock controller block for the MT_CH0 ~ MT_CH3 pins. The digital filter in the MCTM is an N-event counter where N refers to how many valid transitions are necessary to output a filtered signal.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Output Stage The MCTM supports complementary outputs for channels 0, 1 and 2 with dead time insertion. The MCTM channel 3 output function is almost the same as that of GPTM channel 3 except for the break function.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Channel Output Reference Signal When the MCTM is used in the compare match output mode, the CHxOREF signal (Channel x Output Reference signal) is defined by the CHxOM bit setup. The CHxOREF signal has several types of output function which defines what happens to the output when the counter value matches the contents of the CHxCCR register.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Counter Value CHxOM=0x03, CHxPRE=1 (Output toggle, preload enable) CHxCCR (New value 2) CHxCCR (New value 3) CHxCCR (New value 1) CHxCCR Time Update CHxCCR value CHxOREF UEV1 (Update Event 1) Figure 94. Toggle Mode Channel Output Reference Signal – CHxPRE = 1...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Dead Time Generator An 8-bit dead time generator function is included for channels 0~2. The dead time insertion is enabled by setting both the CHxE and CHxNE bits. The relationship between the CHxO and CHxNO signals with respect to the CHxOREF signal is as follows: ▄...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Break Function The MCTM includes break function and one input signals for MCTM break. The MT_BRK is default function and from external MT_BRK pin. The detail block diagram is shown as below figure. Output...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 When using the break function, the channel output enable signals and output levels are changed depending on several control bits which include the CHMOE, CHOSSI, CHOSSR, CHxOIS and CHxOISN bits. Once a break event occurs, the output enable bit CHMOE will be cleared asynchronously.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 The accompanying diagram shows that the complementary output states when a break event occurs where the complementary outputs are enabled by setting both the CHxE and CHxNE bits to 1. Break event CHMOE...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 The CHxO and CHxNO complementary outputs should not be set to an active level at the same time. The hardware will protect the MCTM circuitry to force only one channel output to be in the active state.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Table 36. Output Control Bits for Complementary Output with a Break Event Occurrence Control bit Output status MT_CHxN Pin output CHMOE CHOSSI CHOSSR CHxE CHxNE MT_CHx Pin output state state Output disabled - floating...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Update Management The update events are categorised into two different types which are the update event 1, UEV1, and update event 2, UEV2. The update event 1 is used to update the CRR, the PSCR, the CHxACR and the CHxCCR values from the actual registers to the corresponding shadow registers.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Update Event 2 The CHxE, CHxNE, CHxOM control bits for the complementary outputs can be preloaded by setting the COMPRE bit in the CTR register. Here the shadow bits of the CHxE, CHxNE, and CHxOM bits will be updated when an update event 2 occurs.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Single Pulse Mode Once the timer is set to operate in the single pulse mode, it is not necessary to set the timer enable bit TME in the CTR register to 1 to enable the counter. The trigger to generate a pulse can be sourced from the STI signal rising edge or by setting the TME bit to 1 using software.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 In the Single Pulse mode, the STI active edge which sets the TME bit to 1 will enable the counter. However, there exist several clock delays to perform the comparison result between the counter value and the CHxCCR value. In order to reduce the delay to a minimum value, users can set the CHxIMAE bit in each CHxOCFR register.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Asymmetric PWM Mode Asymmetric PWM mode allows two center-aligned PWM signals to be genetated with a programmable phase shift. While the PWM frequency is determined by the value of the MCTMx_ CRR register, the duty cycle and the phase-shift are determined by the CHxCCR and CHxACR register.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Timer Interconnection The timers can be internally connected together for timer chaining or synchronization. This can be implemented by configuring one timer to operate in the master mode while configuring another timer to be in the slave mode. The following figures present several examples of trigger selection for the master and slave modes.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Using one timer to trigger another timer to start counting ▄ Configure MCTM to operate in the master mode and to send its Update Event UEV as the trigger output (MMSEL = 0x02).
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Starting two timers synchronously in response to an external trigger ▄ Configure MCTM to operate in the master mode to send its enable signal as a trigger output (MMSEL = 0x01). ▄...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Using one timer as a hall sensor interface to trigger another timer with update event 2 GPTM: ▄ Configure channel 0 to choose an input XOR function (TI0SRC = 1) ▄ Configure channel 0 to be in the input capture mode and TRCED as capture source (CH0CCS= 0x03) and Enable channel 0 (CH0E=1) ▄...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Trigger ADC Start To interconnect to the Analog-to-Digital Converter, the MCTM can output the MTO signal or the channel compare match output signal CHxOREF (x = 0 ~ 3) to be used as an Analog-to-Digital Converter input trigger signal.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 PDMA Request The MCTM has a PDMA data transfer interface. There are certain events which can generate PDMA requests if the corresponding enable control bits are set to 1 to enable the PDMA access.
Page 350
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions UGDIS Update event 1 interrupt generation disable control 0: Any of the following events will generate an update PDMA request or interrupt - Counter overflow / underflow - Setting the UEV1G bit...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Timer Mode Configuration Register – MDCFR This register specifies the MCTM master and slave mode selection and single pulse mode. Offset: 0x004 Reset value: 0x0000_0000 Reserved SPMSET Type/Reset Reserved MMSEL Type/Reset 0 RW...
Page 352
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [18:16] MMSEL Master Mode Selection Master mode selection is used to select the MTO signal source which is used to synchronise the other slave timer. MMSEL [2:0] Mode Descriptions...
Page 353
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [10:8] SMSEL Slave Mode Selection SMSEL [2:0] Mode Descriptions Disable mode The prescaler is clocked directly by the internal clock. Reserved Reserved Reserved The counter value restarts from 0 or the CRR shadow...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Timer Counter Register – CTR This register specifies the timer enable bit (TME), CRR buffer enable bit (CRBE), Capture/compare control bit and Channel PDMA selection bit (CHCCDS). Offset: 0x010 Reset value: 0x0000_0000...
Page 357
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] TI0F Channel 0 Input Source TI0 Filter Setting These bits define the frequency divided ratio used to sample the TI0 signal. The Digital filter in the MCTM is an N-event counter where N is defined as how many valid transitions are necessary to output a filtered signal.
Page 359
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] TI1F Channel 1 Input Source TI1 Filter Setting These bits define the frequency divide ratio used to sample the TI1 signal. The Digital filter in the MCTM is an N-event counter where N is defined as how many...
Page 361
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] TI2F Channel 2 Input Source TI2 Filter Setting These bits define the frequency divide ratio used to sample the TI2 signal. The Digital filter in the MCTM is an N-event counter where N is defined as how many valid transitions are necessary to output a filtered signal.
Page 363
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] TI3F Channel 3 Input Source TI3 Filter Setting These bits define the frequency divide ratio used to sample the TI3 signal. The digital filter in the GPTM is an N-event counter where N is defined as how many...
Page 365
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [8][2:0] CH0OM[3:0] Channel 0 Output Mode Setting These bits define the functional types of the output reference signal CH0OREF. 0000: No Change 0001: Output 0 on compare match 0010: Output 1 on compare match 0011: Output toggles on compare match 0100: Force inactive –...
Page 367
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [8][2:0] CH1OM[3:0] Channel 1 Output Mode Setting These bits define the functional types of the output reference signal CH1OREF. 0000: No Change 0001: Output 0 on compare match 0010: Output 1 on compare match 0011: Output toggles on compare match 0100: Force inactive –...
Page 369
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [8][2:0] CH2OM[3:0] Channel 2 Output Mode Setting These bits define the functional types of the output reference signal CH2OREF. 0000: No Change 0001: Output 0 on compare match 0010: Output 1 on compare match 0011: Output toggles on compare match 0100: Force inactive –...
Page 371
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [8][2:0] CH3OM[3:0] Channel 3 Output Mode Setting These bits define the functional types of the output reference signal CH3OREF 0000: No Change 0001: Output 0 on compare match 0010: Output 1 on compare match 0011: Output toggles on compare match 0100: Force inactive –...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Channel Control Register – CHCTR This register contains the channel capture input or compare output function enable control bits. Offset: 0x050 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset Reserved CH3E...
Page 373
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CH1NE Channel 1 Capture/Compare Complementary Enable 0: Off – Channel 1 complementary output CH1NO is not active. The CH1NO level is then determined by the condition of the CHMOE, CHOSSI, CHOSSR, CH1OIS, CH1OISN and CH1E bits.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Channel Polarity Configuration Register – CHPOLR This register contains the channel capture input or compare output polarity control. Offset: 0x054 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset Reserved CH3P CH2NP...
Page 375
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CH0P Channel 0 Capture/Compare Polarity - When Channel 0 is configured as an input 0: capture event occurs on a Channel 0 rising edge 1: capture event occurs on a Channel 0 falling edge...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Channel Break Control Register – CHBRKCTR This register specifies the channel break control bits. Offset: 0x070 Reset value: 0x0000_0000 CHDTG Type/Reset 0 RW 0 RW 0 RW 0 RW 0 RW 0 RW...
Page 378
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [11:8] Break Input Filter Setting These bits define the frequency ratio used to sample the MT_BRK signal. The digital filter in the MCTM is an N-event counter where N is defined as how many valid transitions are necessary to output a filtered signal.
Page 382
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CH3CCG Channel 3 Capture/Compare Generation A Channel 3 capture/compare event can be generated by setting this bit. It is cleared by hardware automatically. 0: No action 1: Capture/compare event is generated on channel 3 If Channel 3 is configured as an input, the counter value is captured into the CH3CCR register and then the CH3CCIF bit is set.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Timer Interrupt Status Register – INTSR This register stores the timer interrupt status. Offset: 0x07C Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved BRKIF TEVIF UEV2IF UEV1IF Type/Reset 0 W0C 0 W0C...
Page 384
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CH2OCF Channel 2 Over-capture Flag This flag is set by hardware and cleared by software. 0: No over-capture event is detected 1: Capture event occurs again when the CH2CCIF bit is already set and it is not cleared yet by software.
Page 385
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions CH0CCIF Channel 0 Capture/Compare Interrupt Flag - Channel 0 is configured as an output 0: No match event occurs 1: The contents of the counter CNTR have matched the content of the CH0CCR...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Single-Channel Timer (SCTM) Introduction The Single-Channel Timer consists of one 16-bit up-counter, one 16-bit Capture/Compare Register (CCR), one 16-bit Counter-Reload Register (CRR) and several control/status registers. It can be used for a variety of purposes including general timer, input signal pulse width measurement or output waveform generation such as single pulse generation or PWM output.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ 16-bit auto-reload up counter ▄ 16-bit programmable prescaler that allows division of the counter clock frequency by any factor between 1 and 65536 ▄ Single channel for: ● Input Capture function ●...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Clock Controller The following describes the Timer Module clock controller which determines the clock source of the internal prescaler counter. ▄ Internal APB clock f CLKIN The default internal clock source is the APB clock f...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Trigger Controller The trigger controller is used to select the trigger source and setup the trigger level or edge trigger condition. For the internal trigger input, it can be selected by the Trigger Selection bits TRSEL in the TRCFR register.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Slave Controller The SCTM can be synchronized with an external trigger in several modes including the Restart mode, the Pause mode and the Trigger mode which is selected by the SMSEL field in the MDCFR register.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Pause Mode In the Pause Mode, the selected STI input signal level is used to control the counter start/stop operation. The counter starts to count when the selected STI signal is at a high level and stops counting when the STI signal is changed to a low level, here the counter will maintain its present value and will not be reset.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Channel Controller The SCTM channel can be used as the capture input or compare match output. The capture input or compare match output channel is composed of a preload register and a shadow register. Data access of the APB bus is always through the read/write preload register.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Capture Counter Value Transferred to CHCCR When the channel is used as a capture input, the counter value is captured into the Channel Capture/Compare Register (CHCCR) when an effective input signal transition occurs. Once the capture event occurs, the CHCCIF flag in the INTSR register is set accordingly.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Input Stage The input stage consists of a digital filter, a channel polarity selection, edge detection and a channel prescaler. The channel input signal (TI) is sampled by a digital filter to generate a filtered input signal TIFP.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Output Stage The SCTM output has function for compare match, single pulse or PWM output. The channel output SCTM_CHO is controlled by the CHOM, CHP and CHE bits in the corresponding CHOCFR, CHPOLR and CHCTR registers.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Counter Value CHOM=0x03, CHPRE=0 (Output toggle, preload disable) CHCCR (New value 2) CHCCR (New value 3) CHCCR (New value 1) CHCCR Time Update CHCCR value CHOREF (Update Event) Figure 129. Toggle Mode Channel Output Reference Signal (CHPRE = 0)
Page 416
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [3:0] Channel Input Source TI Filter Setting These bits define the frequency divided ratio used to sample the TI signal. The Digital filter in the SCTM is an N-event counter where N is defined as how many valid transitions are necessary to output a filtered signal.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Real Time Clock (RTC) Introduction The Real Time Clock, RTC, circuitry includes the APB interface, a 32-bit up-counter, a control register, a prescalmer, a compare register and a status register. Most of the RTC circuits are located in the Backup Domain, as shown shaded in the accompanying figure, except for the APB interface.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Descriptions RTC Related Register Reset The RTC registers can only be reset by either a Backup Domain power on reset, PORB, or by a Backup Domain software reset by setting the BAKRST bit in the BAKCR register. Other reset events have no effect to clear the RTC registers.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 RTC Counter Operation The RTC provides a 32-bit up-counter which increments at the falling edge of the CK_SECOND clock and whose value can be read from the RTCCNT register asynchronously via the APB bus.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 RTCOUT Output Pin Configuration The following table shows RTCOUT output format according to the mode, polarity, and event selection setting. Table 43. RTCOUT Output Mode and Active Level Setting ROWM ROES RTCOUT Output Waveform...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Map The following table shows the RTC registers and reset values. Note all the registers in this unit are located at the V backup power domain. Table 44. RTC Register Map...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 RTC Compare Register – RTCCMP This register defines a specific value to be compared with the RTC counter value. Offset: 0x004 Reset value: 0x0000_0000 (Reset by Backup Domain reset only) RTCCMPV Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 RTC Control Register – RTCCR This register specifies a range of RTC circuitry control bits. Offset: 0x008 Reset value: 0x0000_0F04 (Reset by Backup Domain reset only) Reserved Type/Reset Reserved ROLF ROAP ROWM...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 RTC Status Register – RTCSR This register stores the counter flags. Offset: 0x00C Reset value: 0x0000_0000 (Reset by Backup Domain reset and RTCEN bit change from 1 to 0) Reserved Type/Reset Reserved...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Watchdog Timer (WDT) Introduction The Watchdog timer is a hardware timing circuitry that can be used to detect a system lock-up due to software trapped in a deadlock. The Watchdog timer can be operated in a reset mode. The Watchdog timer will generate a reset when the counter counts down to a zero value.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Description The Watchdog timer is formed from a 12-bit count-down counter and a fixed 3-bit prescaler. The largest time-out period is 16 seconds, using the LSE or LSI clock and a 1/128 maximum prescaler value.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 The Watchdog timer should be used in the following manners: ▄ Set the Watchdog timer reload value (WDTV) and reset in the WDTMR0 register. ▄ Set the Watchdog timer delta value (WDTD) and prescaler in the WDTMR1 register.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Inter-Integrated Circuit (I Introduction The I C Module is an internal circuit allowing communication with an external I C interface which is an industry standard two line serial interface used for connection to external hardware. These two serial lines are known as a serial data line, SDA, and a serial clock line, SCL.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Two–wire I C serial interface ● Serial data line (SDA) and serial clock (SCL) ▄ Multiple speed modes ● Standard mode – 100 kHz ● Fast mode – 400 kHz ●...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 STOP Condition START Condition Figure 137. START and STOP Condition Data Validity The data on the SDA line must be stable during the high period of the SCL clock. The SDA data state can only be changed when the clock signal on the SCL line is in a low state.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Addressing Format The I C interface starts to transfer data after the master device has sent the address to confirm the targeted slave device. The address frame is sent just after the START signal by master device. The addressing mode selection bit named ADRM in the I2CCR register should be defined to choose either the 7-bit or 10-bit addressing mode.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 10-bit Address Format In order to prevent address clashes, due to the limited range of the 7-bit addresses, a new 10-bit address scheme has been introduced. This enhancement can be mixed with the 7-bit addressing mode which increases the available address range about ten times.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Data Transfer and Acknowledge Once the slave device address has been matched, the data can be transmitted to or received from the slave device according to the transfer direction specified by the R/W bit. Each byte is followed...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Clock Synchronization Only one master device can generate the SCL clock under normal operation. However when there is more than one master trying to generate the SCL clock, the clock should be synchronized so that the data output can be compared.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 General Call Addressing The general call addressing function can be used to address all the devices connected to the I bus. The master device can activate the general call function by writing a value “00” into the TAR and setting the RWD bit to 0 in the I2CTAR register on the addressing frame.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Master Transmitter Mode Start condition Users write the target slave device address and communication direction into the I2CTAR register after setting the I2CEN bit in the I2CCR register. The STA flag in the I2CSR register is set by hardware after a start condition occurs.
Page 455
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Master Receiver Mode Start condition The target slave device address and communication direction must be written into the I2CTAR register. The STA flag in the I2CSR register is set by hardware after a start condition occurs. In order to send the following address frame, the STA flag must be cleared to 0 if it has been set to 1.The...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Close / Continue Transmission The master device needs to reset the AA bit in the I2CCR register to send a NACK signal to the slave device before the last data byte transfer has been completed. After the last data byte has been received from the slave device, the master device will hold the SCL line at a logic low state following after a NACK signal sent by the master device to the slave device.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Slave Transmitter Mode Address Frame In the 7-bit addressing mode, the ADRS bit in the I2CSR register is set after the slave device receives the calling address which matches with the slave device address. In the 10-bit addressing mode, the ADRS bit is set when the first header byte is matched and the second address byte is matched respectively.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Slave Receiver Mode Address Frame The ADRS bit in the I2CSR register is set after the slave device receives the calling address which matches with the slave device address. After the ADRS bit has been set to 1, it must be cleared to 0 to continue the data transfer process.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Conditions of Holding SCL Line The following conditions will cause the SCL line to be held at a logic low state by hardware resulting in all the I C transfers being stopped. Data transfer will be continued after the creating conditions are eliminated.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C Timeout Function In order to reduce the occurrence of I C lockup problem due to the reception of erroneous clock source, a timeout function is provided. If the I C bus clock source is not received for a certain timeout period, then a corresponding I C timeout flag will be asserted.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Map The following table shows the I C registers and reset values. Table 47. I C Register Map Register Offset Description Reset Value I2CCR 0x000 C Control Register 0x0000_2000 I2CIER 0x004...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions C Control Register – I2CCR This register specifies the corresponding I C function enable control. Offset: 0x000 (0) Reset value: 0x0000_2000 Reserved Type/Reset Reserved Type/Reset SEQFILTER COMBFILTEREn ENTOUT Reserved DMANACK RXDMAE TXDMAE...
Page 463
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions RXDMAE DMA Mode RX Request Enable Control 0: RX DMA request disabled 1: RX DMA request enabled If the data register is not empty in the receiver mode and the RXDMAE bit is...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C Interrupt Enable Register – I2CIER This register specifies the corresponding I C interrupt enable bits. Offset: 0x004 Reset value: 0x0000_0000 Reserved Type/Reset Reserved RXBFIE TXDEIE RXDNEIE Type/Reset 0 RW 0 RW...
Page 465
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions ARBLOSIE Arbitration Loss Interrupt Enable Bit in the I C multi-master mode 0: Interrupt disabled 1: Interrupt enabled When the I2CEN bit in the I2CCR register is cleared to 0, this bit is cleared to 0 by hardware.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C Status Register – I2CSR This register contains the I C operation status. Offset: 0x00C Reset value: 0x0000_0000 Reserved Type/Reset Reserved TXNRX MASTER BUSBUSY RXBF TXDE RXDNE Type/Reset 0 RO 0 RO...
Page 468
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [17] TXDE Data Register Empty Using in Transmitter Mode 0: Data register I2CDR not empty 1: Data register I2CDR empty This bit is set when the I2CDR register is empty in the Transmitter mode. Note that the TXDE bit will be set after the address frame is being transmitted to inform that the data to be transmitted should be loaded into the I2CDR register.
Page 469
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions ADRS Address Transmit (master mode) / Address Receive (slave mode) Flag Address Sent in Master Mode 0: Address frame has not been transmitted 1: Address frame has been transmitted For the 7-bit addressing mode, this bit is set after the master device receives the address frame acknowledge bit sent from the slave device.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C SCL High Period Generation Register – I2CSHPGR This register specifies the I C SCL clock high period interval. Offset: 0x010 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset SHPG Type/Reset 0 RW...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C SCL Low Period Generation Register – I2CSLPGR This register specifies the I C SCL clock low period interval. Offset: 0x014 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset SLPG Type/Reset 0 RW...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C Data Register – I2CDR This register specifies the data to be transmitted or received by the I C module. Offset: 0x018 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset DATA...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C Address Mask Register – I2CADDMR This register specifies which bit of the I C address is masked and not compared with corresponding bit of the received address frame. Offset: 0x020 Reset value: 0x0000_0000...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C Address Snoop Register – I2CADDSR This register is used to indicate the address frame value appeared on the I C bus. Offset: 0x024 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 C Timeout Register – I2CTOUT This register specifies the I C Timeout counter preload value and clock prescaler ratio. Offset: 0x028 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset 0 RW 0 RW...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Serial Peripheral Interface (SPI) Introduction The Serial Peripheral Interface, SPI, provides an SPI protocol data transmit and receive functions in both master or slave mode. The SPI interface uses 4 pins, among which are serial data input and output lines MISO and MOSI, the clock line SCK, and the slave select line SEL.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Master or slave mode ▄ Master mode speed up to f PCLK ▄ Slave mode speed up to f PCLK ▄ Programmable data frame length up to 16 bits ▄...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SPI Serial Frame Format The SPI interface format is base on the Clock Polarity, CPOL, and the Clock Phase, CPHA, configurations. ▄ Clock Polarity Bit – CPOL When the Clock Polarity bit is cleared to 0, the SCK line idle state is LOW. When the Clock Polarity bit is set to 1, the SCK line idle state is HIGH.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Figure 152 shows the continuous data transfer timing diagram of this format. Note that the SEL signal must change to an inactive level between each data frame. SEL (SELAP=0) SEL (SELAP=1) MOSI/MISO...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Figure 154 shows the continuous data transfer diagram timing. Note that the SEL signal must remain active until the last data transfer has completed. SEL (SELAP=0) SEL (SELAP=1) MOSI/MISO Data1 Data2 Figure 154. SPI Continuous Transfer Timing Diagram – CPOL = 0, CPHA = 1...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Figure 156 shows the continuous data transfer timing of this format. Note that the SEL signal must change to an inactive level between each data frame. SEL (SELAP=0) SEL (SELAP=1) ½ SCK ½...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Status Flags TX Buffer Empty – TXBE This TXBE flag is set when the TX buffer is empty in the non-FIFO mode or when the TX FIFO data length is equal to or less than the TX FIFO threshold level as defined by the TXFTLS field in the SPIFCR register in the FIFO mode.
Page 485
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Write Collision – WC The following conditions will assert the Write Collision Flag. ▄ The FIFOEN bit in the SPIFCR register is cleared The write collision flag is asserted when new data is written into the SPIDR register while both the TX buffer and the shift register are already full.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Map The following table shows the SPI registers and their reset values. Table 52. SPI Register Map Register Offset Description Reset Value SPICR0 0x000 SPI Control Register 0 0x0000_0000 SPICR1 0x004...
Page 487
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [11:8] GUADT Guard Time GUADTEN=1 0x0:1 SCK 0x1:2 SCK 0x2: 3 SCK Note that GUADT is for master mode only. GUADTEN Guard Time Enable 0: Guard Time is 1/2 SCK 1: When set this bit, Guard time can be controlled by GUADT Note that GUADTEN is for master mode only.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SPI Control Register 1 – SPICR1 This register specifies the SPI parameters including the data length, the transfer format, the SEL active polarity/ mode, the LSB/MSB control, and the master/slave mode. Offset:...
Page 489
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [10:8] FORMAT SPI Data Transfer Format These three bits are used to determine the data transfer format of the SPI interface FORMAT [2:0] CPOL CPHA Others Reserved CPOL: Clock Polarity...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions TXBEIEN TX Buffer Empty Interrupt Enable 0: Disable 1: Enable The TX buffer empty interrupt request will be generated when the TXBE flag and the TXBEIEN bit are set. In the FIFO mode, the interrupt request being generated depends upon the TX FIFO trigger level setting.
Page 494
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions Write Collision flag 0: No write collision 1: Write collision has occurred. This bit is set by hardware and cleared by writing 1. RXBNE Receive Buffer Not Empty flag...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SPI FIFO Control Register – SPIFCR This register contains the related SPI FIFO control including the FIFO enable control and the FIFO trigger level selections. Offset: 0x018 Reset value: 0x0000_0000 Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Universal Synchronous Asynchronous Receiver Transmitter (USART) Introduction The Universal Synchronous Asynchronous Receiver Transceiver, USART, provides a flexible full duplex data exchange using synchronous or asynchronous transfer. The USART is used to translate data between parallel and serial interfaces, and is also commonly used for RS232 standard communication.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Supports both asynchronous and clocked synchronous serial communication modes ▄ Full Duplex Communication Capability ▄ Programming baud rate up to 3 Mbit/s for asynchronous mode and 6 Mbit/s for synchronous mode ▄...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Function Descriptions Serial Data Format The USART module performs a parallel-to-serial conversion on data that is written to the transmit FIFO registers and then sends the data with the following format: Start bit, 7 ~ 9 LSB first data bits, optional Parity bit and finally 1 ~ 2 Stop bits.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Baud Rate Generation The baud rate for the USART receiver and transmitter are both set with the same values. The baud- rate divisor, BRD, has the following relationship with the USART clock which is known as CK_ USART.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 RTS Flow Control In the RTS flow control, the USART RTS pin is active with a logic low state when the receive data register is empty. It means that the receiver is ready to receive a new data. When the RX FIFO reaches the trigger level which is specified by configuring the RXTL field in the USRFCR register, the USART RTS pin is inactive with a logic high state.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 IrDA The USART IrDA mode is provided half-duplex point-to-point wireless communication. The USART module includes an integrated modulator and demodulator which allow a wireless communication using infrared transceivers. The transmitter specifies a logic data ‘0’ as a ‘high’...
Page 505
Cortex ® -M0+ MCU HT32F52342/HT32F52352 IrDA Normal Mode For the IrDA normal mode, the width of each transmitted pulse generated by the transmitter modulator is specified as 3/16 of the baud rate clock period. The receiver pulse width for the IrDA receiver demodulator is based on the IrDA receive debounce filter which is implement using an 8-bit down-counting counter.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 TX_Data Transmitter Modulation TXSEL RX_Data Receiver Demodulation IrDAEN Figure 167. USART I/O and IrDA Block Diagram RS485 Mode The RS485 mode of the USART provides the data transmission on the interface transmitted over a 2-wire twisted pair bus.
Page 508
Cortex ® -M0+ MCU HT32F52342/HT32F52352 RS485 Normal Multi-drop Operation Mode – NMM When the RS485 mode is configured as an addressable slave, it will operate in the Normal Multi- drop Operation Mode, NMM. This mode is enabled when the RSNMM field is set in the RS485CR register.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Synchronous Master Mode The data is transmitted in a full-duplex style in the USART Synchronous Master Mode, i.e., data transmission and reception both occur at the same time and only support master mode. The USART CTS pin is the synchronous USART transmitter clock output.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Interrupts and Status The USART can generate interrupts when the following event occurs and corresponding interrupt enable bits are set: ▄ Receive FIFO time-out interrupt: An interrupt will be generated when the USART receive FIFO does not receive a new data package during the specified time-out interval.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions USART Data Register – USRDR The register is used to access the USART transmitted and received FIFO data. Offset: 0x000 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset Type/Reset...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 USART Control Register – USRCR The register specifies the serial parameters such as data length, parity, and stop bit for the USART. It also contains the USART enable control bits together with the USART mode and data transfer mode selections.
Page 514
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [11] Parity Bit Enable 0: Parity bit is not generated (transmitted data) or checked (receive data) during transfer. 1: Parity bit is generated or checked during transfer. Note: When the WLS field is set to “10” to select the 9-bit data format, writing to the PBE bit has no effect.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USART FIFO Control Register – USRFCR This register specifies the USART FIFO control and configurations including threshold level and reset function together with the USART FIFO status. Offset: 0x008 Reset value: 0x0000_0000...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions TX FIFO Reset Setting this bit will generate a reset pulse to reset TX FIFO which will empty the TX FIFO, i.e., the TX pointer will be reset to 0 after a reset signal. This bit returns to 0 automatically after the reset pulse is generated.
Page 517
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions FEIE Framing Error Interrupt Enable 0: Disable interrupt 1: Enable interrupt An interrupt will be generated when the FEI bit is set in the URSIFR register. PEIE Parity Error Interrupt Enable...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USART Status & Interrupt Flag Register – USRSIFR This register contains the corresponding USART status. Offset: 0x010 Reset value: 0x0000_0180 Reserved Type/Reset Reserved Type/Reset Reserved CTSS CTSC RSADDE Type/Reset 0 WC 0 WC...
Page 519
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions RXTOF Receive FIFO Time-Out Flag 0: RX FIFO Time-Out does not occur. 1: RX FIFO Time-Out occurs. This bit is clear when RX FIFO is empty. RXDR Receive FIFO Ready Flag...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USART Timing Parameter Register – USRTPR This register contains the USART timing parameters including the transmitter time guard parameters and the receive FIFO time-out value together with the RX FIFO time-out function enable control.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USART IrDA Control Register – IrDACR This register is used to control the IrDA mode of USART. Offset: 0x018 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset IrDAPSC Type/Reset 0 RW 0 RW...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions IrDAEN IrDA Enable control 0: Disable IrDA mode 1: Enable IrDA mode USART RS485 Control Register – RS485CR This register is used to control the RS485 mode of USART.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USART Divider Latch Register – USRDLR The register is used to determine the USART clock divided ratio to generate the appropriate baud rate. Offset: 0x024 Reset value: 0x0000_0010 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Universal Asynchronous Receiver Transmitter (UART) Introduction The Universal Asynchronous Receiver Transceiver, UART, provides a flexible full duplex data exchange using asynchronous transfer. The UART is used to translate data between parallel and serial interfaces, and is also commonly used for RS232 standard communication.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Supports asynchronous serial communication modes ▄ Full Duplex Communication Capability ▄ Programming baud rate up to 3 Mbit/s. ▄ Fully programmable serial communication functions including: ● Word length: 7, 8, or 9-bit character ●...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Baud Rate Generation The baud rate for the UART receiver and transmitter are both set with the same values. The baud- rate divisor, BRD, has the following relationship with the UART clock which is known as CK_ UART.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 UART Control Register – URCR The register specifies the serial parameters such as data length, parity, and stop bit for the UART. Offset: 0x004 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 UART Interrupt Enable Register – URIER This register is used to enable the related UART interrupt function. The UART module generates interrupts to the controller when the corresponding events occur and the corresponding interrupt enable bits are set.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions TXDEIE Transmit Data Register Empty Interrupt Enable 0: Disable interrupt 1: Enable interrupt An interrupt is generated when the transmit data register empty interrupt is enabled and the TXDE bit is set in the URSIFR register.
Page 535
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions RXDR RX Data Ready 0: Receive data register is empty 1: Received data in the receive data register is ready to read. This bit is set by hardware when the content of the receive shift register RDR has been transferred to the URDR register.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 UART Divider Latch Register – URDLR The register is used to determine the UART clock divided ratio to generate the appropriate baud rate. Offset: 0x024 Reset value: 0x0000_0010 Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Smart Card Interface (SCI) Introduction The Smart Card Interface, SCI, is compatible with the ISO 7816-3 standard. This interface includes functions for card Insertion/Removal detection, SCI data transfer control logic and data buffers, internal Timer Counters and corresponding control logic circuits to perform the required Smart Card operations.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Supports ISO 7816-3 standard ▄ Character Transfer Mode ▄ 1 transmit buffer and 1 receive buffer ▄ 11-bit ETU (elementary time unit) counter ▄ 9-bit guard time counter ▄ 24-bit general purpose waiting time counter ▄...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 where: ▄ etu is the nominal duration of the data bit on the signal SCI_DIO provided to the card by the interface ▄ Di is the bit-rate adjustment factor ▄ Fi is the clock rate conversion factor ▄...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Compensation mode As the value of the ETUR register is obtained by the above procedure, the calculation results of the value may not be an integer. If the calculation result is not an integer and is less than the integer n but greater than the integer (n-1), either the integer n or (n-1) should be written into the ETUR register depending upon whether the result is closer to integer n or (n-1).
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Start Start Start Start Char 0 Char 1 Char n SCI_DIO Start Start Start SCI_DIO Smart CardàSCI Char 0 Char 1 SCIàSmart Card Figure 176. Guard Time Duration Waiting Time Counter The Waiting Time counter, WT, is a 24-bit down counting counter which generates a maximum time duration, denoted as t , for data transfer.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Start bit Program the CWT Program the BWT SCI_DIO Char 0 Char 1 Char n Start bit SCI_DIO SCIàSmart Card Char 0 Char 1 BWT is reloaded on Start bit Smart CardàSCI Figure 177.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 CPREF Edge Detection SCI_DET Card Insertion / Removal Interrupt request CARDIRE DETCNF Figure 178. SCI Card Detection Diagram SCI Data Transfer Mode The SCI data transfer with the external Smart Card is implemented with two operating modes. One is the SCI mode while the other is the Manual Mode.
Page 545
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Repetition Function There is a Character Repetition function supported by the SCI transfer circuitry when a parity error occurs. The Character Repetition function is enabled by setting the CREP bit in the CR register to 1.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Interrupt Generator There are several conditions for the SCI to generate an SCI interrupt. When these conditions are met, an interrupt signal will be generated to obtain the attention of the microcontroller. These conditions are a Smart Card Insertion/Removal, a Waiting Time Counter Underflow, a Parity error, an end of a Character Transmission or Reception and an empty Transmit buffer.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 PDMA Interface The PDMA interface is integrated in the SCI module. The PDMA function can be enabled by setting the TXDMA or RXDMA bit to 1 in the transmitter or receiver mode respectively. When the...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions SCI Control Register – CR This register contains the SCI control bits. Offset: 0x000 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved RXDMA TXDMA Type/Reset 0 RW Reserved DETCNF ENSCI...
Page 549
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions SCIM SCI Mode Selection 0: SCI data transfer in manual mode 1: SCI data transfer in SCI mode This bit is set and cleared by the application program to select the SCI data Transfer Mode.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SCI Status Register – SR This register contains the SCI status bits. Offset: 0x004 Reset value: 0x0000_0080 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset TXBEF CPREF reserved TXCF RXCF PARF Type/Reset 1 RO...
Page 551
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions PARF Parity Error Request Flag. 0: No parity error occurs 1: Parity error has occurred This bit is set by hardware and cleared by writing a “0” into it. When a character is received, the parity check circuitry will check that the parity is correct or not.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 SCI Elementary Time Unit Register – ETUR The register specifies the value determined by the formula described in the ETU section. It also includes the Compensation function enable control bit for the ETU time granularity.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SCI Guard Time Register – GTR This register specifies the guard time value obtained from the Answer-to-Reset packet described in the Guard Time Counter section. Offset: 0x010 Reset value: 0x0000_000C Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SCI Waiting Time Register – WTR This register specifies the waiting time value obtained from the Answer-to-Reset packet described in the Waiting Time Counter section. Offset: 0x014 Reset value: 0x0000_2580 Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SCI Interrupt Enable Register – IER This register specifies the interrupt enable control bits for all of the interrupt events in the SCI. Offset: 0x018 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset...
Page 557
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions RXCE Character Reception Completion interrupt enable control 0: Disabled 1: Enabled This bit is set and cleared by the application program and is used to control the Character Reception Completion interrupt. If this bit is set to 1, the Character Reception Completion interrupt will be generated at the end of the character reception.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 SCI Interrupt Pending Register – IPR This register contains the interrupt pending flags for all of the interrupt events in the SCI. These pending flags can be masked by the corresponding interrupt enable control bits.
Page 559
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions TXCP Character Transmission Completion interrupt pending flag 0: No interrupt pending 1: Interrupt pending This bit is set by hardware and cleared by a read access to this register using the application program.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SCI Transmit Buffer – TXB This register is used to store the SCI data to be transmitted. Offset: 0x020 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset Type/Reset 0 RW 0 RW...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 SCI Prescaler Register – PSCR This register specifies the prescaler division ratio which is used the SCI internal clock. Offset: 0x028 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USB Device Controller (USB) Introduction The USB device controller is compliant with the USB 2.0 full-speed specification. There is one control endpoint know as Endpoint 0 and seven configurable endpoints (EP1~EP7). A 1024- byte EP-SRAM is used for the endpoint buffers.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Descriptions Endpoints The USB Endpoint 0 is the only bidirectional endpoint dedicated to USB control transfer. The device also contains seven unidirectional endpoints for other USB transfer types. There are three endpoints (EP1~EP3) which supports a single buffering function which is used for Bulk and Interrupt IN or OUT data transfer.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 CK_USART BRD =18 Reference Divisor Clock Parity Bit Next Start Start Bit Bit0 Bit1 Bit2 Bit3 Bit4 Bitn Stop Bit n=6~8 Figure 181. Endpoint Buffer Allocation Example Serial Interface Engine – SIE The Serial Interface Engine, SIE, which is connected to the USB full-speed transceiver and internal USB control circuitry provides a temporal buffer for the transmitted and received data.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 IN Transaction Buffer toggled by SIE hardware Endpoint 4 Buffer Accessed Endpoint 4 Endpoint 4 by USB SIE Buf 0 Buf 1 Buf 0 1st Data packet 2nd Data packet 3rd Data packet...
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Suspend Mode and Wake-up According to USB specifications, the device must enter the suspend mode after a 3 ms bus idle time. When the USB device enters the suspend mode, the current from the USB bus must not be greater than 500 μA to meet the specification suspend mode current requirements.
Page 567
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Offset Description Reset Value USBEP3IER 0x054 USB Endpoint 3 Interrupt Enable Register 0x0000_0000 USBEP3ISR 0x058 USB Endpoint 3 Interrupt Status Register 0x0000_0000 USBEP3TCR 0x05C USB Endpoint 3 Transfer Count Register 0x0000_0000...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions USB Control and Status Register – USBCSR This register specifies the USB control bits and USB data line status. Offset: 0x000 Reset value: 0x0000_00X6 Reserved Type/Reset Reserved Type/Reset Reserved DPWKEN...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions LPMODE Low-power Mode Control This bit is used to determine the USB operating mode. Setting this bit will force the USB to enter the low-power mode. When USB bus traffic, known as a wakeup event, is detected by the hardware, this bit should be cleared by software.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USB Interrupt Status Register – USBISR This register specifies the USB interrupt status. Offset: 0x008 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset EP7IF EP6IF EP5IF EP4IF EP3IF EP2IF EP1IF EP0IF Type/Reset 0 WC...
Page 572
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions URSTIF USB Reset Interrupt Flag This bit is set by the hardware when the USB reset has been detected. When a USB reset occurs, the internal protocol state machine will be reset and an USB reset interrupt will be generated if the URSTIE bit in the USBIER register is set to 1.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USB Frame Count Register – USBFCR This register specifies the lost Start-of-Frame number and the USB frame count. Offset: 0x00C Reset value: 0x0000_0000 Reserved Type/Reset Reserved LSOF SOFLCK Type/Reset 0 RO 0 RO...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USB Endpoint 0 Control and Status Register – USBEP0CSR This register specifies the Endpoint 0 control and status. Offset: 0x014 Reset value: 0x0000_0002 Reserved Type/Reset Reserved Type/Reset Reserved Type/Reset Reserved STLRX NAKRX...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions NAKTX NAK Status for transmission (IN) transfer This bit is toggled from 0 to 1 by the hardware circuitry, which will result in a NAK signal in the handshake phase of an IN transaction after an ACK signal has been received.
Page 577
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions STRXIE SETUP Token Received Interrupt Enable Control 0: Disable interrupt 1: Enable interrupt UERIE USB Error Interrupt Enable Control 0: Disable interrupt 1: Enable interrupt STLIE STALL Transmitted Interrupt Enable Control...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions IDTXIF IN Data Transmitted Interrupt Flag This bit is set by the hardware when a data packet is transmitted to and then an ACK signal is received from the USB host.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USB Endpoint 1 ~ 3 Control and Status Register – USBEPnCSR, n = 1 ~ 3 This register specifies the Endpoint 1 ~ 3 control and status bit. Offset: 0x028 (n = 1), 0x03C (n = 2), 0x050 (n = 3)
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions DTGTX Data Toggle bit for transmission transfers. This bit contains the required value of the data toggle bit (0=DATA0, 1=DATA1) for the next data packet to be transmitted. When the current data packet is transmitted...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions ODOVIF OUT Data Buffer Overrun Interrupt Flag. This bit is set by the hardware circuitry when the received data byte count is larger than the corresponding endpoint OUT data buffersize.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 USB Endpoint 4 ~ 7 Control and Status Register – USBEPnCSR, n = 4 ~ 7 This register specifies the Endpoint 4 ~ 7 control and status bits. Offset: 0x064 (n = 4), 0x078 (n = 5), 0x08C (n = 6), 0x0A0 (n = 7)
Page 587
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions MDBTG CPU Double Buffer Toggle bit The MDBTG bit is used to indicate which data buffer is accessed by the CPU if the double buffering function is enabled. It can be toggled to switch to the other buffer by the CPU application software after the data in the current buffer accessed by the CPU has been properly setup.
Page 588
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions DTGTX Data Toggle bit for transmission transfers. If the endpoint is not used for Isochronous transfer, this bit is available for usage. This bit contains the required value of the data toggle bit (0 = DATA0, 1 = DATA1) for the next data packet to be transmitted.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Peripheral Direct Memory Access (PDMA) Introduction The Peripheral Direct Memory Access circuitry, PDMA, provides 6 unidirectional channels for dedicated peripherals to implement the peripheral-to-memory and memory-to-peripheral data transfer. The memory-to-memory data transfer such as the FLASH-to-SRAM or SRAM-to- SRAM type is also supported and requested by the application program.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Description AHB Master The PDMA is an AHB master connected to other AHB peripherals such as the FLASH memory, the SRAM memory and the AHB-to-APB bridges through the bus-matrix. The CPU and PDMA can access different AHB slaves at the same time via the bus-matrix.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Channel transfer A PDMA channel transfer is split into multiple block transactions with PDMA arbitration occurring at the end of each block transaction. Although these channel transfers can all be activated, there is only one block transaction being transferred through the bus at a time. The channel transfer sequence depends upon the channel priority setting of each PDMA channel.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Transfer Request For a peripheral-to-memory or memory-to-peripheral transfer, one peripheral hardware request will trigger one block transaction of the dedicated PDMA channel. However, a complete data transfer of the relevant dedicated PDMA channel will be triggered when a software request occurs. It is recommended that the PDMA channel is configured to have a lower priority level and a smaller block length which is requested by the software for memory-to-memory data copy applications.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Transfer Interrupt There are five transfer events during which the interrupts can be asserted for each PDMA channel. These are the block transaction end (BE), half-transfer (HT), transfer complete (TC), transfer error (TE) and global transfer event (GE). Setting the corresponding control bits in the PDMA interrupt enable register PDMAIER will enable the relevant interrupt events.
Page 599
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Offset Description Reset Value PDMA Base Address = 0x4009_0000 PDMACH4CTSR 0x074 PDMA Channel 4 Current Transfer Size Register 0x0000_0000 PDMA Channel 5 Registers PDMACH5CR 0x078 PDMA Channel 5 Control Register 0x0000_0000...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions PDMA Channel n Control Register – PDMACHnCR, n = 0 ~ 5 This register is used to specify the PDMA channel n data transfer configuration. Offset: 0x000 (0), 0x018 (1), 0x030 (2), 0x048 (3), 0x060 (4), 0x078 (5)
Page 601
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions SRCAMODn Channel n Source Address Mode selection 0: Linear address mode 1: Circular address mode In the linear address mode, the current source address value can be incremented or decremented, determined by the SRCAINCn bit value during a complete transfer.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 PDMA Channel n Current Transfer Size Register – PDMACHnCTSR, n=0~5 This register is used to indicate the current block transaction count. Offset: 0x014 (0), 0x02C (1), 0x044 (2), 0x05C (3), 0x074 (4), 0x08C (5)
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 PDMA Interrupt Status Register – PDMAISR This register is used to indicate the corresponding interrupt status of the PDMA channel 0 ~ 5. Offset: 0x120 Reset value: 0x0000_0000 Reserved TEISTA5 TCISTA5 HTISTA5...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [ 2 5 ] , [ 2 0 ] , GEISTAn Channel n Global Transfer Interrupt Status (n= 0 ~ 5) [15], [10], [5], 0: No TE, TC, HT or BE event occurs 1: TE, TC, HT, or BE event occurs This bit is set by hardware and is cleared by writing a “1”...
Page 608
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [ 2 6 ] , [ 2 1 ] , BEICLRn Channel n Block Transaction End Interrupt Status Clear (n = 0 ~ 5) [16], [11], [6], 0: No Operation 1: Clear the corresponding BEISTAn bit in the PDMAISR register Writing a “1”...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 PDMA Interrupt Enable Register – PDMAIER This register is used to enable or disable the related interrupts of the PDMA channel 0 ~ 5. Offset: 0x130 Reset value: 0x0000_0000 Reserved TEIE5 TCIE5...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Extend Bus Interface (EBI) Introduction The external bus interface is able to access external parallel interface devices such as SRAM, Flash and LCD modules. The interface is memory mapped into the internal address bus of the CPU. The data and address lines can be multiplexed in order to reduce the number of pins required to connect to external devices.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Function Descriptions An overview of the EBI module is shown in Figure 186. The EBI enables internal CPU and other bus matrix master peripherals to access external memories or devices. The EBI automatically translates the internal AHB transactions into the external device protocol. In particular, if the selected external memory is 16 or 8 bits width, then 32-bit wide transactions on the AHB are auto split into consecutive 16 or 8-bit accesses.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Non-multiplexed 8-bit Data 8-bit Address Mode In this mode, 8-bit address and 8-bit data is supported. The address is located on the higher 8 bits of the EBI_AD lines and the data uses the lower 8 bits. This mode is set by programming the MODE field in the EBICR register to D8A8.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Non-multiplexed 16-bit Data N-bit Address Mode In this non-multiplexed mode 16-bit data is provided on the 16 EBI_AD lines. The addresses are provided on the EBI_A lines. This mode is set by programming the MODE field in the EBICR register to D16.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Multiplexed 16-bit Data, 16-bit Address Mode In this mode, 16-bit address and 16-bit data is supported, but the utilization of an external latch and an extra signal EBI_ALE is required. The 16-bit address and 16-bit data bits are multiplexed on the EBI_AD pins.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 EBI Bank Access The EBI is split into 4 different address regions and each owns an individual EBI_CSn line. When accessing one of the memory regions, the corresponding EBI_CSn line is asserted. This way up to 4 separate devices can share the EBI lines and be identified by the EBI_CSn line.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 PDMA Request The EBI only supports a software trigger for activating a PDMA service. Register Map The following table shows the EBI register and reset value. Table 72. EBI Register Map Register...
Page 621
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [14] NOIDLE2 No IDLE 2 0: Enable IDLE state insertion 1: Disable IDLE state insertion Enable or disable the insertion of an idle state between transactions for bank 2.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 EBI Parity Register – EBIPR This register specifies the polarity of the EBI control signal for each bank. Offset: 0x01C Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset 0 RW 0 RW Reserved...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Inter-IC Sound (I Introduction The I S is a synchronous communication interface that can be used as a master or slave to exchange data with other audio peripherals, such as ADCs or DACs. The I S supports a variety of data formats.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Functional Description S Master and Slave Mode The I S can operate in slave or master mode. Within the I S module the difference between these modes lies in the word select (WS) signal which determines the timing of data transmissions.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 S Clock Rate Generator The main (I S_MCLK) and bit clock (I S_BCLK) rates for the I S are determined by the values in the I2SCDR register. The required I S bit clock rate setting depends on the desired audio sample rate desired, the format (stereo/mono) used, and the data size.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 S Interface Format S-justified Stereo Mode The standard I S-justified mode is where the Most Significant Bit (MSB) of the stereo audio sample data is available on the second rising edge of the BCLK clock following a WS signal transition. In the stereo mode, a low WS state indicates left channel data and a high state indicates right channel data.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Left-justified Stereo Mode Left-Justified mode is where the Most Significant Bit (MSB) of the stereo audio sample data is available on the first rising edge of BCLK following a WS transition. Figure 204 and Figure 205 are shown with a left I S-justified stereo mode format.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Right-justified Stereo Mode Right-Justified mode is where the Least Significant Bit (LSB) of the stereo audio sample data is available on the rising edge of BCLK preceding a WS transition and where the MSB is transmitted first.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 S-justified Mono Mode In the I S-justified mono mode, the Most Significant Bit (MSB) of the mono audio sample data is available on the second rising edge of the BCLK clock following a falling edge on the WS signal.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Left-justified Mono Mode In the left-justified mono mode, the Most Significant Bit (MSB) of the mono audio sample data is available on the first rising edge of the BCLK clock following a falling edge on the WS signal.
Cortex ® -M0+ MCU HT32F52342/HT32F52352 Right-justified Mono Mode In the right-justified mono mode, the Least Significant Bit (LSB) of the mono audio sample data is available on the last rising edge of the BCLK clock preceding a rising edge on the WS signal.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 S-justified Repeat Mode In the I S-justified repeat mode, the Most Significant Bit (MSB) of the mono audio sample data is available on the second rising edge of the BCLK clock following a WS signal transition. In this mode the same data is transmitted twice, once when WS is low and again when WS is high.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 FIFO Control and Arrangement The I S handles audio data for transmission and reception and is performed via the FIFO controller. Each transmitted or received FIFO has a depth of 8 words (8 × 32-bit) and can buffer the data. The format is dependent upon the stereo/mono mode and sample size setting.
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 PDMA and Interrupt When the level of received data in the RX FIFO is equal to or greater than the level defined by the RXFTLS field in the I S FIFO control register (I2SFCR), the relative RXFTL flag will be set and then an I S RX PDMA request will be generated.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Register Descriptions S Control Register – I2SCR This register specifies the corresponding I S function enable control. Offset: 0x000 Reset value: 0x0000_0000 Reserved Type/Reset Reserved MCKINV BCKINV RCSEL RCEN Type/Reset 0 RW...
Page 641
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [11] CHANNEL Stereo or Mono 0: Stereo 1: Mono Note: This bit should be configured when I S is disabled. [10] REPEAT Repeat Mode 0: Disable 1: Enable This mode is for I S-justified stereo configuration only, transmitting the mono data on both channels and receiving just the left channel data and ignoring the right.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 S TX Data Register – I2STXDR This register is used to specify the I S transmitted data. Offset: 0x00C Reset value: 0x0000_0000 TXDR Type/Reset 0 WO 0 WO 0 WO 0 WO...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 S FIFO Control Register – I2SFCR This register contains the related I S FIFO control bits. Offset: 0x014 Reset value: 0x0000_0000 Reserved Type/Reset Reserved Type/Reset Reserved RXFRST TXFRST Type/Reset 0 RW RXFTLS...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 S Status Register – I2SSR This register contains the relevant I S status. Offset: 0x018 Reset value: 0x0000_0809 RXFS TXFS Type/Reset 0 RO 0 RO 0 RO 0 RO 0 RO 0 RO...
Page 647
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Bits Field Descriptions [10] RXFOV RX FIFO Overflow Flag 0: RX FIFO not overflow 1: RX FIFO overflow This bit is set by hardware and cleared by writing 1. RXFUD RX FIFO Underflow Flag...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 S Rate Counter Value Register – I2SRCNTR This register specifics the I S rate control counter value. Offset: 0x01C Reset value: 0x0000_0000 Reserved Type/Reset 0 RW 0 RW 0 RW 0 RW...
® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Cyclic Redundancy Check (CRC) Introduction The CRC (Cyclic Redundancy Check) calculation unit is an error detection technique test algorithm and uses to verify data transmission or storage data correctness. A CRC calculation takes a data stream or a block of data as input and generates a 16- or 32-bit output remainder.
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 Features ▄ Support CRC16 polynomial: 0x8005, X ▄ Support CCITT CRC16 polynomial: 0x1021, X ▄ Support IEEE-802.3 CRC32 polynomial: 0x04C11DB7, X +X+1 ▄ Support 1’s complement, byte reverse & bit reverse operation on data and checksum ▄...
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 CRC Seed Register – CRCSDR This register is used to specify the CRC seed. Offset: 0x004 Reset value: 0x0000_0000 SEED Type/Reset 0 WO 0 WO 0 WO 0 WO 0 WO 0 WO...
Page 655
32-Bit Arm ® Cortex ® -M0+ MCU HT32F52342/HT32F52352 CRC Data Register – CRCDR This register is used to specify the CRC input data. Offset: 0x00C Reset value: 0x0000_0000 CRCDATA Type/Reset 0 WO 0 WO 0 WO 0 WO 0 WO...
Page 656
Holtek's products are not authorized for use as critical components in life support devices or systems. Holtek reserves the right to alter its products without prior notification. For the most up-to-date information, please visit our web site at http://www.
Need help?
Do you have a question about the HT32F52342 and is the answer not in the manual?
Questions and answers