
GD32A50x User Manual
179
8.3.1.
GPIO pin configuration
During or just after the reset period, the alternative functions are all inactive and the GPIO
ports are configured into the input floating mode that input disabled without Pull-Up(PU)/Pull-
Down(PD) resistors. But the JTAG/Serial-Wired Debug pins are in input PU/PD mode after
reset:
PB7: JTDI in PU mode
PB8: JTCK / SWCLK in PD mode
PB9: JTMS / SWDIO in PU mode
PB3: NJTRST in PU mode
PB4: JTDO in
output
mode
The GPIO pins can be configured as inputs or outputs. When the GPIO pins are configured
as input pins, all GPIO pins have an internal weak pull-up and weak pull-down which can be
chosen. And the data on the external pins can be captured at every AHB clock cycle to the
port input status register (GPIOx_ISTAT).
When the GPIO pins are configured as output pins, user can configure the speed of the ports.
And chooses the output driver mode: Push-Pull or Open-Drain mode. The value of the port
output control register (GPIOx_OCTL) is output on the I/O pin.
There is no need to read-then-write when programming the GPIOx_OCTL at bit level, the
user can modify only one or several bits in a single atomic AHB write access by programming
‘1’ to the bit operate register (GPIOx_BOP, or for clearing only GPIOx_BC, or for toggle only
GPIOx_TG). The other bits will not be affected.
8.3.2.
External interrupt/event lines
All ports have external interrupt capability. To use external interrupt lines, the port must be
configured as input mode.
8.3.3.
Alternate functions (AF)
When the port is configured as AFIO (set CTLy bits to “0b10”, which is in GPIOx_CTL
registers), the port is used as peripheral alternate functions. Each port has sixteen alternate
functions can be configured by GPIO alternate functions selected registers (GPIOx_AFSELy
(y = 0,1)). The detail alternate function assignments for each port are in the device datasheet.
8.3.4.
Additional functions
Some pins have additional functions, which have priority over the configuration in the standard
GPIO registers. When for ADC , DAC, CMP or additional functions, the port must be
configured as analog mode. When for RTC, WKUPx and oscillators additional functions, the
port type is set automatically by related RTC, PMU and RCU registers. These ports can be
used as normal GPIO when the additional functions disabled.