How does a stm32f chip set its GPIO speed? (hardware, not register setting)

armgpiostm32

The speed of GPIO of a stm32 chip is set by register of OSPEEDR. It shows:

  • 00: Low speed
  • 01: Medium speed
  • 10: Fast speed (50MHz in library)
  • 11: High speed (100MHz in library)

My guess is that the speed is not related with the system clocks(AHB1) at all. It is just the physical property of the GPIO pin itself. Am I correct? Is it done by varying the output resistance of the pin or something?

The datasheet could be found here: http://www.st.com/stonline/stappl/resourceSelector/app?page=fullResourceSelector&doctype=datasheet&LineID=11

Best Answer

Generally this is done by having multiple different drivers for the line, of different sizes and therefore with varying output impedance. Recall the basic CMOS driver:

schematic

simulate this circuit – Schematic created using CircuitLab

Making the transistors larger increases their drive strength and lowers their on-resistance, but requires more charge to be moved on and off the gate when changing state. That results in increased power consumption.