STM32 gotchas
84.GPIO pin does not output enough current (if set to low GPIO_OSPEEDR setting)

For each IO pin, the GPIO module has a set of registers, which determine their exact behaviour. One of these is the OSPEEDR register determining the "output speed" of the pin (when set as Output, or when set as Alternate Function and the controlling peripherals turns it to Output). More precisely, OSPEEDR influences the slew rate of the output signal when switching, by activating one or more MOSFET output transistors of varying dimensions (hence varying resistance). The resulting slew rate of the signal's edge is then given by multiple of the resulting total channel resistance and the loading (usually parasitic) capacitance on the given pin, connected tracks and other circuits.

While some high-speed circuits demand to have very high slew rates, setting all pins indiscriminately to high slew rate is a bad idea, as these generally result in increased high frequency emissions, transmission-line effects such as reflections, increased signal crosstalk and effects arising from imperfect ground. STM32 thus generally have by default the OSPEEDR settings set to the lowest range (there are individual exceptions, e.g. the SWI/JTAG pins).

However, OSPEEDR setting has also a different, maybe less expected effect: as OSPEEDR effectively influences total output resistance, it also means that it also determines the maximum output current to be drawn for given pin. The DS does not account for this effect and for most STM32 (except some pins like those which are supplied through the backup-domain switch) it gives an universal figure of maximum output current of 8mA or 20mA at degraded output voltage, without mentioning that this current is achievable only at higher OSPEEDR settings.

This may come as a surprise if the user attempts to supply higher current from an IO pin, e.g. to drive a LED in an optocoupler.