Skip to content
esp-labsESP32-S3 bench guide
All blocks

System

GPIO and IO MUX

45 pins, and a matrix that routes almost any signal to almost any pin

runs on the board

Loading the 3D view…

  • IN
  • OUT
  • OE

Key facts

  • 45 GPIOs, numbered 0-21 and 26-48. Each one can be an input or an output.

    Technical reference §6.1

  • The GPIO matrix connects 175 peripheral inputs and 184 peripheral outputs to any pin. Fast signals (SPI, JTAG, UART) can skip it through the IO MUX for better timing.

    Technical reference §6.2

  • Each pin drives about 5, 10, 20 or 40 mA. The default is 20 mA (10 mA on GPIO17/18, 40 mA on GPIO19/20).

    Chip datasheet §C2.2

  • Internal pull-up and pull-down resistors are about 45 kΩ: fine for a button, too weak for a long I2C bus.

    Chip datasheet §C5.4

  • Inputs accept up to the supply plus 0.3 V. The pins are not 5 V tolerant.

    Chip datasheet §C5.4

  • A pin can be latched (held) so it keeps its level through a watchdog reset or deep sleep.

    Technical reference §6.9

Gotchas

Four pins are read at reset

GPIO0, GPIO3, GPIO45 and GPIO46 are sampled the moment the chip comes out of reset: they pick the boot mode, the flash voltage, the ROM log and the JTAG source. Anything wired to them must not pull them the wrong way at power-up. After reset they are normal pins again.

GPIO3 has no pull resistor at reset

GPIO0 has a weak pull-up and GPIO45/46 weak pull-downs, but GPIO3 floats. When the eFuses make it choose the JTAG source, an outside circuit has to hold it at a clear level.

GPIO47 and 48 run at 1.8 V on R16V modules

Modules with the ESP32-S3R16V chip set the flash voltage to 1.8 V, and GPIO47/48 share that supply. A 3.3 V part on those pins sees the wrong levels.

The pins are not 5 V tolerant

A high input may go up to the pin's supply plus 0.3 V, so about 3.6 V on a 3.3 V board, and the power pins are rated to 3.6 V at most. 5 V from a sensor or an Arduino can damage the chip: use a level shifter or a divider.

GPIO39-42 can be JTAG

MTCK, MTDO, MTDI and MTMS sit on GPIO39-42. They are free by default, since JTAG goes over USB, but an external debugger needs them.

Some pins blip low at power-up

GPIO1-20 output a short low level (about 60 µs) while the chip powers up, and GPIO18-20 also blip high. Do not drive a relay or a motor driver straight from them without a pull resistor.

GPIO17 and 18 count drive strength differently

On most pins drive level 1 means about 10 mA and 2 about 20 mA. On GPIO17 and 18 the two are swapped, so their default (level 2) gives about 10 mA, not 20.

Only GPIO0-21 can wake the chip from deep sleep

In deep sleep only the RTC domain stays on, so only the RTC GPIOs (0-21) can wake the chip. A button on GPIO38 will not.

In our labs

29 labs use this block, across 6 tracks. Open a track to see them.

  • done by you
  • runs on the board
  • built, not flashed
  • planned

Key registers

GPIO_OUT_W1TS_REGoffset 0x0008
GPIO_OUT_W1TS_REG
BitsFieldWhat it does
31:0GPIO_OUT_W1TSWrite a 1 to set that pin's output high (GPIO0-31). Bits written 0 are left alone.

Technical reference §6.15.1

GPIO_ENABLE_W1TS_REGoffset 0x0024
GPIO_ENABLE_W1TS_REG
BitsFieldWhat it does
31:0GPIO_ENABLE_W1TSWrite a 1 to turn that pin into an output (GPIO0-31).

Technical reference §6.15.1

GPIO_IN_REGoffset 0x003C
GPIO_IN_REG
BitsFieldWhat it does
31:0GPIO_IN_DATA_NEXTThe level on GPIO0-31, one bit per pin: 1 high, 0 low.

Technical reference §6.15.1

GPIO_FUNCx_OUT_SEL_CFG_REGoffset 0x0554 + 0x4·x
GPIO_FUNCx_OUT_SEL_CFG_REG
BitsFieldWhat it does
9GPIO_FUNCx_OUT_INV_SELInvert the output.
8:0GPIO_FUNCx_OUT_SELWhich peripheral output signal drives pin x. 256 means plain GPIO output.

Technical reference §6.15.1

IO_MUX_GPIOn_REGoffset 0x0004 + 4·n
IO_MUX_GPIOn_REG
BitsFieldWhat it does
14:12IO_MUX_MCU_SELWhich IO MUX function the pin takes (function 1 is GPIO on most pins).
11:10IO_MUX_FUN_DRVDrive strength: 0 is about 5 mA, 3 about 40 mA.
9IO_MUX_FUN_IEInput enabled.
8IO_MUX_FUN_WPUInternal pull-up on.
7IO_MUX_FUN_WPDInternal pull-down on.

Technical reference §6.15.2

Read the full sectionTechnical reference §6