Page 1
STM32 32-bit Arm ® Cortex MCUs using the GPIO pin. This application note must be used in conjunction with the related STM32 reference manual and datasheet available at www.st.com. March 2022 AN4899 Rev 3 1/31 www.st.com...
General information AN4899 General information ®(a) ® STM32 microcontrollers are based on the Arm Cortex processor. Documentation conventions Glossary This section defines the main acronyms and abbreviations used in this document. AMR: absolute maximum rating GPIO: general-purpose input output general-purpose...
GPIO alternate function high register GPIOx_ASCR: GPIO port analog switch control register GPIO main features STM32 GPIO exhibits the following features: • Output states: push-pull, or open drain + pull-up / pull-down according to GPIOx_MODER, GPIOx_OTYPER, and GPIOx_PUPDR registers settings •...
PB1 I/O: port B bit 1 input / output – FT: five-volt tolerant Before starting a board design, it is important to refer to the datasheet of the STM32 product or to the STM32CubeMX tool to check for GPIO availability in coherence with the target application.
2, the analog switch in the dotted square is optional. Its presence depends on the STM32 product considered. The analog switch is controlled by enabling analog peripheral on the given pin (not by setting the GPIO in the analog mode). Refer to the product datasheet for details.
This section describes the possible GPIO pin configurations available in STM32 devices. 4.3.1 Input mode configuration When a STM32 device I/O pin is configured as input, one of three options must be selected: • Input with internal pull-up. Pull-up resistors are used in STM32 devices to ensure a well-defined logical level in case of floating input signal.
AHB clock cycle Open-drain output is often used to control devices which operate at a different voltage supply than the STM32. Open-drain mode is also used to drive one or several I C devices when specific pull-up resistors are required.
4.3.4 Analog configuration Few STM32 GPIO pins can be configured in analog mode which allows the use of ADC, DAC, OPAMP, and COMP internal peripherals. To use a GPIO pin in analog mode, the following register are considered: •...
GPIO electrical characteristics and definitions GPIO electrical characteristics and definitions This chapter defines and explains some of the electrical parameters in STM32 datasheets. GPIO general information The following sections detail some of the electrical parameters in the datasheets as a function of their use from an application point of view.
The GPIO speed has no impact on the dynamic current consumption. 5.1.4 Voltage output and current drive All STM32 GPIOs are CMOS and TTL compliant and are able to source or sink current from external pin. Figure 3 shows the current flow according to the output level selected. I sourced current when GPIO output is in High state.
Ouput control ‘0’ MSv46874V2 In case of communication exchange, STM32 output signals must be compatible with the of the receptor device and STM32 inputs must be compliant with the V the transmitter device as shown in Figure Figure 4. Logical level compatibility...
Each STM32 GPIO offers the possibility to select internal pull-up and pull-down (typical value = 40 kOhm). Some STM32 applications may require to use an external pull-up resistor. This section presents output and input levels compatibility and the way to calculate the appropriate pull-up resistor when the STM32 GPIO open-drain output is connected to an external device.
GPIO. Capability represents the voltage value which can be output by the GPIO. 5.2.1 Three-volt tolerant GPIO (TT) For some STM32, electrical specifications define GPIO as three-volt tolerant or three-volt compliant. From the user point of view, there is no difference between these two kinds of GPIO.
A white LED needs a typical ~20 mA current under typical 3.5 V supply (4 V max.). As STM32 devices maximum sink current is 25 mA, there is not enough margin to directly drive a LED. Two options, using an external MOSFET (or BJT) or driving by means of two...
GPIO must be set up in open-drain mode. If the I/O drive current is not sufficient, coupled GPIOs can be used in parallel. 5.3.3 C application The STM32 device supplied by 1.8 V or 3.3 V can directly communicate with a 5 V I C bus as illustrated in Figure Figure 8.
< 0.8 V and V > 2.0 V. This implies that a 3.3 V CMOS output can drive without any problem. An STM32 FT pad can accept 0 V to 5 V CMOS level input when V = 3.3 V.
= 3.3 V (example) STM32 VBUS MSv46882V1 If the STM32 supply is provided by an LDO supplied by VBUS, it is recommended to use a Zenner diode (ex. 3.3 V) as illustrated in Figure Figure 12. Example of V to V power supply 3.3 V...
The parasitic diodes are not characterized for reliability. STMicroelectronics does not guarantee the level of current which those diodes can accept. Work around proposal If there is an unused FT pad available on the STM32 device, connect it to the ADC input pad with parallel configuration as illustrated in Figure Figure 14.
The example provided in Figure 15 shows the leakage current induced by the internal pull- up resistor when the STM32 and the driving buffer are not supplied with the same V source. The pink arrow marks the leakage current path. AN4899 Rev 3...
If V is not present, for example grounded, the maximum voltage must not exceed 3.6 V (the exact limit value is provided in the STM32 datasheet). Warning: If the external voltage exceeds the maximum voltage value, the STM32 device can be damaged.
Analog Digital output Internal ground STM32 MSv46888V1 Using the MCO clock output Clock signals can be a major factor of high current consumption. Specific attention must be paid to all input and output clocks related to the MCU or to other components on the board.
Debug pins have PU or PD by default Some pins are by default programmed as inputs with PU or PD (see STM32 datasheet for the related GPIO). If these pins are used for other purposes, it must be avoided to force a 0 while PU or a 1 while PD, as this causes extra consumption.
In order to help users to control the signal integrity in their applications, the IBIS model of the selected STM32 GPIO pin is available and can be downloaded from STMicroelectronics web site at www.st.com.
GPIO selection guide and configuration AN4899 GPIO selection guide and configuration The flowchart presented in Figure 18 Figure 19 provides users with a quick help to select the GPIO mode and configuration adapted to their application. Figure 18. GPIO configuration flowchart (1 of 2) General recommendations No floating pins No pins driving in opposite...
AN4899 GPIO selection guide and configuration Figure 19. GPIO configuration flowchart (2 of 2) Is the GPIO pin configured as External output stage must be digital output? analyzed. The GPIO is connected to a specific hardware output which can require Hi-Z input, input Is the GPIO output connected with pull-up / pull-down resistor, to an external floating or to a...
Revision history AN4899 Revision history Table 2. Document revision history Date Revision Changes 21-Sep-2017 Initial release. Updated the document title. Added a note to Section 5.2.1: Three-volt tolerant GPIO (TT) Section 5.2.2: Five-volt tolerant GPIO (FT) about the maximum operating voltage when an analog 12-Aug-2021 input function is enabled.
Page 31
ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgment.
Need help?
Do you have a question about the STM32 and is the answer not in the manual?
Questions and answers