STM32W108CB, STM32W108HB
General-purpose input/outputs
Doc ID 16252 Rev 3
8.1.6
GPIO modes
Analog mode
Analog mode enables analog functions, and disconnects a pin from the digital input and
output logic. Only the following GPIO pins have analog functions:
●
PA4, PA5, PB5, PB6, PB7, and PC1 can be analog inputs to the ADC.
●
PB0 can be an external analog voltage reference input to the ADC, or it can output the
internal analog voltage reference from the ADC.
●
PC6 and PC7 can connect to an optional 32.768 kHz crystal.
Note:
When an external timing source is required, a 32.768 kHz crystal is commonly connected to
PC6 and PC7. Alternatively, when PC7 is configured as a digital input, PC7 can accept a
digital external clock input.
When configured in analog mode:
●
The output drivers are disabled.
●
The internal pull-up and pull-down resistors are disabled.
●
The Schmitt trigger input is connected to a high logic level.
●
Reading GPIO_PxIN returns a constant 1.
Input mode
Input mode is used both for general purpose input and for on-chip peripheral inputs. Input
floating mode disables the internal pull-up and pull-down resistors, leaving the pin in a high-
impedance state. Input pull-up or pull-down mode enables either an internal pull-up or pull-
down resistor based on the GPIO_PxOUT register. Setting a bit to 0 in GPIO_PxOUT
enables the pull-down and setting a bit to 1 enables the pull up.
When configured in input mode:
●
The output drivers are disabled.
●
An internal pull-up or pull-down resistor may be activated depending on
GPIO_PxCFGH/L and GPIO_PxOUT.
●
The Schmitt trigger input is connected to the pin.
●
Reading GPIO_PxIN returns the input at the pin.
●
The input is also available to on-chip peripherals.
Output mode
Output mode provides a general purpose output under direct software control. Regardless
of whether an output is configured as push-pull or open-drain, the GPIO's bit in the
GPIO_PxOUT register controls the output. The GPIO_PxSET and GPIO_PxCLR registers
can atomically set and clear bits within GPIO_PxOUT register. These set and clear registers
simplify software using the output port because they eliminate the need to disable interrupts
to perform an atomic read-modify-write operation of GPIO_PxOUT.