ESP32 - Understanding IO_MUX_x_REG
Posted: Thu May 29, 2025 12:20 pm
Hello folks,
I'm trying to implement my own baremetal solution to setup the GPIO pins on ESP32, but unfortunately I've come up across a confusion when reading the SoC documentation.
I want to implement a generic function to get the IO_MUX_GPIOX_REG address, in order to properly control it.
Referring to the Register 6.34 section, we have the following description:

That shows on parenthesis how to calculate the register address relative to the IO MUX base, as specified by the section 6.13.2:
From the table 3.3-6, we have the IO MUX base address to be 0x3FF49000.
So, I was expecting that if, for example, I wanted the address for IO_MUX_GPIO0_REG, I should calculate 0x3FF49000 + 0x10 + 4 * 0, which is 0x3FF49010.
But instead, the IO_MUX_GPIO0_REG is mapped to 0x3FF49044 according to Table 6.12-2.

What I'm getting wrong about the formula on Register 6.34? There's any way to write one that generalizes it without having to write my own Lookup Table?
I'm trying to implement my own baremetal solution to setup the GPIO pins on ESP32, but unfortunately I've come up across a confusion when reading the SoC documentation.
I want to implement a generic function to get the IO_MUX_GPIOX_REG address, in order to properly control it.
Referring to the Register 6.34 section, we have the following description:

That shows on parenthesis how to calculate the register address relative to the IO MUX base, as specified by the section 6.13.2:
6.13.2 IO MUX Registers
The addresses in parenthesis besides register names are the register addresses relative to the IO MUX base
addresses provided in Table 3.3-6 Peripheral Address Mapping in Chapter 3 System and Memory. The
absolute register addresses are listed in Section 6.12.2 IO MUX Register Summary.
From the table 3.3-6, we have the IO MUX base address to be 0x3FF49000.
So, I was expecting that if, for example, I wanted the address for IO_MUX_GPIO0_REG, I should calculate 0x3FF49000 + 0x10 + 4 * 0, which is 0x3FF49010.
But instead, the IO_MUX_GPIO0_REG is mapped to 0x3FF49044 according to Table 6.12-2.

What I'm getting wrong about the formula on Register 6.34? There's any way to write one that generalizes it without having to write my own Lookup Table?