ESP32 GPIO drive strength

mgiacomelli
Posts: 3
Joined: Tue Jun 10, 2025 12:59 pm

ESP32 GPIO drive strength

Postby mgiacomelli » Tue Jun 10, 2025 1:12 pm

Based on some posts here (e.g. viewtopic.php?f=2&t=2027), I expected that the GPIO drive strength current limits should adjust the GPIO output impedance, which could be used to optimize signal/noise on digital IO lines. To confirm this, I measured the output impedance by hooking an ESP32 up to a 75 ohm coax cable and fast oscilloscope. I then recorded the rise time and reflection coefficient and backed out the source impedance.

Surprisingly the rise time (16 ns) and source impedance (30 ohms) are constant for all settings of drive strength, at least on my ESP-WROOM-32 development board. I used ESPHome as an easy way to test since it exposes this setting for its GPIO. Looking at the source code, gpio_set_drive_capability which I think looks ok so I don't think this is an ESPHome issue.

Before I spend a lot more time testing more, what is the "drive strength" setting expected to do? Is it just a current limiter that kicks in after a delay or does it actually parallel more output stage drivers to supply more current? The documentation says it sets the "drive capability of the pad", which certainly sounds like it should have some measurable effect.

mgiacomelli
Posts: 3
Joined: Tue Jun 10, 2025 12:59 pm

Re: ESP32 GPIO drive strength

Postby mgiacomelli » Sun Jun 15, 2025 2:15 am

To eliminate ESPHome as a variable, I installed ESP-IDF 5.4.1 and wrote a simple program that changes the drive strength:

Code: Select all

#include "driver/gpio.h"

void app_main(void)
{
    gpio_num_t gpio_num = GPIO_NUM_4;


    gpio_dump_io_configuration(stdout, (1ULL << GPIO_NUM_4));

    // Configure the GPIO as output
    gpio_set_direction(gpio_num, GPIO_MODE_OUTPUT);

    // Set drive strength to maximum
    int ret = gpio_set_drive_capability(gpio_num, GPIO_DRIVE_CAP_3);
    printf("Drive strength returned: %d\n", ret);


    gpio_dump_io_configuration(stdout, (1ULL << GPIO_NUM_4));

}
Running on an ESP32 gives:
================IO DUMP Start================
IO[4] -
Pullup: 0, Pulldown: 1, DriveCap: 2
InputEn: 1, OutputEn: 0, OpenDrain: 0
FuncSel: 0 (IOMUX)
SleepSelEn: 0

=================IO DUMP End==================
Drive strength returned: 0
================IO DUMP Start================
IO[4] -
Pullup: 0, Pulldown: 1, DriveCap: 2
InputEn: 0, OutputEn: 1, OpenDrain: 0
FuncSel: 0 (IOMUX)
SleepSelEn: 0

=================IO DUMP End==================
The IO switches to output (OutputEN = 1), but DriveCap does not. Am I missing something?

mgiacomelli
Posts: 3
Joined: Tue Jun 10, 2025 12:59 pm

Re: ESP32 GPIO drive strength

Postby mgiacomelli » Sun Jun 15, 2025 6:17 pm

On further investigation, the drive strength setting does work on the ESP32, but gpio_dump_io_configuration does not reflect the updated values (always returns 2 even if value is different). Testing on the ESP32-C3, gpio_dump_io_configuration does detect the changed value, so perhaps this is some errata on my board.

If anyone was wondering, here are the output impedances I measured:

Code: Select all

ESP32:
GPIO_DRIVE_CAP_3		11 ohms
GPIO_DRIVE_CAP_2		30 ohms
GPIO_DRIVE_CAP_1		76 ohms
GPIO_DRIVE_CAP_0		84 ohms

ESP32-C3:
GPIO_DRIVE_CAP_3		12 ohms
GPIO_DRIVE_CAP_2		27 ohms
GPIO_DRIVE_CAP_1		75 ohms
GPIO_DRIVE_CAP_0		90 ohms

Essentially both chips have the same impedances.

I'm still unsure why I couldn't set the impedance in ESPHome.

Who is online

Users browsing this forum: ChatGPT-User, PetalBot, Qwantbot and 5 guests