Skip to content

ESP32-S2: pinMode() not working on certain pins #5947

@PaintYourDragon

Description

@PaintYourDragon

Hardware:

Board: Adafruit Feather ESP32-S2
Core Installation version: 2.0.1
IDE name: Arduino IDE

Description:

pinMode() has no effect on pins 9, 11 or A4. Other pins work as expected.
Replacing digitalWrite() with equivalent GPIO register accesses does not work; issue is likely in pinMode().
Replacing pinMode() with equivalent gpio_set_direction() call does work.
A different workaround, though I don’t know if this is universally correct fix or will break something else, is to edit esp32-hal-gpio.c and move line 41:
#define USE_ESP_IDF_GPIO 1
…up 2 lines so it’s in the CONFIG_IDF_TARGET_ESP32S2 condition rather than the #else. Test code then works on all pins.
(EDIT: perhaps it’s also still needed in the #else, I haven’t tested on “classic” ESP32 with the change)

Sketch:

// Just the standard Arduino blink, but on different pin. Also try 9 or A4:

void setup() {
  pinMode(11, OUTPUT);
}

void loop() {
  digitalWrite(11, HIGH);
  delay(100);
  digitalWrite(11, LOW);
  delay(100);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Peripherals APIRelates to peripheral's APIs.Chip: ESP32-S2Issue is related to support of ESP32-S2 ChipStatus: SolvedThe issue has been resolved and requires no further action.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions