
CH32V003
Reference Manual
V1.3
50
Chapter 7 GPIO and Alternate function (GPIO/AFIO)
The GPIO port can be configured for multiple input or output modes, with built-in pull-up or pull-down
resistors that can be turned off, and can be configured for push-pull or open-drain functions. the GPIO port
can also be multiplexed for other functions.
7.1 Main features
Each pin of the port can be configured to one of the following multiple modes.
l
Floating input
l
Pull-up input
l
Dropdown input
l
Analog input
l
Open drain output
l
Push-pull output
l
Multiplexing the inputs and outputs of
functions
Many pins have multiplexing capabilities, and many other peripherals map their output and input channels to
these pins. The specific usage of these multiplexed pins needs to be referred to the individual peripherals, and
the content of whether these pins are multiplexed and remapped is explained in this chapter.
7.2 Function description
7.2.1 Overview
Figure 7-1 GPIO module basic structure block diagram
As shown in Figure 7-1 I/O port structure, each pin has two protection diodes inside the chip, and the I/O port
can be divided into input and output driver modules internally. Among them, the input driver has a weak pull-
up and pull-down resistor optional, which can be connected to AD and other analog input peripherals; if the
input is to a digital peripheral, it needs to go through a TTL Schmitt trigger and then connect to GPIO input
registers or other multiplexed peripherals. The output driver has a pair of MOS tubes,
and the I/O port can be
configured as open-drain or push-pull output by configuring whether the upper and lower MOS tubes are
enabled or not; the output driver can also be configured internally to control the output by GPIO or by other
multiplexed peripherals.
Output
control
Input data
register
Output data
register
Bit set/reset
registers
Push-pull,
open-drain or
disabled
Protection
diode
Protection
diode
I/O pin
P-MOS
N-MOS
V
SS
V
DD
V
SS
V
DD
V
SS
V
DD
on/off
on/off
on/off
on/off
Analog Input
Alternate Function Input
TTL Schmitt
trigger
Input driver
Output driver
Alternate Function Output
To on-chip
peripheral
Read
Write
Read/write
from on-chip
peripheral