
Rev. 1.00
141 of 486
July 31, 2018
32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F50231/HT32F50241
9
Alternate Function Input / Output Control Unit (AFIO)
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 ~ C) registers. If the pin is selected as
unavailable item which is noted as “N/A” item in the “Alternate Function Mapping” table of the
device datasheet, this pin will be defined as default alternate function. Refer to the “Alternate
Function Mapping” table in the device datasheet for the detailed mapping of the alternate function
I/O pins. In addition to this flexible I/O multiplexing architecture, each peripheral has alternate
functions mapped onto different I/O pins to optimize the number of peripherals available in smaller
packages. The following description shows the setting of the PxCFGn [3:0] field.
▄
PxCFGn [3:0] = 0000: The default alternated function (after reset, AF0)
▄
PxCFGn [3:0] = 0001: Alternate Function 1 (AF1)
▄
PxCFGn [3:0] = 0010: Alternate Function 2 (AF2)
▄
…….
▄
PxCFGn [3:0] = 1110: Alternate Function 14 (AF14)
▄
PxCFGn [3:0] = 1111: Alternate Function 15 (AF15)
Table 19. AFIO Selection for Peripheral Map Example
AF0
AF1 AF2 AF3
AF4
AF5
AF6 AF7 AF8 AF9 AF10 AF11 AF12 AF13 AF14 AF15
System
Default GPIO ADC N/A
GPTM
/MCTM
SPI USART
/UART
I
2
C
N/A
N/A
N/A
N/A
N/A
PWM
N/A
System
Other
Lock Mechanism
The device also offers a lock function to lock the AFIO configuration using the GPIO lock register,
PxLOCKR, until a reset event occurs. Refer to the GPIO Locking Mechanism section in the GPIO
chapter for more details.
Register Map
The following table shows the AFIO registers and reset value.
Table 20. AFIO Register Map
Register
Offset
Description
Reset Value
ESSR0
0x000
EXTI Source Selection Register 0
0x0000_0000
ESSR1
0x004
EXTI Source Selection Register 1
0x0000_0000
GPACFGLR
0x020
GPIO Port A Configuration Low Register
0x0000_0000
GPACFGHR
0x024
GPIO Port A Configuration High Register
0x0000_0000
GPBCFGLR
0x028
GPIO Port B Configuration Low Register
0x0000_0000
GPBCFGHR
0x02C
GPIO Port B Configuration High Register
0x0000_0000
GPCCFGLR
0x030
GPIO Port C Configuration Low Register
0x0000_0000
GPCCFGHR
0x034
GPIO Port C Configuration High Register
0x0000_0000