Skip to content

multiple pinmode calls to the same Pin disable the pin completely #11628

@vladtepesch

Description

@vladtepesch

Board

ESP Wroom 32 38 Pin Dev Board (ESP Node MCU)

Device Description

ESP Wroom 32 - 38 Pin Dev Board (ESP Node MCU)
Nothing special

Hardware Configuration

only RGB LED to pins 5,4,0

Version

v3.2.0

IDE Name

VS Code PlatformIO

Operating System

Win 11

Flash frequency

OTA

PSRAM enabled

yes

Upload speed

does not matter

Description

when calling pinMode a second time after a call of analogWrite the pin seems not to work anymore. Any further analogWrite do not seem to do anything.

It seems that this is a change to previous versions, because the same code worked a couple of years ago

platformio uses get the following packages:

PLATFORM: Espressif 32 (5.3.0) > uPesy ESP32 Wroom DevKit
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20006.221224 (2.0.6)
 - tool-esptoolpy @ 1.40400.0 (4.4.0)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5

Sketch

#define LED_R 5

void setup(){
  pinMode(LED_R, OUTPUT);
  analogWrite(LED_R, 100); // if this line is removed - it works
  pinMode(LED_R, OUTPUT);
}
void loop(){
  static int val = 0;
  delay(2000);
  analogWrite(LED_R, val);
  val += 20; 
  if(val > 200) {
    val = 0;
  }
}

Debug Message

no thing to post

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions